generated from refcell/femplate
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Calculate
t0Debt2ToCollateral
ratio only for loans not in auction (#…
…758) * Calculate t0Debt2ToCollateral ratio only for loans not in auction: - drawDebt/repayDebt: check if loan not in auction. If not in auction check if auction settled by pledge collateral/repay action and if so calculate t0Debt2ToCollateral ratio considering debt and collateral pre action as 0 - take/bucketTake: check if loan settled by take action and if so calculate t0Debt2ToCollateral ratio considering debt and collateral pre action as 0 - kick/kickWithDeposit: always calculate t0Debt2ToCollateral ratio considering debt and collateral post action as 0 (as loan will enter in auction queue) settle: do not calculate t0Debt2ToCollateral ratio as debt and collateral pre settle are not taken into account (loan still auctioned) and loan is removed from auction queue only when there's no more debt (post debt = 0) - return inAuction flag in DrawDebtResult/RepayDebtResult structs (to be used when checking if loan in auction) and remove inAuction member from local vars structs Additional fix: on forgiveBadDebt emit BucketBankruptcy before forfeiting LP from bucket, otherwise event will always be emitted with 0. Added unit test to ensure this Reduce optimizer runs to 50 to fit contract size limit * Fix I4 invariant to account only borrowers that are not in auction * Include t0debtInAuction in PoolState struct so to make it available when interest rate is calcualted. Consistent order of updates: - in memory pool state struct - update t0Debt2ToCollateral ratio state - update pool balances state - update interest rate state * Introduce Pool helper functions to save state - post take/bucketTake action (Use single struct for take/bucketTake result) - post settle action Use helper functions in both ERC20 and ERC721 pools Less duplicate code, smaller contract size, bumped optimizer runs to 500 * Use nonAuctionedT0Debt to calculate EMAs and interest rate * More tests fix * Fix deposit take unit tests * fixes for baselines * Add NATSpec to _meaningfulDeposit function Gas optimization: use PoolState.t0DebtInAuction for `_revertIfAuctionDebtLocked` param * Changes after review: nit space alignment * T0 debt2 to collateral ema init fix (#760) * Fix for initialization of emas checking lastUpdateTime, and some baseline fixes. 29 tests failing * Fix tests * Check for EMA init only once --------- Co-authored-by: mwc <[email protected]> Co-authored-by: grandizzy <[email protected]> * Changes after review: style --------- Co-authored-by: mwc <[email protected]> Co-authored-by: mattcushman <[email protected]>
- Loading branch information
1 parent
2b31b19
commit 48791b5
Showing
42 changed files
with
855 additions
and
850 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
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
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
Oops, something went wrong.