-
Notifications
You must be signed in to change notification settings - Fork 83
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
Gas reductions + AaveV2 #115
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
* Added v2 migration and test cases * Differentiated between AaveV1 and AaveV2
… into gas-reductions
wuestholz
reviewed
Nov 25, 2020
wuestholz
reviewed
Nov 25, 2020
wuestholz
reviewed
Nov 25, 2020
wuestholz
reviewed
Nov 25, 2020
wuestholz
reviewed
Nov 25, 2020
wuestholz
reviewed
Nov 25, 2020
wuestholz
reviewed
Nov 25, 2020
wuestholz
reviewed
Nov 26, 2020
wuestholz
reviewed
Nov 26, 2020
wuestholz
reviewed
Nov 26, 2020
wuestholz
reviewed
Nov 26, 2020
wuestholz
reviewed
Nov 27, 2020
wuestholz
reviewed
Nov 27, 2020
wuestholz
reviewed
Nov 27, 2020
wuestholz
reviewed
Nov 27, 2020
wuestholz
reviewed
Nov 27, 2020
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.
Description
PlatformIntegration
for Aave V2 and the ability to move assets between IntegrationsAffected files:
Masset.sol
: Major changes to depositing and withdrawing tokens (1) and tracking fee collection (2)BasketManager.sol
: Minor changes to accomodate (1) and (3), also ability to collect system revenue to recipient (to support buy and make)AaveIntegration.sol
,CompoundIntegration.sol
: Major changes to accommodate new cache functionality (1) and maintain backwards compatibilitySavingsManager.sol
: Extension of current streaming functionality to accomodate (2)New files:
AaveV2Integration.sol
: New contractMinor changes:
swapFee
andredemptionFee
from40bps
and0bps
to6bps
and3bps
respectively, as this is what is currently active on the mainnet mUSD contract. Note these changes don't have any knock on effect to mainnet and are used to simulate live environment as accurately as possiblesavingsRate
from90%
to70%
. Having asavingsRate
of70%
would mean that70%
of system revenue is sent to SAVE and the other 30 is redistributed to a specified address. This is now more in line with general standardsUpgrade plan
Integration
files are all backwards compatible, as is theBasketManager
andSavingsManager
. Therefore it would be possible to upgrade all these contracts without completing (1), (2) or (3). The below plan iteratively moves towards full completion.AaveIntegration
,CompoundIntegration
andBasketManager
. DeployAaveV2Integration
. Complete (3) - migration of funds fromAaveIntegration
toAaveV2Integration
SavingsManager
(first, ensure that there is no residual mUSD from the Liquidator stream here)Masset
and set cache size to finalise (1) and (2)Low level
Implementation details
1 - Cache
Details in MIP-3.
There are a number of concerns in accounting for tokens with transfer fees enabled. If we were to use the cache with these assets then it may be possible to churn funds at both a cost to the attacker and to the system. It is highly unlikely for this to happen, but the
require(transferred == _quantity, "Asset not fully transferred");
in_depositTokens
should protect against this churn, and also ensure that when we deposit into the cache, we are minting the correct amount of mAsset.Some properties:
txFees
enabled (e.g. USDT turns on), then there should be 0 in the cache2 - Swap fee accrual and interest collection batching
Details in MIP-4.
Adds a new
surplus
variable to theMasset.sol
. This always remains at1
base unit or higher to limit the cost to Swap/Redeem.Note: the fees do not get minted until collected by the SAVE contract. Technically speaking, the sum of the vaultBalances should equal
totalSupply
+surplus
.. so with that being the case, this is what is sent to the ForgeValidator to use in weight checking.3 - Aave V2 and migration
Aave are releasing V2. Instead of upgrading the existing migration and then doing some sort of migration script, it's much less error prone to simply create a second platform integration contract and move the funds about.
Upgrades the Aave Integration to accommodate Aave v2 - docs here.
V2 Spec
V1 -> V2 changes:
LendingPoolAddressesProvider
that gives out all different module addressesdeposit
adds an_onBehalfOf
argaToken
addresses changeILendingPoolAddressesProvider(platformAddress).getLendingPoolCore();
) is no longer the contract to approve - now simplyLendingPool
Assumptions: