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
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"""Boros-specific utilities (tick math, parsing helpers, conversions)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import math
|
|
6
|
+
from decimal import Decimal
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
BOROS_TICK_BASE = 1.0001
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def tick_from_rate(
|
|
13
|
+
rate: float, tick_step: int, *, round_down: bool, base: float = BOROS_TICK_BASE
|
|
14
|
+
) -> int:
|
|
15
|
+
"""Convert APR rate to Boros limitTick."""
|
|
16
|
+
if tick_step <= 0:
|
|
17
|
+
tick_step = 1
|
|
18
|
+
ln_base = math.log(base)
|
|
19
|
+
if rate >= 0:
|
|
20
|
+
if rate == 0:
|
|
21
|
+
return 0
|
|
22
|
+
raw = math.log1p(rate) / (tick_step * ln_base)
|
|
23
|
+
return int(math.floor(raw) if round_down else math.ceil(raw))
|
|
24
|
+
# Negative rate
|
|
25
|
+
raw = math.log1p(-rate) / (tick_step * ln_base)
|
|
26
|
+
return -int(math.floor(raw) if round_down else math.ceil(raw))
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def rate_from_tick(tick: int, tick_step: int, base: float = BOROS_TICK_BASE) -> float:
|
|
30
|
+
"""Convert Boros limitTick to APR rate."""
|
|
31
|
+
if tick_step <= 0:
|
|
32
|
+
tick_step = 1
|
|
33
|
+
p = base ** (abs(int(tick)) * int(tick_step))
|
|
34
|
+
r = p - 1
|
|
35
|
+
return r if tick >= 0 else -r
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def normalize_apr(value: Any) -> float | None:
|
|
39
|
+
"""Normalize various APR encodings to decimal.
|
|
40
|
+
|
|
41
|
+
Handles: decimal (0.1115), percent (11.15), bps (1115), 1e18-scaled.
|
|
42
|
+
"""
|
|
43
|
+
if value is None:
|
|
44
|
+
return None
|
|
45
|
+
try:
|
|
46
|
+
x = float(value)
|
|
47
|
+
except (TypeError, ValueError):
|
|
48
|
+
return None
|
|
49
|
+
|
|
50
|
+
if x == 0:
|
|
51
|
+
return None
|
|
52
|
+
# 1e18-scaled decimal
|
|
53
|
+
if x > 1e9:
|
|
54
|
+
return x / 1e18
|
|
55
|
+
# bps (1115 = 11.15%)
|
|
56
|
+
if x > 1000:
|
|
57
|
+
return x / 10_000.0
|
|
58
|
+
# percent (11.15 = 11.15%)
|
|
59
|
+
if x > 1:
|
|
60
|
+
return x / 100.0
|
|
61
|
+
# already decimal
|
|
62
|
+
return x
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def cash_wei_to_float(value_wei: Any) -> float:
|
|
66
|
+
"""Convert Boros cash units (1e18) to float."""
|
|
67
|
+
if value_wei is None:
|
|
68
|
+
return 0.0
|
|
69
|
+
try:
|
|
70
|
+
return float(Decimal(str(value_wei)) / Decimal(1e18))
|
|
71
|
+
except Exception:
|
|
72
|
+
return 0.0
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def market_id_from_market_acc(market_acc: str) -> int | None:
|
|
76
|
+
"""Parse a Boros `marketAcc` into a market_id (last 3 bytes)."""
|
|
77
|
+
if not market_acc or len(market_acc) < 8:
|
|
78
|
+
return None
|
|
79
|
+
try:
|
|
80
|
+
market_id = int(market_acc[-6:], 16)
|
|
81
|
+
except ValueError:
|
|
82
|
+
return None
|
|
83
|
+
if market_id == 0xFFFFFF:
|
|
84
|
+
return None
|
|
85
|
+
return market_id
|
|
@@ -5,118 +5,65 @@ Adapter for cross-chain swaps and bridges via the BRAP (Bridge/Router/Adapter Pr
|
|
|
5
5
|
- **Type**: `BRAP`
|
|
6
6
|
- **Module**: `wayfinder_paths.adapters.brap_adapter.adapter.BRAPAdapter`
|
|
7
7
|
|
|
8
|
-
## Overview
|
|
9
|
-
|
|
10
|
-
The BRAPAdapter provides:
|
|
11
|
-
- Cross-chain swap quotes
|
|
12
|
-
- Bridge operation quotes
|
|
13
|
-
- Route comparison and optimization
|
|
14
|
-
- Fee calculations
|
|
15
|
-
- Swap execution
|
|
16
|
-
|
|
17
8
|
## Usage
|
|
18
9
|
|
|
19
10
|
```python
|
|
20
11
|
from wayfinder_paths.adapters.brap_adapter.adapter import BRAPAdapter
|
|
21
12
|
|
|
22
|
-
adapter = BRAPAdapter()
|
|
13
|
+
adapter = BRAPAdapter(strategy_wallet_signing_callback=signing_callback)
|
|
23
14
|
```
|
|
24
15
|
|
|
25
16
|
## Methods
|
|
26
17
|
|
|
27
|
-
###
|
|
28
|
-
|
|
29
|
-
Get quotes for a cross-chain swap.
|
|
30
|
-
|
|
31
|
-
```python
|
|
32
|
-
success, data = await adapter.get_swap_quote(
|
|
33
|
-
from_token_address="0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
34
|
-
to_token_address="0x...",
|
|
35
|
-
from_chain_id=8453,
|
|
36
|
-
to_chain_id=1,
|
|
37
|
-
from_address="0x...",
|
|
38
|
-
to_address="0x...",
|
|
39
|
-
amount="1000000000", # Raw amount
|
|
40
|
-
slippage=0.01, # 1%
|
|
41
|
-
)
|
|
42
|
-
if success:
|
|
43
|
-
best_quote = data.get("quotes", {}).get("best_quote", {})
|
|
44
|
-
print(f"Output: {best_quote.get('output_amount')}")
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
### get_best_quote
|
|
18
|
+
### best_quote
|
|
48
19
|
|
|
49
20
|
Get the best quote for a swap.
|
|
50
21
|
|
|
51
22
|
```python
|
|
52
|
-
success,
|
|
23
|
+
success, quote = await adapter.best_quote(
|
|
53
24
|
from_token_address="0x...",
|
|
54
25
|
to_token_address="0x...",
|
|
55
26
|
from_chain_id=8453,
|
|
56
27
|
to_chain_id=1,
|
|
57
28
|
from_address="0x...",
|
|
58
|
-
to_address="0x...",
|
|
59
|
-
amount="1000000000",
|
|
60
|
-
)
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
### compare_routes
|
|
64
|
-
|
|
65
|
-
Compare available routes for a swap.
|
|
66
|
-
|
|
67
|
-
```python
|
|
68
|
-
success, data = await adapter.compare_routes(
|
|
69
|
-
from_token_address="0x...",
|
|
70
|
-
to_token_address="0x...",
|
|
71
|
-
from_chain_id=8453,
|
|
72
|
-
to_chain_id=1,
|
|
73
29
|
amount="1000000000",
|
|
30
|
+
preferred_providers=["enso"], # optional
|
|
74
31
|
)
|
|
75
32
|
if success:
|
|
76
|
-
print(f"
|
|
77
|
-
for route in data.get("all_routes", []):
|
|
78
|
-
print(f"Output: {route.get('output_amount')}, Fee: {route.get('total_fee')}")
|
|
33
|
+
print(f"Output: {quote.get('output_amount')}")
|
|
79
34
|
```
|
|
80
35
|
|
|
81
|
-
###
|
|
36
|
+
### swap_from_token_ids
|
|
82
37
|
|
|
83
|
-
|
|
38
|
+
Execute a swap using token IDs.
|
|
84
39
|
|
|
85
40
|
```python
|
|
86
|
-
success,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
to_chain_id=1,
|
|
41
|
+
success, result = await adapter.swap_from_token_ids(
|
|
42
|
+
from_token_id="usd-coin-base",
|
|
43
|
+
to_token_id="ethereum",
|
|
44
|
+
from_address="0x...",
|
|
91
45
|
amount="1000000000",
|
|
92
|
-
|
|
46
|
+
strategy_name="my_strategy",
|
|
47
|
+
preferred_providers=["enso"],
|
|
93
48
|
)
|
|
94
49
|
if success:
|
|
95
|
-
print(f"
|
|
96
|
-
print(f"Bridge fee: {data.get('bridge_fee')}")
|
|
97
|
-
print(f"Total fee: {data.get('total_fee')}")
|
|
50
|
+
print(f"TX: {result.get('tx_hash')}")
|
|
98
51
|
```
|
|
99
52
|
|
|
100
|
-
###
|
|
53
|
+
### swap_from_quote
|
|
101
54
|
|
|
102
|
-
|
|
55
|
+
Execute a swap from a pre-fetched quote.
|
|
103
56
|
|
|
104
57
|
```python
|
|
105
|
-
success,
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
58
|
+
success, result = await adapter.swap_from_quote(
|
|
59
|
+
from_token=from_token_info,
|
|
60
|
+
to_token=to_token_info,
|
|
61
|
+
from_address="0x...",
|
|
62
|
+
quote=quote,
|
|
63
|
+
strategy_name="my_strategy",
|
|
111
64
|
)
|
|
112
|
-
if success and data.get("valid"):
|
|
113
|
-
print("Parameters are valid")
|
|
114
65
|
```
|
|
115
66
|
|
|
116
|
-
## Dependencies
|
|
117
|
-
|
|
118
|
-
- `BRAPClient` - Low-level API client
|
|
119
|
-
|
|
120
67
|
## Testing
|
|
121
68
|
|
|
122
69
|
```bash
|