wayfinder-paths 0.1.11__py3-none-any.whl → 0.1.14__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.
Potentially problematic release.
This version of wayfinder-paths might be problematic. Click here for more details.
- wayfinder_paths/adapters/balance_adapter/README.md +13 -14
- wayfinder_paths/adapters/balance_adapter/adapter.py +36 -39
- wayfinder_paths/adapters/balance_adapter/test_adapter.py +123 -0
- wayfinder_paths/adapters/brap_adapter/README.md +11 -16
- wayfinder_paths/adapters/brap_adapter/adapter.py +87 -75
- wayfinder_paths/adapters/brap_adapter/examples.json +63 -52
- wayfinder_paths/adapters/brap_adapter/test_adapter.py +121 -59
- wayfinder_paths/adapters/hyperlend_adapter/adapter.py +22 -23
- wayfinder_paths/adapters/hyperlend_adapter/test_adapter.py +114 -60
- wayfinder_paths/adapters/hyperliquid_adapter/adapter.py +1 -1
- wayfinder_paths/adapters/hyperliquid_adapter/executor.py +44 -5
- wayfinder_paths/adapters/hyperliquid_adapter/test_executor.py +104 -0
- wayfinder_paths/adapters/moonwell_adapter/adapter.py +0 -3
- wayfinder_paths/adapters/pool_adapter/README.md +11 -27
- wayfinder_paths/adapters/pool_adapter/adapter.py +11 -37
- wayfinder_paths/adapters/pool_adapter/examples.json +6 -7
- wayfinder_paths/adapters/pool_adapter/test_adapter.py +8 -8
- wayfinder_paths/adapters/token_adapter/README.md +2 -14
- wayfinder_paths/adapters/token_adapter/adapter.py +16 -10
- wayfinder_paths/adapters/token_adapter/examples.json +4 -8
- wayfinder_paths/adapters/token_adapter/test_adapter.py +5 -3
- wayfinder_paths/core/clients/BRAPClient.py +103 -62
- wayfinder_paths/core/clients/ClientManager.py +1 -68
- wayfinder_paths/core/clients/HyperlendClient.py +127 -66
- wayfinder_paths/core/clients/LedgerClient.py +1 -4
- wayfinder_paths/core/clients/PoolClient.py +126 -88
- wayfinder_paths/core/clients/TokenClient.py +92 -37
- wayfinder_paths/core/clients/WalletClient.py +28 -58
- wayfinder_paths/core/clients/WayfinderClient.py +33 -166
- wayfinder_paths/core/clients/__init__.py +0 -2
- wayfinder_paths/core/clients/protocols.py +35 -52
- wayfinder_paths/core/clients/sdk_example.py +37 -22
- wayfinder_paths/core/config.py +60 -224
- wayfinder_paths/core/engine/StrategyJob.py +7 -55
- wayfinder_paths/core/services/local_evm_txn.py +28 -10
- wayfinder_paths/core/services/local_token_txn.py +1 -1
- wayfinder_paths/core/strategies/Strategy.py +3 -5
- wayfinder_paths/core/strategies/descriptors.py +7 -0
- wayfinder_paths/core/utils/evm_helpers.py +7 -3
- wayfinder_paths/core/utils/wallets.py +12 -19
- wayfinder_paths/core/wallets/README.md +1 -1
- wayfinder_paths/run_strategy.py +8 -17
- wayfinder_paths/scripts/create_strategy.py +5 -5
- wayfinder_paths/scripts/make_wallets.py +5 -5
- wayfinder_paths/scripts/run_strategy.py +3 -3
- wayfinder_paths/strategies/basis_trading_strategy/snapshot_mixin.py +1 -1
- wayfinder_paths/strategies/basis_trading_strategy/strategy.py +206 -526
- wayfinder_paths/strategies/basis_trading_strategy/test_strategy.py +228 -11
- wayfinder_paths/strategies/hyperlend_stable_yield_strategy/README.md +2 -2
- wayfinder_paths/strategies/hyperlend_stable_yield_strategy/strategy.py +41 -25
- wayfinder_paths/strategies/hyperlend_stable_yield_strategy/test_strategy.py +54 -9
- wayfinder_paths/strategies/moonwell_wsteth_loop_strategy/README.md +1 -1
- wayfinder_paths/strategies/moonwell_wsteth_loop_strategy/strategy.py +10 -9
- wayfinder_paths/strategies/moonwell_wsteth_loop_strategy/test_strategy.py +12 -6
- wayfinder_paths/strategies/stablecoin_yield_strategy/README.md +3 -3
- wayfinder_paths/strategies/stablecoin_yield_strategy/strategy.py +110 -78
- wayfinder_paths/strategies/stablecoin_yield_strategy/test_strategy.py +44 -21
- wayfinder_paths/templates/adapter/README.md +1 -1
- wayfinder_paths/templates/strategy/README.md +3 -3
- wayfinder_paths/templates/strategy/test_strategy.py +3 -2
- {wayfinder_paths-0.1.11.dist-info → wayfinder_paths-0.1.14.dist-info}/METADATA +21 -59
- {wayfinder_paths-0.1.11.dist-info → wayfinder_paths-0.1.14.dist-info}/RECORD +64 -65
- wayfinder_paths/core/clients/AuthClient.py +0 -83
- wayfinder_paths/core/settings.py +0 -61
- {wayfinder_paths-0.1.11.dist-info → wayfinder_paths-0.1.14.dist-info}/LICENSE +0 -0
- {wayfinder_paths-0.1.11.dist-info → wayfinder_paths-0.1.14.dist-info}/WHEEL +0 -0
|
@@ -1,97 +1,163 @@
|
|
|
1
1
|
"""
|
|
2
2
|
Hyperlend Client
|
|
3
|
-
Provides access to Hyperlend stable markets data via
|
|
3
|
+
Provides access to Hyperlend stable markets data via blockchain endpoints.
|
|
4
4
|
"""
|
|
5
5
|
|
|
6
6
|
from __future__ import annotations
|
|
7
7
|
|
|
8
|
-
from typing import Any,
|
|
8
|
+
from typing import Any, Required, TypedDict
|
|
9
9
|
|
|
10
10
|
from wayfinder_paths.core.clients.WayfinderClient import WayfinderClient
|
|
11
|
-
from wayfinder_paths.core.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
class StableMarket(TypedDict):
|
|
15
|
-
"""Stable market data structure"""
|
|
16
|
-
|
|
17
|
-
chain_id: Required[int]
|
|
18
|
-
token_address: Required[str]
|
|
19
|
-
symbol: Required[str]
|
|
20
|
-
name: Required[str]
|
|
21
|
-
underlying_tokens: Required[float]
|
|
22
|
-
buffer_bps: Required[int]
|
|
23
|
-
min_buffer_tokens: Required[float]
|
|
24
|
-
is_stable_symbol: Required[bool]
|
|
11
|
+
from wayfinder_paths.core.config import get_api_base_url
|
|
25
12
|
|
|
26
13
|
|
|
27
14
|
class AssetsView(TypedDict):
|
|
28
15
|
"""Assets view response structure"""
|
|
29
16
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
17
|
+
block_number: Required[int]
|
|
18
|
+
user: Required[str]
|
|
19
|
+
native_balance_wei: Required[int]
|
|
20
|
+
native_balance: Required[float]
|
|
21
|
+
assets: Required[list[AssetInfo]]
|
|
22
|
+
account_data: Required[AccountData]
|
|
23
|
+
base_currency_info: Required[BaseCurrencyInfo]
|
|
34
24
|
|
|
35
25
|
|
|
36
26
|
class MarketEntry(TypedDict):
|
|
37
27
|
"""Market entry data structure"""
|
|
38
28
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
29
|
+
symbol: Required[str]
|
|
30
|
+
symbol_canonical: Required[str]
|
|
31
|
+
display_symbol: Required[str]
|
|
32
|
+
reserve: Required[dict[str, Any]]
|
|
42
33
|
|
|
43
34
|
|
|
44
35
|
class LendRateHistory(TypedDict):
|
|
45
36
|
"""Lend rate history response structure"""
|
|
46
37
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
38
|
+
history: Required[list[RateHistoryEntry]]
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class MarketHeadroom(TypedDict):
|
|
42
|
+
"""Market headroom data structure"""
|
|
43
|
+
|
|
44
|
+
symbol: Required[str]
|
|
45
|
+
symbol_canonical: Required[str]
|
|
46
|
+
display_symbol: Required[str]
|
|
47
|
+
reserve: Required[dict[str, Any]]
|
|
48
|
+
decimals: Required[int]
|
|
49
|
+
headroom: Required[int]
|
|
50
|
+
supply_cap: Required[int]
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class StableMarketsHeadroomResponse(TypedDict):
|
|
54
|
+
"""Stable markets headroom response structure"""
|
|
55
|
+
|
|
56
|
+
markets: Required[dict[str, MarketHeadroom]]
|
|
57
|
+
notes: Required[list[str]]
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
class RateHistoryEntry(TypedDict):
|
|
61
|
+
"""Rate history entry data structure"""
|
|
62
|
+
|
|
63
|
+
timestamp_ms: Required[int]
|
|
64
|
+
timestamp: Required[float]
|
|
65
|
+
supply_apr: Required[float]
|
|
66
|
+
supply_apy: Required[float]
|
|
67
|
+
borrow_apr: Required[float]
|
|
68
|
+
borrow_apy: Required[float]
|
|
69
|
+
token: Required[str]
|
|
70
|
+
symbol: Required[str]
|
|
71
|
+
display_symbol: Required[str]
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class AssetInfo(TypedDict):
|
|
75
|
+
"""Asset information structure"""
|
|
76
|
+
|
|
77
|
+
underlying: Required[str]
|
|
78
|
+
symbol: Required[str]
|
|
79
|
+
symbol_canonical: Required[str]
|
|
80
|
+
symbol_display: Required[str]
|
|
81
|
+
decimals: Required[int]
|
|
82
|
+
a_token: Required[str]
|
|
83
|
+
variable_debt_token: Required[str]
|
|
84
|
+
usage_as_collateral_enabled: Required[bool]
|
|
85
|
+
borrowing_enabled: Required[bool]
|
|
86
|
+
is_active: Required[bool]
|
|
87
|
+
is_frozen: Required[bool]
|
|
88
|
+
is_paused: Required[bool]
|
|
89
|
+
is_siloed_borrowing: Required[bool]
|
|
90
|
+
is_stablecoin: Required[bool]
|
|
91
|
+
underlying_wallet_balance: Required[float]
|
|
92
|
+
underlying_wallet_balance_wei: Required[int]
|
|
93
|
+
price_usd: Required[float]
|
|
94
|
+
supply: Required[float]
|
|
95
|
+
variable_borrow: Required[float]
|
|
96
|
+
supply_usd: Required[float]
|
|
97
|
+
variable_borrow_usd: Required[float]
|
|
98
|
+
supply_apr: Required[float]
|
|
99
|
+
supply_apy: Required[float]
|
|
100
|
+
variable_borrow_apr: Required[float]
|
|
101
|
+
variable_borrow_apy: Required[float]
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
class AccountData(TypedDict):
|
|
105
|
+
"""Account data structure"""
|
|
106
|
+
|
|
107
|
+
total_collateral_base: Required[int | float]
|
|
108
|
+
total_debt_base: Required[int | float]
|
|
109
|
+
available_borrows_base: Required[int | float]
|
|
110
|
+
current_liquidation_threshold: Required[int | float]
|
|
111
|
+
ltv: Required[int | float]
|
|
112
|
+
health_factor_wad: Required[int]
|
|
113
|
+
health_factor: Required[float]
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
class BaseCurrencyInfo(TypedDict):
|
|
117
|
+
"""Base currency information structure"""
|
|
118
|
+
|
|
119
|
+
marketReferenceCurrencyUnit: Required[int]
|
|
120
|
+
marketReferenceCurrencyPriceInUsd: Required[int]
|
|
121
|
+
networkBaseTokenPriceInUsd: Required[int]
|
|
122
|
+
networkBaseTokenPriceDecimals: Required[int]
|
|
51
123
|
|
|
52
124
|
|
|
53
125
|
class HyperlendClient(WayfinderClient):
|
|
54
126
|
"""Client for Hyperlend-related operations"""
|
|
55
127
|
|
|
56
|
-
def __init__(self
|
|
57
|
-
super().__init__(
|
|
58
|
-
self.api_base_url =
|
|
128
|
+
def __init__(self):
|
|
129
|
+
super().__init__()
|
|
130
|
+
self.api_base_url = get_api_base_url()
|
|
59
131
|
|
|
60
132
|
async def get_stable_markets(
|
|
61
133
|
self,
|
|
62
134
|
*,
|
|
63
|
-
chain_id: int,
|
|
64
135
|
required_underlying_tokens: float | None = None,
|
|
65
136
|
buffer_bps: int | None = None,
|
|
66
137
|
min_buffer_tokens: float | None = None,
|
|
67
|
-
|
|
68
|
-
) -> list[StableMarket]:
|
|
138
|
+
) -> StableMarketsHeadroomResponse:
|
|
69
139
|
"""
|
|
70
|
-
Fetch stable markets from Hyperlend.
|
|
140
|
+
Fetch stable markets headroom from Hyperlend.
|
|
71
141
|
|
|
72
142
|
Args:
|
|
73
|
-
chain_id: Chain ID to query markets for
|
|
74
143
|
required_underlying_tokens: Required underlying tokens amount
|
|
75
144
|
buffer_bps: Buffer in basis points
|
|
76
145
|
min_buffer_tokens: Minimum buffer in tokens
|
|
77
|
-
is_stable_symbol: Filter by stable symbol (optional)
|
|
78
146
|
|
|
79
147
|
Example:
|
|
80
|
-
GET /api/v1/
|
|
148
|
+
GET /api/v1/blockchain/hyperlend/stable_markets_headroom/?required_underlying_tokens=1000&buffer_bps=50&min_buffer_tokens=100
|
|
81
149
|
|
|
82
150
|
Returns:
|
|
83
|
-
Dictionary containing stable markets data
|
|
151
|
+
Dictionary containing stable markets headroom data with markets and notes
|
|
84
152
|
"""
|
|
85
|
-
url = f"{self.api_base_url}/
|
|
86
|
-
params: dict[str, Any] = {
|
|
153
|
+
url = f"{self.api_base_url}/v1/blockchain/hyperlend/stable_markets_headroom/"
|
|
154
|
+
params: dict[str, Any] = {}
|
|
87
155
|
if required_underlying_tokens is not None:
|
|
88
156
|
params["required_underlying_tokens"] = required_underlying_tokens
|
|
89
157
|
if buffer_bps is not None:
|
|
90
158
|
params["buffer_bps"] = buffer_bps
|
|
91
159
|
if min_buffer_tokens is not None:
|
|
92
160
|
params["min_buffer_tokens"] = min_buffer_tokens
|
|
93
|
-
if is_stable_symbol is not None:
|
|
94
|
-
params["is_stable_symbol"] = "true" if is_stable_symbol else "false"
|
|
95
161
|
|
|
96
162
|
response = await self._authed_request("GET", url, params=params, headers={})
|
|
97
163
|
response.raise_for_status()
|
|
@@ -101,25 +167,22 @@ class HyperlendClient(WayfinderClient):
|
|
|
101
167
|
async def get_assets_view(
|
|
102
168
|
self,
|
|
103
169
|
*,
|
|
104
|
-
chain_id: int,
|
|
105
170
|
user_address: str,
|
|
106
171
|
) -> AssetsView:
|
|
107
172
|
"""
|
|
108
173
|
Fetch assets view for a user address from Hyperlend.
|
|
109
174
|
|
|
110
175
|
Args:
|
|
111
|
-
chain_id: Chain ID to query assets for
|
|
112
176
|
user_address: User wallet address to query assets for
|
|
113
177
|
|
|
114
178
|
Example:
|
|
115
|
-
GET /api/v1/
|
|
179
|
+
GET /api/v1/blockchain/hyperlend/assets/?user_address=0x0c737cB5934afCb5B01965141F865F795B324080
|
|
116
180
|
|
|
117
181
|
Returns:
|
|
118
|
-
Dictionary containing assets view data
|
|
182
|
+
Dictionary containing assets view data with account information and base currency info
|
|
119
183
|
"""
|
|
120
|
-
url = f"{self.api_base_url}/
|
|
184
|
+
url = f"{self.api_base_url}/v1/blockchain/hyperlend/assets/"
|
|
121
185
|
params: dict[str, Any] = {
|
|
122
|
-
"chain_id": chain_id,
|
|
123
186
|
"user_address": user_address,
|
|
124
187
|
}
|
|
125
188
|
|
|
@@ -131,26 +194,23 @@ class HyperlendClient(WayfinderClient):
|
|
|
131
194
|
async def get_market_entry(
|
|
132
195
|
self,
|
|
133
196
|
*,
|
|
134
|
-
|
|
135
|
-
token_address: str,
|
|
197
|
+
token: str,
|
|
136
198
|
) -> MarketEntry:
|
|
137
199
|
"""
|
|
138
200
|
Fetch market entry from Hyperlend.
|
|
139
201
|
|
|
140
202
|
Args:
|
|
141
|
-
|
|
142
|
-
token_address: Token address to query market for
|
|
203
|
+
token: Token address to query market for
|
|
143
204
|
|
|
144
205
|
Example:
|
|
145
|
-
GET /api/v1/
|
|
206
|
+
GET /api/v1/blockchain/hyperlend/market_entry/?token=0x5555555555555555555555555555555555555555
|
|
146
207
|
|
|
147
208
|
Returns:
|
|
148
|
-
Dictionary containing market entry data
|
|
209
|
+
Dictionary containing market entry data with symbol and reserve information
|
|
149
210
|
"""
|
|
150
|
-
url = f"{self.api_base_url}/
|
|
211
|
+
url = f"{self.api_base_url}/v1/blockchain/hyperlend/market_entry/"
|
|
151
212
|
params: dict[str, Any] = {
|
|
152
|
-
"
|
|
153
|
-
"token_address": token_address,
|
|
213
|
+
"token": token,
|
|
154
214
|
}
|
|
155
215
|
|
|
156
216
|
response = await self._authed_request("GET", url, params=params, headers={})
|
|
@@ -161,30 +221,31 @@ class HyperlendClient(WayfinderClient):
|
|
|
161
221
|
async def get_lend_rate_history(
|
|
162
222
|
self,
|
|
163
223
|
*,
|
|
164
|
-
|
|
165
|
-
token_address: str,
|
|
224
|
+
token: str,
|
|
166
225
|
lookback_hours: int,
|
|
226
|
+
force_refresh: bool | None = None,
|
|
167
227
|
) -> LendRateHistory:
|
|
168
228
|
"""
|
|
169
229
|
Fetch lend rate history from Hyperlend.
|
|
170
230
|
|
|
171
231
|
Args:
|
|
172
|
-
|
|
173
|
-
token_address: Token address to query rate history for
|
|
232
|
+
token: Token address to query rate history for
|
|
174
233
|
lookback_hours: Number of hours to look back for rate history
|
|
234
|
+
force_refresh: Whether to force refresh the data (optional)
|
|
175
235
|
|
|
176
236
|
Example:
|
|
177
|
-
GET /api/v1/
|
|
237
|
+
GET /api/v1/blockchain/hyperlend/lend_rate_history/?token=0x5555555555555555555555555555555555555555&lookback_hours=24&force_refresh=false
|
|
178
238
|
|
|
179
239
|
Returns:
|
|
180
|
-
Dictionary containing lend rate history data
|
|
240
|
+
Dictionary containing lend rate history data with history array
|
|
181
241
|
"""
|
|
182
|
-
url = f"{self.api_base_url}/
|
|
242
|
+
url = f"{self.api_base_url}/v1/blockchain/hyperlend/lend_rate_history/"
|
|
183
243
|
params: dict[str, Any] = {
|
|
184
|
-
"
|
|
185
|
-
"token_address": token_address,
|
|
244
|
+
"token": token,
|
|
186
245
|
"lookback_hours": lookback_hours,
|
|
187
246
|
}
|
|
247
|
+
if force_refresh is not None:
|
|
248
|
+
params["force_refresh"] = "true" if force_refresh else "false"
|
|
188
249
|
|
|
189
250
|
response = await self._authed_request("GET", url, params=params, headers={})
|
|
190
251
|
response.raise_for_status()
|
|
@@ -63,14 +63,11 @@ class LedgerClient:
|
|
|
63
63
|
- POST record snapshot
|
|
64
64
|
"""
|
|
65
65
|
|
|
66
|
-
def __init__(
|
|
67
|
-
self, api_key: str | None = None, ledger_dir: Path | str | None = None
|
|
68
|
-
) -> None:
|
|
66
|
+
def __init__(self, ledger_dir: Path | str | None = None) -> None:
|
|
69
67
|
"""
|
|
70
68
|
Initialize the ledger client.
|
|
71
69
|
|
|
72
70
|
Args:
|
|
73
|
-
api_key: Unused, kept for backward compatibility
|
|
74
71
|
ledger_dir: Directory to store ledger JSON files. Defaults to .ledger in project root
|
|
75
72
|
"""
|
|
76
73
|
if ledger_dir is None:
|
|
@@ -1,112 +1,150 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Pool Client
|
|
3
|
-
Provides read-only access to pool metadata and analytics via public endpoints.
|
|
4
|
-
"""
|
|
1
|
+
"""Read-only pool metadata and analytics via public endpoints."""
|
|
5
2
|
|
|
6
3
|
from __future__ import annotations
|
|
7
4
|
|
|
8
|
-
from typing import Any,
|
|
5
|
+
from typing import Any, Required, TypedDict
|
|
9
6
|
|
|
10
|
-
from wayfinder_paths.core.clients.AuthClient import AuthClient
|
|
11
7
|
from wayfinder_paths.core.clients.WayfinderClient import WayfinderClient
|
|
12
|
-
from wayfinder_paths.core.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
class
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
8
|
+
from wayfinder_paths.core.config import get_api_base_url
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class PoolPredictions(TypedDict, total=False):
|
|
12
|
+
predictedClass: str | None
|
|
13
|
+
predictedProbability: int | None
|
|
14
|
+
binnedConfidence: int | None
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class PoolData(TypedDict, total=False):
|
|
18
|
+
pool: str
|
|
19
|
+
timestamp: str
|
|
20
|
+
project: str
|
|
21
|
+
chain: str
|
|
22
|
+
symbol: str
|
|
23
|
+
poolMeta: str | None
|
|
24
|
+
underlyingTokens: list[str]
|
|
25
|
+
rewardTokens: list[str] | None
|
|
26
|
+
tvlUsd: float
|
|
27
|
+
apy: float
|
|
28
|
+
apyBase: float
|
|
29
|
+
apyReward: float | None
|
|
30
|
+
il7d: float | None
|
|
31
|
+
apyBase7d: float | None
|
|
32
|
+
volumeUsd1d: float | None
|
|
33
|
+
volumeUsd7d: float | None
|
|
34
|
+
apyBaseInception: float | None
|
|
35
|
+
url: str
|
|
36
|
+
apyPct1D: float
|
|
37
|
+
apyPct7D: float
|
|
38
|
+
apyPct30D: float
|
|
39
|
+
apyMean30d: float
|
|
40
|
+
stablecoin: bool
|
|
41
|
+
ilRisk: str
|
|
42
|
+
exposure: str
|
|
43
|
+
count: int
|
|
44
|
+
apyMeanExpanding: float
|
|
45
|
+
apyStdExpanding: float
|
|
46
|
+
mu: float
|
|
47
|
+
sigma: float
|
|
48
|
+
outlier: bool
|
|
49
|
+
project_factorized: int
|
|
50
|
+
chain_factorized: int
|
|
51
|
+
predictions: PoolPredictions
|
|
52
|
+
pool_old: str
|
|
53
|
+
pool_old_addr: str
|
|
54
|
+
pool_old_chain: str
|
|
55
|
+
apy_pct: float
|
|
56
|
+
kind: str
|
|
57
|
+
source: str
|
|
58
|
+
underlying_apy_pct: float | None
|
|
59
|
+
combined_apy_pct: float
|
|
60
|
+
id: str
|
|
61
|
+
address: str
|
|
62
|
+
network: str
|
|
63
|
+
chain_code: str
|
|
31
64
|
|
|
32
65
|
|
|
33
66
|
class PoolList(TypedDict):
|
|
34
|
-
"""Pool list response structure"""
|
|
35
|
-
|
|
36
67
|
pools: Required[list[PoolData]]
|
|
37
|
-
total: NotRequired[int | None]
|
|
38
|
-
|
|
39
68
|
|
|
40
|
-
class LlamaMatch(TypedDict):
|
|
41
|
-
"""Llama match data structure"""
|
|
42
69
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
70
|
+
class LlamaMatchesResponse(TypedDict):
|
|
71
|
+
matches: Required[list[PoolData]]
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def _normalize_pool(raw: dict[str, Any]) -> dict[str, Any]:
|
|
75
|
+
out = dict(raw)
|
|
76
|
+
pool_id_val = out.get("pool")
|
|
77
|
+
if pool_id_val is not None:
|
|
78
|
+
if "id" not in out:
|
|
79
|
+
out["id"] = pool_id_val
|
|
80
|
+
if "token_id" not in out:
|
|
81
|
+
out["token_id"] = pool_id_val
|
|
82
|
+
if "pool_id" not in out:
|
|
83
|
+
out["pool_id"] = pool_id_val
|
|
84
|
+
if "address" not in out and "pool_old_addr" in out:
|
|
85
|
+
out["address"] = out["pool_old_addr"]
|
|
86
|
+
chain_val = out.get("pool_old_chain") or out.get("chain")
|
|
87
|
+
if chain_val is not None:
|
|
88
|
+
chain_lower = (
|
|
89
|
+
chain_val.lower() if isinstance(chain_val, str) else str(chain_val)
|
|
90
|
+
)
|
|
91
|
+
if "network" not in out:
|
|
92
|
+
out["network"] = chain_lower
|
|
93
|
+
if "chain_code" not in out:
|
|
94
|
+
out["chain_code"] = chain_lower
|
|
95
|
+
return out
|
|
57
96
|
|
|
58
97
|
|
|
59
98
|
class PoolClient(WayfinderClient):
|
|
60
|
-
|
|
99
|
+
def __init__(self):
|
|
100
|
+
super().__init__()
|
|
101
|
+
self.api_base_url = get_api_base_url()
|
|
61
102
|
|
|
62
|
-
def
|
|
63
|
-
|
|
64
|
-
self.api_base_url = f"{settings.WAYFINDER_API_URL}"
|
|
65
|
-
self._auth_client: AuthClient | None = AuthClient(api_key=api_key)
|
|
103
|
+
def _pools_url(self) -> str:
|
|
104
|
+
return f"{self.api_base_url}/v1/blockchain/pools/"
|
|
66
105
|
|
|
67
|
-
async def
|
|
106
|
+
async def get_pools(
|
|
68
107
|
self,
|
|
69
108
|
*,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
) ->
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
url = f"{self.api_base_url}/public/pools/"
|
|
80
|
-
params: dict[str, Any] = {"pool_ids": pool_ids}
|
|
81
|
-
if merge_external is not None:
|
|
82
|
-
params["merge_external"] = "true" if merge_external else "false"
|
|
109
|
+
chain_id: int | None = None,
|
|
110
|
+
project: str | None = None,
|
|
111
|
+
) -> LlamaMatchesResponse:
|
|
112
|
+
url = self._pools_url()
|
|
113
|
+
params: dict[str, Any] = {}
|
|
114
|
+
if chain_id is not None:
|
|
115
|
+
params["chain_id"] = chain_id
|
|
116
|
+
if project is not None:
|
|
117
|
+
params["project"] = project
|
|
83
118
|
response = await self._request("GET", url, params=params, headers={})
|
|
84
119
|
response.raise_for_status()
|
|
85
120
|
data = response.json()
|
|
86
|
-
|
|
121
|
+
if isinstance(data, list):
|
|
122
|
+
data = [_normalize_pool(p) for p in data]
|
|
123
|
+
return {"matches": data}
|
|
124
|
+
inner = data.get("data", data)
|
|
125
|
+
if isinstance(inner, list):
|
|
126
|
+
return {"matches": [_normalize_pool(p) for p in inner]}
|
|
127
|
+
return {"matches": inner.get("matches", [])}
|
|
87
128
|
|
|
88
|
-
async def
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
"""
|
|
102
|
-
Fetch Llama reports using identifiers (token ids, address_network, or pool ids).
|
|
103
|
-
|
|
104
|
-
Example:
|
|
105
|
-
GET /api/v1/public/pools/llama/reports/?identifiers=pool-1,usd-coin
|
|
106
|
-
"""
|
|
107
|
-
url = f"{self.api_base_url}/public/pools/llama/reports/"
|
|
108
|
-
params = {"identifiers": identifiers}
|
|
109
|
-
response = await self._request("GET", url, params=params, headers={})
|
|
129
|
+
async def get_pools_by_ids(
|
|
130
|
+
self,
|
|
131
|
+
*,
|
|
132
|
+
pool_ids: list[str] | str,
|
|
133
|
+
) -> PoolList:
|
|
134
|
+
url = self._pools_url()
|
|
135
|
+
ids = (
|
|
136
|
+
pool_ids
|
|
137
|
+
if isinstance(pool_ids, list)
|
|
138
|
+
else [s.strip() for s in str(pool_ids).split(",") if s.strip()]
|
|
139
|
+
)
|
|
140
|
+
body: dict[str, Any] = {"pool_ids": ids}
|
|
141
|
+
response = await self._request("POST", url, json=body, headers={})
|
|
110
142
|
response.raise_for_status()
|
|
111
143
|
data = response.json()
|
|
112
|
-
|
|
144
|
+
if isinstance(data, list):
|
|
145
|
+
data = [_normalize_pool(p) for p in data]
|
|
146
|
+
return {"pools": data}
|
|
147
|
+
inner = data.get("data", data)
|
|
148
|
+
if isinstance(inner, list):
|
|
149
|
+
return {"pools": [_normalize_pool(p) for p in inner]}
|
|
150
|
+
return {"pools": inner.get("pools", [])}
|