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.

Files changed (149) hide show
  1. wayfinder_paths/CONFIG_GUIDE.md +399 -0
  2. wayfinder_paths/__init__.py +22 -0
  3. wayfinder_paths/abis/generic/erc20.json +383 -0
  4. wayfinder_paths/adapters/__init__.py +0 -0
  5. wayfinder_paths/adapters/balance_adapter/README.md +94 -0
  6. wayfinder_paths/adapters/balance_adapter/adapter.py +238 -0
  7. wayfinder_paths/adapters/balance_adapter/examples.json +6 -0
  8. wayfinder_paths/adapters/balance_adapter/manifest.yaml +8 -0
  9. wayfinder_paths/adapters/balance_adapter/test_adapter.py +59 -0
  10. wayfinder_paths/adapters/brap_adapter/README.md +249 -0
  11. wayfinder_paths/adapters/brap_adapter/__init__.py +7 -0
  12. wayfinder_paths/adapters/brap_adapter/adapter.py +726 -0
  13. wayfinder_paths/adapters/brap_adapter/examples.json +175 -0
  14. wayfinder_paths/adapters/brap_adapter/manifest.yaml +11 -0
  15. wayfinder_paths/adapters/brap_adapter/test_adapter.py +286 -0
  16. wayfinder_paths/adapters/hyperlend_adapter/__init__.py +7 -0
  17. wayfinder_paths/adapters/hyperlend_adapter/adapter.py +305 -0
  18. wayfinder_paths/adapters/hyperlend_adapter/manifest.yaml +10 -0
  19. wayfinder_paths/adapters/hyperlend_adapter/test_adapter.py +274 -0
  20. wayfinder_paths/adapters/hyperliquid_adapter/__init__.py +18 -0
  21. wayfinder_paths/adapters/hyperliquid_adapter/adapter.py +1093 -0
  22. wayfinder_paths/adapters/hyperliquid_adapter/executor.py +549 -0
  23. wayfinder_paths/adapters/hyperliquid_adapter/manifest.yaml +8 -0
  24. wayfinder_paths/adapters/hyperliquid_adapter/paired_filler.py +1050 -0
  25. wayfinder_paths/adapters/hyperliquid_adapter/test_adapter.py +126 -0
  26. wayfinder_paths/adapters/hyperliquid_adapter/test_adapter_live.py +219 -0
  27. wayfinder_paths/adapters/hyperliquid_adapter/test_utils.py +220 -0
  28. wayfinder_paths/adapters/hyperliquid_adapter/utils.py +134 -0
  29. wayfinder_paths/adapters/ledger_adapter/README.md +145 -0
  30. wayfinder_paths/adapters/ledger_adapter/__init__.py +7 -0
  31. wayfinder_paths/adapters/ledger_adapter/adapter.py +289 -0
  32. wayfinder_paths/adapters/ledger_adapter/examples.json +137 -0
  33. wayfinder_paths/adapters/ledger_adapter/manifest.yaml +11 -0
  34. wayfinder_paths/adapters/ledger_adapter/test_adapter.py +205 -0
  35. wayfinder_paths/adapters/pool_adapter/README.md +206 -0
  36. wayfinder_paths/adapters/pool_adapter/__init__.py +7 -0
  37. wayfinder_paths/adapters/pool_adapter/adapter.py +282 -0
  38. wayfinder_paths/adapters/pool_adapter/examples.json +143 -0
  39. wayfinder_paths/adapters/pool_adapter/manifest.yaml +10 -0
  40. wayfinder_paths/adapters/pool_adapter/test_adapter.py +220 -0
  41. wayfinder_paths/adapters/token_adapter/README.md +101 -0
  42. wayfinder_paths/adapters/token_adapter/__init__.py +3 -0
  43. wayfinder_paths/adapters/token_adapter/adapter.py +96 -0
  44. wayfinder_paths/adapters/token_adapter/examples.json +26 -0
  45. wayfinder_paths/adapters/token_adapter/manifest.yaml +6 -0
  46. wayfinder_paths/adapters/token_adapter/test_adapter.py +125 -0
  47. wayfinder_paths/config.example.json +22 -0
  48. wayfinder_paths/conftest.py +31 -0
  49. wayfinder_paths/core/__init__.py +18 -0
  50. wayfinder_paths/core/adapters/BaseAdapter.py +65 -0
  51. wayfinder_paths/core/adapters/__init__.py +5 -0
  52. wayfinder_paths/core/adapters/base.py +5 -0
  53. wayfinder_paths/core/adapters/models.py +46 -0
  54. wayfinder_paths/core/analytics/__init__.py +11 -0
  55. wayfinder_paths/core/analytics/bootstrap.py +57 -0
  56. wayfinder_paths/core/analytics/stats.py +48 -0
  57. wayfinder_paths/core/analytics/test_analytics.py +170 -0
  58. wayfinder_paths/core/clients/AuthClient.py +83 -0
  59. wayfinder_paths/core/clients/BRAPClient.py +109 -0
  60. wayfinder_paths/core/clients/ClientManager.py +210 -0
  61. wayfinder_paths/core/clients/HyperlendClient.py +192 -0
  62. wayfinder_paths/core/clients/LedgerClient.py +443 -0
  63. wayfinder_paths/core/clients/PoolClient.py +128 -0
  64. wayfinder_paths/core/clients/SimulationClient.py +192 -0
  65. wayfinder_paths/core/clients/TokenClient.py +89 -0
  66. wayfinder_paths/core/clients/TransactionClient.py +63 -0
  67. wayfinder_paths/core/clients/WalletClient.py +94 -0
  68. wayfinder_paths/core/clients/WayfinderClient.py +269 -0
  69. wayfinder_paths/core/clients/__init__.py +48 -0
  70. wayfinder_paths/core/clients/protocols.py +392 -0
  71. wayfinder_paths/core/clients/sdk_example.py +110 -0
  72. wayfinder_paths/core/config.py +458 -0
  73. wayfinder_paths/core/constants/__init__.py +26 -0
  74. wayfinder_paths/core/constants/base.py +42 -0
  75. wayfinder_paths/core/constants/erc20_abi.py +118 -0
  76. wayfinder_paths/core/constants/hyperlend_abi.py +152 -0
  77. wayfinder_paths/core/engine/StrategyJob.py +188 -0
  78. wayfinder_paths/core/engine/__init__.py +5 -0
  79. wayfinder_paths/core/engine/manifest.py +97 -0
  80. wayfinder_paths/core/services/__init__.py +0 -0
  81. wayfinder_paths/core/services/base.py +179 -0
  82. wayfinder_paths/core/services/local_evm_txn.py +430 -0
  83. wayfinder_paths/core/services/local_token_txn.py +231 -0
  84. wayfinder_paths/core/services/web3_service.py +45 -0
  85. wayfinder_paths/core/settings.py +61 -0
  86. wayfinder_paths/core/strategies/Strategy.py +280 -0
  87. wayfinder_paths/core/strategies/__init__.py +5 -0
  88. wayfinder_paths/core/strategies/base.py +7 -0
  89. wayfinder_paths/core/strategies/descriptors.py +81 -0
  90. wayfinder_paths/core/utils/__init__.py +1 -0
  91. wayfinder_paths/core/utils/evm_helpers.py +206 -0
  92. wayfinder_paths/core/utils/wallets.py +77 -0
  93. wayfinder_paths/core/wallets/README.md +91 -0
  94. wayfinder_paths/core/wallets/WalletManager.py +56 -0
  95. wayfinder_paths/core/wallets/__init__.py +7 -0
  96. wayfinder_paths/policies/enso.py +17 -0
  97. wayfinder_paths/policies/erc20.py +34 -0
  98. wayfinder_paths/policies/evm.py +21 -0
  99. wayfinder_paths/policies/hyper_evm.py +19 -0
  100. wayfinder_paths/policies/hyperlend.py +12 -0
  101. wayfinder_paths/policies/hyperliquid.py +30 -0
  102. wayfinder_paths/policies/moonwell.py +54 -0
  103. wayfinder_paths/policies/prjx.py +30 -0
  104. wayfinder_paths/policies/util.py +27 -0
  105. wayfinder_paths/run_strategy.py +411 -0
  106. wayfinder_paths/scripts/__init__.py +0 -0
  107. wayfinder_paths/scripts/create_strategy.py +181 -0
  108. wayfinder_paths/scripts/make_wallets.py +169 -0
  109. wayfinder_paths/scripts/run_strategy.py +124 -0
  110. wayfinder_paths/scripts/validate_manifests.py +213 -0
  111. wayfinder_paths/strategies/__init__.py +0 -0
  112. wayfinder_paths/strategies/basis_trading_strategy/README.md +213 -0
  113. wayfinder_paths/strategies/basis_trading_strategy/__init__.py +3 -0
  114. wayfinder_paths/strategies/basis_trading_strategy/constants.py +1 -0
  115. wayfinder_paths/strategies/basis_trading_strategy/examples.json +16 -0
  116. wayfinder_paths/strategies/basis_trading_strategy/manifest.yaml +23 -0
  117. wayfinder_paths/strategies/basis_trading_strategy/snapshot_mixin.py +1011 -0
  118. wayfinder_paths/strategies/basis_trading_strategy/strategy.py +4522 -0
  119. wayfinder_paths/strategies/basis_trading_strategy/test_strategy.py +727 -0
  120. wayfinder_paths/strategies/basis_trading_strategy/types.py +39 -0
  121. wayfinder_paths/strategies/config.py +85 -0
  122. wayfinder_paths/strategies/hyperlend_stable_yield_strategy/README.md +100 -0
  123. wayfinder_paths/strategies/hyperlend_stable_yield_strategy/examples.json +8 -0
  124. wayfinder_paths/strategies/hyperlend_stable_yield_strategy/manifest.yaml +7 -0
  125. wayfinder_paths/strategies/hyperlend_stable_yield_strategy/strategy.py +2270 -0
  126. wayfinder_paths/strategies/hyperlend_stable_yield_strategy/test_strategy.py +352 -0
  127. wayfinder_paths/strategies/stablecoin_yield_strategy/README.md +96 -0
  128. wayfinder_paths/strategies/stablecoin_yield_strategy/examples.json +17 -0
  129. wayfinder_paths/strategies/stablecoin_yield_strategy/manifest.yaml +17 -0
  130. wayfinder_paths/strategies/stablecoin_yield_strategy/strategy.py +1810 -0
  131. wayfinder_paths/strategies/stablecoin_yield_strategy/test_strategy.py +520 -0
  132. wayfinder_paths/templates/adapter/README.md +105 -0
  133. wayfinder_paths/templates/adapter/adapter.py +26 -0
  134. wayfinder_paths/templates/adapter/examples.json +8 -0
  135. wayfinder_paths/templates/adapter/manifest.yaml +6 -0
  136. wayfinder_paths/templates/adapter/test_adapter.py +49 -0
  137. wayfinder_paths/templates/strategy/README.md +153 -0
  138. wayfinder_paths/templates/strategy/examples.json +11 -0
  139. wayfinder_paths/templates/strategy/manifest.yaml +8 -0
  140. wayfinder_paths/templates/strategy/strategy.py +57 -0
  141. wayfinder_paths/templates/strategy/test_strategy.py +197 -0
  142. wayfinder_paths/tests/__init__.py +0 -0
  143. wayfinder_paths/tests/test_smoke_manifest.py +48 -0
  144. wayfinder_paths/tests/test_test_coverage.py +212 -0
  145. wayfinder_paths/tests/test_utils.py +64 -0
  146. wayfinder_paths-0.1.7.dist-info/LICENSE +21 -0
  147. wayfinder_paths-0.1.7.dist-info/METADATA +777 -0
  148. wayfinder_paths-0.1.7.dist-info/RECORD +149 -0
  149. wayfinder_paths-0.1.7.dist-info/WHEEL +4 -0
@@ -0,0 +1,39 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass
4
+ from typing import Any
5
+
6
+
7
+ @dataclass
8
+ class BasisCandidate:
9
+ """Represents a potential basis trading opportunity."""
10
+
11
+ coin: str
12
+ spot_pair: str
13
+ spot_asset_id: int
14
+ perp_asset_id: int
15
+ mark_price: float
16
+ target_leverage: int
17
+ ctx: dict[str, Any]
18
+ spot_book: dict[str, Any]
19
+ open_interest_base: float
20
+ open_interest_usd: float
21
+ day_notional_usd: float
22
+ order_usd: float
23
+ depth_checks: dict[str, dict[str, Any]]
24
+ margin_table_id: int | None = None
25
+
26
+
27
+ @dataclass
28
+ class BasisPosition:
29
+ """Tracks an active basis position."""
30
+
31
+ coin: str
32
+ spot_asset_id: int
33
+ perp_asset_id: int
34
+ spot_amount: float
35
+ perp_amount: float
36
+ entry_price: float
37
+ leverage: int
38
+ entry_timestamp: int
39
+ funding_collected: float = 0.0
@@ -0,0 +1,85 @@
1
+ """
2
+ Configuration for community strategies
3
+ Each strategy can define its own configuration parameters
4
+ """
5
+
6
+ from typing import Any
7
+
8
+ # Funding Rate Strategy Configuration
9
+ FUNDING_RATE_CONFIG = {
10
+ "min_deposit": 30, # USDC
11
+ "lookback_days": 90,
12
+ "confidence": 0.9999,
13
+ "min_open_interest": 50_000,
14
+ "min_daily_volume": 100_000,
15
+ "max_leverage": 3,
16
+ "liquidation_threshold": 0.75,
17
+ "rebalance_threshold": 0.05,
18
+ "hyperliquid_system_address": "0x2Df1c51E09aECF9cacB7bc98cB1742757f163dF7",
19
+ "supported_chains": ["arbitrum"],
20
+ }
21
+
22
+
23
+ # Stablecoin Yield Strategy Configuration
24
+ STABLECOIN_YIELD_CONFIG = {
25
+ "min_deposit": 50, # USDC
26
+ "min_tvl": 1_000_000, # $1M minimum TVL for safety
27
+ "min_apy": 0.01, # 1% minimum APY
28
+ "rebalance_days": 7, # Days until rebalance is profitable
29
+ "search_depth": 10, # Number of pools to evaluate
30
+ "gas_buffer": 0.001, # ETH for gas
31
+ "supported_chains": ["base", "arbitrum"],
32
+ "supported_tokens": ["USDC", "DAI", "USDT"],
33
+ "excluded_protocols": [], # Protocols to avoid
34
+ }
35
+
36
+
37
+ # Moonwell wstETH Loop Strategy Configuration (example for advanced strategies)
38
+ MOONWELL_LOOP_CONFIG = {
39
+ "min_deposit": 200, # USDC
40
+ "max_loops": 30,
41
+ "leverage_limit": 10,
42
+ "contracts": {
43
+ "m_usdc": "0xedc817a28e8b93b03976fbd4a3ddbc9f7d176c22",
44
+ "m_weth": "0x628ff693426583D9a7FB391E54366292F509D457",
45
+ "m_wsteth": "0x627fe393bc6edda28e99ae648fd6ff362514304b",
46
+ "reward_distributor": "0xe9005b078701e2a0948d2eac43010d35870ad9d2",
47
+ "comptroller": "0xfbb21d0380bee3312b33c4353c8936a0f13ef26c",
48
+ },
49
+ "supported_chains": ["base"],
50
+ }
51
+
52
+
53
+ # Global adapter configurations
54
+ ADAPTER_CONFIGS = {
55
+ "hyperliquid": {
56
+ "api_url": "https://api.hyperliquid.xyz",
57
+ "testnet_url": "https://api.hyperliquid-testnet.xyz",
58
+ "rate_limit": 10, # requests per second
59
+ "timeout": 30, # seconds
60
+ "slippage": 0.05, # 5% default slippage for market orders
61
+ },
62
+ "enso": {
63
+ "router_address": "0xF75584eF6673aD213a685a1B58Cc0330B8eA22Cf",
64
+ "supported_chains": ["ethereum", "base", "arbitrum", "polygon"],
65
+ },
66
+ "moonwell": {
67
+ "supported_chains": ["base"],
68
+ "protocol_fee": 0.001, # 0.1%
69
+ },
70
+ }
71
+
72
+
73
+ def get_strategy_config(strategy_name: str) -> dict[str, Any]:
74
+ """Get configuration for a specific strategy"""
75
+ configs = {
76
+ "funding_rate": FUNDING_RATE_CONFIG,
77
+ "stablecoin_yield": STABLECOIN_YIELD_CONFIG,
78
+ "moonwell_loop": MOONWELL_LOOP_CONFIG,
79
+ }
80
+ return configs.get(strategy_name.lower(), {})
81
+
82
+
83
+ def get_adapter_config(adapter_name: str) -> dict[str, Any]:
84
+ """Get configuration for a specific adapter"""
85
+ return ADAPTER_CONFIGS.get(adapter_name.lower(), {})
@@ -0,0 +1,100 @@
1
+ # Hyperlend Stable Yield Strategy
2
+
3
+ - Entrypoint: `strategies.hyperlend_stable_yield_strategy.strategy.HyperlendStableYieldStrategy`
4
+ - Manifest: `manifest.yaml`
5
+ - Examples: `examples.json`
6
+ - Tests: `test_strategy.py`
7
+
8
+ ## What it does
9
+
10
+ Allocates USDT0 on HyperEVM across HyperLend stablecoin markets. The strategy:
11
+
12
+ 1. Pulls USDT0 (plus a configurable HYPE gas buffer) from the main wallet into the strategy wallet.
13
+ 2. Samples HyperLend hourly rate history, applies a bootstrap tournament (horizon = 6h, blocks = 6h, 4,000 trials, 7-day half-life) to estimate which stablecoin should outperform.
14
+ 3. Tops up the small HYPE gas buffer if needed, swaps USDT0 into the target stablecoin, and supplies it to HyperLend.
15
+ 4. Enforces a hysteresis rotation policy so minor APY noise does not churn capital.
16
+
17
+ ## Policy
18
+
19
+ The manifest policy simply locks transactions to the strategy wallet ID:
20
+
21
+ ```
22
+ (wallet.id == 'FORMAT_WALLET_ID')
23
+ ```
24
+
25
+ ## Key parameters
26
+
27
+ - `MIN_USDT0_DEPOSIT_AMOUNT = 1`
28
+ - `GAS_MAXIMUM = 0.1` HYPE (max accepted per deposit)
29
+ - `HORIZON_HOURS = 6`, `BLOCK_LEN = 6`, `TRIALS = 4000`
30
+ - `HYSTERESIS_DWELL_HOURS = 168`, `HYSTERESIS_Z = 1.15`
31
+ - `ROTATION_COOLDOWN = 168 hours`
32
+ - `APY_REBALANCE_THRESHOLD = 0.0035` (35 bps edge required to rotate when not short-circuiting)
33
+ - `MIN_STABLE_SWAP_TOKENS = 1e-3` → dust threshold when sweeping balances
34
+
35
+ ## Adapters used
36
+
37
+ - `BalanceAdapter` for token/pool balances and orchestrating wallet transfers with ledger tracking.
38
+ - `TokenAdapter` for metadata (USDT0, HYPE, wrapping info).
39
+ - `LedgerAdapter` for net deposit + rotation history.
40
+ - `BRAPAdapter` to source quotes/swap stablecoins.
41
+ - `HyperlendAdapter` for asset views, lend/withdraw ops, supply caps.
42
+ - `LocalTokenTxnService` via `DefaultWeb3Service` for low-level sends/approvals leveraged by the adapters.
43
+
44
+ ## Actions
45
+
46
+ ### Deposit
47
+
48
+ - Validates USDT0 and HYPE balances in the main wallet.
49
+ - Transfers HYPE into the strategy wallet when a top-up is required, ensuring the strategy maintains the configured buffer.
50
+ - Moves USDT0 from the main wallet into the strategy wallet through `BalanceAdapter.move_from_main_wallet_to_strategy_wallet`.
51
+ - Clears cached asset snapshots so the next update starts from on-chain reality.
52
+
53
+ ### Update
54
+
55
+ - Refreshes HyperLend asset snapshots, calculates tournament winners, and filters markets that respect supply caps + buffer requirements.
56
+ - Reads rotation history through `LedgerAdapter.get_strategy_latest_transactions` to enforce the cooldown (unless the short-circuit policy is triggered).
57
+ - If a new asset wins the tournament and passes hysteresis checks, BRAP quotes are fetched and executed to rotate into the better performer.
58
+ - Sweeps residual stable balances, lends via `HyperlendAdapter`, and records ledger operations.
59
+
60
+ ### Status
61
+
62
+ `_status()` returns:
63
+
64
+ - `portfolio_value`: active lend balance (converted to float),
65
+ - `net_deposit`: fetched from `LedgerAdapter`,
66
+ - `strategy_status`: includes current lent asset, APY, idle balances, and tournament projections.
67
+
68
+ ### Withdraw
69
+
70
+ - Unwinds existing HyperLend positions, swaps back to USDT0 when necessary, returns USDT0 and residual HYPE to the main wallet via `BalanceAdapter`, and clears cached state.
71
+
72
+ ## Running locally
73
+
74
+ ```bash
75
+ # Install dependencies
76
+ poetry install
77
+
78
+ # Generate main wallet (writes wallets.json)
79
+ # Creates a main wallet (or use 'just create-strategy' which auto-creates wallets)
80
+ poetry run python wayfinder_paths/scripts/make_wallets.py -n 1
81
+
82
+ # Copy config and edit credentials (or rely on env vars)
83
+ cp wayfinder_paths/config.example.json config.json
84
+
85
+ # Check status / health
86
+ poetry run python wayfinder_paths/run_strategy.py hyperlend_stable_yield_strategy --action status --config $(pwd)/config.json
87
+
88
+ # Perform a deposit/update/withdraw cycle
89
+ poetry run python wayfinder_paths/run_strategy.py hyperlend_stable_yield_strategy --action deposit --main-token-amount 25 --gas-token-amount 0.02 --config $(pwd)/config.json
90
+ poetry run python wayfinder_paths/run_strategy.py hyperlend_stable_yield_strategy --action update --config $(pwd)/config.json
91
+ poetry run python wayfinder_paths/run_strategy.py hyperlend_stable_yield_strategy --action withdraw --config $(pwd)/config.json
92
+ ```
93
+
94
+ Use the manifest directly if you prefer:
95
+
96
+ ```bash
97
+ poetry run python wayfinder_paths/run_strategy.py --manifest wayfinder_paths/strategies/hyperlend_stable_yield_strategy/manifest.yaml --action status --config $(pwd)/config.json
98
+ ```
99
+
100
+ Wallet addresses/labels are auto-resolved from `wallets.json`. Set `NETWORK=testnet` in your config to run the orchestration without touching live HyperEVM endpoints.
@@ -0,0 +1,8 @@
1
+ {
2
+ "smoke": {
3
+ "deposit": {},
4
+ "update": {},
5
+ "status": {},
6
+ "withdraw": {}
7
+ }
8
+ }
@@ -0,0 +1,7 @@
1
+ schema_version: "0.1"
2
+ entrypoint: "strategies.hyperlend_stable_yield_strategy.strategy.HyperlendStableYieldStrategy"
3
+ permissions:
4
+ policy: "(wallet.id == 'FORMAT_WALLET_ID')"
5
+ adapters:
6
+ - name: "BALANCE"
7
+ capabilities: ["wallet_read"]