-
Notifications
You must be signed in to change notification settings - Fork 41
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
Negative fCash Liquidation and Sweep Cash #34
Merged
Merged
Conversation
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
jeffywu
added a commit
that referenced
this pull request
Mar 19, 2022
* adding additional checks in fcash liquidation * updating ETH whale * adding additional selector * implemented a fix for last claim time issue * updating test
jeffywu
added a commit
that referenced
this pull request
Apr 4, 2022
* Hotfix: disable bitmap currency * Bugfix: disallow changing bitmap currency * Feature: Treasury Action * Feature: switching to transfer / claim ownership * Bugfix: settlement rates set prematurely * Feature: adding patch fix router * Hotfix: setting account context during liquidation calculations * Deployment: adding treasury action to deployment * Misc: removing github actions file * Feature (SOLIDITY): allow nToken to redeem around residuals * Feature (TESTS): allow nToken to redeem around residuals * Deployment: deployed nToken redeem to Kovan * Bugfix (SOLIDITY): incentives calculation fix and migration * Bugfix (TESTS): incentives calculation fix and migration * Refactor: modularizing nToken code * Refactor: simplifying the nToken asset pv calculation * Refactor: handling initialization edge case * Testing: refactor migration code and add fix router * Feature: adding a secondary incentive rewarder * Feature (SOLIDITY): support Aave tokens * Feature (TESTS): support Aave tokens * add router fix message * commenting out some views, code size * refactoring treasury action code * removing unused file * moving address to a separate file * fixing unit test * Treasury cannot claim COMP tokens & COMP tokens are stuck [code-423n4/2022-01-notional-findings#192] * Optimization on _redeemAndTransfer [code-423n4/2022-01-notional-findings#213] * Gas: reserveInternal.subNoNeg(bufferInternal) can be unchecked [code-423n4/2022-01-notional-findings#199] * Revert string > 32 bytes [code-423n4/2022-01-notional-findings#110] * setReserveCashBalance can only set less reserves [code-423n4/2022-01-notional-findings#103] * Gas: When a function uses the onlyManagerContract modifier, use msg.sender instead of treasuryManagerContract [code-423n4/2022-01-notional-findings#98] * Prefix (++i), rather than postfix (i++), increment/decrement operators should be used in for-loops [code-423n4/2022-01-notional-findings#228] * Gas: Missing checks for non-zero transfer value calls [code-423n4/2022-01-notional-findings#94] * Working on token deployer * Refactor compound deployer * Adding notional deployer * Adding mainnet addresses * Adding governance deployer * Adding liquidator deployer * Implementing library checker * Refactor token deployer * Working on contract initialization * Refactoring initializers * Fixing lib deployment logic * Implementing init parameters and various fixes * Initialize markets and updated deployment json * Adding liquidator addresses * fixing tests * Deploying governor and NOTE * Re-deploying NOTE and upgraded router * Adding deployment files * Adding aave lending pool storage * Moving calculation functions out of views * Cleaning up * Updating ABI * Renaming contract * renaming the calculation contract * fixing deployment script * fixing some tests (#29) * fixing some tests * fixes to aave tests * bumping max market index * combining two fixes into patch fix router * updating a number of comments * adding some comments in initi markets * adding safety check in patch fix * re-enabling view methods * fixing potential edge case on claim time * renaming incentives variable * updating rewarder to include the nToken supply change * adding an event for migration incentive * updating abi * adding events and exporting new abi * moving events in treasury action * removing WETH variable * adding fork tests for incentives * adding tests for trading calculations * adding currency id to IRewarder * Bugfix/init markets cash withholding (#32) * adding fork tests for incentives * adding tests for trading calculations * adding currency id to IRewarder * adding test for withholding amount * fixing init markets cash withholding * adding a get present value method for fCash * adding additional checks in fcash liquidation * updating ETH whale * adding additional selector * Fixing patchfix router (#33) * Bugfix/last claim time revert (#34) * adding additional checks in fcash liquidation * updating ETH whale * adding additional selector * implemented a fix for last claim time issue * updating test * Bugfix/init markets at zero rate (#36) * adding additional checks in fcash liquidation * updating ETH whale * adding additional selector * fixing return value for zero rate * Redeploy Kovan (#35) * validated sources * updating some config * Deploying to mainnet (#96) * Deploying to mainnet * Updating mainnet addresses * Adding v2.1 upgrade script Co-authored-by: Tianjie Wei <[email protected]> Co-authored-by: weitianjie2000 <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR covers three issues uncovered during further testing:
The logProportion method in Market was not doing the appropriate natural log calculation, fix can be seen in this diff: https://github.com/notional-finance/contracts-v2/pull/34/files?file-filters%5B%5D=.sol#diff-5be16aacfabeaee46baa4078b7798218c335cc25bc2307bd0790a0f83cd2fd8e
In the event that significant residuals build up as a result of trading, markets may not have enough liquidity after initialize markets. Adds a
sweepCashIntoMarkets
method that will push residual cash balances back into markets for an nToken: https://github.com/notional-finance/contracts-v2/pull/34/files?file-filters%5B%5D=.sol#diff-75eb111fb88272cc0f5a6e32552ee6cb1d34120e519ec288632d17ebca43f973R439Local currency fCash liquidations may require liquidating negative fCash balances in the case when an account is holding cash as collateral against a negative fCash balance. If oracle rates shift such that the cash held is insufficient, the account may become undercollateralized. In this case, a liquidator may take negative fCash AND cash balances into their account which will give the liquidated account some amount of free collateral benefit. This liquidation requires an additional governance parameter
liquidationDebtBuffer
which defines the discount that the liquidator receives in basis points. This change does require some additional logic in the finalizefCashLiquidation method because this transaction is a net positive present value transaction but a net negative free collateral transaction.Majority of the changes can be found here: https://github.com/notional-finance/contracts-v2/pull/34/files?file-filters%5B%5D=.sol#diff-827b709b2b402e73db8f0cd638885feafa8428be6137bcaf1cf9991fab46f0b6