wayfinder-paths 0.1.11__tar.gz → 0.1.14__tar.gz
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-0.1.11/README.md → wayfinder_paths-0.1.14/PKG-INFO +42 -56
- wayfinder_paths-0.1.11/PKG-INFO → wayfinder_paths-0.1.14/README.md +20 -80
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/pyproject.toml +2 -3
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/adapters/balance_adapter/README.md +13 -14
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/adapters/balance_adapter/adapter.py +36 -39
- wayfinder_paths-0.1.14/wayfinder_paths/adapters/balance_adapter/test_adapter.py +182 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/adapters/brap_adapter/README.md +11 -16
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/adapters/brap_adapter/adapter.py +87 -75
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/adapters/brap_adapter/examples.json +63 -52
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/adapters/brap_adapter/test_adapter.py +121 -59
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/adapters/hyperlend_adapter/adapter.py +22 -23
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/adapters/hyperlend_adapter/test_adapter.py +114 -60
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/adapters/hyperliquid_adapter/adapter.py +1 -1
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/adapters/hyperliquid_adapter/executor.py +44 -5
- wayfinder_paths-0.1.14/wayfinder_paths/adapters/hyperliquid_adapter/test_executor.py +104 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/adapters/moonwell_adapter/adapter.py +0 -3
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/adapters/pool_adapter/README.md +11 -27
- wayfinder_paths-0.1.14/wayfinder_paths/adapters/pool_adapter/adapter.py +62 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/adapters/pool_adapter/examples.json +6 -7
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/adapters/pool_adapter/test_adapter.py +8 -8
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/adapters/token_adapter/README.md +2 -14
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/adapters/token_adapter/adapter.py +16 -10
- wayfinder_paths-0.1.14/wayfinder_paths/adapters/token_adapter/examples.json +22 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/adapters/token_adapter/test_adapter.py +5 -3
- wayfinder_paths-0.1.14/wayfinder_paths/core/clients/BRAPClient.py +151 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/core/clients/ClientManager.py +1 -68
- wayfinder_paths-0.1.14/wayfinder_paths/core/clients/HyperlendClient.py +253 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/core/clients/LedgerClient.py +1 -4
- wayfinder_paths-0.1.14/wayfinder_paths/core/clients/PoolClient.py +150 -0
- wayfinder_paths-0.1.14/wayfinder_paths/core/clients/TokenClient.py +144 -0
- wayfinder_paths-0.1.14/wayfinder_paths/core/clients/WalletClient.py +56 -0
- wayfinder_paths-0.1.14/wayfinder_paths/core/clients/WayfinderClient.py +131 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/core/clients/__init__.py +0 -2
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/core/clients/protocols.py +35 -52
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/core/clients/sdk_example.py +37 -22
- wayfinder_paths-0.1.14/wayfinder_paths/core/config.py +254 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/core/engine/StrategyJob.py +7 -55
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/core/services/local_evm_txn.py +28 -10
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/core/services/local_token_txn.py +1 -1
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/core/strategies/Strategy.py +3 -5
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/core/strategies/descriptors.py +7 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/core/utils/evm_helpers.py +7 -3
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/core/utils/wallets.py +12 -19
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/core/wallets/README.md +1 -1
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/run_strategy.py +8 -17
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/scripts/create_strategy.py +5 -5
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/scripts/make_wallets.py +5 -5
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/scripts/run_strategy.py +3 -3
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/strategies/basis_trading_strategy/snapshot_mixin.py +1 -1
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/strategies/basis_trading_strategy/strategy.py +206 -526
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/strategies/basis_trading_strategy/test_strategy.py +228 -11
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/strategies/hyperlend_stable_yield_strategy/README.md +2 -2
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/strategies/hyperlend_stable_yield_strategy/strategy.py +41 -25
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/strategies/hyperlend_stable_yield_strategy/test_strategy.py +54 -9
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/strategies/moonwell_wsteth_loop_strategy/README.md +1 -1
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/strategies/moonwell_wsteth_loop_strategy/strategy.py +10 -9
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/strategies/moonwell_wsteth_loop_strategy/test_strategy.py +12 -6
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/strategies/stablecoin_yield_strategy/README.md +3 -3
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/strategies/stablecoin_yield_strategy/strategy.py +110 -78
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/strategies/stablecoin_yield_strategy/test_strategy.py +44 -21
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/templates/adapter/README.md +1 -1
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/templates/strategy/README.md +3 -3
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/templates/strategy/test_strategy.py +3 -2
- wayfinder_paths-0.1.11/wayfinder_paths/adapters/balance_adapter/test_adapter.py +0 -59
- wayfinder_paths-0.1.11/wayfinder_paths/adapters/pool_adapter/adapter.py +0 -88
- wayfinder_paths-0.1.11/wayfinder_paths/adapters/token_adapter/examples.json +0 -26
- wayfinder_paths-0.1.11/wayfinder_paths/core/clients/AuthClient.py +0 -83
- wayfinder_paths-0.1.11/wayfinder_paths/core/clients/BRAPClient.py +0 -110
- wayfinder_paths-0.1.11/wayfinder_paths/core/clients/HyperlendClient.py +0 -192
- wayfinder_paths-0.1.11/wayfinder_paths/core/clients/PoolClient.py +0 -112
- wayfinder_paths-0.1.11/wayfinder_paths/core/clients/TokenClient.py +0 -89
- wayfinder_paths-0.1.11/wayfinder_paths/core/clients/WalletClient.py +0 -86
- wayfinder_paths-0.1.11/wayfinder_paths/core/clients/WayfinderClient.py +0 -264
- wayfinder_paths-0.1.11/wayfinder_paths/core/config.py +0 -418
- wayfinder_paths-0.1.11/wayfinder_paths/core/settings.py +0 -61
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/LICENSE +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/__init__.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/abis/generic/erc20.json +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/adapters/__init__.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/adapters/balance_adapter/examples.json +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/adapters/brap_adapter/__init__.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/adapters/hyperlend_adapter/__init__.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/adapters/hyperliquid_adapter/__init__.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/adapters/hyperliquid_adapter/paired_filler.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/adapters/hyperliquid_adapter/test_adapter.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/adapters/hyperliquid_adapter/test_adapter_live.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/adapters/hyperliquid_adapter/test_utils.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/adapters/hyperliquid_adapter/utils.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/adapters/ledger_adapter/README.md +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/adapters/ledger_adapter/__init__.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/adapters/ledger_adapter/adapter.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/adapters/ledger_adapter/examples.json +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/adapters/ledger_adapter/test_adapter.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/adapters/moonwell_adapter/README.md +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/adapters/moonwell_adapter/__init__.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/adapters/moonwell_adapter/test_adapter.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/adapters/pool_adapter/__init__.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/adapters/token_adapter/__init__.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/conftest.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/core/__init__.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/core/adapters/BaseAdapter.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/core/adapters/__init__.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/core/adapters/base.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/core/adapters/models.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/core/analytics/__init__.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/core/analytics/bootstrap.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/core/analytics/stats.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/core/analytics/test_analytics.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/core/constants/__init__.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/core/constants/base.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/core/constants/erc20_abi.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/core/constants/hyperlend_abi.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/core/constants/moonwell_abi.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/core/engine/__init__.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/core/services/__init__.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/core/services/base.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/core/services/web3_service.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/core/strategies/__init__.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/core/strategies/base.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/core/utils/__init__.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/core/wallets/WalletManager.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/core/wallets/__init__.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/policies/enso.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/policies/erc20.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/policies/evm.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/policies/hyper_evm.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/policies/hyperlend.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/policies/hyperliquid.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/policies/moonwell.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/policies/prjx.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/policies/util.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/scripts/__init__.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/strategies/__init__.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/strategies/basis_trading_strategy/README.md +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/strategies/basis_trading_strategy/__init__.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/strategies/basis_trading_strategy/constants.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/strategies/basis_trading_strategy/examples.json +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/strategies/basis_trading_strategy/types.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/strategies/config.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/strategies/hyperlend_stable_yield_strategy/examples.json +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/strategies/moonwell_wsteth_loop_strategy/examples.json +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/strategies/stablecoin_yield_strategy/examples.json +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/templates/adapter/adapter.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/templates/adapter/examples.json +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/templates/adapter/test_adapter.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/templates/strategy/examples.json +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/templates/strategy/strategy.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/tests/__init__.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/tests/test_smoke_manifest.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/tests/test_test_coverage.py +0 -0
- {wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/tests/test_utils.py +0 -0
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: wayfinder-paths
|
|
3
|
+
Version: 0.1.14
|
|
4
|
+
Summary: Wayfinder Path: strategies and adapters
|
|
5
|
+
Author: Wayfinder
|
|
6
|
+
Author-email: dev@wayfinder.ai
|
|
7
|
+
Requires-Python: >=3.12,<4.0
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
10
|
+
Requires-Dist: aiohttp (>=3.13.0,<4.0.0)
|
|
11
|
+
Requires-Dist: eth-account (>=0.13.7,<0.14.0)
|
|
12
|
+
Requires-Dist: httpx (>=0.28.1,<0.29.0)
|
|
13
|
+
Requires-Dist: hyperliquid-python-sdk (>=0.21.0,<0.22.0)
|
|
14
|
+
Requires-Dist: loguru (>=0.7.3,<0.8.0)
|
|
15
|
+
Requires-Dist: numpy (>=1.26.0,<2.0.0)
|
|
16
|
+
Requires-Dist: pandas (>=2.2.0,<3.0.0)
|
|
17
|
+
Requires-Dist: pydantic (>=2.11.9,<3.0.0)
|
|
18
|
+
Requires-Dist: pyyaml (>=6.0.1,<7.0.0)
|
|
19
|
+
Requires-Dist: web3 (>=7.13.0,<8.0.0)
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
|
|
1
22
|
# 🔐 Wayfinder Paths
|
|
2
23
|
|
|
3
24
|
[](https://www.python.org/downloads/)
|
|
@@ -20,7 +41,7 @@ curl -sSL https://install.python-poetry.org | python3 -
|
|
|
20
41
|
poetry install
|
|
21
42
|
|
|
22
43
|
# ⚠️ Generate test wallets FIRST (required!)
|
|
23
|
-
# This creates
|
|
44
|
+
# This creates config.json with a main wallet for local testing
|
|
24
45
|
just create-wallets
|
|
25
46
|
# Or manually: poetry run python wayfinder_paths/scripts/make_wallets.py -n 1
|
|
26
47
|
|
|
@@ -69,8 +90,7 @@ wayfinder_paths/
|
|
|
69
90
|
│ ├── config.example.json # Example configuration
|
|
70
91
|
│ ├── scripts/ # Utility scripts
|
|
71
92
|
│ └── run_strategy.py # Strategy runner script
|
|
72
|
-
├── config.json # Your local config
|
|
73
|
-
├── wallets.json # Generated dev wallets
|
|
93
|
+
├── config.json # Your local config with credentials and wallets
|
|
74
94
|
├── pyproject.toml # Poetry configuration
|
|
75
95
|
└── README.md # This file
|
|
76
96
|
```
|
|
@@ -196,63 +216,28 @@ See [CONFIG_GUIDE.md](wayfinder_paths/CONFIG_GUIDE.md) for details.
|
|
|
196
216
|
|
|
197
217
|
### Authentication
|
|
198
218
|
|
|
199
|
-
Wayfinder Paths
|
|
200
|
-
|
|
201
|
-
#### 1. Service Account Authentication (API Key)
|
|
202
|
-
|
|
203
|
-
For backend services and automated systems with higher rate limits:
|
|
204
|
-
|
|
205
|
-
**Option A: Pass to Strategy Constructor**
|
|
206
|
-
|
|
207
|
-
```python
|
|
208
|
-
from wayfinder_paths.strategies.stablecoin_yield_strategy.strategy import StablecoinYieldStrategy
|
|
209
|
-
|
|
210
|
-
strategy = StablecoinYieldStrategy(
|
|
211
|
-
config={...},
|
|
212
|
-
api_key="sk_live_abc123..." # API key is auto-discovered by all clients
|
|
213
|
-
)
|
|
214
|
-
```
|
|
219
|
+
Wayfinder Paths uses API key authentication via the `X-API-KEY` header.
|
|
215
220
|
|
|
216
|
-
**
|
|
221
|
+
**Add API key to config.json:**
|
|
217
222
|
|
|
218
223
|
```json
|
|
219
224
|
{
|
|
220
|
-
"user": {
|
|
221
|
-
"api_key": "sk_live_abc123..."
|
|
222
|
-
},
|
|
223
225
|
"system": {
|
|
224
|
-
"api_key": "sk_live_abc123..."
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
```
|
|
228
|
-
|
|
229
|
-
**Priority Order:** Constructor parameter > `config.json` (user.api_key or system.api_key)
|
|
230
|
-
|
|
231
|
-
**Note:** API keys in `config.json` are loaded directly by `WayfinderClient` via `_load_config_credentials()`, not through the `UserConfig` or `SystemConfig` dataclasses. This allows flexible credential loading.
|
|
232
|
-
|
|
233
|
-
#### 2. Personal Access Authentication (OAuth)
|
|
234
|
-
|
|
235
|
-
For standalone SDK users with username/password:
|
|
236
|
-
|
|
237
|
-
```json
|
|
238
|
-
{
|
|
239
|
-
"user": {
|
|
240
|
-
"username": "your_username",
|
|
241
|
-
"password": "your_password",
|
|
242
|
-
"refresh_token": null // Optional: use refresh token instead
|
|
226
|
+
"api_key": "sk_live_abc123...",
|
|
227
|
+
"api_base_url": "https://wayfinder.ai/api/v1",
|
|
228
|
+
"wallets_path": "wallets.json"
|
|
243
229
|
}
|
|
244
230
|
}
|
|
245
231
|
```
|
|
246
232
|
|
|
247
233
|
**How It Works:**
|
|
248
234
|
|
|
249
|
-
- API
|
|
250
|
-
-
|
|
251
|
-
-
|
|
252
|
-
-
|
|
253
|
-
- API keys in `config.json` are loaded directly by `WayfinderClient._load_config_credentials()` from `user.api_key` or `system.api_key`, not stored in the `UserConfig` or `SystemConfig` dataclasses
|
|
235
|
+
- API key is automatically loaded from `system.api_key` in config.json
|
|
236
|
+
- The API key is sent as the `X-API-KEY` header on all API requests
|
|
237
|
+
- All clients automatically include the API key header
|
|
238
|
+
- No need to pass API keys explicitly to strategies or clients
|
|
254
239
|
|
|
255
|
-
See [CONFIG_GUIDE.md](wayfinder_paths/CONFIG_GUIDE.md) for detailed
|
|
240
|
+
See [CONFIG_GUIDE.md](wayfinder_paths/CONFIG_GUIDE.md) for detailed configuration documentation.
|
|
256
241
|
|
|
257
242
|
## 🔌 Creating Adapters
|
|
258
243
|
|
|
@@ -279,7 +264,7 @@ class MyAdapter(BaseAdapter):
|
|
|
279
264
|
|
|
280
265
|
async def get_pools(self, pool_ids: list[str]):
|
|
281
266
|
data = await self.pool_client.get_pools_by_ids(
|
|
282
|
-
pool_ids=
|
|
267
|
+
pool_ids=pool_ids
|
|
283
268
|
)
|
|
284
269
|
return (True, data)
|
|
285
270
|
```
|
|
@@ -320,7 +305,7 @@ class MyStrategy(Strategy):
|
|
|
320
305
|
return (False, "Nothing to deposit")
|
|
321
306
|
|
|
322
307
|
success, _ = await self.balance_adapter.get_balance(
|
|
323
|
-
|
|
308
|
+
query=self.config.get("token_id"),
|
|
324
309
|
wallet_address=self.config.get("main_wallet", {}).get("address"),
|
|
325
310
|
)
|
|
326
311
|
if not success:
|
|
@@ -337,7 +322,7 @@ class MyStrategy(Strategy):
|
|
|
337
322
|
async def _status(self) -> StatusDict:
|
|
338
323
|
"""Report balances back to the runner"""
|
|
339
324
|
success, balance = await self.balance_adapter.get_balance(
|
|
340
|
-
|
|
325
|
+
query=self.config.get("token_id"),
|
|
341
326
|
wallet_address=self.config.get("strategy_wallet", {}).get("address"),
|
|
342
327
|
)
|
|
343
328
|
return {
|
|
@@ -468,7 +453,7 @@ poetry run python wayfinder_paths/run_strategy.py stablecoin_yield_strategy --de
|
|
|
468
453
|
|
|
469
454
|
### Wallet Generation for Testing
|
|
470
455
|
|
|
471
|
-
**Before running any strategies, generate test wallets.** This creates `
|
|
456
|
+
**Before running any strategies, generate test wallets.** This creates `config.json` in the repository root with throwaway wallets for local testing:
|
|
472
457
|
|
|
473
458
|
```bash
|
|
474
459
|
# Essential: Create main wallet for testing
|
|
@@ -478,8 +463,8 @@ just create-wallets
|
|
|
478
463
|
|
|
479
464
|
This creates:
|
|
480
465
|
|
|
481
|
-
- `main` wallet - your main wallet for testing (labeled "main" in
|
|
482
|
-
- `
|
|
466
|
+
- `main` wallet - your main wallet for testing (labeled "main" in config.json)
|
|
467
|
+
- `config.json` - wallet addresses and private keys for local testing
|
|
483
468
|
|
|
484
469
|
**Note:** Strategy-specific wallets are automatically created when you use `just create-strategy "Strategy Name"`. For manual creation, use `just create-wallet "strategy_name"` or `poetry run python wayfinder_paths/scripts/make_wallets.py --label "strategy_name"`.
|
|
485
470
|
|
|
@@ -515,9 +500,9 @@ cp wayfinder_paths/config.example.json config.json
|
|
|
515
500
|
# - user.username: Your Wayfinder username
|
|
516
501
|
# - user.password: Your Wayfinder password
|
|
517
502
|
# - OR user.refresh_token: Your refresh token
|
|
518
|
-
# - system.wallets_path: Path to
|
|
503
|
+
# - system.wallets_path: Path to config.json (default: "config.json")
|
|
519
504
|
#
|
|
520
|
-
# Wallet addresses are auto-loaded from
|
|
505
|
+
# Wallet addresses are auto-loaded from config.json by default.
|
|
521
506
|
# Then run with:
|
|
522
507
|
poetry run python wayfinder_paths/run_strategy.py stablecoin_yield_strategy --config config.json
|
|
523
508
|
```
|
|
@@ -642,3 +627,4 @@ Need help or want to discuss strategies? Join our [Discord](https://discord.gg/f
|
|
|
642
627
|
MIT License - see [LICENSE](LICENSE) file for details
|
|
643
628
|
|
|
644
629
|
🚀 **Happy Wayfinding!**
|
|
630
|
+
|
|
@@ -1,26 +1,3 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: wayfinder-paths
|
|
3
|
-
Version: 0.1.11
|
|
4
|
-
Summary: Wayfinder Path: strategies and adapters
|
|
5
|
-
Author: Wayfinder
|
|
6
|
-
Author-email: dev@wayfinder.ai
|
|
7
|
-
Requires-Python: >=3.12,<4.0
|
|
8
|
-
Classifier: Programming Language :: Python :: 3
|
|
9
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
10
|
-
Requires-Dist: aiohttp (>=3.13.0,<4.0.0)
|
|
11
|
-
Requires-Dist: eth-account (>=0.13.7,<0.14.0)
|
|
12
|
-
Requires-Dist: httpx (>=0.28.1,<0.29.0)
|
|
13
|
-
Requires-Dist: hyperliquid-python-sdk (>=0.21.0,<0.22.0)
|
|
14
|
-
Requires-Dist: loguru (>=0.7.3,<0.8.0)
|
|
15
|
-
Requires-Dist: numpy (>=1.26.0,<2.0.0)
|
|
16
|
-
Requires-Dist: pandas (>=2.2.0,<3.0.0)
|
|
17
|
-
Requires-Dist: pydantic (>=2.11.9,<3.0.0)
|
|
18
|
-
Requires-Dist: pydantic-settings (>=2.7.0,<3.0.0)
|
|
19
|
-
Requires-Dist: python-dotenv (>=1.1.1,<2.0.0)
|
|
20
|
-
Requires-Dist: pyyaml (>=6.0.1,<7.0.0)
|
|
21
|
-
Requires-Dist: web3 (>=7.13.0,<8.0.0)
|
|
22
|
-
Description-Content-Type: text/markdown
|
|
23
|
-
|
|
24
1
|
# 🔐 Wayfinder Paths
|
|
25
2
|
|
|
26
3
|
[](https://www.python.org/downloads/)
|
|
@@ -43,7 +20,7 @@ curl -sSL https://install.python-poetry.org | python3 -
|
|
|
43
20
|
poetry install
|
|
44
21
|
|
|
45
22
|
# ⚠️ Generate test wallets FIRST (required!)
|
|
46
|
-
# This creates
|
|
23
|
+
# This creates config.json with a main wallet for local testing
|
|
47
24
|
just create-wallets
|
|
48
25
|
# Or manually: poetry run python wayfinder_paths/scripts/make_wallets.py -n 1
|
|
49
26
|
|
|
@@ -92,8 +69,7 @@ wayfinder_paths/
|
|
|
92
69
|
│ ├── config.example.json # Example configuration
|
|
93
70
|
│ ├── scripts/ # Utility scripts
|
|
94
71
|
│ └── run_strategy.py # Strategy runner script
|
|
95
|
-
├── config.json # Your local config
|
|
96
|
-
├── wallets.json # Generated dev wallets
|
|
72
|
+
├── config.json # Your local config with credentials and wallets
|
|
97
73
|
├── pyproject.toml # Poetry configuration
|
|
98
74
|
└── README.md # This file
|
|
99
75
|
```
|
|
@@ -219,63 +195,28 @@ See [CONFIG_GUIDE.md](wayfinder_paths/CONFIG_GUIDE.md) for details.
|
|
|
219
195
|
|
|
220
196
|
### Authentication
|
|
221
197
|
|
|
222
|
-
Wayfinder Paths
|
|
223
|
-
|
|
224
|
-
#### 1. Service Account Authentication (API Key)
|
|
225
|
-
|
|
226
|
-
For backend services and automated systems with higher rate limits:
|
|
227
|
-
|
|
228
|
-
**Option A: Pass to Strategy Constructor**
|
|
229
|
-
|
|
230
|
-
```python
|
|
231
|
-
from wayfinder_paths.strategies.stablecoin_yield_strategy.strategy import StablecoinYieldStrategy
|
|
232
|
-
|
|
233
|
-
strategy = StablecoinYieldStrategy(
|
|
234
|
-
config={...},
|
|
235
|
-
api_key="sk_live_abc123..." # API key is auto-discovered by all clients
|
|
236
|
-
)
|
|
237
|
-
```
|
|
198
|
+
Wayfinder Paths uses API key authentication via the `X-API-KEY` header.
|
|
238
199
|
|
|
239
|
-
**
|
|
200
|
+
**Add API key to config.json:**
|
|
240
201
|
|
|
241
202
|
```json
|
|
242
203
|
{
|
|
243
|
-
"user": {
|
|
244
|
-
"api_key": "sk_live_abc123..."
|
|
245
|
-
},
|
|
246
204
|
"system": {
|
|
247
|
-
"api_key": "sk_live_abc123..."
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
```
|
|
251
|
-
|
|
252
|
-
**Priority Order:** Constructor parameter > `config.json` (user.api_key or system.api_key)
|
|
253
|
-
|
|
254
|
-
**Note:** API keys in `config.json` are loaded directly by `WayfinderClient` via `_load_config_credentials()`, not through the `UserConfig` or `SystemConfig` dataclasses. This allows flexible credential loading.
|
|
255
|
-
|
|
256
|
-
#### 2. Personal Access Authentication (OAuth)
|
|
257
|
-
|
|
258
|
-
For standalone SDK users with username/password:
|
|
259
|
-
|
|
260
|
-
```json
|
|
261
|
-
{
|
|
262
|
-
"user": {
|
|
263
|
-
"username": "your_username",
|
|
264
|
-
"password": "your_password",
|
|
265
|
-
"refresh_token": null // Optional: use refresh token instead
|
|
205
|
+
"api_key": "sk_live_abc123...",
|
|
206
|
+
"api_base_url": "https://wayfinder.ai/api/v1",
|
|
207
|
+
"wallets_path": "wallets.json"
|
|
266
208
|
}
|
|
267
209
|
}
|
|
268
210
|
```
|
|
269
211
|
|
|
270
212
|
**How It Works:**
|
|
271
213
|
|
|
272
|
-
- API
|
|
273
|
-
-
|
|
274
|
-
-
|
|
275
|
-
-
|
|
276
|
-
- API keys in `config.json` are loaded directly by `WayfinderClient._load_config_credentials()` from `user.api_key` or `system.api_key`, not stored in the `UserConfig` or `SystemConfig` dataclasses
|
|
214
|
+
- API key is automatically loaded from `system.api_key` in config.json
|
|
215
|
+
- The API key is sent as the `X-API-KEY` header on all API requests
|
|
216
|
+
- All clients automatically include the API key header
|
|
217
|
+
- No need to pass API keys explicitly to strategies or clients
|
|
277
218
|
|
|
278
|
-
See [CONFIG_GUIDE.md](wayfinder_paths/CONFIG_GUIDE.md) for detailed
|
|
219
|
+
See [CONFIG_GUIDE.md](wayfinder_paths/CONFIG_GUIDE.md) for detailed configuration documentation.
|
|
279
220
|
|
|
280
221
|
## 🔌 Creating Adapters
|
|
281
222
|
|
|
@@ -302,7 +243,7 @@ class MyAdapter(BaseAdapter):
|
|
|
302
243
|
|
|
303
244
|
async def get_pools(self, pool_ids: list[str]):
|
|
304
245
|
data = await self.pool_client.get_pools_by_ids(
|
|
305
|
-
pool_ids=
|
|
246
|
+
pool_ids=pool_ids
|
|
306
247
|
)
|
|
307
248
|
return (True, data)
|
|
308
249
|
```
|
|
@@ -343,7 +284,7 @@ class MyStrategy(Strategy):
|
|
|
343
284
|
return (False, "Nothing to deposit")
|
|
344
285
|
|
|
345
286
|
success, _ = await self.balance_adapter.get_balance(
|
|
346
|
-
|
|
287
|
+
query=self.config.get("token_id"),
|
|
347
288
|
wallet_address=self.config.get("main_wallet", {}).get("address"),
|
|
348
289
|
)
|
|
349
290
|
if not success:
|
|
@@ -360,7 +301,7 @@ class MyStrategy(Strategy):
|
|
|
360
301
|
async def _status(self) -> StatusDict:
|
|
361
302
|
"""Report balances back to the runner"""
|
|
362
303
|
success, balance = await self.balance_adapter.get_balance(
|
|
363
|
-
|
|
304
|
+
query=self.config.get("token_id"),
|
|
364
305
|
wallet_address=self.config.get("strategy_wallet", {}).get("address"),
|
|
365
306
|
)
|
|
366
307
|
return {
|
|
@@ -491,7 +432,7 @@ poetry run python wayfinder_paths/run_strategy.py stablecoin_yield_strategy --de
|
|
|
491
432
|
|
|
492
433
|
### Wallet Generation for Testing
|
|
493
434
|
|
|
494
|
-
**Before running any strategies, generate test wallets.** This creates `
|
|
435
|
+
**Before running any strategies, generate test wallets.** This creates `config.json` in the repository root with throwaway wallets for local testing:
|
|
495
436
|
|
|
496
437
|
```bash
|
|
497
438
|
# Essential: Create main wallet for testing
|
|
@@ -501,8 +442,8 @@ just create-wallets
|
|
|
501
442
|
|
|
502
443
|
This creates:
|
|
503
444
|
|
|
504
|
-
- `main` wallet - your main wallet for testing (labeled "main" in
|
|
505
|
-
- `
|
|
445
|
+
- `main` wallet - your main wallet for testing (labeled "main" in config.json)
|
|
446
|
+
- `config.json` - wallet addresses and private keys for local testing
|
|
506
447
|
|
|
507
448
|
**Note:** Strategy-specific wallets are automatically created when you use `just create-strategy "Strategy Name"`. For manual creation, use `just create-wallet "strategy_name"` or `poetry run python wayfinder_paths/scripts/make_wallets.py --label "strategy_name"`.
|
|
508
449
|
|
|
@@ -538,9 +479,9 @@ cp wayfinder_paths/config.example.json config.json
|
|
|
538
479
|
# - user.username: Your Wayfinder username
|
|
539
480
|
# - user.password: Your Wayfinder password
|
|
540
481
|
# - OR user.refresh_token: Your refresh token
|
|
541
|
-
# - system.wallets_path: Path to
|
|
482
|
+
# - system.wallets_path: Path to config.json (default: "config.json")
|
|
542
483
|
#
|
|
543
|
-
# Wallet addresses are auto-loaded from
|
|
484
|
+
# Wallet addresses are auto-loaded from config.json by default.
|
|
544
485
|
# Then run with:
|
|
545
486
|
poetry run python wayfinder_paths/run_strategy.py stablecoin_yield_strategy --config config.json
|
|
546
487
|
```
|
|
@@ -665,4 +606,3 @@ Need help or want to discuss strategies? Join our [Discord](https://discord.gg/f
|
|
|
665
606
|
MIT License - see [LICENSE](LICENSE) file for details
|
|
666
607
|
|
|
667
608
|
🚀 **Happy Wayfinding!**
|
|
668
|
-
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "wayfinder-paths"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.14"
|
|
4
4
|
description = "Wayfinder Path: strategies and adapters"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = ["Wayfinder <dev@wayfinder.ai>"]
|
|
@@ -14,10 +14,8 @@ loguru = "^0.7.3"
|
|
|
14
14
|
httpx = "^0.28.1"
|
|
15
15
|
pyyaml = "^6.0.1"
|
|
16
16
|
pydantic = "^2.11.9"
|
|
17
|
-
pydantic-settings = "^2.7.0"
|
|
18
17
|
web3 = "^7.13.0"
|
|
19
18
|
eth-account = "^0.13.7"
|
|
20
|
-
python-dotenv = "^1.1.1"
|
|
21
19
|
aiohttp = "^3.13.0"
|
|
22
20
|
numpy = "^1.26.0"
|
|
23
21
|
pandas = "^2.2.0"
|
|
@@ -34,6 +32,7 @@ ruff = "^0.13.2"
|
|
|
34
32
|
bandit = "^1.7.5"
|
|
35
33
|
safety = "^2.3.5"
|
|
36
34
|
twine = "^6.2.0"
|
|
35
|
+
vulture = "^2.14"
|
|
37
36
|
|
|
38
37
|
[tool.ruff]
|
|
39
38
|
target-version = "py312"
|
{wayfinder_paths-0.1.11 → wayfinder_paths-0.1.14}/wayfinder_paths/adapters/balance_adapter/README.md
RENAMED
|
@@ -23,24 +23,23 @@ balance = BalanceAdapter(config, web3_service=web3_service)
|
|
|
23
23
|
|
|
24
24
|
## API surface
|
|
25
25
|
|
|
26
|
-
### `get_balance(
|
|
27
|
-
Returns the raw balance (as an integer) for a specific token on a wallet.
|
|
26
|
+
### `get_balance(*, query: str | dict, wallet_address: str, chain_id: int | None = None)`
|
|
27
|
+
Returns the raw balance (as an integer) for a specific token or pool on a wallet.
|
|
28
|
+
|
|
29
|
+
`query`: token_id/address string or a dict with a `"token_id"` key. When `query` is a token identifier (e.g. `"usd-coin-base"`), `chain_id` is auto-resolved from token info; when it is a pool address, `chain_id` must be provided.
|
|
28
30
|
|
|
29
31
|
```python
|
|
32
|
+
# Token balance (chain_id auto-resolved)
|
|
30
33
|
success, balance = await balance.get_balance(
|
|
31
|
-
|
|
34
|
+
query="usd-coin-base",
|
|
32
35
|
wallet_address=config["main_wallet"]["address"],
|
|
33
36
|
)
|
|
34
|
-
```
|
|
35
37
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
success, amount = await balance.get_pool_balance(
|
|
41
|
-
pool_address="0xPool",
|
|
38
|
+
# Pool balance (chain_id required)
|
|
39
|
+
success, pool_balance = await balance.get_balance(
|
|
40
|
+
query="0xPool...",
|
|
41
|
+
wallet_address=config["strategy_wallet"]["address"],
|
|
42
42
|
chain_id=8453,
|
|
43
|
-
user_address=config["strategy_wallet"]["address"],
|
|
44
43
|
)
|
|
45
44
|
```
|
|
46
45
|
|
|
@@ -80,10 +79,10 @@ class MyStrategy(Strategy):
|
|
|
80
79
|
self.balance_adapter = balance_adapter
|
|
81
80
|
|
|
82
81
|
async def _status(self):
|
|
83
|
-
success, pool_balance = await self.balance_adapter.
|
|
84
|
-
|
|
82
|
+
success, pool_balance = await self.balance_adapter.get_balance(
|
|
83
|
+
query=self.current_pool["address"],
|
|
84
|
+
wallet_address=self.config["strategy_wallet"]["address"],
|
|
85
85
|
chain_id=self.current_pool["chain"]["id"],
|
|
86
|
-
user_address=self.config["strategy_wallet"]["address"],
|
|
87
86
|
)
|
|
88
87
|
return {"portfolio_value": float(pool_balance or 0), ...}
|
|
89
88
|
```
|
|
@@ -7,7 +7,6 @@ from wayfinder_paths.core.clients.TokenClient import TokenClient
|
|
|
7
7
|
from wayfinder_paths.core.clients.WalletClient import WalletClient
|
|
8
8
|
from wayfinder_paths.core.constants.base import DEFAULT_TRANSACTION_TIMEOUT
|
|
9
9
|
from wayfinder_paths.core.services.base import Web3Service
|
|
10
|
-
from wayfinder_paths.core.settings import settings
|
|
11
10
|
from wayfinder_paths.core.utils.evm_helpers import resolve_chain_id
|
|
12
11
|
|
|
13
12
|
|
|
@@ -43,16 +42,39 @@ class BalanceAdapter(BaseAdapter):
|
|
|
43
42
|
async def get_balance(
|
|
44
43
|
self,
|
|
45
44
|
*,
|
|
46
|
-
|
|
45
|
+
query: str | dict[str, Any],
|
|
47
46
|
wallet_address: str,
|
|
47
|
+
chain_id: int | None = None,
|
|
48
48
|
) -> tuple[bool, str | int]:
|
|
49
|
-
"""Get token balance for a wallet.
|
|
49
|
+
"""Get token or pool balance for a wallet.
|
|
50
|
+
|
|
51
|
+
query: token_id/address string or a dict with a "token_id" key.
|
|
52
|
+
"""
|
|
53
|
+
resolved = query if isinstance(query, str) else (query or {}).get("token_id")
|
|
54
|
+
if not resolved:
|
|
55
|
+
return (False, "missing query")
|
|
50
56
|
try:
|
|
51
|
-
|
|
52
|
-
|
|
57
|
+
if chain_id is None:
|
|
58
|
+
token_info = await self.token_client.get_token_details(resolved)
|
|
59
|
+
if not token_info:
|
|
60
|
+
return (False, f"Token not found: {resolved}")
|
|
61
|
+
resolved_chain_id = resolve_chain_id(token_info, self.logger)
|
|
62
|
+
if resolved_chain_id is None:
|
|
63
|
+
return (False, f"Token {resolved} is missing a chain id")
|
|
64
|
+
chain_id = resolved_chain_id
|
|
65
|
+
|
|
66
|
+
data = await self.wallet_client.get_token_balance_for_address(
|
|
53
67
|
wallet_address=wallet_address,
|
|
68
|
+
query=resolved,
|
|
69
|
+
chain_id=int(chain_id),
|
|
70
|
+
)
|
|
71
|
+
# Use _parse_balance for consistent parsing (handles balance_raw or balance)
|
|
72
|
+
raw = (
|
|
73
|
+
data.get("balance_raw") or data.get("balance")
|
|
74
|
+
if isinstance(data, dict)
|
|
75
|
+
else None
|
|
54
76
|
)
|
|
55
|
-
return (True,
|
|
77
|
+
return (True, self._parse_balance(raw))
|
|
56
78
|
except Exception as e:
|
|
57
79
|
return (False, str(e))
|
|
58
80
|
|
|
@@ -129,12 +151,9 @@ class BalanceAdapter(BaseAdapter):
|
|
|
129
151
|
return False, tx_data
|
|
130
152
|
|
|
131
153
|
tx = tx_data
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
broadcast_result = await self.wallet_provider.broadcast_transaction(
|
|
136
|
-
tx, wait_for_receipt=True, timeout=DEFAULT_TRANSACTION_TIMEOUT
|
|
137
|
-
)
|
|
154
|
+
broadcast_result = await self.wallet_provider.broadcast_transaction(
|
|
155
|
+
tx, wait_for_receipt=True, timeout=DEFAULT_TRANSACTION_TIMEOUT
|
|
156
|
+
)
|
|
138
157
|
|
|
139
158
|
if broadcast_result[0] and not skip_ledger and ledger_method is not None:
|
|
140
159
|
wallet_for_ledger = from_address if ledger_wallet == "from" else to_address
|
|
@@ -163,6 +182,7 @@ class BalanceAdapter(BaseAdapter):
|
|
|
163
182
|
|
|
164
183
|
usd_value = await self._token_amount_usd(token_info, amount)
|
|
165
184
|
try:
|
|
185
|
+
token_id = token_info.get("token_id") or token_info.get("id")
|
|
166
186
|
success, response = await ledger_method(
|
|
167
187
|
wallet_address=wallet_address,
|
|
168
188
|
chain_id=chain_id,
|
|
@@ -170,7 +190,7 @@ class BalanceAdapter(BaseAdapter):
|
|
|
170
190
|
token_amount=str(amount),
|
|
171
191
|
usd_value=usd_value,
|
|
172
192
|
data={
|
|
173
|
-
"token_id":
|
|
193
|
+
"token_id": token_id,
|
|
174
194
|
"amount": str(amount),
|
|
175
195
|
"usd_value": usd_value,
|
|
176
196
|
},
|
|
@@ -180,15 +200,16 @@ class BalanceAdapter(BaseAdapter):
|
|
|
180
200
|
self.logger.warning(
|
|
181
201
|
"Ledger entry failed",
|
|
182
202
|
wallet=wallet_address,
|
|
183
|
-
token_id=
|
|
203
|
+
token_id=token_id,
|
|
184
204
|
amount=amount,
|
|
185
205
|
error=response,
|
|
186
206
|
)
|
|
187
207
|
except Exception as exc: # noqa: BLE001
|
|
208
|
+
token_id = token_info.get("token_id") or token_info.get("id")
|
|
188
209
|
self.logger.warning(
|
|
189
210
|
f"Ledger entry raised: {exc}",
|
|
190
211
|
wallet=wallet_address,
|
|
191
|
-
token_id=
|
|
212
|
+
token_id=token_id,
|
|
192
213
|
)
|
|
193
214
|
|
|
194
215
|
async def _token_amount_usd(
|
|
@@ -212,27 +233,3 @@ class BalanceAdapter(BaseAdapter):
|
|
|
212
233
|
if isinstance(evm_wallet, dict):
|
|
213
234
|
return evm_wallet.get("address")
|
|
214
235
|
return None
|
|
215
|
-
|
|
216
|
-
async def get_pool_balance(
|
|
217
|
-
self,
|
|
218
|
-
*,
|
|
219
|
-
pool_address: str,
|
|
220
|
-
chain_id: int,
|
|
221
|
-
user_address: str,
|
|
222
|
-
) -> tuple[bool, Any]:
|
|
223
|
-
"""Get pool balance for a wallet."""
|
|
224
|
-
try:
|
|
225
|
-
data = await self.wallet_client.get_pool_balance_for_wallet(
|
|
226
|
-
pool_address=pool_address,
|
|
227
|
-
chain_id=chain_id,
|
|
228
|
-
user_address=user_address,
|
|
229
|
-
human_readable=False,
|
|
230
|
-
)
|
|
231
|
-
raw = (
|
|
232
|
-
data.get("balance_raw") or data.get("balance")
|
|
233
|
-
if isinstance(data, dict)
|
|
234
|
-
else None
|
|
235
|
-
)
|
|
236
|
-
return (True, self._parse_balance(raw))
|
|
237
|
-
except Exception as e:
|
|
238
|
-
return (False, str(e))
|