Commit 15bed7b
DRBalancerVault contract for system DR rebalancing (#269)
* Implement a vault that holds underlying (AMPL) and perp (SPOT) tokens and auto-rebalances to maintain the system's target deviation ratio via IRolloverVault swaps.
Key features:
- Deposit underlying tokens and mint vault notes (LP tokens)
- Redeem notes for proportional underlying + perp tokens
- Auto-rebalance when system DR is outside equilibrium zone:
DR < 1 (perpTVL too high): redeem perps to decrease perpTVL
DR > 1 (perpTVL too low): mint perps to increase perpTVL
- Rebalance formula: requiredChange = perpTVL × |dr - targetDR|
(rolloverVaultTVL unchanged during flash mint/redeem)
- Liquidity limits based on swap direction:
underlying->perp: limited by underlying balance
perp->underlying: limited by perp value held
- Separate lag factors and percentage limits for each direction
- Slippage protection with configurable max swap fee percentage
- Keeper-controlled pause functionality.
* Update DRBalancerVault deposit/redeem to accept both tokens with slippage protection
- Update deposit() to accept both underlying and perp tokens with signature:
deposit(underlyingAmtMax, perpAmtMax, minNotesMinted)
- Update redeem() to include slippage protection with signature:
redeem(notesAmt, minUnderlyingAmtOut, minPerpAmtOut)
- Update computeMintAmt() to return (notesMinted, underlyingAmtIn, perpAmtIn)
- First deposit accepts any ratio; subsequent deposits enforce vault ratio
- Update Deposited event to include perpAmtIn
- Fix lag factor comments (swapped DR conditions)
- Add InvalidLagFactor validation to prevent division by zero
- Update contract docstring to reflect dual-token deposits
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* renamed events
* added dr eq range back
* allowing empty equilibriumDR
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>1 parent 1415531 commit 15bed7b
13 files changed
Lines changed: 3886 additions & 1340 deletions
File tree
- spot-contracts
- spot-vaults
- contracts
- _interfaces
- errors
- _test
- tasks
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
0 commit comments