Skip to content

Commit e42bd38

Browse files
committed
(feat) Updated proto definitions to injective-core v1.17.0-beta.3 and indexer v1.17.0-beta
1 parent 226c092 commit e42bd38

File tree

90 files changed

+6497
-1318
lines changed

Some content is hidden

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

90 files changed

+6497
-1318
lines changed

Makefile

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,14 @@ fix-generated-proto-imports:
1919
@find ./pyinjective/proto -type f -name "*.py" -exec sed -i "" -e "s/from google.api/from pyinjective.proto.google.api/g" {} \;
2020

2121
define clean_repos
22-
rm -Rf cosmos-sdk
23-
rm -Rf ibc-go
24-
rm -Rf cometbft
25-
rm -Rf wasmd
26-
rm -Rf injective-core
2722
rm -Rf injective-indexer
2823
endef
2924

3025
clean-all:
3126
$(call clean_repos)
3227

3328
clone-injective-indexer:
34-
git clone https://github.com/InjectiveLabs/injective-indexer.git -b v1.16.91 --depth 1 --single-branch
29+
git clone https://github.com/InjectiveLabs/injective-indexer.git -b v1.17.0-beta --depth 1 --single-branch
3530

3631
clone-all: clone-injective-indexer
3732

buf.gen.yaml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,21 @@ inputs:
1212
- module: buf.build/googleapis/googleapis
1313
- module: buf.build/cosmos/ics23
1414
- git_repo: https://github.com/InjectiveLabs/ibc-go
15-
tag: v8.7.0-evm-comet1-inj
15+
tag: v8.7.0-inj.3
1616
- git_repo: https://github.com/InjectiveLabs/wasmd
17-
tag: v0.53.3-evm-comet1-inj
17+
tag: v0.53.3-inj.2
1818
- git_repo: https://github.com/InjectiveLabs/cometbft
19-
tag: v1.0.1-inj.3
19+
tag: v1.0.1-inj.4
2020
- git_repo: https://github.com/InjectiveLabs/cosmos-sdk
21-
tag: v0.50.13-evm-comet1-inj.6
21+
tag: v0.50.14-inj
2222
# - git_repo: https://github.com/InjectiveLabs/wasmd
2323
# branch: v0.51.x-inj
2424
# subdir: proto
25+
- git_repo: https://github.com/InjectiveLabs/hyperlane-cosmos
26+
tag: v1.0.1-inj
27+
subdir: proto
2528
- git_repo: https://github.com/InjectiveLabs/injective-core
26-
tag: v1.16.4
29+
tag: v1.17.0-beta.3
2730
subdir: proto
2831
# - git_repo: https://github.com/InjectiveLabs/injective-core
2932
# branch: master

examples/chain_client/7_ChainStream.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ async def main() -> None:
5050
subaccount_ids=[subaccount_id], market_ids=[inj_usdt_perp_market]
5151
)
5252
oracle_price_filter = composer.chain_stream_oracle_price_filter(symbols=["INJ", "USDT"])
53+
order_failures_filter = composer.chain_stream_order_failures_filter(
54+
accounts=["inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r"]
55+
)
56+
conditional_order_trigger_failures_filter = composer.chain_stream_conditional_order_trigger_failures_filter(
57+
subaccount_ids=[subaccount_id], market_ids=[inj_usdt_perp_market]
58+
)
5359

5460
task = asyncio.get_event_loop().create_task(
5561
client.listen_chain_stream_updates(
@@ -66,6 +72,8 @@ async def main() -> None:
6672
derivative_orderbooks_filter=derivative_orderbooks_filter,
6773
positions_filter=positions_filter,
6874
oracle_price_filter=oracle_price_filter,
75+
order_failures_filter=order_failures_filter,
76+
conditional_order_trigger_failures_filter=conditional_order_trigger_failures_filter,
6977
)
7078
)
7179

examples/chain_client/exchange/13_MsgInstantBinaryOptionsMarketLaunch.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ async def main() -> None:
5757
min_price_tick_size=Decimal("0.01"),
5858
min_quantity_tick_size=Decimal("0.01"),
5959
min_notional=Decimal("1"),
60+
open_notional_cap=composer.uncapped_open_notional_cap()
6061
)
6162

6263
# broadcast the transaction

examples/chain_client/exchange/25_MsgUpdateDerivativeMarket.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ async def main() -> None:
5252
new_initial_margin_ratio=Decimal("0.40"),
5353
new_maintenance_margin_ratio=Decimal("0.085"),
5454
new_reduce_margin_ratio=Decimal("3.5"),
55+
new_open_notional_cap=composer.uncapped_open_notional_cap()
5556
)
5657

5758
# broadcast the transaction
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import asyncio
2+
import json
3+
import os
4+
from decimal import Decimal
5+
6+
import dotenv
7+
8+
from pyinjective.async_client_v2 import AsyncClient
9+
from pyinjective.core.broadcaster import MsgBroadcasterWithPk
10+
from pyinjective.core.network import Network
11+
from pyinjective.wallet import PrivateKey
12+
13+
14+
async def main() -> None:
15+
dotenv.load_dotenv()
16+
configured_private_key = os.getenv("INJECTIVE_PRIVATE_KEY")
17+
18+
# select network: local, testnet, mainnet
19+
network = Network.testnet()
20+
21+
# initialize grpc client
22+
client = AsyncClient(network)
23+
await client.initialize_tokens_from_chain_denoms()
24+
composer = await client.composer()
25+
26+
gas_price = await client.current_chain_gas_price()
27+
# adjust gas price to make it valid even if it changes between the time it is requested and the TX is broadcasted
28+
gas_price = int(gas_price * 1.1)
29+
30+
message_broadcaster = MsgBroadcasterWithPk.new_using_simulation(
31+
network=network,
32+
private_key=configured_private_key,
33+
gas_price=gas_price,
34+
client=client,
35+
composer=composer,
36+
)
37+
38+
# load account
39+
priv_key = PrivateKey.from_hex(configured_private_key)
40+
pub_key = priv_key.to_public_key()
41+
address = pub_key.to_address()
42+
await client.fetch_account(address.to_acc_bech32())
43+
44+
offsetting_subaccount_ids = {
45+
"0xbdaedec95d563fb05240d6e01821008454c24c36000000000000000000000000",
46+
"0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000",
47+
}
48+
49+
# prepare tx msg
50+
message = composer.msg_offset_position(
51+
sender=address.to_acc_bech32(),
52+
subaccount_id=address.get_subaccount_id(index=0),
53+
market_id="0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6",
54+
offsetting_subaccount_ids=offsetting_subaccount_ids,
55+
)
56+
57+
# broadcast the transaction
58+
result = await message_broadcaster.broadcast([message])
59+
print("---Transaction Response---")
60+
print(json.dumps(result, indent=2))
61+
62+
gas_price = await client.current_chain_gas_price()
63+
# adjust gas price to make it valid even if it changes between the time it is requested and the TX is broadcasted
64+
gas_price = int(gas_price * 1.1)
65+
message_broadcaster.update_gas_price(gas_price=gas_price)
66+
67+
68+
if __name__ == "__main__":
69+
asyncio.get_event_loop().run_until_complete(main())

examples/chain_client/exchange/4_MsgInstantPerpetualMarketLaunch.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ async def main() -> None:
5858
min_price_tick_size=Decimal("0.001"),
5959
min_quantity_tick_size=Decimal("0.01"),
6060
min_notional=Decimal("1"),
61+
open_notional_cap=composer.uncapped_open_notional_cap()
6162
)
6263

6364
# broadcast the transaction

examples/chain_client/exchange/5_MsgInstantExpiryFuturesMarketLaunch.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ async def main() -> None:
5858
min_price_tick_size=Decimal("0.001"),
5959
min_quantity_tick_size=Decimal("0.01"),
6060
min_notional=Decimal("1"),
61+
open_notional_cap=composer.uncapped_open_notional_cap()
6162
)
6263

6364
# broadcast the transaction

examples/chain_client/exchange/9_MsgBatchUpdateOrders.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,21 @@ async def main() -> None:
104104
),
105105
]
106106

107+
derivative_market_orders_to_create = [
108+
composer.derivative_order(
109+
market_id=derivative_market_id_create,
110+
subaccount_id=subaccount_id,
111+
fee_recipient=fee_recipient,
112+
price=Decimal(25100),
113+
quantity=Decimal(0.1),
114+
margin=composer.calculate_margin(
115+
quantity=Decimal(0.1), price=Decimal(25100), leverage=Decimal(1), is_reduce_only=False
116+
),
117+
order_type="BUY",
118+
cid=str(uuid.uuid4()),
119+
),
120+
]
121+
107122
spot_orders_to_create = [
108123
composer.spot_order(
109124
market_id=spot_market_id_create,
@@ -125,13 +140,27 @@ async def main() -> None:
125140
),
126141
]
127142

143+
spot_market_orders_to_create = [
144+
composer.spot_order(
145+
market_id=spot_market_id_create,
146+
subaccount_id=subaccount_id,
147+
fee_recipient=fee_recipient,
148+
price=Decimal("3.5"),
149+
quantity=Decimal("1"),
150+
order_type="BUY",
151+
cid=str(uuid.uuid4()),
152+
),
153+
]
154+
128155
# prepare tx msg
129156
msg = composer.msg_batch_update_orders(
130157
sender=address.to_acc_bech32(),
131158
derivative_orders_to_create=derivative_orders_to_create,
132159
spot_orders_to_create=spot_orders_to_create,
133160
derivative_orders_to_cancel=derivative_orders_to_cancel,
134161
spot_orders_to_cancel=spot_orders_to_cancel,
162+
spot_market_orders_to_create=spot_market_orders_to_create,
163+
derivative_market_orders_to_create=derivative_market_orders_to_create,
135164
)
136165

137166
# broadcast the transaction
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import asyncio
2+
import json
3+
4+
from pyinjective.async_client_v2 import AsyncClient
5+
from pyinjective.core.network import Network
6+
7+
8+
async def main() -> None:
9+
"""
10+
Demonstrate fetching denom min notionals using AsyncClient.
11+
"""
12+
# Select network: choose between Network.mainnet(), Network.testnet(), or Network.devnet()
13+
network = Network.testnet()
14+
15+
# Initialize the Async Client
16+
client = AsyncClient(network)
17+
18+
market_id = "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6"
19+
open_interest = await client.fetch_open_interest(market_id=market_id)
20+
print(json.dumps(open_interest, indent=2))
21+
22+
23+
if __name__ == "__main__":
24+
asyncio.get_event_loop().run_until_complete(main())

0 commit comments

Comments
 (0)