avantis-trader-sdk 0.8.10__py3-none-any.whl → 0.8.11__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.10"
5
+ __version__ = "0.8.11"
@@ -5,7 +5,7 @@ MAINNET_ADDRESSES = {
5
5
  "PriceAggregator": "0x64e2625621970F8cfA17B294670d61CB883dA511",
6
6
  "USDC": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
7
7
  "Trading": "0x44914408af82bC9983bbb330e3578E1105e11d4e",
8
- "Multicall": "0x7A829c5C97A2Bf8BeFB4b01d96A282E4763848d8",
8
+ "Multicall": "0xA7cFc43872F4D7B0E6141ee8c36f1F7FEe5d099e",
9
9
  "Referral": "0x1A110bBA13A1f16cCa4b79758BD39290f29De82D",
10
10
  }
11
11
 
@@ -1,4 +1,7 @@
1
1
  from ..types import PairInfoWithData
2
+ from ..config import AVANTIS_SOCKET_API
3
+ import requests
4
+ from pydantic import ValidationError
2
5
 
3
6
 
4
7
  class PairsCache:
@@ -6,7 +9,11 @@ class PairsCache:
6
9
  This class provides methods to retrieve pairs information from the blockchain.
7
10
  """
8
11
 
9
- def __init__(self, client):
12
+ def __init__(
13
+ self,
14
+ client,
15
+ socket_api: str = AVANTIS_SOCKET_API,
16
+ ):
10
17
  """
11
18
  Constructor for the PairsCache class.
12
19
 
@@ -14,10 +21,14 @@ class PairsCache:
14
21
  client: The TraderClient object.
15
22
  """
16
23
  self.client = client
24
+ self.socket_api = socket_api
25
+
17
26
  self._pair_info_cache = {}
18
27
  self._group_indexes_cache = {}
19
28
  self._pair_mapping = {}
20
29
 
30
+ self._pair_info_from_socket_cache = {}
31
+
21
32
  async def get_pairs_info(self, force_update=False):
22
33
  """
23
34
  Retrieves the pairs information from the blockchain. The information is cached and will be returned from the cache if it is available and force_update is False. This is to avoid unnecessary calls to the blockchain.
@@ -76,6 +87,27 @@ class PairsCache:
76
87
 
77
88
  return self._pair_info_cache
78
89
 
90
+ async def get_pair_info_from_socket(self, pair_index=None):
91
+ """
92
+ Retrieves the pair information from the socket.
93
+ """
94
+ if not self.socket_api:
95
+ raise ValueError("socket_api is not set")
96
+ try:
97
+ response = requests.get(self.socket_api)
98
+ response.raise_for_status()
99
+
100
+ result = response.json()
101
+ pairs = result["data"]["pairInfos"]
102
+ self._pair_info_from_socket_cache = pairs
103
+ except (requests.RequestException, ValidationError) as e:
104
+ print(f"Error fetching pair feeds: {e}")
105
+ return {}
106
+
107
+ if pair_index is not None:
108
+ return self._pair_info_from_socket_cache[str(pair_index)]
109
+ return self._pair_info_from_socket_cache
110
+
79
111
  async def get_pairs_count(self):
80
112
  """
81
113
  Retrieves the number of pairs from the blockchain.
@@ -57,11 +57,8 @@ class TradingParametersRPC:
57
57
  Returns:
58
58
  The loss protection percentage.
59
59
  """
60
- PairStorage = self.client.contracts.get("PairStorage")
61
- data = await PairStorage.functions.lossProtectionMultiplier(
62
- pair_index, tier
63
- ).call()
64
- return 100 - data
60
+ pair_info = await self.client.pairs_cache.get_pair_info_from_socket(pair_index)
61
+ return pair_info["lossProtectionMultiplier"][str(tier)]
65
62
 
66
63
  async def get_loss_protection_percentage(self, trade: TradeInput):
67
64
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: avantis_trader_sdk
3
- Version: 0.8.10
3
+ Version: 0.8.11
4
4
  Summary: SDK for interacting with Avantis trading contracts.
5
5
  Home-page: https://avantisfi.com/
6
6
  Author: Avantis Labs
@@ -1,6 +1,6 @@
1
- avantis_trader_sdk/__init__.py,sha256=fJXuL3T_V_cURn8bZ0LutoUkMgtT8xInZBR--mBhxD4,135
1
+ avantis_trader_sdk/__init__.py,sha256=wnKUpVEGLQJDYXowu2-hGy4kisH75fJ8k5KY0nT9Im8,135
2
2
  avantis_trader_sdk/client.py,sha256=M01uwXIdxJjmPEcFr1MsDuoxU9YGddxcGMTPucOOssA,10903
3
- avantis_trader_sdk/config.py,sha256=grmfE2piX6jonWuGwD-G6Zl2mvXkTPv1dU3w4Xfm56k,653
3
+ avantis_trader_sdk/config.py,sha256=anwq2ynMurYna24ABbhtAyfpDg4NtPI2lubFuzHkJ9A,653
4
4
  avantis_trader_sdk/types.py,sha256=IGiCmZcpvpkfz70VYkSYPMcQewST_ch3dBHh2f3SSoI,13817
5
5
  avantis_trader_sdk/utils.py,sha256=gTYgNVVd5rLZEUf2eyJftjKYxn55wRm09xAXIF_xjXM,2831
6
6
  avantis_trader_sdk/abis/AggregatorV3Interface.json,sha256=qUeDGZ55Akgu8zOv_Wzf21sTREEyZXF47K_TdPcliBM,26244
@@ -201,18 +201,18 @@ avantis_trader_sdk/rpc/asset_parameters.py,sha256=ESx4eg0K3W9EigsEmN0a7Pym2hL4iJ
201
201
  avantis_trader_sdk/rpc/blended.py,sha256=tRWfO7XreY_YahL9ACpss7ylWz5fdk6G3bv4QpLpGms,2441
202
202
  avantis_trader_sdk/rpc/category_parameters.py,sha256=ofsKct23E8DThCKqP627ol-_YPIdN5HAn09eLqyf6WM,7965
203
203
  avantis_trader_sdk/rpc/fee_parameters.py,sha256=0UCf4FZQp26777o8aA75oOO-b3xFK88c-_glbqQ2-8M,9132
204
- avantis_trader_sdk/rpc/pairs_cache.py,sha256=lXKqGTjJFFTmGOk1RyiEXatsr2ls7vOELlu_HTHAoek,4559
204
+ avantis_trader_sdk/rpc/pairs_cache.py,sha256=tSDfPaBcqtVHj0yyUEHXfD5OAgFgq6_JneNjUxIsbzg,5580
205
205
  avantis_trader_sdk/rpc/rpc_helpers.py,sha256=Sywz6BIj4y2gkudkOhPEND2r2ILvtfq502A_pSEUDv8,284
206
206
  avantis_trader_sdk/rpc/snapshot.py,sha256=hfLRfCbOqnqcuZncaiTmm0BJ2pgLFOEHgsgQ-92Xlcs,5352
207
207
  avantis_trader_sdk/rpc/trade.py,sha256=do0o9i4uB1j5UEL3jSOJ1jp77l7IfoPfTIoTcQN-CD4,23439
208
- avantis_trader_sdk/rpc/trading_parameters.py,sha256=mpWK8dyA0k0KvPHVlFzU21Akdl1VxTzNYy47YZ5ud-c,4640
208
+ avantis_trader_sdk/rpc/trading_parameters.py,sha256=KMLR0RTU82Q9UzSmjnBhUrVn8AaRvG09MovPQs-yXaA,4588
209
209
  avantis_trader_sdk/signers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
210
210
  avantis_trader_sdk/signers/base.py,sha256=QaOu0CxFq60oR4LegCp1XwONMQx8ZShXyiLZvfcbCPM,260
211
211
  avantis_trader_sdk/signers/kms_signer.py,sha256=lxK3f9KQsdCDAvOE1SHleKjI8zD_3PTvywDjDVQGDKg,4448
212
212
  avantis_trader_sdk/signers/local_signer.py,sha256=kUx5vExiBfvFGmoMCFR6b7_4cXx2mvYOJNqZQDIEcG8,505
213
213
  tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
214
214
  tests/test_client.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
215
- avantis_trader_sdk-0.8.10.dist-info/METADATA,sha256=HOIaNo70VhWNnQLLGeWHy_Ny2d8dGvKJzVcASaibkvA,5032
216
- avantis_trader_sdk-0.8.10.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
217
- avantis_trader_sdk-0.8.10.dist-info/top_level.txt,sha256=XffaQJ68SGT1KUz2HHXSGSEsmNy8-AGjgtO127xhzQA,25
218
- avantis_trader_sdk-0.8.10.dist-info/RECORD,,
215
+ avantis_trader_sdk-0.8.11.dist-info/METADATA,sha256=ZaH1iIDrzjkgZ1gv8kNhvtlguRtbvsET-S8FvFfzii0,5032
216
+ avantis_trader_sdk-0.8.11.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
217
+ avantis_trader_sdk-0.8.11.dist-info/top_level.txt,sha256=XffaQJ68SGT1KUz2HHXSGSEsmNy8-AGjgtO127xhzQA,25
218
+ avantis_trader_sdk-0.8.11.dist-info/RECORD,,