-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: rebalancing donations (only manual donation)
This commit lays the foundations to reintroduce donation support for TwoCrypto pools. We first introduce a new contract-level invariant: D_total = D + D_rebalance. Where: * D_total is the total amount of liquidity in the pool. * D represents the depositors' liquidity (what can be withdrawn). * D_rebalance is a siloed reserve of liquidity used to cover rebalancing losses or absorb rebalancing gains. To reintroduce donations safely, during rebalancing (triggered by `tweak_price`), the pool taps into a separate reserve (`D_rebalance`) from depositors' liquidity to cover losses. `tweak_price` no longer relies on `xcp_profit` (referred to as `profit` here) to decide whether it should attempt to rebalance. Instead, it uses the ratio between `D_rebalance` and `D_total`. The threshold for attempting a rebalance has been arbitrarily set to 0.1% for now but will be parameterized by `allowed_extra_profit`, which will be repurposed since it is no longer used for the old condition. Furthermore, a new function `donate` has been added to the pool to manually donate funds for rebalancing. The function works similarly to `add_liquidity` except it doesn't mint any LP tokens and doesn't inflate `virtual_price`. In the future, fees collected by normal operations in the pool (`exchange`, `add_liquidity`, etc.) will increase `D_rebalance`, allowing the removal of `xcp_profit` related code.
- Loading branch information
1 parent
727c13d
commit 969ad6d
Showing
1 changed file
with
109 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters