-
Notifications
You must be signed in to change notification settings - Fork 12
DRBalancerVault contract for system DR rebalancing #269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
DRBalancerVault contract for system DR rebalancing
🚨 Report Summary
For more details view the full report in OpenZeppelin Code Inspector |
404525b to
ecdf37e
Compare
… 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.
ecdf37e to
173047c
Compare
…page 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>
| /// @notice Emitted when a user deposits underlying tokens. | ||
| event Deposit( | ||
| /// @notice Emitted when a user deposits tokens. | ||
| event Deposited( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think Deposit is more consistent with other standards.
ERC-20, for example, has events for Transfer and Redeem, not Transferred and Redeemed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. I don't think there is a naming conflict between "deposit" and "Deposit". We can go back to how it was ..
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:
(rolloverVaultTVL unchanged during flash mint/redeem)