wayfinder-paths 0.1.13__py3-none-any.whl → 0.1.15__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.

Files changed (61) hide show
  1. wayfinder_paths/adapters/balance_adapter/README.md +13 -14
  2. wayfinder_paths/adapters/balance_adapter/adapter.py +73 -32
  3. wayfinder_paths/adapters/balance_adapter/test_adapter.py +123 -0
  4. wayfinder_paths/adapters/brap_adapter/README.md +11 -16
  5. wayfinder_paths/adapters/brap_adapter/adapter.py +144 -78
  6. wayfinder_paths/adapters/brap_adapter/examples.json +63 -52
  7. wayfinder_paths/adapters/brap_adapter/test_adapter.py +127 -65
  8. wayfinder_paths/adapters/hyperlend_adapter/adapter.py +30 -14
  9. wayfinder_paths/adapters/hyperlend_adapter/test_adapter.py +121 -67
  10. wayfinder_paths/adapters/hyperliquid_adapter/test_adapter.py +6 -6
  11. wayfinder_paths/adapters/hyperliquid_adapter/test_adapter_live.py +12 -12
  12. wayfinder_paths/adapters/ledger_adapter/test_adapter.py +6 -6
  13. wayfinder_paths/adapters/moonwell_adapter/adapter.py +332 -9
  14. wayfinder_paths/adapters/moonwell_adapter/test_adapter.py +13 -13
  15. wayfinder_paths/adapters/pool_adapter/README.md +9 -10
  16. wayfinder_paths/adapters/pool_adapter/adapter.py +9 -10
  17. wayfinder_paths/adapters/pool_adapter/test_adapter.py +2 -2
  18. wayfinder_paths/adapters/token_adapter/README.md +2 -14
  19. wayfinder_paths/adapters/token_adapter/adapter.py +16 -10
  20. wayfinder_paths/adapters/token_adapter/examples.json +4 -8
  21. wayfinder_paths/adapters/token_adapter/test_adapter.py +9 -7
  22. wayfinder_paths/core/clients/BRAPClient.py +102 -61
  23. wayfinder_paths/core/clients/ClientManager.py +1 -68
  24. wayfinder_paths/core/clients/HyperlendClient.py +125 -64
  25. wayfinder_paths/core/clients/LedgerClient.py +1 -4
  26. wayfinder_paths/core/clients/PoolClient.py +122 -48
  27. wayfinder_paths/core/clients/TokenClient.py +91 -36
  28. wayfinder_paths/core/clients/WalletClient.py +26 -56
  29. wayfinder_paths/core/clients/WayfinderClient.py +28 -160
  30. wayfinder_paths/core/clients/__init__.py +0 -2
  31. wayfinder_paths/core/clients/protocols.py +35 -46
  32. wayfinder_paths/core/clients/sdk_example.py +37 -22
  33. wayfinder_paths/core/constants/erc20_abi.py +0 -11
  34. wayfinder_paths/core/engine/StrategyJob.py +10 -56
  35. wayfinder_paths/core/services/base.py +1 -0
  36. wayfinder_paths/core/services/local_evm_txn.py +25 -9
  37. wayfinder_paths/core/services/local_token_txn.py +2 -6
  38. wayfinder_paths/core/services/test_local_evm_txn.py +145 -0
  39. wayfinder_paths/core/strategies/Strategy.py +16 -4
  40. wayfinder_paths/core/utils/evm_helpers.py +2 -9
  41. wayfinder_paths/policies/erc20.py +1 -1
  42. wayfinder_paths/run_strategy.py +13 -19
  43. wayfinder_paths/strategies/basis_trading_strategy/strategy.py +77 -11
  44. wayfinder_paths/strategies/basis_trading_strategy/test_strategy.py +6 -6
  45. wayfinder_paths/strategies/hyperlend_stable_yield_strategy/strategy.py +107 -23
  46. wayfinder_paths/strategies/hyperlend_stable_yield_strategy/test_strategy.py +54 -9
  47. wayfinder_paths/strategies/moonwell_wsteth_loop_strategy/README.md +6 -5
  48. wayfinder_paths/strategies/moonwell_wsteth_loop_strategy/strategy.py +2246 -1279
  49. wayfinder_paths/strategies/moonwell_wsteth_loop_strategy/test_strategy.py +276 -109
  50. wayfinder_paths/strategies/stablecoin_yield_strategy/README.md +1 -1
  51. wayfinder_paths/strategies/stablecoin_yield_strategy/strategy.py +153 -56
  52. wayfinder_paths/strategies/stablecoin_yield_strategy/test_strategy.py +16 -12
  53. wayfinder_paths/templates/adapter/README.md +1 -1
  54. wayfinder_paths/templates/strategy/README.md +3 -3
  55. wayfinder_paths/templates/strategy/test_strategy.py +3 -2
  56. {wayfinder_paths-0.1.13.dist-info → wayfinder_paths-0.1.15.dist-info}/METADATA +14 -49
  57. {wayfinder_paths-0.1.13.dist-info → wayfinder_paths-0.1.15.dist-info}/RECORD +59 -60
  58. wayfinder_paths/abis/generic/erc20.json +0 -383
  59. wayfinder_paths/core/clients/AuthClient.py +0 -83
  60. {wayfinder_paths-0.1.13.dist-info → wayfinder_paths-0.1.15.dist-info}/LICENSE +0 -0
  61. {wayfinder_paths-0.1.13.dist-info → wayfinder_paths-0.1.15.dist-info}/WHEEL +0 -0
@@ -1,97 +1,163 @@
1
1
  """
2
2
  Hyperlend Client
3
- Provides access to Hyperlend stable markets data via public endpoints.
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, NotRequired, Required, TypedDict
8
+ from typing import Any, Required, TypedDict
9
9
 
10
10
  from wayfinder_paths.core.clients.WayfinderClient import WayfinderClient
11
11
  from wayfinder_paths.core.config import get_api_base_url
12
12
 
13
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]
25
-
26
-
27
14
  class AssetsView(TypedDict):
28
15
  """Assets view response structure"""
29
16
 
30
- chain_id: Required[int]
31
- user_address: Required[str]
32
- assets: Required[list[dict[str, Any]]]
33
- total_value: NotRequired[float | None]
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
- chain_id: Required[int]
40
- token_address: Required[str]
41
- market_data: Required[dict[str, Any]]
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
- chain_id: Required[int]
48
- token_address: Required[str]
49
- lookback_hours: Required[int]
50
- rates: Required[list[dict[str, Any]]]
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, api_key: str | None = None):
57
- super().__init__(api_key=api_key)
128
+ def __init__(self):
129
+ super().__init__()
58
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
- is_stable_symbol: bool | None = None,
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/public/hyperlend/stable-markets/?chain_id=999&required_underlying_tokens=1000.0&buffer_bps=100&min_buffer_tokens=100.0&is_stable_symbol=true
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}/public/hyperlend/stable-markets/"
86
- params: dict[str, Any] = {"chain_id": chain_id}
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/public/hyperlend/assets-view/?chain_id=999&user_address=0x0c737cB5934afCb5B01965141F865F795B324080
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}/public/hyperlend/assets-view/"
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
- chain_id: int,
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
- chain_id: Chain ID to query market for
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/public/hyperlend/market-entry/?chain_id=999&token_address=0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
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}/public/hyperlend/market-entry/"
211
+ url = f"{self.api_base_url}/v1/blockchain/hyperlend/market_entry/"
151
212
  params: dict[str, Any] = {
152
- "chain_id": chain_id,
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
- chain_id: int,
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
- chain_id: Chain ID to query rate history for
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/public/hyperlend/lend-rate-history/?chain_id=999&token_address=0x5555555555555555555555555555555555555555&lookback_hours=24
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}/public/hyperlend/lend-rate-history/"
242
+ url = f"{self.api_base_url}/v1/blockchain/hyperlend/lend_rate_history/"
183
243
  params: dict[str, Any] = {
184
- "chain_id": chain_id,
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,76 +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, NotRequired, Required, TypedDict
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
8
  from wayfinder_paths.core.config import get_api_base_url
13
9
 
14
10
 
15
- class PoolData(TypedDict):
16
- """Individual pool data structure"""
17
-
18
- id: Required[str]
19
- name: Required[str]
20
- symbol: Required[str]
21
- address: Required[str]
22
- chain_id: Required[int]
23
- chain_code: Required[str]
24
- apy: NotRequired[float]
25
- tvl: NotRequired[float]
26
- apy: NotRequired[float | None]
27
- tvlUsd: NotRequired[float | None]
28
- stablecoin: NotRequired[bool | None]
29
- ilRisk: NotRequired[str | None]
30
- network: NotRequired[str | None]
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
68
 
39
69
 
40
- class LlamaMatch(TypedDict):
41
- """Llama match data structure"""
42
-
43
- id: Required[str]
44
- apy: Required[float]
45
- tvlUsd: Required[float]
46
- stablecoin: Required[bool]
47
- ilRisk: Required[str]
48
- network: Required[str]
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
49
96
 
50
97
 
51
98
  class PoolClient(WayfinderClient):
52
- """Client for pool-related read operations"""
99
+ def __init__(self):
100
+ super().__init__()
101
+ self.api_base_url = get_api_base_url()
53
102
 
54
- def __init__(self, api_key: str | None = None):
55
- super().__init__(api_key=api_key)
56
- self.api_base_url = f"{get_api_base_url()}"
57
- 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/"
58
105
 
59
- async def get_pools(self) -> dict[str, LlamaMatch]:
60
- url = f"{self.api_base_url}/pools/"
61
- response = await self._request("GET", url, headers={})
106
+ async def get_pools(
107
+ self,
108
+ *,
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
118
+ response = await self._request("GET", url, params=params, headers={})
62
119
  response.raise_for_status()
63
120
  data = response.json()
64
- return data.get("data", data)
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", [])}
65
128
 
66
129
  async def get_pools_by_ids(
67
130
  self,
68
131
  *,
69
- pool_ids: str,
132
+ pool_ids: list[str] | str,
70
133
  ) -> PoolList:
71
- url = f"{self.api_base_url}/pools/"
72
- params: dict[str, Any] = {"pool_ids": pool_ids}
73
- response = await self._request("GET", url, params=params, headers={})
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={})
74
142
  response.raise_for_status()
75
143
  data = response.json()
76
- return data.get("data", data)
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", [])}