wayfinder-paths 0.1.7__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/CONFIG_GUIDE.md +399 -0
- wayfinder_paths/__init__.py +22 -0
- wayfinder_paths/abis/generic/erc20.json +383 -0
- wayfinder_paths/adapters/__init__.py +0 -0
- wayfinder_paths/adapters/balance_adapter/README.md +94 -0
- wayfinder_paths/adapters/balance_adapter/adapter.py +238 -0
- wayfinder_paths/adapters/balance_adapter/examples.json +6 -0
- wayfinder_paths/adapters/balance_adapter/manifest.yaml +8 -0
- wayfinder_paths/adapters/balance_adapter/test_adapter.py +59 -0
- wayfinder_paths/adapters/brap_adapter/README.md +249 -0
- wayfinder_paths/adapters/brap_adapter/__init__.py +7 -0
- wayfinder_paths/adapters/brap_adapter/adapter.py +726 -0
- wayfinder_paths/adapters/brap_adapter/examples.json +175 -0
- wayfinder_paths/adapters/brap_adapter/manifest.yaml +11 -0
- wayfinder_paths/adapters/brap_adapter/test_adapter.py +286 -0
- wayfinder_paths/adapters/hyperlend_adapter/__init__.py +7 -0
- wayfinder_paths/adapters/hyperlend_adapter/adapter.py +305 -0
- wayfinder_paths/adapters/hyperlend_adapter/manifest.yaml +10 -0
- wayfinder_paths/adapters/hyperlend_adapter/test_adapter.py +274 -0
- wayfinder_paths/adapters/hyperliquid_adapter/__init__.py +18 -0
- wayfinder_paths/adapters/hyperliquid_adapter/adapter.py +1093 -0
- wayfinder_paths/adapters/hyperliquid_adapter/executor.py +549 -0
- wayfinder_paths/adapters/hyperliquid_adapter/manifest.yaml +8 -0
- wayfinder_paths/adapters/hyperliquid_adapter/paired_filler.py +1050 -0
- wayfinder_paths/adapters/hyperliquid_adapter/test_adapter.py +126 -0
- wayfinder_paths/adapters/hyperliquid_adapter/test_adapter_live.py +219 -0
- wayfinder_paths/adapters/hyperliquid_adapter/test_utils.py +220 -0
- wayfinder_paths/adapters/hyperliquid_adapter/utils.py +134 -0
- wayfinder_paths/adapters/ledger_adapter/README.md +145 -0
- wayfinder_paths/adapters/ledger_adapter/__init__.py +7 -0
- wayfinder_paths/adapters/ledger_adapter/adapter.py +289 -0
- wayfinder_paths/adapters/ledger_adapter/examples.json +137 -0
- wayfinder_paths/adapters/ledger_adapter/manifest.yaml +11 -0
- wayfinder_paths/adapters/ledger_adapter/test_adapter.py +205 -0
- wayfinder_paths/adapters/pool_adapter/README.md +206 -0
- wayfinder_paths/adapters/pool_adapter/__init__.py +7 -0
- wayfinder_paths/adapters/pool_adapter/adapter.py +282 -0
- wayfinder_paths/adapters/pool_adapter/examples.json +143 -0
- wayfinder_paths/adapters/pool_adapter/manifest.yaml +10 -0
- wayfinder_paths/adapters/pool_adapter/test_adapter.py +220 -0
- wayfinder_paths/adapters/token_adapter/README.md +101 -0
- wayfinder_paths/adapters/token_adapter/__init__.py +3 -0
- wayfinder_paths/adapters/token_adapter/adapter.py +96 -0
- wayfinder_paths/adapters/token_adapter/examples.json +26 -0
- wayfinder_paths/adapters/token_adapter/manifest.yaml +6 -0
- wayfinder_paths/adapters/token_adapter/test_adapter.py +125 -0
- wayfinder_paths/config.example.json +22 -0
- wayfinder_paths/conftest.py +31 -0
- wayfinder_paths/core/__init__.py +18 -0
- wayfinder_paths/core/adapters/BaseAdapter.py +65 -0
- wayfinder_paths/core/adapters/__init__.py +5 -0
- wayfinder_paths/core/adapters/base.py +5 -0
- wayfinder_paths/core/adapters/models.py +46 -0
- wayfinder_paths/core/analytics/__init__.py +11 -0
- wayfinder_paths/core/analytics/bootstrap.py +57 -0
- wayfinder_paths/core/analytics/stats.py +48 -0
- wayfinder_paths/core/analytics/test_analytics.py +170 -0
- wayfinder_paths/core/clients/AuthClient.py +83 -0
- wayfinder_paths/core/clients/BRAPClient.py +109 -0
- wayfinder_paths/core/clients/ClientManager.py +210 -0
- wayfinder_paths/core/clients/HyperlendClient.py +192 -0
- wayfinder_paths/core/clients/LedgerClient.py +443 -0
- wayfinder_paths/core/clients/PoolClient.py +128 -0
- wayfinder_paths/core/clients/SimulationClient.py +192 -0
- wayfinder_paths/core/clients/TokenClient.py +89 -0
- wayfinder_paths/core/clients/TransactionClient.py +63 -0
- wayfinder_paths/core/clients/WalletClient.py +94 -0
- wayfinder_paths/core/clients/WayfinderClient.py +269 -0
- wayfinder_paths/core/clients/__init__.py +48 -0
- wayfinder_paths/core/clients/protocols.py +392 -0
- wayfinder_paths/core/clients/sdk_example.py +110 -0
- wayfinder_paths/core/config.py +458 -0
- wayfinder_paths/core/constants/__init__.py +26 -0
- wayfinder_paths/core/constants/base.py +42 -0
- wayfinder_paths/core/constants/erc20_abi.py +118 -0
- wayfinder_paths/core/constants/hyperlend_abi.py +152 -0
- wayfinder_paths/core/engine/StrategyJob.py +188 -0
- wayfinder_paths/core/engine/__init__.py +5 -0
- wayfinder_paths/core/engine/manifest.py +97 -0
- wayfinder_paths/core/services/__init__.py +0 -0
- wayfinder_paths/core/services/base.py +179 -0
- wayfinder_paths/core/services/local_evm_txn.py +430 -0
- wayfinder_paths/core/services/local_token_txn.py +231 -0
- wayfinder_paths/core/services/web3_service.py +45 -0
- wayfinder_paths/core/settings.py +61 -0
- wayfinder_paths/core/strategies/Strategy.py +280 -0
- wayfinder_paths/core/strategies/__init__.py +5 -0
- wayfinder_paths/core/strategies/base.py +7 -0
- wayfinder_paths/core/strategies/descriptors.py +81 -0
- wayfinder_paths/core/utils/__init__.py +1 -0
- wayfinder_paths/core/utils/evm_helpers.py +206 -0
- wayfinder_paths/core/utils/wallets.py +77 -0
- wayfinder_paths/core/wallets/README.md +91 -0
- wayfinder_paths/core/wallets/WalletManager.py +56 -0
- wayfinder_paths/core/wallets/__init__.py +7 -0
- wayfinder_paths/policies/enso.py +17 -0
- wayfinder_paths/policies/erc20.py +34 -0
- wayfinder_paths/policies/evm.py +21 -0
- wayfinder_paths/policies/hyper_evm.py +19 -0
- wayfinder_paths/policies/hyperlend.py +12 -0
- wayfinder_paths/policies/hyperliquid.py +30 -0
- wayfinder_paths/policies/moonwell.py +54 -0
- wayfinder_paths/policies/prjx.py +30 -0
- wayfinder_paths/policies/util.py +27 -0
- wayfinder_paths/run_strategy.py +411 -0
- wayfinder_paths/scripts/__init__.py +0 -0
- wayfinder_paths/scripts/create_strategy.py +181 -0
- wayfinder_paths/scripts/make_wallets.py +169 -0
- wayfinder_paths/scripts/run_strategy.py +124 -0
- wayfinder_paths/scripts/validate_manifests.py +213 -0
- wayfinder_paths/strategies/__init__.py +0 -0
- wayfinder_paths/strategies/basis_trading_strategy/README.md +213 -0
- wayfinder_paths/strategies/basis_trading_strategy/__init__.py +3 -0
- wayfinder_paths/strategies/basis_trading_strategy/constants.py +1 -0
- wayfinder_paths/strategies/basis_trading_strategy/examples.json +16 -0
- wayfinder_paths/strategies/basis_trading_strategy/manifest.yaml +23 -0
- wayfinder_paths/strategies/basis_trading_strategy/snapshot_mixin.py +1011 -0
- wayfinder_paths/strategies/basis_trading_strategy/strategy.py +4522 -0
- wayfinder_paths/strategies/basis_trading_strategy/test_strategy.py +727 -0
- wayfinder_paths/strategies/basis_trading_strategy/types.py +39 -0
- wayfinder_paths/strategies/config.py +85 -0
- wayfinder_paths/strategies/hyperlend_stable_yield_strategy/README.md +100 -0
- wayfinder_paths/strategies/hyperlend_stable_yield_strategy/examples.json +8 -0
- wayfinder_paths/strategies/hyperlend_stable_yield_strategy/manifest.yaml +7 -0
- wayfinder_paths/strategies/hyperlend_stable_yield_strategy/strategy.py +2270 -0
- wayfinder_paths/strategies/hyperlend_stable_yield_strategy/test_strategy.py +352 -0
- wayfinder_paths/strategies/stablecoin_yield_strategy/README.md +96 -0
- wayfinder_paths/strategies/stablecoin_yield_strategy/examples.json +17 -0
- wayfinder_paths/strategies/stablecoin_yield_strategy/manifest.yaml +17 -0
- wayfinder_paths/strategies/stablecoin_yield_strategy/strategy.py +1810 -0
- wayfinder_paths/strategies/stablecoin_yield_strategy/test_strategy.py +520 -0
- wayfinder_paths/templates/adapter/README.md +105 -0
- wayfinder_paths/templates/adapter/adapter.py +26 -0
- wayfinder_paths/templates/adapter/examples.json +8 -0
- wayfinder_paths/templates/adapter/manifest.yaml +6 -0
- wayfinder_paths/templates/adapter/test_adapter.py +49 -0
- wayfinder_paths/templates/strategy/README.md +153 -0
- wayfinder_paths/templates/strategy/examples.json +11 -0
- wayfinder_paths/templates/strategy/manifest.yaml +8 -0
- wayfinder_paths/templates/strategy/strategy.py +57 -0
- wayfinder_paths/templates/strategy/test_strategy.py +197 -0
- wayfinder_paths/tests/__init__.py +0 -0
- wayfinder_paths/tests/test_smoke_manifest.py +48 -0
- wayfinder_paths/tests/test_test_coverage.py +212 -0
- wayfinder_paths/tests/test_utils.py +64 -0
- wayfinder_paths-0.1.7.dist-info/LICENSE +21 -0
- wayfinder_paths-0.1.7.dist-info/METADATA +777 -0
- wayfinder_paths-0.1.7.dist-info/RECORD +149 -0
- wayfinder_paths-0.1.7.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"constant": true,
|
|
4
|
+
"inputs": [
|
|
5
|
+
{
|
|
6
|
+
"name": "owner",
|
|
7
|
+
"type": "address"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"name": "spender",
|
|
11
|
+
"type": "address"
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"name": "allowance",
|
|
15
|
+
"outputs": [
|
|
16
|
+
{
|
|
17
|
+
"name": "",
|
|
18
|
+
"type": "uint256"
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"type": "function"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"constant": true,
|
|
25
|
+
"inputs": [
|
|
26
|
+
{
|
|
27
|
+
"name": "account",
|
|
28
|
+
"type": "address"
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
"name": "balanceOf",
|
|
32
|
+
"outputs": [
|
|
33
|
+
{
|
|
34
|
+
"name": "",
|
|
35
|
+
"type": "uint256"
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"type": "function"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"constant": true,
|
|
42
|
+
"inputs": [],
|
|
43
|
+
"name": "decimals",
|
|
44
|
+
"outputs": [
|
|
45
|
+
{
|
|
46
|
+
"name": "",
|
|
47
|
+
"type": "uint8"
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
"type": "function"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"constant": true,
|
|
54
|
+
"inputs": [],
|
|
55
|
+
"name": "name",
|
|
56
|
+
"outputs": [
|
|
57
|
+
{
|
|
58
|
+
"name": "",
|
|
59
|
+
"type": "string"
|
|
60
|
+
}
|
|
61
|
+
],
|
|
62
|
+
"type": "function"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"constant": true,
|
|
66
|
+
"inputs": [],
|
|
67
|
+
"name": "symbol",
|
|
68
|
+
"outputs": [
|
|
69
|
+
{
|
|
70
|
+
"name": "",
|
|
71
|
+
"type": "string"
|
|
72
|
+
}
|
|
73
|
+
],
|
|
74
|
+
"type": "function"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"constant": false,
|
|
78
|
+
"inputs": [
|
|
79
|
+
{
|
|
80
|
+
"name": "recipient",
|
|
81
|
+
"type": "address"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"name": "amount",
|
|
85
|
+
"type": "uint256"
|
|
86
|
+
}
|
|
87
|
+
],
|
|
88
|
+
"name": "transfer",
|
|
89
|
+
"outputs": [
|
|
90
|
+
{
|
|
91
|
+
"name": "",
|
|
92
|
+
"type": "bool"
|
|
93
|
+
}
|
|
94
|
+
],
|
|
95
|
+
"type": "function"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"constant": false,
|
|
99
|
+
"inputs": [
|
|
100
|
+
{
|
|
101
|
+
"name": "spender",
|
|
102
|
+
"type": "address"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"name": "amount",
|
|
106
|
+
"type": "uint256"
|
|
107
|
+
}
|
|
108
|
+
],
|
|
109
|
+
"name": "approve",
|
|
110
|
+
"outputs": [
|
|
111
|
+
{
|
|
112
|
+
"name": "",
|
|
113
|
+
"type": "bool"
|
|
114
|
+
}
|
|
115
|
+
],
|
|
116
|
+
"type": "function"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"inputs": [
|
|
120
|
+
{
|
|
121
|
+
"internalType": "address",
|
|
122
|
+
"name": "tokenA",
|
|
123
|
+
"type": "address"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"internalType": "address",
|
|
127
|
+
"name": "tokenB",
|
|
128
|
+
"type": "address"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"internalType": "bool",
|
|
132
|
+
"name": "stable",
|
|
133
|
+
"type": "bool"
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"internalType": "uint256",
|
|
137
|
+
"name": "amountADesired",
|
|
138
|
+
"type": "uint256"
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"internalType": "uint256",
|
|
142
|
+
"name": "amountBDesired",
|
|
143
|
+
"type": "uint256"
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"internalType": "uint256",
|
|
147
|
+
"name": "amountAMin",
|
|
148
|
+
"type": "uint256"
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"internalType": "uint256",
|
|
152
|
+
"name": "amountBMin",
|
|
153
|
+
"type": "uint256"
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"internalType": "address",
|
|
157
|
+
"name": "to",
|
|
158
|
+
"type": "address"
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"internalType": "uint256",
|
|
162
|
+
"name": "deadline",
|
|
163
|
+
"type": "uint256"
|
|
164
|
+
}
|
|
165
|
+
],
|
|
166
|
+
"name": "addLiquidity",
|
|
167
|
+
"outputs": [
|
|
168
|
+
{
|
|
169
|
+
"internalType": "uint256",
|
|
170
|
+
"name": "amountA",
|
|
171
|
+
"type": "uint256"
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"internalType": "uint256",
|
|
175
|
+
"name": "amountB",
|
|
176
|
+
"type": "uint256"
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
"internalType": "uint256",
|
|
180
|
+
"name": "liquidity",
|
|
181
|
+
"type": "uint256"
|
|
182
|
+
}
|
|
183
|
+
],
|
|
184
|
+
"stateMutability": "nonpayable",
|
|
185
|
+
"type": "function"
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
"inputs": [
|
|
189
|
+
{
|
|
190
|
+
"internalType": "address",
|
|
191
|
+
"name": "tokenA",
|
|
192
|
+
"type": "address"
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
"internalType": "address",
|
|
196
|
+
"name": "tokenB",
|
|
197
|
+
"type": "address"
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
"internalType": "bool",
|
|
201
|
+
"name": "stable",
|
|
202
|
+
"type": "bool"
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
"internalType": "address",
|
|
206
|
+
"name": "_factory",
|
|
207
|
+
"type": "address"
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
"internalType": "uint256",
|
|
211
|
+
"name": "amountADesired",
|
|
212
|
+
"type": "uint256"
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
"internalType": "uint256",
|
|
216
|
+
"name": "amountBDesired",
|
|
217
|
+
"type": "uint256"
|
|
218
|
+
}
|
|
219
|
+
],
|
|
220
|
+
"name": "quoteAddLiquidity",
|
|
221
|
+
"outputs": [
|
|
222
|
+
{
|
|
223
|
+
"internalType": "uint256",
|
|
224
|
+
"name": "amountA",
|
|
225
|
+
"type": "uint256"
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
"internalType": "uint256",
|
|
229
|
+
"name": "amountB",
|
|
230
|
+
"type": "uint256"
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
"internalType": "uint256",
|
|
234
|
+
"name": "liquidity",
|
|
235
|
+
"type": "uint256"
|
|
236
|
+
}
|
|
237
|
+
],
|
|
238
|
+
"stateMutability": "view",
|
|
239
|
+
"type": "function"
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
"inputs": [],
|
|
243
|
+
"name": "defaultFactory",
|
|
244
|
+
"outputs": [
|
|
245
|
+
{
|
|
246
|
+
"internalType": "address",
|
|
247
|
+
"name": "",
|
|
248
|
+
"type": "address"
|
|
249
|
+
}
|
|
250
|
+
],
|
|
251
|
+
"stateMutability": "view",
|
|
252
|
+
"type": "function"
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
"inputs": [
|
|
256
|
+
{
|
|
257
|
+
"internalType": "address",
|
|
258
|
+
"name": "tokenA",
|
|
259
|
+
"type": "address"
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
"internalType": "address",
|
|
263
|
+
"name": "tokenB",
|
|
264
|
+
"type": "address"
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
"internalType": "bool",
|
|
268
|
+
"name": "stable",
|
|
269
|
+
"type": "bool"
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
"internalType": "address",
|
|
273
|
+
"name": "_factory",
|
|
274
|
+
"type": "address"
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
"internalType": "uint256",
|
|
278
|
+
"name": "liquidity",
|
|
279
|
+
"type": "uint256"
|
|
280
|
+
}
|
|
281
|
+
],
|
|
282
|
+
"name": "quoteRemoveLiquidity",
|
|
283
|
+
"outputs": [
|
|
284
|
+
{
|
|
285
|
+
"internalType": "uint256",
|
|
286
|
+
"name": "amountA",
|
|
287
|
+
"type": "uint256"
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
"internalType": "uint256",
|
|
291
|
+
"name": "amountB",
|
|
292
|
+
"type": "uint256"
|
|
293
|
+
}
|
|
294
|
+
],
|
|
295
|
+
"stateMutability": "view",
|
|
296
|
+
"type": "function"
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
"inputs": [
|
|
300
|
+
{
|
|
301
|
+
"internalType": "address",
|
|
302
|
+
"name": "tokenA",
|
|
303
|
+
"type": "address"
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
"internalType": "address",
|
|
307
|
+
"name": "tokenB",
|
|
308
|
+
"type": "address"
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
"internalType": "bool",
|
|
312
|
+
"name": "stable",
|
|
313
|
+
"type": "bool"
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
"internalType": "uint256",
|
|
317
|
+
"name": "liquidity",
|
|
318
|
+
"type": "uint256"
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
"internalType": "uint256",
|
|
322
|
+
"name": "amountAMin",
|
|
323
|
+
"type": "uint256"
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
"internalType": "uint256",
|
|
327
|
+
"name": "amountBMin",
|
|
328
|
+
"type": "uint256"
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
"internalType": "address",
|
|
332
|
+
"name": "to",
|
|
333
|
+
"type": "address"
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
"internalType": "uint256",
|
|
337
|
+
"name": "deadline",
|
|
338
|
+
"type": "uint256"
|
|
339
|
+
}
|
|
340
|
+
],
|
|
341
|
+
"name": "removeLiquidity",
|
|
342
|
+
"outputs": [
|
|
343
|
+
{
|
|
344
|
+
"internalType": "uint256",
|
|
345
|
+
"name": "amountA",
|
|
346
|
+
"type": "uint256"
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
"internalType": "uint256",
|
|
350
|
+
"name": "amountB",
|
|
351
|
+
"type": "uint256"
|
|
352
|
+
}
|
|
353
|
+
],
|
|
354
|
+
"stateMutability": "nonpayable",
|
|
355
|
+
"type": "function"
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
"inputs": [
|
|
359
|
+
{
|
|
360
|
+
"internalType": "uint256",
|
|
361
|
+
"name": "_amount",
|
|
362
|
+
"type": "uint256"
|
|
363
|
+
}
|
|
364
|
+
],
|
|
365
|
+
"name": "deposit",
|
|
366
|
+
"outputs": [],
|
|
367
|
+
"stateMutability": "nonpayable",
|
|
368
|
+
"type": "function"
|
|
369
|
+
},
|
|
370
|
+
{
|
|
371
|
+
"inputs": [
|
|
372
|
+
{
|
|
373
|
+
"internalType": "uint256",
|
|
374
|
+
"name": "_shares",
|
|
375
|
+
"type": "uint256"
|
|
376
|
+
}
|
|
377
|
+
],
|
|
378
|
+
"name": "withdraw",
|
|
379
|
+
"outputs": [],
|
|
380
|
+
"stateMutability": "nonpayable",
|
|
381
|
+
"type": "function"
|
|
382
|
+
}
|
|
383
|
+
]
|
|
File without changes
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# Balance Adapter
|
|
2
|
+
|
|
3
|
+
Adapter that exposes wallet, token, and pool balances backed by `WalletClient`/`TokenClient` and now orchestrates transfers between the configured main/strategy wallets (with ledger bookkeeping).
|
|
4
|
+
|
|
5
|
+
- Entrypoint: `adapters.balance_adapter.adapter.BalanceAdapter`
|
|
6
|
+
- Manifest: `manifest.yaml`
|
|
7
|
+
- Tests: `test_adapter.py`
|
|
8
|
+
|
|
9
|
+
## Capabilities
|
|
10
|
+
|
|
11
|
+
The adapter declares both `wallet_read` and `wallet_transfer` capabilities in its manifest. Transfers are executed by leveraging the shared `DefaultWeb3Service.token_transactions` helper, but ledger recording + wallet selection now live inside the adapter.
|
|
12
|
+
|
|
13
|
+
## Construction
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
from wayfinder_paths.core.services.web3_service import DefaultWeb3Service
|
|
17
|
+
from wayfinder_paths.adapters.balance_adapter.adapter import BalanceAdapter
|
|
18
|
+
|
|
19
|
+
web3_service = DefaultWeb3Service(config)
|
|
20
|
+
balance = BalanceAdapter(config, web3_service=web3_service)
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
`web3_service` is required so the adapter can share the same wallet provider (and `TokenTxn` helper) as the rest of the strategy.
|
|
24
|
+
|
|
25
|
+
## API surface
|
|
26
|
+
|
|
27
|
+
### `get_balance(token_id: str, wallet_address: str)`
|
|
28
|
+
Returns the raw balance (as an integer) for a specific token on a wallet.
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
success, balance = await balance.get_balance(
|
|
32
|
+
token_id="usd-coin-base",
|
|
33
|
+
wallet_address=config["main_wallet"]["address"],
|
|
34
|
+
)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### `get_pool_balance(pool_address: str, chain_id: int, user_address: str)`
|
|
38
|
+
Fetches the amount supplied to a specific pool, using the `/wallets/pool-balance` endpoint.
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
success, amount = await balance.get_pool_balance(
|
|
42
|
+
pool_address="0xPool",
|
|
43
|
+
chain_id=8453,
|
|
44
|
+
user_address=config["strategy_wallet"]["address"],
|
|
45
|
+
)
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### `move_from_main_wallet_to_strategy_wallet(token_id: str, amount: float, strategy_name="unknown", skip_ledger=False)`
|
|
49
|
+
Sends the specified token from the configured `main_wallet` to the strategy wallet, records the ledger deposit (unless `skip_ledger=True`), and returns the `(success, tx_result)` tuple from the underlying send helper.
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
success, tx = await balance.move_from_main_wallet_to_strategy_wallet(
|
|
53
|
+
token_id="usd-coin-base",
|
|
54
|
+
amount=1.5,
|
|
55
|
+
strategy_name="MyStrategy",
|
|
56
|
+
)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### `move_from_strategy_wallet_to_main_wallet(token_id: str, amount: float, strategy_name="unknown", skip_ledger=False)`
|
|
60
|
+
Mirrors the previous method but withdraws from the strategy wallet back to the main wallet while recording a ledger withdrawal entry.
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
await balance.move_from_strategy_wallet_to_main_wallet(
|
|
64
|
+
token_id="usd-coin-base",
|
|
65
|
+
amount=0.75,
|
|
66
|
+
strategy_name="MyStrategy",
|
|
67
|
+
)
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
All methods return `(success: bool, payload: Any)` tuples. On failure the payload is an error string.
|
|
71
|
+
|
|
72
|
+
## Usage inside strategies
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
class MyStrategy(Strategy):
|
|
76
|
+
def __init__(self, config):
|
|
77
|
+
super().__init__()
|
|
78
|
+
web3_service = DefaultWeb3Service(config)
|
|
79
|
+
balance_adapter = BalanceAdapter(config, web3_service=web3_service)
|
|
80
|
+
self.register_adapters([balance_adapter])
|
|
81
|
+
self.balance_adapter = balance_adapter
|
|
82
|
+
|
|
83
|
+
async def _status(self):
|
|
84
|
+
success, pool_balance = await self.balance_adapter.get_pool_balance(
|
|
85
|
+
pool_address=self.current_pool["address"],
|
|
86
|
+
chain_id=self.current_pool["chain"]["id"],
|
|
87
|
+
user_address=self.config["strategy_wallet"]["address"],
|
|
88
|
+
)
|
|
89
|
+
return {"portfolio_value": float(pool_balance or 0), ...}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Error handling and health checks
|
|
93
|
+
|
|
94
|
+
Any exception raised by the underlying `WalletClient`/`TokenClient` is caught and emitted as a `(False, "message")` tuple. The inherited `health_check()` method reports adapter status plus dependency status, making it safe to call from `Strategy.health_check`.
|