Skip to content

Commit 15bed7b

Browse files
aalavandhanclaude
andauthored
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

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,6 @@ artifacts
2323
#Generated files
2424
RolloverBatch.json
2525
RedeemBatch.json
26+
27+
.claude
28+
CLAUDE.md

spot-contracts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"@ethersproject/providers": "^5.6.8",
2727
"@nomicfoundation/hardhat-chai-matchers": "latest",
2828
"@nomicfoundation/hardhat-ethers": "^3.0.0",
29-
"@nomicfoundation/hardhat-verify": "latest",
29+
"@nomicfoundation/hardhat-verify": "^2.0.0",
3030
"@nomiclabs/hardhat-waffle": "^2.0.6",
3131
"@openzeppelin/hardhat-upgrades": "^3.0.4",
3232
"@openzeppelin/upgrades-core": "latest",

0 commit comments

Comments
 (0)