wayfinder-paths 0.1.19__py3-none-any.whl → 0.1.21__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 (98) hide show
  1. wayfinder_paths/__init__.py +0 -2
  2. wayfinder_paths/adapters/balance_adapter/README.md +59 -45
  3. wayfinder_paths/adapters/balance_adapter/adapter.py +1 -22
  4. wayfinder_paths/adapters/balance_adapter/test_adapter.py +0 -14
  5. wayfinder_paths/adapters/brap_adapter/README.md +61 -184
  6. wayfinder_paths/adapters/brap_adapter/__init__.py +0 -4
  7. wayfinder_paths/adapters/brap_adapter/adapter.py +1 -148
  8. wayfinder_paths/adapters/brap_adapter/test_adapter.py +0 -15
  9. wayfinder_paths/adapters/hyperlend_adapter/__init__.py +0 -4
  10. wayfinder_paths/adapters/hyperlend_adapter/adapter.py +1 -10
  11. wayfinder_paths/adapters/hyperlend_adapter/test_adapter.py +0 -17
  12. wayfinder_paths/adapters/hyperliquid_adapter/adapter.py +3 -312
  13. wayfinder_paths/adapters/hyperliquid_adapter/executor.py +1 -71
  14. wayfinder_paths/adapters/hyperliquid_adapter/paired_filler.py +0 -57
  15. wayfinder_paths/adapters/hyperliquid_adapter/test_adapter.py +0 -17
  16. wayfinder_paths/adapters/hyperliquid_adapter/test_adapter_live.py +2 -42
  17. wayfinder_paths/adapters/hyperliquid_adapter/test_executor.py +1 -9
  18. wayfinder_paths/adapters/hyperliquid_adapter/test_utils.py +15 -47
  19. wayfinder_paths/adapters/hyperliquid_adapter/utils.py +0 -7
  20. wayfinder_paths/adapters/ledger_adapter/README.md +54 -74
  21. wayfinder_paths/adapters/ledger_adapter/__init__.py +0 -4
  22. wayfinder_paths/adapters/ledger_adapter/adapter.py +0 -106
  23. wayfinder_paths/adapters/ledger_adapter/test_adapter.py +0 -12
  24. wayfinder_paths/adapters/moonwell_adapter/README.md +67 -106
  25. wayfinder_paths/adapters/moonwell_adapter/__init__.py +0 -4
  26. wayfinder_paths/adapters/moonwell_adapter/adapter.py +10 -122
  27. wayfinder_paths/adapters/moonwell_adapter/test_adapter.py +84 -83
  28. wayfinder_paths/adapters/pool_adapter/README.md +30 -51
  29. wayfinder_paths/adapters/pool_adapter/__init__.py +0 -4
  30. wayfinder_paths/adapters/pool_adapter/adapter.py +0 -19
  31. wayfinder_paths/adapters/pool_adapter/test_adapter.py +0 -8
  32. wayfinder_paths/adapters/token_adapter/README.md +41 -49
  33. wayfinder_paths/adapters/token_adapter/adapter.py +0 -32
  34. wayfinder_paths/adapters/token_adapter/test_adapter.py +1 -12
  35. wayfinder_paths/conftest.py +0 -8
  36. wayfinder_paths/core/__init__.py +0 -2
  37. wayfinder_paths/core/adapters/BaseAdapter.py +0 -22
  38. wayfinder_paths/core/adapters/__init__.py +0 -5
  39. wayfinder_paths/core/adapters/models.py +0 -5
  40. wayfinder_paths/core/analytics/__init__.py +0 -2
  41. wayfinder_paths/core/analytics/bootstrap.py +0 -16
  42. wayfinder_paths/core/analytics/stats.py +0 -7
  43. wayfinder_paths/core/analytics/test_analytics.py +5 -34
  44. wayfinder_paths/core/clients/BRAPClient.py +0 -35
  45. wayfinder_paths/core/clients/ClientManager.py +0 -51
  46. wayfinder_paths/core/clients/HyperlendClient.py +0 -77
  47. wayfinder_paths/core/clients/LedgerClient.py +2 -122
  48. wayfinder_paths/core/clients/PoolClient.py +0 -2
  49. wayfinder_paths/core/clients/TokenClient.py +0 -39
  50. wayfinder_paths/core/clients/WalletClient.py +0 -15
  51. wayfinder_paths/core/clients/WayfinderClient.py +0 -24
  52. wayfinder_paths/core/clients/__init__.py +0 -4
  53. wayfinder_paths/core/clients/protocols.py +25 -98
  54. wayfinder_paths/core/config.py +0 -24
  55. wayfinder_paths/core/constants/__init__.py +0 -7
  56. wayfinder_paths/core/constants/base.py +2 -9
  57. wayfinder_paths/core/constants/erc20_abi.py +0 -5
  58. wayfinder_paths/core/constants/hyperlend_abi.py +0 -7
  59. wayfinder_paths/core/constants/moonwell_abi.py +0 -35
  60. wayfinder_paths/core/engine/StrategyJob.py +0 -32
  61. wayfinder_paths/core/strategies/Strategy.py +0 -99
  62. wayfinder_paths/core/strategies/__init__.py +0 -2
  63. wayfinder_paths/core/utils/__init__.py +0 -1
  64. wayfinder_paths/core/utils/evm_helpers.py +0 -50
  65. wayfinder_paths/core/utils/{erc20_service.py → tokens.py} +25 -21
  66. wayfinder_paths/core/utils/transaction.py +0 -1
  67. wayfinder_paths/run_strategy.py +0 -46
  68. wayfinder_paths/scripts/create_strategy.py +0 -17
  69. wayfinder_paths/scripts/make_wallets.py +1 -4
  70. wayfinder_paths/strategies/basis_trading_strategy/README.md +71 -163
  71. wayfinder_paths/strategies/basis_trading_strategy/snapshot_mixin.py +0 -24
  72. wayfinder_paths/strategies/basis_trading_strategy/strategy.py +36 -400
  73. wayfinder_paths/strategies/basis_trading_strategy/test_strategy.py +15 -64
  74. wayfinder_paths/strategies/basis_trading_strategy/types.py +0 -4
  75. wayfinder_paths/strategies/hyperlend_stable_yield_strategy/README.md +65 -56
  76. wayfinder_paths/strategies/hyperlend_stable_yield_strategy/strategy.py +4 -27
  77. wayfinder_paths/strategies/hyperlend_stable_yield_strategy/test_strategy.py +0 -10
  78. wayfinder_paths/strategies/moonwell_wsteth_loop_strategy/README.md +71 -72
  79. wayfinder_paths/strategies/moonwell_wsteth_loop_strategy/strategy.py +23 -227
  80. wayfinder_paths/strategies/moonwell_wsteth_loop_strategy/test_strategy.py +120 -113
  81. wayfinder_paths/strategies/stablecoin_yield_strategy/README.md +64 -59
  82. wayfinder_paths/strategies/stablecoin_yield_strategy/strategy.py +4 -44
  83. wayfinder_paths/strategies/stablecoin_yield_strategy/test_strategy.py +2 -35
  84. wayfinder_paths/templates/adapter/README.md +107 -46
  85. wayfinder_paths/templates/adapter/adapter.py +0 -9
  86. wayfinder_paths/templates/adapter/test_adapter.py +0 -19
  87. wayfinder_paths/templates/strategy/README.md +113 -59
  88. wayfinder_paths/templates/strategy/strategy.py +0 -22
  89. wayfinder_paths/templates/strategy/test_strategy.py +0 -28
  90. wayfinder_paths/tests/test_test_coverage.py +2 -12
  91. wayfinder_paths/tests/test_utils.py +1 -31
  92. wayfinder_paths-0.1.21.dist-info/METADATA +355 -0
  93. wayfinder_paths-0.1.21.dist-info/RECORD +129 -0
  94. {wayfinder_paths-0.1.19.dist-info → wayfinder_paths-0.1.21.dist-info}/WHEEL +1 -1
  95. wayfinder_paths/core/adapters/base.py +0 -5
  96. wayfinder_paths-0.1.19.dist-info/METADATA +0 -592
  97. wayfinder_paths-0.1.19.dist-info/RECORD +0 -130
  98. {wayfinder_paths-0.1.19.dist-info → wayfinder_paths-0.1.21.dist-info}/LICENSE +0 -0
@@ -11,11 +11,6 @@ from wayfinder_paths.core.constants.base import DEFAULT_HTTP_TIMEOUT
11
11
 
12
12
  class WayfinderClient:
13
13
  def __init__(self):
14
- """
15
- Initialize WayfinderClient.
16
-
17
- API key is loaded from system.api_key in config.json.
18
- """
19
14
  self.api_base_url = f"{get_api_base_url()}/"
20
15
  timeout = httpx.Timeout(DEFAULT_HTTP_TIMEOUT)
21
16
  self.client = httpx.AsyncClient(timeout=timeout)
@@ -25,17 +20,9 @@ class WayfinderClient:
25
20
  }
26
21
 
27
22
  def clear_auth(self) -> None:
28
- """Clear X-API-KEY header."""
29
23
  self.headers.pop("X-API-KEY", None)
30
24
 
31
25
  def _load_config_credentials(self) -> dict[str, str | None]:
32
- """
33
- Load API key from config.json.
34
- Expected shape:
35
- {
36
- "system": { "api_key": ... }
37
- }
38
- """
39
26
  try:
40
27
  with open("config.json") as f:
41
28
  cfg = json.load(f)
@@ -50,10 +37,6 @@ class WayfinderClient:
50
37
  return {"api_key": None}
51
38
 
52
39
  def _ensure_api_key(self) -> bool:
53
- """
54
- Ensure X-API-KEY header is set from system.api_key in config.json.
55
- Raises PermissionError if no API key found.
56
- """
57
40
  if self.headers.get("X-API-KEY"):
58
41
  return True
59
42
 
@@ -80,10 +63,6 @@ class WayfinderClient:
80
63
  retry_on_401: bool = False,
81
64
  **kwargs: Any,
82
65
  ) -> httpx.Response:
83
- """
84
- Wrapper around httpx that injects X-API-KEY header.
85
- Ensures API key is set in headers when available (for authentication and rate limiting).
86
- """
87
66
  logger.debug(f"Making {method} request to {url}")
88
67
  start_time = time.time()
89
68
 
@@ -124,8 +103,5 @@ class WayfinderClient:
124
103
  headers: dict[str, str] | None = None,
125
104
  **kwargs: Any,
126
105
  ) -> httpx.Response:
127
- """
128
- Ensure X-API-KEY header is set (from system.api_key in config.json) and perform the request.
129
- """
130
106
  self._ensure_api_key()
131
107
  return await self._request(method, url, headers=headers, **kwargs)
@@ -1,7 +1,3 @@
1
- """
2
- Core client modules for API communication
3
- """
4
-
5
1
  from wayfinder_paths.core.clients.BRAPClient import BRAPClient
6
2
  from wayfinder_paths.core.clients.ClientManager import ClientManager
7
3
  from wayfinder_paths.core.clients.HyperlendClient import HyperlendClient
@@ -1,12 +1,3 @@
1
- """
2
- Protocol definitions for API clients.
3
-
4
- These protocols define the interface that all client implementations must satisfy.
5
- When used as an SDK, users can provide custom implementations that match these protocols.
6
-
7
- Note: Authentication is handled via X-API-KEY header in WayfinderClient base class.
8
- """
9
-
10
1
  from __future__ import annotations
11
2
 
12
3
  from typing import TYPE_CHECKING, Any, Protocol
@@ -37,50 +28,36 @@ if TYPE_CHECKING:
37
28
 
38
29
 
39
30
  class TokenClientProtocol(Protocol):
40
- """Protocol for token-related operations"""
41
-
42
31
  async def get_token_details(
43
32
  self,
44
33
  query: str,
45
34
  market_data: bool = True,
46
35
  chain_id: int | None = None,
47
- ) -> TokenDetails:
48
- """Get token data including price from the token-details endpoint"""
49
- ...
36
+ ) -> TokenDetails: ...
50
37
 
51
- async def get_gas_token(self, chain_code: str) -> GasToken:
52
- """Fetch the native gas token for a given chain code"""
53
- ...
38
+ async def get_gas_token(self, chain_code: str) -> GasToken: ...
54
39
 
55
40
 
56
41
  class HyperlendClientProtocol(Protocol):
57
- """Protocol for Hyperlend-related operations"""
58
-
59
42
  async def get_stable_markets(
60
43
  self,
61
44
  *,
62
45
  required_underlying_tokens: float | None = None,
63
46
  buffer_bps: int | None = None,
64
47
  min_buffer_tokens: float | None = None,
65
- ) -> StableMarketsHeadroomResponse:
66
- """Fetch stable markets headroom from Hyperlend"""
67
- ...
48
+ ) -> StableMarketsHeadroomResponse: ...
68
49
 
69
50
  async def get_assets_view(
70
51
  self,
71
52
  *,
72
53
  user_address: str,
73
- ) -> AssetsView:
74
- """Fetch assets view for a user address from Hyperlend"""
75
- ...
54
+ ) -> AssetsView: ...
76
55
 
77
56
  async def get_market_entry(
78
57
  self,
79
58
  *,
80
59
  token: str,
81
- ) -> MarketEntry:
82
- """Fetch market entry from Hyperlend"""
83
- ...
60
+ ) -> MarketEntry: ...
84
61
 
85
62
  async def get_lend_rate_history(
86
63
  self,
@@ -88,33 +65,23 @@ class HyperlendClientProtocol(Protocol):
88
65
  token: str,
89
66
  lookback_hours: int,
90
67
  force_refresh: bool | None = None,
91
- ) -> LendRateHistory:
92
- """Fetch lend rate history from Hyperlend"""
93
- ...
68
+ ) -> LendRateHistory: ...
94
69
 
95
70
 
96
71
  class LedgerClientProtocol(Protocol):
97
- """Protocol for strategy transaction history and bookkeeping operations"""
98
-
99
72
  async def get_strategy_transactions(
100
73
  self,
101
74
  *,
102
75
  wallet_address: str,
103
76
  limit: int = 50,
104
77
  offset: int = 0,
105
- ) -> StrategyTransactionList:
106
- """Fetch a paginated list of transactions for a given strategy wallet"""
107
- ...
78
+ ) -> StrategyTransactionList: ...
108
79
 
109
- async def get_strategy_net_deposit(self, *, wallet_address: str) -> float:
110
- """Fetch the net deposit (deposits - withdrawals) for a strategy"""
111
- ...
80
+ async def get_strategy_net_deposit(self, *, wallet_address: str) -> float: ...
112
81
 
113
82
  async def get_strategy_latest_transactions(
114
83
  self, *, wallet_address: str
115
- ) -> StrategyTransactionList:
116
- """Fetch the latest transactions for a strategy"""
117
- ...
84
+ ) -> StrategyTransactionList: ...
118
85
 
119
86
  async def add_strategy_deposit(
120
87
  self,
@@ -126,9 +93,7 @@ class LedgerClientProtocol(Protocol):
126
93
  usd_value: str | float,
127
94
  data: dict[str, Any] | None = None,
128
95
  strategy_name: str | None = None,
129
- ) -> TransactionRecord:
130
- """Record a deposit for a strategy"""
131
- ...
96
+ ) -> TransactionRecord: ...
132
97
 
133
98
  async def add_strategy_withdraw(
134
99
  self,
@@ -140,9 +105,7 @@ class LedgerClientProtocol(Protocol):
140
105
  usd_value: str | float,
141
106
  data: dict[str, Any] | None = None,
142
107
  strategy_name: str | None = None,
143
- ) -> TransactionRecord:
144
- """Record a withdrawal for a strategy"""
145
- ...
108
+ ) -> TransactionRecord: ...
146
109
 
147
110
  async def add_strategy_operation(
148
111
  self,
@@ -151,49 +114,35 @@ class LedgerClientProtocol(Protocol):
151
114
  operation_data: dict[str, Any],
152
115
  usd_value: str | float,
153
116
  strategy_name: str | None = None,
154
- ) -> TransactionRecord:
155
- """Record a strategy operation (e.g., swaps, rebalances)"""
156
- ...
117
+ ) -> TransactionRecord: ...
157
118
 
158
119
 
159
120
  class WalletClientProtocol(Protocol):
160
- """Protocol for wallet-related operations"""
161
-
162
121
  async def get_token_balance_for_address(
163
122
  self,
164
123
  *,
165
124
  wallet_address: str,
166
125
  query: str,
167
126
  chain_id: int | None = None,
168
- ) -> AddressBalance:
169
- """Fetch a balance for an address + chain + query (supports compound query formats)"""
170
- ...
127
+ ) -> AddressBalance: ...
171
128
 
172
129
 
173
130
  class PoolClientProtocol(Protocol):
174
- """Protocol for pool-related read operations"""
175
-
176
131
  async def get_pools_by_ids(
177
132
  self,
178
133
  *,
179
134
  pool_ids: list[str] | str,
180
- ) -> PoolList:
181
- """Fetch pools by pool IDs (list or comma-separated string)"""
182
- ...
135
+ ) -> PoolList: ...
183
136
 
184
137
  async def get_pools(
185
138
  self,
186
139
  *,
187
140
  chain_id: int | None = None,
188
141
  project: str | None = None,
189
- ) -> LlamaMatchesResponse:
190
- """Fetch pools (optionally filtered by chain_id and project)"""
191
- ...
142
+ ) -> LlamaMatchesResponse: ...
192
143
 
193
144
 
194
145
  class BRAPClientProtocol(Protocol):
195
- """Protocol for BRAP (Bridge/Router/Adapter Protocol) quote operations"""
196
-
197
146
  async def get_quote(
198
147
  self,
199
148
  *,
@@ -203,14 +152,10 @@ class BRAPClientProtocol(Protocol):
203
152
  to_chain: int,
204
153
  from_wallet: str,
205
154
  from_amount: str,
206
- ) -> BRAPQuoteResponse:
207
- """Get a quote for a bridge/swap operation"""
208
- ...
155
+ ) -> BRAPQuoteResponse: ...
209
156
 
210
157
 
211
158
  class HyperliquidExecutorProtocol(Protocol):
212
- """Protocol for Hyperliquid order execution operations."""
213
-
214
159
  async def place_market_order(
215
160
  self,
216
161
  *,
@@ -222,9 +167,7 @@ class HyperliquidExecutorProtocol(Protocol):
222
167
  reduce_only: bool = False,
223
168
  cloid: Any = None,
224
169
  builder: dict[str, Any] | None = None,
225
- ) -> dict[str, Any]:
226
- """Place a market order."""
227
- ...
170
+ ) -> dict[str, Any]: ...
228
171
 
229
172
  async def cancel_order(
230
173
  self,
@@ -232,9 +175,7 @@ class HyperliquidExecutorProtocol(Protocol):
232
175
  asset_id: int,
233
176
  order_id: int,
234
177
  address: str,
235
- ) -> dict[str, Any]:
236
- """Cancel an open order."""
237
- ...
178
+ ) -> dict[str, Any]: ...
238
179
 
239
180
  async def update_leverage(
240
181
  self,
@@ -243,27 +184,21 @@ class HyperliquidExecutorProtocol(Protocol):
243
184
  leverage: int,
244
185
  is_cross: bool,
245
186
  address: str,
246
- ) -> dict[str, Any]:
247
- """Update leverage for an asset."""
248
- ...
187
+ ) -> dict[str, Any]: ...
249
188
 
250
189
  async def transfer_spot_to_perp(
251
190
  self,
252
191
  *,
253
192
  amount: float,
254
193
  address: str,
255
- ) -> dict[str, Any]:
256
- """Transfer USDC from spot to perp balance."""
257
- ...
194
+ ) -> dict[str, Any]: ...
258
195
 
259
196
  async def transfer_perp_to_spot(
260
197
  self,
261
198
  *,
262
199
  amount: float,
263
200
  address: str,
264
- ) -> dict[str, Any]:
265
- """Transfer USDC from perp to spot balance."""
266
- ...
201
+ ) -> dict[str, Any]: ...
267
202
 
268
203
  async def place_stop_loss(
269
204
  self,
@@ -273,9 +208,7 @@ class HyperliquidExecutorProtocol(Protocol):
273
208
  trigger_price: float,
274
209
  size: float,
275
210
  address: str,
276
- ) -> dict[str, Any]:
277
- """Place a stop-loss order."""
278
- ...
211
+ ) -> dict[str, Any]: ...
279
212
 
280
213
  async def place_limit_order(
281
214
  self,
@@ -287,18 +220,14 @@ class HyperliquidExecutorProtocol(Protocol):
287
220
  address: str,
288
221
  reduce_only: bool = False,
289
222
  builder: dict[str, Any] | None = None,
290
- ) -> dict[str, Any]:
291
- """Place a limit order."""
292
- ...
223
+ ) -> dict[str, Any]: ...
293
224
 
294
225
  async def withdraw(
295
226
  self,
296
227
  *,
297
228
  amount: float,
298
229
  address: str,
299
- ) -> dict[str, Any]:
300
- """Withdraw USDC from Hyperliquid to Arbitrum."""
301
- ...
230
+ ) -> dict[str, Any]: ...
302
231
 
303
232
  async def approve_builder_fee(
304
233
  self,
@@ -306,6 +235,4 @@ class HyperliquidExecutorProtocol(Protocol):
306
235
  builder: str,
307
236
  max_fee_rate: str,
308
237
  address: str,
309
- ) -> dict[str, Any]:
310
- """Approve a builder fee for the user."""
311
- ...
238
+ ) -> dict[str, Any]: ...
@@ -28,17 +28,6 @@ SUPPORTED_CHAINS = [
28
28
  ]
29
29
 
30
30
 
31
- @dataclass
32
- class UserConfig:
33
- username: str | None = None
34
- password: str | None = None
35
- refresh_token: str | None = None
36
- main_wallet_address: str | None = None
37
- strategy_wallet_address: str | None = None
38
- default_slippage: float = 0.005
39
- gas_multiplier: float = 1.2
40
-
41
-
42
31
  @dataclass
43
32
  class SystemConfig:
44
33
  api_base_url: str = field(default="https://api.wayfinder.ai")
@@ -54,7 +43,6 @@ class SystemConfig:
54
43
 
55
44
  @dataclass
56
45
  class StrategyJobConfig:
57
- user: UserConfig
58
46
  system: SystemConfig
59
47
  strategy_config: dict[str, Any] = field(default_factory=dict)
60
48
 
@@ -161,17 +149,6 @@ class StrategyJobConfig:
161
149
  def from_dict(
162
150
  cls, data: dict[str, Any], strategy_name: str | None = None
163
151
  ) -> "StrategyJobConfig":
164
- user_data = data.get("user", {})
165
- user_cfg = UserConfig(
166
- username=user_data.get("username"),
167
- password=user_data.get("password"),
168
- refresh_token=user_data.get("refresh_token"),
169
- main_wallet_address=user_data.get("main_wallet_address"),
170
- strategy_wallet_address=user_data.get("strategy_wallet_address"),
171
- default_slippage=user_data.get("default_slippage", 0.005),
172
- gas_multiplier=user_data.get("gas_multiplier", 1.2),
173
- )
174
-
175
152
  system_data = data.get("system", {})
176
153
  sys_cfg = SystemConfig(
177
154
  api_base_url=system_data.get("api_base_url", "https://api.wayfinder.ai"),
@@ -189,7 +166,6 @@ class StrategyJobConfig:
189
166
  if strategy_name:
190
167
  strategy_config["_strategy_name"] = strategy_name
191
168
  return cls(
192
- user=user_cfg,
193
169
  system=sys_cfg,
194
170
  strategy_config=strategy_config,
195
171
  )
@@ -1,10 +1,3 @@
1
- """Constants package for wayfinder-paths.
2
-
3
- This package contains all constants used across the system, organized by category:
4
- - base: Fundamental constants (addresses, chain mappings, gas defaults)
5
- - erc20_abi: ERC20 token ABI definitions for smart contract interactions
6
- """
7
-
8
1
  from .base import (
9
2
  CHAIN_CODE_TO_ID,
10
3
  DEFAULT_NATIVE_GAS_UNITS,
@@ -1,10 +1,3 @@
1
- """Base constants for adapters and strategies.
2
-
3
- This module contains fundamental constants used across the wayfinder-paths system,
4
- including address constants, chain mappings, and gas-related defaults.
5
- """
6
-
7
- # Address constants
8
1
  ZERO_ADDRESS = "0x0000000000000000000000000000000000000000"
9
2
 
10
3
  # Chain code to EVM chain id mapping
@@ -21,7 +14,7 @@ CHAIN_CODE_TO_ID = {
21
14
  DEFAULT_NATIVE_GAS_UNITS = 21000
22
15
  # Fallback gas limit used only when RPC gas estimation fails for non-revert reasons.
23
16
  # Must be high enough for typical DeFi interactions (lending, swaps, etc.).
24
- GAS_BUFFER_MULTIPLIER = 1.1 # 10% buffer for native sends
17
+ GAS_BUFFER_MULTIPLIER = 1.1
25
18
  ONE_GWEI = 1_000_000_000
26
19
  DEFAULT_SLIPPAGE = 0.005
27
20
 
@@ -42,4 +35,4 @@ ADAPTER_LEDGER = "LEDGER"
42
35
  ADAPTER_HYPERLEND = "HYPERLEND"
43
36
 
44
37
  # Pagination defaults
45
- DEFAULT_PAGINATION_LIMIT = 50 # Default limit for paginated API responses
38
+ DEFAULT_PAGINATION_LIMIT = 50
@@ -1,8 +1,3 @@
1
- """
2
- ERC20 ABI constants for consistent use across the codebase.
3
- This centralizes ABI definitions to avoid duplication and improve maintainability.
4
- """
5
-
6
1
  # Standard ERC20 ABI - includes common functions needed for token operations
7
2
  ERC20_ABI = [
8
3
  {
@@ -1,10 +1,3 @@
1
- """
2
- HyperLend ABI constants for smart contract interactions.
3
-
4
- This module contains ABI definitions for HyperLend protocol contracts,
5
- including Pool, Protocol Data Provider, Wrapped Token Gateway, and WETH contracts.
6
- """
7
-
8
1
  # Minimal Pool ABI for supply and deposit operations
9
2
  POOL_ABI = [
10
3
  {
@@ -1,10 +1,3 @@
1
- """
2
- Moonwell ABI constants for smart contract interactions.
3
-
4
- This module contains ABI definitions for Moonwell protocol contracts,
5
- including mToken (ERC20 Delegator), Comptroller, and Reward Distributor contracts.
6
- """
7
-
8
1
  # mToken (CErc20Delegator) ABI - for lending, borrowing, and position management
9
2
  MTOKEN_ABI = [
10
3
  # Lend (supply) tokens by minting mTokens
@@ -47,7 +40,6 @@ MTOKEN_ABI = [
47
40
  "inputs": [{"name": "repayAmount", "type": "uint256"}],
48
41
  "outputs": [{"name": "", "type": "uint256"}],
49
42
  },
50
- # Get mToken balance
51
43
  {
52
44
  "name": "balanceOf",
53
45
  "type": "function",
@@ -55,7 +47,6 @@ MTOKEN_ABI = [
55
47
  "inputs": [{"name": "owner", "type": "address"}],
56
48
  "outputs": [{"name": "", "type": "uint256"}],
57
49
  },
58
- # Get underlying balance (including accrued interest)
59
50
  {
60
51
  "name": "balanceOfUnderlying",
61
52
  "type": "function",
@@ -63,7 +54,6 @@ MTOKEN_ABI = [
63
54
  "inputs": [{"name": "owner", "type": "address"}],
64
55
  "outputs": [{"name": "", "type": "uint256"}],
65
56
  },
66
- # Get current borrow balance (including interest)
67
57
  {
68
58
  "name": "borrowBalanceCurrent",
69
59
  "type": "function",
@@ -71,7 +61,6 @@ MTOKEN_ABI = [
71
61
  "inputs": [{"name": "account", "type": "address"}],
72
62
  "outputs": [{"name": "", "type": "uint256"}],
73
63
  },
74
- # Get stored borrow balance (without accruing interest first)
75
64
  {
76
65
  "name": "borrowBalanceStored",
77
66
  "type": "function",
@@ -79,7 +68,6 @@ MTOKEN_ABI = [
79
68
  "inputs": [{"name": "account", "type": "address"}],
80
69
  "outputs": [{"name": "", "type": "uint256"}],
81
70
  },
82
- # Get exchange rate between mToken and underlying
83
71
  {
84
72
  "name": "exchangeRateCurrent",
85
73
  "type": "function",
@@ -87,7 +75,6 @@ MTOKEN_ABI = [
87
75
  "inputs": [],
88
76
  "outputs": [{"name": "", "type": "uint256"}],
89
77
  },
90
- # Get stored exchange rate
91
78
  {
92
79
  "name": "exchangeRateStored",
93
80
  "type": "function",
@@ -95,7 +82,6 @@ MTOKEN_ABI = [
95
82
  "inputs": [],
96
83
  "outputs": [{"name": "", "type": "uint256"}],
97
84
  },
98
- # Get underlying token address
99
85
  {
100
86
  "name": "underlying",
101
87
  "type": "function",
@@ -103,7 +89,6 @@ MTOKEN_ABI = [
103
89
  "inputs": [],
104
90
  "outputs": [{"name": "", "type": "address"}],
105
91
  },
106
- # Get supply rate per timestamp
107
92
  {
108
93
  "name": "supplyRatePerTimestamp",
109
94
  "type": "function",
@@ -111,7 +96,6 @@ MTOKEN_ABI = [
111
96
  "inputs": [],
112
97
  "outputs": [{"name": "", "type": "uint256"}],
113
98
  },
114
- # Get borrow rate per timestamp
115
99
  {
116
100
  "name": "borrowRatePerTimestamp",
117
101
  "type": "function",
@@ -119,7 +103,6 @@ MTOKEN_ABI = [
119
103
  "inputs": [],
120
104
  "outputs": [{"name": "", "type": "uint256"}],
121
105
  },
122
- # Get total borrows
123
106
  {
124
107
  "name": "totalBorrows",
125
108
  "type": "function",
@@ -127,7 +110,6 @@ MTOKEN_ABI = [
127
110
  "inputs": [],
128
111
  "outputs": [{"name": "", "type": "uint256"}],
129
112
  },
130
- # Get total supply of mTokens
131
113
  {
132
114
  "name": "totalSupply",
133
115
  "type": "function",
@@ -135,7 +117,6 @@ MTOKEN_ABI = [
135
117
  "inputs": [],
136
118
  "outputs": [{"name": "", "type": "uint256"}],
137
119
  },
138
- # Get cash (available liquidity)
139
120
  {
140
121
  "name": "getCash",
141
122
  "type": "function",
@@ -151,7 +132,6 @@ MTOKEN_ABI = [
151
132
  "inputs": [],
152
133
  "outputs": [{"name": "", "type": "uint256"}],
153
134
  },
154
- # Get decimals
155
135
  {
156
136
  "name": "decimals",
157
137
  "type": "function",
@@ -179,7 +159,6 @@ COMPTROLLER_ABI = [
179
159
  "inputs": [{"name": "mTokenAddress", "type": "address"}],
180
160
  "outputs": [{"name": "", "type": "uint256"}],
181
161
  },
182
- # Get account liquidity (error, liquidity, shortfall)
183
162
  {
184
163
  "name": "getAccountLiquidity",
185
164
  "type": "function",
@@ -191,7 +170,6 @@ COMPTROLLER_ABI = [
191
170
  {"name": "shortfall", "type": "uint256"},
192
171
  ],
193
172
  },
194
- # Get market info (isListed, collateralFactorMantissa)
195
173
  {
196
174
  "name": "markets",
197
175
  "type": "function",
@@ -202,7 +180,6 @@ COMPTROLLER_ABI = [
202
180
  {"name": "collateralFactorMantissa", "type": "uint256"},
203
181
  ],
204
182
  },
205
- # Check if account has entered a market
206
183
  {
207
184
  "name": "checkMembership",
208
185
  "type": "function",
@@ -213,7 +190,6 @@ COMPTROLLER_ABI = [
213
190
  ],
214
191
  "outputs": [{"name": "", "type": "bool"}],
215
192
  },
216
- # Get all markets an account has entered
217
193
  {
218
194
  "name": "getAssetsIn",
219
195
  "type": "function",
@@ -221,7 +197,6 @@ COMPTROLLER_ABI = [
221
197
  "inputs": [{"name": "account", "type": "address"}],
222
198
  "outputs": [{"name": "", "type": "address[]"}],
223
199
  },
224
- # Get all listed markets
225
200
  {
226
201
  "name": "getAllMarkets",
227
202
  "type": "function",
@@ -229,7 +204,6 @@ COMPTROLLER_ABI = [
229
204
  "inputs": [],
230
205
  "outputs": [{"name": "", "type": "address[]"}],
231
206
  },
232
- # Get hypothetical account liquidity
233
207
  {
234
208
  "name": "getHypotheticalAccountLiquidity",
235
209
  "type": "function",
@@ -246,7 +220,6 @@ COMPTROLLER_ABI = [
246
220
  {"name": "shortfall", "type": "uint256"},
247
221
  ],
248
222
  },
249
- # Get close factor
250
223
  {
251
224
  "name": "closeFactorMantissa",
252
225
  "type": "function",
@@ -254,7 +227,6 @@ COMPTROLLER_ABI = [
254
227
  "inputs": [],
255
228
  "outputs": [{"name": "", "type": "uint256"}],
256
229
  },
257
- # Get liquidation incentive
258
230
  {
259
231
  "name": "liquidationIncentiveMantissa",
260
232
  "type": "function",
@@ -293,7 +265,6 @@ REWARD_DISTRIBUTOR_ABI = [
293
265
  ],
294
266
  "outputs": [],
295
267
  },
296
- # Get reward token address
297
268
  {
298
269
  "name": "rewardToken",
299
270
  "type": "function",
@@ -301,7 +272,6 @@ REWARD_DISTRIBUTOR_ABI = [
301
272
  "inputs": [],
302
273
  "outputs": [{"name": "", "type": "address"}],
303
274
  },
304
- # Get pending rewards (accrued but not yet claimed)
305
275
  {
306
276
  "name": "rewardAccrued",
307
277
  "type": "function",
@@ -309,8 +279,6 @@ REWARD_DISTRIBUTOR_ABI = [
309
279
  "inputs": [{"name": "holder", "type": "address"}],
310
280
  "outputs": [{"name": "", "type": "uint256"}],
311
281
  },
312
- # Get outstanding rewards for a user across all markets
313
- # Returns array of (mToken, [(rewardToken, totalReward, supplySide, borrowSide)])
314
282
  {
315
283
  "name": "getOutstandingRewardsForUser",
316
284
  "type": "function",
@@ -336,7 +304,6 @@ REWARD_DISTRIBUTOR_ABI = [
336
304
  }
337
305
  ],
338
306
  },
339
- # Get outstanding rewards for a user for a specific mToken
340
307
  {
341
308
  "name": "getOutstandingRewardsForUser",
342
309
  "type": "function",
@@ -358,8 +325,6 @@ REWARD_DISTRIBUTOR_ABI = [
358
325
  }
359
326
  ],
360
327
  },
361
- # Get all market configurations for an mToken
362
- # Returns array of (mToken, rewardToken, supplyEmissionsPerSec, borrowEmissionsPerSec, ...)
363
328
  {
364
329
  "name": "getAllMarketConfigs",
365
330
  "type": "function",