Skip to content

Commit b8f4603

Browse files
authored
Merge pull request #354 from InjectiveLabs/feat/add_support_exchange_v2
Feat/add support exchange v2
2 parents c78af17 + de24ebd commit b8f4603

File tree

346 files changed

+28516
-3685
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

346 files changed

+28516
-3685
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
All notable changes to this project will be documented in this file.
44

55
## [Unreleased] - 9999-99-99
6+
### Added
7+
- Added support for Exchange V2 proto queries and types
8+
- Updated all chain exchange module examples to use the new Exchange V2 proto queries and types
9+
10+
### Removed
11+
- Removed all methods marked as deprecated in AsyncClient and Composer
612

713
## [1.10.0] - 2025-04-16
814
### Added

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ gen-client: clone-all copy-proto
99
$(call clean_repos)
1010
$(MAKE) fix-generated-proto-imports
1111

12-
PROTO_MODULES := cosmwasm exchange gogoproto cosmos_proto cosmos testpb ibc amino tendermint injective
12+
PROTO_MODULES := cosmwasm exchange gogoproto cosmos_proto cosmos testpb ibc amino tendermint cometbft injective
1313

1414
fix-generated-proto-imports:
1515
@touch pyinjective/proto/__init__.py
@@ -31,7 +31,7 @@ clean-all:
3131
$(call clean_repos)
3232

3333
clone-injective-indexer:
34-
git clone https://github.com/InjectiveLabs/injective-indexer.git -b v1.15.6 --depth 1 --single-branch
34+
git clone https://github.com/InjectiveLabs/injective-indexer.git -b v1.16.0-rc2 --depth 1 --single-branch
3535

3636
clone-all: clone-injective-indexer
3737

buf.gen.yaml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,21 @@ inputs:
1111
- module: buf.build/cosmos/gogo-proto
1212
- module: buf.build/googleapis/googleapis
1313
- module: buf.build/cosmos/ics23
14-
- git_repo: https://github.com/InjectiveLabs/cosmos-sdk
15-
tag: v0.50.9-inj.5
1614
- git_repo: https://github.com/InjectiveLabs/ibc-go
17-
tag: v8.7.0-inj
15+
tag: v8.7.0-evm-comet1-inj
1816
- git_repo: https://github.com/InjectiveLabs/wasmd
19-
tag: v0.53.2-inj.2
17+
tag: v0.53.2-evm-comet1-inj
18+
- git_repo: https://github.com/InjectiveLabs/cometbft
19+
tag: v1.0.1-inj
20+
- git_repo: https://github.com/InjectiveLabs/cosmos-sdk
21+
tag: v0.50.13-evm-comet1-inj.2
2022
# - git_repo: https://github.com/InjectiveLabs/wasmd
2123
# branch: v0.51.x-inj
2224
# subdir: proto
2325
- git_repo: https://github.com/InjectiveLabs/injective-core
24-
tag: v1.15.0
26+
tag: v1.16.0-beta.2
2527
subdir: proto
2628
# - git_repo: https://github.com/InjectiveLabs/injective-core
27-
# branch: release/v1.15.x
29+
# branch: master
2830
# subdir: proto
2931
- directory: proto

examples/chain_client/1_LocalOrderHash.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ async def main() -> None:
4141
fee_recipient = "inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r"
4242

4343
spot_orders = [
44-
composer.spot_order(
44+
composer.create_spot_order_v2(
4545
market_id=spot_market_id,
4646
subaccount_id=subaccount_id,
4747
fee_recipient=fee_recipient,
@@ -50,7 +50,7 @@ async def main() -> None:
5050
order_type="BUY",
5151
cid=str(uuid.uuid4()),
5252
),
53-
composer.spot_order(
53+
composer.create_spot_order_v2(
5454
market_id=spot_market_id,
5555
subaccount_id=subaccount_id,
5656
fee_recipient=fee_recipient,
@@ -62,7 +62,7 @@ async def main() -> None:
6262
]
6363

6464
derivative_orders = [
65-
composer.derivative_order(
65+
composer.create_derivative_order_v2(
6666
market_id=deriv_market_id,
6767
subaccount_id=subaccount_id,
6868
fee_recipient=fee_recipient,
@@ -74,7 +74,7 @@ async def main() -> None:
7474
order_type="BUY",
7575
cid=str(uuid.uuid4()),
7676
),
77-
composer.derivative_order(
77+
composer.create_derivative_order_v2(
7878
market_id=deriv_market_id,
7979
subaccount_id=subaccount_id,
8080
fee_recipient=fee_recipient,
@@ -89,9 +89,9 @@ async def main() -> None:
8989
]
9090

9191
# prepare tx msg
92-
spot_msg = composer.msg_batch_create_spot_limit_orders(sender=address.to_acc_bech32(), orders=spot_orders)
92+
spot_msg = composer.msg_batch_create_spot_limit_orders_v2(sender=address.to_acc_bech32(), orders=spot_orders)
9393

94-
deriv_msg = composer.msg_batch_create_derivative_limit_orders(
94+
deriv_msg = composer.msg_batch_create_derivative_limit_orders_v2(
9595
sender=address.to_acc_bech32(), orders=derivative_orders
9696
)
9797

@@ -178,7 +178,7 @@ async def main() -> None:
178178
print("gas fee: {} INJ".format(gas_fee))
179179

180180
spot_orders = [
181-
composer.spot_order(
181+
composer.create_spot_order_v2(
182182
market_id=spot_market_id,
183183
subaccount_id=subaccount_id_2,
184184
fee_recipient=fee_recipient,
@@ -187,7 +187,7 @@ async def main() -> None:
187187
order_type="BUY_PO",
188188
cid=str(uuid.uuid4()),
189189
),
190-
composer.spot_order(
190+
composer.create_spot_order_v2(
191191
market_id=spot_market_id,
192192
subaccount_id=subaccount_id_2,
193193
fee_recipient=fee_recipient,
@@ -199,7 +199,7 @@ async def main() -> None:
199199
]
200200

201201
derivative_orders = [
202-
composer.derivative_order(
202+
composer.create_derivative_order_v2(
203203
market_id=deriv_market_id,
204204
subaccount_id=subaccount_id_2,
205205
fee_recipient=fee_recipient,
@@ -211,7 +211,7 @@ async def main() -> None:
211211
order_type="BUY",
212212
cid=str(uuid.uuid4()),
213213
),
214-
composer.derivative_order(
214+
composer.create_derivative_order_v2(
215215
market_id=deriv_market_id,
216216
subaccount_id=subaccount_id_2,
217217
fee_recipient=fee_recipient,
@@ -226,9 +226,9 @@ async def main() -> None:
226226
]
227227

228228
# prepare tx msg
229-
spot_msg = composer.msg_batch_create_spot_limit_orders(sender=address.to_acc_bech32(), orders=spot_orders)
229+
spot_msg = composer.msg_batch_create_spot_limit_orders_v2(sender=address.to_acc_bech32(), orders=spot_orders)
230230

231-
deriv_msg = composer.msg_batch_create_derivative_limit_orders(
231+
deriv_msg = composer.msg_batch_create_derivative_limit_orders_v2(
232232
sender=address.to_acc_bech32(), orders=derivative_orders
233233
)
234234

examples/chain_client/2_StreamEventOrderFail.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ async def main() -> None:
1111
network = Network.mainnet()
1212
event_filter = (
1313
"tm.event='Tx' AND message.sender='inj1rwv4zn3jptsqs7l8lpa3uvzhs57y8duemete9e' "
14-
"AND message.action='/injective.exchange.v1beta1.MsgBatchUpdateOrders' "
15-
"AND injective.exchange.v1beta1.EventOrderFail.flags EXISTS"
14+
"AND message.action='/injective.exchange.v2.MsgBatchUpdateOrders' "
15+
"AND injective.exchange.v2.EventOrderFail.flags EXISTS"
1616
)
1717
query = json.dumps(
1818
{
@@ -32,8 +32,8 @@ async def main() -> None:
3232
if result == {}:
3333
continue
3434

35-
failed_order_hashes = json.loads(result["events"]["injective.exchange.v1beta1.EventOrderFail.hashes"][0])
36-
failed_order_codes = json.loads(result["events"]["injective.exchange.v1beta1.EventOrderFail.flags"][0])
35+
failed_order_hashes = json.loads(result["events"]["injective.exchange.v2.EventOrderFail.hashes"][0])
36+
failed_order_codes = json.loads(result["events"]["injective.exchange.v2.EventOrderFail.flags"][0])
3737

3838
dict = {}
3939
for i, order_hash in enumerate(failed_order_hashes):

examples/chain_client/3_MessageBroadcaster.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ async def main() -> None:
4545
spot_market_id_create = "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe"
4646

4747
spot_orders_to_create = [
48-
composer.spot_order(
48+
composer.create_spot_order_v2(
4949
market_id=spot_market_id_create,
5050
subaccount_id=subaccount_id,
5151
fee_recipient=fee_recipient,
@@ -54,7 +54,7 @@ async def main() -> None:
5454
order_type="BUY",
5555
cid=(str(uuid.uuid4())),
5656
),
57-
composer.spot_order(
57+
composer.create_spot_order_v2(
5858
market_id=spot_market_id_create,
5959
subaccount_id=subaccount_id,
6060
fee_recipient=fee_recipient,
@@ -66,7 +66,7 @@ async def main() -> None:
6666
]
6767

6868
# prepare tx msg
69-
msg = composer.msg_batch_update_orders(
69+
msg = composer.msg_batch_update_orders_v2(
7070
sender=address.to_acc_bech32(),
7171
spot_orders_to_create=spot_orders_to_create,
7272
)

examples/chain_client/4_MessageBroadcasterWithGranteeAccount.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ async def main() -> None:
4848
granter_address = Address.from_acc_bech32(granter_inj_address)
4949
granter_subaccount_id = granter_address.get_subaccount_id(index=0)
5050

51-
msg = composer.msg_create_spot_limit_order(
51+
msg = composer.msg_create_spot_limit_order_v2(
5252
market_id=market_id,
5353
sender=granter_inj_address,
5454
subaccount_id=granter_subaccount_id,

examples/chain_client/5_MessageBroadcasterWithoutSimulation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ async def main() -> None:
4646
spot_market_id_create = "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe"
4747

4848
spot_orders_to_create = [
49-
composer.spot_order(
49+
composer.create_spot_order_v2(
5050
market_id=spot_market_id_create,
5151
subaccount_id=subaccount_id,
5252
fee_recipient=fee_recipient,
@@ -55,7 +55,7 @@ async def main() -> None:
5555
order_type="BUY",
5656
cid=str(uuid.uuid4()),
5757
),
58-
composer.spot_order(
58+
composer.create_spot_order_v2(
5959
market_id=spot_market_id_create,
6060
subaccount_id=subaccount_id,
6161
fee_recipient=fee_recipient,
@@ -67,7 +67,7 @@ async def main() -> None:
6767
]
6868

6969
# prepare tx msg
70-
msg = composer.msg_batch_update_orders(
70+
msg = composer.msg_batch_update_orders_v2(
7171
sender=address.to_acc_bech32(),
7272
spot_orders_to_create=spot_orders_to_create,
7373
)

examples/chain_client/6_MessageBroadcasterWithGranteeAccountWithoutSimulation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ async def main() -> None:
4646
granter_address = Address.from_acc_bech32(granter_inj_address)
4747
granter_subaccount_id = granter_address.get_subaccount_id(index=0)
4848

49-
msg = composer.msg_create_spot_limit_order(
49+
msg = composer.msg_create_spot_limit_order_v2(
5050
market_id=market_id,
5151
sender=granter_inj_address,
5252
subaccount_id=granter_subaccount_id,

examples/chain_client/7_ChainStream.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,29 +31,29 @@ async def main() -> None:
3131
inj_usdt_market = "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe"
3232
inj_usdt_perp_market = "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6"
3333

34-
bank_balances_filter = composer.chain_stream_bank_balances_filter(
34+
bank_balances_filter = composer.chain_stream_bank_balances_v2_filter(
3535
accounts=["inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r"]
3636
)
37-
subaccount_deposits_filter = composer.chain_stream_subaccount_deposits_filter(subaccount_ids=[subaccount_id])
38-
spot_trades_filter = composer.chain_stream_trades_filter(subaccount_ids=["*"], market_ids=[inj_usdt_market])
39-
derivative_trades_filter = composer.chain_stream_trades_filter(
37+
subaccount_deposits_filter = composer.chain_stream_subaccount_deposits_v2_filter(subaccount_ids=[subaccount_id])
38+
spot_trades_filter = composer.chain_stream_trades_v2_filter(subaccount_ids=["*"], market_ids=[inj_usdt_market])
39+
derivative_trades_filter = composer.chain_stream_trades_v2_filter(
4040
subaccount_ids=["*"], market_ids=[inj_usdt_perp_market]
4141
)
42-
spot_orders_filter = composer.chain_stream_orders_filter(
42+
spot_orders_filter = composer.chain_stream_orders_v2_filter(
4343
subaccount_ids=[subaccount_id], market_ids=[inj_usdt_market]
4444
)
45-
derivative_orders_filter = composer.chain_stream_orders_filter(
45+
derivative_orders_filter = composer.chain_stream_orders_v2_filter(
4646
subaccount_ids=[subaccount_id], market_ids=[inj_usdt_perp_market]
4747
)
48-
spot_orderbooks_filter = composer.chain_stream_orderbooks_filter(market_ids=[inj_usdt_market])
49-
derivative_orderbooks_filter = composer.chain_stream_orderbooks_filter(market_ids=[inj_usdt_perp_market])
50-
positions_filter = composer.chain_stream_positions_filter(
48+
spot_orderbooks_filter = composer.chain_stream_orderbooks_v2_filter(market_ids=[inj_usdt_market])
49+
derivative_orderbooks_filter = composer.chain_stream_orderbooks_v2_filter(market_ids=[inj_usdt_perp_market])
50+
positions_filter = composer.chain_stream_positions_v2_filter(
5151
subaccount_ids=[subaccount_id], market_ids=[inj_usdt_perp_market]
5252
)
53-
oracle_price_filter = composer.chain_stream_oracle_price_filter(symbols=["INJ", "USDT"])
53+
oracle_price_filter = composer.chain_stream_oracle_price_v2_filter(symbols=["INJ", "USDT"])
5454

5555
task = asyncio.get_event_loop().create_task(
56-
client.listen_chain_stream_updates(
56+
client.listen_chain_stream_v2_updates(
5757
callback=chain_stream_event_processor,
5858
on_end_callback=stream_closed_processor,
5959
on_status_callback=stream_error_processor,

examples/chain_client/authz/1_MsgGrant.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ async def main() -> None:
3838
msg = composer.MsgGrantGeneric(
3939
granter=address.to_acc_bech32(),
4040
grantee=grantee_public_address,
41-
msg_type="/injective.exchange.v1beta1.MsgCreateSpotLimitOrder",
41+
msg_type="/injective.exchange.v2.MsgCreateSpotLimitOrder",
4242
expire_in=31536000, # 1 year
4343
)
4444

examples/chain_client/authz/2_MsgExec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ async def main() -> None:
3838

3939
granter_address = Address.from_acc_bech32(granter_inj_address)
4040
granter_subaccount_id = granter_address.get_subaccount_id(index=0)
41-
msg0 = composer.msg_create_spot_limit_order(
41+
msg0 = composer.msg_create_spot_limit_order_v2(
4242
sender=granter_inj_address,
4343
market_id=market_id,
4444
subaccount_id=granter_subaccount_id,

examples/chain_client/authz/3_MsgRevoke.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ async def main() -> None:
3434
msg = composer.MsgRevoke(
3535
granter=address.to_acc_bech32(),
3636
grantee=grantee_public_address,
37-
msg_type="/injective.exchange.v1beta1.MsgCreateSpotLimitOrder",
37+
msg_type="/injective.exchange.v2.MsgCreateSpotLimitOrder",
3838
)
3939

4040
# build sim tx

examples/chain_client/authz/query/1_Grants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ async def main() -> None:
1414

1515
network = Network.testnet()
1616
client = AsyncClient(network)
17-
msg_type_url = "/injective.exchange.v1beta1.MsgCreateDerivativeLimitOrder"
17+
msg_type_url = "/injective.exchange.v2.MsgCreateDerivativeLimitOrder"
1818
authorizations = await client.fetch_grants(granter=granter, grantee=grantee, msg_type_url=msg_type_url)
1919
print(authorizations)
2020

examples/chain_client/bank/1_MsgSend.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ async def main() -> None:
3030
await client.fetch_account(address.to_acc_bech32())
3131

3232
# prepare tx msg
33-
msg = composer.MsgSend(
33+
msg = composer.msg_send(
3434
from_address=address.to_acc_bech32(),
3535
to_address="inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r",
36-
amount=0.000000000000000001,
37-
denom="INJ",
36+
amount=1,
37+
denom="inj",
3838
)
3939

4040
# build sim tx

examples/chain_client/exchange/10_MsgCreateDerivativeLimitOrder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ async def main() -> None:
3737
fee_recipient = "inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r"
3838

3939
# prepare tx msg
40-
msg = composer.msg_create_derivative_limit_order(
40+
msg = composer.msg_create_derivative_limit_order_v2(
4141
sender=address.to_acc_bech32(),
4242
market_id=market_id,
4343
subaccount_id=subaccount_id,

examples/chain_client/exchange/11_MsgCreateDerivativeMarketOrder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ async def main() -> None:
3737
fee_recipient = "inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r"
3838

3939
# prepare tx msg
40-
msg = composer.msg_create_derivative_market_order(
40+
msg = composer.msg_create_derivative_market_order_v2(
4141
sender=address.to_acc_bech32(),
4242
market_id=market_id,
4343
subaccount_id=subaccount_id,

examples/chain_client/exchange/12_MsgCancelDerivativeOrder.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,14 @@ async def main() -> None:
3535
order_hash = "0x667ee6f37f6d06bf473f4e1434e92ac98ff43c785405e2a511a0843daeca2de9"
3636

3737
# prepare tx msg
38-
msg = composer.msg_cancel_derivative_order(
39-
sender=address.to_acc_bech32(), market_id=market_id, subaccount_id=subaccount_id, order_hash=order_hash
38+
msg = composer.msg_cancel_derivative_order_v2(
39+
sender=address.to_acc_bech32(),
40+
market_id=market_id,
41+
subaccount_id=subaccount_id,
42+
order_hash=order_hash,
43+
is_buy=True,
44+
is_market_order=False,
45+
is_conditional=False,
4046
)
4147

4248
# build sim tx

examples/chain_client/exchange/13_MsgInstantBinaryOptionsMarketLaunch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ async def main() -> None:
4141
await client.fetch_account(address.to_acc_bech32())
4242

4343
# prepare tx msg
44-
message = composer.msg_instant_binary_options_market_launch(
44+
message = composer.msg_instant_binary_options_market_launch_v2(
4545
sender=address.to_acc_bech32(),
4646
ticker="UFC-KHABIB-TKO-05/30/2023",
4747
oracle_symbol="UFC-KHABIB-TKO-05/30/2023",

0 commit comments

Comments
 (0)