wayfinder-paths 0.1.22__py3-none-any.whl → 0.1.24__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/__init__.py +0 -4
- wayfinder_paths/adapters/balance_adapter/README.md +0 -1
- wayfinder_paths/adapters/balance_adapter/adapter.py +313 -167
- wayfinder_paths/adapters/balance_adapter/manifest.yaml +8 -0
- wayfinder_paths/adapters/balance_adapter/test_adapter.py +41 -124
- wayfinder_paths/adapters/boros_adapter/__init__.py +17 -0
- wayfinder_paths/adapters/boros_adapter/adapter.py +1574 -0
- wayfinder_paths/adapters/boros_adapter/client.py +476 -0
- wayfinder_paths/adapters/boros_adapter/manifest.yaml +10 -0
- wayfinder_paths/adapters/boros_adapter/parsers.py +88 -0
- wayfinder_paths/adapters/boros_adapter/test_adapter.py +460 -0
- wayfinder_paths/adapters/boros_adapter/test_golden.py +156 -0
- wayfinder_paths/adapters/boros_adapter/types.py +70 -0
- wayfinder_paths/adapters/boros_adapter/utils.py +85 -0
- wayfinder_paths/adapters/brap_adapter/README.md +22 -75
- wayfinder_paths/adapters/brap_adapter/adapter.py +187 -576
- wayfinder_paths/adapters/brap_adapter/examples.json +21 -140
- wayfinder_paths/adapters/brap_adapter/manifest.yaml +9 -0
- wayfinder_paths/adapters/brap_adapter/test_adapter.py +6 -234
- wayfinder_paths/adapters/hyperlend_adapter/adapter.py +180 -92
- wayfinder_paths/adapters/hyperlend_adapter/manifest.yaml +9 -0
- wayfinder_paths/adapters/hyperlend_adapter/test_adapter.py +82 -14
- wayfinder_paths/adapters/hyperliquid_adapter/__init__.py +2 -9
- wayfinder_paths/adapters/hyperliquid_adapter/adapter.py +586 -61
- wayfinder_paths/adapters/hyperliquid_adapter/executor.py +47 -68
- wayfinder_paths/adapters/hyperliquid_adapter/manifest.yaml +14 -0
- wayfinder_paths/adapters/hyperliquid_adapter/paired_filler.py +2 -3
- wayfinder_paths/adapters/hyperliquid_adapter/test_adapter.py +17 -21
- wayfinder_paths/adapters/hyperliquid_adapter/test_adapter_live.py +3 -6
- wayfinder_paths/adapters/hyperliquid_adapter/test_executor.py +4 -8
- wayfinder_paths/adapters/hyperliquid_adapter/test_utils.py +2 -2
- wayfinder_paths/adapters/ledger_adapter/README.md +4 -1
- wayfinder_paths/adapters/ledger_adapter/adapter.py +3 -3
- wayfinder_paths/adapters/ledger_adapter/manifest.yaml +7 -0
- wayfinder_paths/adapters/ledger_adapter/test_adapter.py +1 -2
- wayfinder_paths/adapters/moonwell_adapter/adapter.py +649 -547
- wayfinder_paths/adapters/moonwell_adapter/manifest.yaml +14 -0
- wayfinder_paths/adapters/moonwell_adapter/test_adapter.py +160 -239
- wayfinder_paths/adapters/multicall_adapter/__init__.py +7 -0
- wayfinder_paths/adapters/multicall_adapter/adapter.py +166 -0
- wayfinder_paths/adapters/multicall_adapter/manifest.yaml +5 -0
- wayfinder_paths/adapters/multicall_adapter/test_adapter.py +97 -0
- wayfinder_paths/adapters/pendle_adapter/README.md +102 -0
- wayfinder_paths/adapters/pendle_adapter/__init__.py +7 -0
- wayfinder_paths/adapters/pendle_adapter/adapter.py +1992 -0
- wayfinder_paths/adapters/pendle_adapter/examples.json +11 -0
- wayfinder_paths/adapters/pendle_adapter/manifest.yaml +21 -0
- wayfinder_paths/adapters/pendle_adapter/test_adapter.py +666 -0
- wayfinder_paths/adapters/pool_adapter/manifest.yaml +6 -0
- wayfinder_paths/adapters/token_adapter/adapter.py +14 -0
- wayfinder_paths/adapters/token_adapter/examples.json +0 -4
- wayfinder_paths/adapters/token_adapter/manifest.yaml +7 -0
- wayfinder_paths/conftest.py +24 -17
- wayfinder_paths/core/__init__.py +0 -3
- wayfinder_paths/core/adapters/BaseAdapter.py +0 -25
- wayfinder_paths/core/adapters/models.py +17 -7
- wayfinder_paths/core/clients/BRAPClient.py +4 -1
- wayfinder_paths/core/clients/ClientManager.py +0 -7
- wayfinder_paths/core/clients/LedgerClient.py +196 -172
- wayfinder_paths/core/clients/TokenClient.py +47 -1
- wayfinder_paths/core/clients/WayfinderClient.py +1 -3
- wayfinder_paths/core/clients/__init__.py +0 -5
- wayfinder_paths/core/clients/protocols.py +21 -35
- wayfinder_paths/core/clients/test_ledger_client.py +448 -0
- wayfinder_paths/core/config.py +10 -162
- wayfinder_paths/core/constants/__init__.py +73 -2
- wayfinder_paths/core/constants/base.py +8 -17
- wayfinder_paths/core/constants/chains.py +36 -0
- wayfinder_paths/core/constants/contracts.py +52 -0
- wayfinder_paths/core/constants/erc20_abi.py +0 -1
- wayfinder_paths/core/constants/hyperlend_abi.py +0 -4
- wayfinder_paths/core/constants/hyperliquid.py +16 -0
- wayfinder_paths/core/constants/moonwell_abi.py +0 -15
- wayfinder_paths/core/constants/tokens.py +9 -0
- wayfinder_paths/core/engine/manifest.py +66 -0
- wayfinder_paths/core/strategies/Strategy.py +0 -71
- wayfinder_paths/core/strategies/__init__.py +10 -1
- wayfinder_paths/core/strategies/opa_loop.py +167 -0
- wayfinder_paths/core/utils/evm_helpers.py +5 -15
- wayfinder_paths/core/utils/test_transaction.py +289 -0
- wayfinder_paths/core/utils/tokens.py +28 -0
- wayfinder_paths/core/utils/transaction.py +57 -8
- wayfinder_paths/core/utils/web3.py +8 -3
- wayfinder_paths/mcp/__init__.py +5 -0
- wayfinder_paths/mcp/preview.py +185 -0
- wayfinder_paths/mcp/scripting.py +84 -0
- wayfinder_paths/mcp/server.py +52 -0
- wayfinder_paths/mcp/state/profile_store.py +195 -0
- wayfinder_paths/mcp/state/store.py +89 -0
- wayfinder_paths/mcp/test_scripting.py +267 -0
- wayfinder_paths/mcp/tools/__init__.py +0 -0
- wayfinder_paths/mcp/tools/balances.py +290 -0
- wayfinder_paths/mcp/tools/discovery.py +158 -0
- wayfinder_paths/mcp/tools/execute.py +770 -0
- wayfinder_paths/mcp/tools/hyperliquid.py +931 -0
- wayfinder_paths/mcp/tools/quotes.py +288 -0
- wayfinder_paths/mcp/tools/run_script.py +286 -0
- wayfinder_paths/mcp/tools/strategies.py +188 -0
- wayfinder_paths/mcp/tools/tokens.py +46 -0
- wayfinder_paths/mcp/tools/wallets.py +354 -0
- wayfinder_paths/mcp/utils.py +129 -0
- wayfinder_paths/policies/enso.py +1 -2
- wayfinder_paths/policies/hyper_evm.py +6 -3
- wayfinder_paths/policies/hyperlend.py +1 -2
- wayfinder_paths/policies/hyperliquid.py +1 -1
- wayfinder_paths/policies/lifi.py +18 -0
- wayfinder_paths/policies/moonwell.py +12 -7
- wayfinder_paths/policies/prjx.py +1 -3
- wayfinder_paths/policies/util.py +8 -2
- wayfinder_paths/run_strategy.py +97 -300
- wayfinder_paths/strategies/basis_trading_strategy/constants.py +3 -1
- wayfinder_paths/strategies/basis_trading_strategy/strategy.py +47 -133
- wayfinder_paths/strategies/basis_trading_strategy/test_strategy.py +24 -53
- wayfinder_paths/strategies/boros_hype_strategy/__init__.py +3 -0
- wayfinder_paths/strategies/boros_hype_strategy/boros_ops_mixin.py +450 -0
- wayfinder_paths/strategies/boros_hype_strategy/constants.py +255 -0
- wayfinder_paths/strategies/boros_hype_strategy/examples.json +37 -0
- wayfinder_paths/strategies/boros_hype_strategy/hyperevm_ops_mixin.py +114 -0
- wayfinder_paths/strategies/boros_hype_strategy/hyperliquid_ops_mixin.py +642 -0
- wayfinder_paths/strategies/boros_hype_strategy/manifest.yaml +36 -0
- wayfinder_paths/strategies/boros_hype_strategy/planner.py +460 -0
- wayfinder_paths/strategies/boros_hype_strategy/risk_ops_mixin.py +886 -0
- wayfinder_paths/strategies/boros_hype_strategy/snapshot_mixin.py +494 -0
- wayfinder_paths/strategies/boros_hype_strategy/strategy.py +1194 -0
- wayfinder_paths/strategies/boros_hype_strategy/test_planner_golden.py +374 -0
- wayfinder_paths/{templates/strategy → strategies/boros_hype_strategy}/test_strategy.py +99 -63
- wayfinder_paths/strategies/boros_hype_strategy/types.py +365 -0
- wayfinder_paths/strategies/boros_hype_strategy/withdraw_mixin.py +997 -0
- wayfinder_paths/strategies/hyperlend_stable_yield_strategy/strategy.py +15 -23
- wayfinder_paths/strategies/hyperlend_stable_yield_strategy/test_strategy.py +27 -62
- wayfinder_paths/strategies/moonwell_wsteth_loop_strategy/strategy.py +84 -58
- wayfinder_paths/strategies/moonwell_wsteth_loop_strategy/test_strategy.py +5 -15
- wayfinder_paths/strategies/stablecoin_yield_strategy/strategy.py +69 -164
- wayfinder_paths/strategies/stablecoin_yield_strategy/test_strategy.py +43 -76
- wayfinder_paths/tests/test_mcp_quote_swap.py +165 -0
- wayfinder_paths/tests/test_test_coverage.py +1 -4
- wayfinder_paths-0.1.24.dist-info/METADATA +378 -0
- wayfinder_paths-0.1.24.dist-info/RECORD +185 -0
- {wayfinder_paths-0.1.22.dist-info → wayfinder_paths-0.1.24.dist-info}/WHEEL +1 -1
- wayfinder_paths/core/clients/WalletClient.py +0 -41
- wayfinder_paths/core/engine/StrategyJob.py +0 -110
- wayfinder_paths/core/services/test_local_evm_txn.py +0 -145
- wayfinder_paths/scripts/create_strategy.py +0 -139
- wayfinder_paths/scripts/make_wallets.py +0 -142
- wayfinder_paths/templates/adapter/README.md +0 -150
- wayfinder_paths/templates/adapter/adapter.py +0 -16
- wayfinder_paths/templates/adapter/examples.json +0 -8
- wayfinder_paths/templates/adapter/test_adapter.py +0 -30
- wayfinder_paths/templates/strategy/README.md +0 -186
- wayfinder_paths/templates/strategy/examples.json +0 -11
- wayfinder_paths/templates/strategy/strategy.py +0 -35
- wayfinder_paths/tests/test_smoke_manifest.py +0 -63
- wayfinder_paths-0.1.22.dist-info/METADATA +0 -355
- wayfinder_paths-0.1.22.dist-info/RECORD +0 -129
- /wayfinder_paths/{scripts → mcp/state}/__init__.py +0 -0
- {wayfinder_paths-0.1.22.dist-info → wayfinder_paths-0.1.24.dist-info}/LICENSE +0 -0
|
@@ -1,55 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
"description": "Get a quote for a cross-chain swap operation",
|
|
4
|
-
"input": {
|
|
5
|
-
"from_token_address": "0xA0b86a33E6441c8C06DdD4D4c4c4c4c4c4c4c4c4c",
|
|
6
|
-
"to_token_address": "0xB1c97a44F7552d9Dd5e5e5e5e5e5e5e5e5e5e5e5e5e",
|
|
7
|
-
"from_chain_id": 8453,
|
|
8
|
-
"to_chain_id": 1,
|
|
9
|
-
"from_address": "0x1234567890123456789012345678901234567890",
|
|
10
|
-
"to_address": "0x1234567890123456789012345678901234567890",
|
|
11
|
-
"amount": "1000000000000000000",
|
|
12
|
-
"slippage": 0.01
|
|
13
|
-
},
|
|
14
|
-
"output": {
|
|
15
|
-
"success": true,
|
|
16
|
-
"data": {
|
|
17
|
-
"quotes": [
|
|
18
|
-
{
|
|
19
|
-
"provider": "enso",
|
|
20
|
-
"input_amount": 1000000000000000000,
|
|
21
|
-
"output_amount": 995000000000000000,
|
|
22
|
-
"fee_estimate": {
|
|
23
|
-
"fee_total_usd": 0.08,
|
|
24
|
-
"fee_breakdown": []
|
|
25
|
-
},
|
|
26
|
-
"calldata": {
|
|
27
|
-
"data": "0x",
|
|
28
|
-
"to": "0x",
|
|
29
|
-
"value": "0",
|
|
30
|
-
"chainId": 8453
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
],
|
|
34
|
-
"best_quote": {
|
|
35
|
-
"provider": "enso",
|
|
36
|
-
"input_amount": 1000000000000000000,
|
|
37
|
-
"output_amount": 995000000000000000,
|
|
38
|
-
"fee_estimate": {
|
|
39
|
-
"fee_total_usd": 0.08,
|
|
40
|
-
"fee_breakdown": []
|
|
41
|
-
},
|
|
42
|
-
"calldata": {
|
|
43
|
-
"data": "0x",
|
|
44
|
-
"to": "0x",
|
|
45
|
-
"value": "0",
|
|
46
|
-
"chainId": 8453
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
"get_best_quote": {
|
|
2
|
+
"best_quote": {
|
|
53
3
|
"description": "Get the best available quote for a swap operation",
|
|
54
4
|
"input": {
|
|
55
5
|
"from_token_address": "0xA0b86a33E6441c8C06DdD4D4c4c4c4c4c4c4c4c4c",
|
|
@@ -57,9 +7,7 @@
|
|
|
57
7
|
"from_chain_id": 8453,
|
|
58
8
|
"to_chain_id": 1,
|
|
59
9
|
"from_address": "0x1234567890123456789012345678901234567890",
|
|
60
|
-
"
|
|
61
|
-
"amount": "1000000000000000000",
|
|
62
|
-
"slippage": 0.01
|
|
10
|
+
"amount": "1000000000000000000"
|
|
63
11
|
},
|
|
64
12
|
"output": {
|
|
65
13
|
"success": true,
|
|
@@ -80,106 +28,39 @@
|
|
|
80
28
|
}
|
|
81
29
|
}
|
|
82
30
|
},
|
|
83
|
-
"
|
|
84
|
-
"description": "
|
|
31
|
+
"swap_from_token_ids": {
|
|
32
|
+
"description": "Execute a swap using token IDs",
|
|
85
33
|
"input": {
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"to_chain_id": 1,
|
|
90
|
-
"amount": "1000000000000000000",
|
|
91
|
-
"slippage": 0.01
|
|
92
|
-
},
|
|
93
|
-
"output": {
|
|
94
|
-
"success": true,
|
|
95
|
-
"data": {
|
|
96
|
-
"input_amount": 1000000000000000000,
|
|
97
|
-
"output_amount": 995000000000000000,
|
|
98
|
-
"gas_fee": 567840,
|
|
99
|
-
"bridge_fee": 0,
|
|
100
|
-
"protocol_fee": 0.08,
|
|
101
|
-
"total_fee": 0.08,
|
|
102
|
-
"slippage": 0,
|
|
103
|
-
"price_impact": 6888
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
"compare_routes": {
|
|
108
|
-
"description": "Compare multiple routes for a swap operation",
|
|
109
|
-
"input": {
|
|
110
|
-
"from_token_address": "0xA0b86a33E6441c8C06DdD4D4c4c4c4c4c4c4c4c4c",
|
|
111
|
-
"to_token_address": "0xB1c97a44F7552d9Dd5e5e5e5e5e5e5e5e5e5e5e5e5e",
|
|
112
|
-
"from_chain_id": 8453,
|
|
113
|
-
"to_chain_id": 1,
|
|
34
|
+
"from_token_id": "usd-coin-base",
|
|
35
|
+
"to_token_id": "ethereum",
|
|
36
|
+
"from_address": "0x1234567890123456789012345678901234567890",
|
|
114
37
|
"amount": "1000000000000000000",
|
|
115
|
-
"
|
|
38
|
+
"strategy_name": "my_strategy"
|
|
116
39
|
},
|
|
117
40
|
"output": {
|
|
118
41
|
"success": true,
|
|
119
42
|
"data": {
|
|
120
|
-
"
|
|
121
|
-
"
|
|
122
|
-
|
|
123
|
-
"output_amount": 995000000000000000,
|
|
124
|
-
"fee_estimate": { "fee_total_usd": 0.08, "fee_breakdown": [] }
|
|
125
|
-
},
|
|
126
|
-
"all_routes": [
|
|
127
|
-
{
|
|
128
|
-
"provider": "enso",
|
|
129
|
-
"output_amount": 995000000000000000,
|
|
130
|
-
"fee_estimate": { "fee_total_usd": 0.08, "fee_breakdown": [] }
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
"provider": "enso",
|
|
134
|
-
"output_amount": 992000000000000000,
|
|
135
|
-
"fee_estimate": { "fee_total_usd": 0.12, "fee_breakdown": [] }
|
|
136
|
-
}
|
|
137
|
-
],
|
|
138
|
-
"route_analysis": {
|
|
139
|
-
"highest_output": {
|
|
140
|
-
"output_amount": 995000000000000000
|
|
141
|
-
},
|
|
142
|
-
"lowest_fees": {
|
|
143
|
-
"fee_estimate": { "fee_total_usd": 0.08, "fee_breakdown": [] }
|
|
144
|
-
}
|
|
145
|
-
}
|
|
43
|
+
"from_amount": "1000000000000000000",
|
|
44
|
+
"to_amount": "995000000000000000",
|
|
45
|
+
"tx_hash": "0xabc123..."
|
|
146
46
|
}
|
|
147
47
|
}
|
|
148
48
|
},
|
|
149
|
-
"
|
|
150
|
-
"description": "
|
|
49
|
+
"swap_from_quote": {
|
|
50
|
+
"description": "Execute a swap from a pre-fetched quote",
|
|
151
51
|
"input": {
|
|
152
|
-
"
|
|
153
|
-
"
|
|
154
|
-
"
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
"success": true,
|
|
158
|
-
"data": {
|
|
159
|
-
"from_chain": "base",
|
|
160
|
-
"to_chain": "ethereum",
|
|
161
|
-
"from_gas_estimate": 100000,
|
|
162
|
-
"to_gas_estimate": 150000,
|
|
163
|
-
"total_operations": 2,
|
|
164
|
-
"operation_type": "swap"
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
},
|
|
168
|
-
"validate_swap_parameters": {
|
|
169
|
-
"description": "Validate swap parameters before executing",
|
|
170
|
-
"input": {
|
|
171
|
-
"from_token_address": "0xA0b86a33E6441c8C06DdD4D4c4c4c4c4c4c4c4c4c",
|
|
172
|
-
"to_token_address": "0xB1c97a44F7552d9Dd5e5e5e5e5e5e5e5e5e5e5e5e5e",
|
|
173
|
-
"from_chain_id": 8453,
|
|
174
|
-
"to_chain_id": 1,
|
|
175
|
-
"amount": "1000000000000000000"
|
|
52
|
+
"from_token": {"address": "0x...", "chain": {"id": 8453}},
|
|
53
|
+
"to_token": {"address": "0x...", "chain": {"id": 1}},
|
|
54
|
+
"from_address": "0x1234567890123456789012345678901234567890",
|
|
55
|
+
"quote": {"calldata": {"data": "0x...", "to": "0x..."}, "input_amount": "1000000000000000000"},
|
|
56
|
+
"strategy_name": "my_strategy"
|
|
176
57
|
},
|
|
177
58
|
"output": {
|
|
178
59
|
"success": true,
|
|
179
60
|
"data": {
|
|
180
|
-
"
|
|
181
|
-
"
|
|
182
|
-
"
|
|
61
|
+
"from_amount": "1000000000000000000",
|
|
62
|
+
"to_amount": "995000000000000000",
|
|
63
|
+
"tx_hash": "0xabc123..."
|
|
183
64
|
}
|
|
184
65
|
}
|
|
185
66
|
}
|
|
@@ -18,63 +18,7 @@ class TestBRAPAdapter:
|
|
|
18
18
|
return adapter
|
|
19
19
|
|
|
20
20
|
@pytest.mark.asyncio
|
|
21
|
-
async def
|
|
22
|
-
mock_response = {
|
|
23
|
-
"quotes": [
|
|
24
|
-
{
|
|
25
|
-
"provider": "enso",
|
|
26
|
-
"input_amount": 1000000000000000000,
|
|
27
|
-
"output_amount": 995000000000000000,
|
|
28
|
-
"calldata": {
|
|
29
|
-
"data": "0x",
|
|
30
|
-
"to": "0x",
|
|
31
|
-
"from_address": "0x",
|
|
32
|
-
"value": "0",
|
|
33
|
-
"chainId": 8453,
|
|
34
|
-
},
|
|
35
|
-
"fee_estimate": {"fee_total_usd": 0.008, "fee_breakdown": []},
|
|
36
|
-
}
|
|
37
|
-
],
|
|
38
|
-
"best_quote": {
|
|
39
|
-
"provider": "enso",
|
|
40
|
-
"input_amount": 1000000000000000000,
|
|
41
|
-
"output_amount": 995000000000000000,
|
|
42
|
-
"calldata": {
|
|
43
|
-
"data": "0x",
|
|
44
|
-
"to": "0x",
|
|
45
|
-
"from_address": "0x",
|
|
46
|
-
"value": "0",
|
|
47
|
-
"chainId": 8453,
|
|
48
|
-
},
|
|
49
|
-
"fee_estimate": {"fee_total_usd": 0.008, "fee_breakdown": []},
|
|
50
|
-
},
|
|
51
|
-
}
|
|
52
|
-
mock_brap_client.get_quote = AsyncMock(return_value=mock_response)
|
|
53
|
-
|
|
54
|
-
success, data = await adapter.get_swap_quote(
|
|
55
|
-
from_token_address="0x" + "a" * 40,
|
|
56
|
-
to_token_address="0x" + "b" * 40,
|
|
57
|
-
from_chain_id=8453,
|
|
58
|
-
to_chain_id=1,
|
|
59
|
-
from_address="0x1234567890123456789012345678901234567890",
|
|
60
|
-
to_address="0x1234567890123456789012345678901234567890",
|
|
61
|
-
amount="1000000000000000000",
|
|
62
|
-
slippage=0.01,
|
|
63
|
-
)
|
|
64
|
-
|
|
65
|
-
assert success
|
|
66
|
-
assert data == mock_response
|
|
67
|
-
mock_brap_client.get_quote.assert_called_once_with(
|
|
68
|
-
from_token="0x" + "a" * 40,
|
|
69
|
-
to_token="0x" + "b" * 40,
|
|
70
|
-
from_chain=8453,
|
|
71
|
-
to_chain=1,
|
|
72
|
-
from_wallet="0x1234567890123456789012345678901234567890",
|
|
73
|
-
from_amount="1000000000000000000",
|
|
74
|
-
)
|
|
75
|
-
|
|
76
|
-
@pytest.mark.asyncio
|
|
77
|
-
async def test_get_best_quote_success(self, adapter, mock_brap_client):
|
|
21
|
+
async def test_best_quote_success(self, adapter, mock_brap_client):
|
|
78
22
|
mock_response = {
|
|
79
23
|
"quotes": [],
|
|
80
24
|
"best_quote": {
|
|
@@ -93,13 +37,12 @@ class TestBRAPAdapter:
|
|
|
93
37
|
}
|
|
94
38
|
mock_brap_client.get_quote = AsyncMock(return_value=mock_response)
|
|
95
39
|
|
|
96
|
-
success, data = await adapter.
|
|
40
|
+
success, data = await adapter.best_quote(
|
|
97
41
|
from_token_address="0x" + "a" * 40,
|
|
98
42
|
to_token_address="0x" + "b" * 40,
|
|
99
43
|
from_chain_id=8453,
|
|
100
44
|
to_chain_id=1,
|
|
101
45
|
from_address="0x1234567890123456789012345678901234567890",
|
|
102
|
-
to_address="0x1234567890123456789012345678901234567890",
|
|
103
46
|
amount="1000000000000000000",
|
|
104
47
|
)
|
|
105
48
|
|
|
@@ -108,17 +51,16 @@ class TestBRAPAdapter:
|
|
|
108
51
|
assert data["output_amount"] == 995000000000000000
|
|
109
52
|
|
|
110
53
|
@pytest.mark.asyncio
|
|
111
|
-
async def
|
|
54
|
+
async def test_best_quote_no_quotes(self, adapter, mock_brap_client):
|
|
112
55
|
mock_response = {"quotes": [], "best_quote": None}
|
|
113
56
|
mock_brap_client.get_quote = AsyncMock(return_value=mock_response)
|
|
114
57
|
|
|
115
|
-
success, data = await adapter.
|
|
58
|
+
success, data = await adapter.best_quote(
|
|
116
59
|
from_token_address="0x" + "a" * 40,
|
|
117
60
|
to_token_address="0x" + "b" * 40,
|
|
118
61
|
from_chain_id=8453,
|
|
119
62
|
to_chain_id=1,
|
|
120
63
|
from_address="0x1234567890123456789012345678901234567890",
|
|
121
|
-
to_address="0x1234567890123456789012345678901234567890",
|
|
122
64
|
amount="1000000000000000000",
|
|
123
65
|
)
|
|
124
66
|
|
|
@@ -126,185 +68,15 @@ class TestBRAPAdapter:
|
|
|
126
68
|
assert "No quotes available" in data
|
|
127
69
|
|
|
128
70
|
@pytest.mark.asyncio
|
|
129
|
-
async def
|
|
130
|
-
mock_quote_response = {
|
|
131
|
-
"quotes": [],
|
|
132
|
-
"best_quote": {
|
|
133
|
-
"provider": "enso",
|
|
134
|
-
"input_amount": 1000000000000000000,
|
|
135
|
-
"output_amount": 995000000000000000,
|
|
136
|
-
"gas_estimate": 5000000000000000,
|
|
137
|
-
"quote": {"priceImpact": 5},
|
|
138
|
-
"fee_estimate": {
|
|
139
|
-
"fee_total_usd": 0.008,
|
|
140
|
-
"fee_breakdown": [],
|
|
141
|
-
},
|
|
142
|
-
"calldata": {
|
|
143
|
-
"data": "0x",
|
|
144
|
-
"to": "0x",
|
|
145
|
-
"from_address": "0x",
|
|
146
|
-
"value": "0",
|
|
147
|
-
"chainId": 8453,
|
|
148
|
-
},
|
|
149
|
-
},
|
|
150
|
-
}
|
|
151
|
-
mock_brap_client.get_quote = AsyncMock(return_value=mock_quote_response)
|
|
152
|
-
|
|
153
|
-
success, data = await adapter.calculate_swap_fees(
|
|
154
|
-
from_token_address="0x" + "a" * 40,
|
|
155
|
-
to_token_address="0x" + "b" * 40,
|
|
156
|
-
from_chain_id=8453,
|
|
157
|
-
to_chain_id=1,
|
|
158
|
-
amount="1000000000000000000",
|
|
159
|
-
slippage=0.01,
|
|
160
|
-
)
|
|
161
|
-
|
|
162
|
-
assert success
|
|
163
|
-
assert data["input_amount"] == 1000000000000000000
|
|
164
|
-
assert data["output_amount"] == 995000000000000000
|
|
165
|
-
assert data["gas_fee"] == 5000000000000000
|
|
166
|
-
assert data["total_fee"] == 0.008
|
|
167
|
-
|
|
168
|
-
@pytest.mark.asyncio
|
|
169
|
-
async def test_compare_routes_success(self, adapter, mock_brap_client):
|
|
170
|
-
mock_response = {
|
|
171
|
-
"quotes": [
|
|
172
|
-
{
|
|
173
|
-
"provider": "enso",
|
|
174
|
-
"output_amount": 995000000000000000,
|
|
175
|
-
"fee_estimate": {"fee_total_usd": 0.008, "fee_breakdown": []},
|
|
176
|
-
"calldata": {
|
|
177
|
-
"data": "0x",
|
|
178
|
-
"to": "0x",
|
|
179
|
-
"from_address": "0x",
|
|
180
|
-
"value": "0",
|
|
181
|
-
"chainId": 8453,
|
|
182
|
-
},
|
|
183
|
-
},
|
|
184
|
-
{
|
|
185
|
-
"provider": "enso",
|
|
186
|
-
"output_amount": 992000000000000000,
|
|
187
|
-
"fee_estimate": {"fee_total_usd": 0.012, "fee_breakdown": []},
|
|
188
|
-
"calldata": {
|
|
189
|
-
"data": "0x",
|
|
190
|
-
"to": "0x",
|
|
191
|
-
"from_address": "0x",
|
|
192
|
-
"value": "0",
|
|
193
|
-
"chainId": 8453,
|
|
194
|
-
},
|
|
195
|
-
},
|
|
196
|
-
],
|
|
197
|
-
"best_quote": {
|
|
198
|
-
"provider": "enso",
|
|
199
|
-
"output_amount": 995000000000000000,
|
|
200
|
-
"fee_estimate": {"fee_total_usd": 0.008, "fee_breakdown": []},
|
|
201
|
-
"calldata": {
|
|
202
|
-
"data": "0x",
|
|
203
|
-
"to": "0x",
|
|
204
|
-
"from_address": "0x",
|
|
205
|
-
"value": "0",
|
|
206
|
-
"chainId": 8453,
|
|
207
|
-
},
|
|
208
|
-
},
|
|
209
|
-
}
|
|
210
|
-
mock_brap_client.get_quote = AsyncMock(return_value=mock_response)
|
|
211
|
-
|
|
212
|
-
success, data = await adapter.compare_routes(
|
|
213
|
-
from_token_address="0x" + "a" * 40,
|
|
214
|
-
to_token_address="0x" + "b" * 40,
|
|
215
|
-
from_chain_id=8453,
|
|
216
|
-
to_chain_id=1,
|
|
217
|
-
amount="1000000000000000000",
|
|
218
|
-
)
|
|
219
|
-
|
|
220
|
-
assert success
|
|
221
|
-
assert data["total_routes"] == 2
|
|
222
|
-
assert len(data["all_routes"]) == 2
|
|
223
|
-
assert data["best_route"]["output_amount"] == 995000000000000000
|
|
224
|
-
|
|
225
|
-
@pytest.mark.asyncio
|
|
226
|
-
async def test_estimate_gas_cost_success(self, adapter):
|
|
227
|
-
success, data = await adapter.estimate_gas_cost(
|
|
228
|
-
from_chain_id=8453, to_chain_id=1, operation_type="swap"
|
|
229
|
-
)
|
|
230
|
-
|
|
231
|
-
assert success
|
|
232
|
-
assert data["from_chain"] == "base"
|
|
233
|
-
assert data["to_chain"] == "ethereum"
|
|
234
|
-
assert data["from_gas_estimate"] == 100000
|
|
235
|
-
assert data["to_gas_estimate"] == 150000
|
|
236
|
-
assert data["total_operations"] == 2
|
|
237
|
-
|
|
238
|
-
@pytest.mark.asyncio
|
|
239
|
-
async def test_validate_swap_parameters_success(self, adapter, mock_brap_client):
|
|
240
|
-
mock_quote_response = {
|
|
241
|
-
"quotes": [],
|
|
242
|
-
"best_quote": {
|
|
243
|
-
"output_amount": 995000000000000000,
|
|
244
|
-
"calldata": {
|
|
245
|
-
"data": "0x",
|
|
246
|
-
"to": "0x",
|
|
247
|
-
"from_address": "0x",
|
|
248
|
-
"value": "0",
|
|
249
|
-
"chainId": 8453,
|
|
250
|
-
},
|
|
251
|
-
"fee_estimate": {"fee_total_usd": 0.008, "fee_breakdown": []},
|
|
252
|
-
},
|
|
253
|
-
}
|
|
254
|
-
mock_brap_client.get_quote = AsyncMock(return_value=mock_quote_response)
|
|
255
|
-
|
|
256
|
-
success, data = await adapter.validate_swap_parameters(
|
|
257
|
-
from_token_address="0x" + "a" * 40,
|
|
258
|
-
to_token_address="0x" + "b" * 40,
|
|
259
|
-
from_chain_id=8453,
|
|
260
|
-
to_chain_id=1,
|
|
261
|
-
amount="1000000000000000000",
|
|
262
|
-
)
|
|
263
|
-
|
|
264
|
-
assert success
|
|
265
|
-
assert data["valid"] is True
|
|
266
|
-
assert data["quote_available"] is True
|
|
267
|
-
assert data["estimated_output"] == "995000000000000000"
|
|
268
|
-
|
|
269
|
-
@pytest.mark.asyncio
|
|
270
|
-
async def test_validate_swap_parameters_invalid_address(self, adapter):
|
|
271
|
-
success, data = await adapter.validate_swap_parameters(
|
|
272
|
-
from_token_address="invalid_address",
|
|
273
|
-
to_token_address="0xB1c97a44F7552d9Dd5e5e5e5e5e5e5e5e5e5e5e5e5e",
|
|
274
|
-
from_chain_id=8453,
|
|
275
|
-
to_chain_id=1,
|
|
276
|
-
amount="1000000000000000000",
|
|
277
|
-
)
|
|
278
|
-
|
|
279
|
-
assert success is False
|
|
280
|
-
assert data["valid"] is False
|
|
281
|
-
assert "Invalid from_token_address" in data["errors"]
|
|
282
|
-
|
|
283
|
-
@pytest.mark.asyncio
|
|
284
|
-
async def test_validate_swap_parameters_invalid_amount(self, adapter):
|
|
285
|
-
success, data = await adapter.validate_swap_parameters(
|
|
286
|
-
from_token_address="0x" + "a" * 40,
|
|
287
|
-
to_token_address="0x" + "b" * 40,
|
|
288
|
-
from_chain_id=8453,
|
|
289
|
-
to_chain_id=1,
|
|
290
|
-
amount="invalid_amount",
|
|
291
|
-
)
|
|
292
|
-
|
|
293
|
-
assert success is False
|
|
294
|
-
assert data["valid"] is False
|
|
295
|
-
assert "Invalid amount format" in data["errors"]
|
|
296
|
-
|
|
297
|
-
@pytest.mark.asyncio
|
|
298
|
-
async def test_get_swap_quote_failure(self, adapter, mock_brap_client):
|
|
71
|
+
async def test_best_quote_failure(self, adapter, mock_brap_client):
|
|
299
72
|
mock_brap_client.get_quote = AsyncMock(side_effect=Exception("API Error"))
|
|
300
73
|
|
|
301
|
-
success, data = await adapter.
|
|
74
|
+
success, data = await adapter.best_quote(
|
|
302
75
|
from_token_address="0x" + "a" * 40,
|
|
303
76
|
to_token_address="0x" + "b" * 40,
|
|
304
77
|
from_chain_id=8453,
|
|
305
78
|
to_chain_id=1,
|
|
306
79
|
from_address="0x1234567890123456789012345678901234567890",
|
|
307
|
-
to_address="0x1234567890123456789012345678901234567890",
|
|
308
80
|
amount="1000000000000000000",
|
|
309
81
|
)
|
|
310
82
|
|