wayfinder-paths 0.1.19__py3-none-any.whl → 0.1.20__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 (98) hide show
  1. wayfinder_paths/__init__.py +0 -2
  2. wayfinder_paths/adapters/balance_adapter/README.md +59 -45
  3. wayfinder_paths/adapters/balance_adapter/adapter.py +0 -21
  4. wayfinder_paths/adapters/balance_adapter/test_adapter.py +0 -14
  5. wayfinder_paths/adapters/brap_adapter/README.md +61 -184
  6. wayfinder_paths/adapters/brap_adapter/__init__.py +0 -4
  7. wayfinder_paths/adapters/brap_adapter/adapter.py +0 -147
  8. wayfinder_paths/adapters/brap_adapter/test_adapter.py +0 -15
  9. wayfinder_paths/adapters/hyperlend_adapter/__init__.py +0 -4
  10. wayfinder_paths/adapters/hyperlend_adapter/adapter.py +0 -9
  11. wayfinder_paths/adapters/hyperlend_adapter/test_adapter.py +0 -17
  12. wayfinder_paths/adapters/hyperliquid_adapter/adapter.py +3 -312
  13. wayfinder_paths/adapters/hyperliquid_adapter/executor.py +1 -71
  14. wayfinder_paths/adapters/hyperliquid_adapter/paired_filler.py +0 -57
  15. wayfinder_paths/adapters/hyperliquid_adapter/test_adapter.py +0 -17
  16. wayfinder_paths/adapters/hyperliquid_adapter/test_adapter_live.py +2 -42
  17. wayfinder_paths/adapters/hyperliquid_adapter/test_executor.py +1 -9
  18. wayfinder_paths/adapters/hyperliquid_adapter/test_utils.py +15 -47
  19. wayfinder_paths/adapters/hyperliquid_adapter/utils.py +0 -7
  20. wayfinder_paths/adapters/ledger_adapter/README.md +54 -74
  21. wayfinder_paths/adapters/ledger_adapter/__init__.py +0 -4
  22. wayfinder_paths/adapters/ledger_adapter/adapter.py +0 -106
  23. wayfinder_paths/adapters/ledger_adapter/test_adapter.py +0 -12
  24. wayfinder_paths/adapters/moonwell_adapter/README.md +67 -106
  25. wayfinder_paths/adapters/moonwell_adapter/__init__.py +0 -4
  26. wayfinder_paths/adapters/moonwell_adapter/adapter.py +9 -121
  27. wayfinder_paths/adapters/moonwell_adapter/test_adapter.py +84 -83
  28. wayfinder_paths/adapters/pool_adapter/README.md +30 -51
  29. wayfinder_paths/adapters/pool_adapter/__init__.py +0 -4
  30. wayfinder_paths/adapters/pool_adapter/adapter.py +0 -19
  31. wayfinder_paths/adapters/pool_adapter/test_adapter.py +0 -8
  32. wayfinder_paths/adapters/token_adapter/README.md +41 -49
  33. wayfinder_paths/adapters/token_adapter/adapter.py +0 -32
  34. wayfinder_paths/adapters/token_adapter/test_adapter.py +1 -12
  35. wayfinder_paths/conftest.py +0 -8
  36. wayfinder_paths/core/__init__.py +0 -2
  37. wayfinder_paths/core/adapters/BaseAdapter.py +0 -22
  38. wayfinder_paths/core/adapters/__init__.py +0 -5
  39. wayfinder_paths/core/adapters/models.py +0 -5
  40. wayfinder_paths/core/analytics/__init__.py +0 -2
  41. wayfinder_paths/core/analytics/bootstrap.py +0 -16
  42. wayfinder_paths/core/analytics/stats.py +0 -7
  43. wayfinder_paths/core/analytics/test_analytics.py +5 -34
  44. wayfinder_paths/core/clients/BRAPClient.py +0 -35
  45. wayfinder_paths/core/clients/ClientManager.py +0 -51
  46. wayfinder_paths/core/clients/HyperlendClient.py +0 -77
  47. wayfinder_paths/core/clients/LedgerClient.py +2 -122
  48. wayfinder_paths/core/clients/PoolClient.py +0 -2
  49. wayfinder_paths/core/clients/TokenClient.py +0 -39
  50. wayfinder_paths/core/clients/WalletClient.py +0 -15
  51. wayfinder_paths/core/clients/WayfinderClient.py +0 -24
  52. wayfinder_paths/core/clients/__init__.py +0 -4
  53. wayfinder_paths/core/clients/protocols.py +25 -98
  54. wayfinder_paths/core/config.py +0 -24
  55. wayfinder_paths/core/constants/__init__.py +0 -7
  56. wayfinder_paths/core/constants/base.py +2 -9
  57. wayfinder_paths/core/constants/erc20_abi.py +0 -5
  58. wayfinder_paths/core/constants/hyperlend_abi.py +0 -7
  59. wayfinder_paths/core/constants/moonwell_abi.py +0 -35
  60. wayfinder_paths/core/engine/StrategyJob.py +0 -32
  61. wayfinder_paths/core/strategies/Strategy.py +0 -99
  62. wayfinder_paths/core/strategies/__init__.py +0 -2
  63. wayfinder_paths/core/utils/__init__.py +0 -1
  64. wayfinder_paths/core/utils/erc20_service.py +0 -1
  65. wayfinder_paths/core/utils/evm_helpers.py +0 -50
  66. wayfinder_paths/core/utils/transaction.py +0 -1
  67. wayfinder_paths/run_strategy.py +0 -46
  68. wayfinder_paths/scripts/create_strategy.py +0 -17
  69. wayfinder_paths/scripts/make_wallets.py +1 -4
  70. wayfinder_paths/strategies/basis_trading_strategy/README.md +71 -163
  71. wayfinder_paths/strategies/basis_trading_strategy/snapshot_mixin.py +0 -24
  72. wayfinder_paths/strategies/basis_trading_strategy/strategy.py +36 -400
  73. wayfinder_paths/strategies/basis_trading_strategy/test_strategy.py +15 -64
  74. wayfinder_paths/strategies/basis_trading_strategy/types.py +0 -4
  75. wayfinder_paths/strategies/hyperlend_stable_yield_strategy/README.md +65 -56
  76. wayfinder_paths/strategies/hyperlend_stable_yield_strategy/strategy.py +4 -27
  77. wayfinder_paths/strategies/hyperlend_stable_yield_strategy/test_strategy.py +0 -10
  78. wayfinder_paths/strategies/moonwell_wsteth_loop_strategy/README.md +71 -72
  79. wayfinder_paths/strategies/moonwell_wsteth_loop_strategy/strategy.py +23 -227
  80. wayfinder_paths/strategies/moonwell_wsteth_loop_strategy/test_strategy.py +120 -113
  81. wayfinder_paths/strategies/stablecoin_yield_strategy/README.md +64 -59
  82. wayfinder_paths/strategies/stablecoin_yield_strategy/strategy.py +4 -44
  83. wayfinder_paths/strategies/stablecoin_yield_strategy/test_strategy.py +2 -35
  84. wayfinder_paths/templates/adapter/README.md +107 -46
  85. wayfinder_paths/templates/adapter/adapter.py +0 -9
  86. wayfinder_paths/templates/adapter/test_adapter.py +0 -19
  87. wayfinder_paths/templates/strategy/README.md +113 -59
  88. wayfinder_paths/templates/strategy/strategy.py +0 -22
  89. wayfinder_paths/templates/strategy/test_strategy.py +0 -28
  90. wayfinder_paths/tests/test_test_coverage.py +2 -12
  91. wayfinder_paths/tests/test_utils.py +1 -31
  92. wayfinder_paths-0.1.20.dist-info/METADATA +355 -0
  93. wayfinder_paths-0.1.20.dist-info/RECORD +129 -0
  94. wayfinder_paths/core/adapters/base.py +0 -5
  95. wayfinder_paths-0.1.19.dist-info/METADATA +0 -592
  96. wayfinder_paths-0.1.19.dist-info/RECORD +0 -130
  97. {wayfinder_paths-0.1.19.dist-info → wayfinder_paths-0.1.20.dist-info}/LICENSE +0 -0
  98. {wayfinder_paths-0.1.19.dist-info → wayfinder_paths-0.1.20.dist-info}/WHEEL +0 -0
@@ -1,106 +1,105 @@
1
1
  # Moonwell wstETH Loop Strategy
2
2
 
3
- - Entrypoint: `strategies.moonwell_wsteth_loop_strategy.strategy.MoonwellWstethLoopStrategy`
4
- - Examples: `examples.json`
5
- - Tests: `test_strategy.py`
3
+ Leveraged wstETH carry trade on Base via Moonwell.
6
4
 
7
- ## What it does
5
+ - **Module**: `wayfinder_paths.strategies.moonwell_wsteth_loop_strategy.strategy.MoonwellWstethLoopStrategy`
6
+ - **Chain**: Base (8453)
7
+ - **Tokens**: USDC, WETH, wstETH
8
8
 
9
- A leveraged liquid-staking carry trade on Base that loops USDC collateral into wstETH exposure. The strategy:
9
+ ## Overview
10
10
 
11
- 1. Deposits USDC as initial collateral on Moonwell lending protocol.
12
- 2. Borrows WETH against the USDC collateral.
13
- 3. Swaps WETH to wstETH via Aerodrome/BRAP routing.
14
- 4. Lends wstETH back to Moonwell as additional collateral.
15
- 5. Repeats the loop until target leverage is reached or marginal gains fall below threshold.
11
+ This strategy creates a leveraged liquid-staking carry trade by:
12
+ 1. Depositing USDC as initial collateral on Moonwell
13
+ 2. Borrowing WETH against the USDC collateral
14
+ 3. Swapping WETH to wstETH via Aerodrome/BRAP
15
+ 4. Lending wstETH back to Moonwell as additional collateral
16
+ 5. Repeating the loop until target leverage is reached
16
17
 
17
18
  The position is **delta-neutral**: WETH debt offsets wstETH collateral, so PnL is driven by the spread between wstETH staking yield and WETH borrow cost.
18
19
 
19
- ## Key parameters
20
+ ## Key Parameters
20
21
 
21
- - `MIN_GAS = 0.002` ETH (minimum Base ETH for gas)
22
- - `MIN_USDC_DEPOSIT = 20` USDC (minimum initial collateral)
23
- - `MAX_DEPEG = 0.01` (1% max stETH/ETH depeg threshold)
24
- - `MIN_HEALTH_FACTOR = 1.2` (triggers deleveraging if below)
25
- - `MAX_HEALTH_FACTOR = 1.5` (triggers leverage loop if above)
26
- - `leverage_limit = 10` (maximum leverage multiplier)
27
- - `COLLATERAL_SAFETY_FACTOR = 0.98` (2% safety buffer on borrows)
28
- - `MAX_SLIPPAGE_TOLERANCE = 0.03` (3% max slippage to prevent MEV)
29
- - `_MIN_LEVERAGE_GAIN_BPS = 50e-4` (stop looping if marginal gain < 50 bps)
22
+ | Parameter | Value | Description |
23
+ |-----------|-------|-------------|
24
+ | `MIN_GAS` | 0.002 ETH | Minimum gas buffer |
25
+ | `MIN_USDC_DEPOSIT` | 20 USDC | Minimum initial collateral |
26
+ | `MAX_DEPEG` | 0.01 (1%) | Max stETH/ETH depeg threshold |
27
+ | `MIN_HEALTH_FACTOR` | 1.2 | Triggers deleveraging if below |
28
+ | `MAX_HEALTH_FACTOR` | 1.5 | Triggers leverage loop if above |
29
+ | `leverage_limit` | 10 | Maximum leverage multiplier |
30
+ | `COLLATERAL_SAFETY_FACTOR` | 0.98 | 2% safety buffer on borrows |
31
+ | `MAX_SLIPPAGE_TOLERANCE` | 0.03 | 3% max slippage |
30
32
 
31
- ## Safety features
33
+ ## Safety Features
32
34
 
33
- - **Depeg guard**: `_max_safe_F()` calculates leverage ceiling based on wstETH collateral factor and max depeg tolerance.
34
- - **Delta-neutrality**: `_post_run_guard()` enforces wstETH collateral WETH debt (within tolerance) via `_reconcile_wallet_into_position()` and `_settle_weth_debt_to_target_usd()`.
35
- - **Swap retries**: `_swap_with_retries()` uses progressive slippage (0.5% 1% 1.5%) with exponential backoff.
36
- - **Health monitoring**: Automatic deleveraging when health factor drops below `MIN_HEALTH_FACTOR`.
37
- - **Deterministic Base reads**: waits 2 blocks after receipts by default and pins ETH/ERC20 balance reads to the confirmed block to avoid stale RPC reads on Base.
38
- - **Rollback protection**: Checks actual balances before rollback swaps to prevent failed transactions.
35
+ - **Depeg guard**: Calculates leverage ceiling based on collateral factor and max depeg tolerance
36
+ - **Delta-neutrality**: Enforces wstETH collateral >= WETH debt
37
+ - **Swap retries**: Progressive slippage (0.5% -> 1% -> 1.5%) with exponential backoff
38
+ - **Health monitoring**: Automatic deleveraging when health factor drops
39
+ - **Deterministic reads**: Waits 2 blocks after receipts to avoid stale RPC data
39
40
 
40
- ## Adapters used
41
+ ## Adapters Used
41
42
 
42
- - `BalanceAdapter` for token balances and wallet transfers with ledger tracking.
43
- - `TokenAdapter` for token metadata and price feeds.
44
- - `LedgerAdapter` for net deposit tracking.
45
- - `BRAPAdapter` for swap quotes and execution via Aerodrome/routing.
46
- - `MoonwellAdapter` for lending, borrowing, collateral management, and position queries.
43
+ - **BalanceAdapter**: Token balances, wallet transfers
44
+ - **TokenAdapter**: Token metadata, price feeds
45
+ - **LedgerAdapter**: Net deposit tracking
46
+ - **BRAPAdapter**: Swap quotes and execution
47
+ - **MoonwellAdapter**: Lending, borrowing, collateral management
47
48
 
48
49
  ## Actions
49
50
 
50
51
  ### Deposit
51
52
 
52
- - Validates USDC and ETH balances in the main wallet.
53
- - Transfers ETH (gas) into the strategy wallet if needed.
54
- - Moves USDC from main wallet to strategy wallet.
55
- - Lends USDC on Moonwell and enables as collateral.
56
- - Executes leverage loop: borrow WETH → swap to wstETH → lend wstETH → repeat.
53
+ ```bash
54
+ poetry run python wayfinder_paths/run_strategy.py moonwell_wsteth_loop_strategy \
55
+ --action deposit --main-token-amount 100 --gas-token-amount 0.01 --config config.json
56
+ ```
57
+
58
+ - Validates USDC and ETH balances
59
+ - Transfers ETH gas buffer if needed
60
+ - Moves USDC to strategy wallet
61
+ - Lends USDC on Moonwell and enables as collateral
62
+ - Executes leverage loop (borrow WETH -> swap to wstETH -> lend)
57
63
 
58
64
  ### Update
59
65
 
60
- - Checks gas balance meets maintenance threshold.
61
- - Reconciles wallet leftovers into the intended position (`_reconcile_wallet_into_position()`).
62
- - Computes HF/LTV/delta from a single accounting snapshot.
63
- - If HF < MIN: triggers deleveraging via `_settle_weth_debt_to_target_usd()`.
64
- - If HF > MAX: executes additional leverage loops to optimize yield.
65
- - Claims WELL rewards if above minimum threshold.
66
+ ```bash
67
+ poetry run python wayfinder_paths/run_strategy.py moonwell_wsteth_loop_strategy \
68
+ --action update --config config.json
69
+ ```
70
+
71
+ - Checks gas balance meets threshold
72
+ - Reconciles wallet leftovers into position
73
+ - Computes health factor/LTV/delta
74
+ - If HF < MIN: triggers deleveraging
75
+ - If HF > MAX: executes additional leverage loops
76
+ - Claims WELL rewards if above threshold
66
77
 
67
78
  ### Status
68
79
 
69
- `_status()` returns:
80
+ ```bash
81
+ poetry run python wayfinder_paths/run_strategy.py moonwell_wsteth_loop_strategy \
82
+ --action status --config config.json
83
+ ```
70
84
 
71
- - `portfolio_value`: sum of all position values (USDC lent + wstETH lent - WETH debt)
72
- - `net_deposit`: fetched from LedgerAdapter
73
- - `strategy_status`: includes current leverage, health factor, LTV, peg diff, credit remaining
85
+ Returns:
86
+ - `portfolio_value`: USDC lent + wstETH lent - WETH debt
87
+ - `net_deposit`: From LedgerAdapter
88
+ - `strategy_status`: Leverage, health factor, LTV, peg diff, credit remaining
74
89
 
75
90
  ### Withdraw
76
91
 
77
- - Sweeps miscellaneous token balances to WETH.
78
- - Repays all WETH debt via `_settle_weth_debt_to_target_usd(target_debt_usd=0.0, mode="exit")`.
79
- - Unlends wstETH, swaps to USDC.
80
- - Unlends USDC collateral.
81
- - Returns USDC and remaining ETH to main wallet.
82
-
83
- ## Running locally
84
-
85
92
  ```bash
86
- # Install dependencies
87
- poetry install
88
-
89
- # Generate wallets (writes config.json)
90
- poetry run python wayfinder_paths/scripts/make_wallets.py -n 1
91
-
92
- # Copy config and edit credentials
93
- cp wayfinder_paths/config.example.json config.json
94
-
95
- # Check status / health
96
- poetry run python wayfinder_paths/run_strategy.py moonwell_wsteth_loop_strategy --action status --config $(pwd)/config.json
97
-
98
- # Perform a deposit/update/withdraw cycle
99
- poetry run python wayfinder_paths/run_strategy.py moonwell_wsteth_loop_strategy --action deposit --main-token-amount 100 --gas-token-amount 0.01 --config $(pwd)/config.json
100
- poetry run python wayfinder_paths/run_strategy.py moonwell_wsteth_loop_strategy --action update --config $(pwd)/config.json
101
- poetry run python wayfinder_paths/run_strategy.py moonwell_wsteth_loop_strategy --action withdraw --config $(pwd)/config.json
93
+ poetry run python wayfinder_paths/run_strategy.py moonwell_wsteth_loop_strategy \
94
+ --action withdraw --config config.json
102
95
  ```
103
96
 
97
+ - Sweeps miscellaneous token balances to WETH
98
+ - Repays all WETH debt
99
+ - Unlends wstETH, swaps to USDC
100
+ - Unlends USDC collateral
101
+ - Returns USDC and remaining ETH to main wallet
102
+
104
103
  ## Testing
105
104
 
106
105
  ```bash