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
@@ -12,16 +12,6 @@ from wayfinder_paths.core.strategies.Strategy import StatusDict
12
12
 
13
13
 
14
14
  class LedgerAdapter(BaseAdapter):
15
- """
16
- Ledger adapter for strategy transaction history and bookkeeping operations.
17
-
18
- Provides high-level operations for:
19
- - Fetching strategy transaction history
20
- - Getting net deposit amounts
21
- - Getting last rotation time
22
- - Recording deposits, withdrawals, and operations
23
- """
24
-
25
15
  adapter_type: str = "LEDGER"
26
16
 
27
17
  def __init__(
@@ -35,17 +25,6 @@ class LedgerAdapter(BaseAdapter):
35
25
  async def get_strategy_transactions(
36
26
  self, wallet_address: str, limit: int = 50, offset: int = 0
37
27
  ) -> tuple[bool, StrategyTransactionList | str]:
38
- """
39
- Get paginated strategy transaction history.
40
-
41
- Args:
42
- wallet_address: Strategy wallet address
43
- limit: Maximum number of transactions to return
44
- offset: Number of transactions to skip
45
-
46
- Returns:
47
- Tuple of (success, data) where data is transaction list or error message
48
- """
49
28
  try:
50
29
  data = await self.ledger_client.get_strategy_transactions(
51
30
  wallet_address=wallet_address, limit=limit, offset=offset
@@ -58,15 +37,6 @@ class LedgerAdapter(BaseAdapter):
58
37
  async def get_strategy_net_deposit(
59
38
  self, wallet_address: str
60
39
  ) -> tuple[bool, NetDeposit | str]:
61
- """
62
- Get net deposit amount (deposits - withdrawals) for a strategy.
63
-
64
- Args:
65
- wallet_address: Strategy wallet address
66
-
67
- Returns:
68
- Tuple of (success, data) where data contains net_deposit or error message
69
- """
70
40
  try:
71
41
  data = await self.ledger_client.get_strategy_net_deposit(
72
42
  wallet_address=wallet_address
@@ -79,15 +49,6 @@ class LedgerAdapter(BaseAdapter):
79
49
  async def get_strategy_latest_transactions(
80
50
  self, wallet_address: str
81
51
  ) -> tuple[bool, StrategyTransactionList | str]:
82
- """
83
- Get the latest transactions for a strategy.
84
-
85
- Args:
86
- wallet_address: Strategy wallet address
87
-
88
- Returns:
89
- Tuple of (success, data) where data contains latest transactions or error message
90
- """
91
52
  try:
92
53
  data = await self.ledger_client.get_strategy_latest_transactions(
93
54
  wallet_address=wallet_address
@@ -107,21 +68,6 @@ class LedgerAdapter(BaseAdapter):
107
68
  data: dict[str, Any] | None = None,
108
69
  strategy_name: str | None = None,
109
70
  ) -> tuple[bool, TransactionRecord | str]:
110
- """
111
- Record a strategy deposit transaction.
112
-
113
- Args:
114
- wallet_address: Strategy wallet address
115
- chain_id: Blockchain chain ID
116
- token_address: Token contract address
117
- token_amount: Amount deposited (in token units)
118
- usd_value: USD value of the deposit
119
- data: Additional transaction data
120
- strategy_name: Name of the strategy making the deposit
121
-
122
- Returns:
123
- Tuple of (success, data) where data is transaction record or error message
124
- """
125
71
  try:
126
72
  result = await self.ledger_client.add_strategy_deposit(
127
73
  wallet_address=wallet_address,
@@ -147,21 +93,6 @@ class LedgerAdapter(BaseAdapter):
147
93
  data: dict[str, Any] | None = None,
148
94
  strategy_name: str | None = None,
149
95
  ) -> tuple[bool, TransactionRecord | str]:
150
- """
151
- Record a strategy withdrawal transaction.
152
-
153
- Args:
154
- wallet_address: Strategy wallet address
155
- chain_id: Blockchain chain ID
156
- token_address: Token contract address
157
- token_amount: Amount withdrawn (in token units)
158
- usd_value: USD value of the withdrawal
159
- data: Additional transaction data
160
- strategy_name: Name of the strategy making the withdrawal
161
-
162
- Returns:
163
- Tuple of (success, data) where data is transaction record or error message
164
- """
165
96
  try:
166
97
  result = await self.ledger_client.add_strategy_withdraw(
167
98
  wallet_address=wallet_address,
@@ -184,18 +115,6 @@ class LedgerAdapter(BaseAdapter):
184
115
  usd_value: str | float,
185
116
  strategy_name: str | None = None,
186
117
  ) -> tuple[bool, TransactionRecord | str]:
187
- """
188
- Record a strategy operation (e.g., swaps, rebalances) for bookkeeping.
189
-
190
- Args:
191
- wallet_address: Strategy wallet address
192
- operation_data: Operation model (SWAP, LEND, BORROW, etc.)
193
- usd_value: USD value of the operation
194
- strategy_name: Name of the strategy performing the operation
195
-
196
- Returns:
197
- Tuple of (success, data) where data is operation record or error message
198
- """
199
118
  try:
200
119
  result = await self.ledger_client.add_strategy_operation(
201
120
  wallet_address=wallet_address,
@@ -211,16 +130,6 @@ class LedgerAdapter(BaseAdapter):
211
130
  async def get_transaction_summary(
212
131
  self, wallet_address: str, limit: int = 10
213
132
  ) -> tuple[bool, Any]:
214
- """
215
- Get a summary of recent strategy transactions.
216
-
217
- Args:
218
- wallet_address: Strategy wallet address
219
- limit: Number of recent transactions to include
220
-
221
- Returns:
222
- Tuple of (success, data) where data is transaction summary or error message
223
- """
224
133
  try:
225
134
  success, transactions_data = await self.get_strategy_transactions(
226
135
  wallet_address=wallet_address, limit=limit
@@ -231,7 +140,6 @@ class LedgerAdapter(BaseAdapter):
231
140
 
232
141
  transactions = transactions_data.get("transactions", [])
233
142
 
234
- # Create summary
235
143
  summary = {
236
144
  "total_transactions": len(transactions),
237
145
  "recent_transactions": transactions[:limit],
@@ -260,20 +168,6 @@ class LedgerAdapter(BaseAdapter):
260
168
  async def record_strategy_snapshot(
261
169
  self, wallet_address: str, strategy_status: StatusDict
262
170
  ) -> tuple[bool, None | str]:
263
- """
264
- Record a strategy snapshot with current state.
265
-
266
- Args:
267
- wallet_address: Strategy wallet address
268
- strat_portfolio_value: Current portfolio value
269
- net_deposit: Net deposit amount
270
- strategy_status: Current strategy status dictionary
271
- gas_available: Available gas amount
272
- gassed_up: Whether the strategy is gassed up
273
-
274
- Returns:
275
- Tuple of (success, None) on success or (False, error_message) on failure
276
- """
277
171
  try:
278
172
  await self.ledger_client.strategy_snapshot(
279
173
  wallet_address=wallet_address,
@@ -6,24 +6,19 @@ from wayfinder_paths.adapters.ledger_adapter.adapter import LedgerAdapter
6
6
 
7
7
 
8
8
  class TestLedgerAdapter:
9
- """Test cases for LedgerAdapter"""
10
-
11
9
  @pytest.fixture
12
10
  def mock_ledger_client(self):
13
- """Mock LedgerClient for testing"""
14
11
  mock_client = AsyncMock()
15
12
  return mock_client
16
13
 
17
14
  @pytest.fixture
18
15
  def adapter(self, mock_ledger_client):
19
- """Create a LedgerAdapter instance with mocked client for testing"""
20
16
  adapter = LedgerAdapter()
21
17
  adapter.ledger_client = mock_ledger_client
22
18
  return adapter
23
19
 
24
20
  @pytest.mark.asyncio
25
21
  async def test_get_strategy_transactions_success(self, adapter, mock_ledger_client):
26
- """Test successful strategy transaction retrieval"""
27
22
  mock_response = {
28
23
  "transactions": [
29
24
  {
@@ -55,7 +50,6 @@ class TestLedgerAdapter:
55
50
 
56
51
  @pytest.mark.asyncio
57
52
  async def test_get_strategy_transactions_failure(self, adapter, mock_ledger_client):
58
- """Test strategy transaction retrieval failure"""
59
53
  mock_ledger_client.get_strategy_transactions = AsyncMock(
60
54
  side_effect=Exception("API Error")
61
55
  )
@@ -69,7 +63,6 @@ class TestLedgerAdapter:
69
63
 
70
64
  @pytest.mark.asyncio
71
65
  async def test_get_strategy_net_deposit_success(self, adapter, mock_ledger_client):
72
- """Test successful strategy net deposit retrieval"""
73
66
  mock_response = {
74
67
  "net_deposit": "1000.00",
75
68
  "total_deposits": "1500.00",
@@ -92,7 +85,6 @@ class TestLedgerAdapter:
92
85
 
93
86
  @pytest.mark.asyncio
94
87
  async def test_record_deposit_success(self, adapter, mock_ledger_client):
95
- """Test successful deposit recording"""
96
88
  mock_response = {
97
89
  "transaction_id": "tx_456",
98
90
  "status": "recorded",
@@ -124,7 +116,6 @@ class TestLedgerAdapter:
124
116
 
125
117
  @pytest.mark.asyncio
126
118
  async def test_record_withdrawal_success(self, adapter, mock_ledger_client):
127
- """Test successful withdrawal recording"""
128
119
  mock_response = {
129
120
  "transaction_id": "tx_789",
130
121
  "status": "recorded",
@@ -147,7 +138,6 @@ class TestLedgerAdapter:
147
138
 
148
139
  @pytest.mark.asyncio
149
140
  async def test_record_operation_success(self, adapter, mock_ledger_client):
150
- """Test successful operation recording"""
151
141
  from wayfinder_paths.core.adapters.models import SWAP
152
142
 
153
143
  mock_response = {
@@ -182,7 +172,6 @@ class TestLedgerAdapter:
182
172
 
183
173
  @pytest.mark.asyncio
184
174
  async def test_get_transaction_summary_success(self, adapter, mock_ledger_client):
185
- """Test successful transaction summary generation"""
186
175
  mock_transactions = {
187
176
  "transactions": [
188
177
  {"operation": "DEPOSIT", "amount": "1000000000000000000"},
@@ -204,5 +193,4 @@ class TestLedgerAdapter:
204
193
  assert data["operations"]["operations"] == 1
205
194
 
206
195
  def test_adapter_type(self, adapter):
207
- """Test adapter has adapter_type"""
208
196
  assert adapter.adapter_type == "LEDGER"
@@ -1,90 +1,109 @@
1
1
  # Moonwell Adapter
2
2
 
3
- Adapter for interacting with the [Moonwell](https://moonwell.fi/) lending protocol on Base chain.
3
+ Adapter for the [Moonwell](https://moonwell.fi/) lending protocol on Base.
4
4
 
5
- - Entrypoint: `adapters.moonwell_adapter.adapter.MoonwellAdapter`
6
- - Tests: `test_adapter.py`
7
-
8
- ## Capabilities
9
-
10
- The adapter provides the following capabilities:
11
-
12
- - Lending: Supply and withdraw tokens
13
- - Borrowing: Borrow and repay tokens
14
- - Collateral management: Enable/disable markets as collateral
15
- - Rewards: Claim WELL token rewards
16
- - Position & market queries: Get balances, APYs, and liquidity info
5
+ - **Type**: `MOONWELL`
6
+ - **Module**: `wayfinder_paths.adapters.moonwell_adapter.adapter.MoonwellAdapter`
17
7
 
18
8
  ## Overview
19
9
 
20
- The MoonwellAdapter provides functionality for:
21
-
22
- - **Lending**: Supply tokens to earn yield
23
- - **Borrowing**: Borrow against collateral
24
- - **Collateral Management**: Enable/disable markets as collateral
25
- - **Rewards**: Claim WELL token rewards
26
- - **Position Queries**: Get balances, APYs, and liquidity info
10
+ The MoonwellAdapter provides:
11
+ - Lending (supply/withdraw)
12
+ - Borrowing (borrow/repay)
13
+ - Collateral management
14
+ - WELL rewards claiming
15
+ - Position and market queries
27
16
 
28
- ## Supported Markets (Base Chain)
17
+ ## Supported Markets (Base)
29
18
 
30
- | Token | mToken Address | Underlying Address |
31
- | ------ | -------------------------------------------- | -------------------------------------------- |
32
- | USDC | `0xEdc817A28E8B93B03976FBd4a3dDBc9f7D176c22` | `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913` |
33
- | WETH | `0x628ff693426583D9a7FB391E54366292F509D457` | `0x4200000000000000000000000000000000000006` |
19
+ | Token | mToken Address | Underlying Address |
20
+ |-------|----------------|-------------------|
21
+ | USDC | `0xEdc817A28E8B93B03976FBd4a3dDBc9f7D176c22` | `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913` |
22
+ | WETH | `0x628ff693426583D9a7FB391E54366292F509D457` | `0x4200000000000000000000000000000000000006` |
34
23
  | wstETH | `0x627Fe393Bc6EdDA28e99AE648fD6fF362514304b` | `0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452` |
35
24
 
36
- ## Protocol Addresses (Base Chain)
25
+ ## Protocol Addresses (Base)
37
26
 
38
27
  - **Comptroller**: `0xfbb21d0380bee3312b33c4353c8936a0f13ef26c`
39
28
  - **Reward Distributor**: `0xe9005b078701e2a0948d2eac43010d35870ad9d2`
40
29
  - **WELL Token**: `0xA88594D404727625A9437C3f886C7643872296AE`
41
30
 
42
- ## Construction
31
+ ## Usage
43
32
 
44
33
  ```python
45
34
  from wayfinder_paths.adapters.moonwell_adapter import MoonwellAdapter
46
35
 
47
36
  config = {
48
- "strategy_wallet": {"address": "0x...your_wallet..."},
37
+ "strategy_wallet": {"address": "0x..."},
49
38
  "moonwell_adapter": {
50
- "chain_id": 8453, # Base chain (default)
39
+ "chain_id": 8453,
51
40
  }
52
41
  }
53
42
  adapter = MoonwellAdapter(config=config)
54
43
  ```
55
44
 
56
- ## Usage
45
+ ## Methods
46
+
47
+ ### Lending
57
48
 
58
49
  ```python
59
50
  # Supply tokens
60
51
  await adapter.lend(
61
- mtoken="0xEdc817A28E8B93B03976FBd4a3dDBc9f7D176c22", # mUSDC
62
- underlying_token="0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", # USDC
63
- amount=1000 * 10**6, # 1000 USDC
52
+ mtoken="0xEdc817A28E8B93B03976FBd4a3dDBc9f7D176c22",
53
+ underlying_token="0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
54
+ amount=1000 * 10**6,
64
55
  )
65
56
 
66
- # Enable as collateral
67
- await adapter.set_collateral(
68
- mtoken="0x627Fe393Bc6EdDA28e99AE648fD6fF362514304b", # mwstETH
57
+ # Withdraw tokens
58
+ await adapter.unlend(
59
+ mtoken="0xEdc817A28E8B93B03976FBd4a3dDBc9f7D176c22",
60
+ amount=500 * 10**6,
69
61
  )
62
+ ```
63
+
64
+ ### Borrowing
70
65
 
66
+ ```python
71
67
  # Borrow
72
68
  await adapter.borrow(
73
- mtoken="0x628ff693426583D9a7FB391E54366292F509D457", # mWETH
69
+ mtoken="0x628ff693426583D9a7FB391E54366292F509D457",
74
70
  amount=10**17, # 0.1 WETH
75
71
  )
76
72
 
77
- # Get position info
73
+ # Repay
74
+ await adapter.repay(
75
+ mtoken="0x628ff693426583D9a7FB391E54366292F509D457",
76
+ underlying_token="0x4200000000000000000000000000000000000006",
77
+ amount=10**17,
78
+ )
79
+ ```
80
+
81
+ ### Collateral Management
82
+
83
+ ```python
84
+ # Enable as collateral
85
+ await adapter.set_collateral(
86
+ mtoken="0x627Fe393Bc6EdDA28e99AE648fD6fF362514304b",
87
+ )
88
+
89
+ # Disable collateral
90
+ await adapter.remove_collateral(
91
+ mtoken="0x627Fe393Bc6EdDA28e99AE648fD6fF362514304b",
92
+ )
93
+ ```
94
+
95
+ ### Position Queries
96
+
97
+ ```python
98
+ # Get position data
78
99
  success, position = await adapter.get_pos(
79
100
  mtoken="0xEdc817A28E8B93B03976FBd4a3dDBc9f7D176c22",
80
101
  )
81
- # Returns: {mtoken_balance, underlying_balance, borrow_balance, exchange_rate, balances}
82
102
 
83
103
  # Get collateral factor
84
104
  success, cf = await adapter.get_collateral_factor(
85
105
  mtoken="0x627Fe393Bc6EdDA28e99AE648fD6fF362514304b",
86
106
  )
87
- # Returns: 0.75 (75% LTV)
88
107
 
89
108
  # Get APY
90
109
  success, apy = await adapter.get_apy(
@@ -92,81 +111,23 @@ success, apy = await adapter.get_apy(
92
111
  apy_type="supply", # or "borrow"
93
112
  )
94
113
 
95
- # Claim rewards
96
- await adapter.claim_rewards()
114
+ # Get max borrowable
115
+ success, amount = await adapter.get_borrowable_amount(account="0x...")
97
116
  ```
98
117
 
99
- ## API Reference
100
-
101
- ### Lending Operations
102
-
103
- | Method | Description |
104
- | ---------------------------------------- | ----------------------------- |
105
- | `lend(mtoken, underlying_token, amount)` | Supply tokens to earn yield |
106
- | `unlend(mtoken, amount)` | Withdraw by redeeming mTokens |
107
-
108
- ### Borrowing Operations
109
-
110
- | Method | Description |
111
- | ----------------------------------------- | ------------------------ |
112
- | `borrow(mtoken, amount)` | Borrow underlying tokens |
113
- | `repay(mtoken, underlying_token, amount)` | Repay borrowed tokens |
114
-
115
- ### Collateral Management
116
-
117
- | Method | Description |
118
- | --------------------------- | ------------------------------------------ |
119
- | `set_collateral(mtoken)` | Enable market as collateral (enterMarkets) |
120
- | `remove_collateral(mtoken)` | Disable market as collateral (exitMarket) |
121
-
122
- ### Position & Market Data
123
-
124
- | Method | Description |
125
- | ------------------------------------------ | -------------------------------------------------- |
126
- | `get_pos(mtoken, account)` | Get position data (balances, debt, rewards) |
127
- | `get_collateral_factor(mtoken)` | Get collateral factor (LTV) |
128
- | `get_apy(mtoken, apy_type)` | Get supply or borrow APY |
129
- | `get_borrowable_amount(account)` | Get max borrowable in USD |
130
- | `max_withdrawable_mtoken(mtoken, account)` | Calculate safe withdrawal amount via binary search |
131
-
132
118
  ### Rewards
133
119
 
134
- | Method | Description |
135
- | -------------------------------- | --------------------------------------------- |
136
- | `claim_rewards(min_rewards_usd)` | Claim WELL rewards (skips if below threshold) |
137
-
138
- ### Utilities
120
+ ```python
121
+ # Claim WELL rewards
122
+ await adapter.claim_rewards(min_rewards_usd=1.0)
123
+ ```
139
124
 
140
- | Method | Description |
141
- | ------------------ | ---------------- |
142
- | `wrap_eth(amount)` | Wrap ETH to WETH |
125
+ ## Return Format
143
126
 
144
- All methods return `(success: bool, payload: Any)` tuples. On failure the payload is an error string.
127
+ All methods return `(success: bool, data: Any)` tuples.
145
128
 
146
129
  ## Testing
147
130
 
148
131
  ```bash
149
132
  poetry run pytest wayfinder_paths/adapters/moonwell_adapter/ -v
150
133
  ```
151
-
152
- ## Configuration
153
-
154
- The adapter can be configured via the `moonwell_adapter` config key:
155
-
156
- ```python
157
- config = {
158
- "strategy_wallet": {"address": "0x..."},
159
- "moonwell_adapter": {
160
- "chain_id": 8453, # Chain ID (default: Base)
161
- "comptroller": "0x...", # Override comptroller address
162
- "reward_distributor": "0x...", # Override reward distributor
163
- "m_usdc": "0x...", # Override mUSDC address
164
- "m_weth": "0x...", # Override mWETH address
165
- "m_wsteth": "0x...", # Override mwstETH address
166
- }
167
- }
168
- ```
169
-
170
- ## Error handling
171
-
172
- Any exception raised by the underlying web3 calls is caught and returned as a `(False, "message")` tuple. The inherited `health_check()` method reports adapter status, making it safe to call from `Strategy.health_check`.
@@ -1,7 +1,3 @@
1
- """
2
- Moonwell Adapter
3
- """
4
-
5
1
  from wayfinder_paths.adapters.moonwell_adapter.adapter import MoonwellAdapter
6
2
 
7
3
  __all__ = ["MoonwellAdapter"]