avantis-trader-sdk 0.8.4__py3-none-any.whl → 0.8.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,4 +2,4 @@ from .client import TraderClient
2
2
  from .feed.feed_client import FeedClient
3
3
  from .signers.base import BaseSigner
4
4
 
5
- __version__ = "0.8.4"
5
+ __version__ = "0.8.5"
@@ -38,6 +38,11 @@ class TraderClient:
38
38
  l1_provider_url (optional): The URL of the L1 Ethereum node provider.
39
39
  signer (optional): The signer to use for signing transactions.
40
40
  """
41
+ if l1_provider_url is not None:
42
+ print(
43
+ " ⚠️ Warning: l1_provider_url is deprecated and will be removed in the future."
44
+ )
45
+
41
46
  self.web3 = Web3(
42
47
  Web3.HTTPProvider(provider_url, request_kwargs={"timeout": 60})
43
48
  )
@@ -45,14 +50,6 @@ class TraderClient:
45
50
  AsyncWeb3.AsyncHTTPProvider(provider_url, request_kwargs={"timeout": 60})
46
51
  )
47
52
 
48
- self.l1_web3 = Web3(
49
- Web3.HTTPProvider(l1_provider_url, request_kwargs={"timeout": 60})
50
- )
51
-
52
- self.l1_async_web3 = AsyncWeb3(
53
- AsyncWeb3.AsyncHTTPProvider(l1_provider_url, request_kwargs={"timeout": 60})
54
- )
55
-
56
53
  self.contracts = self.load_contracts()
57
54
  self.chain_id = self.web3.eth.chain_id
58
55
 
@@ -0,0 +1,214 @@
1
+ {
2
+ "AERO/USD": {
3
+ "id": "0x9db37f4d5654aad3e37e2e14ffd8d53265fb3026d1d8f91146539eebaa2ef45f",
4
+ "group": "crypto"
5
+ },
6
+ "ETHFI/USD": {
7
+ "id": "0xb27578a9654246cb0a2950842b92330e9ace141c52b63829cc72d5c45a5a595a",
8
+ "group": "crypto"
9
+ },
10
+ "JUP/USD": {
11
+ "id": "0x0a0408d619e9380abad35060f9192039ed5042fa6f82301d0e48bb52be830996",
12
+ "group": "crypto"
13
+ },
14
+ "REZ/USD": {
15
+ "id": "0x9df307038f76e26ba0f9aaa1d5eefce919bf5b7b282d0ad247d4f77ffb506ede",
16
+ "group": "crypto"
17
+ },
18
+ "RNDR/USD": {
19
+ "id": "0xab7347771135fc733f8f38db462ba085ed3309955f42554a14fa13e855ac0e2f",
20
+ "group": "crypto"
21
+ },
22
+ "RENDER/USD": {
23
+ "id": "0x3d4a2bd9535be6ce8059d75eadeba507b043257321aa544717c56fa19b49e35d",
24
+ "group": "crypto"
25
+ },
26
+ "WLD/USD": {
27
+ "id": "0xd6835ad1f773de4a378115eb6824bd0c0e42d84d1c84d9750e853fb6b6c7794a",
28
+ "group": "crypto"
29
+ },
30
+ "ARKM/USD": {
31
+ "id": "0x7677dd124dee46cfcd46ff03cf405fb0ed94b1f49efbea3444aadbda939a7ad3",
32
+ "group": "crypto"
33
+ },
34
+ "PENDLE/USD": {
35
+ "id": "0x9a4df90b25497f66b1afb012467e316e801ca3d839456db028892fe8c70c8016",
36
+ "group": "crypto"
37
+ },
38
+ "ONDO/USD": {
39
+ "id": "0xd40472610abe56d36d065a0cf889fc8f1dd9f3b7f2a478231a5fc6df07ea5ce3",
40
+ "group": "crypto"
41
+ },
42
+ "PRIME/USD": {
43
+ "id": "0xe417fb7d1edcfe70283c608fa9f14d11ebf4d1b3ecf2e97e42a110f7fb649843",
44
+ "group": "crypto"
45
+ },
46
+ "DYM/USD": {
47
+ "id": "0xa9f3b2a89c6f85a6c20a9518abde39b944e839ca49a0c92307c65974d3f14a57",
48
+ "group": "crypto"
49
+ },
50
+ "ORDI/USD": {
51
+ "id": "0x193c739db502aadcef37c2589738b1e37bdb257d58cf1ab3c7ebc8e6df4e3ec0",
52
+ "group": "crypto"
53
+ },
54
+ "STX/USD": {
55
+ "id": "0xec7a775f46379b5e943c3526b1c8d54cd49749176b0b98e02dde68d1bd335c17",
56
+ "group": "crypto"
57
+ },
58
+ "ENA/USD": {
59
+ "id": "0xb7910ba7322db020416fcac28b48c01212fd9cc8fbcbaf7d30477ed8605f6bd4",
60
+ "group": "crypto"
61
+ },
62
+ "TIA/USD": {
63
+ "id": "0x09f7c1d7dfbb7df2b8fe3d3d87ee94a2259d212da4f30c1f0540d066dfa44723",
64
+ "group": "crypto"
65
+ },
66
+ "SEI/USD": {
67
+ "id": "0x53614f1cb0c031d4af66c04cb9c756234adad0e1cee85303795091499a4084eb",
68
+ "group": "crypto"
69
+ },
70
+ "ARB/USD": {
71
+ "id": "0x3fa4252848f9f0a1480be62745a4629d9eb1322aebab8a791e344b3b9c1adcf5",
72
+ "group": "crypto"
73
+ },
74
+ "AVAX/USD": {
75
+ "id": "0x93da3352f9f1d105fdfe4971cfa80e9dd777bfc5d0f683ebb6e1294b92137bb7",
76
+ "group": "crypto"
77
+ },
78
+ "BNB/USD": {
79
+ "id": "0x2f95862b045670cd22bee3114c39763a4a08beeb663b145d283c31d7d1101c4f",
80
+ "group": "crypto"
81
+ },
82
+ "BONK/USD": {
83
+ "id": "0x72b021217ca3fe68922a19aaf990109cb9d84e9ad004b4d2025ad6f529314419",
84
+ "group": "crypto"
85
+ },
86
+ "BTC/USD": {
87
+ "id": "0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43",
88
+ "group": "crypto"
89
+ },
90
+ "DOGE/USD": {
91
+ "id": "0xdcef50dd0a4cd2dcc17e45df1676dcb336a11a61c69df7a0299b0150c672d25c",
92
+ "group": "crypto"
93
+ },
94
+ "ETH/USD": {
95
+ "id": "0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace",
96
+ "group": "crypto"
97
+ },
98
+ "FET/USD": {
99
+ "id": "0xb98e7ae8af2d298d2651eb21ab5b8b5738212e13efb43bd0dfbce7a74ba4b5d0",
100
+ "group": "crypto"
101
+ },
102
+ "LDO/USD": {
103
+ "id": "0xc63e2a7f37a04e5e614c07238bedb25dcc38927fba8fe890597a593c0b2fa4ad",
104
+ "group": "crypto"
105
+ },
106
+ "LINK/USD": {
107
+ "id": "0x8ac0c70fff57e9aefdf5edf44b51d62c2d433653cbb2cf5cc06bb115af04d221",
108
+ "group": "crypto"
109
+ },
110
+ "MATIC/USD": {
111
+ "id": "0x5de33a9112c2b700b8d30b8a3402c103578ccfa2765696471cc672bd5cf6ac52",
112
+ "group": "crypto"
113
+ },
114
+ "POL/USD": {
115
+ "id": "0xffd11c5a1cfd42f80afb2df4d9f264c15f956d68153335374ec10722edd70472",
116
+ "group": "crypto"
117
+ },
118
+ "NEAR/USD": {
119
+ "id": "0xc415de8d2eba7db216527dff4b60e8f3a5311c740dadb233e13e12547e226750",
120
+ "group": "crypto"
121
+ },
122
+ "OP/USD": {
123
+ "id": "0x385f64d993f7b77d8182ed5003d97c60aa3361f3cecfe711544d2d59165e9bdf",
124
+ "group": "crypto"
125
+ },
126
+ "SHIB/USD": {
127
+ "id": "0xf0d57deca57b3da2fe63a493f4c25925fdfd8edf834b20f93e1f84dbd1504d4a",
128
+ "group": "crypto"
129
+ },
130
+ "SOL/USD": {
131
+ "id": "0xef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d",
132
+ "group": "crypto"
133
+ },
134
+ "WIF/USD": {
135
+ "id": "0x4ca4beeca86f0d164160323817a4e42b10010a724c2217c6ee41b54cd4cc61fc",
136
+ "group": "crypto"
137
+ },
138
+ "PEPE/USD": {
139
+ "id": "0xd69731a2e74ac1ce884fc3890f7ee324b6deb66147055249568869ed700882e4",
140
+ "group": "crypto"
141
+ },
142
+ "AUD/USD": {
143
+ "id": "0x67a6f93030420c1c9e3fe37c1ab6b77966af82f995944a9fefce357a22854a80",
144
+ "group": "forex"
145
+ },
146
+ "EUR/USD": {
147
+ "id": "0xa995d00bb36a63cef7fd2c287dc105fc8f3d93779f062f09551b0af3e81ec30b",
148
+ "group": "forex"
149
+ },
150
+ "GBP/USD": {
151
+ "id": "0x84c2dde9633d93d1bcad84e7dc41c9d56578b7ec52fabedc1f335d673df0a7c1",
152
+ "group": "forex"
153
+ },
154
+ "NZD/USD": {
155
+ "id": "0x92eea8ba1b00078cdc2ef6f64f091f262e8c7d0576ee4677572f314ebfafa4c7",
156
+ "group": "forex"
157
+ },
158
+ "USD/CAD": {
159
+ "id": "0x3112b03a41c910ed446852aacf67118cb1bec67b2cd0b9a214c58cc0eaa2ecca",
160
+ "group": "forex"
161
+ },
162
+ "USD/CHF": {
163
+ "id": "0x0b1e3297e69f162877b577b0d6a47a0d63b2392bc8499e6540da4187a63e28f8",
164
+ "group": "forex"
165
+ },
166
+ "USD/JPY": {
167
+ "id": "0xef2c98c804ba503c6a707e38be4dfbb16683775f195b091252bf24693042fd52",
168
+ "group": "forex"
169
+ },
170
+ "USD/SEK": {
171
+ "id": "0x8ccb376aa871517e807358d4e3cf0bc7fe4950474dbe6c9ffc21ef64e43fc676",
172
+ "group": "forex"
173
+ },
174
+ "USD/SGD": {
175
+ "id": "0x396a969a9c1480fa15ed50bc59149e2c0075a72fe8f458ed941ddec48bdb4918",
176
+ "group": "forex"
177
+ },
178
+ "XAG/USD": {
179
+ "id": "0xf2fb02c32b055c805e7238d628e5e9dadef274376114eb1f012337cabe93871e",
180
+ "group": "metal"
181
+ },
182
+ "XAU/USD": {
183
+ "id": "0x765d2ba906dbc32ca17cc11f5310a89e9ee1f6420508c63861f2f8ba4ee34bb2",
184
+ "group": "metal"
185
+ },
186
+ "ZRO/USD": {
187
+ "id": "0x3bd860bea28bf982fa06bcf358118064bb114086cc03993bd76197eaab0b8018",
188
+ "group": "crypto"
189
+ },
190
+ "INJ/USD": {
191
+ "id": "0x7a5bc1d2b56ad029048cd63964b3ad2776eadf812edc1a43a31406cb54bff592",
192
+ "group": "crypto"
193
+ },
194
+ "ZK/USD": {
195
+ "id": "0xcc03dc09298fb447e0bf9afdb760d5b24340fd2167fd33d8967dd8f9a141a2e8",
196
+ "group": "crypto"
197
+ },
198
+ "AAVE/USD": {
199
+ "id": "0x2b9ab1e972a281585084148ba1389800799bd4be63b957507db1349314e47445",
200
+ "group": "crypto"
201
+ },
202
+ "SUI/USD": {
203
+ "id": "0x23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
204
+ "group": "crypto"
205
+ },
206
+ "TAO/USD": {
207
+ "id": "0x410f41de235f2db824e562ea7ab2d3d3d4ff048316c61d629c0b93f58584e1af",
208
+ "group": "crypto"
209
+ },
210
+ "EIGEN/USD": {
211
+ "id": "0xc65db025687356496e8653d0d6608eec64ce2d96e2e28c530e574f0e4f712380",
212
+ "group": "crypto"
213
+ }
214
+ }
@@ -180,16 +180,11 @@ class TradeRPC:
180
180
  execution_fee_wei = int(execution_fee * 10**18)
181
181
 
182
182
  try:
183
- feeScalar = 0.001
184
-
185
- estimatedL1Gas = math.floor(22676 * feeScalar)
186
183
  estimatedL2Gas = math.floor(850000 * 1.1)
187
184
 
188
185
  l2GasPrice = await self.client.async_web3.eth.gas_price
189
186
  estimatedL2GasEth = l2GasPrice * estimatedL2Gas
190
-
191
- l1GasPrice = await self.client.l1_async_web3.eth.gas_price
192
- estimatedL1GasEth = l1GasPrice * estimatedL1Gas
187
+ estimatedL1GasEth = 5000000000
193
188
 
194
189
  feeEstimate = estimatedL1GasEth + estimatedL2GasEth
195
190
  feeEstimate = round(feeEstimate, 18)
@@ -295,6 +290,7 @@ class TradeRPC:
295
290
  trade_index: int,
296
291
  collateral_to_close: float,
297
292
  trader: Optional[str] = None,
293
+ execution_fee: Optional[float] = None,
298
294
  ):
299
295
  """
300
296
  Builds a transaction to close a trade.
@@ -304,6 +300,7 @@ class TradeRPC:
304
300
  trade_index: The trade index.
305
301
  collateral_to_close: The collateral to close.
306
302
  trader (optional): The trader's wallet address.
303
+ execution_fee (optional): The execution fee.
307
304
 
308
305
  Returns:
309
306
  A transaction object.
@@ -315,7 +312,10 @@ class TradeRPC:
315
312
 
316
313
  collateral_to_close = int(collateral_to_close * 10**6)
317
314
 
318
- execution_fee = await self.get_trade_execution_fee()
315
+ if execution_fee is not None:
316
+ execution_fee_wei = int(execution_fee * 10**18)
317
+ else:
318
+ execution_fee_wei = await self.get_trade_execution_fee()
319
319
 
320
320
  transaction = await Trading.functions.closeTradeMarket(
321
321
  pair_index,
@@ -326,7 +326,7 @@ class TradeRPC:
326
326
  "from": trader,
327
327
  "chainId": self.client.chain_id,
328
328
  "nonce": await self.client.get_transaction_count(trader),
329
- "value": execution_fee,
329
+ "value": execution_fee_wei,
330
330
  }
331
331
  )
332
332
 
@@ -338,6 +338,7 @@ class TradeRPC:
338
338
  trade_index: int,
339
339
  collateral_to_close: float,
340
340
  trader: Optional[str] = None,
341
+ execution_fee: Optional[float] = None,
341
342
  ):
342
343
  """
343
344
  Builds a transaction to close a trade.
@@ -358,7 +359,10 @@ class TradeRPC:
358
359
 
359
360
  collateral_to_close = int(collateral_to_close * 10**6)
360
361
 
361
- execution_fee = await self.get_trade_execution_fee()
362
+ if execution_fee is not None:
363
+ execution_fee_wei = int(execution_fee * 10**18)
364
+ else:
365
+ execution_fee_wei = await self.get_trade_execution_fee()
362
366
 
363
367
  transaction = await Trading.functions.closeTradeMarket(
364
368
  pair_index,
@@ -378,7 +382,7 @@ class TradeRPC:
378
382
  ).build_transaction(
379
383
  {
380
384
  "from": self.client.get_signer().get_ethereum_address(),
381
- "value": execution_fee,
385
+ "value": execution_fee_wei,
382
386
  "chainId": self.client.chain_id,
383
387
  "nonce": await self.client.get_transaction_count(
384
388
  self.client.get_signer().get_ethereum_address()
@@ -51,6 +51,7 @@ class KMSSigner(BaseSigner):
51
51
  self._key_id = kms_key_id
52
52
  self._kms_client = boto3.client("kms", region_name)
53
53
  self.address = self.get_public_key()
54
+ self.cached_address = None
54
55
 
55
56
  async def sign_transaction(self, transaction):
56
57
  """
@@ -68,8 +69,10 @@ class KMSSigner(BaseSigner):
68
69
  """
69
70
  Retrieves the public key associated with the KMS key.
70
71
  """
71
- eth_address = self.get_eth_address()
72
- return Web3.to_checksum_address(eth_address)
72
+ if self.cached_address is None:
73
+ eth_address = self.get_eth_address()
74
+ self.cached_address = Web3.to_checksum_address(eth_address)
75
+ return self.cached_address
73
76
 
74
77
  def get_ethereum_address(self):
75
78
  """
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: avantis_trader_sdk
3
- Version: 0.8.4
3
+ Version: 0.8.5
4
4
  Summary: SDK for interacting with Avantis trading contracts.
5
5
  Home-page: https://avantisfi.com/
6
6
  Author: Avantis Labs
7
- Author-email: brank@avantisfi.com
7
+ Author-email: yug@avantisfi.com
8
8
  License: MIT
9
9
  Keywords: trading sdk blockchain ethereum web3 avantis
10
10
  Classifier: Programming Language :: Python :: 3
@@ -1,5 +1,5 @@
1
- avantis_trader_sdk/__init__.py,sha256=eI0gPerUaeLI_QHMaj3ZFUH-0OoY3LfR2QOnElNl01o,134
2
- avantis_trader_sdk/client.py,sha256=n6iXxmy_bVV6AdcgMrtqNgUe_A-VsYmuq2IvkV-IJgM,10970
1
+ avantis_trader_sdk/__init__.py,sha256=zKb-KdL09iEoncdVH7H07-v0w6NnywVq9N_zloBOUyE,134
2
+ avantis_trader_sdk/client.py,sha256=XyTrCjaJGU7aITayi_zBgqKn926Bdg8yOIy0FfQ-YrM,10885
3
3
  avantis_trader_sdk/config.py,sha256=AWMAW4SdMCSjNjOy3PMPn0rE_VY2DJ-LGDK2E27Q6jc,638
4
4
  avantis_trader_sdk/types.py,sha256=IGiCmZcpvpkfz70VYkSYPMcQewST_ch3dBHh2f3SSoI,13817
5
5
  avantis_trader_sdk/utils.py,sha256=gTYgNVVd5rLZEUf2eyJftjKYxn55wRm09xAXIF_xjXM,2831
@@ -194,6 +194,7 @@ avantis_trader_sdk/abis/wire.s.sol/Wire.json,sha256=b8M2fVPiLMMZhapuD3FilICRjfRW
194
194
  avantis_trader_sdk/crypto/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
195
195
  avantis_trader_sdk/crypto/spki.py,sha256=CNy7A8TTwBHiNSzIj7uqiHKAeLcn1Q9MbszW_2mdXgI,3080
196
196
  avantis_trader_sdk/feed/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
197
+ avantis_trader_sdk/feed/feedIds.json,sha256=T77nww3eRiQt8rqZBDpdxA49USGyfI0dQBPnzo-H1dE,6697
197
198
  avantis_trader_sdk/feed/feed_client.py,sha256=SsCX5CJfrXjN5rl8hMqED-kebHnM3AMRDkdCKeMV5DI,9283
198
199
  avantis_trader_sdk/rpc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
199
200
  avantis_trader_sdk/rpc/asset_parameters.py,sha256=ESx4eg0K3W9EigsEmN0a7Pym2hL4iJgMWmzhHmmWXyY,19323
@@ -203,15 +204,15 @@ avantis_trader_sdk/rpc/fee_parameters.py,sha256=0UCf4FZQp26777o8aA75oOO-b3xFK88c
203
204
  avantis_trader_sdk/rpc/pairs_cache.py,sha256=lXKqGTjJFFTmGOk1RyiEXatsr2ls7vOELlu_HTHAoek,4559
204
205
  avantis_trader_sdk/rpc/rpc_helpers.py,sha256=Sywz6BIj4y2gkudkOhPEND2r2ILvtfq502A_pSEUDv8,284
205
206
  avantis_trader_sdk/rpc/snapshot.py,sha256=hfLRfCbOqnqcuZncaiTmm0BJ2pgLFOEHgsgQ-92Xlcs,5352
206
- avantis_trader_sdk/rpc/trade.py,sha256=rT_tTeTG8LVj04nV2H3sEfLFLB9lcqvdZGH9Z39Pwa0,23214
207
+ avantis_trader_sdk/rpc/trade.py,sha256=FJeyyln-V9_j0lFc6SaivusSO2wUHLUZd4EA-Y2XNFE,23434
207
208
  avantis_trader_sdk/rpc/trading_parameters.py,sha256=mpWK8dyA0k0KvPHVlFzU21Akdl1VxTzNYy47YZ5ud-c,4640
208
209
  avantis_trader_sdk/signers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
209
210
  avantis_trader_sdk/signers/base.py,sha256=QaOu0CxFq60oR4LegCp1XwONMQx8ZShXyiLZvfcbCPM,260
210
- avantis_trader_sdk/signers/kms_signer.py,sha256=lxK3f9KQsdCDAvOE1SHleKjI8zD_3PTvywDjDVQGDKg,4448
211
+ avantis_trader_sdk/signers/kms_signer.py,sha256=X8344ysIMnV-sghr-w9NYJLem5uZjtjZlsK4cV5OVBI,4581
211
212
  avantis_trader_sdk/signers/local_signer.py,sha256=kUx5vExiBfvFGmoMCFR6b7_4cXx2mvYOJNqZQDIEcG8,505
212
213
  tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
213
214
  tests/test_client.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
214
- avantis_trader_sdk-0.8.4.dist-info/METADATA,sha256=3ob3YDkZ_5KAwCPcZ-jGeTglDsOlQjgJFNwNFtZCNmA,5035
215
- avantis_trader_sdk-0.8.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
216
- avantis_trader_sdk-0.8.4.dist-info/top_level.txt,sha256=XffaQJ68SGT1KUz2HHXSGSEsmNy8-AGjgtO127xhzQA,25
217
- avantis_trader_sdk-0.8.4.dist-info/RECORD,,
215
+ avantis_trader_sdk-0.8.5.dist-info/METADATA,sha256=ThPAnO_wa8xntDSRLJLh05ZUu64vTzIVr_X1-g4D3mc,5033
216
+ avantis_trader_sdk-0.8.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
217
+ avantis_trader_sdk-0.8.5.dist-info/top_level.txt,sha256=XffaQJ68SGT1KUz2HHXSGSEsmNy8-AGjgtO127xhzQA,25
218
+ avantis_trader_sdk-0.8.5.dist-info/RECORD,,