Skip to content

Commit

Permalink
ALM internal audit fixes (#122)
Browse files Browse the repository at this point in the history
* Fix: CollateralAssetsUpdated and BorrowAssetsUpdated events

* Fix: AavReserveUpdated event

* Emit struct elements separately for greater clarity
* Add corresponding test

* Add test for LendingPoolUpdated event

* Fix: Line 214 & 182 comments

* Fix: Initialize function

* Add header for external functions
* Add _addCollateralAssets and _addBorrowAssets internal functions
* Note: New internal functions are a straight copy of the previous external function implementations. Specific changes to _addCollateralAssets and _addBorrowAssets would be done later.

* Fix: lever javadocs

* Improve javadocs for lever() and delever()

* Fix: deleverToZeroBorrowBalance() function

* Improve javadocs
* Revert if borrow balance is zero
* Add corresponding test

* Fix: Improve sync() javadocs

* Fix: sync(), store borrowAssets[i] in local variable

* Fix: addCollateralAssets() function

* Made the function external
* Removed call to _updateUnderlyingToReserveTokens() from the associated internal
function
* Added note to javadoc

* Fix: addBorrowAssets() function

* Made the function external
* Removed call to _updateUnderlyingToReserveTokens() from the associated internal function
* Added note to javadoc
* Removed tests associated with confirming underlyingToReserveTokens mappings update

* Add Note in caps about adding only required collateral assets

* Fix: componentIssueHook(), use preciseMul

* Remove call to sync() from removeModule(), removeCollateralAssets() and removeBorrowAssets() functions

* Fix: updateAllowedSetToken function()

* Fix javadocs
* Add check to validate passed address is valid SetToken
* Add corresponding tests

* Fix: updateUnderlyingToReserveTokensMapping

* Fix javadocs
* Move emitting events to internal function
* Add check for valid aave reserve
* Rename event AaveReserveUpdated to more suitable ReserveTokensUpddated

* Add test for invalid reserve in updateUnderlyingToReserveTokensMapping

* Fix: Add reference to AaveV2 library in internal function javadocs

* Fix: _createAndValidateActionInfoNotional()

* Pass setTotalSupply as an argument

* Fix: _updateLeverPositions()

* Put underlyingToReserveTokens[actionInfo.collateralAsset].aToken into local variable to avoid fetching from storage twice

* Fix: _getBorrowPosition() math

* Update preciseDiv to preciseDivCeil

* Fix: _updateUseReserveAsCollateral()

* Fix javadocs: Add impossible case

* Fix: _validateCommon()

Improve revert message

* Fix: _validateNewCollateralAssets() and _validatNewBorrowAsset()

* Check latest reserve token addresses are saved in  underlyingToReserveTokens mapping before adding a new collateral/borrow asset
* Add tests for introduced changes

* Refactor updateUnderlyingToReserveTokensMapping

* Add check to revert if mapping already exists.
* Rename to _addUnderlyingToReserveTokensMapping
* Add tests for changes

* Remove updateLendingPool function and corresponding event

* Since we fetch and store lendingPool proxy address in the constructor which would never change.
* Aave would only update the lendingPool implementation.
* Remove corresponding tests

* Reorder functions to match CLM

* Easier to review the diff.

* Add suggested changes

* Rename parameters to reflect position units
  • Loading branch information
0xSachinK authored Aug 11, 2021
1 parent 60ec0b4 commit f6db6ad
Show file tree
Hide file tree
Showing 2 changed files with 524 additions and 435 deletions.
Loading

0 comments on commit f6db6ad

Please sign in to comment.