From d93867f0aaed696ae6b88bd1da58ee261eafb652 Mon Sep 17 00:00:00 2001 From: alpha-guy Date: Thu, 15 Jul 2021 18:30:07 +0530 Subject: [PATCH 01/19] Move Aave V1 ABIs to external/abi/aave/v1 subfolder --- external/abi/aave/{ => v1}/AToken.json | 0 .../abi/aave/{ => v1}/AaveGovernanceV2.json | 0 .../aave/{ => v1}/AavePropositionPower.json | 0 .../aave/{ => v1}/AaveProtoGovernance.json | 0 .../aave/{ => v1}/AaveTokenV2Mintable.json | 0 .../{ => v1}/AssetVotingWeightProvider.json | 0 external/abi/aave/{ => v1}/CoreLibrary.json | 0 .../DefaultReserveInterestRateStrategy.json | 0 external/abi/aave/{ => v1}/Executor.json | 0 .../{ => v1}/GovernanceParamsProvider.json | 0 .../abi/aave/{ => v1}/GovernanceStrategy.json | 0 .../abi/aave/{ => v1}/LendToAaveMigrator.json | 0 external/abi/aave/{ => v1}/LendingPool.json | 1062 ++++++++++++++++- .../LendingPoolAddressesProvider.json | 0 .../{ => v1}/LendingPoolConfigurator.json | 0 .../abi/aave/{ => v1}/LendingPoolCore.json | 0 .../{ => v1}/LendingPoolDataProvider.json | 0 .../abi/aave/{ => v1}/LendingRateOracle.json | 0 18 files changed, 1060 insertions(+), 2 deletions(-) rename external/abi/aave/{ => v1}/AToken.json (100%) rename external/abi/aave/{ => v1}/AaveGovernanceV2.json (100%) rename external/abi/aave/{ => v1}/AavePropositionPower.json (100%) rename external/abi/aave/{ => v1}/AaveProtoGovernance.json (100%) rename external/abi/aave/{ => v1}/AaveTokenV2Mintable.json (100%) rename external/abi/aave/{ => v1}/AssetVotingWeightProvider.json (100%) rename external/abi/aave/{ => v1}/CoreLibrary.json (100%) rename external/abi/aave/{ => v1}/DefaultReserveInterestRateStrategy.json (100%) rename external/abi/aave/{ => v1}/Executor.json (100%) rename external/abi/aave/{ => v1}/GovernanceParamsProvider.json (100%) rename external/abi/aave/{ => v1}/GovernanceStrategy.json (100%) rename external/abi/aave/{ => v1}/LendToAaveMigrator.json (100%) rename external/abi/aave/{ => v1}/LendingPool.json (59%) rename external/abi/aave/{ => v1}/LendingPoolAddressesProvider.json (100%) rename external/abi/aave/{ => v1}/LendingPoolConfigurator.json (100%) rename external/abi/aave/{ => v1}/LendingPoolCore.json (100%) rename external/abi/aave/{ => v1}/LendingPoolDataProvider.json (100%) rename external/abi/aave/{ => v1}/LendingRateOracle.json (100%) diff --git a/external/abi/aave/AToken.json b/external/abi/aave/v1/AToken.json similarity index 100% rename from external/abi/aave/AToken.json rename to external/abi/aave/v1/AToken.json diff --git a/external/abi/aave/AaveGovernanceV2.json b/external/abi/aave/v1/AaveGovernanceV2.json similarity index 100% rename from external/abi/aave/AaveGovernanceV2.json rename to external/abi/aave/v1/AaveGovernanceV2.json diff --git a/external/abi/aave/AavePropositionPower.json b/external/abi/aave/v1/AavePropositionPower.json similarity index 100% rename from external/abi/aave/AavePropositionPower.json rename to external/abi/aave/v1/AavePropositionPower.json diff --git a/external/abi/aave/AaveProtoGovernance.json b/external/abi/aave/v1/AaveProtoGovernance.json similarity index 100% rename from external/abi/aave/AaveProtoGovernance.json rename to external/abi/aave/v1/AaveProtoGovernance.json diff --git a/external/abi/aave/AaveTokenV2Mintable.json b/external/abi/aave/v1/AaveTokenV2Mintable.json similarity index 100% rename from external/abi/aave/AaveTokenV2Mintable.json rename to external/abi/aave/v1/AaveTokenV2Mintable.json diff --git a/external/abi/aave/AssetVotingWeightProvider.json b/external/abi/aave/v1/AssetVotingWeightProvider.json similarity index 100% rename from external/abi/aave/AssetVotingWeightProvider.json rename to external/abi/aave/v1/AssetVotingWeightProvider.json diff --git a/external/abi/aave/CoreLibrary.json b/external/abi/aave/v1/CoreLibrary.json similarity index 100% rename from external/abi/aave/CoreLibrary.json rename to external/abi/aave/v1/CoreLibrary.json diff --git a/external/abi/aave/DefaultReserveInterestRateStrategy.json b/external/abi/aave/v1/DefaultReserveInterestRateStrategy.json similarity index 100% rename from external/abi/aave/DefaultReserveInterestRateStrategy.json rename to external/abi/aave/v1/DefaultReserveInterestRateStrategy.json diff --git a/external/abi/aave/Executor.json b/external/abi/aave/v1/Executor.json similarity index 100% rename from external/abi/aave/Executor.json rename to external/abi/aave/v1/Executor.json diff --git a/external/abi/aave/GovernanceParamsProvider.json b/external/abi/aave/v1/GovernanceParamsProvider.json similarity index 100% rename from external/abi/aave/GovernanceParamsProvider.json rename to external/abi/aave/v1/GovernanceParamsProvider.json diff --git a/external/abi/aave/GovernanceStrategy.json b/external/abi/aave/v1/GovernanceStrategy.json similarity index 100% rename from external/abi/aave/GovernanceStrategy.json rename to external/abi/aave/v1/GovernanceStrategy.json diff --git a/external/abi/aave/LendToAaveMigrator.json b/external/abi/aave/v1/LendToAaveMigrator.json similarity index 100% rename from external/abi/aave/LendToAaveMigrator.json rename to external/abi/aave/v1/LendToAaveMigrator.json diff --git a/external/abi/aave/LendingPool.json b/external/abi/aave/v1/LendingPool.json similarity index 59% rename from external/abi/aave/LendingPool.json rename to external/abi/aave/v1/LendingPool.json index f86c18355..5ad04d9db 100644 --- a/external/abi/aave/LendingPool.json +++ b/external/abi/aave/v1/LendingPool.json @@ -1,8 +1,1066 @@ { "contractName": "LendingPool", - "abi": [{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_reserve","type":"address"},{"indexed":true,"internalType":"address","name":"_user","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_borrowRateMode","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_borrowRate","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_originationFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_borrowBalanceIncrease","type":"uint256"},{"indexed":true,"internalType":"uint16","name":"_referral","type":"uint16"},{"indexed":false,"internalType":"uint256","name":"_timestamp","type":"uint256"}],"name":"Borrow","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_reserve","type":"address"},{"indexed":true,"internalType":"address","name":"_user","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":true,"internalType":"uint16","name":"_referral","type":"uint16"},{"indexed":false,"internalType":"uint256","name":"_timestamp","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_target","type":"address"},{"indexed":true,"internalType":"address","name":"_reserve","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_totalFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_protocolFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_timestamp","type":"uint256"}],"name":"FlashLoan","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_collateral","type":"address"},{"indexed":true,"internalType":"address","name":"_reserve","type":"address"},{"indexed":true,"internalType":"address","name":"_user","type":"address"},{"indexed":false,"internalType":"uint256","name":"_purchaseAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_liquidatedCollateralAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_accruedBorrowInterest","type":"uint256"},{"indexed":false,"internalType":"address","name":"_liquidator","type":"address"},{"indexed":false,"internalType":"bool","name":"_receiveAToken","type":"bool"},{"indexed":false,"internalType":"uint256","name":"_timestamp","type":"uint256"}],"name":"LiquidationCall","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_collateral","type":"address"},{"indexed":true,"internalType":"address","name":"_reserve","type":"address"},{"indexed":true,"internalType":"address","name":"_user","type":"address"},{"indexed":false,"internalType":"uint256","name":"_feeLiquidated","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_liquidatedCollateralForFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_timestamp","type":"uint256"}],"name":"OriginationFeeLiquidated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_reserve","type":"address"},{"indexed":true,"internalType":"address","name":"_user","type":"address"},{"indexed":false,"internalType":"uint256","name":"_newStableRate","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_borrowBalanceIncrease","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_timestamp","type":"uint256"}],"name":"RebalanceStableBorrowRate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_reserve","type":"address"},{"indexed":true,"internalType":"address","name":"_user","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_timestamp","type":"uint256"}],"name":"RedeemUnderlying","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_reserve","type":"address"},{"indexed":true,"internalType":"address","name":"_user","type":"address"},{"indexed":true,"internalType":"address","name":"_repayer","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amountMinusFees","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_fees","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_borrowBalanceIncrease","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_timestamp","type":"uint256"}],"name":"Repay","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_reserve","type":"address"},{"indexed":true,"internalType":"address","name":"_user","type":"address"}],"name":"ReserveUsedAsCollateralDisabled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_reserve","type":"address"},{"indexed":true,"internalType":"address","name":"_user","type":"address"}],"name":"ReserveUsedAsCollateralEnabled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_reserve","type":"address"},{"indexed":true,"internalType":"address","name":"_user","type":"address"},{"indexed":false,"internalType":"uint256","name":"_newRateMode","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_newRate","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_borrowBalanceIncrease","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_timestamp","type":"uint256"}],"name":"Swap","type":"event"},{"constant":true,"inputs":[],"name":"LENDINGPOOL_REVISION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"UINT_MAX_VALUE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"addressesProvider","outputs":[{"internalType":"contract LendingPoolAddressesProvider","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"core","outputs":[{"internalType":"contract LendingPoolCore","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"dataProvider","outputs":[{"internalType":"contract LendingPoolDataProvider","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"parametersProvider","outputs":[{"internalType":"contract LendingPoolParametersProvider","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"contract LendingPoolAddressesProvider","name":"_addressesProvider","type":"address"}],"name":"initialize","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_reserve","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint16","name":"_referralCode","type":"uint16"}],"name":"deposit","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_reserve","type":"address"},{"internalType":"address payable","name":"_user","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_aTokenBalanceAfterRedeem","type":"uint256"}],"name":"redeemUnderlying","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_reserve","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_interestRateMode","type":"uint256"},{"internalType":"uint16","name":"_referralCode","type":"uint16"}],"name":"borrow","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_reserve","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address payable","name":"_onBehalfOf","type":"address"}],"name":"repay","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_reserve","type":"address"}],"name":"swapBorrowRateMode","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_reserve","type":"address"},{"internalType":"address","name":"_user","type":"address"}],"name":"rebalanceStableBorrowRate","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_reserve","type":"address"},{"internalType":"bool","name":"_useAsCollateral","type":"bool"}],"name":"setUserUseReserveAsCollateral","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_collateral","type":"address"},{"internalType":"address","name":"_reserve","type":"address"},{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_purchaseAmount","type":"uint256"},{"internalType":"bool","name":"_receiveAToken","type":"bool"}],"name":"liquidationCall","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"address","name":"_reserve","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"bytes","name":"_params","type":"bytes"}],"name":"flashLoan","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"_reserve","type":"address"}],"name":"getReserveConfigurationData","outputs":[{"internalType":"uint256","name":"ltv","type":"uint256"},{"internalType":"uint256","name":"liquidationThreshold","type":"uint256"},{"internalType":"uint256","name":"liquidationBonus","type":"uint256"},{"internalType":"address","name":"interestRateStrategyAddress","type":"address"},{"internalType":"bool","name":"usageAsCollateralEnabled","type":"bool"},{"internalType":"bool","name":"borrowingEnabled","type":"bool"},{"internalType":"bool","name":"stableBorrowRateEnabled","type":"bool"},{"internalType":"bool","name":"isActive","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"_reserve","type":"address"}],"name":"getReserveData","outputs":[{"internalType":"uint256","name":"totalLiquidity","type":"uint256"},{"internalType":"uint256","name":"availableLiquidity","type":"uint256"},{"internalType":"uint256","name":"totalBorrowsStable","type":"uint256"},{"internalType":"uint256","name":"totalBorrowsVariable","type":"uint256"},{"internalType":"uint256","name":"liquidityRate","type":"uint256"},{"internalType":"uint256","name":"variableBorrowRate","type":"uint256"},{"internalType":"uint256","name":"stableBorrowRate","type":"uint256"},{"internalType":"uint256","name":"averageStableBorrowRate","type":"uint256"},{"internalType":"uint256","name":"utilizationRate","type":"uint256"},{"internalType":"uint256","name":"liquidityIndex","type":"uint256"},{"internalType":"uint256","name":"variableBorrowIndex","type":"uint256"},{"internalType":"address","name":"aTokenAddress","type":"address"},{"internalType":"uint40","name":"lastUpdateTimestamp","type":"uint40"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"getUserAccountData","outputs":[{"internalType":"uint256","name":"totalLiquidityETH","type":"uint256"},{"internalType":"uint256","name":"totalCollateralETH","type":"uint256"},{"internalType":"uint256","name":"totalBorrowsETH","type":"uint256"},{"internalType":"uint256","name":"totalFeesETH","type":"uint256"},{"internalType":"uint256","name":"availableBorrowsETH","type":"uint256"},{"internalType":"uint256","name":"currentLiquidationThreshold","type":"uint256"},{"internalType":"uint256","name":"ltv","type":"uint256"},{"internalType":"uint256","name":"healthFactor","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"_reserve","type":"address"},{"internalType":"address","name":"_user","type":"address"}],"name":"getUserReserveData","outputs":[{"internalType":"uint256","name":"currentATokenBalance","type":"uint256"},{"internalType":"uint256","name":"currentBorrowBalance","type":"uint256"},{"internalType":"uint256","name":"principalBorrowBalance","type":"uint256"},{"internalType":"uint256","name":"borrowRateMode","type":"uint256"},{"internalType":"uint256","name":"borrowRate","type":"uint256"},{"internalType":"uint256","name":"liquidityRate","type":"uint256"},{"internalType":"uint256","name":"originationFee","type":"uint256"},{"internalType":"uint256","name":"variableBorrowIndex","type":"uint256"},{"internalType":"uint256","name":"lastUpdateTimestamp","type":"uint256"},{"internalType":"bool","name":"usageAsCollateralEnabled","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getReserves","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"payable":false,"stateMutability":"view","type":"function"}], + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_reserve", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_borrowRateMode", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_borrowRate", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_originationFee", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_borrowBalanceIncrease", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint16", + "name": "_referral", + "type": "uint16" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_timestamp", + "type": "uint256" + } + ], + "name": "Borrow", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_reserve", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint16", + "name": "_referral", + "type": "uint16" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_timestamp", + "type": "uint256" + } + ], + "name": "Deposit", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_target", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_reserve", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_totalFee", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_protocolFee", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_timestamp", + "type": "uint256" + } + ], + "name": "FlashLoan", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_collateral", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_reserve", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_purchaseAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_liquidatedCollateralAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_accruedBorrowInterest", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "_liquidator", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "_receiveAToken", + "type": "bool" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_timestamp", + "type": "uint256" + } + ], + "name": "LiquidationCall", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_collateral", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_reserve", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_feeLiquidated", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_liquidatedCollateralForFee", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_timestamp", + "type": "uint256" + } + ], + "name": "OriginationFeeLiquidated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_reserve", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_newStableRate", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_borrowBalanceIncrease", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_timestamp", + "type": "uint256" + } + ], + "name": "RebalanceStableBorrowRate", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_reserve", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_timestamp", + "type": "uint256" + } + ], + "name": "RedeemUnderlying", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_reserve", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_repayer", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_amountMinusFees", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_fees", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_borrowBalanceIncrease", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_timestamp", + "type": "uint256" + } + ], + "name": "Repay", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_reserve", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_user", + "type": "address" + } + ], + "name": "ReserveUsedAsCollateralDisabled", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_reserve", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_user", + "type": "address" + } + ], + "name": "ReserveUsedAsCollateralEnabled", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_reserve", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_newRateMode", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_newRate", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_borrowBalanceIncrease", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_timestamp", + "type": "uint256" + } + ], + "name": "Swap", + "type": "event" + }, + { + "constant": true, + "inputs": [], + "name": "LENDINGPOOL_REVISION", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "UINT_MAX_VALUE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "addressesProvider", + "outputs": [ + { + "internalType": "contract LendingPoolAddressesProvider", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "core", + "outputs": [ + { + "internalType": "contract LendingPoolCore", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "dataProvider", + "outputs": [ + { + "internalType": "contract LendingPoolDataProvider", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "parametersProvider", + "outputs": [ + { + "internalType": "contract LendingPoolParametersProvider", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract LendingPoolAddressesProvider", + "name": "_addressesProvider", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_reserve", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + }, + { + "internalType": "uint16", + "name": "_referralCode", + "type": "uint16" + } + ], + "name": "deposit", + "outputs": [], + "payable": true, + "stateMutability": "payable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_reserve", + "type": "address" + }, + { + "internalType": "address payable", + "name": "_user", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_aTokenBalanceAfterRedeem", + "type": "uint256" + } + ], + "name": "redeemUnderlying", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_reserve", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_interestRateMode", + "type": "uint256" + }, + { + "internalType": "uint16", + "name": "_referralCode", + "type": "uint16" + } + ], + "name": "borrow", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_reserve", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + }, + { + "internalType": "address payable", + "name": "_onBehalfOf", + "type": "address" + } + ], + "name": "repay", + "outputs": [], + "payable": true, + "stateMutability": "payable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_reserve", + "type": "address" + } + ], + "name": "swapBorrowRateMode", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_reserve", + "type": "address" + }, + { + "internalType": "address", + "name": "_user", + "type": "address" + } + ], + "name": "rebalanceStableBorrowRate", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_reserve", + "type": "address" + }, + { + "internalType": "bool", + "name": "_useAsCollateral", + "type": "bool" + } + ], + "name": "setUserUseReserveAsCollateral", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_collateral", + "type": "address" + }, + { + "internalType": "address", + "name": "_reserve", + "type": "address" + }, + { + "internalType": "address", + "name": "_user", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_purchaseAmount", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "_receiveAToken", + "type": "bool" + } + ], + "name": "liquidationCall", + "outputs": [], + "payable": true, + "stateMutability": "payable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_receiver", + "type": "address" + }, + { + "internalType": "address", + "name": "_reserve", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "_params", + "type": "bytes" + } + ], + "name": "flashLoan", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "_reserve", + "type": "address" + } + ], + "name": "getReserveConfigurationData", + "outputs": [ + { + "internalType": "uint256", + "name": "ltv", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "liquidationThreshold", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "liquidationBonus", + "type": "uint256" + }, + { + "internalType": "address", + "name": "interestRateStrategyAddress", + "type": "address" + }, + { + "internalType": "bool", + "name": "usageAsCollateralEnabled", + "type": "bool" + }, + { + "internalType": "bool", + "name": "borrowingEnabled", + "type": "bool" + }, + { + "internalType": "bool", + "name": "stableBorrowRateEnabled", + "type": "bool" + }, + { + "internalType": "bool", + "name": "isActive", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "_reserve", + "type": "address" + } + ], + "name": "getReserveData", + "outputs": [ + { + "internalType": "uint256", + "name": "totalLiquidity", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "availableLiquidity", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalBorrowsStable", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalBorrowsVariable", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "liquidityRate", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "variableBorrowRate", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "stableBorrowRate", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "averageStableBorrowRate", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "utilizationRate", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "liquidityIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "variableBorrowIndex", + "type": "uint256" + }, + { + "internalType": "address", + "name": "aTokenAddress", + "type": "address" + }, + { + "internalType": "uint40", + "name": "lastUpdateTimestamp", + "type": "uint40" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "_user", + "type": "address" + } + ], + "name": "getUserAccountData", + "outputs": [ + { + "internalType": "uint256", + "name": "totalLiquidityETH", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalCollateralETH", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalBorrowsETH", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalFeesETH", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "availableBorrowsETH", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "currentLiquidationThreshold", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "ltv", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "healthFactor", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "_reserve", + "type": "address" + }, + { + "internalType": "address", + "name": "_user", + "type": "address" + } + ], + "name": "getUserReserveData", + "outputs": [ + { + "internalType": "uint256", + "name": "currentATokenBalance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "currentBorrowBalance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "principalBorrowBalance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowRateMode", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowRate", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "liquidityRate", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "originationFee", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "variableBorrowIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lastUpdateTimestamp", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "usageAsCollateralEnabled", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getReserves", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + } + ], "bytecode": "0x60806040526000600181815590556146908061001c6000396000f3fe6080604052600436106101295760003560e01c80638afaff02116100ab578063c72c4d101161006f578063c72c4d1014610664578063c858f5f914610679578063cd112382146106c2578063d0fc81d2146106fd578063d2d0e06614610712578063f2f4eb261461074857610129565b80638afaff02146105385780639895e3d81461055f578063b334ed86146105a8578063bf92857c146105bd578063c4d66de81461063157610129565b806348ca1300116100f257806348ca13001461039057806358707e06146103c35780635a3b74b9146103f45780635ceae9c41461042f5780635cffe9de1461046557610129565b8062a718a91461012e5780630902f1ac1461017457806328dd2d01146101d957806335ea6a75146102665780633e1501411461030e575b600080fd5b610172600480360360a081101561014457600080fd5b506001600160a01b03813581169160208101358216916040820135169060608101359060800135151561075d565b005b34801561018057600080fd5b50610189610b72565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156101c55781810151838201526020016101ad565b505050509050019250505060405180910390f35b3480156101e557600080fd5b50610214600480360360408110156101fc57600080fd5b506001600160a01b0381358116916020013516610c85565b604080519a8b5260208b0199909952898901979097526060890195909552608088019390935260a087019190915260c086015260e0850152610100840152151561012083015251908190036101400190f35b34801561027257600080fd5b506102996004803603602081101561028957600080fd5b50356001600160a01b0316610da6565b604080519d8e5260208e019c909c528c8c019a909a5260608c019890985260808b019690965260a08a019490945260c089019290925260e08801526101008701526101208601526101408501526001600160a01b031661016084015264ffffffffff1661018083015251908190036101a00190f35b34801561031a57600080fd5b506103416004803603602081101561033157600080fd5b50356001600160a01b0316610f05565b604080519889526020890197909752878701959095526001600160a01b0390931660608701529015156080860152151560a0850152151560c0840152151560e083015251908190036101000190f35b34801561039c57600080fd5b50610172600480360360208110156103b357600080fd5b50356001600160a01b0316610fee565b3480156103cf57600080fd5b506103d86113b0565b604080516001600160a01b039092168252519081900360200190f35b34801561040057600080fd5b506101726004803603604081101561041757600080fd5b506001600160a01b03813516906020013515156113bf565b6101726004803603606081101561044557600080fd5b506001600160a01b03813581169160208101359160409091013516611697565b34801561047157600080fd5b506101726004803603608081101561048857600080fd5b6001600160a01b038235811692602081013590911691604082013591908101906080810160608201356401000000008111156104c357600080fd5b8201836020820111156104d557600080fd5b803590602001918460018302840111640100000000831117156104f757600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550611e92945050505050565b34801561054457600080fd5b5061054d6124af565b60408051918252519081900360200190f35b34801561056b57600080fd5b506101726004803603608081101561058257600080fd5b506001600160a01b038135811691602081013590911690604081013590606001356124b4565b3480156105b457600080fd5b506103d86127d5565b3480156105c957600080fd5b506105f0600480360360208110156105e057600080fd5b50356001600160a01b03166127e4565b604080519889526020890197909752878701959095526060870193909352608086019190915260a085015260c084015260e083015251908190036101000190f35b34801561063d57600080fd5b506101726004803603602081101561065457600080fd5b50356001600160a01b031661285c565b34801561067057600080fd5b506103d8612b30565b34801561068557600080fd5b506101726004803603608081101561069c57600080fd5b5080356001600160a01b0316906020810135906040810135906060013561ffff16612b3f565b3480156106ce57600080fd5b50610172600480360360408110156106e557600080fd5b506001600160a01b038135811691602001351661343a565b34801561070957600080fd5b5061054d613986565b6101726004803603606081101561072857600080fd5b5080356001600160a01b0316906020810135906040013561ffff1661398c565b34801561075457600080fd5b506103d8613c9c565b60008054600101908190558461077281613cab565b8661077c81613cab565b60355460408051632c1a75cd60e11b815290516000926001600160a01b031691635834eb9a916004808301926020929190829003018186803b1580156107c157600080fd5b505afa1580156107d5573d6000803e3d6000fd5b505050506040513d60208110156107eb57600080fd5b5051604080516001600160a01b038c811660248301528b811660448301528a81166064830152608482018a905288151560a4808401919091528351808403909101815260c490920183526020820180516001600160e01b031662a718a960e01b17815292518251949550600094606094928716939282918083835b602083106108855780518252601f199092019160209182019101610866565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d80600081146108e5576040519150601f19603f3d011682016040523d82523d6000602084013e6108ea565b606091505b509150915081610941576040805162461bcd60e51b815260206004820152601760248201527f4c69717569646174696f6e2063616c6c206661696c6564000000000000000000604482015290519081900360640190fd5b6000606082806020019051604081101561095a57600080fd5b81516020830180516040519294929383019291908464010000000082111561098157600080fd5b90830190602082018581111561099657600080fd5b82516401000000008111828201881017156109b057600080fd5b82525081516020918201929091019080838360005b838110156109dd5781810151838201526020016109c5565b50505050905090810190601f168015610a0a5780820380516001836020036101000a031916815260200191505b506040525050509150915081600014610b1f578060405160200180807302634b8bab4b230ba34b7b7103330b4b632b21d160651b81525060140182805190602001908083835b60208310610a6f5780518252601f199092019160209182019101610a50565b51815160209384036101000a60001901801990921691161790526040805192909401828103601f190183529384905262461bcd60e51b84526004840181815282516024860152825192965094508493604401925085019080838360005b83811015610ae4578181015183820152602001610acc565b50505050905090810190601f168015610b115780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050505050506000548114610b6a576040805162461bcd60e51b815260206004820152601f6024820152600080516020614169833981519152604482015290519081900360640190fd5b505050505050565b60365460408051630240bc6b60e21b815290516060926001600160a01b031691630902f1ac916004808301926000929190829003018186803b158015610bb757600080fd5b505afa158015610bcb573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526020811015610bf457600080fd5b8101908080516040519392919084640100000000821115610c1457600080fd5b908301906020820185811115610c2957600080fd5b8251866020820283011164010000000082111715610c4657600080fd5b82525081516020918201928201910280838360005b83811015610c73578181015183820152602001610c5b565b50505050905001604052505050905090565b603754604080516328dd2d0160e01b81526001600160a01b0385811660048301528481166024830152915160009384938493849384938493849384938493849316916328dd2d0191604480830192610140929190829003018186803b158015610ced57600080fd5b505afa158015610d01573d6000803e3d6000fd5b505050506040513d610140811015610d1857600080fd5b810190808051906020019092919080519060200190929190805190602001909291908051906020019092919080519060200190929190805190602001909291908051906020019092919080519060200190929190805190602001909291908051906020019092919050505099509950995099509950995099509950995099509295989b9194979a5092959850565b6000806000806000806000806000806000806000603760009054906101000a90046001600160a01b03166001600160a01b03166335ea6a758f6040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b031681526020019150506101a06040518083038186803b158015610e2657600080fd5b505afa158015610e3a573d6000803e3d6000fd5b505050506040513d6101a0811015610e5157600080fd5b81019080805190602001909291908051906020019092919080519060200190929190805190602001909291908051906020019092919080519060200190929190805190602001909291908051906020019092919080519060200190929190805190602001909291908051906020019092919080519060200190929190805190602001909291905050509c509c509c509c509c509c509c509c509c509c509c509c509c5091939597999b9d90929496989a9c50565b600080600080600080600080603760009054906101000a90046001600160a01b03166001600160a01b0316633e1501418a6040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b031681526020019150506101006040518083038186803b158015610f7d57600080fd5b505afa158015610f91573d6000803e3d6000fd5b505050506040513d610100811015610fa857600080fd5b508051602082015160408301516060840151608085015160a086015160c087015160e090970151959e50939c50919a509850965094509092509050919395975091939597565b60008054600101908190558161100381613cab565b8261100d81613d62565b60365460408051639fb8afcd60e01b81526001600160a01b038781166004830152336024830152915160009384938493911691639fb8afcd91604480820192606092909190829003018186803b15801561106657600080fd5b505afa15801561107a573d6000803e3d6000fd5b505050506040513d606081101561109057600080fd5b50805160208201516040909201519094509092509050816110e25760405162461bcd60e51b815260040180806020018281038252603781526020018061438f6037913960400191505060405180910390fd5b60365460408051631ca19f1960e01b81526001600160a01b038a8116600483015233602483015291516000939290921691631ca19f1991604480820192602092909190829003018186803b15801561113957600080fd5b505afa15801561114d573d6000803e3d6000fd5b505050506040513d602081101561116357600080fd5b50519050600281600281111561117557fe5b141561123c576036546040805163710ba6c360e11b81526001600160a01b038b81166004830152336024830152604482018790529151919092169163e2174d86916064808301926020929190829003018186803b1580156111d557600080fd5b505afa1580156111e9573d6000803e3d6000fd5b505050506040513d60208110156111ff57600080fd5b505161123c5760405162461bcd60e51b81526004018080602001828103825260308152602001806145c46030913960400191505060405180910390fd5b60365460405163f614831160e01b81526001600160a01b038a8116600483019081523360248401819052604484018990526064840188905260848401879052600094859493169263f6148311928e92918b918b918b918b9160a4018260028111156112a357fe5b60ff16815260200196505050505050506040805180830381600087803b1580156112cc57600080fd5b505af11580156112e0573d6000803e3d6000fd5b505050506040513d60408110156112f657600080fd5b5080516020909101519092509050336001600160a01b038b167fb3e2773606abfd36b5bd91394b3a54d1398336c65005baf7bf7a05efeffaf75b84600281111561133c57fe5b6040805191825260208201869052818101899052426060830152519081900360800190a3505050505050505060005481146113ac576040805162461bcd60e51b815260206004820152601f6024820152600080516020614169833981519152604482015290519081900360640190fd5b5050565b6038546001600160a01b031681565b6000805460010190819055826113d481613cab565b836113de81613d62565b60365460408051630c526de560e11b81526001600160a01b038881166004830152336024830152915160009392909216916318a4dbca91604480820192602092909190829003018186803b15801561143557600080fd5b505afa158015611449573d6000803e3d6000fd5b505050506040513d602081101561145f57600080fd5b505190508061149f5760405162461bcd60e51b815260040180806020018281038252602a815260200180614535602a913960400191505060405180910390fd5b603754604080516376e9d61560e01b81526001600160a01b03898116600483015233602483015260448201859052915191909216916376e9d615916064808301926020929190829003018186803b1580156114f957600080fd5b505afa15801561150d573d6000803e3d6000fd5b505050506040513d602081101561152357600080fd5b50516115605760405162461bcd60e51b815260040180806020018281038252603081526020018061422c6030913960400191505060405180910390fd5b60365460408051633e94615360e21b81526001600160a01b03898116600483015233602483015288151560448301529151919092169163fa51854c91606480830192600092919082900301818387803b1580156115bc57600080fd5b505af11580156115d0573d6000803e3d6000fd5b5050505084156116145760405133906001600160a01b038816907e058a56ea94653cdf4f152d227ace22d4c00ad99e2a43f58cb7d9e3feb295f290600090a361164b565b60405133906001600160a01b038816907f44c58d81365b66dd4b1a7f36c25aa97b8c71c361ee4937adc1a00000227db5dd90600090a35b5050506000548114611692576040805162461bcd60e51b815260206004820152601f6024820152600080516020614169833981519152604482015290519081900360640190fd5b505050565b6000805460010190819055836116ac81613cab565b836116b681613e17565b6116be61405a565b60365460408051639fb8afcd60e01b81526001600160a01b038a81166004830152888116602483015291519190921691639fb8afcd916044808301926060929190829003018186803b15801561171357600080fd5b505afa158015611727573d6000803e3d6000fd5b505050506040513d606081101561173d57600080fd5b50805160208083015160409384015185850152848201529083526036548251633faacc6b60e21b81526001600160a01b038b8116600483015289811660248301529351939091169263feab31ac92604480840193919291829003018186803b1580156117a857600080fd5b505afa1580156117bc573d6000803e3d6000fd5b505050506040513d60208110156117d257600080fd5b505160e08201526001600160a01b0387166117eb613e6c565b6001600160a01b0316146060820152602081015161183a5760405162461bcd60e51b815260040180806020018281038252602981526020018061459b6029913960400191505060405180910390fd5b600019861415806118535750336001600160a01b038616145b61188e5760405162461bcd60e51b81526004018080602001828103825260448152602001806145f46044913960600191505060405180910390fd5b60e081015160208201516118a79163ffffffff613e8416565b608082015260001986148015906118c15750806080015186105b156118ce57608081018690525b806060015115806118e3575080608001513410155b61191e5760405162461bcd60e51b81526004018080602001828103825260288152602001806142e56028913960400191505060405180910390fd5b8060e00151816080015111611b49576036546080820151604080840151815163da12d96f60e01b81526001600160a01b038c811660048301528a811660248301526000604483018190526064830195909552608482019290925260a48101849052915193169263da12d96f9260c48084019391929182900301818387803b1580156119a857600080fd5b505af11580156119bc573d6000803e3d6000fd5b505060365460608401516001600160a01b03909116925063c7d1423791506119e55760006119eb565b82608001515b89888560800151603560009054906101000a90046001600160a01b03166001600160a01b031663ee8912966040518163ffffffff1660e01b815260040160206040518083038186803b158015611a4057600080fd5b505afa158015611a54573d6000803e3d6000fd5b505050506040513d6020811015611a6a57600080fd5b5051604080516001600160e01b031960e089901b1681526001600160a01b039586166004820152938516602485015260448401929092529290921660648201529051608480830192600092919082900301818588803b158015611acc57600080fd5b505af1158015611ae0573d6000803e3d6000fd5b505050608080840151604080860151815160008152602081019390935282820152426060830152513394506001600160a01b038a811694508c16927fb718f0b14f03d8c3adf35b15e3da52421b042ac879e5a689011a8b1e0036773d928290030190a450611e46565b60e08101516080820151611b629163ffffffff613ee716565b60a0820181905260365460e08301516040808501516020860151825163da12d96f60e01b81526001600160a01b038e811660048301528c81166024830152604482018890526064820195909552608481019290925290941460a48501525191169163da12d96f9160c480830192600092919082900301818387803b158015611be957600080fd5b505af1158015611bfd573d6000803e3d6000fd5b5050505060e081015115611d315760365460608201516001600160a01b039091169063c7d1423790611c30576000611c36565b8260e001515b89888560e00151603560009054906101000a90046001600160a01b03166001600160a01b031663ee8912966040518163ffffffff1660e01b815260040160206040518083038186803b158015611c8b57600080fd5b505afa158015611c9f573d6000803e3d6000fd5b505050506040513d6020811015611cb557600080fd5b5051604080516001600160e01b031960e089901b1681526001600160a01b039586166004820152938516602485015260448401929092529290921660648201529051608480830192600092919082900301818588803b158015611d1757600080fd5b505af1158015611d2b573d6000803e3d6000fd5b50505050505b60365460608201516001600160a01b03909116906328fcf4d390611d56576000611d6c565b60e0830151611d6c90349063ffffffff613ee716565b60a0840151604080516001600160e01b031960e086901b1681526001600160a01b038d166004820152336024820152604481019290925251606480830192600092919082900301818588803b158015611dc457600080fd5b505af1158015611dd8573d6000803e3d6000fd5b50505060a083015160e08401516040808601518151938452602084019290925282810191909152426060830152513393506001600160a01b0389811693508b16917fb718f0b14f03d8c3adf35b15e3da52421b042ac879e5a689011a8b1e0036773d919081900360800190a4505b50506000548114611e8c576040805162461bcd60e51b815260206004820152601f6024820152600080516020614169833981519152604482015290519081900360640190fd5b50505050565b600080546001019081905583611ea781613cab565b83611eb181613e17565b6000611ebb613e6c565b6001600160a01b0316876001600160a01b031614611f5157603654604080516370a0823160e01b81526001600160a01b0392831660048201529051918916916370a0823191602480820192602092909190829003018186803b158015611f2057600080fd5b505afa158015611f34573d6000803e3d6000fd5b505050506040513d6020811015611f4a57600080fd5b5051611f5f565b6036546001600160a01b0316315b905085811015611fa05760405162461bcd60e51b81526004018080602001828103825260318152602001806141896031913960400191505060405180910390fd5b60385460408051630161bfad60e61b8152815160009384936001600160a01b039091169263586feb409260048083019392829003018186803b158015611fe557600080fd5b505afa158015611ff9573d6000803e3d6000fd5b505050506040513d604081101561200f57600080fd5b508051602090910151909250905060006120416127106120358b8663ffffffff613f4416565b9063ffffffff613f9d16565b9050600061205b612710612035848663ffffffff613f4416565b905060008211801561206d5750600081115b6120a85760405162461bcd60e51b815260040180806020018281038252603281526020018061449c6032913960400191505060405180910390fd5b60008c905060008d9050603660009054906101000a90046001600160a01b03166001600160a01b031663fa93b2a58e838f6040518463ffffffff1660e01b815260040180846001600160a01b03166001600160a01b03168152602001836001600160a01b03166001600160a01b031681526020018281526020019350505050600060405180830381600087803b15801561214157600080fd5b505af1158015612155573d6000803e3d6000fd5b50505050816001600160a01b031663ee8725588e8e878f6040518563ffffffff1660e01b815260040180856001600160a01b03166001600160a01b0316815260200184815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b838110156121dc5781810151838201526020016121c4565b50505050905090810190601f1680156122095780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15801561222b57600080fd5b505af115801561223f573d6000803e3d6000fd5b50505050600061224d613e6c565b6001600160a01b03168e6001600160a01b031614612301578d6001600160a01b03166370a08231603660009054906101000a90046001600160a01b03166040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b1580156122d057600080fd5b505afa1580156122e4573d6000803e3d6000fd5b505050506040513d60208110156122fa57600080fd5b505161230f565b6036546001600160a01b0316315b9050612321888663ffffffff613e8416565b811461235e5760405162461bcd60e51b815260040180806020018281038252603281526020018061435d6032913960400191505060405180910390fd5b6036546001600160a01b03166309ac29538f8a612381898963ffffffff613ee716565b886040518563ffffffff1660e01b815260040180856001600160a01b03166001600160a01b03168152602001848152602001838152602001828152602001945050505050600060405180830381600087803b1580156123df57600080fd5b505af11580156123f3573d6000803e3d6000fd5b505050508d6001600160a01b03168f6001600160a01b03167f5b8f46461c1dd69fb968f1a003acee221ea3e19540e350233b612ddb43433b558f8888426040518085815260200184815260200183815260200182815260200194505050505060405180910390a35050505050505050505060005481146124a8576040805162461bcd60e51b815260206004820152601f6024820152600080516020614169833981519152604482015290519081900360640190fd5b5050505050565b600281565b600080546001019081905560365460408051631a59df7760e11b81526001600160a01b0380891660048301529151889392909216916334b3beee91602480820192602092909190829003018186803b15801561250f57600080fd5b505afa158015612523573d6000803e3d6000fd5b505050506040513d602081101561253957600080fd5b50516001600160a01b031633146125815760405162461bcd60e51b815260040180806020018281038252604b8152602001806143fa604b913960600191505060405180910390fd5b8561258b81613cab565b8461259581613e17565b6036546040805163e240301960e01b81526001600160a01b038b811660048301529151600093929092169163e240301991602480820192602092909190829003018186803b1580156125e657600080fd5b505afa1580156125fa573d6000803e3d6000fd5b505050506040513d602081101561261057600080fd5b50519050868110156126535760405162461bcd60e51b81526004018080602001828103825260318152602001806142806031913960400191505060405180910390fd5b6036546040805163afcdbea360e01b81526001600160a01b038c811660048301528b81166024830152604482018b9052891560648301529151919092169163afcdbea391608480830192600092919082900301818387803b1580156126b757600080fd5b505af11580156126cb573d6000803e3d6000fd5b50506036546040805163fa93b2a560e01b81526001600160a01b038e811660048301528d81166024830152604482018d9052915191909216935063fa93b2a59250606480830192600092919082900301818387803b15801561272c57600080fd5b505af1158015612740573d6000803e3d6000fd5b5050604080518a815242602082015281516001600160a01b03808e1695508e1693507f9c4ed599cd8555b9c1e8cd7643240d7d71eb76b792948c49fcb4d411f7b6b3c6929181900390910190a35050505060005481146124a8576040805162461bcd60e51b815260206004820152601f6024820152600080516020614169833981519152604482015290519081900360640190fd5b6037546001600160a01b031681565b600080600080600080600080603760009054906101000a90046001600160a01b03166001600160a01b031663bf92857c8a6040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b031681526020019150506101006040518083038186803b158015610f7d57600080fd5b6000612866614007565b60025490915060ff168061287d575061287d61400c565b80612889575060015481115b6128c45760405162461bcd60e51b815260040180806020018281038252602e8152602001806144ce602e913960400191505060405180910390fd5b60025460ff161580156128e5576002805460ff191660019081179091558290555b603580546001600160a01b0319166001600160a01b0385811691909117918290556040805163076b7fbb60e51b81529051929091169163ed6ff76091600480820192602092909190829003018186803b15801561294157600080fd5b505afa158015612955573d6000803e3d6000fd5b505050506040513d602081101561296b57600080fd5b5051603680546001600160a01b0319166001600160a01b0392831617905560355460408051632f58b80d60e01b815290519190921691632f58b80d916004808301926020929190829003018186803b1580156129c657600080fd5b505afa1580156129da573d6000803e3d6000fd5b505050506040513d60208110156129f057600080fd5b5051603780546001600160a01b0319166001600160a01b03928316179055603554604080516302030ec760e11b8152905191909216916304061d8e916004808301926020929190829003018186803b158015612a4b57600080fd5b505afa158015612a5f573d6000803e3d6000fd5b505050506040513d6020811015612a7557600080fd5b5051603880546001600160a01b0319166001600160a01b0392831617905560355460408051633efbbf0f60e21b81529051919092169163fbeefc3c916004808301926020929190829003018186803b158015612ad057600080fd5b505afa158015612ae4573d6000803e3d6000fd5b505050506040513d6020811015612afa57600080fd5b5051603980546001600160a01b0319166001600160a01b039092169190911790558015611692576002805460ff19169055505050565b6035546001600160a01b031681565b600080546001019081905584612b5481613cab565b85612b5e81613d62565b85612b6881613e17565b612b706140a1565b60365460408051632e79732b60e11b81526001600160a01b038c8116600483015291519190921691635cf2e656916024808301926020929190829003018186803b158015612bbd57600080fd5b505afa158015612bd1573d6000803e3d6000fd5b505050506040513d6020811015612be757600080fd5b5051612c245760405162461bcd60e51b815260040180806020018281038252602481526020018061425c6024913960400191505060405180910390fd5b8660021480612c335750866001145b612c6e5760405162461bcd60e51b81526004018080602001828103825260238152602001806141ba6023913960400191505060405180910390fd5b866002811115612c7a57fe5b816101c001906002811115612c8b57fe5b90816002811115612c9857fe5b9052506036546040805163e240301960e01b81526001600160a01b038c811660048301529151919092169163e2403019916024808301926020929190829003018186803b158015612ce857600080fd5b505afa158015612cfc573d6000803e3d6000fd5b505050506040513d6020811015612d1257600080fd5b50516101608201819052881115612d5a5760405162461bcd60e51b81526004018080602001828103825260368152602001806144666036913960400191505060405180910390fd5b60375460408051632c6d0e9b60e01b815233600482015290516001600160a01b0390921691632c6d0e9b9160248082019261010092909190829003018186803b158015612da657600080fd5b505afa158015612dba573d6000803e3d6000fd5b505050506040513d610100811015612dd157600080fd5b506020808201516040808401516060850151608086015160a087015160e09788015115156101e08a015293880193909352938601919091526101008501929092529183015260c08201819052612e6e576040805162461bcd60e51b815260206004820152601b60248201527f54686520636f6c6c61746572616c2062616c616e636520697320300000000000604482015290519081900360640190fd5b806101e0015115612eb05760405162461bcd60e51b815260040180806020018281038252603f81526020018061412a603f913960400191505060405180910390fd5b60395460408051630e563a7d60e41b8152336004820152602481018b905290516001600160a01b039092169163e563a7d091604480820192602092909190829003018186803b158015612f0257600080fd5b505afa158015612f16573d6000803e3d6000fd5b505050506040513d6020811015612f2c57600080fd5b505160608201819052612f705760405162461bcd60e51b81526004018080602001828103825260218152602001806141dd6021913960400191505060405180910390fd5b603760009054906101000a90046001600160a01b03166001600160a01b03166312737c338a8a84606001518560e0015186610100015187602001516040518763ffffffff1660e01b815260040180876001600160a01b03166001600160a01b03168152602001868152602001858152602001848152602001838152602001828152602001965050505050505060206040518083038186803b15801561301457600080fd5b505afa158015613028573d6000803e3d6000fd5b505050506040513d602081101561303e57600080fd5b505160a0820181905260c082015110156130895760405162461bcd60e51b81526004018080602001828103825260348152602001806143c66034913960400191505060405180910390fd5b6001816101c00151600281111561309c57fe5b141561323b576036546040805163710ba6c360e11b81526001600160a01b038c81166004830152336024830152604482018c90529151919092169163e2174d86916064808301926020929190829003018186803b1580156130fc57600080fd5b505afa158015613110573d6000803e3d6000fd5b505050506040513d602081101561312657600080fd5b50516131635760405162461bcd60e51b81526004018080602001828103825260398152602001806144fc6039913960400191505060405180910390fd5b603854604080516335adc96b60e21b815290516000926001600160a01b03169163d6b725ac916004808301926020929190829003018186803b1580156131a857600080fd5b505afa1580156131bc573d6000803e3d6000fd5b505050506040513d60208110156131d257600080fd5b50516101608301519091506000906131f790606490612035908563ffffffff613f4416565b9050808a11156132385760405162461bcd60e51b815260040180806020018281038252603c81526020018061455f603c913960400191505060405180910390fd5b50505b60365460608201516101c0830151604051630deb1bf960e21b81526001600160a01b038d8116600483019081523360248401819052604484018f90526064840186905291909516946337ac6fe4948f9492938f939192906084018260028111156132a157fe5b60ff168152602001955050505050506040805180830381600087803b1580156132c957600080fd5b505af11580156132dd573d6000803e3d6000fd5b505050506040513d60408110156132f357600080fd5b5080516020909101516101208301526101a08201526036546040805163fa93b2a560e01b81526001600160a01b038c81166004830152336024830152604482018c90529151919092169163fa93b2a591606480830192600092919082900301818387803b15801561336357600080fd5b505af1158015613377573d6000803e3d6000fd5b5050506101a0820151606080840151610120850151604080518e8152602081018e9052808201959095529284019190915260808301524260a08301525161ffff8916925033916001600160a01b038d16917f1e77446728e5558aa1b7e81e0cdab9cc1b075ba893b740600c76a315c2caa5539181900360c00190a45050505060005481146124a8576040805162461bcd60e51b815260206004820152601f6024820152600080516020614169833981519152604482015290519081900360640190fd5b60008054600101908190558261344f81613cab565b60365460408051639fb8afcd60e01b81526001600160a01b0387811660048301528681166024830152915160009384931691639fb8afcd916044808301926060929190829003018186803b1580156134a657600080fd5b505afa1580156134ba573d6000803e3d6000fd5b505050506040513d60608110156134d057600080fd5b50602081015160409091015190925090508161351d5760405162461bcd60e51b815260040180806020018281038252602e8152602001806141fe602e913960400191505060405180910390fd5b600160365460408051631ca19f1960e01b81526001600160a01b038a81166004830152898116602483015291519190921691631ca19f19916044808301926020929190829003018186803b15801561357457600080fd5b505afa158015613588573d6000803e3d6000fd5b505050506040513d602081101561359e57600080fd5b505160028111156135ab57fe5b146135e75760405162461bcd60e51b81526004018080602001828103825260348152602001806142b16034913960400191505060405180910390fd5b60365460408051631bffeac360e21b81526001600160a01b038981166004830152888116602483015291516000939290921691636fffab0c91604480820192602092909190829003018186803b15801561364057600080fd5b505afa158015613654573d6000803e3d6000fd5b505050506040513d602081101561366a57600080fd5b5051603654604080516362a00a4760e11b81526001600160a01b038b811660048301529151939450600093919092169163c540148e916024808301926020929190829003018186803b1580156136bf57600080fd5b505afa1580156136d3573d6000803e3d6000fd5b505050506040513d60208110156136e957600080fd5b505160365460408051631100f3b160e31b81526001600160a01b038c81166004830152915193945060009391909216916388079d88916024808301926020929190829003018186803b15801561373e57600080fd5b505afa158015613752573d6000803e3d6000fd5b505050506040513d602081101561376857600080fd5b5051603854604080516346f4f8d160e01b8152905192935060009261380a926137fd926001600160a01b03909116916346f4f8d191600480820192602092909190829003018186803b1580156137bd57600080fd5b505afa1580156137d1573d6000803e3d6000fd5b505050506040513d60208110156137e757600080fd5b50516137f1614012565b9063ffffffff613e8416565b839063ffffffff61402216565b90508284108061381957508084115b1561390a576036546040805163af825b0760e01b81526001600160a01b038d811660048301528c81166024830152604482018990529151600093929092169163af825b079160648082019260209290919082900301818787803b15801561387f57600080fd5b505af1158015613893573d6000803e3d6000fd5b505050506040513d60208110156138a957600080fd5b50516040805182815260208101899052428183015290519192506001600160a01b03808d1692908e16917f5050ad184862424ee0852d1838d355ad65bed1e5e6da67ac9a2dac1922677f60919081900360600190a350505050505050613941565b60405162461bcd60e51b815260040180806020018281038252602f81526020018061432e602f913960400191505060405180910390fd5b506000548114611692576040805162461bcd60e51b815260206004820152601f6024820152600080516020614169833981519152604482015290519081900360640190fd5b60001981565b6000805460010190819055836139a181613cab565b846139ab81613d62565b846139b581613e17565b60365460408051631a59df7760e11b81526001600160a01b038a81166004830152915160009392909216916334b3beee91602480820192602092909190829003018186803b158015613a0657600080fd5b505afa158015613a1a573d6000803e3d6000fd5b505050506040513d6020811015613a3057600080fd5b5051604080516370a0823160e01b815233600482015290519192506000916001600160a01b038416916370a08231916024808301926020929190829003018186803b158015613a7e57600080fd5b505afa158015613a92573d6000803e3d6000fd5b505050506040513d6020811015613aa857600080fd5b505160365460408051632f35bfe960e21b81526001600160a01b038d81166004830152336024830152604482018d90529315606482018190529151919450929091169163bcd6ffa491608480830192600092919082900301818387803b158015613b1157600080fd5b505af1158015613b25573d6000803e3d6000fd5b5050604080516394362e8b60e01b8152336004820152602481018c905290516001600160a01b03861693506394362e8b9250604480830192600092919082900301818387803b158015613b7757600080fd5b505af1158015613b8b573d6000803e3d6000fd5b5050603654604080516328fcf4d360e01b81526001600160a01b038e81166004830152336024830152604482018e905291519190921693506328fcf4d39250349160648082019260009290919082900301818588803b158015613bed57600080fd5b505af1158015613c01573d6000803e3d6000fd5b5050604080518c8152426020820152815161ffff8d1695503394506001600160a01b038f1693507fc12c57b1c73a2c3a2ea4613e9476abb3d8d146857aab7329e24243fb59710c82929181900390910190a450505050506000548114611e8c576040805162461bcd60e51b815260206004820152601f6024820152600080516020614169833981519152604482015290519081900360640190fd5b6036546001600160a01b031681565b60365460408051630283aeb760e11b81526001600160a01b038481166004830152915191909216916305075d6e916024808301926020929190829003018186803b158015613cf857600080fd5b505afa158015613d0c573d6000803e3d6000fd5b505050506040513d6020811015613d2257600080fd5b5051613d5f5760405162461bcd60e51b815260040180806020018281038252602181526020018061430d6021913960400191505060405180910390fd5b50565b60365460408051634a08accb60e01b81526001600160a01b03848116600483015291519190921691634a08accb916024808301926020929190829003018186803b158015613daf57600080fd5b505afa158015613dc3573d6000803e3d6000fd5b505050506040513d6020811015613dd957600080fd5b505115613d5f5760405162461bcd60e51b81526004018080602001828103825260248152602001806146386024913960400191505060405180910390fd5b60008111613d5f576040805162461bcd60e51b815260206004820152601d60248201527f416d6f756e74206d7573742062652067726561746572207468616e2030000000604482015290519081900360640190fd5b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee90565b600082820183811015613ede576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b90505b92915050565b600082821115613f3e576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b600082613f5357506000613ee1565b82820282848281613f6057fe5b0414613ede5760405162461bcd60e51b81526004018080602001828103825260218152602001806144456021913960400191505060405180910390fd5b6000808211613ff3576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b6000828481613ffe57fe5b04949350505050565b600290565b303b1590565b6b033b2e3c9fd0803ce800000090565b6000613ede6b033b2e3c9fd0803ce8000000612035614047868663ffffffff613f4416565b6b019d971e4fe8401e7400000090613e84565b604051806101000160405280600081526020016000815260200160008152602001600015158152602001600081526020016000815260200160008152602001600081525090565b60405180610200016040528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000600281111561411c57fe5b815260006020909101529056fe54686520626f72726f7765722063616e20616c7265616479206265206c69717569646174656420736f2068652063616e6e6f7420626f72726f77206d6f72655265656e7472616e637947756172643a207265656e7472616e742063616c6c005468657265206973206e6f7420656e6f756768206c697175696469747920617661696c61626c6520746f20626f72726f77496e76616c696420696e7465726573742072617465206d6f64652073656c656374656454686520616d6f756e7420746f20626f72726f7720697320746f6f20736d616c6c5573657220646f6573206e6f74206861766520616e7920626f72726f7720666f722074686973207265736572766555736572206465706f73697420697320616c7265616479206265696e67207573656420617320636f6c6c61746572616c52657365727665206973206e6f7420656e61626c656420666f7220626f72726f77696e675468657265206973206e6f7420656e6f756768206c697175696469747920617661696c61626c6520746f2072656465656d546865207573657220626f72726f77206973207661726961626c6520616e642063616e6e6f7420626520726562616c616e636564496e76616c6964206d73672e76616c75652073656e7420666f72207468652072657061796d656e74416374696f6e20726571756972657320616e206163746976652072657365727665496e746572657374207261746520726562616c616e636520636f6e646974696f6e732077657265206e6f74206d65745468652061637475616c2062616c616e6365206f66207468652070726f746f636f6c20697320696e636f6e73697374656e745573657220646f6573206e6f742068617665206120626f72726f7720696e2070726f6772657373206f6e207468697320726573657276655468657265206973206e6f7420656e6f75676820636f6c6c61746572616c20746f20636f7665722061206e657720626f72726f775468652063616c6c6572206f6620746869732066756e6374696f6e2063616e206f6e6c79206265207468652061546f6b656e20636f6e7472616374206f6620746869732072657365727665536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775468657265206973206e6f7420656e6f756768206c697175696469747920617661696c61626c6520696e2074686520726573657276655468652072657175657374656420616d6f756e7420697320746f6f20736d616c6c20666f72206120666c6173684c6f616e2e436f6e747261637420696e7374616e63652068617320616c7265616479206265656e20696e697469616c697a6564557365722063616e6e6f7420626f72726f77207468652073656c656374656420616d6f756e742077697468206120737461626c6520726174655573657220646f6573206e6f74206861766520616e79206c6971756964697479206465706f73697465645573657220697320747279696e6720746f20626f72726f7720746f6f206d756368206c6971756964697479206174206120737461626c652072617465546865207573657220646f6573206e6f74206861766520616e7920626f72726f772070656e64696e67557365722063616e6e6f7420626f72726f77207468652073656c656374656420616d6f756e7420617420737461626c65546f207265706179206f6e20626568616c66206f6620616e207573657220616e206578706c6963697420616d6f756e7420746f207265706179206973206e65656465642e416374696f6e20726571756972657320616e20756e667265657a65642072657365727665a265627a7a72315820ed59692c50e2ec9cac0b8fa26e0d00888d3764d1840be22ed0adc4e0acde245564736f6c634300050e0032", "deployedBytecode": "", "linkReferences": {}, "deployedLinkReferences": {} -} +} \ No newline at end of file diff --git a/external/abi/aave/LendingPoolAddressesProvider.json b/external/abi/aave/v1/LendingPoolAddressesProvider.json similarity index 100% rename from external/abi/aave/LendingPoolAddressesProvider.json rename to external/abi/aave/v1/LendingPoolAddressesProvider.json diff --git a/external/abi/aave/LendingPoolConfigurator.json b/external/abi/aave/v1/LendingPoolConfigurator.json similarity index 100% rename from external/abi/aave/LendingPoolConfigurator.json rename to external/abi/aave/v1/LendingPoolConfigurator.json diff --git a/external/abi/aave/LendingPoolCore.json b/external/abi/aave/v1/LendingPoolCore.json similarity index 100% rename from external/abi/aave/LendingPoolCore.json rename to external/abi/aave/v1/LendingPoolCore.json diff --git a/external/abi/aave/LendingPoolDataProvider.json b/external/abi/aave/v1/LendingPoolDataProvider.json similarity index 100% rename from external/abi/aave/LendingPoolDataProvider.json rename to external/abi/aave/v1/LendingPoolDataProvider.json diff --git a/external/abi/aave/LendingRateOracle.json b/external/abi/aave/v1/LendingRateOracle.json similarity index 100% rename from external/abi/aave/LendingRateOracle.json rename to external/abi/aave/v1/LendingRateOracle.json From 2de20eabc12110578731b5738bc165da8229fa32 Mon Sep 17 00:00:00 2001 From: alpha-guy Date: Thu, 15 Jul 2021 18:30:47 +0530 Subject: [PATCH 02/19] Move Aave V1 contracts to external/contracts/aave/v1 subfolder --- external/contracts/aave/{ => v1}/AToken.sol | 0 external/contracts/aave/{ => v1}/AaveGovernanceV2.sol | 0 external/contracts/aave/{ => v1}/AavePropositionPower.sol | 0 external/contracts/aave/{ => v1}/AaveProtoGovernance.sol | 0 external/contracts/aave/{ => v1}/AaveTokenV2Mintable.sol | 0 external/contracts/aave/{ => v1}/AssetVotingWeightProvider.sol | 0 external/contracts/aave/{ => v1}/CoreLibrary.sol | 0 .../aave/{ => v1}/DefaultReserveInterestRateStrategy.sol | 0 external/contracts/aave/{ => v1}/Executor.sol | 0 external/contracts/aave/{ => v1}/GovernanceParamsProvider.sol | 0 external/contracts/aave/{ => v1}/GovernanceStrategy.sol | 0 external/contracts/aave/{ => v1}/LendToAaveMigrator.sol | 0 external/contracts/aave/{ => v1}/LendingPool.sol | 0 external/contracts/aave/{ => v1}/LendingPoolAddressesProvider.sol | 0 external/contracts/aave/{ => v1}/LendingPoolConfigurator.sol | 0 external/contracts/aave/{ => v1}/LendingPoolCore.sol | 0 external/contracts/aave/{ => v1}/LendingPoolDataProvider.sol | 0 external/contracts/aave/{ => v1}/LendingRateOracle.sol | 0 18 files changed, 0 insertions(+), 0 deletions(-) rename external/contracts/aave/{ => v1}/AToken.sol (100%) rename external/contracts/aave/{ => v1}/AaveGovernanceV2.sol (100%) rename external/contracts/aave/{ => v1}/AavePropositionPower.sol (100%) rename external/contracts/aave/{ => v1}/AaveProtoGovernance.sol (100%) rename external/contracts/aave/{ => v1}/AaveTokenV2Mintable.sol (100%) rename external/contracts/aave/{ => v1}/AssetVotingWeightProvider.sol (100%) rename external/contracts/aave/{ => v1}/CoreLibrary.sol (100%) rename external/contracts/aave/{ => v1}/DefaultReserveInterestRateStrategy.sol (100%) rename external/contracts/aave/{ => v1}/Executor.sol (100%) rename external/contracts/aave/{ => v1}/GovernanceParamsProvider.sol (100%) rename external/contracts/aave/{ => v1}/GovernanceStrategy.sol (100%) rename external/contracts/aave/{ => v1}/LendToAaveMigrator.sol (100%) rename external/contracts/aave/{ => v1}/LendingPool.sol (100%) rename external/contracts/aave/{ => v1}/LendingPoolAddressesProvider.sol (100%) rename external/contracts/aave/{ => v1}/LendingPoolConfigurator.sol (100%) rename external/contracts/aave/{ => v1}/LendingPoolCore.sol (100%) rename external/contracts/aave/{ => v1}/LendingPoolDataProvider.sol (100%) rename external/contracts/aave/{ => v1}/LendingRateOracle.sol (100%) diff --git a/external/contracts/aave/AToken.sol b/external/contracts/aave/v1/AToken.sol similarity index 100% rename from external/contracts/aave/AToken.sol rename to external/contracts/aave/v1/AToken.sol diff --git a/external/contracts/aave/AaveGovernanceV2.sol b/external/contracts/aave/v1/AaveGovernanceV2.sol similarity index 100% rename from external/contracts/aave/AaveGovernanceV2.sol rename to external/contracts/aave/v1/AaveGovernanceV2.sol diff --git a/external/contracts/aave/AavePropositionPower.sol b/external/contracts/aave/v1/AavePropositionPower.sol similarity index 100% rename from external/contracts/aave/AavePropositionPower.sol rename to external/contracts/aave/v1/AavePropositionPower.sol diff --git a/external/contracts/aave/AaveProtoGovernance.sol b/external/contracts/aave/v1/AaveProtoGovernance.sol similarity index 100% rename from external/contracts/aave/AaveProtoGovernance.sol rename to external/contracts/aave/v1/AaveProtoGovernance.sol diff --git a/external/contracts/aave/AaveTokenV2Mintable.sol b/external/contracts/aave/v1/AaveTokenV2Mintable.sol similarity index 100% rename from external/contracts/aave/AaveTokenV2Mintable.sol rename to external/contracts/aave/v1/AaveTokenV2Mintable.sol diff --git a/external/contracts/aave/AssetVotingWeightProvider.sol b/external/contracts/aave/v1/AssetVotingWeightProvider.sol similarity index 100% rename from external/contracts/aave/AssetVotingWeightProvider.sol rename to external/contracts/aave/v1/AssetVotingWeightProvider.sol diff --git a/external/contracts/aave/CoreLibrary.sol b/external/contracts/aave/v1/CoreLibrary.sol similarity index 100% rename from external/contracts/aave/CoreLibrary.sol rename to external/contracts/aave/v1/CoreLibrary.sol diff --git a/external/contracts/aave/DefaultReserveInterestRateStrategy.sol b/external/contracts/aave/v1/DefaultReserveInterestRateStrategy.sol similarity index 100% rename from external/contracts/aave/DefaultReserveInterestRateStrategy.sol rename to external/contracts/aave/v1/DefaultReserveInterestRateStrategy.sol diff --git a/external/contracts/aave/Executor.sol b/external/contracts/aave/v1/Executor.sol similarity index 100% rename from external/contracts/aave/Executor.sol rename to external/contracts/aave/v1/Executor.sol diff --git a/external/contracts/aave/GovernanceParamsProvider.sol b/external/contracts/aave/v1/GovernanceParamsProvider.sol similarity index 100% rename from external/contracts/aave/GovernanceParamsProvider.sol rename to external/contracts/aave/v1/GovernanceParamsProvider.sol diff --git a/external/contracts/aave/GovernanceStrategy.sol b/external/contracts/aave/v1/GovernanceStrategy.sol similarity index 100% rename from external/contracts/aave/GovernanceStrategy.sol rename to external/contracts/aave/v1/GovernanceStrategy.sol diff --git a/external/contracts/aave/LendToAaveMigrator.sol b/external/contracts/aave/v1/LendToAaveMigrator.sol similarity index 100% rename from external/contracts/aave/LendToAaveMigrator.sol rename to external/contracts/aave/v1/LendToAaveMigrator.sol diff --git a/external/contracts/aave/LendingPool.sol b/external/contracts/aave/v1/LendingPool.sol similarity index 100% rename from external/contracts/aave/LendingPool.sol rename to external/contracts/aave/v1/LendingPool.sol diff --git a/external/contracts/aave/LendingPoolAddressesProvider.sol b/external/contracts/aave/v1/LendingPoolAddressesProvider.sol similarity index 100% rename from external/contracts/aave/LendingPoolAddressesProvider.sol rename to external/contracts/aave/v1/LendingPoolAddressesProvider.sol diff --git a/external/contracts/aave/LendingPoolConfigurator.sol b/external/contracts/aave/v1/LendingPoolConfigurator.sol similarity index 100% rename from external/contracts/aave/LendingPoolConfigurator.sol rename to external/contracts/aave/v1/LendingPoolConfigurator.sol diff --git a/external/contracts/aave/LendingPoolCore.sol b/external/contracts/aave/v1/LendingPoolCore.sol similarity index 100% rename from external/contracts/aave/LendingPoolCore.sol rename to external/contracts/aave/v1/LendingPoolCore.sol diff --git a/external/contracts/aave/LendingPoolDataProvider.sol b/external/contracts/aave/v1/LendingPoolDataProvider.sol similarity index 100% rename from external/contracts/aave/LendingPoolDataProvider.sol rename to external/contracts/aave/v1/LendingPoolDataProvider.sol diff --git a/external/contracts/aave/LendingRateOracle.sol b/external/contracts/aave/v1/LendingRateOracle.sol similarity index 100% rename from external/contracts/aave/LendingRateOracle.sol rename to external/contracts/aave/v1/LendingRateOracle.sol From f903b4bb244578dfb05c2411f77c3c4afabc4738 Mon Sep 17 00:00:00 2001 From: alpha-guy Date: Thu, 15 Jul 2021 18:35:27 +0530 Subject: [PATCH 03/19] Remove unnecessary diff --- external/abi/aave/v1/LendingPool.json | 1060 +------------------------ 1 file changed, 1 insertion(+), 1059 deletions(-) diff --git a/external/abi/aave/v1/LendingPool.json b/external/abi/aave/v1/LendingPool.json index 5ad04d9db..5e9e2c32f 100644 --- a/external/abi/aave/v1/LendingPool.json +++ b/external/abi/aave/v1/LendingPool.json @@ -1,1064 +1,6 @@ { "contractName": "LendingPool", - "abi": [ - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "_reserve", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "_user", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_borrowRateMode", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_borrowRate", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_originationFee", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_borrowBalanceIncrease", - "type": "uint256" - }, - { - "indexed": true, - "internalType": "uint16", - "name": "_referral", - "type": "uint16" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_timestamp", - "type": "uint256" - } - ], - "name": "Borrow", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "_reserve", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "_user", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - }, - { - "indexed": true, - "internalType": "uint16", - "name": "_referral", - "type": "uint16" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_timestamp", - "type": "uint256" - } - ], - "name": "Deposit", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "_target", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "_reserve", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_totalFee", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_protocolFee", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_timestamp", - "type": "uint256" - } - ], - "name": "FlashLoan", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "_collateral", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "_reserve", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "_user", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_purchaseAmount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_liquidatedCollateralAmount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_accruedBorrowInterest", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "address", - "name": "_liquidator", - "type": "address" - }, - { - "indexed": false, - "internalType": "bool", - "name": "_receiveAToken", - "type": "bool" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_timestamp", - "type": "uint256" - } - ], - "name": "LiquidationCall", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "_collateral", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "_reserve", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "_user", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_feeLiquidated", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_liquidatedCollateralForFee", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_timestamp", - "type": "uint256" - } - ], - "name": "OriginationFeeLiquidated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "_reserve", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "_user", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_newStableRate", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_borrowBalanceIncrease", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_timestamp", - "type": "uint256" - } - ], - "name": "RebalanceStableBorrowRate", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "_reserve", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "_user", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_timestamp", - "type": "uint256" - } - ], - "name": "RedeemUnderlying", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "_reserve", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "_user", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "_repayer", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_amountMinusFees", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_fees", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_borrowBalanceIncrease", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_timestamp", - "type": "uint256" - } - ], - "name": "Repay", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "_reserve", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "_user", - "type": "address" - } - ], - "name": "ReserveUsedAsCollateralDisabled", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "_reserve", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "_user", - "type": "address" - } - ], - "name": "ReserveUsedAsCollateralEnabled", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "_reserve", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "_user", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_newRateMode", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_newRate", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_borrowBalanceIncrease", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_timestamp", - "type": "uint256" - } - ], - "name": "Swap", - "type": "event" - }, - { - "constant": true, - "inputs": [], - "name": "LENDINGPOOL_REVISION", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "UINT_MAX_VALUE", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "addressesProvider", - "outputs": [ - { - "internalType": "contract LendingPoolAddressesProvider", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "core", - "outputs": [ - { - "internalType": "contract LendingPoolCore", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "dataProvider", - "outputs": [ - { - "internalType": "contract LendingPoolDataProvider", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "parametersProvider", - "outputs": [ - { - "internalType": "contract LendingPoolParametersProvider", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "contract LendingPoolAddressesProvider", - "name": "_addressesProvider", - "type": "address" - } - ], - "name": "initialize", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "_reserve", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - }, - { - "internalType": "uint16", - "name": "_referralCode", - "type": "uint16" - } - ], - "name": "deposit", - "outputs": [], - "payable": true, - "stateMutability": "payable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "_reserve", - "type": "address" - }, - { - "internalType": "address payable", - "name": "_user", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_aTokenBalanceAfterRedeem", - "type": "uint256" - } - ], - "name": "redeemUnderlying", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "_reserve", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_interestRateMode", - "type": "uint256" - }, - { - "internalType": "uint16", - "name": "_referralCode", - "type": "uint16" - } - ], - "name": "borrow", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "_reserve", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - }, - { - "internalType": "address payable", - "name": "_onBehalfOf", - "type": "address" - } - ], - "name": "repay", - "outputs": [], - "payable": true, - "stateMutability": "payable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "_reserve", - "type": "address" - } - ], - "name": "swapBorrowRateMode", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "_reserve", - "type": "address" - }, - { - "internalType": "address", - "name": "_user", - "type": "address" - } - ], - "name": "rebalanceStableBorrowRate", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "_reserve", - "type": "address" - }, - { - "internalType": "bool", - "name": "_useAsCollateral", - "type": "bool" - } - ], - "name": "setUserUseReserveAsCollateral", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "_collateral", - "type": "address" - }, - { - "internalType": "address", - "name": "_reserve", - "type": "address" - }, - { - "internalType": "address", - "name": "_user", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_purchaseAmount", - "type": "uint256" - }, - { - "internalType": "bool", - "name": "_receiveAToken", - "type": "bool" - } - ], - "name": "liquidationCall", - "outputs": [], - "payable": true, - "stateMutability": "payable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "_receiver", - "type": "address" - }, - { - "internalType": "address", - "name": "_reserve", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "_params", - "type": "bytes" - } - ], - "name": "flashLoan", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "_reserve", - "type": "address" - } - ], - "name": "getReserveConfigurationData", - "outputs": [ - { - "internalType": "uint256", - "name": "ltv", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "liquidationThreshold", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "liquidationBonus", - "type": "uint256" - }, - { - "internalType": "address", - "name": "interestRateStrategyAddress", - "type": "address" - }, - { - "internalType": "bool", - "name": "usageAsCollateralEnabled", - "type": "bool" - }, - { - "internalType": "bool", - "name": "borrowingEnabled", - "type": "bool" - }, - { - "internalType": "bool", - "name": "stableBorrowRateEnabled", - "type": "bool" - }, - { - "internalType": "bool", - "name": "isActive", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "_reserve", - "type": "address" - } - ], - "name": "getReserveData", - "outputs": [ - { - "internalType": "uint256", - "name": "totalLiquidity", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "availableLiquidity", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "totalBorrowsStable", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "totalBorrowsVariable", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "liquidityRate", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "variableBorrowRate", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "stableBorrowRate", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "averageStableBorrowRate", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "utilizationRate", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "liquidityIndex", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "variableBorrowIndex", - "type": "uint256" - }, - { - "internalType": "address", - "name": "aTokenAddress", - "type": "address" - }, - { - "internalType": "uint40", - "name": "lastUpdateTimestamp", - "type": "uint40" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "_user", - "type": "address" - } - ], - "name": "getUserAccountData", - "outputs": [ - { - "internalType": "uint256", - "name": "totalLiquidityETH", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "totalCollateralETH", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "totalBorrowsETH", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "totalFeesETH", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "availableBorrowsETH", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "currentLiquidationThreshold", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "ltv", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "healthFactor", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "_reserve", - "type": "address" - }, - { - "internalType": "address", - "name": "_user", - "type": "address" - } - ], - "name": "getUserReserveData", - "outputs": [ - { - "internalType": "uint256", - "name": "currentATokenBalance", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "currentBorrowBalance", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "principalBorrowBalance", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "borrowRateMode", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "borrowRate", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "liquidityRate", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "originationFee", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "variableBorrowIndex", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "lastUpdateTimestamp", - "type": "uint256" - }, - { - "internalType": "bool", - "name": "usageAsCollateralEnabled", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "getReserves", - "outputs": [ - { - "internalType": "address[]", - "name": "", - "type": "address[]" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - } - ], + "abi": [{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_reserve","type":"address"},{"indexed":true,"internalType":"address","name":"_user","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_borrowRateMode","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_borrowRate","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_originationFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_borrowBalanceIncrease","type":"uint256"},{"indexed":true,"internalType":"uint16","name":"_referral","type":"uint16"},{"indexed":false,"internalType":"uint256","name":"_timestamp","type":"uint256"}],"name":"Borrow","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_reserve","type":"address"},{"indexed":true,"internalType":"address","name":"_user","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":true,"internalType":"uint16","name":"_referral","type":"uint16"},{"indexed":false,"internalType":"uint256","name":"_timestamp","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_target","type":"address"},{"indexed":true,"internalType":"address","name":"_reserve","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_totalFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_protocolFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_timestamp","type":"uint256"}],"name":"FlashLoan","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_collateral","type":"address"},{"indexed":true,"internalType":"address","name":"_reserve","type":"address"},{"indexed":true,"internalType":"address","name":"_user","type":"address"},{"indexed":false,"internalType":"uint256","name":"_purchaseAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_liquidatedCollateralAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_accruedBorrowInterest","type":"uint256"},{"indexed":false,"internalType":"address","name":"_liquidator","type":"address"},{"indexed":false,"internalType":"bool","name":"_receiveAToken","type":"bool"},{"indexed":false,"internalType":"uint256","name":"_timestamp","type":"uint256"}],"name":"LiquidationCall","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_collateral","type":"address"},{"indexed":true,"internalType":"address","name":"_reserve","type":"address"},{"indexed":true,"internalType":"address","name":"_user","type":"address"},{"indexed":false,"internalType":"uint256","name":"_feeLiquidated","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_liquidatedCollateralForFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_timestamp","type":"uint256"}],"name":"OriginationFeeLiquidated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_reserve","type":"address"},{"indexed":true,"internalType":"address","name":"_user","type":"address"},{"indexed":false,"internalType":"uint256","name":"_newStableRate","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_borrowBalanceIncrease","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_timestamp","type":"uint256"}],"name":"RebalanceStableBorrowRate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_reserve","type":"address"},{"indexed":true,"internalType":"address","name":"_user","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_timestamp","type":"uint256"}],"name":"RedeemUnderlying","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_reserve","type":"address"},{"indexed":true,"internalType":"address","name":"_user","type":"address"},{"indexed":true,"internalType":"address","name":"_repayer","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amountMinusFees","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_fees","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_borrowBalanceIncrease","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_timestamp","type":"uint256"}],"name":"Repay","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_reserve","type":"address"},{"indexed":true,"internalType":"address","name":"_user","type":"address"}],"name":"ReserveUsedAsCollateralDisabled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_reserve","type":"address"},{"indexed":true,"internalType":"address","name":"_user","type":"address"}],"name":"ReserveUsedAsCollateralEnabled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_reserve","type":"address"},{"indexed":true,"internalType":"address","name":"_user","type":"address"},{"indexed":false,"internalType":"uint256","name":"_newRateMode","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_newRate","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_borrowBalanceIncrease","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_timestamp","type":"uint256"}],"name":"Swap","type":"event"},{"constant":true,"inputs":[],"name":"LENDINGPOOL_REVISION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"UINT_MAX_VALUE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"addressesProvider","outputs":[{"internalType":"contract LendingPoolAddressesProvider","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"core","outputs":[{"internalType":"contract LendingPoolCore","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"dataProvider","outputs":[{"internalType":"contract LendingPoolDataProvider","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"parametersProvider","outputs":[{"internalType":"contract LendingPoolParametersProvider","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"contract LendingPoolAddressesProvider","name":"_addressesProvider","type":"address"}],"name":"initialize","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_reserve","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint16","name":"_referralCode","type":"uint16"}],"name":"deposit","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_reserve","type":"address"},{"internalType":"address payable","name":"_user","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_aTokenBalanceAfterRedeem","type":"uint256"}],"name":"redeemUnderlying","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_reserve","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_interestRateMode","type":"uint256"},{"internalType":"uint16","name":"_referralCode","type":"uint16"}],"name":"borrow","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_reserve","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address payable","name":"_onBehalfOf","type":"address"}],"name":"repay","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_reserve","type":"address"}],"name":"swapBorrowRateMode","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_reserve","type":"address"},{"internalType":"address","name":"_user","type":"address"}],"name":"rebalanceStableBorrowRate","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_reserve","type":"address"},{"internalType":"bool","name":"_useAsCollateral","type":"bool"}],"name":"setUserUseReserveAsCollateral","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_collateral","type":"address"},{"internalType":"address","name":"_reserve","type":"address"},{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_purchaseAmount","type":"uint256"},{"internalType":"bool","name":"_receiveAToken","type":"bool"}],"name":"liquidationCall","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"address","name":"_reserve","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"bytes","name":"_params","type":"bytes"}],"name":"flashLoan","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"_reserve","type":"address"}],"name":"getReserveConfigurationData","outputs":[{"internalType":"uint256","name":"ltv","type":"uint256"},{"internalType":"uint256","name":"liquidationThreshold","type":"uint256"},{"internalType":"uint256","name":"liquidationBonus","type":"uint256"},{"internalType":"address","name":"interestRateStrategyAddress","type":"address"},{"internalType":"bool","name":"usageAsCollateralEnabled","type":"bool"},{"internalType":"bool","name":"borrowingEnabled","type":"bool"},{"internalType":"bool","name":"stableBorrowRateEnabled","type":"bool"},{"internalType":"bool","name":"isActive","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"_reserve","type":"address"}],"name":"getReserveData","outputs":[{"internalType":"uint256","name":"totalLiquidity","type":"uint256"},{"internalType":"uint256","name":"availableLiquidity","type":"uint256"},{"internalType":"uint256","name":"totalBorrowsStable","type":"uint256"},{"internalType":"uint256","name":"totalBorrowsVariable","type":"uint256"},{"internalType":"uint256","name":"liquidityRate","type":"uint256"},{"internalType":"uint256","name":"variableBorrowRate","type":"uint256"},{"internalType":"uint256","name":"stableBorrowRate","type":"uint256"},{"internalType":"uint256","name":"averageStableBorrowRate","type":"uint256"},{"internalType":"uint256","name":"utilizationRate","type":"uint256"},{"internalType":"uint256","name":"liquidityIndex","type":"uint256"},{"internalType":"uint256","name":"variableBorrowIndex","type":"uint256"},{"internalType":"address","name":"aTokenAddress","type":"address"},{"internalType":"uint40","name":"lastUpdateTimestamp","type":"uint40"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"getUserAccountData","outputs":[{"internalType":"uint256","name":"totalLiquidityETH","type":"uint256"},{"internalType":"uint256","name":"totalCollateralETH","type":"uint256"},{"internalType":"uint256","name":"totalBorrowsETH","type":"uint256"},{"internalType":"uint256","name":"totalFeesETH","type":"uint256"},{"internalType":"uint256","name":"availableBorrowsETH","type":"uint256"},{"internalType":"uint256","name":"currentLiquidationThreshold","type":"uint256"},{"internalType":"uint256","name":"ltv","type":"uint256"},{"internalType":"uint256","name":"healthFactor","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"_reserve","type":"address"},{"internalType":"address","name":"_user","type":"address"}],"name":"getUserReserveData","outputs":[{"internalType":"uint256","name":"currentATokenBalance","type":"uint256"},{"internalType":"uint256","name":"currentBorrowBalance","type":"uint256"},{"internalType":"uint256","name":"principalBorrowBalance","type":"uint256"},{"internalType":"uint256","name":"borrowRateMode","type":"uint256"},{"internalType":"uint256","name":"borrowRate","type":"uint256"},{"internalType":"uint256","name":"liquidityRate","type":"uint256"},{"internalType":"uint256","name":"originationFee","type":"uint256"},{"internalType":"uint256","name":"variableBorrowIndex","type":"uint256"},{"internalType":"uint256","name":"lastUpdateTimestamp","type":"uint256"},{"internalType":"bool","name":"usageAsCollateralEnabled","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getReserves","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"payable":false,"stateMutability":"view","type":"function"}], "bytecode": "0x60806040526000600181815590556146908061001c6000396000f3fe6080604052600436106101295760003560e01c80638afaff02116100ab578063c72c4d101161006f578063c72c4d1014610664578063c858f5f914610679578063cd112382146106c2578063d0fc81d2146106fd578063d2d0e06614610712578063f2f4eb261461074857610129565b80638afaff02146105385780639895e3d81461055f578063b334ed86146105a8578063bf92857c146105bd578063c4d66de81461063157610129565b806348ca1300116100f257806348ca13001461039057806358707e06146103c35780635a3b74b9146103f45780635ceae9c41461042f5780635cffe9de1461046557610129565b8062a718a91461012e5780630902f1ac1461017457806328dd2d01146101d957806335ea6a75146102665780633e1501411461030e575b600080fd5b610172600480360360a081101561014457600080fd5b506001600160a01b03813581169160208101358216916040820135169060608101359060800135151561075d565b005b34801561018057600080fd5b50610189610b72565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156101c55781810151838201526020016101ad565b505050509050019250505060405180910390f35b3480156101e557600080fd5b50610214600480360360408110156101fc57600080fd5b506001600160a01b0381358116916020013516610c85565b604080519a8b5260208b0199909952898901979097526060890195909552608088019390935260a087019190915260c086015260e0850152610100840152151561012083015251908190036101400190f35b34801561027257600080fd5b506102996004803603602081101561028957600080fd5b50356001600160a01b0316610da6565b604080519d8e5260208e019c909c528c8c019a909a5260608c019890985260808b019690965260a08a019490945260c089019290925260e08801526101008701526101208601526101408501526001600160a01b031661016084015264ffffffffff1661018083015251908190036101a00190f35b34801561031a57600080fd5b506103416004803603602081101561033157600080fd5b50356001600160a01b0316610f05565b604080519889526020890197909752878701959095526001600160a01b0390931660608701529015156080860152151560a0850152151560c0840152151560e083015251908190036101000190f35b34801561039c57600080fd5b50610172600480360360208110156103b357600080fd5b50356001600160a01b0316610fee565b3480156103cf57600080fd5b506103d86113b0565b604080516001600160a01b039092168252519081900360200190f35b34801561040057600080fd5b506101726004803603604081101561041757600080fd5b506001600160a01b03813516906020013515156113bf565b6101726004803603606081101561044557600080fd5b506001600160a01b03813581169160208101359160409091013516611697565b34801561047157600080fd5b506101726004803603608081101561048857600080fd5b6001600160a01b038235811692602081013590911691604082013591908101906080810160608201356401000000008111156104c357600080fd5b8201836020820111156104d557600080fd5b803590602001918460018302840111640100000000831117156104f757600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550611e92945050505050565b34801561054457600080fd5b5061054d6124af565b60408051918252519081900360200190f35b34801561056b57600080fd5b506101726004803603608081101561058257600080fd5b506001600160a01b038135811691602081013590911690604081013590606001356124b4565b3480156105b457600080fd5b506103d86127d5565b3480156105c957600080fd5b506105f0600480360360208110156105e057600080fd5b50356001600160a01b03166127e4565b604080519889526020890197909752878701959095526060870193909352608086019190915260a085015260c084015260e083015251908190036101000190f35b34801561063d57600080fd5b506101726004803603602081101561065457600080fd5b50356001600160a01b031661285c565b34801561067057600080fd5b506103d8612b30565b34801561068557600080fd5b506101726004803603608081101561069c57600080fd5b5080356001600160a01b0316906020810135906040810135906060013561ffff16612b3f565b3480156106ce57600080fd5b50610172600480360360408110156106e557600080fd5b506001600160a01b038135811691602001351661343a565b34801561070957600080fd5b5061054d613986565b6101726004803603606081101561072857600080fd5b5080356001600160a01b0316906020810135906040013561ffff1661398c565b34801561075457600080fd5b506103d8613c9c565b60008054600101908190558461077281613cab565b8661077c81613cab565b60355460408051632c1a75cd60e11b815290516000926001600160a01b031691635834eb9a916004808301926020929190829003018186803b1580156107c157600080fd5b505afa1580156107d5573d6000803e3d6000fd5b505050506040513d60208110156107eb57600080fd5b5051604080516001600160a01b038c811660248301528b811660448301528a81166064830152608482018a905288151560a4808401919091528351808403909101815260c490920183526020820180516001600160e01b031662a718a960e01b17815292518251949550600094606094928716939282918083835b602083106108855780518252601f199092019160209182019101610866565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d80600081146108e5576040519150601f19603f3d011682016040523d82523d6000602084013e6108ea565b606091505b509150915081610941576040805162461bcd60e51b815260206004820152601760248201527f4c69717569646174696f6e2063616c6c206661696c6564000000000000000000604482015290519081900360640190fd5b6000606082806020019051604081101561095a57600080fd5b81516020830180516040519294929383019291908464010000000082111561098157600080fd5b90830190602082018581111561099657600080fd5b82516401000000008111828201881017156109b057600080fd5b82525081516020918201929091019080838360005b838110156109dd5781810151838201526020016109c5565b50505050905090810190601f168015610a0a5780820380516001836020036101000a031916815260200191505b506040525050509150915081600014610b1f578060405160200180807302634b8bab4b230ba34b7b7103330b4b632b21d160651b81525060140182805190602001908083835b60208310610a6f5780518252601f199092019160209182019101610a50565b51815160209384036101000a60001901801990921691161790526040805192909401828103601f190183529384905262461bcd60e51b84526004840181815282516024860152825192965094508493604401925085019080838360005b83811015610ae4578181015183820152602001610acc565b50505050905090810190601f168015610b115780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050505050506000548114610b6a576040805162461bcd60e51b815260206004820152601f6024820152600080516020614169833981519152604482015290519081900360640190fd5b505050505050565b60365460408051630240bc6b60e21b815290516060926001600160a01b031691630902f1ac916004808301926000929190829003018186803b158015610bb757600080fd5b505afa158015610bcb573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526020811015610bf457600080fd5b8101908080516040519392919084640100000000821115610c1457600080fd5b908301906020820185811115610c2957600080fd5b8251866020820283011164010000000082111715610c4657600080fd5b82525081516020918201928201910280838360005b83811015610c73578181015183820152602001610c5b565b50505050905001604052505050905090565b603754604080516328dd2d0160e01b81526001600160a01b0385811660048301528481166024830152915160009384938493849384938493849384938493849316916328dd2d0191604480830192610140929190829003018186803b158015610ced57600080fd5b505afa158015610d01573d6000803e3d6000fd5b505050506040513d610140811015610d1857600080fd5b810190808051906020019092919080519060200190929190805190602001909291908051906020019092919080519060200190929190805190602001909291908051906020019092919080519060200190929190805190602001909291908051906020019092919050505099509950995099509950995099509950995099509295989b9194979a5092959850565b6000806000806000806000806000806000806000603760009054906101000a90046001600160a01b03166001600160a01b03166335ea6a758f6040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b031681526020019150506101a06040518083038186803b158015610e2657600080fd5b505afa158015610e3a573d6000803e3d6000fd5b505050506040513d6101a0811015610e5157600080fd5b81019080805190602001909291908051906020019092919080519060200190929190805190602001909291908051906020019092919080519060200190929190805190602001909291908051906020019092919080519060200190929190805190602001909291908051906020019092919080519060200190929190805190602001909291905050509c509c509c509c509c509c509c509c509c509c509c509c509c5091939597999b9d90929496989a9c50565b600080600080600080600080603760009054906101000a90046001600160a01b03166001600160a01b0316633e1501418a6040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b031681526020019150506101006040518083038186803b158015610f7d57600080fd5b505afa158015610f91573d6000803e3d6000fd5b505050506040513d610100811015610fa857600080fd5b508051602082015160408301516060840151608085015160a086015160c087015160e090970151959e50939c50919a509850965094509092509050919395975091939597565b60008054600101908190558161100381613cab565b8261100d81613d62565b60365460408051639fb8afcd60e01b81526001600160a01b038781166004830152336024830152915160009384938493911691639fb8afcd91604480820192606092909190829003018186803b15801561106657600080fd5b505afa15801561107a573d6000803e3d6000fd5b505050506040513d606081101561109057600080fd5b50805160208201516040909201519094509092509050816110e25760405162461bcd60e51b815260040180806020018281038252603781526020018061438f6037913960400191505060405180910390fd5b60365460408051631ca19f1960e01b81526001600160a01b038a8116600483015233602483015291516000939290921691631ca19f1991604480820192602092909190829003018186803b15801561113957600080fd5b505afa15801561114d573d6000803e3d6000fd5b505050506040513d602081101561116357600080fd5b50519050600281600281111561117557fe5b141561123c576036546040805163710ba6c360e11b81526001600160a01b038b81166004830152336024830152604482018790529151919092169163e2174d86916064808301926020929190829003018186803b1580156111d557600080fd5b505afa1580156111e9573d6000803e3d6000fd5b505050506040513d60208110156111ff57600080fd5b505161123c5760405162461bcd60e51b81526004018080602001828103825260308152602001806145c46030913960400191505060405180910390fd5b60365460405163f614831160e01b81526001600160a01b038a8116600483019081523360248401819052604484018990526064840188905260848401879052600094859493169263f6148311928e92918b918b918b918b9160a4018260028111156112a357fe5b60ff16815260200196505050505050506040805180830381600087803b1580156112cc57600080fd5b505af11580156112e0573d6000803e3d6000fd5b505050506040513d60408110156112f657600080fd5b5080516020909101519092509050336001600160a01b038b167fb3e2773606abfd36b5bd91394b3a54d1398336c65005baf7bf7a05efeffaf75b84600281111561133c57fe5b6040805191825260208201869052818101899052426060830152519081900360800190a3505050505050505060005481146113ac576040805162461bcd60e51b815260206004820152601f6024820152600080516020614169833981519152604482015290519081900360640190fd5b5050565b6038546001600160a01b031681565b6000805460010190819055826113d481613cab565b836113de81613d62565b60365460408051630c526de560e11b81526001600160a01b038881166004830152336024830152915160009392909216916318a4dbca91604480820192602092909190829003018186803b15801561143557600080fd5b505afa158015611449573d6000803e3d6000fd5b505050506040513d602081101561145f57600080fd5b505190508061149f5760405162461bcd60e51b815260040180806020018281038252602a815260200180614535602a913960400191505060405180910390fd5b603754604080516376e9d61560e01b81526001600160a01b03898116600483015233602483015260448201859052915191909216916376e9d615916064808301926020929190829003018186803b1580156114f957600080fd5b505afa15801561150d573d6000803e3d6000fd5b505050506040513d602081101561152357600080fd5b50516115605760405162461bcd60e51b815260040180806020018281038252603081526020018061422c6030913960400191505060405180910390fd5b60365460408051633e94615360e21b81526001600160a01b03898116600483015233602483015288151560448301529151919092169163fa51854c91606480830192600092919082900301818387803b1580156115bc57600080fd5b505af11580156115d0573d6000803e3d6000fd5b5050505084156116145760405133906001600160a01b038816907e058a56ea94653cdf4f152d227ace22d4c00ad99e2a43f58cb7d9e3feb295f290600090a361164b565b60405133906001600160a01b038816907f44c58d81365b66dd4b1a7f36c25aa97b8c71c361ee4937adc1a00000227db5dd90600090a35b5050506000548114611692576040805162461bcd60e51b815260206004820152601f6024820152600080516020614169833981519152604482015290519081900360640190fd5b505050565b6000805460010190819055836116ac81613cab565b836116b681613e17565b6116be61405a565b60365460408051639fb8afcd60e01b81526001600160a01b038a81166004830152888116602483015291519190921691639fb8afcd916044808301926060929190829003018186803b15801561171357600080fd5b505afa158015611727573d6000803e3d6000fd5b505050506040513d606081101561173d57600080fd5b50805160208083015160409384015185850152848201529083526036548251633faacc6b60e21b81526001600160a01b038b8116600483015289811660248301529351939091169263feab31ac92604480840193919291829003018186803b1580156117a857600080fd5b505afa1580156117bc573d6000803e3d6000fd5b505050506040513d60208110156117d257600080fd5b505160e08201526001600160a01b0387166117eb613e6c565b6001600160a01b0316146060820152602081015161183a5760405162461bcd60e51b815260040180806020018281038252602981526020018061459b6029913960400191505060405180910390fd5b600019861415806118535750336001600160a01b038616145b61188e5760405162461bcd60e51b81526004018080602001828103825260448152602001806145f46044913960600191505060405180910390fd5b60e081015160208201516118a79163ffffffff613e8416565b608082015260001986148015906118c15750806080015186105b156118ce57608081018690525b806060015115806118e3575080608001513410155b61191e5760405162461bcd60e51b81526004018080602001828103825260288152602001806142e56028913960400191505060405180910390fd5b8060e00151816080015111611b49576036546080820151604080840151815163da12d96f60e01b81526001600160a01b038c811660048301528a811660248301526000604483018190526064830195909552608482019290925260a48101849052915193169263da12d96f9260c48084019391929182900301818387803b1580156119a857600080fd5b505af11580156119bc573d6000803e3d6000fd5b505060365460608401516001600160a01b03909116925063c7d1423791506119e55760006119eb565b82608001515b89888560800151603560009054906101000a90046001600160a01b03166001600160a01b031663ee8912966040518163ffffffff1660e01b815260040160206040518083038186803b158015611a4057600080fd5b505afa158015611a54573d6000803e3d6000fd5b505050506040513d6020811015611a6a57600080fd5b5051604080516001600160e01b031960e089901b1681526001600160a01b039586166004820152938516602485015260448401929092529290921660648201529051608480830192600092919082900301818588803b158015611acc57600080fd5b505af1158015611ae0573d6000803e3d6000fd5b505050608080840151604080860151815160008152602081019390935282820152426060830152513394506001600160a01b038a811694508c16927fb718f0b14f03d8c3adf35b15e3da52421b042ac879e5a689011a8b1e0036773d928290030190a450611e46565b60e08101516080820151611b629163ffffffff613ee716565b60a0820181905260365460e08301516040808501516020860151825163da12d96f60e01b81526001600160a01b038e811660048301528c81166024830152604482018890526064820195909552608481019290925290941460a48501525191169163da12d96f9160c480830192600092919082900301818387803b158015611be957600080fd5b505af1158015611bfd573d6000803e3d6000fd5b5050505060e081015115611d315760365460608201516001600160a01b039091169063c7d1423790611c30576000611c36565b8260e001515b89888560e00151603560009054906101000a90046001600160a01b03166001600160a01b031663ee8912966040518163ffffffff1660e01b815260040160206040518083038186803b158015611c8b57600080fd5b505afa158015611c9f573d6000803e3d6000fd5b505050506040513d6020811015611cb557600080fd5b5051604080516001600160e01b031960e089901b1681526001600160a01b039586166004820152938516602485015260448401929092529290921660648201529051608480830192600092919082900301818588803b158015611d1757600080fd5b505af1158015611d2b573d6000803e3d6000fd5b50505050505b60365460608201516001600160a01b03909116906328fcf4d390611d56576000611d6c565b60e0830151611d6c90349063ffffffff613ee716565b60a0840151604080516001600160e01b031960e086901b1681526001600160a01b038d166004820152336024820152604481019290925251606480830192600092919082900301818588803b158015611dc457600080fd5b505af1158015611dd8573d6000803e3d6000fd5b50505060a083015160e08401516040808601518151938452602084019290925282810191909152426060830152513393506001600160a01b0389811693508b16917fb718f0b14f03d8c3adf35b15e3da52421b042ac879e5a689011a8b1e0036773d919081900360800190a4505b50506000548114611e8c576040805162461bcd60e51b815260206004820152601f6024820152600080516020614169833981519152604482015290519081900360640190fd5b50505050565b600080546001019081905583611ea781613cab565b83611eb181613e17565b6000611ebb613e6c565b6001600160a01b0316876001600160a01b031614611f5157603654604080516370a0823160e01b81526001600160a01b0392831660048201529051918916916370a0823191602480820192602092909190829003018186803b158015611f2057600080fd5b505afa158015611f34573d6000803e3d6000fd5b505050506040513d6020811015611f4a57600080fd5b5051611f5f565b6036546001600160a01b0316315b905085811015611fa05760405162461bcd60e51b81526004018080602001828103825260318152602001806141896031913960400191505060405180910390fd5b60385460408051630161bfad60e61b8152815160009384936001600160a01b039091169263586feb409260048083019392829003018186803b158015611fe557600080fd5b505afa158015611ff9573d6000803e3d6000fd5b505050506040513d604081101561200f57600080fd5b508051602090910151909250905060006120416127106120358b8663ffffffff613f4416565b9063ffffffff613f9d16565b9050600061205b612710612035848663ffffffff613f4416565b905060008211801561206d5750600081115b6120a85760405162461bcd60e51b815260040180806020018281038252603281526020018061449c6032913960400191505060405180910390fd5b60008c905060008d9050603660009054906101000a90046001600160a01b03166001600160a01b031663fa93b2a58e838f6040518463ffffffff1660e01b815260040180846001600160a01b03166001600160a01b03168152602001836001600160a01b03166001600160a01b031681526020018281526020019350505050600060405180830381600087803b15801561214157600080fd5b505af1158015612155573d6000803e3d6000fd5b50505050816001600160a01b031663ee8725588e8e878f6040518563ffffffff1660e01b815260040180856001600160a01b03166001600160a01b0316815260200184815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b838110156121dc5781810151838201526020016121c4565b50505050905090810190601f1680156122095780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15801561222b57600080fd5b505af115801561223f573d6000803e3d6000fd5b50505050600061224d613e6c565b6001600160a01b03168e6001600160a01b031614612301578d6001600160a01b03166370a08231603660009054906101000a90046001600160a01b03166040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b1580156122d057600080fd5b505afa1580156122e4573d6000803e3d6000fd5b505050506040513d60208110156122fa57600080fd5b505161230f565b6036546001600160a01b0316315b9050612321888663ffffffff613e8416565b811461235e5760405162461bcd60e51b815260040180806020018281038252603281526020018061435d6032913960400191505060405180910390fd5b6036546001600160a01b03166309ac29538f8a612381898963ffffffff613ee716565b886040518563ffffffff1660e01b815260040180856001600160a01b03166001600160a01b03168152602001848152602001838152602001828152602001945050505050600060405180830381600087803b1580156123df57600080fd5b505af11580156123f3573d6000803e3d6000fd5b505050508d6001600160a01b03168f6001600160a01b03167f5b8f46461c1dd69fb968f1a003acee221ea3e19540e350233b612ddb43433b558f8888426040518085815260200184815260200183815260200182815260200194505050505060405180910390a35050505050505050505060005481146124a8576040805162461bcd60e51b815260206004820152601f6024820152600080516020614169833981519152604482015290519081900360640190fd5b5050505050565b600281565b600080546001019081905560365460408051631a59df7760e11b81526001600160a01b0380891660048301529151889392909216916334b3beee91602480820192602092909190829003018186803b15801561250f57600080fd5b505afa158015612523573d6000803e3d6000fd5b505050506040513d602081101561253957600080fd5b50516001600160a01b031633146125815760405162461bcd60e51b815260040180806020018281038252604b8152602001806143fa604b913960600191505060405180910390fd5b8561258b81613cab565b8461259581613e17565b6036546040805163e240301960e01b81526001600160a01b038b811660048301529151600093929092169163e240301991602480820192602092909190829003018186803b1580156125e657600080fd5b505afa1580156125fa573d6000803e3d6000fd5b505050506040513d602081101561261057600080fd5b50519050868110156126535760405162461bcd60e51b81526004018080602001828103825260318152602001806142806031913960400191505060405180910390fd5b6036546040805163afcdbea360e01b81526001600160a01b038c811660048301528b81166024830152604482018b9052891560648301529151919092169163afcdbea391608480830192600092919082900301818387803b1580156126b757600080fd5b505af11580156126cb573d6000803e3d6000fd5b50506036546040805163fa93b2a560e01b81526001600160a01b038e811660048301528d81166024830152604482018d9052915191909216935063fa93b2a59250606480830192600092919082900301818387803b15801561272c57600080fd5b505af1158015612740573d6000803e3d6000fd5b5050604080518a815242602082015281516001600160a01b03808e1695508e1693507f9c4ed599cd8555b9c1e8cd7643240d7d71eb76b792948c49fcb4d411f7b6b3c6929181900390910190a35050505060005481146124a8576040805162461bcd60e51b815260206004820152601f6024820152600080516020614169833981519152604482015290519081900360640190fd5b6037546001600160a01b031681565b600080600080600080600080603760009054906101000a90046001600160a01b03166001600160a01b031663bf92857c8a6040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b031681526020019150506101006040518083038186803b158015610f7d57600080fd5b6000612866614007565b60025490915060ff168061287d575061287d61400c565b80612889575060015481115b6128c45760405162461bcd60e51b815260040180806020018281038252602e8152602001806144ce602e913960400191505060405180910390fd5b60025460ff161580156128e5576002805460ff191660019081179091558290555b603580546001600160a01b0319166001600160a01b0385811691909117918290556040805163076b7fbb60e51b81529051929091169163ed6ff76091600480820192602092909190829003018186803b15801561294157600080fd5b505afa158015612955573d6000803e3d6000fd5b505050506040513d602081101561296b57600080fd5b5051603680546001600160a01b0319166001600160a01b0392831617905560355460408051632f58b80d60e01b815290519190921691632f58b80d916004808301926020929190829003018186803b1580156129c657600080fd5b505afa1580156129da573d6000803e3d6000fd5b505050506040513d60208110156129f057600080fd5b5051603780546001600160a01b0319166001600160a01b03928316179055603554604080516302030ec760e11b8152905191909216916304061d8e916004808301926020929190829003018186803b158015612a4b57600080fd5b505afa158015612a5f573d6000803e3d6000fd5b505050506040513d6020811015612a7557600080fd5b5051603880546001600160a01b0319166001600160a01b0392831617905560355460408051633efbbf0f60e21b81529051919092169163fbeefc3c916004808301926020929190829003018186803b158015612ad057600080fd5b505afa158015612ae4573d6000803e3d6000fd5b505050506040513d6020811015612afa57600080fd5b5051603980546001600160a01b0319166001600160a01b039092169190911790558015611692576002805460ff19169055505050565b6035546001600160a01b031681565b600080546001019081905584612b5481613cab565b85612b5e81613d62565b85612b6881613e17565b612b706140a1565b60365460408051632e79732b60e11b81526001600160a01b038c8116600483015291519190921691635cf2e656916024808301926020929190829003018186803b158015612bbd57600080fd5b505afa158015612bd1573d6000803e3d6000fd5b505050506040513d6020811015612be757600080fd5b5051612c245760405162461bcd60e51b815260040180806020018281038252602481526020018061425c6024913960400191505060405180910390fd5b8660021480612c335750866001145b612c6e5760405162461bcd60e51b81526004018080602001828103825260238152602001806141ba6023913960400191505060405180910390fd5b866002811115612c7a57fe5b816101c001906002811115612c8b57fe5b90816002811115612c9857fe5b9052506036546040805163e240301960e01b81526001600160a01b038c811660048301529151919092169163e2403019916024808301926020929190829003018186803b158015612ce857600080fd5b505afa158015612cfc573d6000803e3d6000fd5b505050506040513d6020811015612d1257600080fd5b50516101608201819052881115612d5a5760405162461bcd60e51b81526004018080602001828103825260368152602001806144666036913960400191505060405180910390fd5b60375460408051632c6d0e9b60e01b815233600482015290516001600160a01b0390921691632c6d0e9b9160248082019261010092909190829003018186803b158015612da657600080fd5b505afa158015612dba573d6000803e3d6000fd5b505050506040513d610100811015612dd157600080fd5b506020808201516040808401516060850151608086015160a087015160e09788015115156101e08a015293880193909352938601919091526101008501929092529183015260c08201819052612e6e576040805162461bcd60e51b815260206004820152601b60248201527f54686520636f6c6c61746572616c2062616c616e636520697320300000000000604482015290519081900360640190fd5b806101e0015115612eb05760405162461bcd60e51b815260040180806020018281038252603f81526020018061412a603f913960400191505060405180910390fd5b60395460408051630e563a7d60e41b8152336004820152602481018b905290516001600160a01b039092169163e563a7d091604480820192602092909190829003018186803b158015612f0257600080fd5b505afa158015612f16573d6000803e3d6000fd5b505050506040513d6020811015612f2c57600080fd5b505160608201819052612f705760405162461bcd60e51b81526004018080602001828103825260218152602001806141dd6021913960400191505060405180910390fd5b603760009054906101000a90046001600160a01b03166001600160a01b03166312737c338a8a84606001518560e0015186610100015187602001516040518763ffffffff1660e01b815260040180876001600160a01b03166001600160a01b03168152602001868152602001858152602001848152602001838152602001828152602001965050505050505060206040518083038186803b15801561301457600080fd5b505afa158015613028573d6000803e3d6000fd5b505050506040513d602081101561303e57600080fd5b505160a0820181905260c082015110156130895760405162461bcd60e51b81526004018080602001828103825260348152602001806143c66034913960400191505060405180910390fd5b6001816101c00151600281111561309c57fe5b141561323b576036546040805163710ba6c360e11b81526001600160a01b038c81166004830152336024830152604482018c90529151919092169163e2174d86916064808301926020929190829003018186803b1580156130fc57600080fd5b505afa158015613110573d6000803e3d6000fd5b505050506040513d602081101561312657600080fd5b50516131635760405162461bcd60e51b81526004018080602001828103825260398152602001806144fc6039913960400191505060405180910390fd5b603854604080516335adc96b60e21b815290516000926001600160a01b03169163d6b725ac916004808301926020929190829003018186803b1580156131a857600080fd5b505afa1580156131bc573d6000803e3d6000fd5b505050506040513d60208110156131d257600080fd5b50516101608301519091506000906131f790606490612035908563ffffffff613f4416565b9050808a11156132385760405162461bcd60e51b815260040180806020018281038252603c81526020018061455f603c913960400191505060405180910390fd5b50505b60365460608201516101c0830151604051630deb1bf960e21b81526001600160a01b038d8116600483019081523360248401819052604484018f90526064840186905291909516946337ac6fe4948f9492938f939192906084018260028111156132a157fe5b60ff168152602001955050505050506040805180830381600087803b1580156132c957600080fd5b505af11580156132dd573d6000803e3d6000fd5b505050506040513d60408110156132f357600080fd5b5080516020909101516101208301526101a08201526036546040805163fa93b2a560e01b81526001600160a01b038c81166004830152336024830152604482018c90529151919092169163fa93b2a591606480830192600092919082900301818387803b15801561336357600080fd5b505af1158015613377573d6000803e3d6000fd5b5050506101a0820151606080840151610120850151604080518e8152602081018e9052808201959095529284019190915260808301524260a08301525161ffff8916925033916001600160a01b038d16917f1e77446728e5558aa1b7e81e0cdab9cc1b075ba893b740600c76a315c2caa5539181900360c00190a45050505060005481146124a8576040805162461bcd60e51b815260206004820152601f6024820152600080516020614169833981519152604482015290519081900360640190fd5b60008054600101908190558261344f81613cab565b60365460408051639fb8afcd60e01b81526001600160a01b0387811660048301528681166024830152915160009384931691639fb8afcd916044808301926060929190829003018186803b1580156134a657600080fd5b505afa1580156134ba573d6000803e3d6000fd5b505050506040513d60608110156134d057600080fd5b50602081015160409091015190925090508161351d5760405162461bcd60e51b815260040180806020018281038252602e8152602001806141fe602e913960400191505060405180910390fd5b600160365460408051631ca19f1960e01b81526001600160a01b038a81166004830152898116602483015291519190921691631ca19f19916044808301926020929190829003018186803b15801561357457600080fd5b505afa158015613588573d6000803e3d6000fd5b505050506040513d602081101561359e57600080fd5b505160028111156135ab57fe5b146135e75760405162461bcd60e51b81526004018080602001828103825260348152602001806142b16034913960400191505060405180910390fd5b60365460408051631bffeac360e21b81526001600160a01b038981166004830152888116602483015291516000939290921691636fffab0c91604480820192602092909190829003018186803b15801561364057600080fd5b505afa158015613654573d6000803e3d6000fd5b505050506040513d602081101561366a57600080fd5b5051603654604080516362a00a4760e11b81526001600160a01b038b811660048301529151939450600093919092169163c540148e916024808301926020929190829003018186803b1580156136bf57600080fd5b505afa1580156136d3573d6000803e3d6000fd5b505050506040513d60208110156136e957600080fd5b505160365460408051631100f3b160e31b81526001600160a01b038c81166004830152915193945060009391909216916388079d88916024808301926020929190829003018186803b15801561373e57600080fd5b505afa158015613752573d6000803e3d6000fd5b505050506040513d602081101561376857600080fd5b5051603854604080516346f4f8d160e01b8152905192935060009261380a926137fd926001600160a01b03909116916346f4f8d191600480820192602092909190829003018186803b1580156137bd57600080fd5b505afa1580156137d1573d6000803e3d6000fd5b505050506040513d60208110156137e757600080fd5b50516137f1614012565b9063ffffffff613e8416565b839063ffffffff61402216565b90508284108061381957508084115b1561390a576036546040805163af825b0760e01b81526001600160a01b038d811660048301528c81166024830152604482018990529151600093929092169163af825b079160648082019260209290919082900301818787803b15801561387f57600080fd5b505af1158015613893573d6000803e3d6000fd5b505050506040513d60208110156138a957600080fd5b50516040805182815260208101899052428183015290519192506001600160a01b03808d1692908e16917f5050ad184862424ee0852d1838d355ad65bed1e5e6da67ac9a2dac1922677f60919081900360600190a350505050505050613941565b60405162461bcd60e51b815260040180806020018281038252602f81526020018061432e602f913960400191505060405180910390fd5b506000548114611692576040805162461bcd60e51b815260206004820152601f6024820152600080516020614169833981519152604482015290519081900360640190fd5b60001981565b6000805460010190819055836139a181613cab565b846139ab81613d62565b846139b581613e17565b60365460408051631a59df7760e11b81526001600160a01b038a81166004830152915160009392909216916334b3beee91602480820192602092909190829003018186803b158015613a0657600080fd5b505afa158015613a1a573d6000803e3d6000fd5b505050506040513d6020811015613a3057600080fd5b5051604080516370a0823160e01b815233600482015290519192506000916001600160a01b038416916370a08231916024808301926020929190829003018186803b158015613a7e57600080fd5b505afa158015613a92573d6000803e3d6000fd5b505050506040513d6020811015613aa857600080fd5b505160365460408051632f35bfe960e21b81526001600160a01b038d81166004830152336024830152604482018d90529315606482018190529151919450929091169163bcd6ffa491608480830192600092919082900301818387803b158015613b1157600080fd5b505af1158015613b25573d6000803e3d6000fd5b5050604080516394362e8b60e01b8152336004820152602481018c905290516001600160a01b03861693506394362e8b9250604480830192600092919082900301818387803b158015613b7757600080fd5b505af1158015613b8b573d6000803e3d6000fd5b5050603654604080516328fcf4d360e01b81526001600160a01b038e81166004830152336024830152604482018e905291519190921693506328fcf4d39250349160648082019260009290919082900301818588803b158015613bed57600080fd5b505af1158015613c01573d6000803e3d6000fd5b5050604080518c8152426020820152815161ffff8d1695503394506001600160a01b038f1693507fc12c57b1c73a2c3a2ea4613e9476abb3d8d146857aab7329e24243fb59710c82929181900390910190a450505050506000548114611e8c576040805162461bcd60e51b815260206004820152601f6024820152600080516020614169833981519152604482015290519081900360640190fd5b6036546001600160a01b031681565b60365460408051630283aeb760e11b81526001600160a01b038481166004830152915191909216916305075d6e916024808301926020929190829003018186803b158015613cf857600080fd5b505afa158015613d0c573d6000803e3d6000fd5b505050506040513d6020811015613d2257600080fd5b5051613d5f5760405162461bcd60e51b815260040180806020018281038252602181526020018061430d6021913960400191505060405180910390fd5b50565b60365460408051634a08accb60e01b81526001600160a01b03848116600483015291519190921691634a08accb916024808301926020929190829003018186803b158015613daf57600080fd5b505afa158015613dc3573d6000803e3d6000fd5b505050506040513d6020811015613dd957600080fd5b505115613d5f5760405162461bcd60e51b81526004018080602001828103825260248152602001806146386024913960400191505060405180910390fd5b60008111613d5f576040805162461bcd60e51b815260206004820152601d60248201527f416d6f756e74206d7573742062652067726561746572207468616e2030000000604482015290519081900360640190fd5b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee90565b600082820183811015613ede576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b90505b92915050565b600082821115613f3e576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b600082613f5357506000613ee1565b82820282848281613f6057fe5b0414613ede5760405162461bcd60e51b81526004018080602001828103825260218152602001806144456021913960400191505060405180910390fd5b6000808211613ff3576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b6000828481613ffe57fe5b04949350505050565b600290565b303b1590565b6b033b2e3c9fd0803ce800000090565b6000613ede6b033b2e3c9fd0803ce8000000612035614047868663ffffffff613f4416565b6b019d971e4fe8401e7400000090613e84565b604051806101000160405280600081526020016000815260200160008152602001600015158152602001600081526020016000815260200160008152602001600081525090565b60405180610200016040528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000600281111561411c57fe5b815260006020909101529056fe54686520626f72726f7765722063616e20616c7265616479206265206c69717569646174656420736f2068652063616e6e6f7420626f72726f77206d6f72655265656e7472616e637947756172643a207265656e7472616e742063616c6c005468657265206973206e6f7420656e6f756768206c697175696469747920617661696c61626c6520746f20626f72726f77496e76616c696420696e7465726573742072617465206d6f64652073656c656374656454686520616d6f756e7420746f20626f72726f7720697320746f6f20736d616c6c5573657220646f6573206e6f74206861766520616e7920626f72726f7720666f722074686973207265736572766555736572206465706f73697420697320616c7265616479206265696e67207573656420617320636f6c6c61746572616c52657365727665206973206e6f7420656e61626c656420666f7220626f72726f77696e675468657265206973206e6f7420656e6f756768206c697175696469747920617661696c61626c6520746f2072656465656d546865207573657220626f72726f77206973207661726961626c6520616e642063616e6e6f7420626520726562616c616e636564496e76616c6964206d73672e76616c75652073656e7420666f72207468652072657061796d656e74416374696f6e20726571756972657320616e206163746976652072657365727665496e746572657374207261746520726562616c616e636520636f6e646974696f6e732077657265206e6f74206d65745468652061637475616c2062616c616e6365206f66207468652070726f746f636f6c20697320696e636f6e73697374656e745573657220646f6573206e6f742068617665206120626f72726f7720696e2070726f6772657373206f6e207468697320726573657276655468657265206973206e6f7420656e6f75676820636f6c6c61746572616c20746f20636f7665722061206e657720626f72726f775468652063616c6c6572206f6620746869732066756e6374696f6e2063616e206f6e6c79206265207468652061546f6b656e20636f6e7472616374206f6620746869732072657365727665536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775468657265206973206e6f7420656e6f756768206c697175696469747920617661696c61626c6520696e2074686520726573657276655468652072657175657374656420616d6f756e7420697320746f6f20736d616c6c20666f72206120666c6173684c6f616e2e436f6e747261637420696e7374616e63652068617320616c7265616479206265656e20696e697469616c697a6564557365722063616e6e6f7420626f72726f77207468652073656c656374656420616d6f756e742077697468206120737461626c6520726174655573657220646f6573206e6f74206861766520616e79206c6971756964697479206465706f73697465645573657220697320747279696e6720746f20626f72726f7720746f6f206d756368206c6971756964697479206174206120737461626c652072617465546865207573657220646f6573206e6f74206861766520616e7920626f72726f772070656e64696e67557365722063616e6e6f7420626f72726f77207468652073656c656374656420616d6f756e7420617420737461626c65546f207265706179206f6e20626568616c66206f6620616e207573657220616e206578706c6963697420616d6f756e7420746f207265706179206973206e65656465642e416374696f6e20726571756972657320616e20756e667265657a65642072657365727665a265627a7a72315820ed59692c50e2ec9cac0b8fa26e0d00888d3764d1840be22ed0adc4e0acde245564736f6c634300050e0032", "deployedBytecode": "", "linkReferences": {}, From 6e9027ee61b275d2360cad7cdaff1def472ddca8 Mon Sep 17 00:00:00 2001 From: alpha-guy Date: Thu, 15 Jul 2021 18:54:22 +0530 Subject: [PATCH 04/19] Add Aave V2 ABIs and contracts --- external/abi/aave/v2/AaveV2AToken.json | 831 +++++++++++++ ...eV2DefaultReserveInterestRateStrategy.json | 285 +++++ external/abi/aave/v2/AaveV2LendingPool.json | 1086 +++++++++++++++++ .../AaveV2LendingPoolAddressesProvider.json | 483 ++++++++ .../AaveV2LendingPoolCollateralManager.json | 140 +++ .../v2/AaveV2LendingPoolConfigurator.json | 753 ++++++++++++ .../aave/v2/AaveV2ProtocolDataProvider.json | 304 +++++ .../abi/aave/v2/AaveV2StableDebtToken.json | 775 ++++++++++++ ...AaveV2StakedTokenIncentivesController.json | 8 + .../abi/aave/v2/AaveV2VariableDebtToken.json | 665 ++++++++++ external/abi/aave/v2/lib/GenericLogic.json | 24 + external/abi/aave/v2/lib/ReserveLogic.json | 52 + external/abi/aave/v2/lib/ValidationLogic.json | 35 + external/contracts/aave/v2/AaveV2AToken.sol | 406 ++++++ ...veV2DefaultReserveInterestRateStrategy.sol | 260 ++++ .../contracts/aave/v2/AaveV2LendingPool.sol | 946 ++++++++++++++ .../v2/AaveV2LendingPoolAddressesProvider.sol | 215 ++++ .../aave/v2/AaveV2LendingPoolConfigurator.sol | 487 ++++++++ .../aave/v2/AaveV2ProtocolDataProvider.sol | 180 +++ .../aave/v2/AaveV2StableDebtToken.sol | 435 +++++++ .../AaveV2StakedTokenIncentivesController.sol | 218 ++++ .../aave/v2/AaveV2VariableDebtToken.sol | 209 ++++ .../contracts/aave/v2/lib/GenericLogic.sol | 275 +++++ .../contracts/aave/v2/lib/ReserveLogic.sol | 373 ++++++ .../contracts/aave/v2/lib/ValidationLogic.sol | 469 +++++++ utils/contracts/aaveV2.ts | 15 + 26 files changed, 9929 insertions(+) create mode 100644 external/abi/aave/v2/AaveV2AToken.json create mode 100644 external/abi/aave/v2/AaveV2DefaultReserveInterestRateStrategy.json create mode 100644 external/abi/aave/v2/AaveV2LendingPool.json create mode 100644 external/abi/aave/v2/AaveV2LendingPoolAddressesProvider.json create mode 100644 external/abi/aave/v2/AaveV2LendingPoolCollateralManager.json create mode 100644 external/abi/aave/v2/AaveV2LendingPoolConfigurator.json create mode 100644 external/abi/aave/v2/AaveV2ProtocolDataProvider.json create mode 100644 external/abi/aave/v2/AaveV2StableDebtToken.json create mode 100644 external/abi/aave/v2/AaveV2StakedTokenIncentivesController.json create mode 100644 external/abi/aave/v2/AaveV2VariableDebtToken.json create mode 100644 external/abi/aave/v2/lib/GenericLogic.json create mode 100644 external/abi/aave/v2/lib/ReserveLogic.json create mode 100644 external/abi/aave/v2/lib/ValidationLogic.json create mode 100644 external/contracts/aave/v2/AaveV2AToken.sol create mode 100644 external/contracts/aave/v2/AaveV2DefaultReserveInterestRateStrategy.sol create mode 100644 external/contracts/aave/v2/AaveV2LendingPool.sol create mode 100644 external/contracts/aave/v2/AaveV2LendingPoolAddressesProvider.sol create mode 100644 external/contracts/aave/v2/AaveV2LendingPoolConfigurator.sol create mode 100644 external/contracts/aave/v2/AaveV2ProtocolDataProvider.sol create mode 100644 external/contracts/aave/v2/AaveV2StableDebtToken.sol create mode 100644 external/contracts/aave/v2/AaveV2StakedTokenIncentivesController.sol create mode 100644 external/contracts/aave/v2/AaveV2VariableDebtToken.sol create mode 100644 external/contracts/aave/v2/lib/GenericLogic.sol create mode 100644 external/contracts/aave/v2/lib/ReserveLogic.sol create mode 100644 external/contracts/aave/v2/lib/ValidationLogic.sol create mode 100644 utils/contracts/aaveV2.ts diff --git a/external/abi/aave/v2/AaveV2AToken.json b/external/abi/aave/v2/AaveV2AToken.json new file mode 100644 index 000000000..ceaab10e3 --- /dev/null +++ b/external/abi/aave/v2/AaveV2AToken.json @@ -0,0 +1,831 @@ +{ + "contractName": "AaveV2AToken", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "BalanceTransfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "Burn", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "underlyingAsset", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "treasury", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "incentivesController", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint8", + "name": "aTokenDecimals", + "type": "uint8" + }, + { + "indexed": false, + "internalType": "string", + "name": "aTokenName", + "type": "string" + }, + { + "indexed": false, + "internalType": "string", + "name": "aTokenSymbol", + "type": "string" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "params", + "type": "bytes" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "Mint", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "inputs": [], + "name": "ATOKEN_REVISION", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "DOMAIN_SEPARATOR", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "EIP712_REVISION", + "outputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "PERMIT_TYPEHASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "POOL", + "outputs": [ + { + "internalType": "contract ILendingPool", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "RESERVE_TREASURY_ADDRESS", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "UNDERLYING_ASSET_ADDRESS", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "_nonces", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "address", + "name": "receiverOfUnderlying", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "burn", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "subtractedValue", + "type": "uint256" + } + ], + "name": "decreaseAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "getIncentivesController", + "outputs": [ + { + "internalType": "contract IAaveIncentivesController", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "getScaledUserBalanceAndSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "handleRepayment", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "addedValue", + "type": "uint256" + } + ], + "name": "increaseAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ILendingPool", + "name": "pool", + "type": "address" + }, + { + "internalType": "address", + "name": "treasury", + "type": "address" + }, + { + "internalType": "address", + "name": "underlyingAsset", + "type": "address" + }, + { + "internalType": "contract IAaveIncentivesController", + "name": "incentivesController", + "type": "address" + }, + { + "internalType": "uint8", + "name": "aTokenDecimals", + "type": "uint8" + }, + { + "internalType": "string", + "name": "aTokenName", + "type": "string" + }, + { + "internalType": "string", + "name": "aTokenSymbol", + "type": "string" + }, + { + "internalType": "bytes", + "name": "params", + "type": "bytes" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "mint", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "mintToTreasury", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "permit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "scaledBalanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "scaledTotalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "transferOnLiquidation", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transferUnderlyingTo", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bytecode": "0x6080604052600080553480156200001557600080fd5b50604080518082018252600b8082526a105513d2d15397d253541360aa1b60208084018281528551808701909652928552840152815191929160009162000060916037919062000094565b5081516200007690603890602085019062000094565b506039805460ff191660ff9290921691909117905550620001309050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10620000d757805160ff191683800117855562000107565b8280016001018555821562000107579182015b8281111562000107578251825591602001919060010190620000ea565b506200011592915062000119565b5090565b5b808211156200011557600081556001016200011a565b61282280620001406000396000f3fe608060405234801561001057600080fd5b50600436106101e55760003560e01c80637535d2461161010f578063ae167335116100a2578063d505accf11610071578063d505accf146106aa578063d7020d0a146106fb578063dd62ed3e14610737578063f866c31914610765576101e5565b8063ae1673351461066c578063b16a19de14610674578063b1bf962d1461067c578063b9844d8d14610684576101e5565b806388dd91a1116100de57806388dd91a1146105e057806395d89b411461060c578063a457c2d714610614578063a9059cbb14610640576101e5565b80637535d2461461058957806375d26413146105ad57806378160376146105b55780637df5bd3b146105bd576101e5565b80631da24f3e116101875780633644e515116101565780633644e51514610503578063395093511461050b5780634efecaa51461053757806370a0823114610563576101e5565b80631da24f3e1461048157806323b872dd146104a757806330adf81f146104dd578063313ce567146104e5576101e5565b80630bd7ad3b116101c35780630bd7ad3b146102e6578063156e29f61461030057806318160ddd14610332578063183fb4131461033a576101e5565b806306fdde03146101ea578063095ea7b3146102675780630afbcdc9146102a7575b600080fd5b6101f261079b565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561022c578181015183820152602001610214565b50505050905090810190601f1680156102595780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102936004803603604081101561027d57600080fd5b506001600160a01b038135169060200135610832565b604080519115158252519081900360200190f35b6102cd600480360360208110156102bd57600080fd5b50356001600160a01b0316610850565b6040805192835260208301919091528051918290030190f35b6102ee61086d565b60408051918252519081900360200190f35b6102936004803603606081101561031657600080fd5b506001600160a01b038135169060208101359060400135610872565b6102ee610a40565b61047f600480360361010081101561035157600080fd5b6001600160a01b038235811692602081013582169260408201358316926060830135169160ff6080820135169181019060c0810160a082013564010000000081111561039c57600080fd5b8201836020820111156103ae57600080fd5b803590602001918460018302840111640100000000831117156103d057600080fd5b9193909290916020810190356401000000008111156103ee57600080fd5b82018360208201111561040057600080fd5b8035906020019184600183028401116401000000008311171561042257600080fd5b91939092909160208101903564010000000081111561044057600080fd5b82018360208201111561045257600080fd5b8035906020019184600183028401116401000000008311171561047457600080fd5b509092509050610aea565b005b6102ee6004803603602081101561049757600080fd5b50356001600160a01b0316610e67565b610293600480360360608110156104bd57600080fd5b506001600160a01b03813581169160208101359091169060400135610e72565b6102ee610f32565b6104ed610f56565b6040805160ff9092168252519081900360200190f35b6102ee610f5f565b6102936004803603604081101561052157600080fd5b506001600160a01b038135169060200135610f65565b6102ee6004803603604081101561054d57600080fd5b506001600160a01b038135169060200135610fb3565b6102ee6004803603602081101561057957600080fd5b50356001600160a01b0316611059565b6105916110e8565b604080516001600160a01b039092168252519081900360200190f35b6105916110f7565b6101f2611106565b61047f600480360360408110156105d357600080fd5b5080359060200135611123565b61047f600480360360408110156105f657600080fd5b506001600160a01b03813516906020013561124a565b6101f26112d4565b6102936004803603604081101561062a57600080fd5b506001600160a01b038135169060200135611335565b6102936004803603604081101561065657600080fd5b506001600160a01b03813516906020013561139d565b6105916113fa565b610591611409565b6102ee611418565b6102ee6004803603602081101561069a57600080fd5b50356001600160a01b0316611422565b61047f600480360360e08110156106c057600080fd5b506001600160a01b03813581169160208101359091169060408101359060608101359060ff6080820135169060a08101359060c00135611434565b61047f6004803603608081101561071157600080fd5b506001600160a01b0381358116916020810135909116906040810135906060013561167b565b6102ee6004803603604081101561074d57600080fd5b506001600160a01b0381358116916020013516611820565b61047f6004803603606081101561077b57600080fd5b506001600160a01b0381358116916020810135909116906040013561184b565b60378054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156108275780601f106107fc57610100808354040283529160200191610827565b820191906000526020600020905b81548152906001019060200180831161080a57829003601f168201915b505050505090505b90565b600061084661083f61191c565b8484611920565b5060015b92915050565b60008061085c83611a0c565b610864611a27565b91509150915091565b600181565b603c546000906001600160a01b031661088961191c565b6001600160a01b03161460405180604001604052806002815260200161323960f01b815250906109375760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156108fc5781810151838201526020016108e4565b50505050905090810190601f1680156109295780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600061094385611a0c565b905060006109518585611a2d565b6040805180820190915260028152611a9b60f11b6020820152909150816109b95760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156108fc5781810151838201526020016108e4565b506109c48682611b34565b6040805186815290516001600160a01b038816916000916000805160206127148339815191529181900360200190a3604080518681526020810186905281516001600160a01b038916927f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f928290030190a25015949350505050565b600080610a4b611a27565b905080610a5c57600091505061082f565b603c54603e546040805163d15e005360e01b81526001600160a01b0392831660048201529051610ae493929092169163d15e005391602480820192602092909190829003018186803b158015610ab157600080fd5b505afa158015610ac5573d6000803e3d6000fd5b505050506040513d6020811015610adb57600080fd5b50518290611c85565b91505090565b6000610af4611d43565b60015490915060ff1680610b0b5750610b0b611d48565b80610b17575060005481115b610b525760405162461bcd60e51b815260040180806020018281038252602e8152602001806126e6602e913960400191505060405180910390fd5b60015460ff16158015610b71576001805460ff19168117905560008290555b60004690507f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f89896040518083838082843780830192505050925050506040518091039020604051806040016040528060018152602001603160f81b81525080519060200120833060405160200180868152602001858152602001848152602001838152602001826001600160a01b031681526020019550505050505060405160208183030381529060405280519060200120603b81905550610c6989898080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611d4e92505050565b610ca887878080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611d6192505050565b610cb18a611d74565b8d603c60006101000a8154816001600160a01b0302191690836001600160a01b031602179055508c603d60006101000a8154816001600160a01b0302191690836001600160a01b031602179055508b603e60006101000a8154816001600160a01b0302191690836001600160a01b031602179055508a603f60006101000a8154816001600160a01b0302191690836001600160a01b031602179055508d6001600160a01b03168c6001600160a01b03167fb19e051f8af41150ccccb3fc2c2d8d15f4a4cf434f32a559ba75fe73d6eea20b8f8e8e8e8e8e8e8e8e604051808a6001600160a01b03168152602001896001600160a01b031681526020018860ff16815260200180602001806020018060200184810384528a8a82818152602001925080828437600083820152601f01601f191690910185810384528881526020019050888880828437600083820152601f01601f191690910185810383528681526020019050868680828437600083820152604051601f909101601f19169092018290039e50909c50505050505050505050505050a3508015610e58576001805460ff191690555b50505050505050505050505050565b600061084a82611a0c565b6000610e7f848484611d8a565b610eef84610e8b61191c565b610eea856040518060600160405280602881526020016126be602891396001600160a01b038a16600090815260356020526040812090610ec961191c565b6001600160a01b031681526020810191909152604001600020549190611d97565b611920565b826001600160a01b0316846001600160a01b0316600080516020612714833981519152846040518082815260200191505060405180910390a35060019392505050565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b60395460ff1690565b603b5481565b6000610846610f7261191c565b84610eea8560356000610f8361191c565b6001600160a01b03908116825260208083019390935260409182016000908120918c168152925290205490611df1565b603c546000906001600160a01b0316610fca61191c565b6001600160a01b03161460405180604001604052806002815260200161323960f01b8152509061103b5760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156108fc5781810151838201526020016108e4565b50603e54611053906001600160a01b03168484611e52565b50919050565b603c54603e546040805163d15e005360e01b81526001600160a01b039283166004820152905160009361084a93169163d15e0053916024808301926020929190829003018186803b1580156110ad57600080fd5b505afa1580156110c1573d6000803e3d6000fd5b505050506040513d60208110156110d757600080fd5b50516110e284611a0c565b90611c85565b603c546001600160a01b031690565b6000611101611ea4565b905090565b604051806040016040528060018152602001603160f81b81525081565b603c546001600160a01b031661113761191c565b6001600160a01b03161460405180604001604052806002815260200161323960f01b815250906111a85760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156108fc5781810151838201526020016108e4565b50816111b357611246565b603d546001600160a01b03166111d2816111cd8585611a2d565b611b34565b6040805184815290516001600160a01b038316916000916000805160206127148339815191529181900360200190a3604080518481526020810184905281516001600160a01b038416927f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f928290030190a2505b5050565b603c546001600160a01b031661125e61191c565b6001600160a01b03161460405180604001604052806002815260200161323960f01b815250906112cf5760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156108fc5781810151838201526020016108e4565b505050565b60388054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156108275780601f106107fc57610100808354040283529160200191610827565b600061084661134261191c565b84610eea856040518060600160405280602581526020016127c8602591396035600061136c61191c565b6001600160a01b03908116825260208083019390935260409182016000908120918d16815292529020549190611d97565b60006113b16113aa61191c565b8484611d8a565b826001600160a01b03166113c361191c565b6001600160a01b0316600080516020612714833981519152846040518082815260200191505060405180910390a350600192915050565b603d546001600160a01b031690565b603e546001600160a01b031690565b6000611101611a27565b603a6020526000908152604090205481565b6001600160a01b03871661147f576040805162461bcd60e51b815260206004820152600d60248201526c24a72b20a624a22fa7aba722a960991b604482015290519081900360640190fd5b834211156114c9576040805162461bcd60e51b815260206004820152601260248201527124a72b20a624a22fa2ac2824a920aa24a7a760711b604482015290519081900360640190fd5b6001600160a01b038088166000818152603a6020908152604080832054603b5482517f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98186015280840196909652958c166060860152608085018b905260a0850181905260c08086018b90528251808703909101815260e08601835280519084012061190160f01b6101008701526101028601969096526101228086019690965281518086039096018652610142850180835286519684019690962093909552610162840180825283905260ff88166101828501526101a284018790526101c284018690525191926001926101e28083019392601f198301929081900390910190855afa1580156115de573d6000803e3d6000fd5b505050602060405103516001600160a01b0316896001600160a01b031614611641576040805162461bcd60e51b8152602060048201526011602482015270494e56414c49445f5349474e415455524560781b604482015290519081900360640190fd5b61164c826001611df1565b6001600160a01b038a166000908152603a6020526040902055611670898989611920565b505050505050505050565b603c546001600160a01b031661168f61191c565b6001600160a01b03161460405180604001604052806002815260200161323960f01b815250906117005760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156108fc5781810151838201526020016108e4565b50600061170d8383611a2d565b60408051808201909152600281526106a760f31b6020820152909150816117755760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156108fc5781810151838201526020016108e4565b506117808582611eb3565b603e54611797906001600160a01b03168585611e52565b6040805184815290516000916001600160a01b038816916000805160206127148339815191529181900360200190a3836001600160a01b0316856001600160a01b03167f5d624aa9c148153ab3446c1b154f660ee7701e549fe9b62dab7171b1c80e6fa28585604051808381526020018281526020019250505060405180910390a35050505050565b6001600160a01b03918216600090815260356020908152604080832093909416825291909152205490565b603c546001600160a01b031661185f61191c565b6001600160a01b03161460405180604001604052806002815260200161323960f01b815250906118d05760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156108fc5781810151838201526020016108e4565b506118de8383836000611f57565b816001600160a01b0316836001600160a01b0316600080516020612714833981519152836040518082815260200191505060405180910390a3505050565b3390565b6001600160a01b0383166119655760405162461bcd60e51b815260040180806020018281038252602481526020018061277a6024913960400191505060405180910390fd5b6001600160a01b0382166119aa5760405162461bcd60e51b81526004018080602001828103825260228152602001806126766022913960400191505060405180910390fd5b6001600160a01b03808416600081815260356020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b031660009081526034602052604090205490565b60365490565b604080518082019091526002815261035360f41b602082015260009082611a955760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156108fc5781810151838201526020016108e4565b5060408051808201909152600280825261068760f31b60208301528304906b033b2e3c9fd0803ce8000000821904851115611b115760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156108fc5781810151838201526020016108e4565b5082816b033b2e3c9fd0803ce800000086020181611b2b57fe5b04949350505050565b6001600160a01b038216611b8f576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b611b9b600083836112cf565b603654611ba88183611df1565b6036556001600160a01b038316600090815260346020526040902054611bce8184611df1565b6001600160a01b038516600090815260346020526040812091909155611bf2611ea4565b6001600160a01b031614611c7f57611c08611ea4565b6001600160a01b03166331873e2e8584846040518463ffffffff1660e01b815260040180846001600160a01b031681526020018381526020018281526020019350505050600060405180830381600087803b158015611c6657600080fd5b505af1158015611c7a573d6000803e3d6000fd5b505050505b50505050565b6000821580611c92575081155b15611c9f5750600061084a565b816b019d971e4fe8401e740000001981611cb557fe5b0483111560405180604001604052806002815260200161068760f31b81525090611d205760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156108fc5781810151838201526020016108e4565b50506b033b2e3c9fd0803ce800000091026b019d971e4fe8401e74000000010490565b600190565b303b1590565b805161124690603790602084019061259d565b805161124690603890602084019061259d565b6039805460ff191660ff92909216919091179055565b6112cf8383836001611f57565b60008184841115611de95760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156108fc5781810151838201526020016108e4565b505050900390565b600082820183811015611e4b576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526112cf908490612100565b603f546001600160a01b031690565b6001600160a01b038216611ef85760405162461bcd60e51b81526004018080602001828103825260218152602001806127346021913960400191505060405180910390fd5b611f04826000836112cf565b603654611f1181836122b8565b6036556001600160a01b0383166000908152603460209081526040918290205482516060810190935260228084529092611bce9286929061265490830139839190611d97565b603e54603c546040805163d15e005360e01b81526001600160a01b03938416600482018190529151919390921691600091839163d15e0053916024808301926020929190829003018186803b158015611faf57600080fd5b505afa158015611fc3573d6000803e3d6000fd5b505050506040513d6020811015611fd957600080fd5b505190506000611fec826110e28a611a0c565b90506000611ffd836110e28a611a0c565b9050612013898961200e8a87611a2d565b6122fa565b85156120a2576040805163d5ed393360e01b81526001600160a01b0387811660048301528b811660248301528a81166044830152606482018a90526084820185905260a4820184905291519186169163d5ed39339160c48082019260009290919082900301818387803b15801561208957600080fd5b505af115801561209d573d6000803e3d6000fd5b505050505b876001600160a01b0316896001600160a01b03167f4beccb90f994c31aced7a23b5611020728a23d8ec5cddd1a3e9d97b96fda86668986604051808381526020018281526020019250505060405180910390a3505050505050505050565b612112826001600160a01b0316612561565b612163576040805162461bcd60e51b815260206004820152601f60248201527f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e747261637400604482015290519081900360640190fd5b60006060836001600160a01b0316836040518082805190602001908083835b602083106121a15780518252601f199092019160209182019101612182565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114612203576040519150601f19603f3d011682016040523d82523d6000602084013e612208565b606091505b50915091508161225f576040805162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564604482015290519081900360640190fd5b805115611c7f5780806020019051602081101561227b57600080fd5b5051611c7f5760405162461bcd60e51b815260040180806020018281038252602a81526020018061279e602a913960400191505060405180910390fd5b6000611e4b83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611d97565b6001600160a01b03831661233f5760405162461bcd60e51b81526004018080602001828103825260258152602001806127556025913960400191505060405180910390fd5b6001600160a01b0382166123845760405162461bcd60e51b81526004018080602001828103825260238152602001806126316023913960400191505060405180910390fd5b61238f8383836112cf565b600060346000856001600160a01b03166001600160a01b031681526020019081526020016000205490506123de8260405180606001604052806026815260200161269860269139839190611d97565b6001600160a01b03808616600090815260346020526040808220939093559085168152205461240d8184611df1565b6001600160a01b038516600090815260346020526040812091909155612431611ea4565b6001600160a01b03161461255a5760365461244a611ea4565b6001600160a01b03166331873e2e8783866040518463ffffffff1660e01b815260040180846001600160a01b031681526020018381526020018281526020019350505050600060405180830381600087803b1580156124a857600080fd5b505af11580156124bc573d6000803e3d6000fd5b50505050846001600160a01b0316866001600160a01b031614612558576124e1611ea4565b6001600160a01b03166331873e2e8683856040518463ffffffff1660e01b815260040180846001600160a01b031681526020018381526020018281526020019350505050600060405180830381600087803b15801561253f57600080fd5b505af1158015612553573d6000803e3d6000fd5b505050505b505b5050505050565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47081811480159061259557508115155b949350505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106125de57805160ff191683800117855561260b565b8280016001018555821561260b579182015b8281111561260b5782518255916020019190600101906125f0565b5061261792915061261b565b5090565b5b80821115612617576000815560010161261c56fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a206275726e20616d6f756e7420657863656564732062616c616e636545524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365436f6e747261637420696e7374616e63652068617320616c7265616479206265656e20696e697469616c697a6564ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef45524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f20616464726573735361666545524332303a204552433230206f7065726174696f6e20646964206e6f74207375636365656445524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa264697066735822122050fcd35b375995b194a7c1cf8c6a0b841179040ffb2045b237ccdb05d008c2f764736f6c634300060c0033", + "deployedBytecode": "", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/external/abi/aave/v2/AaveV2DefaultReserveInterestRateStrategy.json b/external/abi/aave/v2/AaveV2DefaultReserveInterestRateStrategy.json new file mode 100644 index 000000000..dda690f3b --- /dev/null +++ b/external/abi/aave/v2/AaveV2DefaultReserveInterestRateStrategy.json @@ -0,0 +1,285 @@ +{ + "contractName": "AaveV2DefaultReserveInterestRateStrategy", + "abi": [ + { + "inputs": [ + { + "internalType": "contract ILendingPoolAddressesProvider", + "name": "provider", + "type": "address" + }, + { + "internalType": "uint256", + "name": "optimalUtilizationRate", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "baseVariableBorrowRate", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "variableRateSlope1", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "variableRateSlope2", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "stableRateSlope1", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "stableRateSlope2", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "EXCESS_UTILIZATION_RATE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "OPTIMAL_UTILIZATION_RATE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "addressesProvider", + "outputs": [ + { + "internalType": "contract ILendingPoolAddressesProvider", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "baseVariableBorrowRate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "reserve", + "type": "address" + }, + { + "internalType": "address", + "name": "aToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "liquidityAdded", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "liquidityTaken", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalStableDebt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalVariableDebt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "averageStableBorrowRate", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "reserveFactor", + "type": "uint256" + } + ], + "name": "calculateInterestRates", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "reserve", + "type": "address" + }, + { + "internalType": "uint256", + "name": "availableLiquidity", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalStableDebt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalVariableDebt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "averageStableBorrowRate", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "reserveFactor", + "type": "uint256" + } + ], + "name": "calculateInterestRates", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getMaxVariableBorrowRate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "stableRateSlope1", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "stableRateSlope2", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "variableRateSlope1", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "variableRateSlope2", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "bytecode": "0x61018060405234801561001157600080fd5b50604051610fbb380380610fbb833981810160405260e081101561003457600080fd5b5080516020808301516040840151606085015160808087015160a088015160c0909801519185905295969395929491939161008e90879061007c906108526100c3821b17901c565b6100d360201b6108621790919060201c565b60a05260609690961b6001600160601b03191660c05260e09390935261010091909152610120526101405250610160526101b9565b6b033b2e3c9fd0803ce800000090565b600061011b83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061012260201b60201c565b9392505050565b600081848411156101b15760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561017657818101518382015260200161015e565b50505050905090810190601f1680156101a35780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b60805160a05160c05160601c60e05161010051610120516101405161016051610d4d61026e6000398061059752806108305250806101dd52806105c752806106b15250806102df528061032c52806105f852508061030352806103715280610643528061071b5250806103505280610622528061074152806107e8525080610400528061080c52508061020152806105315250806105055280610555528061067d52806106f552806107c45250610d4d6000f3fe608060405234801561001057600080fd5b50600436106100a95760003560e01c806380031e371161007157806380031e37146101535780639584df281461015b578063a15f30ac1461019f578063b2589544146101a7578063c72c4d10146101af578063ccab01a3146101d3576100a9565b80630bdf953f146100ae57806317319873146100c857806329db497d146100d057806365614f81146101435780637b832f581461014b575b600080fd5b6100b66101db565b60408051918252519081900360200190f35b6100b66101ff565b61012560048036036101008110156100e757600080fd5b506001600160a01b03813581169160208101359091169060408101359060608101359060808101359060a08101359060c08101359060e00135610223565b60408051938452602084019290925282820152519081900360600190f35b6100b66102dd565b6100b6610301565b6100b6610325565b610125600480360360c081101561017157600080fd5b506001600160a01b038135169060208101359060408101359060608101359060808101359060a001356103a0565b6100b66107c2565b6100b66107e6565b6101b761080a565b604080516001600160a01b039092168252519081900360200190f35b6100b661082e565b7f000000000000000000000000000000000000000000000000000000000000000090565b7f000000000000000000000000000000000000000000000000000000000000000081565b6000806000808b6001600160a01b03166370a082318c6040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561027657600080fd5b505afa15801561028a573d6000803e3d6000fd5b505050506040513d60208110156102a057600080fd5b505190506102b8896102b2838d6108ad565b90610862565b90506102c88c828a8a8a8a6103a0565b93509350935050985098509895505050505050565b7f000000000000000000000000000000000000000000000000000000000000000090565b7f000000000000000000000000000000000000000000000000000000000000000090565b600061039b7f00000000000000000000000000000000000000000000000000000000000000006103957f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006108ad565b906108ad565b905090565b60008060006103ad610ce8565b6103b788886108ad565b808252600060208301819052604083018190526060830152156103f25780516103ed906103e5908b906108ad565b825190610907565b6103f5565b60005b8160800181815250507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633618abba6040518163ffffffff1660e01b815260040160206040518083038186803b15801561045757600080fd5b505afa15801561046b573d6000803e3d6000fd5b505050506040513d602081101561048157600080fd5b50516040805163bb85c0bb60e01b81526001600160a01b038d811660048301529151919092169163bb85c0bb916024808301926020929190829003018186803b1580156104cd57600080fd5b505afa1580156104e1573d6000803e3d6000fd5b505050506040513d60208110156104f757600080fd5b5051604082015260808101517f0000000000000000000000000000000000000000000000000000000000000000101561067257600061058d7f00000000000000000000000000000000000000000000000000000000000000006105877f0000000000000000000000000000000000000000000000000000000000000000856080015161086290919063ffffffff16565b90610907565b90506105eb6105bc7f000000000000000000000000000000000000000000000000000000000000000083610a4b565b6040840151610395907f00000000000000000000000000000000000000000000000000000000000000006108ad565b604083015261066761061d7f000000000000000000000000000000000000000000000000000000000000000083610a4b565b6103957f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006108ad565b60208301525061076c565b6106e16106d66106af7f0000000000000000000000000000000000000000000000000000000000000000846080015161090790919063ffffffff16565b7f000000000000000000000000000000000000000000000000000000000000000090610a4b565b6040830151906108ad565b604082015260808101516107669061073f907f000000000000000000000000000000000000000000000000000000000000000090610587907f0000000000000000000000000000000000000000000000000000000000000000610a4b565b7f0000000000000000000000000000000000000000000000000000000000000000906108ad565b60208201525b61079f61077b61271087610862565b61079983608001516107938c8c87602001518d610b0c565b90610a4b565b90610b73565b606082018190526040820151602090920151909b919a5098509650505050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000090565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000090565b6b033b2e3c9fd0803ce800000090565b60006108a483836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610c10565b90505b92915050565b6000828201838110156108a4576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b604080518082019091526002815261035360f41b6020820152600090826109ac5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610971578181015183820152602001610959565b50505050905090810190601f16801561099e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060408051808201909152600280825261068760f31b60208301528304906b033b2e3c9fd0803ce8000000821904851115610a285760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610971578181015183820152602001610959565b5082816b033b2e3c9fd0803ce800000086020181610a4257fe5b04949350505050565b6000821580610a58575081155b15610a65575060006108a7565b816b019d971e4fe8401e740000001981610a7b57fe5b0483111560405180604001604052806002815260200161068760f31b81525090610ae65760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610971578181015183820152602001610959565b506b033b2e3c9fd0803ce80000006002815b048385020181610b0457fe5b049392505050565b600080610b1986866108ad565b905080610b2a576000915050610b6b565b6000610b398561079388610c6a565b90506000610b4a856107938a610c6a565b90506000610b64610b5a85610c6a565b61058785856108ad565b9450505050505b949350505050565b6000821580610b80575081155b15610b8d575060006108a7565b816113881981610b9957fe5b0483111560405180604001604052806002815260200161068760f31b81525090610c045760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610971578181015183820152602001610959565b50612710600281610af8565b60008184841115610c625760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610971578181015183820152602001610959565b505050900390565b6000633b9aca0082810290839082041460405180604001604052806002815260200161068760f31b81525090610ce15760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610971578181015183820152602001610959565b5092915050565b6040518060a001604052806000815260200160008152602001600081526020016000815260200160008152509056fea26469706673582212202de93b4e5bd8eff563a6594cebe41ba1046984974b817cc22176094a2c3682bf64736f6c634300060c0033", + "deployedBytecode": "", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/external/abi/aave/v2/AaveV2LendingPool.json b/external/abi/aave/v2/AaveV2LendingPool.json new file mode 100644 index 000000000..f96efa588 --- /dev/null +++ b/external/abi/aave/v2/AaveV2LendingPool.json @@ -0,0 +1,1086 @@ +{ + "contractName": "AaveV2LendingPool", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "reserve", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "onBehalfOf", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "borrowRateMode", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "borrowRate", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint16", + "name": "referral", + "type": "uint16" + } + ], + "name": "Borrow", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "reserve", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "onBehalfOf", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint16", + "name": "referral", + "type": "uint16" + } + ], + "name": "Deposit", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "initiator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "premium", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint16", + "name": "referralCode", + "type": "uint16" + } + ], + "name": "FlashLoan", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "collateralAsset", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "debtAsset", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "debtToCover", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "liquidatedCollateralAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "liquidator", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "receiveAToken", + "type": "bool" + } + ], + "name": "LiquidationCall", + "type": "event" + }, + { + "anonymous": false, + "inputs": [], + "name": "Paused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "reserve", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "RebalanceStableBorrowRate", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "reserve", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "repayer", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "Repay", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "reserve", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "liquidityRate", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "stableBorrowRate", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "variableBorrowRate", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "liquidityIndex", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "variableBorrowIndex", + "type": "uint256" + } + ], + "name": "ReserveDataUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "reserve", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "ReserveUsedAsCollateralDisabled", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "reserve", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "ReserveUsedAsCollateralEnabled", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "reserve", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "rateMode", + "type": "uint256" + } + ], + "name": "Swap", + "type": "event" + }, + { + "anonymous": false, + "inputs": [], + "name": "Unpaused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "reserve", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "Withdraw", + "type": "event" + }, + { + "inputs": [], + "name": "FLASHLOAN_PREMIUM_TOTAL", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "LENDINGPOOL_REVISION", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_NUMBER_RESERVES", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_STABLE_RATE_BORROW_SIZE_PERCENT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "interestRateMode", + "type": "uint256" + }, + { + "internalType": "uint16", + "name": "referralCode", + "type": "uint16" + }, + { + "internalType": "address", + "name": "onBehalfOf", + "type": "address" + } + ], + "name": "borrow", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "address", + "name": "onBehalfOf", + "type": "address" + }, + { + "internalType": "uint16", + "name": "referralCode", + "type": "uint16" + } + ], + "name": "deposit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balanceFromBefore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balanceToBefore", + "type": "uint256" + } + ], + "name": "finalizeTransfer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "receiverAddress", + "type": "address" + }, + { + "internalType": "address[]", + "name": "assets", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "modes", + "type": "uint256[]" + }, + { + "internalType": "address", + "name": "onBehalfOf", + "type": "address" + }, + { + "internalType": "bytes", + "name": "params", + "type": "bytes" + }, + { + "internalType": "uint16", + "name": "referralCode", + "type": "uint16" + } + ], + "name": "flashLoan", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "getAddressesProvider", + "outputs": [ + { + "internalType": "contract ILendingPoolAddressesProvider", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "getConfiguration", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "data", + "type": "uint256" + } + ], + "internalType": "struct DataTypes.ReserveConfigurationMap", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "getReserveData", + "outputs": [ + { + "components": [ + { + "components": [ + { + "internalType": "uint256", + "name": "data", + "type": "uint256" + } + ], + "internalType": "struct DataTypes.ReserveConfigurationMap", + "name": "configuration", + "type": "tuple" + }, + { + "internalType": "uint128", + "name": "liquidityIndex", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "variableBorrowIndex", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "currentLiquidityRate", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "currentVariableBorrowRate", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "currentStableBorrowRate", + "type": "uint128" + }, + { + "internalType": "uint40", + "name": "lastUpdateTimestamp", + "type": "uint40" + }, + { + "internalType": "address", + "name": "aTokenAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "stableDebtTokenAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "variableDebtTokenAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "interestRateStrategyAddress", + "type": "address" + }, + { + "internalType": "uint8", + "name": "id", + "type": "uint8" + } + ], + "internalType": "struct DataTypes.ReserveData", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "getReserveNormalizedIncome", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "getReserveNormalizedVariableDebt", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getReservesList", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "getUserAccountData", + "outputs": [ + { + "internalType": "uint256", + "name": "totalCollateralETH", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalDebtETH", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "availableBorrowsETH", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "currentLiquidationThreshold", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "ltv", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "healthFactor", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "getUserConfiguration", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "data", + "type": "uint256" + } + ], + "internalType": "struct DataTypes.UserConfigurationMap", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "address", + "name": "aTokenAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "stableDebtAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "variableDebtAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "interestRateStrategyAddress", + "type": "address" + } + ], + "name": "initReserve", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ILendingPoolAddressesProvider", + "name": "provider", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "collateralAsset", + "type": "address" + }, + { + "internalType": "address", + "name": "debtAsset", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "uint256", + "name": "debtToCover", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "receiveAToken", + "type": "bool" + } + ], + "name": "liquidationCall", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "paused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "rebalanceStableBorrowRate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rateMode", + "type": "uint256" + }, + { + "internalType": "address", + "name": "onBehalfOf", + "type": "address" + } + ], + "name": "repay", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "configuration", + "type": "uint256" + } + ], + "name": "setConfiguration", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "val", + "type": "bool" + } + ], + "name": "setPause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "address", + "name": "rateStrategyAddress", + "type": "address" + } + ], + "name": "setReserveInterestRateStrategyAddress", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "bool", + "name": "useAsCollateral", + "type": "bool" + } + ], + "name": "setUserUseReserveAsCollateral", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "rateMode", + "type": "uint256" + } + ], + "name": "swapBorrowRateMode", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + } + ], + "name": "withdraw", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bytecode": "0x60806040526000805534801561001457600080fd5b506155c880620000256000396000f3fe608060405234801561001057600080fd5b50600436106101c35760003560e01c8063ab9c4b5d116100f9578063d15e005311610097578063e82fec2f11610071578063e82fec2f146103c2578063e8eda9df146103ca578063f8119d51146103dd578063fe65acfe146103e5576101c3565b8063d15e005314610387578063d1946dbc1461039a578063d5ed3933146103af576101c3565b8063bf92857c116100d3578063bf92857c14610329578063c44b11f71461034e578063c4d66de814610361578063cd11238214610374576101c3565b8063ab9c4b5d146102f0578063b8d2927614610303578063bedb86fb14610316576101c3565b80635a3b74b9116101665780637a708e92116101405780637a708e92146102af5780638afaff02146102c257806394ba89a2146102ca578063a415bcad146102dd576101c3565b80635a3b74b9146102745780635c975abb1461028757806369328dec1461029c576101c3565b806335ea6a75116101a257806335ea6a751461020e578063386497fd1461022e5780634417a58314610241578063573ade8114610261576101c3565b8062a718a9146101c8578063074b2e43146101dd5780631d2118f9146101fb575b600080fd5b6101db6101d6366004614875565b6103fa565b005b6101e56105d0565b6040516101f291906154c9565b60405180910390f35b6101db6102093660046147cd565b6105d6565b61022161021c366004614795565b61060f565b6040516101f291906152e3565b6101e561023c366004614795565b6106f1565b61025461024f366004614795565b610718565b6040516101f291906152d9565b6101e561026f366004614b14565b61074b565b6101db610282366004614a2a565b610a77565b61028f610c3c565b6040516101f2919061511f565b6101e56102aa366004614a82565b610c45565b6101db6102bd366004614805565b610f6f565b6101e5611051565b6101db6102d8366004614a57565b611056565b6101db6102eb366004614b5d565b6113c3565b6101db6102fe366004614932565b611443565b6101db610311366004614a57565b611b17565b6101db610324366004614b9c565b611b3b565b61033c610337366004614795565b611bb6565b6040516101f29695949392919061551b565b61025461035c366004614795565b611cb2565b6101db61036f366004614795565b611ce5565b6101db6103823660046147cd565b611d8d565b6101e5610395366004614795565b612003565b6103a2612024565b6040516101f291906150d2565b6101db6103bd3660046148ce565b6120c9565b6101e5612312565b6101db6103d8366004614ac3565b612318565b6101e5612545565b6103ed61254b565b6040516101f29190614df1565b61040261255a565b6034546040805163712d917160e01b815290516000926001600160a01b03169163712d9171916004808301926020929190829003018186803b15801561044757600080fd5b505afa15801561045b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061047f91906147b1565b905060006060826001600160a01b031688888888886040516024016104a8959493929190614e79565b60408051601f198184030181529181526020820180516001600160e01b031662a718a960e01b179052516104dc9190614dd5565b600060405180830381855af49150503d8060008114610517576040519150601f19603f3d011682016040523d82523d6000602084013e61051c565b606091505b50915091508160405180604001604052806002815260200161323360f01b815250906105645760405162461bcd60e51b815260040161055b919061512a565b60405180910390fd5b50600060608280602001905181019061057d9190614bec565b9150915081600014816040516020016105969190614dd5565b604051602081830303815290604052906105c35760405162461bcd60e51b815260040161055b919061512a565b5050505050505050505050565b603b5490565b6105de612598565b6001600160a01b03918216600090815260356020526040902060070180546001600160a01b03191691909216179055565b6106176144e3565b506001600160a01b0381811660009081526035602090815260409182902082516101a08101845281546101808201908152815260018201546001600160801b0380821694830194909452600160801b908190048416948201949094526002820154808416606083015284900483166080820152600382015492831660a08201529290910464ffffffffff1660c08301526004810154831660e0830152600581015483166101008301526006810154831661012083015260070154918216610140820152600160a01b90910460ff166101608201525b919050565b6001600160a01b038116600090815260356020526040812061071290612657565b92915050565b61072061454e565b506001600160a01b031660009081526036602090815260409182902082519182019092529054815290565b600061075561255a565b6001600160a01b0385166000908152603560205260408120908061077985846126d4565b91509150600086600281111561078b57fe5b60405163fa0c214960e01b815290915073__$de8c0cf1a7d7c36c802af9a64fb9d86036$__9063fa0c2149906107cf9087908c9086908c908a908a90600401615488565b60006040518083038186803b1580156107e757600080fd5b505af41580156107fb573d6000803e3d6000fd5b50600092506001915061080b9050565b82600281111561081757fe5b146108225782610824565b835b9050808910156108315750875b61083a856127e9565b600182600281111561084857fe5b14156108b9576005850154604051632770a7eb60e21b81526001600160a01b0390911690639dc29fac90610882908a908590600401614e36565b600060405180830381600087803b15801561089c57600080fd5b505af11580156108b0573d6000803e3d6000fd5b50505050610937565b60068501546001860154604051637a94c56560e11b81526001600160a01b039092169163f5298aca91610904918b918691600160801b9091046001600160801b031690600401614e4f565b600060405180830381600087803b15801561091e57600080fd5b505af1158015610932573d6000803e3d6000fd5b505050505b60048501546001600160a01b0316610953868c838560006128b6565b610967826109618787612c1e565b90612c43565b61099f5760078601546001600160a01b038916600090815260366020526040812061099f929091600160a01b90910460ff1690612c85565b6109b46001600160a01b038c16338385612cf5565b6040516388dd91a160e01b81526001600160a01b038216906388dd91a1906109e29033908690600401614e36565b600060405180830381600087803b1580156109fc57600080fd5b505af1158015610a10573d6000803e3d6000fd5b50505050336001600160a01b0316886001600160a01b03168c6001600160a01b03167f4cdde6e09bb755c9a5589ebaec640bbfedff1362d4b255ebf8339782b9942faa85604051610a6191906154c9565b60405180910390a4509998505050505050505050565b610a7f61255a565b6001600160a01b03808316600090815260356020818152604080842033855260368352938190206038546034548351631f94a27560e31b81529351969773__$de8c0cf1a7d7c36c802af9a64fb9d86036$__97635fa297e5978a978d978d9792969295603795939493169263fca513a892600480840193919291829003018186803b158015610b0d57600080fd5b505afa158015610b21573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b4591906147b1565b6040518963ffffffff1660e01b8152600401610b68989796959493929190615404565b60006040518083038186803b158015610b8057600080fd5b505af4158015610b94573d6000803e3d6000fd5b505050506007810154336000908152603660205260409020610bc091600160a01b900460ff1684612d53565b8115610c005760405133906001600160a01b038516907e058a56ea94653cdf4f152d227ace22d4c00ad99e2a43f58cb7d9e3feb295f290600090a3610c37565b60405133906001600160a01b038516907f44c58d81365b66dd4b1a7f36c25aa97b8c71c361ee4937adc1a00000227db5dd90600090a35b505050565b60395460ff1690565b6000610c4f61255a565b6001600160a01b0380851660009081526035602052604080822060048082015492516370a0823160e01b8152919492909216929183916370a0823191610c9791339101614df1565b60206040518083038186803b158015610caf57600080fd5b505afa158015610cc3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ce79190614bd4565b905085600019811415610cf75750805b73__$de8c0cf1a7d7c36c802af9a64fb9d86036$__63d09db04a898385603560366000336001600160a01b03166001600160a01b031681526020019081526020016000206037603854603460009054906101000a90046001600160a01b03166001600160a01b031663fca513a86040518163ffffffff1660e01b815260040160206040518083038186803b158015610d8e57600080fd5b505afa158015610da2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dc691906147b1565b6040518963ffffffff1660e01b8152600401610de9989796959493929190614fa2565b60006040518083038186803b158015610e0157600080fd5b505af4158015610e15573d6000803e3d6000fd5b50505050610e22846127e9565b610e308489856000856128b6565b81811415610e9a576007840154336000908152603660205260408120610e63929091600160a01b90910460ff1690612d53565b60405133906001600160a01b038a16907f44c58d81365b66dd4b1a7f36c25aa97b8c71c361ee4937adc1a00000227db5dd90600090a35b6001840154604051636b81068560e11b81526001600160a01b0385169163d7020d0a91610edb9133918b9187916001600160801b0390911690600401614e05565b600060405180830381600087803b158015610ef557600080fd5b505af1158015610f09573d6000803e3d6000fd5b50505050856001600160a01b0316336001600160a01b0316896001600160a01b03167f3115d1449a7b732c986cba18244e897a450f61e1bb8d589cd2e69e6c8924f9f784604051610f5a91906154c9565b60405180910390a493505050505b9392505050565b610f77612598565b610f8085612dc9565b6040518060400160405280600281526020016106e760f31b81525090610fb95760405162461bcd60e51b815260040161055b919061512a565b506001600160a01b038516600090815260356020526040908190209051630acce25f60e21b815273__$22cd43a9dda9ce44e9b92ba393b88fb9ac$__91632b33897c91611011919088908890889088906004016153d6565b60006040518083038186803b15801561102957600080fd5b505af415801561103d573d6000803e3d6000fd5b5050505061104a85612e02565b5050505050565b600281565b61105e61255a565b6001600160a01b0382166000908152603560205260408120908061108233846126d4565b91509150600084600281111561109457fe5b3360009081526036602052604090819020905163a8695b1d60e01b815291925073__$de8c0cf1a7d7c36c802af9a64fb9d86036$__9163a8695b1d916110e591889190889088908890600401615446565b60006040518083038186803b1580156110fd57600080fd5b505af4158015611111573d6000803e3d6000fd5b5050505061111e846127e9565b600181600281111561112c57fe5b141561123c576005840154604051632770a7eb60e21b81526001600160a01b0390911690639dc29fac906111669033908790600401614e36565b600060405180830381600087803b15801561118057600080fd5b505af1158015611194573d6000803e3d6000fd5b505050506006840154600185015460405163b3f1c93d60e01b81526001600160a01b039092169163b3f1c93d916111e491339182918991600160801b90046001600160801b031690600401614e05565b602060405180830381600087803b1580156111fe57600080fd5b505af1158015611212573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112369190614bb8565b50611352565b60068401546001850154604051637a94c56560e11b81526001600160a01b039092169163f5298aca916112879133918791600160801b9091046001600160801b031690600401614e4f565b600060405180830381600087803b1580156112a157600080fd5b505af11580156112b5573d6000803e3d6000fd5b505050506005840154600385015460405163b3f1c93d60e01b81526001600160a01b039092169163b3f1c93d916112fe913391829188916001600160801b031690600401614e05565b602060405180830381600087803b15801561131857600080fd5b505af115801561132c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113509190614bb8565b505b600484015461137090859088906001600160a01b03166000806128b6565b336001600160a01b0316866001600160a01b03167fea368a40e9570069bb8e6511d668293ad2e1f03b0d982431fd223de9f3b70ca6876040516113b391906154c9565b60405180910390a3505050505050565b6113cb61255a565b6001600160a01b038086166000818152603560209081526040918290208251610100810184529384523391840191909152848416918301919091526060820187905260808201869052600481015490921660a082015261ffff841660c0820152600160e082015261143b90612f0b565b505050505050565b61144b61255a565b611453614561565b6114c08b8b8080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050604080516020808f0282810182019093528e82529093508e92508d91829185019084908082843760009201919091525061340492505050565b60608a67ffffffffffffffff811180156114d957600080fd5b50604051908082528060200260200182016040528015611503578160200160208202803683370190505b50905060608b67ffffffffffffffff8111801561151f57600080fd5b50604051908082528060200260200182016040528015611549578160200160208202803683370190505b506001600160a01b038f1684526000604085015290505b60408301518c111561170d57603560008e8e866040015181811061158057fe5b90506020020160208101906115959190614795565b6001600160a01b03166001600160a01b0316815260200190815260200160002060040160009054906101000a90046001600160a01b0316828460400151815181106115dc57fe5b60200260200101906001600160a01b031690816001600160a01b03168152505061163361271061162d603b548e8e886040015181811061161857fe5b9050602002013561344290919063ffffffff16565b9061347c565b8184604001518151811061164357fe5b6020026020010181815250508183604001518151811061165f57fe5b60200260200101516001600160a01b0316634efecaa58f8d8d876040015181811061168657fe5b905060200201356040518363ffffffff1660e01b81526004016116aa929190614e36565b602060405180830381600087803b1580156116c457600080fd5b505af11580156116d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116fc9190614bd4565b506040830180516001019052611560565b82600001516001600160a01b031663920f5c848e8e8e8e86338d8d6040518963ffffffff1660e01b815260040161174b98979695949392919061500e565b602060405180830381600087803b15801561176557600080fd5b505af1158015611779573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061179d9190614bb8565b604051806040016040528060028152602001611b1b60f11b815250906117d65760405162461bcd60e51b815260040161055b919061512a565b50600060408401525b60408301518c1115611b07578c8c84604001518181106117fb57fe5b90506020020160208101906118109190614795565b6001600160a01b0316606084015260408301518b908b9081811061183057fe5b905060200201358360a00181815250508083604001518151811061185057fe5b60200260200101518360c00181815250508183604001518151811061187157fe5b60209081029190910101516001600160a01b0316608084015260c083015160a084015161189d91612c1e565b60e08401526000898985604001518181106118b457fe5b9050602002013560028111156118c657fe5b60028111156118d157fe5b1415611a035760608301516001600160a01b031660009081526035602052604090206118fc906127e9565b61199c83608001516001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561193c57600080fd5b505afa158015611950573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119749190614bd4565b60c085015160608601516001600160a01b0316600090815260356020526040902091906134be565b6060830151608084015160e08501516001600160a01b03831660009081526035602052604081206119d2949093909290916128b6565b6119fe8e84608001518560e0015186606001516001600160a01b0316612cf5909392919063ffffffff16565b611a92565b611a9260405180610100016040528085606001516001600160a01b03168152602001336001600160a01b03168152602001896001600160a01b031681526020018560a0015181526020018b8b8760400151818110611a5d57fe5b90506020020135815260200185608001516001600160a01b031681526020018661ffff16815260200160001515815250612f0b565b82606001516001600160a01b0316336001600160a01b03168f6001600160a01b03167f631042c832b07452973831137f2d73e395028b44b250dedc5abb0ee766e168ac8660a001518760c0015189604051611aef939291906154d2565b60405180910390a460408301805160010190526117df565b5050505050505050505050505050565b611b1f612598565b6001600160a01b03909116600090815260356020526040902055565b611b43612598565b6039805460ff1916821515179081905560ff1615611b89576040517f9e87fac88ff661f02d44f95383c817fece4bce600a3dab7a54406878b965e75290600090a1611bb3565b6040517fa45f47fdea8a1efdd9029a5691c7f759c32b7c698632b563573e155625d1693390600090a15b50565b600080600080600080611c8f876035603660008b6001600160a01b03166001600160a01b031681526020019081526020016000206040518060200160405290816000820154815250506037603854603460009054906101000a90046001600160a01b03166001600160a01b031663fca513a86040518163ffffffff1660e01b815260040160206040518083038186803b158015611c5257600080fd5b505afa158015611c66573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c8a91906147b1565b61357b565b93995091975090945092509050611ca7868684613a3c565b935091939550919395565b611cba61454e565b506001600160a01b031660009081526035602090815260409182902082519182019092529054815290565b6000611cef613a70565b60015490915060ff1680611d065750611d06613a75565b80611d12575060005481115b611d2e5760405162461bcd60e51b815260040161055b9061520a565b60015460ff16158015611d4d576001805460ff19168117905560008290555b603480546001600160a01b0319166001600160a01b0385161790556109c4603a556009603b556080603c558015610c37576001805460ff19169055505050565b611d9561255a565b6001600160a01b038083166000908152603560205260408082206005810154600682015460048084015494516370a0823160e01b81529396928316959183169490921692909185916370a0823191611def918a9101614df1565b60206040518083038186803b158015611e0757600080fd5b505afa158015611e1b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e3f9190614bd4565b60405163548cad0960e01b815290915073__$de8c0cf1a7d7c36c802af9a64fb9d86036$__9063548cad0990611e819088908b908990899089906004016153d6565b60006040518083038186803b158015611e9957600080fd5b505af4158015611ead573d6000803e3d6000fd5b50505050611eba856127e9565b604051632770a7eb60e21b81526001600160a01b03851690639dc29fac90611ee89089908590600401614e36565b600060405180830381600087803b158015611f0257600080fd5b505af1158015611f16573d6000803e3d6000fd5b505050600386015460405163b3f1c93d60e01b81526001600160a01b038716925063b3f1c93d91611f59918a91829187916001600160801b031690600401614e05565b602060405180830381600087803b158015611f7357600080fd5b505af1158015611f87573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fab9190614bb8565b50611fba8588846000806128b6565b856001600160a01b0316876001600160a01b03167f9f439ae0c81e41a04d3fdfe07aed54e6a179fb0db15be7702eb66fa8ef6f530060405160405180910390a350505050505050565b6001600160a01b038116600090815260356020526040812061071290613a7b565b60608060385467ffffffffffffffff8111801561204057600080fd5b5060405190808252806020026020018201604052801561206a578160200160208202803683370190505b50905060005b6038548110156120c35760008181526037602052604090205482516001600160a01b03909116908390839081106120a357fe5b6001600160a01b0390921660209283029190910190910152600101612070565b50905090565b6120d161255a565b6001600160a01b038681166000908152603560209081526040918290206004015482518084019093526002835261363360f01b91830191909152909116331461212d5760405162461bcd60e51b815260040161055b919061512a565b506121e985603560366000896001600160a01b03166001600160a01b031681526020019081526020016000206037603854603460009054906101000a90046001600160a01b03166001600160a01b031663fca513a86040518163ffffffff1660e01b815260040160206040518083038186803b1580156121ac57600080fd5b505afa1580156121c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121e491906147b1565b613ada565b6001600160a01b03868116600090815260356020526040902060070154600160a01b900460ff169085811690871614612309576122268385612c43565b612292576001600160a01b0386166000908152603660205260408120906122509082908490612d53565b866001600160a01b0316886001600160a01b03167f44c58d81365b66dd4b1a7f36c25aa97b8c71c361ee4937adc1a00000227db5dd60405160405180910390a3505b8115801561229f57508315155b15612309576001600160a01b03851660009081526036602052604090206122c881836001612d53565b856001600160a01b0316886001600160a01b03167e058a56ea94653cdf4f152d227ace22d4c00ad99e2a43f58cb7d9e3feb295f260405160405180910390a3505b50505050505050565b603a5490565b61232061255a565b6001600160a01b038416600090815260356020526040908190209051630eca322b60e01b815273__$de8c0cf1a7d7c36c802af9a64fb9d86036$__90630eca322b90612372908490889060040161547a565b60006040518083038186803b15801561238a57600080fd5b505af415801561239e573d6000803e3d6000fd5b5050505060048101546001600160a01b03166123b9826127e9565b6123c78287838860006128b6565b6123dc6001600160a01b038716338388612cf5565b6001820154604051630ab714fb60e11b81526000916001600160a01b0384169163156e29f69161241e9189918b916001600160801b0390911690600401614e4f565b602060405180830381600087803b15801561243857600080fd5b505af115801561244c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124709190614bb8565b905080156124ea5760078301546001600160a01b03861660009081526036602052604090206124aa91600160a01b900460ff166001612d53565b846001600160a01b0316876001600160a01b03167e058a56ea94653cdf4f152d227ace22d4c00ad99e2a43f58cb7d9e3feb295f260405160405180910390a35b8361ffff16856001600160a01b0316886001600160a01b03167fde6857219544bb5b7746f48ed30be6386fefc61b2f864cacf559893bf50fd951338a604051612534929190614e36565b60405180910390a450505050505050565b603c5490565b6034546001600160a01b031690565b6039546040805180820190915260028152610d8d60f21b60208201529060ff1615611bb35760405162461bcd60e51b815260040161055b919061512a565b603454604080516385c858b160e01b8152905133926001600160a01b0316916385c858b1916004808301926020929190829003018186803b1580156125dc57600080fd5b505afa1580156125f0573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061261491906147b1565b6001600160a01b03161460405180604001604052806002815260200161323760f01b81525090611bb35760405162461bcd60e51b815260040161055b919061512a565b600381015460009064ffffffffff600160801b90910481169042168114156126955750506001810154600160801b90046001600160801b03166106ec565b600183015460028401546000916126cc916001600160801b03600160801b928390048116926126c692041685613b50565b90613b5d565b949350505050565b60058101546040516370a0823160e01b815260009182916001600160a01b03909116906370a082319061270b908790600401614df1565b60206040518083038186803b15801561272357600080fd5b505afa158015612737573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061275b9190614bd4565b60068401546040516370a0823160e01b81526001600160a01b03909116906370a082319061278d908890600401614df1565b60206040518083038186803b1580156127a557600080fd5b505afa1580156127b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127dd9190614bd4565b915091505b9250929050565b60068101546040805163b1bf962d60e01b815290516000926001600160a01b03169163b1bf962d916004808301926020929190829003018186803b15801561283057600080fd5b505afa158015612844573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128689190614bd4565b60018301546003840154919250600160801b8082046001600160801b03908116939216910464ffffffffff166000806128a48787868887613bf0565b91509150612309878787858588613d4d565b6128be6145ad565b60058601546001600160a01b031680825260408051637b98f4df60e11b8152815163f731e9be92600480840193919291829003018186803b15801561290257600080fd5b505afa158015612916573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061293a9190614c93565b60c083015260408083019190915260018701546006880154825163b1bf962d60e01b815292516129df93600160801b9093046001600160801b0316926001600160a01b039092169163b1bf962d916004808301926020929190829003018186803b1580156129a757600080fd5b505afa1580156129bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126c69190614bd4565b60e082018190526007870154604083015160c08401516001600160a01b03909216926329db497d9289928992899289929190612a1a8f613f10565b6040518963ffffffff1660e01b8152600401612a3d989796959493929190614efa565b60606040518083038186803b158015612a5557600080fd5b505afa158015612a69573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a8d9190614cb6565b60a0840152608083015260608201819052604080518082019091526002815261353360f01b6020820152906001600160801b031015612adf5760405162461bcd60e51b815260040161055b919061512a565b506080810151604080518082019091526002815261353560f01b6020820152906001600160801b031015612b265760405162461bcd60e51b815260040161055b919061512a565b5060a08101516040805180820190915260028152610d4d60f21b6020820152906001600160801b031015612b6d5760405162461bcd60e51b815260040161055b919061512a565b506060810151600287018054608084015160038a0180546001600160801b03199081166001600160801b038085169190911790925560a08701519316818616178116600160801b84831681029190911790945560018b01546040516001600160a01b038c16967f804c9b842b2748a22bb64b345453a3de7ca54a6ca45ce00d415894979e22897a96612c0e96919594919380831693919004909116906154ec565b60405180910390a2505050505050565b600082820183811015610f685760405162461bcd60e51b815260040161055b9061515d565b6000610f6883836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250613f1b565b604080518082019091526002815261373760f01b602082015260808310612cbf5760405162461bcd60e51b815260040161055b919061512a565b508160020281612cd0576000612cd3565b60015b60ff16901b826002026001901b19846000015416178360000181905550505050565b612d4d846323b872dd60e01b858585604051602401612d1693929190614ead565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613f47565b50505050565b604080518082019091526002815261373760f01b602082015260808310612d8d5760405162461bcd60e51b815260040161055b919061512a565b508160020260010181612da1576000612da4565b60015b60ff16901b826002026001016001901b19846000015416178360000181905550505050565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4708181148015906126cc575050151592915050565b603854603c54604080518082019091526002815261363560f01b6020820152908210612e415760405162461bcd60e51b815260040161055b919061512a565b506001600160a01b038216600090815260356020526040812060070154600160a01b900460ff16151580612eaa57506000805260376020527fa0a618d80eda9243166be83cb7421d97e9dab6ddddd3c70ac7a6b4440256e8e7546001600160a01b038481169116145b905080610c3757506001600160a01b03919091166000818152603560209081526040808320600701805460ff60a01b1916600160a01b60ff8816021790558483526037909152902080546001600160a01b0319169091179055600101603855565b80516001600160a01b0390811660009081526035602090815260408083208186015185168452603683528184206034548351631f94a27560e31b81529351929691959491169263fca513a89260048083019392829003018186803b158015612f7257600080fd5b505afa158015612f86573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612faa91906147b1565b9050600061304b612fba8561402c565b600a0a61162d8760600151856001600160a01b031663b3596f078a600001516040518263ffffffff1660e01b8152600401612ff59190614df1565b60206040518083038186803b15801561300d57600080fd5b505afa158015613021573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130459190614bd4565b90613442565b905073__$de8c0cf1a7d7c36c802af9a64fb9d86036$__63721a92f986600001518688604001518960600151868b60800151603a5460358c60376038548e6040518d63ffffffff1660e01b81526004016130b09c9b9a99989796959493929190614f3e565b60006040518083038186803b1580156130c857600080fd5b505af41580156130dc573d6000803e3d6000fd5b505050506130e9846127e9565b6000806001876080015160028111156130fe57fe5b600281111561310957fe5b14156131be576003860154600587015460208901516040808b015160608c0151915163b3f1c93d60e01b81526001600160801b0390951696506001600160a01b039093169363b3f1c93d93613165939290918890600401614ed1565b602060405180830381600087803b15801561317f57600080fd5b505af1158015613193573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131b79190614bb8565b905061326d565b600686015460208801516040808a015160608b015160018b0154925163b3f1c93d60e01b81526001600160a01b039095169463b3f1c93d946132189490939291600160801b9091046001600160801b031690600401614e05565b602060405180830381600087803b15801561323257600080fd5b505af1158015613246573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061326a9190614bb8565b90505b801561328f57600786015461328f908690600160a01b900460ff166001612c85565b6132be87600001518860a0015160008a60e001516132ae5760006132b4565b8a606001515b8a939291906128b6565b8660e0015115613356578660a001516001600160a01b0316634efecaa5886020015189606001516040518363ffffffff1660e01b8152600401613302929190614e36565b602060405180830381600087803b15801561331c57600080fd5b505af1158015613330573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133549190614bd4565b505b8660c0015161ffff1687604001516001600160a01b031688600001516001600160a01b03167fc6a898309e823ee50bac64e45ca8adba6690e99e7841c45d754e2a38e9019d9b8a602001518b606001518c60800151600160028111156133b857fe5b8e6080015160028111156133c857fe5b60028111156133d357fe5b146133f25760028d0154600160801b90046001600160801b03166133f4565b885b6040516125349493929190614fe8565b805182511460405180604001604052806002815260200161373360f01b81525090610c375760405162461bcd60e51b815260040161055b919061512a565b60008261345157506000610712565b8282028284828161345e57fe5b0414610f685760405162461bcd60e51b815260040161055b906151c9565b6000610f6883836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250614036565b60006134db6134cc8461406d565b6134d58461406d565b906140bd565b905060006134f16134ea614168565b8390612c1e565b600186015490915061350d9082906001600160801b0316613b5d565b604080518082019091526002815261353160f01b60208201529091506001600160801b038211156135515760405162461bcd60e51b815260040161055b919061512a565b5060019490940180546001600160801b0319166001600160801b0390951694909417909355505050565b600080600080600061358b6145fb565b6135948a614178565b156135b2576000806000806000199550955095509550955050613a2e565b600060e08201525b878160e00151101561398d5760e08101516135d6908b9061417d565b6135df5761397d565b60e0810151600090815260208a81526040808320546001600160a01b03166101e085018190528352908d90529020613616816141ce565b506080860181905260c08601929092525060a0840191909152600a0a60208301526101e082015160405163b3596f0760e01b81526001600160a01b038a169163b3596f07916136689190600401614df1565b60206040518083038186803b15801561368057600080fd5b505afa158015613694573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136b89190614bd4565b825260c0820151158015906136d8575060e08201516136d8908c906141f9565b156137f6578060040160009054906101000a90046001600160a01b03166001600160a01b03166370a082318e6040518263ffffffff1660e01b81526004016137209190614df1565b60206040518083038186803b15801561373857600080fd5b505afa15801561374c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137709190614bd4565b604083018190526020830151835160009261378f929161162d91613442565b6101208401519091506137a29082612c1e565b61012084015260a08301516137c8906137bc908390613442565b61016085015190612c1e565b61016084015260c08301516137ee906137e2908390613442565b61018085015190612c1e565b610180840152505b60e0820151613806908c90614251565b1561397b578060050160009054906101000a90046001600160a01b03166001600160a01b03166370a082318e6040518263ffffffff1660e01b815260040161384e9190614df1565b60206040518083038186803b15801561386657600080fd5b505afa15801561387a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061389e9190614bd4565b8260600181815250506139488160060160009054906101000a90046001600160a01b03166001600160a01b03166370a082318f6040518263ffffffff1660e01b81526004016138ed9190614df1565b60206040518083038186803b15801561390557600080fd5b505afa158015613919573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061393d9190614bd4565b606084015190612c1e565b606083018190526020830151835161397492613968929161162d91613442565b61014084015190612c1e565b6101408301525b505b60e08101805160010190526135ba565b6000816101200151116139a15760006139b6565b6101208101516101608201516139b69161347c565b6101608201526101208101516139cd5760006139e2565b6101208101516101808201516139e29161347c565b61018082018190526101208201516101408301516139ff926142a2565b610100820181905261012082015161014083015161016084015161018090940151919850965091945090925090505b965096509650965096915050565b600080613a4985846142c6565b905083811015613a5d576000915050610f68565b613a678185612c43565b95945050505050565b600290565b303b1590565b600381015460009064ffffffffff600160801b9091048116904216811415613ab257505060018101546001600160801b03166106ec565b600183015460028401546000916126cc916001600160801b03918216916126c6911685614335565b604080516020810190915284548152600090613afc908890889087878761357b565b945050505050670de0b6b3a7640000811015604051806040016040528060018152602001601b60f91b81525090613b465760405162461bcd60e51b815260040161055b919061512a565b5050505050505050565b6000610f68838342614373565b6000821580613b6a575081155b15613b7757506000610712565b816b019d971e4fe8401e740000001981613b8d57fe5b0483111560405180604001604052806002815260200161068760f31b81525090613bca5760405162461bcd60e51b815260040161055b919061512a565b506b033b2e3c9fd0803ce80000006002815b048385020181613be857fe5b049392505050565b600285015460009081906001600160801b031685858215613d1e576000613c178488614335565b9050613c23818a613b5d565b604080518082019091526002815261353160f01b60208201529093506001600160801b03841115613c675760405162461bcd60e51b815260040161055b919061512a565b5060018b0180546001600160801b0319166001600160801b0385161790558915613d1c5760028b0154600090613cad90600160801b90046001600160801b031689613b50565b9050613cb9818a613b5d565b6040805180820190915260028152611a9960f11b60208201529093506001600160801b03841115613cfd5760405162461bcd60e51b815260040161055b919061512a565b505060018b0180546001600160801b03808516600160801b0291161790555b505b600399909901805464ffffffffff60801b1916600160801b4264ffffffffff1602179055989650505050505050565b613d55614695565b613d5e87613f10565b6101208201819052613d70575061143b565b8660050160009054906101000a90046001600160a01b03166001600160a01b031663797743386040518163ffffffff1660e01b815260040160806040518083038186803b158015613dc057600080fd5b505afa158015613dd4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613df89190614ce3565b64ffffffffff1661014085015260a084015282526020820152613e1b8686613b5d565b6080820152613e2a8684613b5d565b606082015260a0810151610140820151613e4c919064ffffffffff8516614373565b60c082018190526020820151613e6191613b5d565b60408201819052608082015182516060840151613e8693926109619290918391612c1e565b60e08201819052610120820151613e9d91906142c6565b61010082018190521561230957600480880154610100830151604051637df5bd3b60e01b81526001600160a01b0390921692637df5bd3b92613ee2929189910161547a565b600060405180830381600087803b158015613efc57600080fd5b505af11580156105c3573d6000803e3d6000fd5b5460401c61ffff1690565b60008184841115613f3f5760405162461bcd60e51b815260040161055b919061512a565b505050900390565b613f59826001600160a01b0316612dc9565b613f755760405162461bcd60e51b815260040161055b906152a2565b60006060836001600160a01b031683604051613f919190614dd5565b6000604051808303816000865af19150503d8060008114613fce576040519150601f19603f3d011682016040523d82523d6000602084013e613fd3565b606091505b509150915081613ff55760405162461bcd60e51b815260040161055b90615194565b805115612d4d57808060200190518101906140109190614bb8565b612d4d5760405162461bcd60e51b815260040161055b90615258565b5460301c60ff1690565b600081836140575760405162461bcd60e51b815260040161055b919061512a565b50600083858161406357fe5b0495945050505050565b6000633b9aca0082810290839082041460405180604001604052806002815260200161068760f31b815250906140b65760405162461bcd60e51b815260040161055b919061512a565b5092915050565b604080518082019091526002815261035360f41b6020820152600090826140f75760405162461bcd60e51b815260040161055b919061512a565b5060408051808201909152600280825261068760f31b60208301528304906b033b2e3c9fd0803ce80000008219048511156141455760405162461bcd60e51b815260040161055b919061512a565b5082816b033b2e3c9fd0803ce80000008602018161415f57fe5b04949350505050565b6b033b2e3c9fd0803ce800000090565b511590565b60006080821060405180604001604052806002815260200161373760f01b815250906141bc5760405162461bcd60e51b815260040161055b919061512a565b50509051600360029092021c16151590565b5461ffff80821692601083901c821692602081901c831692603082901c60ff169260409290921c1690565b60006080821060405180604001604052806002815260200161373760f01b815250906142385760405162461bcd60e51b815260040161055b919061512a565b5050815160016002830281019190911c16151592915050565b60006080821060405180604001604052806002815260200161373760f01b815250906142905760405162461bcd60e51b815260040161055b919061512a565b50509051600160029092021c16151590565b6000826142b25750600019610f68565b6126cc836142c086856142c6565b90614449565b60008215806142d3575081155b156142e057506000610712565b8161138819816142ec57fe5b0483111560405180604001604052806002815260200161068760f31b815250906143295760405162461bcd60e51b815260040161055b919061512a565b50612710600281613bdc565b6000806143494264ffffffffff8516612c43565b90506126cc614356614168565b6301e133806143658785613442565b8161436c57fe5b0490612c1e565b6000806143878364ffffffffff8616612c43565b90508061439e57614396614168565b915050610f68565b60001981016000600283116143b45760006143b9565b600283035b90506301e13380870460006143ce8280613b5d565b905060006143dc8284613b5d565b9050600060026143f0846130458a8a613442565b816143f757fe5b0490506000600661440e8461304589818d8d613442565b8161441557fe5b04905061443981614433848161442b8a8e613442565b614433614168565b90612c1e565b9c9b505050505050505050505050565b604080518082019091526002815261035360f41b6020820152600090826144835760405162461bcd60e51b815260040161055b919061512a565b5060408051808201909152600280825261068760f31b6020830152830490670de0b6b3a76400008219048511156144cd5760405162461bcd60e51b815260040161055b919061512a565b508281670de0b6b3a76400008602018161415f57fe5b6040518061018001604052806144f761454e565b815260006020820181905260408201819052606082018190526080820181905260a0820181905260c0820181905260e082018190526101008201819052610120820181905261014082018190526101609091015290565b6040518060200160405280600081525090565b6040805161012081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e0810182905261010081019190915290565b60405180610100016040528060006001600160a01b03168152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b604051806102400160405280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160001515815260200160006001600160a01b031681526020016000151581526020016000151581525090565b60405180610160016040528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600064ffffffffff1681525090565b80356107128161556f565b60008083601f840112614712578182fd5b50813567ffffffffffffffff811115614729578182fd5b60208301915083602080830285010111156127e257600080fd5b60008083601f840112614754578182fd5b50813567ffffffffffffffff81111561476b578182fd5b6020830191508360208285010111156127e257600080fd5b803561ffff8116811461071257600080fd5b6000602082840312156147a6578081fd5b8135610f688161556f565b6000602082840312156147c2578081fd5b8151610f688161556f565b600080604083850312156147df578081fd5b82356147ea8161556f565b915060208301356147fa8161556f565b809150509250929050565b600080600080600060a0868803121561481c578081fd5b85356148278161556f565b945060208601356148378161556f565b935060408601356148478161556f565b925060608601356148578161556f565b915060808601356148678161556f565b809150509295509295909350565b600080600080600060a0868803121561488c578081fd5b85356148978161556f565b945060208601356148a78161556f565b935060408601356148b78161556f565b925060608601359150608086013561486781615584565b60008060008060008060c087890312156148e6578081fd5b86356148f18161556f565b955060208701356149018161556f565b945060408701356149118161556f565b959894975094956060810135955060808101359460a0909101359350915050565b600080600080600080600080600080600060e08c8e031215614952578485fd5b61495c8d8d6146f6565b9a5067ffffffffffffffff8060208e01351115614977578586fd5b6149878e60208f01358f01614701565b909b50995060408d013581101561499c578586fd5b6149ac8e60408f01358f01614701565b909950975060608d01358110156149c1578586fd5b6149d18e60608f01358f01614701565b90975095506149e38e60808f016146f6565b94508060a08e013511156149f5578384fd5b50614a068d60a08e01358e01614743565b9093509150614a188d60c08e01614783565b90509295989b509295989b9093969950565b60008060408385031215614a3c578081fd5b8235614a478161556f565b915060208301356147fa81615584565b60008060408385031215614a69578182fd5b8235614a748161556f565b946020939093013593505050565b600080600060608486031215614a96578081fd5b8335614aa18161556f565b9250602084013591506040840135614ab88161556f565b809150509250925092565b60008060008060808587031215614ad8578182fd5b8435614ae38161556f565b9350602085013592506040850135614afa8161556f565b9150614b098660608701614783565b905092959194509250565b60008060008060808587031215614b29578182fd5b8435614b348161556f565b935060208501359250604085013591506060850135614b528161556f565b939692955090935050565b600080600080600060a08688031215614b74578283fd5b8535614b7f8161556f565b945060208601359350604086013592506148578760608801614783565b600060208284031215614bad578081fd5b8135610f6881615584565b600060208284031215614bc9578081fd5b8151610f6881615584565b600060208284031215614be5578081fd5b5051919050565b60008060408385031215614bfe578182fd5b82519150602083015167ffffffffffffffff80821115614c1c578283fd5b818501915085601f830112614c2f578283fd5b815181811115614c3d578384fd5b604051601f8201601f191681016020018381118282101715614c5d578586fd5b604052818152838201602001881015614c74578485fd5b614c85826020830160208701615543565b809450505050509250929050565b60008060408385031215614ca5578182fd5b505080516020909101519092909150565b600080600060608486031215614cca578081fd5b8351925060208401519150604084015190509250925092565b60008060008060808587031215614cf8578182fd5b845193506020850151925060408501519150606085015164ffffffffff81168114614b52578182fd5b6001600160a01b0316815260200190565b6001600160a01b03169052565b6000815180845260208085019450808401835b83811015614d6e57815187529582019590820190600101614d52565b509495945050505050565b60008284528282602086013780602084860101526020601f19601f85011685010190509392505050565b60038110614dad57fe5b9052565b519052565b6001600160801b03169052565b64ffffffffff169052565b60ff169052565b60008251614de7818460208701615543565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b03948516815292909316602083015260408201526001600160801b03909116606082015260800190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b0393909316835260208301919091526001600160801b0316604082015260600190565b6001600160a01b03958616815293851660208501529190931660408301526060820192909252901515608082015260a00190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b0394851681529290931660208301526040820152606081019190915260800190565b6001600160a01b03988916815296909716602087015260408601949094526060850192909252608084015260a083015260c082015260e08101919091526101000190565b6001600160a01b039c8d168152602081019b909b52988b1660408b015260608a0197909752608089019590955260a088019390935260c087019190915260e08601526101008501526101208401526101408301529091166101608201526101800190565b6001600160a01b039889168152602081019790975260408701959095526060860193909352608085019190915260a084015260c083015290911660e08201526101000190565b6001600160a01b0394909416845260208401929092526040830152606082015260800190565b600060a0820160a08352806150238b836154c9565b90508b9150825b8b81101561505657602083016150498361504483876146f6565b614d21565b909350915060010161502a565b5083810360208501528881526001600160fb1b03891115615075578283fd5b602089029150818a602083013701602081810183815284830390910160408501526150a08189614d3f565b9150506150b06060840187614d32565b82810360808401526150c3818587614d79565b9b9a5050505050505050505050565b6020808252825182820181905260009190848201906040850190845b818110156151135783516001600160a01b0316835292840192918401916001016150ee565b50909695505050505050565b901515815260200190565b6000602082528251806020840152615149816040850160208701615543565b601f01601f19169190910160400192915050565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b6020808252818101527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b6020808252602e908201527f436f6e747261637420696e7374616e63652068617320616c726561647920626560408201526d195b881a5b9a5d1a585b1a5e995960921b606082015260800190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b6020808252601f908201527f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e747261637400604082015260600190565b9051815260200190565b6000610180820190506152f7828451614db1565b60208301516153096020840182614db6565b50604083015161531c6040840182614db6565b50606083015161532f6060840182614db6565b5060808301516153426080840182614db6565b5060a083015161535560a0840182614db6565b5060c083015161536860c0840182614dc3565b5060e083015161537b60e0840182614d32565b506101008084015161538f82850182614d32565b5050610120808401516153a482850182614d32565b5050610140808401516153b982850182614d32565b5050610160808401516153ce82850182614dce565b505092915050565b9485526001600160a01b03938416602086015291831660408501528216606084015216608082015260a00190565b9788526001600160a01b03968716602089015294151560408801526060870193909352608086019190915260a085015260c08401521660e08201526101000190565b600060a0820190508682528560208301528460408301528360608301526154706080830184614da3565b9695505050505050565b918252602082015260400190565b8681526020810186905260c081016154a36040830187614da3565b6001600160a01b03949094166060820152608081019290925260a0909101529392505050565b90815260200190565b928352602083019190915261ffff16604082015260600190565b948552602085019390935260408401919091526001600160801b03908116606084015216608082015260a00190565b958652602086019490945260408501929092526060840152608083015260a082015260c00190565b60005b8381101561555e578181015183820152602001615546565b83811115612d4d5750506000910152565b6001600160a01b0381168114611bb357600080fd5b8015158114611bb357600080fdfea26469706673582212209188474349aa7551c67c51f7a8777c6be7c4d8f5dc7b2b0670a915f3dfe6401264736f6c634300060c0033", + "deployedBytecode": "", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/external/abi/aave/v2/AaveV2LendingPoolAddressesProvider.json b/external/abi/aave/v2/AaveV2LendingPoolAddressesProvider.json new file mode 100644 index 000000000..db1621fca --- /dev/null +++ b/external/abi/aave/v2/AaveV2LendingPoolAddressesProvider.json @@ -0,0 +1,483 @@ +{ + "contractName": "AaveV2LendingPoolAddressesProvider", + "abi": [ + { + "inputs": [ + { + "internalType": "string", + "name": "marketId", + "type": "string" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "id", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "newAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "hasProxy", + "type": "bool" + } + ], + "name": "AddressSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "newAddress", + "type": "address" + } + ], + "name": "ConfigurationAdminUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "newAddress", + "type": "address" + } + ], + "name": "EmergencyAdminUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "newAddress", + "type": "address" + } + ], + "name": "LendingPoolCollateralManagerUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "newAddress", + "type": "address" + } + ], + "name": "LendingPoolConfiguratorUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "newAddress", + "type": "address" + } + ], + "name": "LendingPoolUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "newAddress", + "type": "address" + } + ], + "name": "LendingRateOracleUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string", + "name": "newMarketId", + "type": "string" + } + ], + "name": "MarketIdSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "newAddress", + "type": "address" + } + ], + "name": "PriceOracleUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "id", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "newAddress", + "type": "address" + } + ], + "name": "ProxyCreated", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "id", + "type": "bytes32" + } + ], + "name": "getAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getEmergencyAdmin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getLendingPool", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getLendingPoolCollateralManager", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getLendingPoolConfigurator", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getLendingRateOracle", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getMarketId", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getPoolAdmin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getPriceOracle", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "id", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "newAddress", + "type": "address" + } + ], + "name": "setAddress", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "id", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "implementationAddress", + "type": "address" + } + ], + "name": "setAddressAsProxy", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "emergencyAdmin", + "type": "address" + } + ], + "name": "setEmergencyAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "manager", + "type": "address" + } + ], + "name": "setLendingPoolCollateralManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "configurator", + "type": "address" + } + ], + "name": "setLendingPoolConfiguratorImpl", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "setLendingPoolImpl", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "lendingRateOracle", + "type": "address" + } + ], + "name": "setLendingRateOracle", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "marketId", + "type": "string" + } + ], + "name": "setMarketId", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "admin", + "type": "address" + } + ], + "name": "setPoolAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "priceOracle", + "type": "address" + } + ], + "name": "setPriceOracle", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bytecode": "0x60806040523480156200001157600080fd5b5060405162001dca38038062001dca833981810160405260208110156200003757600080fd5b81019080805160405193929190846401000000008211156200005857600080fd5b9083019060208201858111156200006e57600080fd5b82516401000000008111828201881017156200008957600080fd5b82525081516020918201929091019080838360005b83811015620000b85781810151838201526020016200009e565b50505050905090810190601f168015620000e65780820380516001836020036101000a031916815260200191505b506040525050506000620000ff6200015b60201b60201c565b600080546001600160a01b0319166001600160a01b0383169081178255604051929350917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a35062000154816200015f565b50620002b0565b3390565b80516200017490600190602084019062000214565b507f5e667c32fd847cf8bce48ab3400175cbf107bdc82b2dea62e3364909dfaee799816040518080602001828103825283818151815260200191508051906020019080838360005b83811015620001d6578181015183820152602001620001bc565b50505050905090810190601f168015620002045780820380516001836020036101000a031916815260200191505b509250505060405180910390a150565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106200025757805160ff191683800117855562000287565b8280016001018555821562000287579182015b82811115620002875782518255916020019190600101906200026a565b506200029592915062000299565b5090565b5b808211156200029557600081556001016200029a565b611b0a80620002c06000396000f3fe608060405234801561001057600080fd5b50600436106101425760003560e01c8063715018a6116100b8578063c12542df1161007c578063c12542df14610347578063ca446dd91461036d578063ddcaa9ea14610399578063f2fde38b146103a1578063f67b1847146103c7578063fca513a81461046d57610142565b8063715018a614610301578063820d12741461030957806385c858b11461032f5780638da5cb5b14610337578063aecda3781461033f57610142565b8063398e55531161010a578063398e5553146101de578063530e784f14610204578063568ef4701461022a5780635aef021f146102a75780635dcc528c146102cd578063712d9171146102f957610142565b80630261bf8b1461014757806321f8a7211461016b578063283d62ad1461018857806335da3394146101b05780633618abba146101d6575b600080fd5b61014f610475565b604080516001600160a01b039092168252519081900360200190f35b61014f6004803603602081101561018157600080fd5b5035610494565b6101ae6004803603602081101561019e57600080fd5b50356001600160a01b03166104af565b005b6101ae600480360360208110156101c657600080fd5b50356001600160a01b0316610587565b61014f610664565b6101ae600480360360208110156101f457600080fd5b50356001600160a01b0316610685565b6101ae6004803603602081101561021a57600080fd5b50356001600160a01b0316610765565b61023261083f565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561026c578181015183820152602001610254565b50505050905090810190601f1680156102995780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101ae600480360360208110156102bd57600080fd5b50356001600160a01b03166108d4565b6101ae600480360360408110156102e357600080fd5b50803590602001356001600160a01b031661097c565b61014f610a25565b6101ae610a45565b6101ae6004803603602081101561031f57600080fd5b50356001600160a01b0316610ae7565b61014f610bc8565b61014f610bef565b61014f610bfe565b6101ae6004803603602081101561035d57600080fd5b50356001600160a01b0316610c16565b6101ae6004803603604081101561038357600080fd5b50803590602001356001600160a01b0316610ccb565b61014f610d8c565b6101ae600480360360208110156103b757600080fd5b50356001600160a01b0316610da9565b6101ae600480360360208110156103dd57600080fd5b8101906020810181356401000000008111156103f857600080fd5b82018360208201111561040a57600080fd5b8035906020019184600183028401116401000000008311171561042c57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610ea1945050505050565b61014f610f05565b600061048f6b13115391125391d7d413d3d360a21b610494565b905090565b6000908152600260205260409020546001600160a01b031690565b6104b7610f1f565b6000546001600160a01b03908116911614610507576040805162461bcd60e51b81526020600482018190526024820152600080516020611ab5833981519152604482015290519081900360640190fd5b692827a7a62fa0a226a4a760b11b600090815260026020527f8625fbc469bac10fd11de1d783dcd446542784dbcc535ef64a1da61860fda74c80546001600160a01b0319166001600160a01b03841690811790915560405190917fc20a317155a9e7d84e06b716b4b355d47742ab9f8c5d630e7f556553f582430d91a250565b61058f610f1f565b6000546001600160a01b039081169116146105df576040805162461bcd60e51b81526020600482018190526024820152600080516020611ab5833981519152604482015290519081900360640190fd5b6e22a6a2a923a2a721acafa0a226a4a760891b600090815260026020527f767aa9c986e1d88108b2558f00fbd21b689a0397581446e2e868cd70421026cc80546001600160a01b0319166001600160a01b03841690811790915560405190917fe19673fc861bfeb894cf2d6b7662505497ef31c0f489b742db24ee331082691691a250565b600061048f724c454e44494e475f524154455f4f5241434c4560681b610494565b61068d610f1f565b6000546001600160a01b039081169116146106dd576040805162461bcd60e51b81526020600482018190526024820152600080516020611ab5833981519152604482015290519081900360640190fd5b7121a7a62620aa22a920a62fa6a0a720a3a2a960711b600090815260026020527f65e3f3080e9127c1765503a54b8dbb495249e66169f096dfc87ee63bed17e22c80546001600160a01b0319166001600160a01b03841690811790915560405190917f991888326f0eab3df6084aadb82bee6781b5c9aa75379e8bc50ae8693454163891a250565b61076d610f1f565b6000546001600160a01b039081169116146107bd576040805162461bcd60e51b81526020600482018190526024820152600080516020611ab5833981519152604482015290519081900360640190fd5b6b50524943455f4f5241434c4560a01b600090815260026020527f740f710666bd7a12af42df98311e541e47f7fd33d382d11602457a6d540cbd6380546001600160a01b0319166001600160a01b03841690811790915560405190917fefe8ab924ca486283a79dc604baa67add51afb82af1db8ac386ebbba643cdffd91a250565b60018054604080516020601f600260001961010087891615020190951694909404938401819004810282018101909252828152606093909290918301828280156108ca5780601f1061089f576101008083540402835291602001916108ca565b820191906000526020600020905b8154815290600101906020018083116108ad57829003601f168201915b5050505050905090565b6108dc610f1f565b6000546001600160a01b0390811691161461092c576040805162461bcd60e51b81526020600482018190526024820152600080516020611ab5833981519152604482015290519081900360640190fd5b6109456b13115391125391d7d413d3d360a21b82610f23565b6040516001600160a01b038216907fc4e6c6cdf28d0edbd8bcf071d724d33cc2e7a30be7d06443925656e9cb492aa490600090a250565b610984610f1f565b6000546001600160a01b039081169116146109d4576040805162461bcd60e51b81526020600482018190526024820152600080516020611ab5833981519152604482015290519081900360640190fd5b6109de8282610f23565b604080518381526001602082015281516001600160a01b038416927ff2689d5d5cd0c639e137642cae5d40afced201a1a0327e7ac9358461dc9fff31928290030190a25050565b600061048f7121a7a62620aa22a920a62fa6a0a720a3a2a960711b610494565b610a4d610f1f565b6000546001600160a01b03908116911614610a9d576040805162461bcd60e51b81526020600482018190526024820152600080516020611ab5833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b610aef610f1f565b6000546001600160a01b03908116911614610b3f576040805162461bcd60e51b81526020600482018190526024820152600080516020611ab5833981519152604482015290519081900360640190fd5b724c454e44494e475f524154455f4f5241434c4560681b600090815260026020527f10f0e20294ece4bd93e7a467dbf22ab9ab1740ebd0a532cc53066601e880c0cf80546001600160a01b0319166001600160a01b03841690811790915560405190917f5c29179aba6942020a8a2d38f65de02fb6b7f784e7f049ed3a3cab97621859b591a250565b600061048f782622a72224a723afa827a7a62fa1a7a72324a3aaa920aa27a960391b610494565b6000546001600160a01b031690565b600061048f692827a7a62fa0a226a4a760b11b610494565b610c1e610f1f565b6000546001600160a01b03908116911614610c6e576040805162461bcd60e51b81526020600482018190526024820152600080516020611ab5833981519152604482015290519081900360640190fd5b610c94782622a72224a723afa827a7a62fa1a7a72324a3aaa920aa27a960391b82610f23565b6040516001600160a01b038216907fdfabe479bad36782fb1e77fbfddd4e382671713527e4786cfc93a022ae76372990600090a250565b610cd3610f1f565b6000546001600160a01b03908116911614610d23576040805162461bcd60e51b81526020600482018190526024820152600080516020611ab5833981519152604482015290519081900360640190fd5b600082815260026020908152604080832080546001600160a01b0319166001600160a01b03861690811790915581518681529283019390935280517ff2689d5d5cd0c639e137642cae5d40afced201a1a0327e7ac9358461dc9fff319281900390910190a25050565b600061048f6e22a6a2a923a2a721acafa0a226a4a760891b610494565b610db1610f1f565b6000546001600160a01b03908116911614610e01576040805162461bcd60e51b81526020600482018190526024820152600080516020611ab5833981519152604482015290519081900360640190fd5b6001600160a01b038116610e465760405162461bcd60e51b8152600401808060200182810382526026815260200180611a8f6026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b610ea9610f1f565b6000546001600160a01b03908116911614610ef9576040805162461bcd60e51b81526020600482018190526024820152600080516020611ab5833981519152604482015290519081900360640190fd5b610f02816111cb565b50565b600061048f6b50524943455f4f5241434c4560a01b610494565b3390565b6000828152600260209081526040918290205482513060248083019190915284518083039091018152604490910190935290820180516001600160e01b031663189acdbd60e31b1790526001600160a01b0316908190816110f25730604051610f8b9061127b565b6001600160a01b03909116815260405190819003602001906000f080158015610fb8573d6000803e3d6000fd5b509150816001600160a01b031663d1f5789485836040518363ffffffff1660e01b815260040180836001600160a01b0316815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561102757818101518382015260200161100f565b50505050905090810190601f1680156110545780820380516001836020036101000a031916815260200191505b509350505050600060405180830381600087803b15801561107457600080fd5b505af1158015611088573d6000803e3d6000fd5b50505060008681526002602090815260409182902080546001600160a01b0319166001600160a01b038716908117909155825189815292519093507f1eb35cb4b5bbb23d152f3b4016a5a46c37a07ae930ed0956aba951e2311424389281900390910190a26111c4565b816001600160a01b0316634f1ef28685836040518363ffffffff1660e01b815260040180836001600160a01b0316815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561115e578181015183820152602001611146565b50505050905090810190601f16801561118b5780820380516001836020036101000a031916815260200191505b509350505050600060405180830381600087803b1580156111ab57600080fd5b505af11580156111bf573d6000803e3d6000fd5b505050505b5050505050565b80516111de906001906020840190611288565b507f5e667c32fd847cf8bce48ab3400175cbf107bdc82b2dea62e3364909dfaee799816040518080602001828103825283818151815260200191508051906020019080838360005b8381101561123e578181015183820152602001611226565b50505050905090810190601f16801561126b5780820380516001836020036101000a031916815260200191505b509250505060405180910390a150565b6107738061131c83390190565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106112c957805160ff19168380011785556112f6565b828001600101855582156112f6579182015b828111156112f65782518255916020019190600101906112db565b50611302929150611306565b5090565b5b80821115611302576000815560010161130756fe60a060405234801561001057600080fd5b506040516107733803806107738339818101604052602081101561003357600080fd5b5051606081901b6001600160601b0319166080526001600160a01b03166106f36100806000398061022852806102725280610331528061045e528061048752806105af52506106f36000f3fe60806040526004361061004a5760003560e01c80633659cfe6146100545780634f1ef286146100875780635c60da1b14610107578063d1f5789414610138578063f851a440146101ee575b610052610203565b005b34801561006057600080fd5b506100526004803603602081101561007757600080fd5b50356001600160a01b031661021d565b6100526004803603604081101561009d57600080fd5b6001600160a01b0382351691908101906040810160208201356401000000008111156100c857600080fd5b8201836020820111156100da57600080fd5b803590602001918460018302840111640100000000831117156100fc57600080fd5b509092509050610267565b34801561011357600080fd5b5061011c610324565b604080516001600160a01b039092168252519081900360200190f35b6100526004803603604081101561014e57600080fd5b6001600160a01b03823516919081019060408101602082013564010000000081111561017957600080fd5b82018360208201111561018b57600080fd5b803590602001918460018302840111640100000000831117156101ad57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610371945050505050565b3480156101fa57600080fd5b5061011c610451565b61020b6104ab565b61021b6102166104b3565b6104d8565b565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016141561025c57610257816104fc565b610264565b610264610203565b50565b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161415610317576102a1836104fc565b6000836001600160a01b031683836040518083838082843760405192019450600093509091505080830381855af49150503d80600081146102fe576040519150601f19603f3d011682016040523d82523d6000602084013e610303565b606091505b505090508061031157600080fd5b5061031f565b61031f610203565b505050565b6000336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614156103665761035f6104b3565b905061036e565b61036e610203565b90565b600061037b6104b3565b6001600160a01b03161461038e57600080fd5b6103978261053c565b80511561044d576000826001600160a01b0316826040518082805190602001908083835b602083106103da5780518252601f1990920191602091820191016103bb565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d806000811461043a576040519150601f19603f3d011682016040523d82523d6000602084013e61043f565b606091505b505090508061031f57600080fd5b5050565b6000336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016141561036657507f000000000000000000000000000000000000000000000000000000000000000061036e565b61021b6105a4565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5490565b3660008037600080366000845af43d6000803e8080156104f7573d6000f35b3d6000fd5b6105058161053c565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b61054581610614565b6105805760405162461bcd60e51b815260040180806020018281038252603b815260200180610683603b913960400191505060405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc55565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016141561060c5760405162461bcd60e51b81526004018080602001828103825260328152602001806106516032913960400191505060405180910390fd5b61021b61021b565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47081811480159061064857508115155b94935050505056fe43616e6e6f742063616c6c2066616c6c6261636b2066756e6374696f6e2066726f6d207468652070726f78792061646d696e43616e6e6f742073657420612070726f787920696d706c656d656e746174696f6e20746f2061206e6f6e2d636f6e74726163742061646472657373a26469706673582212203801682b75a74ce25ca5dbe58739c5b62298b707b9119c9413881c56f29bcfa864736f6c634300060c00334f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573734f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572a2646970667358221220f13a46c313fb355d6a9419920c6e2fd982efdc1f9b41ed61f3e408eb17ac382764736f6c634300060c0033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106101425760003560e01c8063715018a6116100b8578063c12542df1161007c578063c12542df14610347578063ca446dd91461036d578063ddcaa9ea14610399578063f2fde38b146103a1578063f67b1847146103c7578063fca513a81461046d57610142565b8063715018a614610301578063820d12741461030957806385c858b11461032f5780638da5cb5b14610337578063aecda3781461033f57610142565b8063398e55531161010a578063398e5553146101de578063530e784f14610204578063568ef4701461022a5780635aef021f146102a75780635dcc528c146102cd578063712d9171146102f957610142565b80630261bf8b1461014757806321f8a7211461016b578063283d62ad1461018857806335da3394146101b05780633618abba146101d6575b600080fd5b61014f610475565b604080516001600160a01b039092168252519081900360200190f35b61014f6004803603602081101561018157600080fd5b5035610494565b6101ae6004803603602081101561019e57600080fd5b50356001600160a01b03166104af565b005b6101ae600480360360208110156101c657600080fd5b50356001600160a01b0316610587565b61014f610664565b6101ae600480360360208110156101f457600080fd5b50356001600160a01b0316610685565b6101ae6004803603602081101561021a57600080fd5b50356001600160a01b0316610765565b61023261083f565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561026c578181015183820152602001610254565b50505050905090810190601f1680156102995780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101ae600480360360208110156102bd57600080fd5b50356001600160a01b03166108d4565b6101ae600480360360408110156102e357600080fd5b50803590602001356001600160a01b031661097c565b61014f610a25565b6101ae610a45565b6101ae6004803603602081101561031f57600080fd5b50356001600160a01b0316610ae7565b61014f610bc8565b61014f610bef565b61014f610bfe565b6101ae6004803603602081101561035d57600080fd5b50356001600160a01b0316610c16565b6101ae6004803603604081101561038357600080fd5b50803590602001356001600160a01b0316610ccb565b61014f610d8c565b6101ae600480360360208110156103b757600080fd5b50356001600160a01b0316610da9565b6101ae600480360360208110156103dd57600080fd5b8101906020810181356401000000008111156103f857600080fd5b82018360208201111561040a57600080fd5b8035906020019184600183028401116401000000008311171561042c57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610ea1945050505050565b61014f610f05565b600061048f6b13115391125391d7d413d3d360a21b610494565b905090565b6000908152600260205260409020546001600160a01b031690565b6104b7610f1f565b6000546001600160a01b03908116911614610507576040805162461bcd60e51b81526020600482018190526024820152600080516020611ab5833981519152604482015290519081900360640190fd5b692827a7a62fa0a226a4a760b11b600090815260026020527f8625fbc469bac10fd11de1d783dcd446542784dbcc535ef64a1da61860fda74c80546001600160a01b0319166001600160a01b03841690811790915560405190917fc20a317155a9e7d84e06b716b4b355d47742ab9f8c5d630e7f556553f582430d91a250565b61058f610f1f565b6000546001600160a01b039081169116146105df576040805162461bcd60e51b81526020600482018190526024820152600080516020611ab5833981519152604482015290519081900360640190fd5b6e22a6a2a923a2a721acafa0a226a4a760891b600090815260026020527f767aa9c986e1d88108b2558f00fbd21b689a0397581446e2e868cd70421026cc80546001600160a01b0319166001600160a01b03841690811790915560405190917fe19673fc861bfeb894cf2d6b7662505497ef31c0f489b742db24ee331082691691a250565b600061048f724c454e44494e475f524154455f4f5241434c4560681b610494565b61068d610f1f565b6000546001600160a01b039081169116146106dd576040805162461bcd60e51b81526020600482018190526024820152600080516020611ab5833981519152604482015290519081900360640190fd5b7121a7a62620aa22a920a62fa6a0a720a3a2a960711b600090815260026020527f65e3f3080e9127c1765503a54b8dbb495249e66169f096dfc87ee63bed17e22c80546001600160a01b0319166001600160a01b03841690811790915560405190917f991888326f0eab3df6084aadb82bee6781b5c9aa75379e8bc50ae8693454163891a250565b61076d610f1f565b6000546001600160a01b039081169116146107bd576040805162461bcd60e51b81526020600482018190526024820152600080516020611ab5833981519152604482015290519081900360640190fd5b6b50524943455f4f5241434c4560a01b600090815260026020527f740f710666bd7a12af42df98311e541e47f7fd33d382d11602457a6d540cbd6380546001600160a01b0319166001600160a01b03841690811790915560405190917fefe8ab924ca486283a79dc604baa67add51afb82af1db8ac386ebbba643cdffd91a250565b60018054604080516020601f600260001961010087891615020190951694909404938401819004810282018101909252828152606093909290918301828280156108ca5780601f1061089f576101008083540402835291602001916108ca565b820191906000526020600020905b8154815290600101906020018083116108ad57829003601f168201915b5050505050905090565b6108dc610f1f565b6000546001600160a01b0390811691161461092c576040805162461bcd60e51b81526020600482018190526024820152600080516020611ab5833981519152604482015290519081900360640190fd5b6109456b13115391125391d7d413d3d360a21b82610f23565b6040516001600160a01b038216907fc4e6c6cdf28d0edbd8bcf071d724d33cc2e7a30be7d06443925656e9cb492aa490600090a250565b610984610f1f565b6000546001600160a01b039081169116146109d4576040805162461bcd60e51b81526020600482018190526024820152600080516020611ab5833981519152604482015290519081900360640190fd5b6109de8282610f23565b604080518381526001602082015281516001600160a01b038416927ff2689d5d5cd0c639e137642cae5d40afced201a1a0327e7ac9358461dc9fff31928290030190a25050565b600061048f7121a7a62620aa22a920a62fa6a0a720a3a2a960711b610494565b610a4d610f1f565b6000546001600160a01b03908116911614610a9d576040805162461bcd60e51b81526020600482018190526024820152600080516020611ab5833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b610aef610f1f565b6000546001600160a01b03908116911614610b3f576040805162461bcd60e51b81526020600482018190526024820152600080516020611ab5833981519152604482015290519081900360640190fd5b724c454e44494e475f524154455f4f5241434c4560681b600090815260026020527f10f0e20294ece4bd93e7a467dbf22ab9ab1740ebd0a532cc53066601e880c0cf80546001600160a01b0319166001600160a01b03841690811790915560405190917f5c29179aba6942020a8a2d38f65de02fb6b7f784e7f049ed3a3cab97621859b591a250565b600061048f782622a72224a723afa827a7a62fa1a7a72324a3aaa920aa27a960391b610494565b6000546001600160a01b031690565b600061048f692827a7a62fa0a226a4a760b11b610494565b610c1e610f1f565b6000546001600160a01b03908116911614610c6e576040805162461bcd60e51b81526020600482018190526024820152600080516020611ab5833981519152604482015290519081900360640190fd5b610c94782622a72224a723afa827a7a62fa1a7a72324a3aaa920aa27a960391b82610f23565b6040516001600160a01b038216907fdfabe479bad36782fb1e77fbfddd4e382671713527e4786cfc93a022ae76372990600090a250565b610cd3610f1f565b6000546001600160a01b03908116911614610d23576040805162461bcd60e51b81526020600482018190526024820152600080516020611ab5833981519152604482015290519081900360640190fd5b600082815260026020908152604080832080546001600160a01b0319166001600160a01b03861690811790915581518681529283019390935280517ff2689d5d5cd0c639e137642cae5d40afced201a1a0327e7ac9358461dc9fff319281900390910190a25050565b600061048f6e22a6a2a923a2a721acafa0a226a4a760891b610494565b610db1610f1f565b6000546001600160a01b03908116911614610e01576040805162461bcd60e51b81526020600482018190526024820152600080516020611ab5833981519152604482015290519081900360640190fd5b6001600160a01b038116610e465760405162461bcd60e51b8152600401808060200182810382526026815260200180611a8f6026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b610ea9610f1f565b6000546001600160a01b03908116911614610ef9576040805162461bcd60e51b81526020600482018190526024820152600080516020611ab5833981519152604482015290519081900360640190fd5b610f02816111cb565b50565b600061048f6b50524943455f4f5241434c4560a01b610494565b3390565b6000828152600260209081526040918290205482513060248083019190915284518083039091018152604490910190935290820180516001600160e01b031663189acdbd60e31b1790526001600160a01b0316908190816110f25730604051610f8b9061127b565b6001600160a01b03909116815260405190819003602001906000f080158015610fb8573d6000803e3d6000fd5b509150816001600160a01b031663d1f5789485836040518363ffffffff1660e01b815260040180836001600160a01b0316815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561102757818101518382015260200161100f565b50505050905090810190601f1680156110545780820380516001836020036101000a031916815260200191505b509350505050600060405180830381600087803b15801561107457600080fd5b505af1158015611088573d6000803e3d6000fd5b50505060008681526002602090815260409182902080546001600160a01b0319166001600160a01b038716908117909155825189815292519093507f1eb35cb4b5bbb23d152f3b4016a5a46c37a07ae930ed0956aba951e2311424389281900390910190a26111c4565b816001600160a01b0316634f1ef28685836040518363ffffffff1660e01b815260040180836001600160a01b0316815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561115e578181015183820152602001611146565b50505050905090810190601f16801561118b5780820380516001836020036101000a031916815260200191505b509350505050600060405180830381600087803b1580156111ab57600080fd5b505af11580156111bf573d6000803e3d6000fd5b505050505b5050505050565b80516111de906001906020840190611288565b507f5e667c32fd847cf8bce48ab3400175cbf107bdc82b2dea62e3364909dfaee799816040518080602001828103825283818151815260200191508051906020019080838360005b8381101561123e578181015183820152602001611226565b50505050905090810190601f16801561126b5780820380516001836020036101000a031916815260200191505b509250505060405180910390a150565b6107738061131c83390190565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106112c957805160ff19168380011785556112f6565b828001600101855582156112f6579182015b828111156112f65782518255916020019190600101906112db565b50611302929150611306565b5090565b5b80821115611302576000815560010161130756fe60a060405234801561001057600080fd5b506040516107733803806107738339818101604052602081101561003357600080fd5b5051606081901b6001600160601b0319166080526001600160a01b03166106f36100806000398061022852806102725280610331528061045e528061048752806105af52506106f36000f3fe60806040526004361061004a5760003560e01c80633659cfe6146100545780634f1ef286146100875780635c60da1b14610107578063d1f5789414610138578063f851a440146101ee575b610052610203565b005b34801561006057600080fd5b506100526004803603602081101561007757600080fd5b50356001600160a01b031661021d565b6100526004803603604081101561009d57600080fd5b6001600160a01b0382351691908101906040810160208201356401000000008111156100c857600080fd5b8201836020820111156100da57600080fd5b803590602001918460018302840111640100000000831117156100fc57600080fd5b509092509050610267565b34801561011357600080fd5b5061011c610324565b604080516001600160a01b039092168252519081900360200190f35b6100526004803603604081101561014e57600080fd5b6001600160a01b03823516919081019060408101602082013564010000000081111561017957600080fd5b82018360208201111561018b57600080fd5b803590602001918460018302840111640100000000831117156101ad57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610371945050505050565b3480156101fa57600080fd5b5061011c610451565b61020b6104ab565b61021b6102166104b3565b6104d8565b565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016141561025c57610257816104fc565b610264565b610264610203565b50565b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161415610317576102a1836104fc565b6000836001600160a01b031683836040518083838082843760405192019450600093509091505080830381855af49150503d80600081146102fe576040519150601f19603f3d011682016040523d82523d6000602084013e610303565b606091505b505090508061031157600080fd5b5061031f565b61031f610203565b505050565b6000336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614156103665761035f6104b3565b905061036e565b61036e610203565b90565b600061037b6104b3565b6001600160a01b03161461038e57600080fd5b6103978261053c565b80511561044d576000826001600160a01b0316826040518082805190602001908083835b602083106103da5780518252601f1990920191602091820191016103bb565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d806000811461043a576040519150601f19603f3d011682016040523d82523d6000602084013e61043f565b606091505b505090508061031f57600080fd5b5050565b6000336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016141561036657507f000000000000000000000000000000000000000000000000000000000000000061036e565b61021b6105a4565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5490565b3660008037600080366000845af43d6000803e8080156104f7573d6000f35b3d6000fd5b6105058161053c565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b61054581610614565b6105805760405162461bcd60e51b815260040180806020018281038252603b815260200180610683603b913960400191505060405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc55565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016141561060c5760405162461bcd60e51b81526004018080602001828103825260328152602001806106516032913960400191505060405180910390fd5b61021b61021b565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47081811480159061064857508115155b94935050505056fe43616e6e6f742063616c6c2066616c6c6261636b2066756e6374696f6e2066726f6d207468652070726f78792061646d696e43616e6e6f742073657420612070726f787920696d706c656d656e746174696f6e20746f2061206e6f6e2d636f6e74726163742061646472657373a26469706673582212203801682b75a74ce25ca5dbe58739c5b62298b707b9119c9413881c56f29bcfa864736f6c634300060c00334f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573734f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572a2646970667358221220f13a46c313fb355d6a9419920c6e2fd982efdc1f9b41ed61f3e408eb17ac382764736f6c634300060c0033", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/external/abi/aave/v2/AaveV2LendingPoolCollateralManager.json b/external/abi/aave/v2/AaveV2LendingPoolCollateralManager.json new file mode 100644 index 000000000..7dcc2a175 --- /dev/null +++ b/external/abi/aave/v2/AaveV2LendingPoolCollateralManager.json @@ -0,0 +1,140 @@ +{ + "contractName": "AaveV2LendingPoolCollateralManager", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "collateral", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "principal", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "debtToCover", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "liquidatedCollateralAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "liquidator", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "receiveAToken", + "type": "bool" + } + ], + "name": "LiquidationCall", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "reserve", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "ReserveUsedAsCollateralDisabled", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "reserve", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "ReserveUsedAsCollateralEnabled", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "collateralAsset", + "type": "address" + }, + { + "internalType": "address", + "name": "debtAsset", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "uint256", + "name": "debtToCover", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "receiveAToken", + "type": "bool" + } + ], + "name": "liquidationCall", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bytecode": "0x60806040526000805534801561001457600080fd5b506129ef806100246000396000f3fe608060405234801561001057600080fd5b506004361061002a5760003560e01c8062a718a91461002f575b600080fd5b610073600480360360a081101561004557600080fd5b506001600160a01b0381358116916020810135821691604082013516906060810135906080013515156100f2565b6040518083815260200180602001828103825283818151815260200191508051906020019080838360005b838110156100b657818101518382015260200161009e565b50505050905090810190601f1680156100e35780820380516001836020036101000a031916815260200191505b50935050505060405180910390f35b6001600160a01b0380861660009081526035602090815260408083208885168452818420948816845260369092528220919260609261012f61274e565b6040805160208082018352845482526038546034548451631f94a27560e31b815294516101c1958f95603595909460379490936001600160a01b039091169263fca513a8926004808301939192829003018186803b15801561019057600080fd5b505afa1580156101a4573d6000803e3d6000fd5b505050506040513d60208110156101ba57600080fd5b5051610971565b610140860152506101d892508b9150859050610e37565b60408301819052602083018290526101408301516101fd928792879287929091610f3a565b6102008301526101e08201819052600090600981111561021957fe5b600981111561022457fe5b1461024257806101e001518161020001519550955050505050610967565b6004808501546001600160a01b039081166101808401819052604080516370a0823160e01b8152928d169383019390935291516370a0823191602480820192602092909190829003018186803b15801561029b57600080fd5b505afa1580156102af573d6000803e3d6000fd5b505050506040513d60208110156102c557600080fd5b50518152604081015160208201516102ea91611388916102e491611077565b906110da565b6060820181905288116102fd5787610303565b80606001515b60808201819052815161031e91869186918f918f91906111c4565b6101208301819052610100830191909152608082015111156103465761012081015160808201525b866104085760008b6001600160a01b03166370a082318361018001516040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561039f57600080fd5b505afa1580156103b3573d6000803e3d6000fd5b505050506040513d60208110156103c957600080fd5b505161010083015190915081101561040657600560405180604001604052806002815260200161343560f01b815250965096505050505050610967565b505b6104118361143d565b80608001518160400151106104b45760068301546080820151600185015460408051637a94c56560e11b81526001600160a01b038e811660048301526024820194909452600160801b9092046001600160801b0316604483015251919092169163f5298aca91606480830192600092919082900301818387803b15801561049757600080fd5b505af11580156104ab573d6000803e3d6000fd5b505050506105d8565b60408101511561054d57600683015460408281015160018601548251637a94c56560e11b81526001600160a01b038e811660048301526024820193909352600160801b9091046001600160801b03166044820152915192169163f5298aca9160648082019260009290919082900301818387803b15801561053457600080fd5b505af1158015610548573d6000803e3d6000fd5b505050505b6005830154604082015160808301516001600160a01b0390921691639dc29fac918c9161057991611507565b6040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050600060405180830381600087803b1580156105bf57600080fd5b505af11580156105d3573d6000803e3d6000fd5b505050505b600483015460808201516105fb9185918d916001600160a01b0316906000611549565b8615610777578061018001516001600160a01b03166370a08231336040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561065357600080fd5b505afa158015610667573d6000803e3d6000fd5b505050506040513d602081101561067d57600080fd5b50516101608201526101808101516101008201516040805163f866c31960e01b81526001600160a01b038d8116600483015233602483015260448201939093529051919092169163f866c31991606480830192600092919082900301818387803b1580156106ea57600080fd5b505af11580156106fe573d6000803e3d6000fd5b505050508061016001516000141561077257336000908152603660205260409020600785015461073b908290600160a01b900460ff16600161197c565b60405133906001600160a01b038e16907e058a56ea94653cdf4f152d227ace22d4c00ad99e2a43f58cb7d9e3feb295f290600090a3505b61082f565b6107808461143d565b61018081015161010082015161079d9186918e9190600090611549565b610180810151610100820151600186015460408051636b81068560e11b81526001600160a01b038e8116600483015233602483015260448201949094526001600160801b03909216606483015251919092169163d7020d0a91608480830192600092919082900301818387803b15801561081657600080fd5b505af115801561082a573d6000803e3d6000fd5b505050505b8051610100820151141561089a576007840154610859908390600160a01b900460ff16600061197c565b886001600160a01b03168b6001600160a01b03167f44c58d81365b66dd4b1a7f36c25aa97b8c71c361ee4937adc1a00000227db5dd60405160405180910390a35b600483015460808201516108c0916001600160a01b038d81169233929190911690611a20565b886001600160a01b03168a6001600160a01b03168c6001600160a01b03167fe413a321e8681d831f4dbccbca790d2952b56f977908e45be37335533e0052868460800151856101000151338d60405180858152602001848152602001836001600160a01b03168152602001821515815260200194505050505060405180910390a46000604051806040016040528060028152602001611a1b60f11b81525095509550505050505b9550959350505050565b60008060008060006109816127e8565b61098a8a611a80565b156109a8576000806000806000199550955095509550955050610e29565b600060e08201525b878160e001511015610d885760e08101516109cc908b90611a85565b6109d557610d78565b60e0810151600090815260208a81526040808320546001600160a01b03166101e085018190528352908d90529020610a0c81611b04565b506080860181905260c08601929092525060a0840191909152600a0a6020808401919091526101e08301516040805163b3596f0760e01b81526001600160a01b0392831660048201529051918b169263b3596f0792602480840193829003018186803b158015610a7b57600080fd5b505afa158015610a8f573d6000803e3d6000fd5b505050506040513d6020811015610aa557600080fd5b5051825260c082015115801590610ac7575060e0820151610ac7908c90611b2f565b15610be8578060040160009054906101000a90046001600160a01b03166001600160a01b03166370a082318e6040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015610b3057600080fd5b505afa158015610b44573d6000803e3d6000fd5b505050506040513d6020811015610b5a57600080fd5b50516040830181905260208301518351600092610b819291610b7b91611bb5565b90611c0e565b610120840151909150610b949082611077565b61012084015260a0830151610bba90610bae908390611bb5565b61016085015190611077565b61016084015260c0830151610be090610bd4908390611bb5565b61018085015190611077565b610180840152505b60e0820151610bf8908c90611c50565b15610d76578060050160009054906101000a90046001600160a01b03166001600160a01b03166370a082318e6040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015610c6157600080fd5b505afa158015610c75573d6000803e3d6000fd5b505050506040513d6020811015610c8b57600080fd5b8101908080519060200190929190505050826060018181525050610d438160060160009054906101000a90046001600160a01b03166001600160a01b03166370a082318f6040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015610d0c57600080fd5b505afa158015610d20573d6000803e3d6000fd5b505050506040513d6020811015610d3657600080fd5b5051606084015190611077565b6060830181905260208301518351610d6f92610d639291610b7b91611bb5565b61014084015190611077565b6101408301525b505b60e08101805160010190526109b0565b600081610120015111610d9c576000610db1565b610120810151610160820151610db191611c0e565b610160820152610120810151610dc8576000610ddd565b610120810151610180820151610ddd91611c0e565b6101808201819052610120820151610140830151610dfa92611ccf565b610100820181905261012082015161014083015161016084015161018090940151919850965091945090925090505b965096509650965096915050565b6005810154604080516370a0823160e01b81526001600160a01b0385811660048301529151600093849316916370a08231916024808301926020929190829003018186803b158015610e8857600080fd5b505afa158015610e9c573d6000803e3d6000fd5b505050506040513d6020811015610eb257600080fd5b50516006840154604080516370a0823160e01b81526001600160a01b038881166004830152915191909216916370a08231916024808301926020929190829003018186803b158015610f0357600080fd5b505afa158015610f17573d6000803e3d6000fd5b505050506040513d6020811015610f2d57600080fd5b5051909590945092505050565b60006060610f4788611cfd565b1580610f595750610f5787611cfd565b155b15610f805750506040805180820190915260018152601960f91b602082015260069061106c565b670de0b6b3a76400008510610fb25750506040805180820190915260028152611a1960f11b602082015260049061106c565b600080610fbe8a611d0d565b118015610fed57506007890154604080516020810190915288548152610fed91600160a01b900460ff16611b2f565b90508061101757505060408051808201909152600280825261343360f01b6020830152915061106c565b84158015611023575083155b1561104c5750506040805180820190915260028152610d0d60f21b60208201526003915061106c565b50506040805180820190915260028152611a1b60f11b6020820152600091505b965096945050505050565b6000828201838110156110d1576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b90505b92915050565b60008215806110e7575081155b156110f4575060006110d4565b81611388198161110057fe5b0483111560405180604001604052806002815260200161068760f31b815250906111a85760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561116d578181015183820152602001611155565b50505050905090810190601f16801561119a5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506127106002815b0483850201816111bc57fe5b049392505050565b6000806000806000603460009054906101000a90046001600160a01b03166001600160a01b031663fca513a86040518163ffffffff1660e01b815260040160206040518083038186803b15801561121a57600080fd5b505afa15801561122e573d6000803e3d6000fd5b505050506040513d602081101561124457600080fd5b50519050611250612882565b816001600160a01b031663b3596f078b6040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561129d57600080fd5b505afa1580156112b1573d6000803e3d6000fd5b505050506040513d60208110156112c757600080fd5b5051604080830191909152805163b3596f0760e01b81526001600160a01b038b8116600483015291519184169163b3596f0791602480820192602092909190829003018186803b15801561131a57600080fd5b505afa15801561132e573d6000803e3d6000fd5b505050506040513d602081101561134457600080fd5b505160608201526113548c611b04565b5060c085015260208401525061136b90508b611d18565b60a0820181905260408201516113b8916113889190600a0a611bb5565b610b7b83602001516102e48560c00151600a0a6113b28e8860600151611bb590919063ffffffff16565b90611bb5565b608082018190528710156114215786935061141a81602001516114146113f28460c00151600a0a8560600151611bb590919063ffffffff16565b610b7b8560a00151600a0a6113b28a8860400151611bb590919063ffffffff16565b90611d22565b925061142c565b806080015193508792505b50919a909950975050505050505050565b60068101546040805163b1bf962d60e01b815290516000926001600160a01b03169163b1bf962d916004808301926020929190829003018186803b15801561148457600080fd5b505afa158015611498573d6000803e3d6000fd5b505050506040513d60208110156114ae57600080fd5b505160018301546003840154919250600160801b8082046001600160801b03908116939216910464ffffffffff166000806114ec8787868887611e15565b915091506114fe878787858588611fce565b50505050505050565b60006110d183836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506121b7565b6115516128bf565b60058601546001600160a01b031680825260408051637b98f4df60e11b8152815163f731e9be92600480840193919291829003018186803b15801561159557600080fd5b505afa1580156115a9573d6000803e3d6000fd5b505050506040513d60408110156115bf57600080fd5b50805160209182015160c084015260408084019190915260018801546006890154825163b1bf962d60e01b8152925161166394600160801b9093046001600160801b0316936001600160a01b039092169263b1bf962d9260048082019391829003018186803b15801561163157600080fd5b505afa158015611645573d6000803e3d6000fd5b505050506040513d602081101561165b57600080fd5b505190612211565b60e082018190526007870154604083015160c08401516001600160a01b03909216926329db497d928992899289928992919061169e8f6122c2565b6040518963ffffffff1660e01b815260040180896001600160a01b03168152602001886001600160a01b031681526020018781526020018681526020018581526020018481526020018381526020018281526020019850505050505050505060606040518083038186803b15801561171557600080fd5b505afa158015611729573d6000803e3d6000fd5b505050506040513d606081101561173f57600080fd5b50805160208083015160409384015160a086015260808501526060840182905282518084019093526002835261353360f01b908301526001600160801b0310156117ca5760405162461bcd60e51b815260206004820181815283516024840152835190928392604490910191908501908083836000831561116d578181015183820152602001611155565b506080810151604080518082019091526002815261353560f01b6020820152906001600160801b03101561183f5760405162461bcd60e51b815260206004820181815283516024840152835190928392604490910191908501908083836000831561116d578181015183820152602001611155565b5060a08101516040805180820190915260028152610d4d60f21b6020820152906001600160801b0310156118b45760405162461bcd60e51b815260206004820181815283516024840152835190928392604490910191908501908083836000831561116d578181015183820152602001611155565b5060608181015160028801805460808086015160038c0180546001600160801b03199081166001600160801b038085169190911790925560a0808a015191909516828816178216600160801b82841681029190911790965560018e01546040805198895260208901949094528784019190915280821697870197909752939095049092169183019190915291516001600160a01b038816927f804c9b842b2748a22bb64b345453a3de7ca54a6ca45ce00d415894979e22897a928290030190a2505050505050565b604080518082019091526002815261373760f01b6020820152608083106119e45760405162461bcd60e51b815260206004820181815283516024840152835190928392604490910191908501908083836000831561116d578181015183820152602001611155565b5081600202600101816119f85760006119fb565b60015b60ff16901b826002026001016001901b19846000015416178360000181905550505050565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052611a7a9085906122cd565b50505050565b511590565b60006080821060405180604001604052806002815260200161373760f01b81525090611af25760405162461bcd60e51b815260206004820181815283516024840152835190928392604490910191908501908083836000831561116d578181015183820152602001611155565b50509051600360029092021c16151590565b5461ffff80821692601083901c821692602081901c831692603082901c60ff169260409290921c1690565b60006080821060405180604001604052806002815260200161373760f01b81525090611b9c5760405162461bcd60e51b815260206004820181815283516024840152835190928392604490910191908501908083836000831561116d578181015183820152602001611155565b5050815160016002830281019190911c16151592915050565b600082611bc4575060006110d4565b82820282848281611bd157fe5b04146110d15760405162461bcd60e51b815260040180806020018281038252602181526020018061296f6021913960400191505060405180910390fd5b60006110d183836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612485565b60006080821060405180604001604052806002815260200161373760f01b81525090611cbd5760405162461bcd60e51b815260206004820181815283516024840152835190928392604490910191908501908083836000831561116d578181015183820152602001611155565b50509051600160029092021c16151590565b600082611cdf5750600019611cf6565b611cf383611ced86856110da565b906124ea565b90505b9392505050565b5467010000000000000016151590565b5460101c61ffff1690565b5460301c60ff1690565b604080518082019091526002815261035360f41b602082015260009082611d8a5760405162461bcd60e51b815260206004820181815283516024840152835190928392604490910191908501908083836000831561116d578181015183820152602001611155565b5060408051808201909152600280825261068760f31b6020830152830490612710821904851115611dfc5760405162461bcd60e51b815260206004820181815283516024840152835190928392604490910191908501908083836000831561116d578181015183820152602001611155565b50828161271086020181611e0c57fe5b04949350505050565b600285015460009081906001600160801b031685858215611f9f576000611e3c84886125e0565b9050611e48818a612211565b604080518082019091526002815261353160f01b60208201529093506001600160801b03841115611eba5760405162461bcd60e51b815260206004820181815283516024840152835190928392604490910191908501908083836000831561116d578181015183820152602001611155565b5060018b0180546001600160801b0319166001600160801b0385161790558915611f9d5760028b0154600090611f0090600160801b90046001600160801b031689612626565b9050611f0c818a612211565b6040805180820190915260028152611a9960f11b60208201529093506001600160801b03841115611f7e5760405162461bcd60e51b815260206004820181815283516024840152835190928392604490910191908501908083836000831561116d578181015183820152602001611155565b505060018b0180546001600160801b03808516600160801b0291161790555b505b600399909901805464ffffffffff60801b1916600160801b4264ffffffffff1602179055989650505050505050565b611fd661290d565b611fdf876122c2565b6101208201819052611ff157506121af565b8660050160009054906101000a90046001600160a01b03166001600160a01b031663797743386040518163ffffffff1660e01b815260040160806040518083038186803b15801561204157600080fd5b505afa158015612055573d6000803e3d6000fd5b505050506040513d608081101561206b57600080fd5b508051602080830151604084015160609094015164ffffffffff1661014086015260a0850193909352918352908201526120a58686612211565b60808201526120b48684612211565b606082015260a08101516101408201516120d6919064ffffffffff851661262f565b60c0820181905260208201516120eb91612211565b6040820181905260808201518251606084015161211693926121109290918391611077565b90611507565b60e0820181905261012082015161212d91906110da565b6101008201819052156114fe5760048088015461010083015160408051637df5bd3b60e01b81529384019190915260248301879052516001600160a01b0390911691637df5bd3b91604480830192600092919082900301818387803b15801561219557600080fd5b505af11580156121a9573d6000803e3d6000fd5b50505050505b505050505050565b600081848411156122095760405162461bcd60e51b815260206004820181815283516024840152835190928392604490910191908501908083836000831561116d578181015183820152602001611155565b505050900390565b600082158061221e575081155b1561222b575060006110d4565b816b019d971e4fe8401e74000000198161224157fe5b0483111560405180604001604052806002815260200161068760f31b815250906122ac5760405162461bcd60e51b815260206004820181815283516024840152835190928392604490910191908501908083836000831561116d578181015183820152602001611155565b506b033b2e3c9fd0803ce80000006002816111b0565b5460401c61ffff1690565b6122df826001600160a01b0316612705565b612330576040805162461bcd60e51b815260206004820152601f60248201527f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e747261637400604482015290519081900360640190fd5b60006060836001600160a01b0316836040518082805190602001908083835b6020831061236e5780518252601f19909201916020918201910161234f565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d80600081146123d0576040519150601f19603f3d011682016040523d82523d6000602084013e6123d5565b606091505b50915091508161242c576040805162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564604482015290519081900360640190fd5b805115611a7a5780806020019051602081101561244857600080fd5b5051611a7a5760405162461bcd60e51b815260040180806020018281038252602a815260200180612990602a913960400191505060405180910390fd5b600081836124d45760405162461bcd60e51b815260206004820181815283516024840152835190928392604490910191908501908083836000831561116d578181015183820152602001611155565b5060008385816124e057fe5b0495945050505050565b604080518082019091526002815261035360f41b6020820152600090826125525760405162461bcd60e51b815260206004820181815283516024840152835190928392604490910191908501908083836000831561116d578181015183820152602001611155565b5060408051808201909152600280825261068760f31b6020830152830490670de0b6b3a76400008219048511156125ca5760405162461bcd60e51b815260206004820181815283516024840152835190928392604490910191908501908083836000831561116d578181015183820152602001611155565b508281670de0b6b3a764000086020181611e0c57fe5b6000806125f44264ffffffffff8516611507565b905061261e61260161273e565b6301e133806126108785611bb5565b8161261757fe5b0490611077565b949350505050565b60006110d18383425b6000806126438364ffffffffff8616611507565b90508061265a5761265261273e565b915050611cf6565b6000198101600060028311612670576000612675565b600283035b90506301e133808704600061268a8280612211565b905060006126988284612211565b9050600060026126ac846113b28a8a611bb5565b816126b357fe5b049050600060066126ca846113b289818d8d611bb5565b816126d157fe5b0490506126f5816126ef84816126e78a8e611bb5565b6126ef61273e565b90611077565b9c9b505050505050505050505050565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47081811480159061261e575050151592915050565b6b033b2e3c9fd0803ce800000090565b60405180610220016040528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160006001600160a01b03168152602001600015158152602001600060028111156127d457fe5b815260200160008152602001606081525090565b604051806102400160405280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160001515815260200160006001600160a01b031681526020016000151581526020016000151581525090565b6040518060e00160405280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b60405180610100016040528060006001600160a01b03168152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b60405180610160016040528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600064ffffffffff168152509056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a2646970667358221220b30c07cd57fdd0f4553597786f213f89726b6473232c51531b2a9a099cc80a0564736f6c634300060c0033", + "deployedBytecode": "", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/external/abi/aave/v2/AaveV2LendingPoolConfigurator.json b/external/abi/aave/v2/AaveV2LendingPoolConfigurator.json new file mode 100644 index 000000000..85d544204 --- /dev/null +++ b/external/abi/aave/v2/AaveV2LendingPoolConfigurator.json @@ -0,0 +1,753 @@ +{ + "contractName": "AaveV2LendingPoolConfigurator", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "proxy", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "ATokenUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "BorrowingDisabledOnReserve", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "stableRateEnabled", + "type": "bool" + } + ], + "name": "BorrowingEnabledOnReserve", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "ltv", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "liquidationThreshold", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "liquidationBonus", + "type": "uint256" + } + ], + "name": "CollateralConfigurationChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "ReserveActivated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "ReserveDeactivated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "decimals", + "type": "uint256" + } + ], + "name": "ReserveDecimalsChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "factor", + "type": "uint256" + } + ], + "name": "ReserveFactorChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "ReserveFrozen", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "aToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "stableDebtToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "variableDebtToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "interestRateStrategyAddress", + "type": "address" + } + ], + "name": "ReserveInitialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "strategy", + "type": "address" + } + ], + "name": "ReserveInterestRateStrategyChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "ReserveUnfrozen", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "proxy", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "StableDebtTokenUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "StableRateDisabledOnReserve", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "StableRateEnabledOnReserve", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "proxy", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "VariableDebtTokenUpgraded", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "activateReserve", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "aTokenImpl", + "type": "address" + }, + { + "internalType": "address", + "name": "stableDebtTokenImpl", + "type": "address" + }, + { + "internalType": "address", + "name": "variableDebtTokenImpl", + "type": "address" + }, + { + "internalType": "uint8", + "name": "underlyingAssetDecimals", + "type": "uint8" + }, + { + "internalType": "address", + "name": "interestRateStrategyAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "underlyingAsset", + "type": "address" + }, + { + "internalType": "address", + "name": "treasury", + "type": "address" + }, + { + "internalType": "address", + "name": "incentivesController", + "type": "address" + }, + { + "internalType": "string", + "name": "underlyingAssetName", + "type": "string" + }, + { + "internalType": "string", + "name": "aTokenName", + "type": "string" + }, + { + "internalType": "string", + "name": "aTokenSymbol", + "type": "string" + }, + { + "internalType": "string", + "name": "variableDebtTokenName", + "type": "string" + }, + { + "internalType": "string", + "name": "variableDebtTokenSymbol", + "type": "string" + }, + { + "internalType": "string", + "name": "stableDebtTokenName", + "type": "string" + }, + { + "internalType": "string", + "name": "stableDebtTokenSymbol", + "type": "string" + }, + { + "internalType": "bytes", + "name": "params", + "type": "bytes" + } + ], + "internalType": "struct ILendingPoolConfigurator.InitReserveInput[]", + "name": "input", + "type": "tuple[]" + } + ], + "name": "batchInitReserve", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "ltv", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "liquidationThreshold", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "liquidationBonus", + "type": "uint256" + } + ], + "name": "configureReserveAsCollateral", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "deactivateReserve", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "disableBorrowingOnReserve", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "disableReserveStableRate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "bool", + "name": "stableBorrowRateEnabled", + "type": "bool" + } + ], + "name": "enableBorrowingOnReserve", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "enableReserveStableRate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "freezeReserve", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ILendingPoolAddressesProvider", + "name": "provider", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "val", + "type": "bool" + } + ], + "name": "setPoolPause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "reserveFactor", + "type": "uint256" + } + ], + "name": "setReserveFactor", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "address", + "name": "rateStrategyAddress", + "type": "address" + } + ], + "name": "setReserveInterestRateStrategyAddress", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "unfreezeReserve", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "address", + "name": "treasury", + "type": "address" + }, + { + "internalType": "address", + "name": "incentivesController", + "type": "address" + }, + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "symbol", + "type": "string" + }, + { + "internalType": "address", + "name": "implementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "params", + "type": "bytes" + } + ], + "internalType": "struct ILendingPoolConfigurator.UpdateATokenInput", + "name": "input", + "type": "tuple" + } + ], + "name": "updateAToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "address", + "name": "incentivesController", + "type": "address" + }, + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "symbol", + "type": "string" + }, + { + "internalType": "address", + "name": "implementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "params", + "type": "bytes" + } + ], + "internalType": "struct ILendingPoolConfigurator.UpdateDebtTokenInput", + "name": "input", + "type": "tuple" + } + ], + "name": "updateStableDebtToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "address", + "name": "incentivesController", + "type": "address" + }, + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "symbol", + "type": "string" + }, + { + "internalType": "address", + "name": "implementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "params", + "type": "bytes" + } + ], + "internalType": "struct ILendingPoolConfigurator.UpdateDebtTokenInput", + "name": "input", + "type": "tuple" + } + ], + "name": "updateVariableDebtToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bytecode": "0x60806040526000805534801561001457600080fd5b50613e13806100246000396000f3fe608060405234801561001057600080fd5b506004361061010b5760003560e01c8063ad4e6432116100a2578063c4d66de811610071578063c4d66de8146101f6578063cef84c5114610209578063eede87c11461021c578063ef1f93731461022f578063f53a2515146102425761010b565b8063ad4e6432146101aa578063b75d6f34146101bd578063bb01c37c146101d0578063bf344183146101e35761010b565b80637641f3d9116100de5780637641f3d91461015e5780637aca76eb146101715780637c4e560b14610184578063a8dc0f45146101975761010b565b80631d2118f9146101105780633e72a454146101255780634b4e6753146101385780637626cde31461014b575b600080fd5b61012361011e366004612f40565b610255565b005b610123610133366004612f01565b6103c7565b610123610146366004612fa9565b6105c2565b6101236101593660046131eb565b6107c1565b61012361016c36600461307d565b610ae5565b61012361017f366004612f01565b610c0a565b610123610192366004612fd4565b610dfc565b6101236101a5366004612f01565b611125565b6101236101b83660046131eb565b611317565b6101236101cb366004612f01565b6115c4565b6101236101de3660046131b3565b6117b6565b6101236101f1366004612f01565b611a75565b610123610204366004612f01565b611c67565b61012361021736600461300e565b611d99565b61012361022a366004612f78565b611ea5565b61012361023d366004612f01565b6120a2565b610123610250366004612f01565b612294565b603454604080516315d9b46f60e31b8152905133926001600160a01b03169163aecda378916004808301926020929190829003018186803b15801561029957600080fd5b505afa1580156102ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102d19190612f24565b6001600160a01b03161460405180604001604052806002815260200161333360f01b8152509061031d5760405162461bcd60e51b8152600401610314919061351a565b60405180910390fd5b50603554604051631d2118f960e01b81526001600160a01b0390911690631d2118f99061035090859085906004016132e0565b600060405180830381600087803b15801561036a57600080fd5b505af115801561037e573d6000803e3d6000fd5b50505050816001600160a01b03167f5644b64ebb0ce18c4032248ca52f58355469092ff072866c3dcd8640e817d6a5826040516103bb91906132cc565b60405180910390a25050565b603454604080516315d9b46f60e31b8152905133926001600160a01b03169163aecda378916004808301926020929190829003018186803b15801561040b57600080fd5b505afa15801561041f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104439190612f24565b6001600160a01b03161460405180604001604052806002815260200161333360f01b815250906104865760405162461bcd60e51b8152600401610314919061351a565b5061049081612486565b610498612e0f565b60355460405163c44b11f760e01b81526001600160a01b039091169063c44b11f7906104c89085906004016132cc565b60206040518083038186803b1580156104e057600080fd5b505afa1580156104f4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610518919061309d565b90506105258160006125e7565b6035548151604051635c69493b60e11b81526001600160a01b039092169163b8d29276916105589186919060040161337b565b600060405180830381600087803b15801561057257600080fd5b505af1158015610586573d6000803e3d6000fd5b50506040516001600160a01b03851692507f6f60cf8bd0f218cabe1ea3150bd07b0b758c35c4cfdf7138017a283e65564d5e9150600090a25050565b603454604080516315d9b46f60e31b8152905133926001600160a01b03169163aecda378916004808301926020929190829003018186803b15801561060657600080fd5b505afa15801561061a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061063e9190612f24565b6001600160a01b03161460405180604001604052806002815260200161333360f01b815250906106815760405162461bcd60e51b8152600401610314919061351a565b5061068a612e0f565b60355460405163c44b11f760e01b81526001600160a01b039091169063c44b11f7906106ba9086906004016132cc565b60206040518083038186803b1580156106d257600080fd5b505afa1580156106e6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061070a919061309d565b90506107168183612615565b6035548151604051635c69493b60e11b81526001600160a01b039092169163b8d29276916107499187919060040161337b565b600060405180830381600087803b15801561076357600080fd5b505af1158015610777573d6000803e3d6000fd5b50505050826001600160a01b03167f2694ccb0b585b6a54b8d8b4a47aa874b05c257b43d34e98aee50838be00d3405836040516107b4919061357b565b60405180910390a2505050565b603454604080516315d9b46f60e31b8152905133926001600160a01b03169163aecda378916004808301926020929190829003018186803b15801561080557600080fd5b505afa158015610819573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061083d9190612f24565b6001600160a01b03161460405180604001604052806002815260200161333360f01b815250906108805760405162461bcd60e51b8152600401610314919061351a565b506035546001600160a01b0316610895612e22565b6001600160a01b0382166335ea6a756108b16020860186612f01565b6040518263ffffffff1660e01b81526004016108cd91906132cc565b6101806040518083038186803b1580156108e657600080fd5b505afa1580156108fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061091e91906130b8565b905060006109b26001600160a01b03841663c44b11f76109416020880188612f01565b6040518263ffffffff1660e01b815260040161095d91906132cc565b60206040518083038186803b15801561097557600080fd5b505afa158015610989573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109ad919061309d565b61266c565b50935060609250636111764560e11b91508590506109d36020880188612f01565b6109e36040890160208a01612f01565b856109f160408b018b6135e6565b6109fe60608d018d6135e6565b610a0b60a08f018f61359a565b604051602401610a249a99989796959493929190613467565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152610100840151909150610a7990610a7360a0880160808901612f01565b83612697565b610a8960a0860160808701612f01565b6101008401516001600160a01b039182169116610aa96020880188612f01565b6001600160a01b03167f7a943a5b6c214bf7726c069a878b1e2a8e7371981d516048b84e03743e67bc2860405160405180910390a45050505050565b60345460408051636ee554f560e11b8152905133926001600160a01b03169163ddcaa9ea916004808301926020929190829003018186803b158015610b2957600080fd5b505afa158015610b3d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b619190612f24565b6001600160a01b031614604051806040016040528060028152602001611b9b60f11b81525090610ba45760405162461bcd60e51b8152600401610314919061351a565b5060355460405163bedb86fb60e01b81526001600160a01b039091169063bedb86fb90610bd5908490600401613394565b600060405180830381600087803b158015610bef57600080fd5b505af1158015610c03573d6000803e3d6000fd5b5050505050565b603454604080516315d9b46f60e31b8152905133926001600160a01b03169163aecda378916004808301926020929190829003018186803b158015610c4e57600080fd5b505afa158015610c62573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c869190612f24565b6001600160a01b03161460405180604001604052806002815260200161333360f01b81525090610cc95760405162461bcd60e51b8152600401610314919061351a565b50610cd2612e0f565b60355460405163c44b11f760e01b81526001600160a01b039091169063c44b11f790610d029085906004016132cc565b60206040518083038186803b158015610d1a57600080fd5b505afa158015610d2e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d52919061309d565b9050610d5f8160016126ff565b6035548151604051635c69493b60e11b81526001600160a01b039092169163b8d2927691610d929186919060040161337b565b600060405180830381600087803b158015610dac57600080fd5b505af1158015610dc0573d6000803e3d6000fd5b50506040516001600160a01b03851692507f85dc710add8a0914461a7dc5a63f6fc529a7700f8c6089a3faf5e93256ccf12a9150600090a25050565b603454604080516315d9b46f60e31b8152905133926001600160a01b03169163aecda378916004808301926020929190829003018186803b158015610e4057600080fd5b505afa158015610e54573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e789190612f24565b6001600160a01b03161460405180604001604052806002815260200161333360f01b81525090610ebb5760405162461bcd60e51b8152600401610314919061351a565b50610ec4612e0f565b60355460405163c44b11f760e01b81526001600160a01b039091169063c44b11f790610ef49088906004016132cc565b60206040518083038186803b158015610f0c57600080fd5b505afa158015610f20573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f44919061309d565b90508284111560405180604001604052806002815260200161373560f01b81525090610f835760405162461bcd60e51b8152600401610314919061351a565b50821561101457604080518082019091526002815261373560f01b60208201526127108311610fc55760405162461bcd60e51b8152600401610314919061351a565b50612710610fd3848461272d565b111560405180604001604052806002815260200161373560f01b8152509061100e5760405162461bcd60e51b8152600401610314919061351a565b50611056565b604080518082019091526002815261373560f01b6020820152821561104c5760405162461bcd60e51b8152600401610314919061351a565b5061105685612486565b61106081856127a4565b61106a81846127ed565b611074818361283e565b6035548151604051635c69493b60e11b81526001600160a01b039092169163b8d29276916110a79189919060040161337b565b600060405180830381600087803b1580156110c157600080fd5b505af11580156110d5573d6000803e3d6000fd5b50505050846001600160a01b03167f637febbda9275aea2e85c0ff690444c8d87eb2e8339bbede9715abcc89cb099585858560405161111693929190613584565b60405180910390a25050505050565b603454604080516315d9b46f60e31b8152905133926001600160a01b03169163aecda378916004808301926020929190829003018186803b15801561116957600080fd5b505afa15801561117d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111a19190612f24565b6001600160a01b03161460405180604001604052806002815260200161333360f01b815250906111e45760405162461bcd60e51b8152600401610314919061351a565b506111ed612e0f565b60355460405163c44b11f760e01b81526001600160a01b039091169063c44b11f79061121d9085906004016132cc565b60206040518083038186803b15801561123557600080fd5b505afa158015611249573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061126d919061309d565b905061127a816000612891565b6035548151604051635c69493b60e11b81526001600160a01b039092169163b8d29276916112ad9186919060040161337b565b600060405180830381600087803b1580156112c757600080fd5b505af11580156112db573d6000803e3d6000fd5b50506040516001600160a01b03851692507fe9a7e5fd4fc8ea18e602350324bf48e8f05d12434af0ce0be05743e6a5fdcb9e9150600090a25050565b603454604080516315d9b46f60e31b8152905133926001600160a01b03169163aecda378916004808301926020929190829003018186803b15801561135b57600080fd5b505afa15801561136f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113939190612f24565b6001600160a01b03161460405180604001604052806002815260200161333360f01b815250906113d65760405162461bcd60e51b8152600401610314919061351a565b506035546001600160a01b03166113eb612e22565b6001600160a01b0382166335ea6a756114076020860186612f01565b6040518263ffffffff1660e01b815260040161142391906132cc565b6101806040518083038186803b15801561143c57600080fd5b505afa158015611450573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061147491906130b8565b905060006114976001600160a01b03841663c44b11f76109416020880188612f01565b50935060609250636111764560e11b91508590506114b86020880188612f01565b6114c86040890160208a01612f01565b856114d660408b018b6135e6565b6114e360608d018d6135e6565b6114f060a08f018f61359a565b6040516024016115099a99989796959493929190613467565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261012084015190915061155890610a7360a0880160808901612f01565b61156860a0860160808701612f01565b6101208401516001600160a01b0391821691166115886020880188612f01565b6001600160a01b03167f9439658a562a5c46b1173589df89cf001483d685bad28aedaff4a88656292d8160405160405180910390a45050505050565b603454604080516315d9b46f60e31b8152905133926001600160a01b03169163aecda378916004808301926020929190829003018186803b15801561160857600080fd5b505afa15801561161c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116409190612f24565b6001600160a01b03161460405180604001604052806002815260200161333360f01b815250906116835760405162461bcd60e51b8152600401610314919061351a565b5061168c612e0f565b60355460405163c44b11f760e01b81526001600160a01b039091169063c44b11f7906116bc9085906004016132cc565b60206040518083038186803b1580156116d457600080fd5b505afa1580156116e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061170c919061309d565b90506117198160016125e7565b6035548151604051635c69493b60e11b81526001600160a01b039092169163b8d292769161174c9186919060040161337b565b600060405180830381600087803b15801561176657600080fd5b505af115801561177a573d6000803e3d6000fd5b50506040516001600160a01b03851692507f35b80cd8ea3440e9a8454f116fa658b858da1b64c86c48451f4559cefcdfb56c9150600090a25050565b603454604080516315d9b46f60e31b8152905133926001600160a01b03169163aecda378916004808301926020929190829003018186803b1580156117fa57600080fd5b505afa15801561180e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118329190612f24565b6001600160a01b03161460405180604001604052806002815260200161333360f01b815250906118755760405162461bcd60e51b8152600401610314919061351a565b506035546001600160a01b031661188a612e22565b6001600160a01b0382166335ea6a756118a66020860186612f01565b6040518263ffffffff1660e01b81526004016118c291906132cc565b6101806040518083038186803b1580156118db57600080fd5b505afa1580156118ef573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061191391906130b8565b905060006119366001600160a01b03841663c44b11f76109416020880188612f01565b5093506060925063183fb41360e01b915085905061195a6040880160208901612f01565b6119676020890189612f01565b61197760608a0160408b01612f01565b8661198560608c018c6135e6565b61199260808e018e6135e6565b8e8060c001906119a2919061359a565b6040516024016119bc9b9a9998979695949392919061339f565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915260e0840151909150611a0a90610a7360c0880160a08901612f01565b611a1a60c0860160a08701612f01565b60e08401516001600160a01b039182169116611a396020880188612f01565b6001600160a01b03167fa76f65411ec66a7fb6bc467432eb14767900449ae4469fa295e4441fe5e1cb7360405160405180910390a45050505050565b603454604080516315d9b46f60e31b8152905133926001600160a01b03169163aecda378916004808301926020929190829003018186803b158015611ab957600080fd5b505afa158015611acd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611af19190612f24565b6001600160a01b03161460405180604001604052806002815260200161333360f01b81525090611b345760405162461bcd60e51b8152600401610314919061351a565b50611b3d612e0f565b60355460405163c44b11f760e01b81526001600160a01b039091169063c44b11f790611b6d9085906004016132cc565b60206040518083038186803b158015611b8557600080fd5b505afa158015611b99573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bbd919061309d565b9050611bca8160016128bf565b6035548151604051635c69493b60e11b81526001600160a01b039092169163b8d2927691611bfd9186919060040161337b565b600060405180830381600087803b158015611c1757600080fd5b505af1158015611c2b573d6000803e3d6000fd5b50506040516001600160a01b03851692507f8dee2b2f3e98319ae6347eda521788f73f4086c9be9a594942b370b137fb8cb19150600090a25050565b6000611c716128ed565b60015490915060ff1680611c885750611c886128f2565b80611c94575060005481115b611cb05760405162461bcd60e51b81526004016103149061352d565b60015460ff16158015611ccf576001805460ff19168117905560008290555b603480546001600160a01b0319166001600160a01b03858116919091179182905560408051630261bf8b60e01b815290519290911691630261bf8b91600480820192602092909190829003018186803b158015611d2b57600080fd5b505afa158015611d3f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d639190612f24565b603580546001600160a01b0319166001600160a01b03929092169190911790558015611d94576001805460ff191690555b505050565b603454604080516315d9b46f60e31b8152905133926001600160a01b03169163aecda378916004808301926020929190829003018186803b158015611ddd57600080fd5b505afa158015611df1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e159190612f24565b6001600160a01b03161460405180604001604052806002815260200161333360f01b81525090611e585760405162461bcd60e51b8152600401610314919061351a565b506035546001600160a01b031660005b82811015611e9f57611e9782858584818110611e8057fe5b9050602002810190611e9291906135fc565b6128f8565b600101611e68565b50505050565b603454604080516315d9b46f60e31b8152905133926001600160a01b03169163aecda378916004808301926020929190829003018186803b158015611ee957600080fd5b505afa158015611efd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f219190612f24565b6001600160a01b03161460405180604001604052806002815260200161333360f01b81525090611f645760405162461bcd60e51b8152600401610314919061351a565b50611f6d612e0f565b60355460405163c44b11f760e01b81526001600160a01b039091169063c44b11f790611f9d9086906004016132cc565b60206040518083038186803b158015611fb557600080fd5b505afa158015611fc9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fed919061309d565b9050611ffa816001612891565b61200481836128bf565b6035548151604051635c69493b60e11b81526001600160a01b039092169163b8d29276916120379187919060040161337b565b600060405180830381600087803b15801561205157600080fd5b505af1158015612065573d6000803e3d6000fd5b50505050826001600160a01b03167fab2f7f9e5ca2772fafa94f355c1842a80ae6b9e41f83083098d81f67d7a0b508836040516107b49190613394565b603454604080516315d9b46f60e31b8152905133926001600160a01b03169163aecda378916004808301926020929190829003018186803b1580156120e657600080fd5b505afa1580156120fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061211e9190612f24565b6001600160a01b03161460405180604001604052806002815260200161333360f01b815250906121615760405162461bcd60e51b8152600401610314919061351a565b5061216a612e0f565b60355460405163c44b11f760e01b81526001600160a01b039091169063c44b11f79061219a9085906004016132cc565b60206040518083038186803b1580156121b257600080fd5b505afa1580156121c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121ea919061309d565b90506121f78160006126ff565b6035548151604051635c69493b60e11b81526001600160a01b039092169163b8d292769161222a9186919060040161337b565b600060405180830381600087803b15801561224457600080fd5b505af1158015612258573d6000803e3d6000fd5b50506040516001600160a01b03851692507f838ecdc4709a31a26db48b0c853212cedde3f725f07030079d793fb0719647609150600090a25050565b603454604080516315d9b46f60e31b8152905133926001600160a01b03169163aecda378916004808301926020929190829003018186803b1580156122d857600080fd5b505afa1580156122ec573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123109190612f24565b6001600160a01b03161460405180604001604052806002815260200161333360f01b815250906123535760405162461bcd60e51b8152600401610314919061351a565b5061235c612e0f565b60355460405163c44b11f760e01b81526001600160a01b039091169063c44b11f79061238c9085906004016132cc565b60206040518083038186803b1580156123a457600080fd5b505afa1580156123b8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123dc919061309d565b90506123e98160006128bf565b6035548151604051635c69493b60e11b81526001600160a01b039092169163b8d292769161241c9186919060040161337b565b600060405180830381600087803b15801561243657600080fd5b505af115801561244a573d6000803e3d6000fd5b50506040516001600160a01b03851692507f8bbf35441ac2c607ddecadd3d8ee58636d32f217fad201fb2655581502dd84e39150600090a25050565b61248e612e22565b6035546040516335ea6a7560e01b81526001600160a01b03909116906335ea6a75906124be9085906004016132cc565b6101806040518083038186803b1580156124d757600080fd5b505afa1580156124eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061250f91906130b8565b90506000826001600160a01b03166370a082318360e001516040518263ffffffff1660e01b815260040161254391906132cc565b60206040518083038186803b15801561255b57600080fd5b505afa15801561256f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125939190613223565b9050801580156125ae575060608201516001600160801b0316155b604051806040016040528060028152602001610ccd60f21b81525090611e9f5760405162461bcd60e51b8152600401610314919061351a565b6038816125f55760006125f8565b60015b8351670100000000000000191660ff9190911690911b1790915250565b604080518082019091526002815261373160f01b602082015261ffff8211156126515760405162461bcd60e51b8152600401610314919061351a565b50815169ffff0000000000000000191660409190911b179052565b5161ffff80821692601083901c821692602081901c831692603082901c60ff169260409290921c1690565b60405163278f794360e11b815283906001600160a01b03821690634f1ef286906126c7908690869060040161334f565b600060405180830381600087803b1580156126e157600080fd5b505af11580156126f5573d6000803e3d6000fd5b5050505050505050565b60398161270d576000612710565b60015b8351670200000000000000191660ff9190911690911b1790915250565b600082158061273a575081155b156127475750600061279e565b81611388198161275357fe5b0483111560405180604001604052806002815260200161068760f31b815250906127905760405162461bcd60e51b8152600401610314919061351a565b505061271061138882840201045b92915050565b604080518082019091526002815261363760f01b602082015261ffff8211156127e05760405162461bcd60e51b8152600401610314919061351a565b50815161ffff1916179052565b60408051808201909152600281526106c760f31b602082015261ffff8211156128295760405162461bcd60e51b8152600401610314919061351a565b50815163ffff0000191660109190911b179052565b604080518082019091526002815261363960f01b602082015261ffff82111561287a5760405162461bcd60e51b8152600401610314919061351a565b50815165ffff00000000191660209190911b179052565b603a8161289f5760006128a2565b60015b8351670400000000000000191660ff9190911690911b1790915250565b603b816128cd5760006128d0565b60015b8351670800000000000000191660ff9190911690911b1790915250565b600190565b303b1590565b60006129cf61290a6020840184612f01565b63183fb41360e01b8561292360e0870160c08801612f01565b61293360c0880160a08901612f01565b612944610100890160e08a01612f01565b61295460808a0160608b0161323b565b6129626101208b018b6135e6565b6129706101408d018d6135e6565b61297e6101e08f018f61359a565b6040516024016129989b9a99989796959493929190613420565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612d1a565b90506000612a636129e66040850160208601612f01565b636111764560e11b866129ff60c0880160a08901612f01565b612a10610100890160e08a01612f01565b612a2060808a0160608b0161323b565b612a2e6101a08b018b6135e6565b612a3c6101c08d018d6135e6565b612a4a6101e08f018f61359a565b6040516024016129989a999897969594939291906134dc565b90506000612ae1612a7a6060860160408701612f01565b636111764560e11b87612a9360c0890160a08a01612f01565b612aa46101008a0160e08b01612f01565b612ab460808b0160608c0161323b565b612ac26101608c018c6135e6565b612ad06101808e018e6135e6565b8e806101e00190612a4a919061359a565b90506001600160a01b038516637a708e92612b0260c0870160a08801612f01565b858585612b1560a08b0160808c01612f01565b6040518663ffffffff1660e01b8152600401612b3595949392919061331d565b600060405180830381600087803b158015612b4f57600080fd5b505af1158015612b63573d6000803e3d6000fd5b50505050612b6f612e0f565b6001600160a01b03861663c44b11f7612b8e60c0880160a08901612f01565b6040518263ffffffff1660e01b8152600401612baa91906132cc565b60206040518083038186803b158015612bc257600080fd5b505afa158015612bd6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bfa919061309d565b9050612c19612c0f608087016060880161323b565b829060ff16612dbc565b612c248160016125e7565b612c2f8160006126ff565b6001600160a01b03861663b8d29276612c4e60c0880160a08901612f01565b83516040516001600160e01b031960e085901b168152612c7292919060040161337b565b600060405180830381600087803b158015612c8c57600080fd5b505af1158015612ca0573d6000803e3d6000fd5b5050506001600160a01b0385169050612cbf60c0870160a08801612f01565b6001600160a01b03167f3a0ca721fc364424566385a1aa271ed508cc2c0949c2272575fb3013a163a45f8585612cfb60a08b0160808c01612f01565b604051612d0a939291906132fa565b60405180910390a3505050505050565b60008030604051612d2a90612e8d565b612d3491906132cc565b604051809103906000f080158015612d50573d6000803e3d6000fd5b5060405163347d5e2560e21b81529091506001600160a01b0382169063d1f5789490612d82908790879060040161334f565b600060405180830381600087803b158015612d9c57600080fd5b505af1158015612db0573d6000803e3d6000fd5b50929695505050505050565b604080518082019091526002815261037360f41b602082015260ff821115612df75760405162461bcd60e51b8152600401610314919061351a565b50815166ff000000000000191660309190911b179052565b6040518060200160405280600081525090565b604051806101800160405280612e36612e0f565b815260006020820181905260408201819052606082018190526080820181905260a0820181905260c0820181905260e082018190526101008201819052610120820181905261014082018190526101609091015290565b6107738061366b83390190565b805161279e81613643565b600060208284031215612eb6578081fd5b612ec0602061361c565b9151825250919050565b80516001600160801b038116811461279e57600080fd5b805164ffffffffff8116811461279e57600080fd5b805161279e8161365b565b600060208284031215612f12578081fd5b8135612f1d81613643565b9392505050565b600060208284031215612f35578081fd5b8151612f1d81613643565b60008060408385031215612f52578081fd5b8235612f5d81613643565b91506020830135612f6d81613643565b809150509250929050565b60008060408385031215612f8a578182fd5b8235612f9581613643565b915060208301358015158114612f6d578182fd5b60008060408385031215612fbb578182fd5b8235612fc681613643565b946020939093013593505050565b60008060008060808587031215612fe9578182fd5b8435612ff481613643565b966020860135965060408601359560600135945092505050565b60008060208385031215613020578182fd5b823567ffffffffffffffff80821115613037578384fd5b818501915085601f83011261304a578384fd5b813581811115613058578485fd5b866020808302850101111561306b578485fd5b60209290920196919550909350505050565b60006020828403121561308e578081fd5b81358015158114612f1d578182fd5b6000602082840312156130ae578081fd5b612f1d8383612ea5565b60006101808083850312156130cb578182fd5b6130d48161361c565b90506130e08484612ea5565b81526130ef8460208501612eca565b60208201526131018460408501612eca565b60408201526131138460608501612eca565b60608201526131258460808501612eca565b60808201526131378460a08501612eca565b60a08201526131498460c08501612ee1565b60c082015261315b8460e08501612e9a565b60e082015261010061316f85828601612e9a565b9082015261012061318285858301612e9a565b9082015261014061319585858301612e9a565b908201526101606131a885858301612ef6565b908201529392505050565b6000602082840312156131c4578081fd5b813567ffffffffffffffff8111156131da578182fd5b820160e08185031215612f1d578182fd5b6000602082840312156131fc578081fd5b813567ffffffffffffffff811115613212578182fd5b820160c08185031215612f1d578182fd5b600060208284031215613234578081fd5b5051919050565b60006020828403121561324c578081fd5b8135612f1d8161365b565b60008284528282602086013780602084860101526020601f19601f85011685010190509392505050565b60008151808452815b818110156132a65760208185018101518683018201520161328a565b818111156132b75782602083870101525b50601f01601f19169290920160200192915050565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b0393841681529183166020830152909116604082015260600190565b6001600160a01b0395861681529385166020850152918416604084015283166060830152909116608082015260a00190565b6001600160a01b038316815260406020820181905260009061337390830184613281565b949350505050565b6001600160a01b03929092168252602082015260400190565b901515815260200190565b6001600160a01b038c811682528b811660208301528a81166040830152891660608201526080810188905261010060a082018190526000906133e4838201898b613257565b905082810360c08401526133f9818789613257565b905082810360e084015261340e818587613257565b9e9d5050505050505050505050505050565b6001600160a01b038c811682528b811660208301528a811660408301528916606082015260ff8816608082015261010060a082018190526000906133e4838201898b613257565b6001600160a01b038b811682528a81166020830152891660408201526060810188905260e0608082018190526000906134a3908301888a613257565b82810360a08401526134b6818789613257565b905082810360c08401526134cb818587613257565b9d9c50505050505050505050505050565b6001600160a01b038b811682528a811660208301528916604082015260ff8816606082015260e0608082018190526000906134a3908301888a613257565b600060208252612f1d6020830184613281565b6020808252602e908201527f436f6e747261637420696e7374616e63652068617320616c726561647920626560408201526d195b881a5b9a5d1a585b1a5e995960921b606082015260800190565b90815260200190565b9283526020830191909152604082015260600190565b6000808335601e198436030181126135b0578283fd5b83018035915067ffffffffffffffff8211156135ca578283fd5b6020019150368190038213156135df57600080fd5b9250929050565b6000808335601e198436030181126135b0578182fd5b600082356101fe19833603018112613612578182fd5b9190910192915050565b60405181810167ffffffffffffffff8111828210171561363b57600080fd5b604052919050565b6001600160a01b038116811461365857600080fd5b50565b60ff8116811461365857600080fdfe60a060405234801561001057600080fd5b506040516107733803806107738339818101604052602081101561003357600080fd5b5051606081901b6001600160601b0319166080526001600160a01b03166106f36100806000398061022852806102725280610331528061045e528061048752806105af52506106f36000f3fe60806040526004361061004a5760003560e01c80633659cfe6146100545780634f1ef286146100875780635c60da1b14610107578063d1f5789414610138578063f851a440146101ee575b610052610203565b005b34801561006057600080fd5b506100526004803603602081101561007757600080fd5b50356001600160a01b031661021d565b6100526004803603604081101561009d57600080fd5b6001600160a01b0382351691908101906040810160208201356401000000008111156100c857600080fd5b8201836020820111156100da57600080fd5b803590602001918460018302840111640100000000831117156100fc57600080fd5b509092509050610267565b34801561011357600080fd5b5061011c610324565b604080516001600160a01b039092168252519081900360200190f35b6100526004803603604081101561014e57600080fd5b6001600160a01b03823516919081019060408101602082013564010000000081111561017957600080fd5b82018360208201111561018b57600080fd5b803590602001918460018302840111640100000000831117156101ad57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610371945050505050565b3480156101fa57600080fd5b5061011c610451565b61020b6104ab565b61021b6102166104b3565b6104d8565b565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016141561025c57610257816104fc565b610264565b610264610203565b50565b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161415610317576102a1836104fc565b6000836001600160a01b031683836040518083838082843760405192019450600093509091505080830381855af49150503d80600081146102fe576040519150601f19603f3d011682016040523d82523d6000602084013e610303565b606091505b505090508061031157600080fd5b5061031f565b61031f610203565b505050565b6000336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614156103665761035f6104b3565b905061036e565b61036e610203565b90565b600061037b6104b3565b6001600160a01b03161461038e57600080fd5b6103978261053c565b80511561044d576000826001600160a01b0316826040518082805190602001908083835b602083106103da5780518252601f1990920191602091820191016103bb565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d806000811461043a576040519150601f19603f3d011682016040523d82523d6000602084013e61043f565b606091505b505090508061031f57600080fd5b5050565b6000336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016141561036657507f000000000000000000000000000000000000000000000000000000000000000061036e565b61021b6105a4565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5490565b3660008037600080366000845af43d6000803e8080156104f7573d6000f35b3d6000fd5b6105058161053c565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b61054581610614565b6105805760405162461bcd60e51b815260040180806020018281038252603b815260200180610683603b913960400191505060405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc55565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016141561060c5760405162461bcd60e51b81526004018080602001828103825260328152602001806106516032913960400191505060405180910390fd5b61021b61021b565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47081811480159061064857508115155b94935050505056fe43616e6e6f742063616c6c2066616c6c6261636b2066756e6374696f6e2066726f6d207468652070726f78792061646d696e43616e6e6f742073657420612070726f787920696d706c656d656e746174696f6e20746f2061206e6f6e2d636f6e74726163742061646472657373a26469706673582212203801682b75a74ce25ca5dbe58739c5b62298b707b9119c9413881c56f29bcfa864736f6c634300060c0033a2646970667358221220c7bbdf7268c4121a496475a0c17b4b47482bfde35e1dd97c02e1ddae1fd05e1964736f6c634300060c0033", + "deployedBytecode": "", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/external/abi/aave/v2/AaveV2ProtocolDataProvider.json b/external/abi/aave/v2/AaveV2ProtocolDataProvider.json new file mode 100644 index 000000000..8189e538a --- /dev/null +++ b/external/abi/aave/v2/AaveV2ProtocolDataProvider.json @@ -0,0 +1,304 @@ +{ + "contractName": "AaveV2ProtocolDataProvider", + "abi": [ + { + "inputs": [ + { + "internalType": "contract ILendingPoolAddressesProvider", + "name": "addressesProvider", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "ADDRESSES_PROVIDER", + "outputs": [ + { + "internalType": "contract ILendingPoolAddressesProvider", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getAllATokens", + "outputs": [ + { + "components": [ + { + "internalType": "string", + "name": "symbol", + "type": "string" + }, + { + "internalType": "address", + "name": "tokenAddress", + "type": "address" + } + ], + "internalType": "struct AaveProtocolDataProvider.TokenData[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getAllReservesTokens", + "outputs": [ + { + "components": [ + { + "internalType": "string", + "name": "symbol", + "type": "string" + }, + { + "internalType": "address", + "name": "tokenAddress", + "type": "address" + } + ], + "internalType": "struct AaveProtocolDataProvider.TokenData[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "getReserveConfigurationData", + "outputs": [ + { + "internalType": "uint256", + "name": "decimals", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "ltv", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "liquidationThreshold", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "liquidationBonus", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "reserveFactor", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "usageAsCollateralEnabled", + "type": "bool" + }, + { + "internalType": "bool", + "name": "borrowingEnabled", + "type": "bool" + }, + { + "internalType": "bool", + "name": "stableBorrowRateEnabled", + "type": "bool" + }, + { + "internalType": "bool", + "name": "isActive", + "type": "bool" + }, + { + "internalType": "bool", + "name": "isFrozen", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "getReserveData", + "outputs": [ + { + "internalType": "uint256", + "name": "availableLiquidity", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalStableDebt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalVariableDebt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "liquidityRate", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "variableBorrowRate", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "stableBorrowRate", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "averageStableBorrowRate", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "liquidityIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "variableBorrowIndex", + "type": "uint256" + }, + { + "internalType": "uint40", + "name": "lastUpdateTimestamp", + "type": "uint40" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "getReserveTokensAddresses", + "outputs": [ + { + "internalType": "address", + "name": "aTokenAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "stableDebtTokenAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "variableDebtTokenAddress", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "getUserReserveData", + "outputs": [ + { + "internalType": "uint256", + "name": "currentATokenBalance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "currentStableDebt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "currentVariableDebt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "principalStableDebt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "scaledVariableDebt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "stableBorrowRate", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "liquidityRate", + "type": "uint256" + }, + { + "internalType": "uint40", + "name": "stableRateLastUpdated", + "type": "uint40" + }, + { + "internalType": "bool", + "name": "usageAsCollateralEnabled", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "bytecode": "0x60a060405234801561001057600080fd5b50604051611be3380380611be383398101604081905261002f91610044565b60601b6001600160601b031916608052610072565b600060208284031215610055578081fd5b81516001600160a01b038116811461006b578182fd5b9392505050565b60805160601c611b316100b26000398061015b528061019552806102ac52806107a75280610b2b5280610c7b5280610ff952806111295250611b316000f3fe608060405234801561001057600080fd5b506004361061007d5760003560e01c80633e1501411161005b5780633e150141146100f1578063b316ff891461011a578063d2493b6c1461012f578063f561ae41146101515761007d565b80630542975c1461008257806328dd2d01146100a057806335ea6a75146100c8575b600080fd5b61008a610159565b60405161009791906118e3565b60405180910390f35b6100b36100ae3660046115f5565b61017d565b60405161009799989796959493929190611a44565b6100db6100d63660046115b6565b61078e565b6040516100979a999897969594939291906119f8565b6101046100ff3660046115b6565b610b12565b6040516100979a999897969594939291906119a9565b610122610c75565b604051610097919061191a565b61014261013d3660046115b6565b610fea565b604051610097939291906118f7565b610122611123565b7f000000000000000000000000000000000000000000000000000000000000000081565b60008060008060008060008060006101936114b3565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316630261bf8b6040518163ffffffff1660e01b815260040160206040518083038186803b1580156101ec57600080fd5b505afa158015610200573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061022491906115d9565b6001600160a01b03166335ea6a758d6040518263ffffffff1660e01b815260040161024f91906118e3565b6101806040518083038186803b15801561026857600080fd5b505afa15801561027c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102a0919061177f565b90506102aa61151e565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316630261bf8b6040518163ffffffff1660e01b815260040160206040518083038186803b15801561030357600080fd5b505afa158015610317573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061033b91906115d9565b6001600160a01b0316634417a5838d6040518263ffffffff1660e01b815260040161036691906118e3565b60206040518083038186803b15801561037e57600080fd5b505afa158015610392573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103b69190611764565b60e08301516040516370a0823160e01b81529192506001600160a01b0316906370a08231906103e9908f906004016118e3565b60206040518083038186803b15801561040157600080fd5b505afa158015610415573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610439919061187a565b6101208301516040516370a0823160e01b8152919c506001600160a01b0316906370a082319061046d908f906004016118e3565b60206040518083038186803b15801561048557600080fd5b505afa158015610499573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104bd919061187a565b6101008301516040516370a0823160e01b8152919a506001600160a01b0316906370a08231906104f1908f906004016118e3565b60206040518083038186803b15801561050957600080fd5b505afa15801561051d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610541919061187a565b61010083015160405163631a6fd560e11b8152919b506001600160a01b03169063c634dfaa90610575908f906004016118e3565b60206040518083038186803b15801561058d57600080fd5b505afa1580156105a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105c5919061187a565b610120830151604051630ed1279f60e11b81529199506001600160a01b031690631da24f3e906105f9908f906004016118e3565b60206040518083038186803b15801561061157600080fd5b505afa158015610625573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610649919061187a565b965081606001516001600160801b031694508161010001516001600160a01b031663e78c9b3b8d6040518263ffffffff1660e01b815260040161068c91906118e3565b60206040518083038186803b1580156106a457600080fd5b505afa1580156106b8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106dc919061187a565b610100830151604051631e739ae360e21b81529197506001600160a01b0316906379ce6b8c90610710908f906004016118e3565b60206040518083038186803b15801561072857600080fd5b505afa15801561073c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107609190611892565b935061077d82610160015160ff16826113ea90919063ffffffff16565b925050509295985092959850929598565b6000806000806000806000806000806107a56114b3565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316630261bf8b6040518163ffffffff1660e01b815260040160206040518083038186803b1580156107fe57600080fd5b505afa158015610812573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061083691906115d9565b6001600160a01b03166335ea6a758d6040518263ffffffff1660e01b815260040161086191906118e3565b6101806040518083038186803b15801561087a57600080fd5b505afa15801561088e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108b2919061177f565b60e08101516040516370a0823160e01b81529192506001600160a01b038e16916370a08231916108e4916004016118e3565b60206040518083038186803b1580156108fc57600080fd5b505afa158015610910573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610934919061187a565b8161010001516001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561097257600080fd5b505afa158015610986573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109aa919061187a565b8261012001516001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b1580156109e857600080fd5b505afa1580156109fc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a20919061187a565b836060015184608001518560a001518661010001516001600160a01b03166390f6fcf26040518163ffffffff1660e01b815260040160206040518083038186803b158015610a6d57600080fd5b505afa158015610a81573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aa5919061187a565b876020015188604001518960c00151866001600160801b03169650856001600160801b03169550846001600160801b03169450826001600160801b03169250816001600160801b031691509a509a509a509a509a509a509a509a509a509a50509193959799509193959799565b600080600080600080600080600080610b2961151e565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316630261bf8b6040518163ffffffff1660e01b815260040160206040518083038186803b158015610b8257600080fd5b505afa158015610b96573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bba91906115d9565b6001600160a01b031663c44b11f78d6040518263ffffffff1660e01b8152600401610be591906118e3565b60206040518083038186803b158015610bfd57600080fd5b505afa158015610c11573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c359190611764565b9050610c408161144c565b909e50929c50909a5098509650610c5681611477565b9d9f9c9e509a9c999b989a8d15159a9099909850919650945092505050565b606060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316630261bf8b6040518163ffffffff1660e01b815260040160206040518083038186803b158015610cd257600080fd5b505afa158015610ce6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d0a91906115d9565b90506060816001600160a01b031663d1946dbc6040518163ffffffff1660e01b815260040160006040518083038186803b158015610d4757600080fd5b505afa158015610d5b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610d83919081019061162d565b90506060815167ffffffffffffffff81118015610d9f57600080fd5b50604051908082528060200260200182016040528015610dd957816020015b610dc6611531565b815260200190600190039081610dbe5790505b50905060005b8251811015610fe257739f8f72aa9304c8b593d555f12ef6589cc3a579a26001600160a01b0316838281518110610e1257fe5b60200260200101516001600160a01b03161415610e915760405180604001604052806040518060400160405280600381526020016226a5a960e91b8152508152602001848381518110610e6157fe5b60200260200101516001600160a01b0316815250828281518110610e8157fe5b6020026020010181905250610fda565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b0316838281518110610ebb57fe5b60200260200101516001600160a01b03161415610f0a5760405180604001604052806040518060400160405280600381526020016208aa8960eb1b8152508152602001848381518110610e6157fe5b6040518060400160405280848381518110610f2157fe5b60200260200101516001600160a01b03166395d89b416040518163ffffffff1660e01b815260040160006040518083038186803b158015610f6157600080fd5b505afa158015610f75573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610f9d91908101906116d8565b8152602001848381518110610fae57fe5b60200260200101516001600160a01b0316815250828281518110610fce57fe5b60200260200101819052505b600101610ddf565b509250505090565b6000806000610ff76114b3565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316630261bf8b6040518163ffffffff1660e01b815260040160206040518083038186803b15801561105057600080fd5b505afa158015611064573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061108891906115d9565b6001600160a01b03166335ea6a75866040518263ffffffff1660e01b81526004016110b391906118e3565b6101806040518083038186803b1580156110cc57600080fd5b505afa1580156110e0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611104919061177f565b60e0810151610100820151610120909201519097919650945092505050565b606060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316630261bf8b6040518163ffffffff1660e01b815260040160206040518083038186803b15801561118057600080fd5b505afa158015611194573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111b891906115d9565b90506060816001600160a01b031663d1946dbc6040518163ffffffff1660e01b815260040160006040518083038186803b1580156111f557600080fd5b505afa158015611209573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611231919081019061162d565b90506060815167ffffffffffffffff8111801561124d57600080fd5b5060405190808252806020026020018201604052801561128757816020015b611274611531565b81526020019060019003908161126c5790505b50905060005b8251811015610fe25761129e6114b3565b846001600160a01b03166335ea6a758584815181106112b957fe5b60200260200101516040518263ffffffff1660e01b81526004016112dd91906118e3565b6101806040518083038186803b1580156112f657600080fd5b505afa15801561130a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061132e919061177f565b905060405180604001604052808260e001516001600160a01b03166395d89b416040518163ffffffff1660e01b815260040160006040518083038186803b15801561137857600080fd5b505afa15801561138c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526113b491908101906116d8565b81526020018260e001516001600160a01b03168152508383815181106113d657fe5b60209081029190910101525060010161128d565b60006080821060405180604001604052806002815260200161373760f01b815250906114325760405162461bcd60e51b81526004016114299190611996565b60405180910390fd5b5050815160016002830281019190911c1615155b92915050565b5161ffff80821692601083901c821692602081901c831692603082901c60ff169260409290921c1690565b51670100000000000000811615159167020000000000000082161515916704000000000000008116151591670800000000000000909116151590565b6040518061018001604052806114c761151e565b815260006020820181905260408201819052606082018190526080820181905260a0820181905260c0820181905260e082018190526101008201819052610120820181905261014082018190526101609091015290565b6040518060200160405280600081525090565b60408051808201909152606081526000602082015290565b805161144681611ae3565b600060208284031215611565578081fd5b61156f6020611a8c565b9151825250919050565b80516001600160801b038116811461144657600080fd5b805164ffffffffff8116811461144657600080fd5b805160ff8116811461144657600080fd5b6000602082840312156115c7578081fd5b81356115d281611ae3565b9392505050565b6000602082840312156115ea578081fd5b81516115d281611ae3565b60008060408385031215611607578081fd5b823561161281611ae3565b9150602083013561162281611ae3565b809150509250929050565b6000602080838503121561163f578182fd5b825167ffffffffffffffff80821115611656578384fd5b818501915085601f830112611669578384fd5b815181811115611677578485fd5b8381029150611687848301611a8c565b8181528481019084860184860187018a10156116a1578788fd5b8795505b838610156116cb576116b78a82611549565b8352600195909501949186019186016116a5565b5098975050505050505050565b6000602082840312156116e9578081fd5b815167ffffffffffffffff80821115611700578283fd5b818401915084601f830112611713578283fd5b815181811115611721578384fd5b611734601f8201601f1916602001611a8c565b915080825285602082850101111561174a578384fd5b61175b816020840160208601611ab3565b50949350505050565b600060208284031215611775578081fd5b6115d28383611554565b6000610180808385031215611792578182fd5b61179b81611a8c565b90506117a78484611554565b81526117b68460208501611579565b60208201526117c88460408501611579565b60408201526117da8460608501611579565b60608201526117ec8460808501611579565b60808201526117fe8460a08501611579565b60a08201526118108460c08501611590565b60c08201526118228460e08501611549565b60e082015261010061183685828601611549565b9082015261012061184985858301611549565b9082015261014061185c85858301611549565b9082015261016061186f858583016115a5565b908201529392505050565b60006020828403121561188b578081fd5b5051919050565b6000602082840312156118a3578081fd5b815164ffffffffff811681146115d2578182fd5b600081518084526118cf816020860160208601611ab3565b601f01601f19169290920160200192915050565b6001600160a01b0391909116815260200190565b6001600160a01b0393841681529183166020830152909116604082015260600190565b60208082528251828201819052600091906040908185019080840286018301878501865b8381101561198857888303603f1901855281518051878552611962888601826118b7565b918901516001600160a01b0316948901949094529487019492509086019060010161193e565b509098975050505050505050565b6000602082526115d260208301846118b7565b998a5260208a0198909852604089019690965260608801949094526080870192909252151560a0860152151560c0850152151560e0840152151561010083015215156101208201526101400190565b998a5260208a019890985260408901969096526060880194909452608087019290925260a086015260c085015260e084015261010083015264ffffffffff166101208201526101400190565b988952602089019790975260408801959095526060870193909352608086019190915260a085015260c084015264ffffffffff1660e083015215156101008201526101200190565b60405181810167ffffffffffffffff81118282101715611aab57600080fd5b604052919050565b60005b83811015611ace578181015183820152602001611ab6565b83811115611add576000848401525b50505050565b6001600160a01b0381168114611af857600080fd5b5056fea2646970667358221220f73278d5d14952b953e77ae18bfcedea4a304aca72eaaad34dc0bb74af1902e264736f6c634300060c0033", + "deployedBytecode": "", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/external/abi/aave/v2/AaveV2StableDebtToken.json b/external/abi/aave/v2/AaveV2StableDebtToken.json new file mode 100644 index 000000000..fa936175f --- /dev/null +++ b/external/abi/aave/v2/AaveV2StableDebtToken.json @@ -0,0 +1,775 @@ +{ + "contractName": "AaveV2StableDebtToken", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "fromUser", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "toUser", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "BorrowAllowanceDelegated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "currentBalance", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "balanceIncrease", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "avgStableRate", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newTotalSupply", + "type": "uint256" + } + ], + "name": "Burn", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "underlyingAsset", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "incentivesController", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint8", + "name": "debtTokenDecimals", + "type": "uint8" + }, + { + "indexed": false, + "internalType": "string", + "name": "debtTokenName", + "type": "string" + }, + { + "indexed": false, + "internalType": "string", + "name": "debtTokenSymbol", + "type": "string" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "params", + "type": "bytes" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "onBehalfOf", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "currentBalance", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "balanceIncrease", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newRate", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "avgStableRate", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newTotalSupply", + "type": "uint256" + } + ], + "name": "Mint", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "inputs": [], + "name": "DEBT_TOKEN_REVISION", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "POOL", + "outputs": [ + { + "internalType": "contract ILendingPool", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "UNDERLYING_ASSET_ADDRESS", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "delegatee", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "approveDelegation", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "fromUser", + "type": "address" + }, + { + "internalType": "address", + "name": "toUser", + "type": "address" + } + ], + "name": "borrowAllowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "burn", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "subtractedValue", + "type": "uint256" + } + ], + "name": "decreaseAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "getAverageStableRate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getIncentivesController", + "outputs": [ + { + "internalType": "contract IAaveIncentivesController", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getSupplyData", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint40", + "name": "", + "type": "uint40" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getTotalSupplyAndAvgRate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getTotalSupplyLastUpdated", + "outputs": [ + { + "internalType": "uint40", + "name": "", + "type": "uint40" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "getUserLastUpdated", + "outputs": [ + { + "internalType": "uint40", + "name": "", + "type": "uint40" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "getUserStableRate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "addedValue", + "type": "uint256" + } + ], + "name": "increaseAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ILendingPool", + "name": "pool", + "type": "address" + }, + { + "internalType": "address", + "name": "underlyingAsset", + "type": "address" + }, + { + "internalType": "contract IAaveIncentivesController", + "name": "incentivesController", + "type": "address" + }, + { + "internalType": "uint8", + "name": "debtTokenDecimals", + "type": "uint8" + }, + { + "internalType": "string", + "name": "debtTokenName", + "type": "string" + }, + { + "internalType": "string", + "name": "debtTokenSymbol", + "type": "string" + }, + { + "internalType": "bytes", + "name": "params", + "type": "bytes" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "address", + "name": "onBehalfOf", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rate", + "type": "uint256" + } + ], + "name": "mint", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "principalBalanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bytecode": "0x608060405260006006553480156200001657600080fd5b50604080518082018252600e8082526d111150951513d2d15397d253541360921b60208084018281528551808701909652928552840152815191929160009162000064916003919062000098565b5081516200007a90600490602085019062000098565b506005805460ff191660ff9290921691909117905550620001349050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10620000db57805160ff19168380011785556200010b565b828001600101855582156200010b579182015b828111156200010b578251825591602001919060010190620000ee565b50620001199291506200011d565b5090565b5b808211156200011957600081556001016200011e565b611d2080620001446000396000f3fe608060405234801561001057600080fd5b50600436106101a95760003560e01c806395d89b41116100f9578063c04a8a1011610097578063dd62ed3e11610071578063dd62ed3e146106ab578063e7484890146106d9578063e78c9b3b146106e1578063f731e9be14610707576101a9565b8063c04a8a10146104b0578063c222ec8a146104dc578063c634dfaa14610685576101a9565b8063a9059cbb116100d3578063a9059cbb14610438578063b16a19de14610464578063b3f1c93d1461046c578063b9a7b622146104a8576101a9565b806395d89b41146104025780639dc29fac1461040a578063a457c2d7146102d9576101a9565b80636bd76d241161016657806375d264131161014057806375d264131461037d578063797743381461038557806379ce6b8c146103ba57806390f6fcf2146103fa576101a9565b80636bd76d241461030557806370a08231146103335780637535d24614610359576101a9565b806306fdde03146101ae578063095ea7b31461022b57806318160ddd1461026b57806323b872dd14610285578063313ce567146102bb57806339509351146102d9575b600080fd5b6101b6610728565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101f05781810151838201526020016101d8565b50505050905090810190601f16801561021d5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102576004803603604081101561024157600080fd5b506001600160a01b0381351690602001356107be565b604080519115158252519081900360200190f35b610273610806565b60408051918252519081900360200190f35b6102576004803603606081101561029b57600080fd5b506001600160a01b03813581169160208101359091169060400135610818565b6102c3610860565b6040805160ff9092168252519081900360200190f35b610257600480360360408110156102ef57600080fd5b506001600160a01b038135169060200135610869565b6102736004803603604081101561031b57600080fd5b506001600160a01b03813581169160200135166108b8565b6102736004803603602081101561034957600080fd5b50356001600160a01b03166108e5565b61036161095f565b604080516001600160a01b039092168252519081900360200190f35b610361610977565b61038d610981565b6040805194855260208501939093528383019190915264ffffffffff166060830152519081900360800190f35b6103e0600480360360208110156103d057600080fd5b50356001600160a01b03166109b7565b6040805164ffffffffff9092168252519081900360200190f35b6102736109d9565b6101b66109df565b6104366004803603604081101561042057600080fd5b506001600160a01b038135169060200135610a40565b005b6102576004803603604081101561044e57600080fd5b506001600160a01b038135169060200135610818565b610361610da6565b6102576004803603608081101561048257600080fd5b506001600160a01b03813581169160208101359091169060408101359060600135610db5565b61027361110d565b610436600480360360408110156104c657600080fd5b506001600160a01b038135169060200135611112565b610436600480360360e08110156104f257600080fd5b6001600160a01b038235811692602081013582169260408201359092169160ff606083013516919081019060a08101608082013564010000000081111561053857600080fd5b82018360208201111561054a57600080fd5b8035906020019184600183028401116401000000008311171561056c57600080fd5b91908080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525092959493602081019350359150506401000000008111156105bf57600080fd5b8201836020820111156105d157600080fd5b803590602001918460018302840111640100000000831117156105f357600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929594936020810193503591505064010000000081111561064657600080fd5b82018360208201111561065857600080fd5b8035906020019184600183028401116401000000008311171561067a57600080fd5b5090925090506111ae565b6102736004803603602081101561069b57600080fd5b50356001600160a01b0316611412565b610273600480360360408110156106c157600080fd5b506001600160a01b0381358116916020013516610869565b6103e061141d565b610273600480360360208110156106f757600080fd5b50356001600160a01b031661142a565b61070f611445565b6040805192835260208301919091528051918290030190f35b60038054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156107b45780601f10610789576101008083540402835291602001916107b4565b820191906000526020600020905b81548152906001019060200180831161079757829003601f168201915b5050505050905090565b6040805162461bcd60e51b81526020600482015260166024820152751054141493d5905317d393d517d4d5541413d495115160521b6044820152905160009181900360640190fd5b6000610813603b5461145e565b905090565b6040805162461bcd60e51b81526020600482015260166024820152751514905394d1915497d393d517d4d5541413d495115160521b6044820152905160009181900360640190fd5b60055460ff1690565b6040805162461bcd60e51b815260206004820152601760248201527f414c4c4f57414e43455f4e4f545f535550504f525445440000000000000000006044820152905160009181900360640190fd5b6001600160a01b038083166000908152603a60209081526040808320938516835292905220545b92915050565b6000806108f1836114a6565b6001600160a01b0384166000908152603d60205260409020549091508161091d5760009250505061095a565b6001600160a01b0384166000908152603c602052604081205461094890839064ffffffffff166114c1565b905061095483826114d5565b93505050505b919050565b603e546501000000000090046001600160a01b031690565b6000610813611593565b6000806000806000603b5490506109966115a2565b61099f8261145e565b603e54919790965091945064ffffffffff1692509050565b6001600160a01b03166000908152603c602052604090205464ffffffffff1690565b603b5490565b60048054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156107b45780601f10610789576101008083540402835291602001916107b4565b610a4861095f565b6001600160a01b0316610a596115a8565b6001600160a01b03161460405180604001604052806002815260200161323960f01b81525090610b075760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610acc578181015183820152602001610ab4565b50505050905090810190601f168015610af95780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600080610b14846115ac565b92509250506000610b23610806565b6001600160a01b0386166000908152603d6020526040812054919250908190868411610b58576000603b819055600255610bda565b610b628488611605565b600281905591506000610b80610b7786611647565b603b54906114d5565b90506000610b97610b908a611647565b84906114d5565b9050818110610bb35760006002819055603b8190559450610bd7565b610bcf610bbf85611647565b610bc98484611605565b906116c5565b603b81905594505b50505b85871415610c18576001600160a01b0388166000908152603d60209081526040808320839055603c9091529020805464ffffffffff19169055610c46565b6001600160a01b0388166000908152603c60205260409020805464ffffffffff19164264ffffffffff161790555b603e805464ffffffffff19164264ffffffffff1617905586851115610ce6576000610c718689611605565b9050610c7e8982876117cc565b6040805182815260208101899052808201889052606081018490526080810186905260a0810185905290516001600160a01b038b169182917fc16f4e4ca34d790de4c656c72fd015c667d688f20be64eea360618545c4c530f9181900360c00190a350610d5b565b6000610cf28887611605565b9050610cff898287611891565b6040805182815260208101899052808201889052606081018690526080810185905290516001600160a01b038b16917f44bd20a79e993bdcc7cbedf54a3b4d19fb78490124b6b90d04fe3242eea579e8919081900360a00190a2505b6040805188815290516000916001600160a01b038b16917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050505050505050565b603f546001600160a01b031690565b6000610dbf61095f565b6001600160a01b0316610dd06115a8565b6001600160a01b03161460405180604001604052806002815260200161323960f01b81525090610e415760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610acc578181015183820152602001610ab4565b50610e4a611bd9565b846001600160a01b0316866001600160a01b031614610e6e57610e6e8587866118d3565b600080610e7a876115ac565b9250925050610e87610806565b808452603b546080850152610e9c908761199b565b60028190556020840152610eaf86611647565b6040840152610f0d610ec9610ec4848961199b565b611647565b6040850151610bc990610edc90896114d5565b610f07610ee887611647565b6001600160a01b038d166000908152603d6020526040902054906114d5565b9061199b565b60608401819052604080518082019091526002815261373960f01b6020820152906fffffffffffffffffffffffffffffffff1015610f8c5760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610acc578181015183820152602001610ab4565b5060608301516001600160a01b0388166000908152603d6020908152604080832093909355603c8152919020805464ffffffffff421664ffffffffff199182168117909255603e8054909116909117905583015161102290610fed90611647565b610bc96110078660400151896114d590919063ffffffff16565b610f076110178860000151611647565b6080890151906114d5565b603b81905560808401526110418761103a888461199b565b85516117cc565b6040805187815290516001600160a01b038916916000917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a3866001600160a01b0316886001600160a01b03167fc16f4e4ca34d790de4c656c72fd015c667d688f20be64eea360618545c4c530f888585886060015189608001518a6020015160405180878152602001868152602001858152602001848152602001838152602001828152602001965050505050505060405180910390a350159695505050505050565b600181565b80603a600061111f6115a8565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120919091556111576115a8565b6001600160a01b03167fda919360433220e13b51e8c211e490d148e61a3bd53de8c097194e458b97f3e1611189610da6565b604080516001600160a01b039092168252602082018690528051918290030190a35050565b60006111b86119f5565b60075490915060ff16806111cf57506111cf6119fa565b806111db575060065481115b6112165760405162461bcd60e51b815260040180806020018281038252602e815260200180611cbd602e913960400191505060405180910390fd5b60075460ff16158015611236576007805460ff1916600117905560068290555b61123f86611a00565b61124885611a17565b61125187611a2a565b603e805465010000000000600160c81b031916650100000000006001600160a01b038d811691820292909217909255603f80546001600160a01b03199081168d841690811790925560408054909116928c169283178155805192835260ff8b1660208085019190915260a09184018281528b51928501929092528a5192937f40251fbfb6656cfa65a00d7879029fec1fad21d28fdcff2f4f68f52795b74f2c938e938e938e938e938e938e9390916060840191608085019160c08601918a019080838360005b8381101561132f578181015183820152602001611317565b50505050905090810190601f16801561135c5780820380516001836020036101000a031916815260200191505b50848103835287518152875160209182019189019080838360005b8381101561138f578181015183820152602001611377565b50505050905090810190601f1680156113bc5780820380516001836020036101000a031916815260200191505b508481038252858152602001868680828437600083820152604051601f909101601f19169092018290039b50909950505050505050505050a38015611406576007805460ff191690555b50505050505050505050565b60006108df826114a6565b603e5464ffffffffff1690565b6001600160a01b03166000908152603d602052604090205490565b603b5460009081906114568161145e565b925090509091565b6000806114696115a2565b90508061147a57600091505061095a565b603e5460009061149290859064ffffffffff166114c1565b905061149e82826114d5565b949350505050565b6001600160a01b031660009081526020819052604090205490565b60006114ce838342611a40565b9392505050565b60008215806114e2575081155b156114ef575060006108df565b816b019d971e4fe8401e74000000198161150557fe5b0483111560405180604001604052806002815260200161068760f31b815250906115705760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610acc578181015183820152602001610ab4565b50506b033b2e3c9fd0803ce800000091026b019d971e4fe8401e74000000010490565b6040546001600160a01b031690565b60025490565b3390565b6000806000806115bb856114a6565b9050806115d3576000806000935093509350506115fe565b60006115e8826115e2886108e5565b90611605565b9050816115f5818361199b565b90955093509150505b9193909250565b60006114ce83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611b16565b6000633b9aca0082810290839082041460405180604001604052806002815260200161068760f31b815250906116be5760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610acc578181015183820152602001610ab4565b5092915050565b604080518082019091526002815261035360f41b60208201526000908261172d5760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610acc578181015183820152602001610ab4565b5060408051808201909152600280825261068760f31b60208301528304906b033b2e3c9fd0803ce80000008219048511156117a95760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610acc578181015183820152602001610ab4565b5082816b033b2e3c9fd0803ce8000000860201816117c357fe5b04949350505050565b6001600160a01b0383166000908152602081905260409020546117ef818461199b565b6001600160a01b0380861660009081526020819052604090819020929092559054161561188b576040805481516318c39f1760e11b81526001600160a01b0387811660048301526024820186905260448201859052925192909116916331873e2e9160648082019260009290919082900301818387803b15801561187257600080fd5b505af1158015611886573d6000803e3d6000fd5b505050505b50505050565b6001600160a01b038316600090815260208181526040918290205482518084019093526002835261038360f41b91830191909152906117ef9082908590611b16565b6040805180820182526002815261353960f01b6020808301919091526001600160a01b038087166000908152603a8352848120918716815291529182205461191c918490611b16565b6001600160a01b038086166000818152603a60209081526040808320948916808452949091529020839055919250907fda919360433220e13b51e8c211e490d148e61a3bd53de8c097194e458b97f3e1611974610da6565b604080516001600160a01b039092168252602082018690528051918290030190a350505050565b6000828201838110156114ce576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b600190565b303b1590565b8051611a13906003906020840190611c08565b5050565b8051611a13906004906020840190611c08565b6005805460ff191660ff92909216919091179055565b600080611a548364ffffffffff8616611605565b905080611a6b57611a63611b70565b9150506114ce565b6000198101600060028311611a81576000611a86565b600283035b90506301e1338087046000611a9b82806114d5565b90506000611aa982846114d5565b905060006002611ac384611abd8a8a611b80565b90611b80565b81611aca57fe5b04905060006006611ae184611abd89818d8d611b80565b81611ae857fe5b049050611b0681610f078481611afe8a8e611b80565b610f07611b70565b9c9b505050505050505050505050565b60008184841115611b685760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610acc578181015183820152602001610ab4565b505050900390565b6b033b2e3c9fd0803ce800000090565b600082611b8f575060006108df565b82820282848281611b9c57fe5b04146114ce5760405162461bcd60e51b8152600401808060200182810382526021815260200180611c9c6021913960400191505060405180910390fd5b6040518060a0016040528060008152602001600081526020016000815260200160008152602001600081525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10611c4957805160ff1916838001178555611c76565b82800160010185558215611c76579182015b82811115611c76578251825591602001919060010190611c5b565b50611c82929150611c86565b5090565b5b80821115611c825760008155600101611c8756fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77436f6e747261637420696e7374616e63652068617320616c7265616479206265656e20696e697469616c697a6564a2646970667358221220f10dc7813ca27ef277f8ddba45f5ef5111bd72a10a8af262a430857f8ed624c764736f6c634300060c0033", + "deployedBytecode": "", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/external/abi/aave/v2/AaveV2StakedTokenIncentivesController.json b/external/abi/aave/v2/AaveV2StakedTokenIncentivesController.json new file mode 100644 index 000000000..67fb6b488 --- /dev/null +++ b/external/abi/aave/v2/AaveV2StakedTokenIncentivesController.json @@ -0,0 +1,8 @@ +{ + "contractName": "AaveV2StakedTokenIncentivesController", + "abi": [{"inputs":[{"internalType":"contract IStakedTokenWithConfig","name":"stakeToken","type":"address"},{"internalType":"address","name":"emissionManager","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"uint256","name":"emission","type":"uint256"}],"name":"AssetConfigUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"uint256","name":"index","type":"uint256"}],"name":"AssetIndexUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"claimer","type":"address"}],"name":"ClaimerSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newDistributionEnd","type":"uint256"}],"name":"DistributionEndUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RewardsAccrued","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"address","name":"claimer","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RewardsClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"uint256","name":"index","type":"uint256"}],"name":"UserIndexUpdated","type":"event"},{"inputs":[],"name":"DISTRIBUTION_END","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"EMISSION_MANAGER","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PRECISION","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"REVISION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"REWARD_TOKEN","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"STAKE_TOKEN","outputs":[{"internalType":"contract IStakedTokenWithConfig","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"assets","outputs":[{"internalType":"uint104","name":"emissionPerSecond","type":"uint104"},{"internalType":"uint104","name":"index","type":"uint104"},{"internalType":"uint40","name":"lastUpdateTimestamp","type":"uint40"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"assets","type":"address[]"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"to","type":"address"}],"name":"claimRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"assets","type":"address[]"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"to","type":"address"}],"name":"claimRewardsOnBehalf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"assets","type":"address[]"},{"internalType":"uint256[]","name":"emissionsPerSecond","type":"uint256[]"}],"name":"configureAssets","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"getAssetData","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"getClaimer","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDistributionEnd","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"assets","type":"address[]"},{"internalType":"address","name":"user","type":"address"}],"name":"getRewardsBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"asset","type":"address"}],"name":"getUserAssetData","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"getUserUnclaimedRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"totalSupply","type":"uint256"},{"internalType":"uint256","name":"userBalance","type":"uint256"}],"name":"handleAction","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"addressesProvider","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"caller","type":"address"}],"name":"setClaimer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"distributionEnd","type":"uint256"}],"name":"setDistributionEnd","outputs":[],"stateMutability":"nonpayable","type":"function"}], + "bytecode": "60c0604052600080553480156200001557600080fd5b5060405162001e7138038062001e71833981016040819052620000389162000058565b6001600160601b0319606091821b811660805291901b1660a052620000af565b600080604083850312156200006b578182fd5b8251620000788162000096565b60208401519092506200008b8162000096565b809150509250929050565b6001600160a01b0381168114620000ac57600080fd5b50565b60805160601c60a05160601c611d75620000fc6000398061030552806109a85280610a275280610a4b5280610e49525080610442528061058d5280610af05280610b595250611d756000f3fe608060405234801561001057600080fd5b506004361061012c5760003560e01c80638b599f26116100ad578063cbcbb50711610071578063cbcbb50714610263578063cc69afec1461022b578063dde43cba1461026b578063f11b818814610273578063f5cf673b146102955761012c565b80638b599f2614610218578063919cd40f1461022b57806399248ea714610233578063aaf5eb681461023b578063c4d66de8146102505761012c565b80633373ee4c116100f45780633373ee4c146101b957806339ccbdd3146101cc5780636d34b96e146101df57806374d945ec146101f257806379f171b2146102055761012c565b80631652e7b714610131578063198fa81e1461015c5780631c39b6721461017c5780633111e7b31461019157806331873e2e146101a4575b600080fd5b61014461013f36600461186f565b6102a8565b60405161015393929190611c75565b60405180910390f35b61016f61016a36600461186f565b6102e8565b6040516101539190611c6c565b610184610303565b6040516101539190611af3565b61016f61019f3660046119d1565b610327565b6101b76101b23660046118df565b610371565b005b61016f6101c73660046118a7565b610406565b6101b76101da366004611aa0565b610437565b61016f6101ed366004611a2e565b6104bf565b61018461020036600461186f565b610564565b6101b7610213366004611968565b610582565b61016f610226366004611913565b6107e7565b61016f6109a0565b6101846109a6565b6102436109ca565b6040516101539190611c8b565b6101b761025e36600461186f565b6109cf565b610184610aee565b61016f610b12565b61028661028136600461186f565b610b17565b60405161015393929190611c42565b6101b76102a33660046118a7565b610b4e565b6001600160a01b0316600090815260336020526040902054600160681b81046001600160681b039081169290821691600160d01b900464ffffffffff1690565b6001600160a01b031660009081526035602052604090205490565b7f000000000000000000000000000000000000000000000000000000000000000081565b60006001600160a01b0382166103585760405162461bcd60e51b815260040161034f90611b4e565b60405180910390fd5b610366858585333387610bed565b90505b949350505050565b600061037f84338486610f17565b90508015610400576001600160a01b0384166000908152603560205260409020546103aa9082610fd6565b6001600160a01b038516600081815260356020526040908190209290925590517f2468f9268c60ad90e2d49edb0032c8a001e733ae888b3ab8e982edf535be1a76906103f7908490611c6c565b60405180910390a25b50505050565b6001600160a01b03808216600090815260336020908152604080832093861683526001909301905220545b92915050565b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461047f5760405162461bcd60e51b815260040161034f90611bd1565b60348190556040517f1cc1849a6602c3e91f2088cadea4381cc5717f2f28584197060ed2ebb434c16f906104b4908390611c6c565b60405180910390a150565b6001600160a01b038083166000908152603660205260408120549091339185911682146104fe5760405162461bcd60e51b815260040161034f90611c00565b6001600160a01b0385166105245760405162461bcd60e51b815260040161034f90611b20565b6001600160a01b03841661054a5760405162461bcd60e51b815260040161034f90611b4e565b610558888888338989610bed565b98975050505050505050565b6001600160a01b039081166000908152603660205260409020541690565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146105ca5760405162461bcd60e51b815260040161034f90611bd1565b8281146105e95760405162461bcd60e51b815260040161034f90611b7a565b60608367ffffffffffffffff8111801561060257600080fd5b5060405190808252806020026020018201604052801561063c57816020015b6106296117dc565b8152602001906001900390816106215790505b50905060005b848110156107d65785858281811061065657fe5b905060200201602081019061066b919061186f565b82828151811061067757fe5b6020026020010151604001906001600160a01b031690816001600160a01b0316815250508383828181106106a757fe5b905060200201358282815181106106ba57fe5b60209081029190910101516001600160681b0390911690528383828181106106de57fe5b905060200201358282815181106106f157fe5b6020026020010151600001516001600160681b0316146107235760405162461bcd60e51b815260040161034f90611b7a565b85858281811061072f57fe5b9050602002016020810190610744919061186f565b6001600160a01b031663b1bf962d6040518163ffffffff1660e01b815260040160206040518083038186803b15801561077c57600080fd5b505afa158015610790573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107b49190611ab8565b8282815181106107c057fe5b6020908102919091018101510152600101610642565b506107e081610fe6565b5050505050565b6001600160a01b03811660009081526035602052604081205460608467ffffffffffffffff8111801561081957600080fd5b5060405190808252806020026020018201604052801561085357816020015b6108406117fc565b8152602001906001900390816108385790505b50905060005b8581101561097f5786868281811061086d57fe5b9050602002016020810190610882919061186f565b82828151811061088e57fe5b60209081029190910101516001600160a01b0390911690528686828181106108b257fe5b90506020020160208101906108c7919061186f565b6001600160a01b0316630afbcdc9866040518263ffffffff1660e01b81526004016108f29190611af3565b604080518083038186803b15801561090957600080fd5b505afa15801561091d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109419190611ad0565b83838151811061094d57fe5b602002602001015160200184848151811061096457fe5b60209081029190910101516040019190915252600101610859565b5061099461098d858361111e565b8390610fd6565b925050505b9392505050565b60345490565b7f000000000000000000000000000000000000000000000000000000000000000090565b601281565b60006109d961121c565b90506000548111610a1b5760405162461bcd60e51b815260040180806020018281038252602e815260200180611cb2602e913960400191505060405180910390fd5b80600081905550610aea7f00000000000000000000000000000000000000000000000000000000000000006000197f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663312f6b836040518163ffffffff1660e01b815260040160206040518083038186803b158015610aa257600080fd5b505afa158015610ab6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ada919061188b565b6001600160a01b03169190611221565b5050565b7f000000000000000000000000000000000000000000000000000000000000000081565b600181565b6033602052600090815260409020546001600160681b0380821691600160681b810490911690600160d01b900464ffffffffff1683565b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610b965760405162461bcd60e51b815260040161034f90611bd1565b6001600160a01b0382811660008181526036602052604080822080546001600160a01b0319169486169485179055517f4925eafc82d0c4d67889898eeed64b18488ab19811e61620f387026dec126a289190a35050565b600084610bfc57506000610f0d565b6001600160a01b03831660009081526035602052604090205460608767ffffffffffffffff81118015610c2e57600080fd5b50604051908082528060200260200182016040528015610c6857816020015b610c556117fc565b815260200190600190039081610c4d5790505b50905060005b88811015610d9457898982818110610c8257fe5b9050602002016020810190610c97919061186f565b828281518110610ca357fe5b60209081029190910101516001600160a01b039091169052898982818110610cc757fe5b9050602002016020810190610cdc919061186f565b6001600160a01b0316630afbcdc9876040518263ffffffff1660e01b8152600401610d079190611af3565b604080518083038186803b158015610d1e57600080fd5b505afa158015610d32573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d569190611ad0565b838381518110610d6257fe5b6020026020010151602001848481518110610d7957fe5b60209081029190910101516040019190915252600101610c6e565b506000610da18683611339565b90508015610df757610db38382610fd6565b9250856001600160a01b03167f2468f9268c60ad90e2d49edb0032c8a001e733ae888b3ab8e982edf535be1a7682604051610dee9190611c6c565b60405180910390a25b82610e085760009350505050610f0d565b6000838911610e175788610e19565b835b6001600160a01b03808916600090815260356020526040908190208388039055516356e4bb9760e11b81529192507f0000000000000000000000000000000000000000000000000000000000000000169063adc9772e90610e809089908590600401611b07565b600060405180830381600087803b158015610e9a57600080fd5b505af1158015610eae573d6000803e3d6000fd5b50505050876001600160a01b0316866001600160a01b0316886001600160a01b03167f5637d7f962248a7f05a7ab69eec6446e31f3d0a299d997f135a65c62806e789184604051610eff9190611c6c565b60405180910390a493505050505b9695505050505050565b6001600160a01b0380841660009081526033602090815260408083209388168352600184019091528120549091908280610f528885886113a5565b9050808314610fca578615610f6f57610f6c8782856114d5565b91505b6001600160a01b03808a1660008181526001870160205260409081902084905551918a16917fbb123b5c06d5408bbea3c4fef481578175cfb432e3b482c6186f02ed9086585b90610fc1908590611c6c565b60405180910390a35b50979650505050505050565b8082018281101561043157600080fd5b60005b8151811015610aea5760006033600084848151811061100457fe5b6020026020010151604001516001600160a01b03166001600160a01b03168152602001908152602001600020905061106b83838151811061104157fe5b6020026020010151604001518285858151811061105a57fe5b6020026020010151602001516113a5565b5082828151811061107857fe5b60209081029190910101515181546cffffffffffffffffffffffffff19166001600160681b0390911617815582518390839081106110b257fe5b6020026020010151604001516001600160a01b03167f87fa03892a0556cb6b8f97e6d533a150d4d55fcbf275fff5fa003fa636bcc7fa8484815181106110f457fe5b60200260200101516000015160405161110d9190611c2e565b60405180910390a250600101610fe9565b600080805b83518110156112145760006033600086848151811061113e57fe5b602090810291909101810151516001600160a01b031682528101919091526040016000908120805487519193506111b391600160681b82046001600160681b039081169290811691600160d01b90910464ffffffffff16908a90889081106111a257fe5b602002602001015160400151611504565b90506112086112018785815181106111c757fe5b602002602001015160200151838560010160008c6001600160a01b03166001600160a01b03168152602001908152602001600020546114d5565b8590610fd6565b93505050600101611123565b509392505050565b600190565b8015806112a7575060408051636eb1769f60e11b81523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b15801561127957600080fd5b505afa15801561128d573d6000803e3d6000fd5b505050506040513d60208110156112a357600080fd5b5051155b6112e25760405162461bcd60e51b8152600401808060200182810382526036815260200180611d0a6036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b1790526113349084906115a4565b505050565b600080805b83518110156112145761139b61098d8686848151811061135a57fe5b60200260200101516000015187858151811061137257fe5b60200260200101516020015188868151811061138a57fe5b602002602001015160400151610f17565b915060010161133e565b81546000906001600160681b03600160681b82048116919081169064ffffffffff600160d01b90910416428114156113e257829350505050610999565b60006113f084848489611504565b90508381146114ab5780816001600160681b0316146114215760405162461bcd60e51b815260040161034f90611ba9565b86546cffffffffffffffffffffffffff60681b1916600160681b6001600160681b038316021764ffffffffff60d01b1916600160d01b4264ffffffffff16021787556040516001600160a01b038916907f5777ca300dfe5bead41006fbce4389794dbc0ed8d6cccebfaf94630aa04184bc9061149e908490611c6c565b60405180910390a26114ca565b865464ffffffffff60d01b1916600160d01b4264ffffffffff16021787555b979650505050505050565b6000670de0b6b3a76400006114f46114ed858561175c565b869061176c565b816114fb57fe5b04949350505050565b603454600090841580611515575082155b80611528575042846001600160801b0316145b8061153c575080846001600160801b031610155b1561154a5785915050610369565b6000814211611559574261155b565b815b90506000611572826001600160801b03881661175c565b90506105588861159e87611598670de0b6b3a76400006115928d8861176c565b9061176c565b90611790565b90610fd6565b6115b6826001600160a01b03166117a3565b611607576040805162461bcd60e51b815260206004820152601f60248201527f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e747261637400604482015290519081900360640190fd5b60006060836001600160a01b0316836040518082805190602001908083835b602083106116455780518252601f199092019160209182019101611626565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d80600081146116a7576040519150601f19603f3d011682016040523d82523d6000602084013e6116ac565b606091505b509150915081611703576040805162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564604482015290519081900360640190fd5b8051156104005780806020019051602081101561171f57600080fd5b50516104005760405162461bcd60e51b815260040180806020018281038252602a815260200180611ce0602a913960400191505060405180910390fd5b8082038281111561043157600080fd5b60008215806117875750508181028183828161178457fe5b04145b61043157600080fd5b600081838161179b57fe5b049392505050565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470818114801590610369575050151592915050565b604080516060810182526000808252602082018190529181019190915290565b604051806060016040528060006001600160a01b0316815260200160008152602001600081525090565b60008083601f840112611837578182fd5b50813567ffffffffffffffff81111561184e578182fd5b602083019150836020808302850101111561186857600080fd5b9250929050565b600060208284031215611880578081fd5b813561099981611c99565b60006020828403121561189c578081fd5b815161099981611c99565b600080604083850312156118b9578081fd5b82356118c481611c99565b915060208301356118d481611c99565b809150509250929050565b6000806000606084860312156118f3578081fd5b83356118fe81611c99565b95602085013595506040909401359392505050565b600080600060408486031215611927578283fd5b833567ffffffffffffffff81111561193d578384fd5b61194986828701611826565b909450925050602084013561195d81611c99565b809150509250925092565b6000806000806040858703121561197d578081fd5b843567ffffffffffffffff80821115611994578283fd5b6119a088838901611826565b909650945060208701359150808211156119b8578283fd5b506119c587828801611826565b95989497509550505050565b600080600080606085870312156119e6578384fd5b843567ffffffffffffffff8111156119fc578485fd5b611a0887828801611826565b909550935050602085013591506040850135611a2381611c99565b939692955090935050565b600080600080600060808688031215611a45578081fd5b853567ffffffffffffffff811115611a5b578182fd5b611a6788828901611826565b909650945050602086013592506040860135611a8281611c99565b91506060860135611a9281611c99565b809150509295509295909350565b600060208284031215611ab1578081fd5b5035919050565b600060208284031215611ac9578081fd5b5051919050565b60008060408385031215611ae2578182fd5b505080516020909101519092909150565b6001600160a01b0391909116815260200190565b6001600160a01b03929092168252602082015260400190565b602080825260149082015273494e56414c49445f555345525f4144445245535360601b604082015260600190565b602080825260129082015271494e56414c49445f544f5f4144445245535360701b604082015260600190565b60208082526015908201527424a72b20a624a22fa1a7a72324a3aaa920aa24a7a760591b604082015260600190565b6020808252600e908201526d496e646578206f766572666c6f7760901b604082015260600190565b60208082526015908201527427a7262cafa2a6a4a9a9a4a7a72fa6a0a720a3a2a960591b604082015260600190565b60208082526014908201527310d3105253515497d5539055551213d49256915160621b604082015260600190565b6001600160681b0391909116815260200190565b6001600160681b03938416815291909216602082015264ffffffffff909116604082015260600190565b90815260200190565b9283526020830191909152604082015260600190565b60ff91909116815260200190565b6001600160a01b0381168114611cae57600080fd5b5056fe436f6e747261637420696e7374616e63652068617320616c7265616479206265656e20696e697469616c697a65645361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e6365a2646970667358221220d94e1a7bc1c2da8e7f89644f4c7824cbb4d6c28be01bda08c043c6db1633574f64736f6c63430007050033", + "deployedBytecode": "", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/external/abi/aave/v2/AaveV2VariableDebtToken.json b/external/abi/aave/v2/AaveV2VariableDebtToken.json new file mode 100644 index 000000000..a8ef5c3f7 --- /dev/null +++ b/external/abi/aave/v2/AaveV2VariableDebtToken.json @@ -0,0 +1,665 @@ +{ + "contractName": "AaveV2VariableDebtToken", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "fromUser", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "toUser", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "BorrowAllowanceDelegated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "Burn", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "underlyingAsset", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "incentivesController", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint8", + "name": "debtTokenDecimals", + "type": "uint8" + }, + { + "indexed": false, + "internalType": "string", + "name": "debtTokenName", + "type": "string" + }, + { + "indexed": false, + "internalType": "string", + "name": "debtTokenSymbol", + "type": "string" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "params", + "type": "bytes" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "onBehalfOf", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "Mint", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "inputs": [], + "name": "DEBT_TOKEN_REVISION", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "POOL", + "outputs": [ + { + "internalType": "contract ILendingPool", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "UNDERLYING_ASSET_ADDRESS", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "delegatee", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "approveDelegation", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "fromUser", + "type": "address" + }, + { + "internalType": "address", + "name": "toUser", + "type": "address" + } + ], + "name": "borrowAllowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "burn", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "subtractedValue", + "type": "uint256" + } + ], + "name": "decreaseAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "getIncentivesController", + "outputs": [ + { + "internalType": "contract IAaveIncentivesController", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "getScaledUserBalanceAndSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "addedValue", + "type": "uint256" + } + ], + "name": "increaseAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ILendingPool", + "name": "pool", + "type": "address" + }, + { + "internalType": "address", + "name": "underlyingAsset", + "type": "address" + }, + { + "internalType": "contract IAaveIncentivesController", + "name": "incentivesController", + "type": "address" + }, + { + "internalType": "uint8", + "name": "debtTokenDecimals", + "type": "uint8" + }, + { + "internalType": "string", + "name": "debtTokenName", + "type": "string" + }, + { + "internalType": "string", + "name": "debtTokenSymbol", + "type": "string" + }, + { + "internalType": "bytes", + "name": "params", + "type": "bytes" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "address", + "name": "onBehalfOf", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "mint", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "scaledBalanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "scaledTotalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bytecode": "0x608060405260006006553480156200001657600080fd5b50604080518082018252600e8082526d111150951513d2d15397d253541360921b60208084018281528551808701909652928552840152815191929160009162000064916003919062000098565b5081516200007a90600490602085019062000098565b506005805460ff191660ff9290921691909117905550620001349050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10620000db57805160ff19168380011785556200010b565b828001600101855582156200010b579182015b828111156200010b578251825591602001919060010190620000ee565b50620001199291506200011d565b5090565b5b808211156200011957600081556001016200011e565b6117c780620001446000396000f3fe608060405234801561001057600080fd5b506004361061014d5760003560e01c806375d26413116100c3578063b3f1c93d1161007c578063b3f1c93d146103d2578063b9a7b6221461040e578063c04a8a1014610416578063c222ec8a14610444578063dd62ed3e146105ed578063f5298aca1461061b5761014d565b806375d264131461038657806395d89b411461038e578063a457c2d7146102e2578063a9059cbb14610396578063b16a19de146103c2578063b1bf962d146103ca5761014d565b806323b872dd1161011557806323b872dd1461028e578063313ce567146102c457806339509351146102e25780636bd76d241461030e57806370a082311461033c5780637535d246146103625761014d565b806306fdde0314610152578063095ea7b3146101cf5780630afbcdc91461020f57806318160ddd1461024e5780631da24f3e14610268575b600080fd5b61015a61064d565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561019457818101518382015260200161017c565b50505050905090810190601f1680156101c15780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101fb600480360360408110156101e557600080fd5b506001600160a01b0381351690602001356106e3565b604080519115158252519081900360200190f35b6102356004803603602081101561022557600080fd5b50356001600160a01b031661072b565b6040805192835260208301919091528051918290030190f35b610256610748565b60408051918252519081900360200190f35b6102566004803603602081101561027e57600080fd5b50356001600160a01b03166107db565b6101fb600480360360608110156102a457600080fd5b506001600160a01b038135811691602081013590911690604001356107ee565b6102cc610836565b6040805160ff9092168252519081900360200190f35b6101fb600480360360408110156102f857600080fd5b506001600160a01b03813516906020013561083f565b6102566004803603604081101561032457600080fd5b506001600160a01b038135811691602001351661088e565b6102566004803603602081101561035257600080fd5b50356001600160a01b03166108bb565b61036a610967565b604080516001600160a01b039092168252519081900360200190f35b61036a610976565b61015a610980565b6101fb600480360360408110156103ac57600080fd5b506001600160a01b0381351690602001356107ee565b61036a6109e1565b6102566109f0565b6101fb600480360360808110156103e857600080fd5b506001600160a01b038135811691602081013590911690604081013590606001356109fa565b610256610c13565b6104426004803603604081101561042c57600080fd5b506001600160a01b038135169060200135610c18565b005b610442600480360360e081101561045a57600080fd5b6001600160a01b038235811692602081013582169260408201359092169160ff606083013516919081019060a0810160808201356401000000008111156104a057600080fd5b8201836020820111156104b257600080fd5b803590602001918460018302840111640100000000831117156104d457600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929594936020810193503591505064010000000081111561052757600080fd5b82018360208201111561053957600080fd5b8035906020019184600183028401116401000000008311171561055b57600080fd5b91908080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525092959493602081019350359150506401000000008111156105ae57600080fd5b8201836020820111156105c057600080fd5b803590602001918460018302840111640100000000831117156105e257600080fd5b509092509050610cb4565b6102566004803603604081101561060357600080fd5b506001600160a01b038135811691602001351661083f565b6104426004803603606081101561063157600080fd5b506001600160a01b038135169060208101359060400135610f03565b60038054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106d95780601f106106ae576101008083540402835291602001916106d9565b820191906000526020600020905b8154815290600101906020018083116106bc57829003601f168201915b5050505050905090565b6040805162461bcd60e51b81526020600482015260166024820152751054141493d5905317d393d517d4d5541413d495115160521b6044820152905160009181900360640190fd5b60008061073783611097565b61073f6110b2565b91509150915091565b603b54603c546040805163386497fd60e01b81526001600160a01b03928316600482015290516000936107d693169163386497fd916024808301926020929190829003018186803b15801561079c57600080fd5b505afa1580156107b0573d6000803e3d6000fd5b505050506040513d60208110156107c657600080fd5b50516107d06110b2565b906110b8565b905090565b60006107e682611097565b90505b919050565b6040805162461bcd60e51b81526020600482015260166024820152751514905394d1915497d393d517d4d5541413d495115160521b6044820152905160009181900360640190fd5b60055460ff1690565b6040805162461bcd60e51b815260206004820152601760248201527f414c4c4f57414e43455f4e4f545f535550504f525445440000000000000000006044820152905160009181900360640190fd5b6001600160a01b038083166000908152603a60209081526040808320938516835292905220545b92915050565b6000806108c783611097565b9050806108d85760009150506107e9565b603b54603c546040805163386497fd60e01b81526001600160a01b039283166004820152905161096093929092169163386497fd91602480820192602092909190829003018186803b15801561092d57600080fd5b505afa158015610941573d6000803e3d6000fd5b505050506040513d602081101561095757600080fd5b505182906110b8565b9392505050565b603b546001600160a01b031690565b60006107d6611176565b60048054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106d95780601f106106ae576101008083540402835291602001916106d9565b603c546001600160a01b031690565b60006107d66110b2565b6000610a04610967565b6001600160a01b0316610a15611185565b6001600160a01b03161460405180604001604052806002815260200161323960f01b81525090610ac35760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610a88578181015183820152602001610a70565b50505050905090810190601f168015610ab55780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50836001600160a01b0316856001600160a01b031614610ae857610ae8848685611189565b6000610af385611097565b90506000610b018585611251565b6040805180820190915260028152611a9b60f11b602082015290915081610b695760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610a88578181015183820152602001610a70565b50610b748682611358565b6040805186815290516001600160a01b038816916000917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a3856001600160a01b0316876001600160a01b03167f2f00e3cdd69a77be7ed215ec7b2a36784dd158f921fca79ac29deffa353fe6ee8787604051808381526020018281526020019250505060405180910390a3501595945050505050565b600181565b80603a6000610c25611185565b6001600160a01b0390811682526020808301939093526040918201600090812091871680825291909352912091909155610c5d611185565b6001600160a01b03167fda919360433220e13b51e8c211e490d148e61a3bd53de8c097194e458b97f3e1610c8f6109e1565b604080516001600160a01b039092168252602082018690528051918290030190a35050565b6000610cbe6114a9565b60075490915060ff1680610cd55750610cd56114ae565b80610ce1575060065481115b610d1c5760405162461bcd60e51b815260040180806020018281038252602e815260200180611743602e913960400191505060405180910390fd5b60075460ff16158015610d3c576007805460ff1916600117905560068290555b610d45866114b4565b610d4e856114cb565b610d57876114de565b603b80546001600160a01b03808d166001600160a01b03199283168117909355603c80548d83169084168117909155603d8054928d169290931682179092556040805191825260ff8b1660208084019190915260a09183018281528b51928401929092528a517f40251fbfb6656cfa65a00d7879029fec1fad21d28fdcff2f4f68f52795b74f2c938e938e938e938e938e938e93919290916060840191608085019160c0860191908a019080838360005b83811015610e20578181015183820152602001610e08565b50505050905090810190601f168015610e4d5780820380516001836020036101000a031916815260200191505b50848103835287518152875160209182019189019080838360005b83811015610e80578181015183820152602001610e68565b50505050905090810190601f168015610ead5780820380516001836020036101000a031916815260200191505b508481038252858152602001868680828437600083820152604051601f909101601f19169092018290039b50909950505050505050505050a38015610ef7576007805460ff191690555b50505050505050505050565b610f0b610967565b6001600160a01b0316610f1c611185565b6001600160a01b03161460405180604001604052806002815260200161323960f01b81525090610f8d5760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610a88578181015183820152602001610a70565b506000610f9a8383611251565b60408051808201909152600281526106a760f31b6020820152909150816110025760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610a88578181015183820152602001610a70565b5061100d84826114f4565b6040805184815290516000916001600160a01b038716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a3604080518481526020810184905281516001600160a01b038716927f49995e5dd6158cf69ad3e9777c46755a1a826a446c6416992167462dad033b2a928290030190a250505050565b6001600160a01b031660009081526020819052604090205490565b60025490565b60008215806110c5575081155b156110d2575060006108b5565b816b019d971e4fe8401e7400000019816110e857fe5b0483111560405180604001604052806002815260200161068760f31b815250906111535760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610a88578181015183820152602001610a70565b50506b033b2e3c9fd0803ce800000091026b019d971e4fe8401e74000000010490565b603d546001600160a01b031690565b3390565b6040805180820182526002815261353960f01b6020808301919091526001600160a01b038087166000908152603a835284812091871681529152918220546111d2918490611592565b6001600160a01b038086166000818152603a60209081526040808320948916808452949091529020839055919250907fda919360433220e13b51e8c211e490d148e61a3bd53de8c097194e458b97f3e161122a6109e1565b604080516001600160a01b039092168252602082018690528051918290030190a350505050565b604080518082019091526002815261035360f41b6020820152600090826112b95760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610a88578181015183820152602001610a70565b5060408051808201909152600280825261068760f31b60208301528304906b033b2e3c9fd0803ce80000008219048511156113355760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610a88578181015183820152602001610a70565b5082816b033b2e3c9fd0803ce80000008602018161134f57fe5b04949350505050565b6001600160a01b0382166113b3576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b6113bf600083836115ec565b6002546113cc81836115f1565b6002556001600160a01b0383166000908152602081905260409020546113f281846115f1565b6001600160a01b038516600090815260208190526040812091909155611416611176565b6001600160a01b0316146114a35761142c611176565b6001600160a01b03166331873e2e8584846040518463ffffffff1660e01b815260040180846001600160a01b031681526020018381526020018281526020019350505050600060405180830381600087803b15801561148a57600080fd5b505af115801561149e573d6000803e3d6000fd5b505050505b50505050565b600190565b303b1590565b80516114c790600390602084019061168d565b5050565b80516114c790600490602084019061168d565b6005805460ff191660ff92909216919091179055565b6001600160a01b0382166115395760405162461bcd60e51b81526004018080602001828103825260218152602001806117716021913960400191505060405180910390fd5b611545826000836115ec565b600254611552818361164b565b6002556001600160a01b0383166000908152602081815260409182902054825160608101909352602280845290926113f292869290611721908301398391905b600081848411156115e45760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610a88578181015183820152602001610a70565b505050900390565b505050565b600082820183811015610960576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b600061096083836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611592565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106116ce57805160ff19168380011785556116fb565b828001600101855582156116fb579182015b828111156116fb5782518255916020019190600101906116e0565b5061170792915061170b565b5090565b5b80821115611707576000815560010161170c56fe45524332303a206275726e20616d6f756e7420657863656564732062616c616e6365436f6e747261637420696e7374616e63652068617320616c7265616479206265656e20696e697469616c697a656445524332303a206275726e2066726f6d20746865207a65726f2061646472657373a26469706673582212201ead4edd76dac0d9ba7c8323839091f018327d3c3c9a8cb30c146a75989199f464736f6c634300060c0033", + "deployedBytecode": "", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/external/abi/aave/v2/lib/GenericLogic.json b/external/abi/aave/v2/lib/GenericLogic.json new file mode 100644 index 000000000..88af8e03d --- /dev/null +++ b/external/abi/aave/v2/lib/GenericLogic.json @@ -0,0 +1,24 @@ +{ + "_format": "hh-sol-artifact-1", + "contractName": "GenericLogic", + "sourceName": "contracts/protocol/libraries/logic/GenericLogic.sol", + "abi": [ + { + "inputs": [], + "name": "HEALTH_FACTOR_LIQUIDATION_THRESHOLD", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "bytecode": "0x610e86610026600b82828239805160001a60731461001957fe5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600436106100405760003560e01c8063c3525c2814610045578063e617042414610063575b600080fd5b61004d610083565b60405161005a9190610e2f565b60405180910390f35b610076610071366004610c58565b61008f565b60405161005a9190610d59565b670de0b6b3a764000081565b60006100a86100a336879003870187610cf0565b6102be565b15806100f057506001600160a01b0389166000908152602087905260409020600701546100ee90600160a01b900460ff166100e836889003880188610cf0565b906102e6565b155b156100fd575060016102b2565b610105610b69565b6001600160a01b038a16600090815260208890526040902061012690610348565b5084525060208301819052151590506101435760019150506102b2565b61015f8988610157368a90038a018a610cf0565b888888610373565b506080850152506060830181905260408301919091526101835760019150506102b2565b61021a8160000151600a0a6102148a866001600160a01b031663b3596f078f6040518263ffffffff1660e01b81526004016101be9190610d45565b60206040518083038186803b1580156101d657600080fd5b505afa1580156101ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061020e9190610d2d565b90610834565b90610875565b60a08201819052604082015161022f916108b7565b60c082018190526102445760009150506102b2565b6102838160c0015161021461026a84602001518560a0015161083490919063ffffffff16565b6080850151604086015161027d91610834565b906108b7565b60e0820181905260c082015160608301516000926102a29291906108f9565b670de0b6b3a76400001115925050505b98975050505050505050565b517f555555555555555555555555555555555555555555555555555555555555555516151590565b60006080821060405180604001604052806002815260200161373760f01b8152509061032e5760405162461bcd60e51b81526004016103259190610d64565b60405180910390fd5b5050815160016002830281019190911c1615155b92915050565b5461ffff80821692601083901c821692602081901c831692603082901c60ff169260409290921c1690565b6000806000806000610383610bbe565b61038c8a610925565b156103aa576000806000806000199550955095509550955050610826565b600060e08201525b878160e0015110156107855760e08101516103ce908b9061092a565b6103d757610775565b60e0810151600090815260208a81526040808320546001600160a01b03166101e085018190528352908d9052902061040e81610348565b506080860181905260c08601929092525060a0840191909152600a0a60208301526101e082015160405163b3596f0760e01b81526001600160a01b038a169163b3596f07916104609190600401610d45565b60206040518083038186803b15801561047857600080fd5b505afa15801561048c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104b09190610d2d565b825260c0820151158015906104d0575060e08201516104d0908c906102e6565b156105ee578060040160009054906101000a90046001600160a01b03166001600160a01b03166370a082318e6040518263ffffffff1660e01b81526004016105189190610d45565b60206040518083038186803b15801561053057600080fd5b505afa158015610544573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105689190610d2d565b6040830181905260208301518351600092610587929161021491610834565b61012084015190915061059a908261097b565b61012084015260a08301516105c0906105b4908390610834565b6101608501519061097b565b61016084015260c08301516105e6906105da908390610834565b6101808501519061097b565b610180840152505b60e08201516105fe908c906109a0565b15610773578060050160009054906101000a90046001600160a01b03166001600160a01b03166370a082318e6040518263ffffffff1660e01b81526004016106469190610d45565b60206040518083038186803b15801561065e57600080fd5b505afa158015610672573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106969190610d2d565b8260600181815250506107408160060160009054906101000a90046001600160a01b03166001600160a01b03166370a082318f6040518263ffffffff1660e01b81526004016106e59190610d45565b60206040518083038186803b1580156106fd57600080fd5b505afa158015610711573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107359190610d2d565b60608401519061097b565b606083018190526020830151835161076c92610760929161021491610834565b6101408401519061097b565b6101408301525b505b60e08101805160010190526103b2565b6000816101200151116107995760006107ae565b6101208101516101608201516107ae91610875565b6101608201526101208101516107c55760006107da565b6101208101516101808201516107da91610875565b61018082018190526101208201516101408301516107f7926108f9565b610100820181905261012082015161014083015161016084015161018090940151919850965091945090925090505b965096509650965096915050565b60008261084357506000610342565b8282028284828161085057fe5b041461086e5760405162461bcd60e51b815260040161032590610dee565b9392505050565b600061086e83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506109f1565b600061086e83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610a28565b600082610909575060001961086e565b61091d836109178685610a54565b90610ac6565b949350505050565b511590565b60006080821060405180604001604052806002815260200161373760f01b815250906109695760405162461bcd60e51b81526004016103259190610d64565b50509051600360029092021c16151590565b60008282018381101561086e5760405162461bcd60e51b815260040161032590610db7565b60006080821060405180604001604052806002815260200161373760f01b815250906109df5760405162461bcd60e51b81526004016103259190610d64565b50509051600160029092021c16151590565b60008183610a125760405162461bcd60e51b81526004016103259190610d64565b506000838581610a1e57fe5b0495945050505050565b60008184841115610a4c5760405162461bcd60e51b81526004016103259190610d64565b505050900390565b6000821580610a61575081155b15610a6e57506000610342565b816113881981610a7a57fe5b0483111560405180604001604052806002815260200161068760f31b81525090610ab75760405162461bcd60e51b81526004016103259190610d64565b50506127109102611388010490565b604080518082019091526002815261035360f41b602082015260009082610b005760405162461bcd60e51b81526004016103259190610d64565b5060408051808201909152600280825261068760f31b6020830152830490670de0b6b3a7640000821904851115610b4a5760405162461bcd60e51b81526004016103259190610d64565b508281670de0b6b3a764000086020181610b6057fe5b04949350505050565b6040518061014001604052806000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000151581525090565b604051806102400160405280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160001515815260200160006001600160a01b031681526020016000151581526020016000151581525090565b600080600080600080600080888a03610100811215610c75578485fd5b8935610c8081610e38565b985060208a0135610c9081610e38565b975060408a0135965060608a013595506020607f1982011215610cb1578485fd5b5060808901935060a0890135925060c0890135915060e08901356001600160a01b0381168114610cdf578182fd5b809150509295985092959890939650565b600060208284031215610d01578081fd5b6040516020810181811067ffffffffffffffff82111715610d20578283fd5b6040529135825250919050565b600060208284031215610d3e578081fd5b5051919050565b6001600160a01b0391909116815260200190565b901515815260200190565b6000602080835283518082850152825b81811015610d9057858101830151858201604001528201610d74565b81811115610da15783604083870101525b50601f01601f1916929092016040019392505050565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b90815260200190565b6001600160a01b0381168114610e4d57600080fd5b5056fea2646970667358221220a4af94f099a5b1db1f8e2910761db06ad9d0e3506746c8a745d78081a9dba6ca64736f6c634300060c0033", + "deployedBytecode": "", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/external/abi/aave/v2/lib/ReserveLogic.json b/external/abi/aave/v2/lib/ReserveLogic.json new file mode 100644 index 000000000..1d06e28e3 --- /dev/null +++ b/external/abi/aave/v2/lib/ReserveLogic.json @@ -0,0 +1,52 @@ +{ + "contractName": "ReserveLogic", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "liquidityRate", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "stableBorrowRate", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "variableBorrowRate", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "liquidityIndex", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "variableBorrowIndex", + "type": "uint256" + } + ], + "name": "ReserveDataUpdated", + "type": "event" + } + ], + "bytecode": "0x61023b610026600b82828239805160001a60731461001957fe5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600436106100355760003560e01c80632b33897c1461003a575b600080fd5b81801561004657600080fd5b5061008b600480360360a081101561005d57600080fd5b508035906001600160a01b03602082013581169160408101358216916060820135811691608001351661008d565b005b6004850154604080518082019091526002815261199960f11b6020820152906001600160a01b03161561013e5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156101035781810151838201526020016100eb565b50505050905090810190601f1680156101305780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506101476101f5565b6001860180546fffffffffffffffffffffffffffffffff19166001600160801b039290921691909117905561017a6101f5565b6001860180546001600160801b03928316600160801b0292169190911790556004850180546001600160a01b039586166001600160a01b031991821617909155600586018054948616948216949094179093556006850180549285169284169290921790915560079093018054939092169216919091179055565b6b033b2e3c9fd0803ce80000009056fea26469706673582212201b1077f3227f32c52fc74f11467fd6c922fa3d2d3c875a9e955c7dd17644dbf764736f6c634300060c0033", + "deployedBytecode": "", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/external/abi/aave/v2/lib/ValidationLogic.json b/external/abi/aave/v2/lib/ValidationLogic.json new file mode 100644 index 000000000..b3a5edf03 --- /dev/null +++ b/external/abi/aave/v2/lib/ValidationLogic.json @@ -0,0 +1,35 @@ +{ + "contractName": "ValidationLogic", + "abi": [ + { + "inputs": [], + "name": "REBALANCE_UP_LIQUIDITY_RATE_THRESHOLD", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "REBALANCE_UP_USAGE_RATIO_THRESHOLD", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "bytecode": "0x612055610026600b82828239805160001a60731461001957fe5b30600052607381538281f3fe730000000000000000000000000000000000000000301460806040526004361061009d5760003560e01c8063721a92f911610070578063721a92f9146100fb578063a8695b1d1461010e578063abfcc86a14610121578063d09db04a14610129578063fa0c21491461013c5761009d565b80630eca322b146100a2578063548cad09146100b75780635494eb8a146100ca5780635fa297e5146100e8575b600080fd5b6100b56100b0366004611e2b565b61014f565b005b6100b56100c5366004611d86565b610217565b6100d261050d565b6040516100df9190611fe3565b60405180910390f35b6100b56100f6366004611d1c565b61051d565b6100b5610109366004611bea565b6106c2565b6100b561011c366004611ded565b610b8a565b6100d2610e23565b6100b5610137366004611c8e565b610e29565b6100b561014a366004611e4c565b610fc7565b60008061015b8461110d565b50506040805180820190915260018152603160f81b60208201529193509150836101a15760405162461bcd60e51b81526004016101989190611f18565b60405180910390fd5b506040805180820190915260018152601960f91b6020820152826101d85760405162461bcd60e51b81526004016101989190611f18565b506040805180820190915260018152603360f81b602082015281156102105760405162461bcd60e51b81526004016101989190611f18565b5050505050565b60006102228661110d565b505050905080604051806040016040528060018152602001601960f91b815250906102605760405162461bcd60e51b81526004016101989190611f18565b506000610356610351856001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b1580156102a257600080fd5b505afa1580156102b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102da9190611ea7565b876001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561031357600080fd5b505afa158015610327573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061034b9190611ea7565b90611145565b611173565b905060006103d9876001600160a01b03166370a08231866040518263ffffffff1660e01b81526004016103899190611ebf565b60206040518083038186803b1580156103a157600080fd5b505afa1580156103b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103519190611ea7565b9050600082156103fc576103f76103f08385611145565b84906111c3565b6103ff565b60005b60028a015460078b0154604080516380031e3760e01b815290519394506fffffffffffffffffffffffffffffffff909216926000926001600160a01b03909216916380031e37916004808301926020929190829003018186803b15801561046557600080fd5b505afa158015610479573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061049d9190611ea7565b90506b0311d253316c79d37600000083101580156104c657506104c281610fa061126e565b8211155b60405180604001604052806002815260200161191960f11b815250906104ff5760405162461bcd60e51b81526004016101989190611f18565b505050505050505050505050565b6b0311d253316c79d37600000081565b6004808901546040516370a0823160e01b81526000926001600160a01b03909216916370a082319161055191339101611ebf565b60206040518083038186803b15801561056957600080fd5b505afa15801561057d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105a19190611ea7565b90506000811160405180604001604052806002815260200161313960f01b815250906105e05760405162461bcd60e51b81526004016101989190611f18565b50868061067d5750604051633985c10960e21b815273__$52a8a86ab43135662ff256bbc95497e8e3$__9063e61704249061062d908b90339086908c908c908c908c908c90600401611ed3565b60206040518083038186803b15801561064557600080fd5b505af4158015610659573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061067d9190611d00565b60405180604001604052806002815260200161032360f41b815250906106b65760405162461bcd60e51b81526004016101989190611f18565b50505050505050505050565b6106ca611aee565b6106d38c61110d565b151561014085015215156101208401521515610100830152151560e082018190526040805180820190915260018152601960f91b60208201529061072a5760405162461bcd60e51b81526004016101989190611f18565b5080610100015115604051806040016040528060018152602001603360f81b8152509061076a5760405162461bcd60e51b81526004016101989190611f18565b506040805180820190915260018152603160f81b60208201528a6107a15760405162461bcd60e51b81526004016101989190611f18565b50806101200151604051806040016040528060018152602001603760f81b815250906107e05760405162461bcd60e51b81526004016101989190611f18565b5087600214806107f05750876001145b604051806040016040528060018152602001600760fb1b815250906108285760405162461bcd60e51b81526004016101989190611f18565b50604080516020810190915285548152610848908c9088908787876112e0565b60c08601526020808601919091529084526080840191909152606083018290526040805180820190915260018152603960f81b91810191909152906108a05760405162461bcd60e51b81526004016101989190611f18565b50670de0b6b3a76400008160c001511160405180604001604052806002815260200161031360f41b815250906108e95760405162461bcd60e51b81526004016101989190611f18565b50805160808201516109069190610900908c611145565b906117a7565b6040808301829052606083015181518083019092526002825261313160f01b60208301529091111561094b5760405162461bcd60e51b81526004016101989190611f18565b506001881415610b7b5780610140015160405180604001604052806002815260200161189960f11b815250906109945760405162461bcd60e51b81526004016101989190611f18565b5060078c01546040805160208101909152865481526109bc91600160a01b900460ff16611835565b15806109ce57506109cc8c61188d565b155b80610a5857506004808d01546040516370a0823160e01b81526001600160a01b03909116916370a0823191610a05918f9101611ebf565b60206040518083038186803b158015610a1d57600080fd5b505afa158015610a31573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a559190611ea7565b8a115b60405180604001604052806002815260200161313360f01b81525090610a915760405162461bcd60e51b81526004016101989190611f18565b508c6001600160a01b03166370a082318d60040160009054906101000a90046001600160a01b03166040518263ffffffff1660e01b8152600401610ad59190611ebf565b60206040518083038186803b158015610aed57600080fd5b505afa158015610b01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b259190611ea7565b60a08201819052600090610b39908961126e565b9050808b1115604051806040016040528060028152602001610c4d60f21b81525090610b785760405162461bcd60e51b81526004016101989190611f18565b50505b50505050505050505050505050565b60008080610b978861110d565b9350509250925082604051806040016040528060018152602001601960f91b81525090610bd75760405162461bcd60e51b81526004016101989190611f18565b506040805180820190915260018152603360f81b60208201528215610c0f5760405162461bcd60e51b81526004016101989190611f18565b506001846002811115610c1e57fe5b1415610c6157604080518082019091526002815261313760f01b602082015286610c5b5760405162461bcd60e51b81526004016101989190611f18565b50610e19565b6002846002811115610c6f57fe5b1415610dea57604080518082019091526002815261062760f31b602082015285610cac5760405162461bcd60e51b81526004016101989190611f18565b50604080518082019091526002815261189960f11b602082015281610ce45760405162461bcd60e51b81526004016101989190611f18565b506007880154604080516020810190915288548152610d0c91600160a01b900460ff16611835565b1580610d1e5750610d1c8861188d565b155b80610db157506004808901546040516370a0823160e01b81526001600160a01b03909116916370a0823191610d5591339101611ebf565b60206040518083038186803b158015610d6d57600080fd5b505afa158015610d81573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610da59190611ea7565b610daf8787611145565b115b60405180604001604052806002815260200161313360f01b81525090610c5b5760405162461bcd60e51b81526004016101989190611f18565b60408051808201825260018152600760fb1b6020820152905162461bcd60e51b81526101989190600401611f18565b5050505050505050565b610fa081565b6040805180820190915260018152603160f81b602082015287610e5f5760405162461bcd60e51b81526004016101989190611f18565b506040805180820190915260018152603560f81b602082015286881115610e995760405162461bcd60e51b81526004016101989190611f18565b506001600160a01b0388166000908152602086905260408120610ebb9061110d565b505050905080604051806040016040528060018152602001601960f91b81525090610ef95760405162461bcd60e51b81526004016101989190611f18565b50604051633985c10960e21b815273__$52a8a86ab43135662ff256bbc95497e8e3$__9063e617042490610f3f908c9033908d908c908c908c908c908c90600401611ed3565b60206040518083038186803b158015610f5757600080fd5b505af4158015610f6b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f8f9190611d00565b604051806040016040528060018152602001601b60f91b815250906106b65760405162461bcd60e51b81526004016101989190611f18565b6000610fd287611895565b905080604051806040016040528060018152602001601960f91b8152509061100d5760405162461bcd60e51b81526004016101989190611f18565b506040805180820190915260018152603160f81b6020820152866110445760405162461bcd60e51b81526004016101989190611f18565b506000831180156110605750600185600281111561105e57fe5b145b8061108157506000821180156110815750600285600281111561107f57fe5b145b60405180604001604052806002815260200161313560f01b815250906110ba5760405162461bcd60e51b81526004016101989190611f18565b50600019861415806110d45750336001600160a01b038516145b60405180604001604052806002815260200161189b60f11b81525090610e195760405162461bcd60e51b81526004016101989190611f18565b54600160381b811615159167020000000000000082161515916704000000000000008116151591670800000000000000909116151590565b60008282018381101561116a5760405162461bcd60e51b815260040161019890611f6b565b90505b92915050565b6000633b9aca0082810290839082041460405180604001604052806002815260200161068760f31b815250906111bc5760405162461bcd60e51b81526004016101989190611f18565b5092915050565b604080518082019091526002815261035360f41b6020820152600090826111fd5760405162461bcd60e51b81526004016101989190611f18565b5060408051808201909152600280825261068760f31b60208301528304906b033b2e3c9fd0803ce800000082190485111561124b5760405162461bcd60e51b81526004016101989190611f18565b5082816b033b2e3c9fd0803ce80000008602018161126557fe5b04949350505050565b600082158061127b575081155b156112885750600061116d565b81611388198161129457fe5b0483111560405180604001604052806002815260200161068760f31b815250906112d15760405162461bcd60e51b81526004016101989190611f18565b50506127109102611388010490565b60008060008060006112f0611b50565b6112f98a6118a1565b15611317576000806000806000199550955095509550955050611799565b600060e08201525b878160e0015110156116f85760e081015161133b908b906118a6565b611344576116e8565b60e0810151600090815260208a81526040808320546001600160a01b03166101e085018190528352908d9052902061137b816118f7565b506080860181905260c08601929092525060a0840191909152600a0a60208301526101e082015160405163b3596f0760e01b81526001600160a01b038a169163b3596f07916113cd9190600401611ebf565b60206040518083038186803b1580156113e557600080fd5b505afa1580156113f9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061141d9190611ea7565b825260c08201511580159061143d575060e082015161143d908c90611835565b15611561578060040160009054906101000a90046001600160a01b03166001600160a01b03166370a082318e6040518263ffffffff1660e01b81526004016114859190611ebf565b60206040518083038186803b15801561149d57600080fd5b505afa1580156114b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114d59190611ea7565b60408301819052602083015183516000926114fa92916114f491611922565b9061195c565b61012084015190915061150d9082611145565b61012084015260a083015161153390611527908390611922565b61016085015190611145565b61016084015260c08301516115599061154d908390611922565b61018085015190611145565b610180840152505b60e0820151611571908c9061199e565b156116e6578060050160009054906101000a90046001600160a01b03166001600160a01b03166370a082318e6040518263ffffffff1660e01b81526004016115b99190611ebf565b60206040518083038186803b1580156115d157600080fd5b505afa1580156115e5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116099190611ea7565b8260600181815250506116b38160060160009054906101000a90046001600160a01b03166001600160a01b03166370a082318f6040518263ffffffff1660e01b81526004016116589190611ebf565b60206040518083038186803b15801561167057600080fd5b505afa158015611684573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116a89190611ea7565b606084015190611145565b60608301819052602083015183516116df926116d392916114f491611922565b61014084015190611145565b6101408301525b505b60e081018051600101905261131f565b60008161012001511161170c576000611721565b6101208101516101608201516117219161195c565b61016082015261012081015161173857600061174d565b61012081015161018082015161174d9161195c565b610180820181905261012082015161014083015161176a926119ef565b610100820181905261012082015161014083015161016084015161018090940151919850965091945090925090505b965096509650965096915050565b604080518082019091526002815261035360f41b6020820152600090826117e15760405162461bcd60e51b81526004016101989190611f18565b5060408051808201909152600280825261068760f31b60208301528304906127108219048511156118255760405162461bcd60e51b81526004016101989190611f18565b5082816127108602018161126557fe5b60006080821060405180604001604052806002815260200161373760f01b815250906118745760405162461bcd60e51b81526004016101989190611f18565b5050815160016002830281019190911c16151592915050565b5461ffff1690565b54600160381b16151590565b511590565b60006080821060405180604001604052806002815260200161373760f01b815250906118e55760405162461bcd60e51b81526004016101989190611f18565b50509051600360029092021c16151590565b5461ffff80821692601083901c821692602081901c831692603082901c60ff169260409290921c1690565b6000826119315750600061116d565b8282028284828161193e57fe5b041461116a5760405162461bcd60e51b815260040161019890611fa2565b600061116a83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611a1d565b60006080821060405180604001604052806002815260200161373760f01b815250906119dd5760405162461bcd60e51b81526004016101989190611f18565b50509051600160029092021c16151590565b6000826119ff5750600019611a16565b611a1383611a0d868561126e565b90611a54565b90505b9392505050565b60008183611a3e5760405162461bcd60e51b81526004016101989190611f18565b506000838581611a4a57fe5b0495945050505050565b604080518082019091526002815261035360f41b602082015260009082611a8e5760405162461bcd60e51b81526004016101989190611f18565b5060408051808201909152600280825261068760f31b6020830152830490670de0b6b3a7640000821904851115611ad85760405162461bcd60e51b81526004016101989190611f18565b508281670de0b6b3a76400008602018161126557fe5b604051806101600160405280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000151581526020016000151581526020016000151581526020016000151581525090565b604051806102400160405280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160001515815260200160006001600160a01b031681526020016000151581526020016000151581525090565b6000806000806000806000806000806000806101808d8f031215611c0c578788fd5b8c35611c1781611fec565b9b5060208d01359a5060408d0135611c2e81611fec565b995060608d0135985060808d0135975060a08d0135965060c08d0135955060e08d013594506101008d013593506101208d013592506101408d013591506101608d0135611c7a81611fec565b809150509295989b509295989b509295989b565b600080600080600080600080610100898b031215611caa578384fd5b8835611cb581611fec565b97506020890135965060408901359550606089013594506080890135935060a0890135925060c0890135915060e0890135611cef81611fec565b809150509295985092959890939650565b600060208284031215611d11578081fd5b815161116a81612004565b600080600080600080600080610100898b031215611d38578384fd5b883597506020890135611d4a81611fec565b96506040890135611d5a81612004565b9550606089013594506080890135935060a0890135925060c0890135915060e0890135611cef81611fec565b600080600080600060a08688031215611d9d578081fd5b853594506020860135611daf81611fec565b93506040860135611dbf81611fec565b92506060860135611dcf81611fec565b91506080860135611ddf81611fec565b809150509295509295909350565b600080600080600060a08688031215611e04578081fd5b853594506020860135935060408601359250606086013591506080860135611ddf81612012565b60008060408385031215611e3d578182fd5b50508035926020909101359150565b60008060008060008060c08789031215611e64578384fd5b86359550602087013594506040870135611e7d81612012565b93506060870135611e8d81611fec565b9598949750929560808101359460a0909101359350915050565b600060208284031215611eb8578081fd5b5051919050565b6001600160a01b0391909116815260200190565b6001600160a01b0398891681529688166020880152604087019590955260608601939093529054608085015260a084015260c083015290911660e08201526101000190565b6000602080835283518082850152825b81811015611f4457858101830151858201604001528201611f28565b81811115611f555783604083870101525b50601f01601f1916929092016040019392505050565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b90815260200190565b6001600160a01b038116811461200157600080fd5b50565b801515811461200157600080fd5b6003811061200157600080fdfea2646970667358221220c68354959a441e754f2640662c1153069b1ea45a624ce497d2886e773f6f336a64736f6c634300060c0033", + "deployedBytecode": "", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/external/contracts/aave/v2/AaveV2AToken.sol b/external/contracts/aave/v2/AaveV2AToken.sol new file mode 100644 index 000000000..9bd156ca2 --- /dev/null +++ b/external/contracts/aave/v2/AaveV2AToken.sol @@ -0,0 +1,406 @@ +// SPDX-License-Identifier: agpl-3.0 +pragma solidity 0.6.12; + +import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol'; +import {SafeERC20} from '../../dependencies/openzeppelin/contracts/SafeERC20.sol'; +import {ILendingPool} from '../../interfaces/ILendingPool.sol'; +import {IAToken} from '../../interfaces/IAToken.sol'; +import {WadRayMath} from '../libraries/math/WadRayMath.sol'; +import {Errors} from '../libraries/helpers/Errors.sol'; +import {VersionedInitializable} from '../libraries/aave-upgradeability/VersionedInitializable.sol'; +import {IncentivizedERC20} from './IncentivizedERC20.sol'; +import {IAaveIncentivesController} from '../../interfaces/IAaveIncentivesController.sol'; + +/** + * @title Aave ERC20 AToken + * @dev Implementation of the interest bearing token for the Aave protocol + * @author Aave + */ +contract AaveV2AToken is + VersionedInitializable, + IncentivizedERC20('ATOKEN_IMPL', 'ATOKEN_IMPL', 0), + IAToken +{ + using WadRayMath for uint256; + using SafeERC20 for IERC20; + + bytes public constant EIP712_REVISION = bytes('1'); + bytes32 internal constant EIP712_DOMAIN = + keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'); + bytes32 public constant PERMIT_TYPEHASH = + keccak256('Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)'); + + uint256 public constant ATOKEN_REVISION = 0x1; + + /// @dev owner => next valid nonce to submit with permit() + mapping(address => uint256) public _nonces; + + bytes32 public DOMAIN_SEPARATOR; + + ILendingPool internal _pool; + address internal _treasury; + address internal _underlyingAsset; + IAaveIncentivesController internal _incentivesController; + + modifier onlyLendingPool { + require(_msgSender() == address(_pool), Errors.CT_CALLER_MUST_BE_LENDING_POOL); + _; + } + + function getRevision() internal pure virtual override returns (uint256) { + return ATOKEN_REVISION; + } + + /** + * @dev Initializes the aToken + * @param pool The address of the lending pool where this aToken will be used + * @param treasury The address of the Aave treasury, receiving the fees on this aToken + * @param underlyingAsset The address of the underlying asset of this aToken (E.g. WETH for aWETH) + * @param incentivesController The smart contract managing potential incentives distribution + * @param aTokenDecimals The decimals of the aToken, same as the underlying asset's + * @param aTokenName The name of the aToken + * @param aTokenSymbol The symbol of the aToken + */ + function initialize( + ILendingPool pool, + address treasury, + address underlyingAsset, + IAaveIncentivesController incentivesController, + uint8 aTokenDecimals, + string calldata aTokenName, + string calldata aTokenSymbol, + bytes calldata params + ) external override initializer { + uint256 chainId; + + //solium-disable-next-line + assembly { + chainId := chainid() + } + + DOMAIN_SEPARATOR = keccak256( + abi.encode( + EIP712_DOMAIN, + keccak256(bytes(aTokenName)), + keccak256(EIP712_REVISION), + chainId, + address(this) + ) + ); + + _setName(aTokenName); + _setSymbol(aTokenSymbol); + _setDecimals(aTokenDecimals); + + _pool = pool; + _treasury = treasury; + _underlyingAsset = underlyingAsset; + _incentivesController = incentivesController; + + emit Initialized( + underlyingAsset, + address(pool), + treasury, + address(incentivesController), + aTokenDecimals, + aTokenName, + aTokenSymbol, + params + ); + } + + /** + * @dev Burns aTokens from `user` and sends the equivalent amount of underlying to `receiverOfUnderlying` + * - Only callable by the LendingPool, as extra state updates there need to be managed + * @param user The owner of the aTokens, getting them burned + * @param receiverOfUnderlying The address that will receive the underlying + * @param amount The amount being burned + * @param index The new liquidity index of the reserve + **/ + function burn( + address user, + address receiverOfUnderlying, + uint256 amount, + uint256 index + ) external override onlyLendingPool { + uint256 amountScaled = amount.rayDiv(index); + require(amountScaled != 0, Errors.CT_INVALID_BURN_AMOUNT); + _burn(user, amountScaled); + + IERC20(_underlyingAsset).safeTransfer(receiverOfUnderlying, amount); + + emit Transfer(user, address(0), amount); + emit Burn(user, receiverOfUnderlying, amount, index); + } + + /** + * @dev Mints `amount` aTokens to `user` + * - Only callable by the LendingPool, as extra state updates there need to be managed + * @param user The address receiving the minted tokens + * @param amount The amount of tokens getting minted + * @param index The new liquidity index of the reserve + * @return `true` if the the previous balance of the user was 0 + */ + function mint( + address user, + uint256 amount, + uint256 index + ) external override onlyLendingPool returns (bool) { + uint256 previousBalance = super.balanceOf(user); + + uint256 amountScaled = amount.rayDiv(index); + require(amountScaled != 0, Errors.CT_INVALID_MINT_AMOUNT); + _mint(user, amountScaled); + + emit Transfer(address(0), user, amount); + emit Mint(user, amount, index); + + return previousBalance == 0; + } + + /** + * @dev Mints aTokens to the reserve treasury + * - Only callable by the LendingPool + * @param amount The amount of tokens getting minted + * @param index The new liquidity index of the reserve + */ + function mintToTreasury(uint256 amount, uint256 index) external override onlyLendingPool { + if (amount == 0) { + return; + } + + address treasury = _treasury; + + // Compared to the normal mint, we don't check for rounding errors. + // The amount to mint can easily be very small since it is a fraction of the interest ccrued. + // In that case, the treasury will experience a (very small) loss, but it + // wont cause potentially valid transactions to fail. + _mint(treasury, amount.rayDiv(index)); + + emit Transfer(address(0), treasury, amount); + emit Mint(treasury, amount, index); + } + + /** + * @dev Transfers aTokens in the event of a borrow being liquidated, in case the liquidators reclaims the aToken + * - Only callable by the LendingPool + * @param from The address getting liquidated, current owner of the aTokens + * @param to The recipient + * @param value The amount of tokens getting transferred + **/ + function transferOnLiquidation( + address from, + address to, + uint256 value + ) external override onlyLendingPool { + // Being a normal transfer, the Transfer() and BalanceTransfer() are emitted + // so no need to emit a specific event here + _transfer(from, to, value, false); + + emit Transfer(from, to, value); + } + + /** + * @dev Calculates the balance of the user: principal balance + interest generated by the principal + * @param user The user whose balance is calculated + * @return The balance of the user + **/ + function balanceOf(address user) + public + view + override(IncentivizedERC20, IERC20) + returns (uint256) + { + return super.balanceOf(user).rayMul(_pool.getReserveNormalizedIncome(_underlyingAsset)); + } + + /** + * @dev Returns the scaled balance of the user. The scaled balance is the sum of all the + * updated stored balance divided by the reserve's liquidity index at the moment of the update + * @param user The user whose balance is calculated + * @return The scaled balance of the user + **/ + function scaledBalanceOf(address user) external view override returns (uint256) { + return super.balanceOf(user); + } + + /** + * @dev Returns the scaled balance of the user and the scaled total supply. + * @param user The address of the user + * @return The scaled balance of the user + * @return The scaled balance and the scaled total supply + **/ + function getScaledUserBalanceAndSupply(address user) + external + view + override + returns (uint256, uint256) + { + return (super.balanceOf(user), super.totalSupply()); + } + + /** + * @dev calculates the total supply of the specific aToken + * since the balance of every single user increases over time, the total supply + * does that too. + * @return the current total supply + **/ + function totalSupply() public view override(IncentivizedERC20, IERC20) returns (uint256) { + uint256 currentSupplyScaled = super.totalSupply(); + + if (currentSupplyScaled == 0) { + return 0; + } + + return currentSupplyScaled.rayMul(_pool.getReserveNormalizedIncome(_underlyingAsset)); + } + + /** + * @dev Returns the scaled total supply of the variable debt token. Represents sum(debt/index) + * @return the scaled total supply + **/ + function scaledTotalSupply() public view virtual override returns (uint256) { + return super.totalSupply(); + } + + /** + * @dev Returns the address of the Aave treasury, receiving the fees on this aToken + **/ + function RESERVE_TREASURY_ADDRESS() public view returns (address) { + return _treasury; + } + + /** + * @dev Returns the address of the underlying asset of this aToken (E.g. WETH for aWETH) + **/ + function UNDERLYING_ASSET_ADDRESS() public override view returns (address) { + return _underlyingAsset; + } + + /** + * @dev Returns the address of the lending pool where this aToken is used + **/ + function POOL() public view returns (ILendingPool) { + return _pool; + } + + /** + * @dev For internal usage in the logic of the parent contract IncentivizedERC20 + **/ + function _getIncentivesController() internal view override returns (IAaveIncentivesController) { + return _incentivesController; + } + + /** + * @dev Returns the address of the incentives controller contract + **/ + function getIncentivesController() external view override returns (IAaveIncentivesController) { + return _getIncentivesController(); + } + + /** + * @dev Transfers the underlying asset to `target`. Used by the LendingPool to transfer + * assets in borrow(), withdraw() and flashLoan() + * @param target The recipient of the aTokens + * @param amount The amount getting transferred + * @return The amount transferred + **/ + function transferUnderlyingTo(address target, uint256 amount) + external + override + onlyLendingPool + returns (uint256) + { + IERC20(_underlyingAsset).safeTransfer(target, amount); + return amount; + } + + /** + * @dev Invoked to execute actions on the aToken side after a repayment. + * @param user The user executing the repayment + * @param amount The amount getting repaid + **/ + function handleRepayment(address user, uint256 amount) external override onlyLendingPool {} + + /** + * @dev implements the permit function as for + * https://github.com/ethereum/EIPs/blob/8a34d644aacf0f9f8f00815307fd7dd5da07655f/EIPS/eip-2612.md + * @param owner The owner of the funds + * @param spender The spender + * @param value The amount + * @param deadline The deadline timestamp, type(uint256).max for max deadline + * @param v Signature param + * @param s Signature param + * @param r Signature param + */ + function permit( + address owner, + address spender, + uint256 value, + uint256 deadline, + uint8 v, + bytes32 r, + bytes32 s + ) external { + require(owner != address(0), 'INVALID_OWNER'); + //solium-disable-next-line + require(block.timestamp <= deadline, 'INVALID_EXPIRATION'); + uint256 currentValidNonce = _nonces[owner]; + bytes32 digest = + keccak256( + abi.encodePacked( + '\x19\x01', + DOMAIN_SEPARATOR, + keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, currentValidNonce, deadline)) + ) + ); + require(owner == ecrecover(digest, v, r, s), 'INVALID_SIGNATURE'); + _nonces[owner] = currentValidNonce.add(1); + _approve(owner, spender, value); + } + + /** + * @dev Transfers the aTokens between two users. Validates the transfer + * (ie checks for valid HF after the transfer) if required + * @param from The source address + * @param to The destination address + * @param amount The amount getting transferred + * @param validate `true` if the transfer needs to be validated + **/ + function _transfer( + address from, + address to, + uint256 amount, + bool validate + ) internal { + address underlyingAsset = _underlyingAsset; + ILendingPool pool = _pool; + + uint256 index = pool.getReserveNormalizedIncome(underlyingAsset); + + uint256 fromBalanceBefore = super.balanceOf(from).rayMul(index); + uint256 toBalanceBefore = super.balanceOf(to).rayMul(index); + + super._transfer(from, to, amount.rayDiv(index)); + + if (validate) { + pool.finalizeTransfer(underlyingAsset, from, to, amount, fromBalanceBefore, toBalanceBefore); + } + + emit BalanceTransfer(from, to, amount, index); + } + + /** + * @dev Overrides the parent _transfer to force validated transfer() and transferFrom() + * @param from The source address + * @param to The destination address + * @param amount The amount getting transferred + **/ + function _transfer( + address from, + address to, + uint256 amount + ) internal override { + _transfer(from, to, amount, true); + } +} diff --git a/external/contracts/aave/v2/AaveV2DefaultReserveInterestRateStrategy.sol b/external/contracts/aave/v2/AaveV2DefaultReserveInterestRateStrategy.sol new file mode 100644 index 000000000..7b321d0c1 --- /dev/null +++ b/external/contracts/aave/v2/AaveV2DefaultReserveInterestRateStrategy.sol @@ -0,0 +1,260 @@ +// SPDX-License-Identifier: agpl-3.0 +pragma solidity 0.6.12; + +import {SafeMath} from '../../dependencies/openzeppelin/contracts/SafeMath.sol'; +import {IReserveInterestRateStrategy} from '../../interfaces/IReserveInterestRateStrategy.sol'; +import {WadRayMath} from '../libraries/math/WadRayMath.sol'; +import {PercentageMath} from '../libraries/math/PercentageMath.sol'; +import {ILendingPoolAddressesProvider} from '../../interfaces/ILendingPoolAddressesProvider.sol'; +import {ILendingRateOracle} from '../../interfaces/ILendingRateOracle.sol'; +import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol'; + +/** + * @title DefaultReserveInterestRateStrategy contract + * @notice Implements the calculation of the interest rates depending on the reserve state + * @dev The model of interest rate is based on 2 slopes, one before the `OPTIMAL_UTILIZATION_RATE` + * point of utilization and another from that one to 100% + * - An instance of this same contract, can't be used across different Aave markets, due to the caching + * of the LendingPoolAddressesProvider + * @author Aave + **/ +contract DefaultReserveInterestRateStrategy is IReserveInterestRateStrategy { + using WadRayMath for uint256; + using SafeMath for uint256; + using PercentageMath for uint256; + + /** + * @dev this constant represents the utilization rate at which the pool aims to obtain most competitive borrow rates. + * Expressed in ray + **/ + uint256 public immutable OPTIMAL_UTILIZATION_RATE; + + /** + * @dev This constant represents the excess utilization rate above the optimal. It's always equal to + * 1-optimal utilization rate. Added as a constant here for gas optimizations. + * Expressed in ray + **/ + + uint256 public immutable EXCESS_UTILIZATION_RATE; + + ILendingPoolAddressesProvider public immutable addressesProvider; + + // Base variable borrow rate when Utilization rate = 0. Expressed in ray + uint256 internal immutable _baseVariableBorrowRate; + + // Slope of the variable interest curve when utilization rate > 0 and <= OPTIMAL_UTILIZATION_RATE. Expressed in ray + uint256 internal immutable _variableRateSlope1; + + // Slope of the variable interest curve when utilization rate > OPTIMAL_UTILIZATION_RATE. Expressed in ray + uint256 internal immutable _variableRateSlope2; + + // Slope of the stable interest curve when utilization rate > 0 and <= OPTIMAL_UTILIZATION_RATE. Expressed in ray + uint256 internal immutable _stableRateSlope1; + + // Slope of the stable interest curve when utilization rate > OPTIMAL_UTILIZATION_RATE. Expressed in ray + uint256 internal immutable _stableRateSlope2; + + constructor( + ILendingPoolAddressesProvider provider, + uint256 optimalUtilizationRate, + uint256 baseVariableBorrowRate, + uint256 variableRateSlope1, + uint256 variableRateSlope2, + uint256 stableRateSlope1, + uint256 stableRateSlope2 + ) public { + OPTIMAL_UTILIZATION_RATE = optimalUtilizationRate; + EXCESS_UTILIZATION_RATE = WadRayMath.ray().sub(optimalUtilizationRate); + addressesProvider = provider; + _baseVariableBorrowRate = baseVariableBorrowRate; + _variableRateSlope1 = variableRateSlope1; + _variableRateSlope2 = variableRateSlope2; + _stableRateSlope1 = stableRateSlope1; + _stableRateSlope2 = stableRateSlope2; + } + + function variableRateSlope1() external view returns (uint256) { + return _variableRateSlope1; + } + + function variableRateSlope2() external view returns (uint256) { + return _variableRateSlope2; + } + + function stableRateSlope1() external view returns (uint256) { + return _stableRateSlope1; + } + + function stableRateSlope2() external view returns (uint256) { + return _stableRateSlope2; + } + + function baseVariableBorrowRate() external view override returns (uint256) { + return _baseVariableBorrowRate; + } + + function getMaxVariableBorrowRate() external view override returns (uint256) { + return _baseVariableBorrowRate.add(_variableRateSlope1).add(_variableRateSlope2); + } + + /** + * @dev Calculates the interest rates depending on the reserve's state and configurations + * @param reserve The address of the reserve + * @param liquidityAdded The liquidity added during the operation + * @param liquidityTaken The liquidity taken during the operation + * @param totalStableDebt The total borrowed from the reserve a stable rate + * @param totalVariableDebt The total borrowed from the reserve at a variable rate + * @param averageStableBorrowRate The weighted average of all the stable rate loans + * @param reserveFactor The reserve portion of the interest that goes to the treasury of the market + * @return The liquidity rate, the stable borrow rate and the variable borrow rate + **/ + function calculateInterestRates( + address reserve, + address aToken, + uint256 liquidityAdded, + uint256 liquidityTaken, + uint256 totalStableDebt, + uint256 totalVariableDebt, + uint256 averageStableBorrowRate, + uint256 reserveFactor + ) + external + view + override + returns ( + uint256, + uint256, + uint256 + ) + { + uint256 availableLiquidity = IERC20(reserve).balanceOf(aToken); + //avoid stack too deep + availableLiquidity = availableLiquidity.add(liquidityAdded).sub(liquidityTaken); + + return + calculateInterestRates( + reserve, + availableLiquidity, + totalStableDebt, + totalVariableDebt, + averageStableBorrowRate, + reserveFactor + ); + } + + struct CalcInterestRatesLocalVars { + uint256 totalDebt; + uint256 currentVariableBorrowRate; + uint256 currentStableBorrowRate; + uint256 currentLiquidityRate; + uint256 utilizationRate; + } + + /** + * @dev Calculates the interest rates depending on the reserve's state and configurations. + * NOTE This function is kept for compatibility with the previous DefaultInterestRateStrategy interface. + * New protocol implementation uses the new calculateInterestRates() interface + * @param reserve The address of the reserve + * @param availableLiquidity The liquidity available in the corresponding aToken + * @param totalStableDebt The total borrowed from the reserve a stable rate + * @param totalVariableDebt The total borrowed from the reserve at a variable rate + * @param averageStableBorrowRate The weighted average of all the stable rate loans + * @param reserveFactor The reserve portion of the interest that goes to the treasury of the market + * @return The liquidity rate, the stable borrow rate and the variable borrow rate + **/ + function calculateInterestRates( + address reserve, + uint256 availableLiquidity, + uint256 totalStableDebt, + uint256 totalVariableDebt, + uint256 averageStableBorrowRate, + uint256 reserveFactor + ) + public + view + override + returns ( + uint256, + uint256, + uint256 + ) + { + CalcInterestRatesLocalVars memory vars; + + vars.totalDebt = totalStableDebt.add(totalVariableDebt); + vars.currentVariableBorrowRate = 0; + vars.currentStableBorrowRate = 0; + vars.currentLiquidityRate = 0; + + vars.utilizationRate = vars.totalDebt == 0 + ? 0 + : vars.totalDebt.rayDiv(availableLiquidity.add(vars.totalDebt)); + + vars.currentStableBorrowRate = ILendingRateOracle(addressesProvider.getLendingRateOracle()) + .getMarketBorrowRate(reserve); + + if (vars.utilizationRate > OPTIMAL_UTILIZATION_RATE) { + uint256 excessUtilizationRateRatio = + vars.utilizationRate.sub(OPTIMAL_UTILIZATION_RATE).rayDiv(EXCESS_UTILIZATION_RATE); + + vars.currentStableBorrowRate = vars.currentStableBorrowRate.add(_stableRateSlope1).add( + _stableRateSlope2.rayMul(excessUtilizationRateRatio) + ); + + vars.currentVariableBorrowRate = _baseVariableBorrowRate.add(_variableRateSlope1).add( + _variableRateSlope2.rayMul(excessUtilizationRateRatio) + ); + } else { + vars.currentStableBorrowRate = vars.currentStableBorrowRate.add( + _stableRateSlope1.rayMul(vars.utilizationRate.rayDiv(OPTIMAL_UTILIZATION_RATE)) + ); + vars.currentVariableBorrowRate = _baseVariableBorrowRate.add( + vars.utilizationRate.rayMul(_variableRateSlope1).rayDiv(OPTIMAL_UTILIZATION_RATE) + ); + } + + vars.currentLiquidityRate = _getOverallBorrowRate( + totalStableDebt, + totalVariableDebt, + vars + .currentVariableBorrowRate, + averageStableBorrowRate + ) + .rayMul(vars.utilizationRate) + .percentMul(PercentageMath.PERCENTAGE_FACTOR.sub(reserveFactor)); + + return ( + vars.currentLiquidityRate, + vars.currentStableBorrowRate, + vars.currentVariableBorrowRate + ); + } + + /** + * @dev Calculates the overall borrow rate as the weighted average between the total variable debt and total stable debt + * @param totalStableDebt The total borrowed from the reserve a stable rate + * @param totalVariableDebt The total borrowed from the reserve at a variable rate + * @param currentVariableBorrowRate The current variable borrow rate of the reserve + * @param currentAverageStableBorrowRate The current weighted average of all the stable rate loans + * @return The weighted averaged borrow rate + **/ + function _getOverallBorrowRate( + uint256 totalStableDebt, + uint256 totalVariableDebt, + uint256 currentVariableBorrowRate, + uint256 currentAverageStableBorrowRate + ) internal pure returns (uint256) { + uint256 totalDebt = totalStableDebt.add(totalVariableDebt); + + if (totalDebt == 0) return 0; + + uint256 weightedVariableRate = totalVariableDebt.wadToRay().rayMul(currentVariableBorrowRate); + + uint256 weightedStableRate = totalStableDebt.wadToRay().rayMul(currentAverageStableBorrowRate); + + uint256 overallBorrowRate = + weightedVariableRate.add(weightedStableRate).rayDiv(totalDebt.wadToRay()); + + return overallBorrowRate; + } +} diff --git a/external/contracts/aave/v2/AaveV2LendingPool.sol b/external/contracts/aave/v2/AaveV2LendingPool.sol new file mode 100644 index 000000000..a3fa55e20 --- /dev/null +++ b/external/contracts/aave/v2/AaveV2LendingPool.sol @@ -0,0 +1,946 @@ +// SPDX-License-Identifier: agpl-3.0 +pragma solidity 0.6.12; +pragma experimental ABIEncoderV2; + +import {SafeMath} from '../../dependencies/openzeppelin/contracts/SafeMath.sol'; +import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol'; +import {SafeERC20} from '../../dependencies/openzeppelin/contracts/SafeERC20.sol'; +import {Address} from '../../dependencies/openzeppelin/contracts/Address.sol'; +import {ILendingPoolAddressesProvider} from '../../interfaces/ILendingPoolAddressesProvider.sol'; +import {IAToken} from '../../interfaces/IAToken.sol'; +import {IVariableDebtToken} from '../../interfaces/IVariableDebtToken.sol'; +import {IFlashLoanReceiver} from '../../flashloan/interfaces/IFlashLoanReceiver.sol'; +import {IPriceOracleGetter} from '../../interfaces/IPriceOracleGetter.sol'; +import {IStableDebtToken} from '../../interfaces/IStableDebtToken.sol'; +import {ILendingPool} from '../../interfaces/ILendingPool.sol'; +import {VersionedInitializable} from '../libraries/aave-upgradeability/VersionedInitializable.sol'; +import {Helpers} from '../libraries/helpers/Helpers.sol'; +import {Errors} from '../libraries/helpers/Errors.sol'; +import {WadRayMath} from '../libraries/math/WadRayMath.sol'; +import {PercentageMath} from '../libraries/math/PercentageMath.sol'; +import {ReserveLogic} from '../libraries/logic/ReserveLogic.sol'; +import {GenericLogic} from '../libraries/logic/GenericLogic.sol'; +import {ValidationLogic} from '../libraries/logic/ValidationLogic.sol'; +import {ReserveConfiguration} from '../libraries/configuration/ReserveConfiguration.sol'; +import {UserConfiguration} from '../libraries/configuration/UserConfiguration.sol'; +import {DataTypes} from '../libraries/types/DataTypes.sol'; +import {LendingPoolStorage} from './LendingPoolStorage.sol'; + +/** + * @title LendingPool contract + * @dev Main point of interaction with an Aave protocol's market + * - Users can: + * # Deposit + * # Withdraw + * # Borrow + * # Repay + * # Swap their loans between variable and stable rate + * # Enable/disable their deposits as collateral rebalance stable rate borrow positions + * # Liquidate positions + * # Execute Flash Loans + * - To be covered by a proxy contract, owned by the LendingPoolAddressesProvider of the specific market + * - All admin functions are callable by the LendingPoolConfigurator contract defined also in the + * LendingPoolAddressesProvider + * @author Aave + **/ +contract AaveV2LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage { + using SafeMath for uint256; + using WadRayMath for uint256; + using PercentageMath for uint256; + using SafeERC20 for IERC20; + + uint256 public constant LENDINGPOOL_REVISION = 0x2; + + modifier whenNotPaused() { + _whenNotPaused(); + _; + } + + modifier onlyLendingPoolConfigurator() { + _onlyLendingPoolConfigurator(); + _; + } + + function _whenNotPaused() internal view { + require(!_paused, Errors.LP_IS_PAUSED); + } + + function _onlyLendingPoolConfigurator() internal view { + require( + _addressesProvider.getLendingPoolConfigurator() == msg.sender, + Errors.LP_CALLER_NOT_LENDING_POOL_CONFIGURATOR + ); + } + + function getRevision() internal pure override returns (uint256) { + return LENDINGPOOL_REVISION; + } + + /** + * @dev Function is invoked by the proxy contract when the LendingPool contract is added to the + * LendingPoolAddressesProvider of the market. + * - Caching the address of the LendingPoolAddressesProvider in order to reduce gas consumption + * on subsequent operations + * @param provider The address of the LendingPoolAddressesProvider + **/ + function initialize(ILendingPoolAddressesProvider provider) public initializer { + _addressesProvider = provider; + _maxStableRateBorrowSizePercent = 2500; + _flashLoanPremiumTotal = 9; + _maxNumberOfReserves = 128; + } + + /** + * @dev Deposits an `amount` of underlying asset into the reserve, receiving in return overlying aTokens. + * - E.g. User deposits 100 USDC and gets in return 100 aUSDC + * @param asset The address of the underlying asset to deposit + * @param amount The amount to be deposited + * @param onBehalfOf The address that will receive the aTokens, same as msg.sender if the user + * wants to receive them on his own wallet, or a different address if the beneficiary of aTokens + * is a different wallet + * @param referralCode Code used to register the integrator originating the operation, for potential rewards. + * 0 if the action is executed directly by the user, without any middle-man + **/ + function deposit( + address asset, + uint256 amount, + address onBehalfOf, + uint16 referralCode + ) external override whenNotPaused { + DataTypes.ReserveData storage reserve = _reserves[asset]; + + ValidationLogic.validateDeposit(reserve, amount); + + address aToken = reserve.aTokenAddress; + + reserve.updateState(); + reserve.updateInterestRates(asset, aToken, amount, 0); + + IERC20(asset).safeTransferFrom(msg.sender, aToken, amount); + + bool isFirstDeposit = IAToken(aToken).mint(onBehalfOf, amount, reserve.liquidityIndex); + + if (isFirstDeposit) { + _usersConfig[onBehalfOf].setUsingAsCollateral(reserve.id, true); + emit ReserveUsedAsCollateralEnabled(asset, onBehalfOf); + } + + emit Deposit(asset, msg.sender, onBehalfOf, amount, referralCode); + } + + /** + * @dev Withdraws an `amount` of underlying asset from the reserve, burning the equivalent aTokens owned + * E.g. User has 100 aUSDC, calls withdraw() and receives 100 USDC, burning the 100 aUSDC + * @param asset The address of the underlying asset to withdraw + * @param amount The underlying amount to be withdrawn + * - Send the value type(uint256).max in order to withdraw the whole aToken balance + * @param to Address that will receive the underlying, same as msg.sender if the user + * wants to receive it on his own wallet, or a different address if the beneficiary is a + * different wallet + * @return The final amount withdrawn + **/ + function withdraw( + address asset, + uint256 amount, + address to + ) external override whenNotPaused returns (uint256) { + DataTypes.ReserveData storage reserve = _reserves[asset]; + + address aToken = reserve.aTokenAddress; + + uint256 userBalance = IAToken(aToken).balanceOf(msg.sender); + + uint256 amountToWithdraw = amount; + + if (amount == type(uint256).max) { + amountToWithdraw = userBalance; + } + + ValidationLogic.validateWithdraw( + asset, + amountToWithdraw, + userBalance, + _reserves, + _usersConfig[msg.sender], + _reservesList, + _reservesCount, + _addressesProvider.getPriceOracle() + ); + + reserve.updateState(); + + reserve.updateInterestRates(asset, aToken, 0, amountToWithdraw); + + if (amountToWithdraw == userBalance) { + _usersConfig[msg.sender].setUsingAsCollateral(reserve.id, false); + emit ReserveUsedAsCollateralDisabled(asset, msg.sender); + } + + IAToken(aToken).burn(msg.sender, to, amountToWithdraw, reserve.liquidityIndex); + + emit Withdraw(asset, msg.sender, to, amountToWithdraw); + + return amountToWithdraw; + } + + /** + * @dev Allows users to borrow a specific `amount` of the reserve underlying asset, provided that the borrower + * already deposited enough collateral, or he was given enough allowance by a credit delegator on the + * corresponding debt token (StableDebtToken or VariableDebtToken) + * - E.g. User borrows 100 USDC passing as `onBehalfOf` his own address, receiving the 100 USDC in his wallet + * and 100 stable/variable debt tokens, depending on the `interestRateMode` + * @param asset The address of the underlying asset to borrow + * @param amount The amount to be borrowed + * @param interestRateMode The interest rate mode at which the user wants to borrow: 1 for Stable, 2 for Variable + * @param referralCode Code used to register the integrator originating the operation, for potential rewards. + * 0 if the action is executed directly by the user, without any middle-man + * @param onBehalfOf Address of the user who will receive the debt. Should be the address of the borrower itself + * calling the function if he wants to borrow against his own collateral, or the address of the credit delegator + * if he has been given credit delegation allowance + **/ + function borrow( + address asset, + uint256 amount, + uint256 interestRateMode, + uint16 referralCode, + address onBehalfOf + ) external override whenNotPaused { + DataTypes.ReserveData storage reserve = _reserves[asset]; + + _executeBorrow( + ExecuteBorrowParams( + asset, + msg.sender, + onBehalfOf, + amount, + interestRateMode, + reserve.aTokenAddress, + referralCode, + true + ) + ); + } + + /** + * @notice Repays a borrowed `amount` on a specific reserve, burning the equivalent debt tokens owned + * - E.g. User repays 100 USDC, burning 100 variable/stable debt tokens of the `onBehalfOf` address + * @param asset The address of the borrowed underlying asset previously borrowed + * @param amount The amount to repay + * - Send the value type(uint256).max in order to repay the whole debt for `asset` on the specific `debtMode` + * @param rateMode The interest rate mode at of the debt the user wants to repay: 1 for Stable, 2 for Variable + * @param onBehalfOf Address of the user who will get his debt reduced/removed. Should be the address of the + * user calling the function if he wants to reduce/remove his own debt, or the address of any other + * other borrower whose debt should be removed + * @return The final amount repaid + **/ + function repay( + address asset, + uint256 amount, + uint256 rateMode, + address onBehalfOf + ) external override whenNotPaused returns (uint256) { + DataTypes.ReserveData storage reserve = _reserves[asset]; + + (uint256 stableDebt, uint256 variableDebt) = Helpers.getUserCurrentDebt(onBehalfOf, reserve); + + DataTypes.InterestRateMode interestRateMode = DataTypes.InterestRateMode(rateMode); + + ValidationLogic.validateRepay( + reserve, + amount, + interestRateMode, + onBehalfOf, + stableDebt, + variableDebt + ); + + uint256 paybackAmount = + interestRateMode == DataTypes.InterestRateMode.STABLE ? stableDebt : variableDebt; + + if (amount < paybackAmount) { + paybackAmount = amount; + } + + reserve.updateState(); + + if (interestRateMode == DataTypes.InterestRateMode.STABLE) { + IStableDebtToken(reserve.stableDebtTokenAddress).burn(onBehalfOf, paybackAmount); + } else { + IVariableDebtToken(reserve.variableDebtTokenAddress).burn( + onBehalfOf, + paybackAmount, + reserve.variableBorrowIndex + ); + } + + address aToken = reserve.aTokenAddress; + reserve.updateInterestRates(asset, aToken, paybackAmount, 0); + + if (stableDebt.add(variableDebt).sub(paybackAmount) == 0) { + _usersConfig[onBehalfOf].setBorrowing(reserve.id, false); + } + + IERC20(asset).safeTransferFrom(msg.sender, aToken, paybackAmount); + + IAToken(aToken).handleRepayment(msg.sender, paybackAmount); + + emit Repay(asset, onBehalfOf, msg.sender, paybackAmount); + + return paybackAmount; + } + + /** + * @dev Allows a borrower to swap his debt between stable and variable mode, or viceversa + * @param asset The address of the underlying asset borrowed + * @param rateMode The rate mode that the user wants to swap to + **/ + function swapBorrowRateMode(address asset, uint256 rateMode) external override whenNotPaused { + DataTypes.ReserveData storage reserve = _reserves[asset]; + + (uint256 stableDebt, uint256 variableDebt) = Helpers.getUserCurrentDebt(msg.sender, reserve); + + DataTypes.InterestRateMode interestRateMode = DataTypes.InterestRateMode(rateMode); + + ValidationLogic.validateSwapRateMode( + reserve, + _usersConfig[msg.sender], + stableDebt, + variableDebt, + interestRateMode + ); + + reserve.updateState(); + + if (interestRateMode == DataTypes.InterestRateMode.STABLE) { + IStableDebtToken(reserve.stableDebtTokenAddress).burn(msg.sender, stableDebt); + IVariableDebtToken(reserve.variableDebtTokenAddress).mint( + msg.sender, + msg.sender, + stableDebt, + reserve.variableBorrowIndex + ); + } else { + IVariableDebtToken(reserve.variableDebtTokenAddress).burn( + msg.sender, + variableDebt, + reserve.variableBorrowIndex + ); + IStableDebtToken(reserve.stableDebtTokenAddress).mint( + msg.sender, + msg.sender, + variableDebt, + reserve.currentStableBorrowRate + ); + } + + reserve.updateInterestRates(asset, reserve.aTokenAddress, 0, 0); + + emit Swap(asset, msg.sender, rateMode); + } + + /** + * @dev Rebalances the stable interest rate of a user to the current stable rate defined on the reserve. + * - Users can be rebalanced if the following conditions are satisfied: + * 1. Usage ratio is above 95% + * 2. the current deposit APY is below REBALANCE_UP_THRESHOLD * maxVariableBorrowRate, which means that too much has been + * borrowed at a stable rate and depositors are not earning enough + * @param asset The address of the underlying asset borrowed + * @param user The address of the user to be rebalanced + **/ + function rebalanceStableBorrowRate(address asset, address user) external override whenNotPaused { + DataTypes.ReserveData storage reserve = _reserves[asset]; + + IERC20 stableDebtToken = IERC20(reserve.stableDebtTokenAddress); + IERC20 variableDebtToken = IERC20(reserve.variableDebtTokenAddress); + address aTokenAddress = reserve.aTokenAddress; + + uint256 stableDebt = IERC20(stableDebtToken).balanceOf(user); + + ValidationLogic.validateRebalanceStableBorrowRate( + reserve, + asset, + stableDebtToken, + variableDebtToken, + aTokenAddress + ); + + reserve.updateState(); + + IStableDebtToken(address(stableDebtToken)).burn(user, stableDebt); + IStableDebtToken(address(stableDebtToken)).mint( + user, + user, + stableDebt, + reserve.currentStableBorrowRate + ); + + reserve.updateInterestRates(asset, aTokenAddress, 0, 0); + + emit RebalanceStableBorrowRate(asset, user); + } + + /** + * @dev Allows depositors to enable/disable a specific deposited asset as collateral + * @param asset The address of the underlying asset deposited + * @param useAsCollateral `true` if the user wants to use the deposit as collateral, `false` otherwise + **/ + function setUserUseReserveAsCollateral(address asset, bool useAsCollateral) + external + override + whenNotPaused + { + DataTypes.ReserveData storage reserve = _reserves[asset]; + + ValidationLogic.validateSetUseReserveAsCollateral( + reserve, + asset, + useAsCollateral, + _reserves, + _usersConfig[msg.sender], + _reservesList, + _reservesCount, + _addressesProvider.getPriceOracle() + ); + + _usersConfig[msg.sender].setUsingAsCollateral(reserve.id, useAsCollateral); + + if (useAsCollateral) { + emit ReserveUsedAsCollateralEnabled(asset, msg.sender); + } else { + emit ReserveUsedAsCollateralDisabled(asset, msg.sender); + } + } + + /** + * @dev Function to liquidate a non-healthy position collateral-wise, with Health Factor below 1 + * - The caller (liquidator) covers `debtToCover` amount of debt of the user getting liquidated, and receives + * a proportionally amount of the `collateralAsset` plus a bonus to cover market risk + * @param collateralAsset The address of the underlying asset used as collateral, to receive as result of the liquidation + * @param debtAsset The address of the underlying borrowed asset to be repaid with the liquidation + * @param user The address of the borrower getting liquidated + * @param debtToCover The debt amount of borrowed `asset` the liquidator wants to cover + * @param receiveAToken `true` if the liquidators wants to receive the collateral aTokens, `false` if he wants + * to receive the underlying collateral asset directly + **/ + function liquidationCall( + address collateralAsset, + address debtAsset, + address user, + uint256 debtToCover, + bool receiveAToken + ) external override whenNotPaused { + address collateralManager = _addressesProvider.getLendingPoolCollateralManager(); + + //solium-disable-next-line + (bool success, bytes memory result) = + collateralManager.delegatecall( + abi.encodeWithSignature( + 'liquidationCall(address,address,address,uint256,bool)', + collateralAsset, + debtAsset, + user, + debtToCover, + receiveAToken + ) + ); + + require(success, Errors.LP_LIQUIDATION_CALL_FAILED); + + (uint256 returnCode, string memory returnMessage) = abi.decode(result, (uint256, string)); + + require(returnCode == 0, string(abi.encodePacked(returnMessage))); + } + + struct FlashLoanLocalVars { + IFlashLoanReceiver receiver; + address oracle; + uint256 i; + address currentAsset; + address currentATokenAddress; + uint256 currentAmount; + uint256 currentPremium; + uint256 currentAmountPlusPremium; + address debtToken; + } + + /** + * @dev Allows smartcontracts to access the liquidity of the pool within one transaction, + * as long as the amount taken plus a fee is returned. + * IMPORTANT There are security concerns for developers of flashloan receiver contracts that must be kept into consideration. + * For further details please visit https://developers.aave.com + * @param receiverAddress The address of the contract receiving the funds, implementing the IFlashLoanReceiver interface + * @param assets The addresses of the assets being flash-borrowed + * @param amounts The amounts amounts being flash-borrowed + * @param modes Types of the debt to open if the flash loan is not returned: + * 0 -> Don't open any debt, just revert if funds can't be transferred from the receiver + * 1 -> Open debt at stable rate for the value of the amount flash-borrowed to the `onBehalfOf` address + * 2 -> Open debt at variable rate for the value of the amount flash-borrowed to the `onBehalfOf` address + * @param onBehalfOf The address that will receive the debt in the case of using on `modes` 1 or 2 + * @param params Variadic packed params to pass to the receiver as extra information + * @param referralCode Code used to register the integrator originating the operation, for potential rewards. + * 0 if the action is executed directly by the user, without any middle-man + **/ + function flashLoan( + address receiverAddress, + address[] calldata assets, + uint256[] calldata amounts, + uint256[] calldata modes, + address onBehalfOf, + bytes calldata params, + uint16 referralCode + ) external override whenNotPaused { + FlashLoanLocalVars memory vars; + + ValidationLogic.validateFlashloan(assets, amounts); + + address[] memory aTokenAddresses = new address[](assets.length); + uint256[] memory premiums = new uint256[](assets.length); + + vars.receiver = IFlashLoanReceiver(receiverAddress); + + for (vars.i = 0; vars.i < assets.length; vars.i++) { + aTokenAddresses[vars.i] = _reserves[assets[vars.i]].aTokenAddress; + + premiums[vars.i] = amounts[vars.i].mul(_flashLoanPremiumTotal).div(10000); + + IAToken(aTokenAddresses[vars.i]).transferUnderlyingTo(receiverAddress, amounts[vars.i]); + } + + require( + vars.receiver.executeOperation(assets, amounts, premiums, msg.sender, params), + Errors.LP_INVALID_FLASH_LOAN_EXECUTOR_RETURN + ); + + for (vars.i = 0; vars.i < assets.length; vars.i++) { + vars.currentAsset = assets[vars.i]; + vars.currentAmount = amounts[vars.i]; + vars.currentPremium = premiums[vars.i]; + vars.currentATokenAddress = aTokenAddresses[vars.i]; + vars.currentAmountPlusPremium = vars.currentAmount.add(vars.currentPremium); + + if (DataTypes.InterestRateMode(modes[vars.i]) == DataTypes.InterestRateMode.NONE) { + _reserves[vars.currentAsset].updateState(); + _reserves[vars.currentAsset].cumulateToLiquidityIndex( + IERC20(vars.currentATokenAddress).totalSupply(), + vars.currentPremium + ); + _reserves[vars.currentAsset].updateInterestRates( + vars.currentAsset, + vars.currentATokenAddress, + vars.currentAmountPlusPremium, + 0 + ); + + IERC20(vars.currentAsset).safeTransferFrom( + receiverAddress, + vars.currentATokenAddress, + vars.currentAmountPlusPremium + ); + } else { + // If the user chose to not return the funds, the system checks if there is enough collateral and + // eventually opens a debt position + _executeBorrow( + ExecuteBorrowParams( + vars.currentAsset, + msg.sender, + onBehalfOf, + vars.currentAmount, + modes[vars.i], + vars.currentATokenAddress, + referralCode, + false + ) + ); + } + emit FlashLoan( + receiverAddress, + msg.sender, + vars.currentAsset, + vars.currentAmount, + vars.currentPremium, + referralCode + ); + } + } + + /** + * @dev Returns the state and configuration of the reserve + * @param asset The address of the underlying asset of the reserve + * @return The state of the reserve + **/ + function getReserveData(address asset) + external + view + override + returns (DataTypes.ReserveData memory) + { + return _reserves[asset]; + } + + /** + * @dev Returns the user account data across all the reserves + * @param user The address of the user + * @return totalCollateralETH the total collateral in ETH of the user + * @return totalDebtETH the total debt in ETH of the user + * @return availableBorrowsETH the borrowing power left of the user + * @return currentLiquidationThreshold the liquidation threshold of the user + * @return ltv the loan to value of the user + * @return healthFactor the current health factor of the user + **/ + function getUserAccountData(address user) + external + view + override + returns ( + uint256 totalCollateralETH, + uint256 totalDebtETH, + uint256 availableBorrowsETH, + uint256 currentLiquidationThreshold, + uint256 ltv, + uint256 healthFactor + ) + { + ( + totalCollateralETH, + totalDebtETH, + ltv, + currentLiquidationThreshold, + healthFactor + ) = GenericLogic.calculateUserAccountData( + user, + _reserves, + _usersConfig[user], + _reservesList, + _reservesCount, + _addressesProvider.getPriceOracle() + ); + + availableBorrowsETH = GenericLogic.calculateAvailableBorrowsETH( + totalCollateralETH, + totalDebtETH, + ltv + ); + } + + /** + * @dev Returns the configuration of the reserve + * @param asset The address of the underlying asset of the reserve + * @return The configuration of the reserve + **/ + function getConfiguration(address asset) + external + view + override + returns (DataTypes.ReserveConfigurationMap memory) + { + return _reserves[asset].configuration; + } + + /** + * @dev Returns the configuration of the user across all the reserves + * @param user The user address + * @return The configuration of the user + **/ + function getUserConfiguration(address user) + external + view + override + returns (DataTypes.UserConfigurationMap memory) + { + return _usersConfig[user]; + } + + /** + * @dev Returns the normalized income per unit of asset + * @param asset The address of the underlying asset of the reserve + * @return The reserve's normalized income + */ + function getReserveNormalizedIncome(address asset) + external + view + virtual + override + returns (uint256) + { + return _reserves[asset].getNormalizedIncome(); + } + + /** + * @dev Returns the normalized variable debt per unit of asset + * @param asset The address of the underlying asset of the reserve + * @return The reserve normalized variable debt + */ + function getReserveNormalizedVariableDebt(address asset) + external + view + override + returns (uint256) + { + return _reserves[asset].getNormalizedDebt(); + } + + /** + * @dev Returns if the LendingPool is paused + */ + function paused() external view override returns (bool) { + return _paused; + } + + /** + * @dev Returns the list of the initialized reserves + **/ + function getReservesList() external view override returns (address[] memory) { + address[] memory _activeReserves = new address[](_reservesCount); + + for (uint256 i = 0; i < _reservesCount; i++) { + _activeReserves[i] = _reservesList[i]; + } + return _activeReserves; + } + + /** + * @dev Returns the cached LendingPoolAddressesProvider connected to this contract + **/ + function getAddressesProvider() external view override returns (ILendingPoolAddressesProvider) { + return _addressesProvider; + } + + /** + * @dev Returns the percentage of available liquidity that can be borrowed at once at stable rate + */ + function MAX_STABLE_RATE_BORROW_SIZE_PERCENT() public view returns (uint256) { + return _maxStableRateBorrowSizePercent; + } + + /** + * @dev Returns the fee on flash loans + */ + function FLASHLOAN_PREMIUM_TOTAL() public view returns (uint256) { + return _flashLoanPremiumTotal; + } + + /** + * @dev Returns the maximum number of reserves supported to be listed in this LendingPool + */ + function MAX_NUMBER_RESERVES() public view returns (uint256) { + return _maxNumberOfReserves; + } + + /** + * @dev Validates and finalizes an aToken transfer + * - Only callable by the overlying aToken of the `asset` + * @param asset The address of the underlying asset of the aToken + * @param from The user from which the aTokens are transferred + * @param to The user receiving the aTokens + * @param amount The amount being transferred/withdrawn + * @param balanceFromBefore The aToken balance of the `from` user before the transfer + * @param balanceToBefore The aToken balance of the `to` user before the transfer + */ + function finalizeTransfer( + address asset, + address from, + address to, + uint256 amount, + uint256 balanceFromBefore, + uint256 balanceToBefore + ) external override whenNotPaused { + require(msg.sender == _reserves[asset].aTokenAddress, Errors.LP_CALLER_MUST_BE_AN_ATOKEN); + + ValidationLogic.validateTransfer( + from, + _reserves, + _usersConfig[from], + _reservesList, + _reservesCount, + _addressesProvider.getPriceOracle() + ); + + uint256 reserveId = _reserves[asset].id; + + if (from != to) { + if (balanceFromBefore.sub(amount) == 0) { + DataTypes.UserConfigurationMap storage fromConfig = _usersConfig[from]; + fromConfig.setUsingAsCollateral(reserveId, false); + emit ReserveUsedAsCollateralDisabled(asset, from); + } + + if (balanceToBefore == 0 && amount != 0) { + DataTypes.UserConfigurationMap storage toConfig = _usersConfig[to]; + toConfig.setUsingAsCollateral(reserveId, true); + emit ReserveUsedAsCollateralEnabled(asset, to); + } + } + } + + /** + * @dev Initializes a reserve, activating it, assigning an aToken and debt tokens and an + * interest rate strategy + * - Only callable by the LendingPoolConfigurator contract + * @param asset The address of the underlying asset of the reserve + * @param aTokenAddress The address of the aToken that will be assigned to the reserve + * @param stableDebtAddress The address of the StableDebtToken that will be assigned to the reserve + * @param aTokenAddress The address of the VariableDebtToken that will be assigned to the reserve + * @param interestRateStrategyAddress The address of the interest rate strategy contract + **/ + function initReserve( + address asset, + address aTokenAddress, + address stableDebtAddress, + address variableDebtAddress, + address interestRateStrategyAddress + ) external override onlyLendingPoolConfigurator { + require(Address.isContract(asset), Errors.LP_NOT_CONTRACT); + _reserves[asset].init( + aTokenAddress, + stableDebtAddress, + variableDebtAddress, + interestRateStrategyAddress + ); + _addReserveToList(asset); + } + + /** + * @dev Updates the address of the interest rate strategy contract + * - Only callable by the LendingPoolConfigurator contract + * @param asset The address of the underlying asset of the reserve + * @param rateStrategyAddress The address of the interest rate strategy contract + **/ + function setReserveInterestRateStrategyAddress(address asset, address rateStrategyAddress) + external + override + onlyLendingPoolConfigurator + { + _reserves[asset].interestRateStrategyAddress = rateStrategyAddress; + } + + /** + * @dev Sets the configuration bitmap of the reserve as a whole + * - Only callable by the LendingPoolConfigurator contract + * @param asset The address of the underlying asset of the reserve + * @param configuration The new configuration bitmap + **/ + function setConfiguration(address asset, uint256 configuration) + external + override + onlyLendingPoolConfigurator + { + _reserves[asset].configuration.data = configuration; + } + + /** + * @dev Set the _pause state of a reserve + * - Only callable by the LendingPoolConfigurator contract + * @param val `true` to pause the reserve, `false` to un-pause it + */ + function setPause(bool val) external override onlyLendingPoolConfigurator { + _paused = val; + if (_paused) { + emit Paused(); + } else { + emit Unpaused(); + } + } + + struct ExecuteBorrowParams { + address asset; + address user; + address onBehalfOf; + uint256 amount; + uint256 interestRateMode; + address aTokenAddress; + uint16 referralCode; + bool releaseUnderlying; + } + + function _executeBorrow(ExecuteBorrowParams memory vars) internal { + DataTypes.ReserveData storage reserve = _reserves[vars.asset]; + DataTypes.UserConfigurationMap storage userConfig = _usersConfig[vars.onBehalfOf]; + + address oracle = _addressesProvider.getPriceOracle(); + + uint256 amountInETH = + IPriceOracleGetter(oracle).getAssetPrice(vars.asset).mul(vars.amount).div( + 10**reserve.configuration.getDecimals() + ); + + ValidationLogic.validateBorrow( + vars.asset, + reserve, + vars.onBehalfOf, + vars.amount, + amountInETH, + vars.interestRateMode, + _maxStableRateBorrowSizePercent, + _reserves, + userConfig, + _reservesList, + _reservesCount, + oracle + ); + + reserve.updateState(); + + uint256 currentStableRate = 0; + + bool isFirstBorrowing = false; + if (DataTypes.InterestRateMode(vars.interestRateMode) == DataTypes.InterestRateMode.STABLE) { + currentStableRate = reserve.currentStableBorrowRate; + + isFirstBorrowing = IStableDebtToken(reserve.stableDebtTokenAddress).mint( + vars.user, + vars.onBehalfOf, + vars.amount, + currentStableRate + ); + } else { + isFirstBorrowing = IVariableDebtToken(reserve.variableDebtTokenAddress).mint( + vars.user, + vars.onBehalfOf, + vars.amount, + reserve.variableBorrowIndex + ); + } + + if (isFirstBorrowing) { + userConfig.setBorrowing(reserve.id, true); + } + + reserve.updateInterestRates( + vars.asset, + vars.aTokenAddress, + 0, + vars.releaseUnderlying ? vars.amount : 0 + ); + + if (vars.releaseUnderlying) { + IAToken(vars.aTokenAddress).transferUnderlyingTo(vars.user, vars.amount); + } + + emit Borrow( + vars.asset, + vars.user, + vars.onBehalfOf, + vars.amount, + vars.interestRateMode, + DataTypes.InterestRateMode(vars.interestRateMode) == DataTypes.InterestRateMode.STABLE + ? currentStableRate + : reserve.currentVariableBorrowRate, + vars.referralCode + ); + } + + function _addReserveToList(address asset) internal { + uint256 reservesCount = _reservesCount; + + require(reservesCount < _maxNumberOfReserves, Errors.LP_NO_MORE_RESERVES_ALLOWED); + + bool reserveAlreadyAdded = _reserves[asset].id != 0 || _reservesList[0] == asset; + + if (!reserveAlreadyAdded) { + _reserves[asset].id = uint8(reservesCount); + _reservesList[reservesCount] = asset; + + _reservesCount = reservesCount + 1; + } + } +} diff --git a/external/contracts/aave/v2/AaveV2LendingPoolAddressesProvider.sol b/external/contracts/aave/v2/AaveV2LendingPoolAddressesProvider.sol new file mode 100644 index 000000000..184b95f7c --- /dev/null +++ b/external/contracts/aave/v2/AaveV2LendingPoolAddressesProvider.sol @@ -0,0 +1,215 @@ +// SPDX-License-Identifier: agpl-3.0 +pragma solidity 0.6.12; + +import {Ownable} from '../../dependencies/openzeppelin/contracts/Ownable.sol'; + +// Prettier ignore to prevent buidler flatter bug +// prettier-ignore +import {InitializableImmutableAdminUpgradeabilityProxy} from '../libraries/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol'; + +import {ILendingPoolAddressesProvider} from '../../interfaces/ILendingPoolAddressesProvider.sol'; + +/** + * @title LendingPoolAddressesProvider contract + * @dev Main registry of addresses part of or connected to the protocol, including permissioned roles + * - Acting also as factory of proxies and admin of those, so with right to change its implementations + * - Owned by the Aave Governance + * @author Aave + **/ +contract AaveV2LendingPoolAddressesProvider is Ownable, ILendingPoolAddressesProvider { + string private _marketId; + mapping(bytes32 => address) private _addresses; + + bytes32 private constant LENDING_POOL = 'LENDING_POOL'; + bytes32 private constant LENDING_POOL_CONFIGURATOR = 'LENDING_POOL_CONFIGURATOR'; + bytes32 private constant POOL_ADMIN = 'POOL_ADMIN'; + bytes32 private constant EMERGENCY_ADMIN = 'EMERGENCY_ADMIN'; + bytes32 private constant LENDING_POOL_COLLATERAL_MANAGER = 'COLLATERAL_MANAGER'; + bytes32 private constant PRICE_ORACLE = 'PRICE_ORACLE'; + bytes32 private constant LENDING_RATE_ORACLE = 'LENDING_RATE_ORACLE'; + + constructor(string memory marketId) public { + _setMarketId(marketId); + } + + /** + * @dev Returns the id of the Aave market to which this contracts points to + * @return The market id + **/ + function getMarketId() external view override returns (string memory) { + return _marketId; + } + + /** + * @dev Allows to set the market which this LendingPoolAddressesProvider represents + * @param marketId The market id + */ + function setMarketId(string memory marketId) external override onlyOwner { + _setMarketId(marketId); + } + + /** + * @dev General function to update the implementation of a proxy registered with + * certain `id`. If there is no proxy registered, it will instantiate one and + * set as implementation the `implementationAddress` + * IMPORTANT Use this function carefully, only for ids that don't have an explicit + * setter function, in order to avoid unexpected consequences + * @param id The id + * @param implementationAddress The address of the new implementation + */ + function setAddressAsProxy(bytes32 id, address implementationAddress) + external + override + onlyOwner + { + _updateImpl(id, implementationAddress); + emit AddressSet(id, implementationAddress, true); + } + + /** + * @dev Sets an address for an id replacing the address saved in the addresses map + * IMPORTANT Use this function carefully, as it will do a hard replacement + * @param id The id + * @param newAddress The address to set + */ + function setAddress(bytes32 id, address newAddress) external override onlyOwner { + _addresses[id] = newAddress; + emit AddressSet(id, newAddress, false); + } + + /** + * @dev Returns an address by id + * @return The address + */ + function getAddress(bytes32 id) public view override returns (address) { + return _addresses[id]; + } + + /** + * @dev Returns the address of the LendingPool proxy + * @return The LendingPool proxy address + **/ + function getLendingPool() external view override returns (address) { + return getAddress(LENDING_POOL); + } + + /** + * @dev Updates the implementation of the LendingPool, or creates the proxy + * setting the new `pool` implementation on the first time calling it + * @param pool The new LendingPool implementation + **/ + function setLendingPoolImpl(address pool) external override onlyOwner { + _updateImpl(LENDING_POOL, pool); + emit LendingPoolUpdated(pool); + } + + /** + * @dev Returns the address of the LendingPoolConfigurator proxy + * @return The LendingPoolConfigurator proxy address + **/ + function getLendingPoolConfigurator() external view override returns (address) { + return getAddress(LENDING_POOL_CONFIGURATOR); + } + + /** + * @dev Updates the implementation of the LendingPoolConfigurator, or creates the proxy + * setting the new `configurator` implementation on the first time calling it + * @param configurator The new LendingPoolConfigurator implementation + **/ + function setLendingPoolConfiguratorImpl(address configurator) external override onlyOwner { + _updateImpl(LENDING_POOL_CONFIGURATOR, configurator); + emit LendingPoolConfiguratorUpdated(configurator); + } + + /** + * @dev Returns the address of the LendingPoolCollateralManager. Since the manager is used + * through delegateCall within the LendingPool contract, the proxy contract pattern does not work properly hence + * the addresses are changed directly + * @return The address of the LendingPoolCollateralManager + **/ + + function getLendingPoolCollateralManager() external view override returns (address) { + return getAddress(LENDING_POOL_COLLATERAL_MANAGER); + } + + /** + * @dev Updates the address of the LendingPoolCollateralManager + * @param manager The new LendingPoolCollateralManager address + **/ + function setLendingPoolCollateralManager(address manager) external override onlyOwner { + _addresses[LENDING_POOL_COLLATERAL_MANAGER] = manager; + emit LendingPoolCollateralManagerUpdated(manager); + } + + /** + * @dev The functions below are getters/setters of addresses that are outside the context + * of the protocol hence the upgradable proxy pattern is not used + **/ + + function getPoolAdmin() external view override returns (address) { + return getAddress(POOL_ADMIN); + } + + function setPoolAdmin(address admin) external override onlyOwner { + _addresses[POOL_ADMIN] = admin; + emit ConfigurationAdminUpdated(admin); + } + + function getEmergencyAdmin() external view override returns (address) { + return getAddress(EMERGENCY_ADMIN); + } + + function setEmergencyAdmin(address emergencyAdmin) external override onlyOwner { + _addresses[EMERGENCY_ADMIN] = emergencyAdmin; + emit EmergencyAdminUpdated(emergencyAdmin); + } + + function getPriceOracle() external view override returns (address) { + return getAddress(PRICE_ORACLE); + } + + function setPriceOracle(address priceOracle) external override onlyOwner { + _addresses[PRICE_ORACLE] = priceOracle; + emit PriceOracleUpdated(priceOracle); + } + + function getLendingRateOracle() external view override returns (address) { + return getAddress(LENDING_RATE_ORACLE); + } + + function setLendingRateOracle(address lendingRateOracle) external override onlyOwner { + _addresses[LENDING_RATE_ORACLE] = lendingRateOracle; + emit LendingRateOracleUpdated(lendingRateOracle); + } + + /** + * @dev Internal function to update the implementation of a specific proxied component of the protocol + * - If there is no proxy registered in the given `id`, it creates the proxy setting `newAdress` + * as implementation and calls the initialize() function on the proxy + * - If there is already a proxy registered, it just updates the implementation to `newAddress` and + * calls the initialize() function via upgradeToAndCall() in the proxy + * @param id The id of the proxy to be updated + * @param newAddress The address of the new implementation + **/ + function _updateImpl(bytes32 id, address newAddress) internal { + address payable proxyAddress = payable(_addresses[id]); + + InitializableImmutableAdminUpgradeabilityProxy proxy = + InitializableImmutableAdminUpgradeabilityProxy(proxyAddress); + bytes memory params = abi.encodeWithSignature('initialize(address)', address(this)); + + if (proxyAddress == address(0)) { + proxy = new InitializableImmutableAdminUpgradeabilityProxy(address(this)); + proxy.initialize(newAddress, params); + _addresses[id] = address(proxy); + emit ProxyCreated(id, address(proxy)); + } else { + proxy.upgradeToAndCall(newAddress, params); + } + } + + function _setMarketId(string memory marketId) internal { + _marketId = marketId; + emit MarketIdSet(marketId); + } +} diff --git a/external/contracts/aave/v2/AaveV2LendingPoolConfigurator.sol b/external/contracts/aave/v2/AaveV2LendingPoolConfigurator.sol new file mode 100644 index 000000000..3dc95d535 --- /dev/null +++ b/external/contracts/aave/v2/AaveV2LendingPoolConfigurator.sol @@ -0,0 +1,487 @@ +// SPDX-License-Identifier: agpl-3.0 +pragma solidity 0.6.12; +pragma experimental ABIEncoderV2; + +import {SafeMath} from '../../dependencies/openzeppelin/contracts/SafeMath.sol'; +import {VersionedInitializable} from '../libraries/aave-upgradeability/VersionedInitializable.sol'; +import { + InitializableImmutableAdminUpgradeabilityProxy +} from '../libraries/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol'; +import {ReserveConfiguration} from '../libraries/configuration/ReserveConfiguration.sol'; +import {ILendingPoolAddressesProvider} from '../../interfaces/ILendingPoolAddressesProvider.sol'; +import {ILendingPool} from '../../interfaces/ILendingPool.sol'; +import {IERC20Detailed} from '../../dependencies/openzeppelin/contracts/IERC20Detailed.sol'; +import {Errors} from '../libraries/helpers/Errors.sol'; +import {PercentageMath} from '../libraries/math/PercentageMath.sol'; +import {DataTypes} from '../libraries/types/DataTypes.sol'; +import {IInitializableDebtToken} from '../../interfaces/IInitializableDebtToken.sol'; +import {IInitializableAToken} from '../../interfaces/IInitializableAToken.sol'; +import {IAaveIncentivesController} from '../../interfaces/IAaveIncentivesController.sol'; +import {ILendingPoolConfigurator} from '../../interfaces/ILendingPoolConfigurator.sol'; + +/** + * @title LendingPoolConfigurator contract + * @author Aave + * @dev Implements the configuration methods for the Aave protocol + **/ + +contract AaveV2LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigurator { + using SafeMath for uint256; + using PercentageMath for uint256; + using ReserveConfiguration for DataTypes.ReserveConfigurationMap; + + ILendingPoolAddressesProvider internal addressesProvider; + ILendingPool internal pool; + + modifier onlyPoolAdmin { + require(addressesProvider.getPoolAdmin() == msg.sender, Errors.CALLER_NOT_POOL_ADMIN); + _; + } + + modifier onlyEmergencyAdmin { + require( + addressesProvider.getEmergencyAdmin() == msg.sender, + Errors.LPC_CALLER_NOT_EMERGENCY_ADMIN + ); + _; + } + + uint256 internal constant CONFIGURATOR_REVISION = 0x1; + + function getRevision() internal pure override returns (uint256) { + return CONFIGURATOR_REVISION; + } + + function initialize(ILendingPoolAddressesProvider provider) public initializer { + addressesProvider = provider; + pool = ILendingPool(addressesProvider.getLendingPool()); + } + + /** + * @dev Initializes reserves in batch + **/ + function batchInitReserve(InitReserveInput[] calldata input) external onlyPoolAdmin { + ILendingPool cachedPool = pool; + for (uint256 i = 0; i < input.length; i++) { + _initReserve(cachedPool, input[i]); + } + } + + function _initReserve(ILendingPool pool, InitReserveInput calldata input) internal { + address aTokenProxyAddress = + _initTokenWithProxy( + input.aTokenImpl, + abi.encodeWithSelector( + IInitializableAToken.initialize.selector, + pool, + input.treasury, + input.underlyingAsset, + IAaveIncentivesController(input.incentivesController), + input.underlyingAssetDecimals, + input.aTokenName, + input.aTokenSymbol, + input.params + ) + ); + + address stableDebtTokenProxyAddress = + _initTokenWithProxy( + input.stableDebtTokenImpl, + abi.encodeWithSelector( + IInitializableDebtToken.initialize.selector, + pool, + input.underlyingAsset, + IAaveIncentivesController(input.incentivesController), + input.underlyingAssetDecimals, + input.stableDebtTokenName, + input.stableDebtTokenSymbol, + input.params + ) + ); + + address variableDebtTokenProxyAddress = + _initTokenWithProxy( + input.variableDebtTokenImpl, + abi.encodeWithSelector( + IInitializableDebtToken.initialize.selector, + pool, + input.underlyingAsset, + IAaveIncentivesController(input.incentivesController), + input.underlyingAssetDecimals, + input.variableDebtTokenName, + input.variableDebtTokenSymbol, + input.params + ) + ); + + pool.initReserve( + input.underlyingAsset, + aTokenProxyAddress, + stableDebtTokenProxyAddress, + variableDebtTokenProxyAddress, + input.interestRateStrategyAddress + ); + + DataTypes.ReserveConfigurationMap memory currentConfig = + pool.getConfiguration(input.underlyingAsset); + + currentConfig.setDecimals(input.underlyingAssetDecimals); + + currentConfig.setActive(true); + currentConfig.setFrozen(false); + + pool.setConfiguration(input.underlyingAsset, currentConfig.data); + + emit ReserveInitialized( + input.underlyingAsset, + aTokenProxyAddress, + stableDebtTokenProxyAddress, + variableDebtTokenProxyAddress, + input.interestRateStrategyAddress + ); + } + + /** + * @dev Updates the aToken implementation for the reserve + **/ + function updateAToken(UpdateATokenInput calldata input) external onlyPoolAdmin { + ILendingPool cachedPool = pool; + + DataTypes.ReserveData memory reserveData = cachedPool.getReserveData(input.asset); + + (, , , uint256 decimals, ) = cachedPool.getConfiguration(input.asset).getParamsMemory(); + + bytes memory encodedCall = abi.encodeWithSelector( + IInitializableAToken.initialize.selector, + cachedPool, + input.treasury, + input.asset, + input.incentivesController, + decimals, + input.name, + input.symbol, + input.params + ); + + _upgradeTokenImplementation( + reserveData.aTokenAddress, + input.implementation, + encodedCall + ); + + emit ATokenUpgraded(input.asset, reserveData.aTokenAddress, input.implementation); + } + + /** + * @dev Updates the stable debt token implementation for the reserve + **/ + function updateStableDebtToken(UpdateDebtTokenInput calldata input) external onlyPoolAdmin { + ILendingPool cachedPool = pool; + + DataTypes.ReserveData memory reserveData = cachedPool.getReserveData(input.asset); + + (, , , uint256 decimals, ) = cachedPool.getConfiguration(input.asset).getParamsMemory(); + + bytes memory encodedCall = abi.encodeWithSelector( + IInitializableDebtToken.initialize.selector, + cachedPool, + input.asset, + input.incentivesController, + decimals, + input.name, + input.symbol, + input.params + ); + + _upgradeTokenImplementation( + reserveData.stableDebtTokenAddress, + input.implementation, + encodedCall + ); + + emit StableDebtTokenUpgraded( + input.asset, + reserveData.stableDebtTokenAddress, + input.implementation + ); + } + + /** + * @dev Updates the variable debt token implementation for the asset + **/ + function updateVariableDebtToken(UpdateDebtTokenInput calldata input) + external + onlyPoolAdmin + { + ILendingPool cachedPool = pool; + + DataTypes.ReserveData memory reserveData = cachedPool.getReserveData(input.asset); + + (, , , uint256 decimals, ) = cachedPool.getConfiguration(input.asset).getParamsMemory(); + + bytes memory encodedCall = abi.encodeWithSelector( + IInitializableDebtToken.initialize.selector, + cachedPool, + input.asset, + input.incentivesController, + decimals, + input.name, + input.symbol, + input.params + ); + + _upgradeTokenImplementation( + reserveData.variableDebtTokenAddress, + input.implementation, + encodedCall + ); + + emit VariableDebtTokenUpgraded( + input.asset, + reserveData.variableDebtTokenAddress, + input.implementation + ); + } + + /** + * @dev Enables borrowing on a reserve + * @param asset The address of the underlying asset of the reserve + * @param stableBorrowRateEnabled True if stable borrow rate needs to be enabled by default on this reserve + **/ + function enableBorrowingOnReserve(address asset, bool stableBorrowRateEnabled) + external + onlyPoolAdmin + { + DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset); + + currentConfig.setBorrowingEnabled(true); + currentConfig.setStableRateBorrowingEnabled(stableBorrowRateEnabled); + + pool.setConfiguration(asset, currentConfig.data); + + emit BorrowingEnabledOnReserve(asset, stableBorrowRateEnabled); + } + + /** + * @dev Disables borrowing on a reserve + * @param asset The address of the underlying asset of the reserve + **/ + function disableBorrowingOnReserve(address asset) external onlyPoolAdmin { + DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset); + + currentConfig.setBorrowingEnabled(false); + + pool.setConfiguration(asset, currentConfig.data); + emit BorrowingDisabledOnReserve(asset); + } + + /** + * @dev Configures the reserve collateralization parameters + * all the values are expressed in percentages with two decimals of precision. A valid value is 10000, which means 100.00% + * @param asset The address of the underlying asset of the reserve + * @param ltv The loan to value of the asset when used as collateral + * @param liquidationThreshold The threshold at which loans using this asset as collateral will be considered undercollateralized + * @param liquidationBonus The bonus liquidators receive to liquidate this asset. The values is always above 100%. A value of 105% + * means the liquidator will receive a 5% bonus + **/ + function configureReserveAsCollateral( + address asset, + uint256 ltv, + uint256 liquidationThreshold, + uint256 liquidationBonus + ) external onlyPoolAdmin { + DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset); + + //validation of the parameters: the LTV can + //only be lower or equal than the liquidation threshold + //(otherwise a loan against the asset would cause instantaneous liquidation) + require(ltv <= liquidationThreshold, Errors.LPC_INVALID_CONFIGURATION); + + if (liquidationThreshold != 0) { + //liquidation bonus must be bigger than 100.00%, otherwise the liquidator would receive less + //collateral than needed to cover the debt + require( + liquidationBonus > PercentageMath.PERCENTAGE_FACTOR, + Errors.LPC_INVALID_CONFIGURATION + ); + + //if threshold * bonus is less than PERCENTAGE_FACTOR, it's guaranteed that at the moment + //a loan is taken there is enough collateral available to cover the liquidation bonus + require( + liquidationThreshold.percentMul(liquidationBonus) <= PercentageMath.PERCENTAGE_FACTOR, + Errors.LPC_INVALID_CONFIGURATION + ); + } else { + require(liquidationBonus == 0, Errors.LPC_INVALID_CONFIGURATION); + //if the liquidation threshold is being set to 0, + // the reserve is being disabled as collateral. To do so, + //we need to ensure no liquidity is deposited + _checkNoLiquidity(asset); + } + + currentConfig.setLtv(ltv); + currentConfig.setLiquidationThreshold(liquidationThreshold); + currentConfig.setLiquidationBonus(liquidationBonus); + + pool.setConfiguration(asset, currentConfig.data); + + emit CollateralConfigurationChanged(asset, ltv, liquidationThreshold, liquidationBonus); + } + + /** + * @dev Enable stable rate borrowing on a reserve + * @param asset The address of the underlying asset of the reserve + **/ + function enableReserveStableRate(address asset) external onlyPoolAdmin { + DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset); + + currentConfig.setStableRateBorrowingEnabled(true); + + pool.setConfiguration(asset, currentConfig.data); + + emit StableRateEnabledOnReserve(asset); + } + + /** + * @dev Disable stable rate borrowing on a reserve + * @param asset The address of the underlying asset of the reserve + **/ + function disableReserveStableRate(address asset) external onlyPoolAdmin { + DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset); + + currentConfig.setStableRateBorrowingEnabled(false); + + pool.setConfiguration(asset, currentConfig.data); + + emit StableRateDisabledOnReserve(asset); + } + + /** + * @dev Activates a reserve + * @param asset The address of the underlying asset of the reserve + **/ + function activateReserve(address asset) external onlyPoolAdmin { + DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset); + + currentConfig.setActive(true); + + pool.setConfiguration(asset, currentConfig.data); + + emit ReserveActivated(asset); + } + + /** + * @dev Deactivates a reserve + * @param asset The address of the underlying asset of the reserve + **/ + function deactivateReserve(address asset) external onlyPoolAdmin { + _checkNoLiquidity(asset); + + DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset); + + currentConfig.setActive(false); + + pool.setConfiguration(asset, currentConfig.data); + + emit ReserveDeactivated(asset); + } + + /** + * @dev Freezes a reserve. A frozen reserve doesn't allow any new deposit, borrow or rate swap + * but allows repayments, liquidations, rate rebalances and withdrawals + * @param asset The address of the underlying asset of the reserve + **/ + function freezeReserve(address asset) external onlyPoolAdmin { + DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset); + + currentConfig.setFrozen(true); + + pool.setConfiguration(asset, currentConfig.data); + + emit ReserveFrozen(asset); + } + + /** + * @dev Unfreezes a reserve + * @param asset The address of the underlying asset of the reserve + **/ + function unfreezeReserve(address asset) external onlyPoolAdmin { + DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset); + + currentConfig.setFrozen(false); + + pool.setConfiguration(asset, currentConfig.data); + + emit ReserveUnfrozen(asset); + } + + /** + * @dev Updates the reserve factor of a reserve + * @param asset The address of the underlying asset of the reserve + * @param reserveFactor The new reserve factor of the reserve + **/ + function setReserveFactor(address asset, uint256 reserveFactor) external onlyPoolAdmin { + DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset); + + currentConfig.setReserveFactor(reserveFactor); + + pool.setConfiguration(asset, currentConfig.data); + + emit ReserveFactorChanged(asset, reserveFactor); + } + + /** + * @dev Sets the interest rate strategy of a reserve + * @param asset The address of the underlying asset of the reserve + * @param rateStrategyAddress The new address of the interest strategy contract + **/ + function setReserveInterestRateStrategyAddress(address asset, address rateStrategyAddress) + external + onlyPoolAdmin + { + pool.setReserveInterestRateStrategyAddress(asset, rateStrategyAddress); + emit ReserveInterestRateStrategyChanged(asset, rateStrategyAddress); + } + + /** + * @dev pauses or unpauses all the actions of the protocol, including aToken transfers + * @param val true if protocol needs to be paused, false otherwise + **/ + function setPoolPause(bool val) external onlyEmergencyAdmin { + pool.setPause(val); + } + + function _initTokenWithProxy(address implementation, bytes memory initParams) + internal + returns (address) + { + InitializableImmutableAdminUpgradeabilityProxy proxy = + new InitializableImmutableAdminUpgradeabilityProxy(address(this)); + + proxy.initialize(implementation, initParams); + + return address(proxy); + } + + function _upgradeTokenImplementation( + address proxyAddress, + address implementation, + bytes memory initParams + ) internal { + InitializableImmutableAdminUpgradeabilityProxy proxy = + InitializableImmutableAdminUpgradeabilityProxy(payable(proxyAddress)); + + proxy.upgradeToAndCall(implementation, initParams); + } + + function _checkNoLiquidity(address asset) internal view { + DataTypes.ReserveData memory reserveData = pool.getReserveData(asset); + + uint256 availableLiquidity = IERC20Detailed(asset).balanceOf(reserveData.aTokenAddress); + + require( + availableLiquidity == 0 && reserveData.currentLiquidityRate == 0, + Errors.LPC_RESERVE_LIQUIDITY_NOT_0 + ); + } +} diff --git a/external/contracts/aave/v2/AaveV2ProtocolDataProvider.sol b/external/contracts/aave/v2/AaveV2ProtocolDataProvider.sol new file mode 100644 index 000000000..76851a75f --- /dev/null +++ b/external/contracts/aave/v2/AaveV2ProtocolDataProvider.sol @@ -0,0 +1,180 @@ +// SPDX-License-Identifier: agpl-3.0 +pragma solidity 0.6.12; +pragma experimental ABIEncoderV2; + +import {IERC20Detailed} from '../dependencies/openzeppelin/contracts/IERC20Detailed.sol'; +import {ILendingPoolAddressesProvider} from '../interfaces/ILendingPoolAddressesProvider.sol'; +import {ILendingPool} from '../interfaces/ILendingPool.sol'; +import {IStableDebtToken} from '../interfaces/IStableDebtToken.sol'; +import {IVariableDebtToken} from '../interfaces/IVariableDebtToken.sol'; +import {ReserveConfiguration} from '../protocol/libraries/configuration/ReserveConfiguration.sol'; +import {UserConfiguration} from '../protocol/libraries/configuration/UserConfiguration.sol'; +import {DataTypes} from '../protocol/libraries/types/DataTypes.sol'; + +contract AaveV2ProtocolDataProvider { + using ReserveConfiguration for DataTypes.ReserveConfigurationMap; + using UserConfiguration for DataTypes.UserConfigurationMap; + + address constant MKR = 0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2; + address constant ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; + + struct TokenData { + string symbol; + address tokenAddress; + } + + ILendingPoolAddressesProvider public immutable ADDRESSES_PROVIDER; + + constructor(ILendingPoolAddressesProvider addressesProvider) public { + ADDRESSES_PROVIDER = addressesProvider; + } + + function getAllReservesTokens() external view returns (TokenData[] memory) { + ILendingPool pool = ILendingPool(ADDRESSES_PROVIDER.getLendingPool()); + address[] memory reserves = pool.getReservesList(); + TokenData[] memory reservesTokens = new TokenData[](reserves.length); + for (uint256 i = 0; i < reserves.length; i++) { + if (reserves[i] == MKR) { + reservesTokens[i] = TokenData({symbol: 'MKR', tokenAddress: reserves[i]}); + continue; + } + if (reserves[i] == ETH) { + reservesTokens[i] = TokenData({symbol: 'ETH', tokenAddress: reserves[i]}); + continue; + } + reservesTokens[i] = TokenData({ + symbol: IERC20Detailed(reserves[i]).symbol(), + tokenAddress: reserves[i] + }); + } + return reservesTokens; + } + + function getAllATokens() external view returns (TokenData[] memory) { + ILendingPool pool = ILendingPool(ADDRESSES_PROVIDER.getLendingPool()); + address[] memory reserves = pool.getReservesList(); + TokenData[] memory aTokens = new TokenData[](reserves.length); + for (uint256 i = 0; i < reserves.length; i++) { + DataTypes.ReserveData memory reserveData = pool.getReserveData(reserves[i]); + aTokens[i] = TokenData({ + symbol: IERC20Detailed(reserveData.aTokenAddress).symbol(), + tokenAddress: reserveData.aTokenAddress + }); + } + return aTokens; + } + + function getReserveConfigurationData(address asset) + external + view + returns ( + uint256 decimals, + uint256 ltv, + uint256 liquidationThreshold, + uint256 liquidationBonus, + uint256 reserveFactor, + bool usageAsCollateralEnabled, + bool borrowingEnabled, + bool stableBorrowRateEnabled, + bool isActive, + bool isFrozen + ) + { + DataTypes.ReserveConfigurationMap memory configuration = + ILendingPool(ADDRESSES_PROVIDER.getLendingPool()).getConfiguration(asset); + + (ltv, liquidationThreshold, liquidationBonus, decimals, reserveFactor) = configuration + .getParamsMemory(); + + (isActive, isFrozen, borrowingEnabled, stableBorrowRateEnabled) = configuration + .getFlagsMemory(); + + usageAsCollateralEnabled = liquidationThreshold > 0; + } + + function getReserveData(address asset) + external + view + returns ( + uint256 availableLiquidity, + uint256 totalStableDebt, + uint256 totalVariableDebt, + uint256 liquidityRate, + uint256 variableBorrowRate, + uint256 stableBorrowRate, + uint256 averageStableBorrowRate, + uint256 liquidityIndex, + uint256 variableBorrowIndex, + uint40 lastUpdateTimestamp + ) + { + DataTypes.ReserveData memory reserve = + ILendingPool(ADDRESSES_PROVIDER.getLendingPool()).getReserveData(asset); + + return ( + IERC20Detailed(asset).balanceOf(reserve.aTokenAddress), + IERC20Detailed(reserve.stableDebtTokenAddress).totalSupply(), + IERC20Detailed(reserve.variableDebtTokenAddress).totalSupply(), + reserve.currentLiquidityRate, + reserve.currentVariableBorrowRate, + reserve.currentStableBorrowRate, + IStableDebtToken(reserve.stableDebtTokenAddress).getAverageStableRate(), + reserve.liquidityIndex, + reserve.variableBorrowIndex, + reserve.lastUpdateTimestamp + ); + } + + function getUserReserveData(address asset, address user) + external + view + returns ( + uint256 currentATokenBalance, + uint256 currentStableDebt, + uint256 currentVariableDebt, + uint256 principalStableDebt, + uint256 scaledVariableDebt, + uint256 stableBorrowRate, + uint256 liquidityRate, + uint40 stableRateLastUpdated, + bool usageAsCollateralEnabled + ) + { + DataTypes.ReserveData memory reserve = + ILendingPool(ADDRESSES_PROVIDER.getLendingPool()).getReserveData(asset); + + DataTypes.UserConfigurationMap memory userConfig = + ILendingPool(ADDRESSES_PROVIDER.getLendingPool()).getUserConfiguration(user); + + currentATokenBalance = IERC20Detailed(reserve.aTokenAddress).balanceOf(user); + currentVariableDebt = IERC20Detailed(reserve.variableDebtTokenAddress).balanceOf(user); + currentStableDebt = IERC20Detailed(reserve.stableDebtTokenAddress).balanceOf(user); + principalStableDebt = IStableDebtToken(reserve.stableDebtTokenAddress).principalBalanceOf(user); + scaledVariableDebt = IVariableDebtToken(reserve.variableDebtTokenAddress).scaledBalanceOf(user); + liquidityRate = reserve.currentLiquidityRate; + stableBorrowRate = IStableDebtToken(reserve.stableDebtTokenAddress).getUserStableRate(user); + stableRateLastUpdated = IStableDebtToken(reserve.stableDebtTokenAddress).getUserLastUpdated( + user + ); + usageAsCollateralEnabled = userConfig.isUsingAsCollateral(reserve.id); + } + + function getReserveTokensAddresses(address asset) + external + view + returns ( + address aTokenAddress, + address stableDebtTokenAddress, + address variableDebtTokenAddress + ) + { + DataTypes.ReserveData memory reserve = + ILendingPool(ADDRESSES_PROVIDER.getLendingPool()).getReserveData(asset); + + return ( + reserve.aTokenAddress, + reserve.stableDebtTokenAddress, + reserve.variableDebtTokenAddress + ); + } +} diff --git a/external/contracts/aave/v2/AaveV2StableDebtToken.sol b/external/contracts/aave/v2/AaveV2StableDebtToken.sol new file mode 100644 index 000000000..77fd4381e --- /dev/null +++ b/external/contracts/aave/v2/AaveV2StableDebtToken.sol @@ -0,0 +1,435 @@ +// SPDX-License-Identifier: agpl-3.0 +pragma solidity 0.6.12; + +import {DebtTokenBase} from './base/DebtTokenBase.sol'; +import {MathUtils} from '../libraries/math/MathUtils.sol'; +import {WadRayMath} from '../libraries/math/WadRayMath.sol'; +import {IStableDebtToken} from '../../interfaces/IStableDebtToken.sol'; +import {ILendingPool} from '../../interfaces/ILendingPool.sol'; +import {IAaveIncentivesController} from '../../interfaces/IAaveIncentivesController.sol'; +import {Errors} from '../libraries/helpers/Errors.sol'; + +/** + * @title StableDebtToken + * @notice Implements a stable debt token to track the borrowing positions of users + * at stable rate mode + * @author Aave + **/ +contract AaveV2StableDebtToken is IStableDebtToken, DebtTokenBase { + using WadRayMath for uint256; + + uint256 public constant DEBT_TOKEN_REVISION = 0x1; + + uint256 internal _avgStableRate; + mapping(address => uint40) internal _timestamps; + mapping(address => uint256) internal _usersStableRate; + uint40 internal _totalSupplyTimestamp; + + ILendingPool internal _pool; + address internal _underlyingAsset; + IAaveIncentivesController internal _incentivesController; + + /** + * @dev Initializes the debt token. + * @param pool The address of the lending pool where this aToken will be used + * @param underlyingAsset The address of the underlying asset of this aToken (E.g. WETH for aWETH) + * @param incentivesController The smart contract managing potential incentives distribution + * @param debtTokenDecimals The decimals of the debtToken, same as the underlying asset's + * @param debtTokenName The name of the token + * @param debtTokenSymbol The symbol of the token + */ + function initialize( + ILendingPool pool, + address underlyingAsset, + IAaveIncentivesController incentivesController, + uint8 debtTokenDecimals, + string memory debtTokenName, + string memory debtTokenSymbol, + bytes calldata params + ) public override initializer { + _setName(debtTokenName); + _setSymbol(debtTokenSymbol); + _setDecimals(debtTokenDecimals); + + _pool = pool; + _underlyingAsset = underlyingAsset; + _incentivesController = incentivesController; + + emit Initialized( + underlyingAsset, + address(pool), + address(incentivesController), + debtTokenDecimals, + debtTokenName, + debtTokenSymbol, + params + ); + } + + /** + * @dev Gets the revision of the stable debt token implementation + * @return The debt token implementation revision + **/ + function getRevision() internal pure virtual override returns (uint256) { + return DEBT_TOKEN_REVISION; + } + + /** + * @dev Returns the average stable rate across all the stable rate debt + * @return the average stable rate + **/ + function getAverageStableRate() external view virtual override returns (uint256) { + return _avgStableRate; + } + + /** + * @dev Returns the timestamp of the last user action + * @return The last update timestamp + **/ + function getUserLastUpdated(address user) external view virtual override returns (uint40) { + return _timestamps[user]; + } + + /** + * @dev Returns the stable rate of the user + * @param user The address of the user + * @return The stable rate of user + **/ + function getUserStableRate(address user) external view virtual override returns (uint256) { + return _usersStableRate[user]; + } + + /** + * @dev Calculates the current user debt balance + * @return The accumulated debt of the user + **/ + function balanceOf(address account) public view virtual override returns (uint256) { + uint256 accountBalance = super.balanceOf(account); + uint256 stableRate = _usersStableRate[account]; + if (accountBalance == 0) { + return 0; + } + uint256 cumulatedInterest = + MathUtils.calculateCompoundedInterest(stableRate, _timestamps[account]); + return accountBalance.rayMul(cumulatedInterest); + } + + struct MintLocalVars { + uint256 previousSupply; + uint256 nextSupply; + uint256 amountInRay; + uint256 newStableRate; + uint256 currentAvgStableRate; + } + + /** + * @dev Mints debt token to the `onBehalfOf` address. + * - Only callable by the LendingPool + * - The resulting rate is the weighted average between the rate of the new debt + * and the rate of the previous debt + * @param user The address receiving the borrowed underlying, being the delegatee in case + * of credit delegate, or same as `onBehalfOf` otherwise + * @param onBehalfOf The address receiving the debt tokens + * @param amount The amount of debt tokens to mint + * @param rate The rate of the debt being minted + **/ + function mint( + address user, + address onBehalfOf, + uint256 amount, + uint256 rate + ) external override onlyLendingPool returns (bool) { + MintLocalVars memory vars; + + if (user != onBehalfOf) { + _decreaseBorrowAllowance(onBehalfOf, user, amount); + } + + (, uint256 currentBalance, uint256 balanceIncrease) = _calculateBalanceIncrease(onBehalfOf); + + vars.previousSupply = totalSupply(); + vars.currentAvgStableRate = _avgStableRate; + vars.nextSupply = _totalSupply = vars.previousSupply.add(amount); + + vars.amountInRay = amount.wadToRay(); + + vars.newStableRate = _usersStableRate[onBehalfOf] + .rayMul(currentBalance.wadToRay()) + .add(vars.amountInRay.rayMul(rate)) + .rayDiv(currentBalance.add(amount).wadToRay()); + + require(vars.newStableRate <= type(uint128).max, Errors.SDT_STABLE_DEBT_OVERFLOW); + _usersStableRate[onBehalfOf] = vars.newStableRate; + + //solium-disable-next-line + _totalSupplyTimestamp = _timestamps[onBehalfOf] = uint40(block.timestamp); + + // Calculates the updated average stable rate + vars.currentAvgStableRate = _avgStableRate = vars + .currentAvgStableRate + .rayMul(vars.previousSupply.wadToRay()) + .add(rate.rayMul(vars.amountInRay)) + .rayDiv(vars.nextSupply.wadToRay()); + + _mint(onBehalfOf, amount.add(balanceIncrease), vars.previousSupply); + + emit Transfer(address(0), onBehalfOf, amount); + + emit Mint( + user, + onBehalfOf, + amount, + currentBalance, + balanceIncrease, + vars.newStableRate, + vars.currentAvgStableRate, + vars.nextSupply + ); + + return currentBalance == 0; + } + + /** + * @dev Burns debt of `user` + * @param user The address of the user getting his debt burned + * @param amount The amount of debt tokens getting burned + **/ + function burn(address user, uint256 amount) external override onlyLendingPool { + (, uint256 currentBalance, uint256 balanceIncrease) = _calculateBalanceIncrease(user); + + uint256 previousSupply = totalSupply(); + uint256 newAvgStableRate = 0; + uint256 nextSupply = 0; + uint256 userStableRate = _usersStableRate[user]; + + // Since the total supply and each single user debt accrue separately, + // there might be accumulation errors so that the last borrower repaying + // mght actually try to repay more than the available debt supply. + // In this case we simply set the total supply and the avg stable rate to 0 + if (previousSupply <= amount) { + _avgStableRate = 0; + _totalSupply = 0; + } else { + nextSupply = _totalSupply = previousSupply.sub(amount); + uint256 firstTerm = _avgStableRate.rayMul(previousSupply.wadToRay()); + uint256 secondTerm = userStableRate.rayMul(amount.wadToRay()); + + // For the same reason described above, when the last user is repaying it might + // happen that user rate * user balance > avg rate * total supply. In that case, + // we simply set the avg rate to 0 + if (secondTerm >= firstTerm) { + newAvgStableRate = _avgStableRate = _totalSupply = 0; + } else { + newAvgStableRate = _avgStableRate = firstTerm.sub(secondTerm).rayDiv(nextSupply.wadToRay()); + } + } + + if (amount == currentBalance) { + _usersStableRate[user] = 0; + _timestamps[user] = 0; + } else { + //solium-disable-next-line + _timestamps[user] = uint40(block.timestamp); + } + //solium-disable-next-line + _totalSupplyTimestamp = uint40(block.timestamp); + + if (balanceIncrease > amount) { + uint256 amountToMint = balanceIncrease.sub(amount); + _mint(user, amountToMint, previousSupply); + emit Mint( + user, + user, + amountToMint, + currentBalance, + balanceIncrease, + userStableRate, + newAvgStableRate, + nextSupply + ); + } else { + uint256 amountToBurn = amount.sub(balanceIncrease); + _burn(user, amountToBurn, previousSupply); + emit Burn(user, amountToBurn, currentBalance, balanceIncrease, newAvgStableRate, nextSupply); + } + + emit Transfer(user, address(0), amount); + } + + /** + * @dev Calculates the increase in balance since the last user interaction + * @param user The address of the user for which the interest is being accumulated + * @return The previous principal balance, the new principal balance and the balance increase + **/ + function _calculateBalanceIncrease(address user) + internal + view + returns ( + uint256, + uint256, + uint256 + ) + { + uint256 previousPrincipalBalance = super.balanceOf(user); + + if (previousPrincipalBalance == 0) { + return (0, 0, 0); + } + + // Calculation of the accrued interest since the last accumulation + uint256 balanceIncrease = balanceOf(user).sub(previousPrincipalBalance); + + return ( + previousPrincipalBalance, + previousPrincipalBalance.add(balanceIncrease), + balanceIncrease + ); + } + + /** + * @dev Returns the principal and total supply, the average borrow rate and the last supply update timestamp + **/ + function getSupplyData() + public + view + override + returns ( + uint256, + uint256, + uint256, + uint40 + ) + { + uint256 avgRate = _avgStableRate; + return (super.totalSupply(), _calcTotalSupply(avgRate), avgRate, _totalSupplyTimestamp); + } + + /** + * @dev Returns the the total supply and the average stable rate + **/ + function getTotalSupplyAndAvgRate() public view override returns (uint256, uint256) { + uint256 avgRate = _avgStableRate; + return (_calcTotalSupply(avgRate), avgRate); + } + + /** + * @dev Returns the total supply + **/ + function totalSupply() public view override returns (uint256) { + return _calcTotalSupply(_avgStableRate); + } + + /** + * @dev Returns the timestamp at which the total supply was updated + **/ + function getTotalSupplyLastUpdated() public view override returns (uint40) { + return _totalSupplyTimestamp; + } + + /** + * @dev Returns the principal debt balance of the user from + * @param user The user's address + * @return The debt balance of the user since the last burn/mint action + **/ + function principalBalanceOf(address user) external view virtual override returns (uint256) { + return super.balanceOf(user); + } + + /** + * @dev Returns the address of the underlying asset of this aToken (E.g. WETH for aWETH) + **/ + function UNDERLYING_ASSET_ADDRESS() public view returns (address) { + return _underlyingAsset; + } + + /** + * @dev Returns the address of the lending pool where this aToken is used + **/ + function POOL() public view returns (ILendingPool) { + return _pool; + } + + /** + * @dev Returns the address of the incentives controller contract + **/ + function getIncentivesController() external view override returns (IAaveIncentivesController) { + return _getIncentivesController(); + } + + /** + * @dev For internal usage in the logic of the parent contracts + **/ + function _getIncentivesController() internal view override returns (IAaveIncentivesController) { + return _incentivesController; + } + + /** + * @dev For internal usage in the logic of the parent contracts + **/ + function _getUnderlyingAssetAddress() internal view override returns (address) { + return _underlyingAsset; + } + + /** + * @dev For internal usage in the logic of the parent contracts + **/ + function _getLendingPool() internal view override returns (ILendingPool) { + return _pool; + } + + /** + * @dev Calculates the total supply + * @param avgRate The average rate at which the total supply increases + * @return The debt balance of the user since the last burn/mint action + **/ + function _calcTotalSupply(uint256 avgRate) internal view virtual returns (uint256) { + uint256 principalSupply = super.totalSupply(); + + if (principalSupply == 0) { + return 0; + } + + uint256 cumulatedInterest = + MathUtils.calculateCompoundedInterest(avgRate, _totalSupplyTimestamp); + + return principalSupply.rayMul(cumulatedInterest); + } + + /** + * @dev Mints stable debt tokens to an user + * @param account The account receiving the debt tokens + * @param amount The amount being minted + * @param oldTotalSupply the total supply before the minting event + **/ + function _mint( + address account, + uint256 amount, + uint256 oldTotalSupply + ) internal { + uint256 oldAccountBalance = _balances[account]; + _balances[account] = oldAccountBalance.add(amount); + + if (address(_incentivesController) != address(0)) { + _incentivesController.handleAction(account, oldTotalSupply, oldAccountBalance); + } + } + + /** + * @dev Burns stable debt tokens of an user + * @param account The user getting his debt burned + * @param amount The amount being burned + * @param oldTotalSupply The total supply before the burning event + **/ + function _burn( + address account, + uint256 amount, + uint256 oldTotalSupply + ) internal { + uint256 oldAccountBalance = _balances[account]; + _balances[account] = oldAccountBalance.sub(amount, Errors.SDT_BURN_EXCEEDS_BALANCE); + + if (address(_incentivesController) != address(0)) { + _incentivesController.handleAction(account, oldTotalSupply, oldAccountBalance); + } + } +} diff --git a/external/contracts/aave/v2/AaveV2StakedTokenIncentivesController.sol b/external/contracts/aave/v2/AaveV2StakedTokenIncentivesController.sol new file mode 100644 index 000000000..64efabecf --- /dev/null +++ b/external/contracts/aave/v2/AaveV2StakedTokenIncentivesController.sol @@ -0,0 +1,218 @@ +// SPDX-License-Identifier: agpl-3.0 +pragma solidity 0.7.5; +pragma experimental ABIEncoderV2; + +import {SafeERC20} from '@aave/aave-stake/contracts/lib/SafeERC20.sol'; +import {SafeMath} from '../lib/SafeMath.sol'; +import {DistributionTypes} from '../lib/DistributionTypes.sol'; +import {VersionedInitializable} from '@aave/aave-stake/contracts/utils/VersionedInitializable.sol'; +import {DistributionManager} from './DistributionManager.sol'; +import {IStakedTokenWithConfig} from '../interfaces/IStakedTokenWithConfig.sol'; +import {IERC20} from '@aave/aave-stake/contracts/interfaces/IERC20.sol'; +import {IScaledBalanceToken} from '../interfaces/IScaledBalanceToken.sol'; +import {IAaveIncentivesController} from '../interfaces/IAaveIncentivesController.sol'; + +/** + * @title StakedTokenIncentivesController + * @notice Distributor contract for rewards to the Aave protocol, using a staked token as rewards asset. + * The contract stakes the rewards before redistributing them to the Aave protocol participants. + * The reference staked token implementation is at https://github.com/aave/aave-stake-v2 + * @author Aave + **/ +contract AaveV2StakedTokenIncentivesController is + IAaveIncentivesController, + VersionedInitializable, + DistributionManager +{ + using SafeMath for uint256; + using SafeERC20 for IERC20; + + uint256 public constant REVISION = 1; + + IStakedTokenWithConfig public immutable STAKE_TOKEN; + + mapping(address => uint256) internal _usersUnclaimedRewards; + + // this mapping allows whitelisted addresses to claim on behalf of others + // useful for contracts that hold tokens to be rewarded but don't have any native logic to claim Liquidity Mining rewards + mapping(address => address) internal _authorizedClaimers; + + modifier onlyAuthorizedClaimers(address claimer, address user) { + require(_authorizedClaimers[user] == claimer, 'CLAIMER_UNAUTHORIZED'); + _; + } + + constructor(IStakedTokenWithConfig stakeToken, address emissionManager) + DistributionManager(emissionManager) + { + STAKE_TOKEN = stakeToken; + } + + /** + * @dev Initialize IStakedTokenIncentivesController + * @param addressesProvider the address of the corresponding addresses provider + **/ + function initialize(address addressesProvider) external initializer { + //approves the safety module to allow staking + IERC20(STAKE_TOKEN.STAKED_TOKEN()).safeApprove(address(STAKE_TOKEN), type(uint256).max); + } + + /// @inheritdoc IAaveIncentivesController + function configureAssets(address[] calldata assets, uint256[] calldata emissionsPerSecond) + external + override + onlyEmissionManager + { + require(assets.length == emissionsPerSecond.length, 'INVALID_CONFIGURATION'); + + DistributionTypes.AssetConfigInput[] memory assetsConfig = + new DistributionTypes.AssetConfigInput[](assets.length); + + for (uint256 i = 0; i < assets.length; i++) { + assetsConfig[i].underlyingAsset = assets[i]; + assetsConfig[i].emissionPerSecond = uint104(emissionsPerSecond[i]); + + require(assetsConfig[i].emissionPerSecond == emissionsPerSecond[i], 'INVALID_CONFIGURATION'); + + assetsConfig[i].totalStaked = IScaledBalanceToken(assets[i]).scaledTotalSupply(); + } + _configureAssets(assetsConfig); + } + + /// @inheritdoc IAaveIncentivesController + function handleAction( + address user, + uint256 totalSupply, + uint256 userBalance + ) external override { + uint256 accruedRewards = _updateUserAssetInternal(user, msg.sender, userBalance, totalSupply); + if (accruedRewards != 0) { + _usersUnclaimedRewards[user] = _usersUnclaimedRewards[user].add(accruedRewards); + emit RewardsAccrued(user, accruedRewards); + } + } + + /// @inheritdoc IAaveIncentivesController + function getRewardsBalance(address[] calldata assets, address user) + external + view + override + returns (uint256) + { + uint256 unclaimedRewards = _usersUnclaimedRewards[user]; + + DistributionTypes.UserStakeInput[] memory userState = + new DistributionTypes.UserStakeInput[](assets.length); + for (uint256 i = 0; i < assets.length; i++) { + userState[i].underlyingAsset = assets[i]; + (userState[i].stakedByUser, userState[i].totalStaked) = IScaledBalanceToken(assets[i]) + .getScaledUserBalanceAndSupply(user); + } + unclaimedRewards = unclaimedRewards.add(_getUnclaimedRewards(user, userState)); + return unclaimedRewards; + } + + /// @inheritdoc IAaveIncentivesController + function claimRewards( + address[] calldata assets, + uint256 amount, + address to + ) external override returns (uint256) { + require(to != address(0), 'INVALID_TO_ADDRESS'); + return _claimRewards(assets, amount, msg.sender, msg.sender, to); + } + + /// @inheritdoc IAaveIncentivesController + function claimRewardsOnBehalf( + address[] calldata assets, + uint256 amount, + address user, + address to + ) external override onlyAuthorizedClaimers(msg.sender, user) returns (uint256) { + require(user != address(0), 'INVALID_USER_ADDRESS'); + require(to != address(0), 'INVALID_TO_ADDRESS'); + return _claimRewards(assets, amount, msg.sender, user, to); + } + + /** + * @dev Claims reward for an user on behalf, on all the assets of the lending pool, accumulating the pending rewards. + * @param amount Amount of rewards to claim + * @param user Address to check and claim rewards + * @param to Address that will be receiving the rewards + * @return Rewards claimed + **/ + + /// @inheritdoc IAaveIncentivesController + function setClaimer(address user, address caller) external override onlyEmissionManager { + _authorizedClaimers[user] = caller; + emit ClaimerSet(user, caller); + } + + /// @inheritdoc IAaveIncentivesController + function getClaimer(address user) external view override returns (address) { + return _authorizedClaimers[user]; + } + + /// @inheritdoc IAaveIncentivesController + function getUserUnclaimedRewards(address _user) external view override returns (uint256) { + return _usersUnclaimedRewards[_user]; + } + + /// @inheritdoc IAaveIncentivesController + function REWARD_TOKEN() external view override returns (address) { + return address(STAKE_TOKEN); + } + + /** + * @dev returns the revision of the implementation contract + */ + function getRevision() internal pure override returns (uint256) { + return REVISION; + } + + /** + * @dev Claims reward for an user on behalf, on all the assets of the lending pool, accumulating the pending rewards. + * @param amount Amount of rewards to claim + * @param user Address to check and claim rewards + * @param to Address that will be receiving the rewards + * @return Rewards claimed + **/ + function _claimRewards( + address[] calldata assets, + uint256 amount, + address claimer, + address user, + address to + ) internal returns (uint256) { + if (amount == 0) { + return 0; + } + uint256 unclaimedRewards = _usersUnclaimedRewards[user]; + + DistributionTypes.UserStakeInput[] memory userState = + new DistributionTypes.UserStakeInput[](assets.length); + for (uint256 i = 0; i < assets.length; i++) { + userState[i].underlyingAsset = assets[i]; + (userState[i].stakedByUser, userState[i].totalStaked) = IScaledBalanceToken(assets[i]) + .getScaledUserBalanceAndSupply(user); + } + + uint256 accruedRewards = _claimRewards(user, userState); + if (accruedRewards != 0) { + unclaimedRewards = unclaimedRewards.add(accruedRewards); + emit RewardsAccrued(user, accruedRewards); + } + + if (unclaimedRewards == 0) { + return 0; + } + + uint256 amountToClaim = amount > unclaimedRewards ? unclaimedRewards : amount; + _usersUnclaimedRewards[user] = unclaimedRewards - amountToClaim; // Safe due to the previous line + + STAKE_TOKEN.stake(to, amountToClaim); + emit RewardsClaimed(user, to, claimer, amountToClaim); + + return amountToClaim; + } +} \ No newline at end of file diff --git a/external/contracts/aave/v2/AaveV2VariableDebtToken.sol b/external/contracts/aave/v2/AaveV2VariableDebtToken.sol new file mode 100644 index 000000000..55c8c9cf8 --- /dev/null +++ b/external/contracts/aave/v2/AaveV2VariableDebtToken.sol @@ -0,0 +1,209 @@ +// SPDX-License-Identifier: agpl-3.0 +pragma solidity 0.6.12; + +import {IVariableDebtToken} from '../../interfaces/IVariableDebtToken.sol'; +import {WadRayMath} from '../libraries/math/WadRayMath.sol'; +import {Errors} from '../libraries/helpers/Errors.sol'; +import {DebtTokenBase} from './base/DebtTokenBase.sol'; +import {ILendingPool} from '../../interfaces/ILendingPool.sol'; +import {IAaveIncentivesController} from '../../interfaces/IAaveIncentivesController.sol'; + +/** + * @title VariableDebtToken + * @notice Implements a variable debt token to track the borrowing positions of users + * at variable rate mode + * @author Aave + **/ +contract AaveV2VariableDebtToken is DebtTokenBase, IVariableDebtToken { + using WadRayMath for uint256; + + uint256 public constant DEBT_TOKEN_REVISION = 0x1; + + ILendingPool internal _pool; + address internal _underlyingAsset; + IAaveIncentivesController internal _incentivesController; + + /** + * @dev Initializes the debt token. + * @param pool The address of the lending pool where this aToken will be used + * @param underlyingAsset The address of the underlying asset of this aToken (E.g. WETH for aWETH) + * @param incentivesController The smart contract managing potential incentives distribution + * @param debtTokenDecimals The decimals of the debtToken, same as the underlying asset's + * @param debtTokenName The name of the token + * @param debtTokenSymbol The symbol of the token + */ + function initialize( + ILendingPool pool, + address underlyingAsset, + IAaveIncentivesController incentivesController, + uint8 debtTokenDecimals, + string memory debtTokenName, + string memory debtTokenSymbol, + bytes calldata params + ) public override initializer { + _setName(debtTokenName); + _setSymbol(debtTokenSymbol); + _setDecimals(debtTokenDecimals); + + _pool = pool; + _underlyingAsset = underlyingAsset; + _incentivesController = incentivesController; + + emit Initialized( + underlyingAsset, + address(pool), + address(incentivesController), + debtTokenDecimals, + debtTokenName, + debtTokenSymbol, + params + ); + } + + /** + * @dev Gets the revision of the stable debt token implementation + * @return The debt token implementation revision + **/ + function getRevision() internal pure virtual override returns (uint256) { + return DEBT_TOKEN_REVISION; + } + + /** + * @dev Calculates the accumulated debt balance of the user + * @return The debt balance of the user + **/ + function balanceOf(address user) public view virtual override returns (uint256) { + uint256 scaledBalance = super.balanceOf(user); + + if (scaledBalance == 0) { + return 0; + } + + return scaledBalance.rayMul(_pool.getReserveNormalizedVariableDebt(_underlyingAsset)); + } + + /** + * @dev Mints debt token to the `onBehalfOf` address + * - Only callable by the LendingPool + * @param user The address receiving the borrowed underlying, being the delegatee in case + * of credit delegate, or same as `onBehalfOf` otherwise + * @param onBehalfOf The address receiving the debt tokens + * @param amount The amount of debt being minted + * @param index The variable debt index of the reserve + * @return `true` if the the previous balance of the user is 0 + **/ + function mint( + address user, + address onBehalfOf, + uint256 amount, + uint256 index + ) external override onlyLendingPool returns (bool) { + if (user != onBehalfOf) { + _decreaseBorrowAllowance(onBehalfOf, user, amount); + } + + uint256 previousBalance = super.balanceOf(onBehalfOf); + uint256 amountScaled = amount.rayDiv(index); + require(amountScaled != 0, Errors.CT_INVALID_MINT_AMOUNT); + + _mint(onBehalfOf, amountScaled); + + emit Transfer(address(0), onBehalfOf, amount); + emit Mint(user, onBehalfOf, amount, index); + + return previousBalance == 0; + } + + /** + * @dev Burns user variable debt + * - Only callable by the LendingPool + * @param user The user whose debt is getting burned + * @param amount The amount getting burned + * @param index The variable debt index of the reserve + **/ + function burn( + address user, + uint256 amount, + uint256 index + ) external override onlyLendingPool { + uint256 amountScaled = amount.rayDiv(index); + require(amountScaled != 0, Errors.CT_INVALID_BURN_AMOUNT); + + _burn(user, amountScaled); + + emit Transfer(user, address(0), amount); + emit Burn(user, amount, index); + } + + /** + * @dev Returns the principal debt balance of the user from + * @return The debt balance of the user since the last burn/mint action + **/ + function scaledBalanceOf(address user) public view virtual override returns (uint256) { + return super.balanceOf(user); + } + + /** + * @dev Returns the total supply of the variable debt token. Represents the total debt accrued by the users + * @return The total supply + **/ + function totalSupply() public view virtual override returns (uint256) { + return super.totalSupply().rayMul(_pool.getReserveNormalizedVariableDebt(_underlyingAsset)); + } + + /** + * @dev Returns the scaled total supply of the variable debt token. Represents sum(debt/index) + * @return the scaled total supply + **/ + function scaledTotalSupply() public view virtual override returns (uint256) { + return super.totalSupply(); + } + + /** + * @dev Returns the principal balance of the user and principal total supply. + * @param user The address of the user + * @return The principal balance of the user + * @return The principal total supply + **/ + function getScaledUserBalanceAndSupply(address user) + external + view + override + returns (uint256, uint256) + { + return (super.balanceOf(user), super.totalSupply()); + } + + /** + * @dev Returns the address of the underlying asset of this aToken (E.g. WETH for aWETH) + **/ + function UNDERLYING_ASSET_ADDRESS() public view returns (address) { + return _underlyingAsset; + } + + /** + * @dev Returns the address of the incentives controller contract + **/ + function getIncentivesController() external view override returns (IAaveIncentivesController) { + return _getIncentivesController(); + } + + /** + * @dev Returns the address of the lending pool where this aToken is used + **/ + function POOL() public view returns (ILendingPool) { + return _pool; + } + + function _getIncentivesController() internal view override returns (IAaveIncentivesController) { + return _incentivesController; + } + + function _getUnderlyingAssetAddress() internal view override returns (address) { + return _underlyingAsset; + } + + function _getLendingPool() internal view override returns (ILendingPool) { + return _pool; + } +} diff --git a/external/contracts/aave/v2/lib/GenericLogic.sol b/external/contracts/aave/v2/lib/GenericLogic.sol new file mode 100644 index 000000000..d4081dda6 --- /dev/null +++ b/external/contracts/aave/v2/lib/GenericLogic.sol @@ -0,0 +1,275 @@ +// SPDX-License-Identifier: agpl-3.0 +pragma solidity 0.6.12; +pragma experimental ABIEncoderV2; + +import {SafeMath} from '../../../dependencies/openzeppelin/contracts/SafeMath.sol'; +import {IERC20} from '../../../dependencies/openzeppelin/contracts/IERC20.sol'; +import {ReserveLogic} from './ReserveLogic.sol'; +import {ReserveConfiguration} from '../configuration/ReserveConfiguration.sol'; +import {UserConfiguration} from '../configuration/UserConfiguration.sol'; +import {WadRayMath} from '../math/WadRayMath.sol'; +import {PercentageMath} from '../math/PercentageMath.sol'; +import {IPriceOracleGetter} from '../../../interfaces/IPriceOracleGetter.sol'; +import {DataTypes} from '../types/DataTypes.sol'; + +/** + * @title GenericLogic library + * @author Aave + * @title Implements protocol-level logic to calculate and validate the state of a user + */ +library GenericLogic { + using ReserveLogic for DataTypes.ReserveData; + using SafeMath for uint256; + using WadRayMath for uint256; + using PercentageMath for uint256; + using ReserveConfiguration for DataTypes.ReserveConfigurationMap; + using UserConfiguration for DataTypes.UserConfigurationMap; + + uint256 public constant HEALTH_FACTOR_LIQUIDATION_THRESHOLD = 1 ether; + + struct balanceDecreaseAllowedLocalVars { + uint256 decimals; + uint256 liquidationThreshold; + uint256 totalCollateralInETH; + uint256 totalDebtInETH; + uint256 avgLiquidationThreshold; + uint256 amountToDecreaseInETH; + uint256 collateralBalanceAfterDecrease; + uint256 liquidationThresholdAfterDecrease; + uint256 healthFactorAfterDecrease; + bool reserveUsageAsCollateralEnabled; + } + + /** + * @dev Checks if a specific balance decrease is allowed + * (i.e. doesn't bring the user borrow position health factor under HEALTH_FACTOR_LIQUIDATION_THRESHOLD) + * @param asset The address of the underlying asset of the reserve + * @param user The address of the user + * @param amount The amount to decrease + * @param reservesData The data of all the reserves + * @param userConfig The user configuration + * @param reserves The list of all the active reserves + * @param oracle The address of the oracle contract + * @return true if the decrease of the balance is allowed + **/ + function balanceDecreaseAllowed( + address asset, + address user, + uint256 amount, + mapping(address => DataTypes.ReserveData) storage reservesData, + DataTypes.UserConfigurationMap calldata userConfig, + mapping(uint256 => address) storage reserves, + uint256 reservesCount, + address oracle + ) external view returns (bool) { + if (!userConfig.isBorrowingAny() || !userConfig.isUsingAsCollateral(reservesData[asset].id)) { + return true; + } + + balanceDecreaseAllowedLocalVars memory vars; + + (, vars.liquidationThreshold, , vars.decimals, ) = reservesData[asset] + .configuration + .getParams(); + + if (vars.liquidationThreshold == 0) { + return true; + } + + ( + vars.totalCollateralInETH, + vars.totalDebtInETH, + , + vars.avgLiquidationThreshold, + + ) = calculateUserAccountData(user, reservesData, userConfig, reserves, reservesCount, oracle); + + if (vars.totalDebtInETH == 0) { + return true; + } + + vars.amountToDecreaseInETH = IPriceOracleGetter(oracle).getAssetPrice(asset).mul(amount).div( + 10**vars.decimals + ); + + vars.collateralBalanceAfterDecrease = vars.totalCollateralInETH.sub(vars.amountToDecreaseInETH); + + //if there is a borrow, there can't be 0 collateral + if (vars.collateralBalanceAfterDecrease == 0) { + return false; + } + + vars.liquidationThresholdAfterDecrease = vars + .totalCollateralInETH + .mul(vars.avgLiquidationThreshold) + .sub(vars.amountToDecreaseInETH.mul(vars.liquidationThreshold)) + .div(vars.collateralBalanceAfterDecrease); + + uint256 healthFactorAfterDecrease = + calculateHealthFactorFromBalances( + vars.collateralBalanceAfterDecrease, + vars.totalDebtInETH, + vars.liquidationThresholdAfterDecrease + ); + + return healthFactorAfterDecrease >= GenericLogic.HEALTH_FACTOR_LIQUIDATION_THRESHOLD; + } + + struct CalculateUserAccountDataVars { + uint256 reserveUnitPrice; + uint256 tokenUnit; + uint256 compoundedLiquidityBalance; + uint256 compoundedBorrowBalance; + uint256 decimals; + uint256 ltv; + uint256 liquidationThreshold; + uint256 i; + uint256 healthFactor; + uint256 totalCollateralInETH; + uint256 totalDebtInETH; + uint256 avgLtv; + uint256 avgLiquidationThreshold; + uint256 reservesLength; + bool healthFactorBelowThreshold; + address currentReserveAddress; + bool usageAsCollateralEnabled; + bool userUsesReserveAsCollateral; + } + + /** + * @dev Calculates the user data across the reserves. + * this includes the total liquidity/collateral/borrow balances in ETH, + * the average Loan To Value, the average Liquidation Ratio, and the Health factor. + * @param user The address of the user + * @param reservesData Data of all the reserves + * @param userConfig The configuration of the user + * @param reserves The list of the available reserves + * @param oracle The price oracle address + * @return The total collateral and total debt of the user in ETH, the avg ltv, liquidation threshold and the HF + **/ + function calculateUserAccountData( + address user, + mapping(address => DataTypes.ReserveData) storage reservesData, + DataTypes.UserConfigurationMap memory userConfig, + mapping(uint256 => address) storage reserves, + uint256 reservesCount, + address oracle + ) + internal + view + returns ( + uint256, + uint256, + uint256, + uint256, + uint256 + ) + { + CalculateUserAccountDataVars memory vars; + + if (userConfig.isEmpty()) { + return (0, 0, 0, 0, uint256(-1)); + } + for (vars.i = 0; vars.i < reservesCount; vars.i++) { + if (!userConfig.isUsingAsCollateralOrBorrowing(vars.i)) { + continue; + } + + vars.currentReserveAddress = reserves[vars.i]; + DataTypes.ReserveData storage currentReserve = reservesData[vars.currentReserveAddress]; + + (vars.ltv, vars.liquidationThreshold, , vars.decimals, ) = currentReserve + .configuration + .getParams(); + + vars.tokenUnit = 10**vars.decimals; + vars.reserveUnitPrice = IPriceOracleGetter(oracle).getAssetPrice(vars.currentReserveAddress); + + if (vars.liquidationThreshold != 0 && userConfig.isUsingAsCollateral(vars.i)) { + vars.compoundedLiquidityBalance = IERC20(currentReserve.aTokenAddress).balanceOf(user); + + uint256 liquidityBalanceETH = + vars.reserveUnitPrice.mul(vars.compoundedLiquidityBalance).div(vars.tokenUnit); + + vars.totalCollateralInETH = vars.totalCollateralInETH.add(liquidityBalanceETH); + + vars.avgLtv = vars.avgLtv.add(liquidityBalanceETH.mul(vars.ltv)); + vars.avgLiquidationThreshold = vars.avgLiquidationThreshold.add( + liquidityBalanceETH.mul(vars.liquidationThreshold) + ); + } + + if (userConfig.isBorrowing(vars.i)) { + vars.compoundedBorrowBalance = IERC20(currentReserve.stableDebtTokenAddress).balanceOf( + user + ); + vars.compoundedBorrowBalance = vars.compoundedBorrowBalance.add( + IERC20(currentReserve.variableDebtTokenAddress).balanceOf(user) + ); + + vars.totalDebtInETH = vars.totalDebtInETH.add( + vars.reserveUnitPrice.mul(vars.compoundedBorrowBalance).div(vars.tokenUnit) + ); + } + } + + vars.avgLtv = vars.totalCollateralInETH > 0 ? vars.avgLtv.div(vars.totalCollateralInETH) : 0; + vars.avgLiquidationThreshold = vars.totalCollateralInETH > 0 + ? vars.avgLiquidationThreshold.div(vars.totalCollateralInETH) + : 0; + + vars.healthFactor = calculateHealthFactorFromBalances( + vars.totalCollateralInETH, + vars.totalDebtInETH, + vars.avgLiquidationThreshold + ); + return ( + vars.totalCollateralInETH, + vars.totalDebtInETH, + vars.avgLtv, + vars.avgLiquidationThreshold, + vars.healthFactor + ); + } + + /** + * @dev Calculates the health factor from the corresponding balances + * @param totalCollateralInETH The total collateral in ETH + * @param totalDebtInETH The total debt in ETH + * @param liquidationThreshold The avg liquidation threshold + * @return The health factor calculated from the balances provided + **/ + function calculateHealthFactorFromBalances( + uint256 totalCollateralInETH, + uint256 totalDebtInETH, + uint256 liquidationThreshold + ) internal pure returns (uint256) { + if (totalDebtInETH == 0) return uint256(-1); + + return (totalCollateralInETH.percentMul(liquidationThreshold)).wadDiv(totalDebtInETH); + } + + /** + * @dev Calculates the equivalent amount in ETH that an user can borrow, depending on the available collateral and the + * average Loan To Value + * @param totalCollateralInETH The total collateral in ETH + * @param totalDebtInETH The total borrow balance + * @param ltv The average loan to value + * @return the amount available to borrow in ETH for the user + **/ + + function calculateAvailableBorrowsETH( + uint256 totalCollateralInETH, + uint256 totalDebtInETH, + uint256 ltv + ) internal pure returns (uint256) { + uint256 availableBorrowsETH = totalCollateralInETH.percentMul(ltv); + + if (availableBorrowsETH < totalDebtInETH) { + return 0; + } + + availableBorrowsETH = availableBorrowsETH.sub(totalDebtInETH); + return availableBorrowsETH; + } +} diff --git a/external/contracts/aave/v2/lib/ReserveLogic.sol b/external/contracts/aave/v2/lib/ReserveLogic.sol new file mode 100644 index 000000000..2b5b2cf4b --- /dev/null +++ b/external/contracts/aave/v2/lib/ReserveLogic.sol @@ -0,0 +1,373 @@ +// SPDX-License-Identifier: agpl-3.0 +pragma solidity 0.6.12; + +import {SafeMath} from '../../../dependencies/openzeppelin/contracts/SafeMath.sol'; +import {IERC20} from '../../../dependencies/openzeppelin/contracts/IERC20.sol'; +import {SafeERC20} from '../../../dependencies/openzeppelin/contracts/SafeERC20.sol'; +import {IAToken} from '../../../interfaces/IAToken.sol'; +import {IStableDebtToken} from '../../../interfaces/IStableDebtToken.sol'; +import {IVariableDebtToken} from '../../../interfaces/IVariableDebtToken.sol'; +import {IReserveInterestRateStrategy} from '../../../interfaces/IReserveInterestRateStrategy.sol'; +import {ReserveConfiguration} from '../configuration/ReserveConfiguration.sol'; +import {MathUtils} from '../math/MathUtils.sol'; +import {WadRayMath} from '../math/WadRayMath.sol'; +import {PercentageMath} from '../math/PercentageMath.sol'; +import {Errors} from '../helpers/Errors.sol'; +import {DataTypes} from '../types/DataTypes.sol'; + +/** + * @title ReserveLogic library + * @author Aave + * @notice Implements the logic to update the reserves state + */ +library ReserveLogic { + using SafeMath for uint256; + using WadRayMath for uint256; + using PercentageMath for uint256; + using SafeERC20 for IERC20; + + /** + * @dev Emitted when the state of a reserve is updated + * @param asset The address of the underlying asset of the reserve + * @param liquidityRate The new liquidity rate + * @param stableBorrowRate The new stable borrow rate + * @param variableBorrowRate The new variable borrow rate + * @param liquidityIndex The new liquidity index + * @param variableBorrowIndex The new variable borrow index + **/ + event ReserveDataUpdated( + address indexed asset, + uint256 liquidityRate, + uint256 stableBorrowRate, + uint256 variableBorrowRate, + uint256 liquidityIndex, + uint256 variableBorrowIndex + ); + + using ReserveLogic for DataTypes.ReserveData; + using ReserveConfiguration for DataTypes.ReserveConfigurationMap; + + /** + * @dev Returns the ongoing normalized income for the reserve + * A value of 1e27 means there is no income. As time passes, the income is accrued + * A value of 2*1e27 means for each unit of asset one unit of income has been accrued + * @param reserve The reserve object + * @return the normalized income. expressed in ray + **/ + function getNormalizedIncome(DataTypes.ReserveData storage reserve) + internal + view + returns (uint256) + { + uint40 timestamp = reserve.lastUpdateTimestamp; + + //solium-disable-next-line + if (timestamp == uint40(block.timestamp)) { + //if the index was updated in the same block, no need to perform any calculation + return reserve.liquidityIndex; + } + + uint256 cumulated = + MathUtils.calculateLinearInterest(reserve.currentLiquidityRate, timestamp).rayMul( + reserve.liquidityIndex + ); + + return cumulated; + } + + /** + * @dev Returns the ongoing normalized variable debt for the reserve + * A value of 1e27 means there is no debt. As time passes, the income is accrued + * A value of 2*1e27 means that for each unit of debt, one unit worth of interest has been accumulated + * @param reserve The reserve object + * @return The normalized variable debt. expressed in ray + **/ + function getNormalizedDebt(DataTypes.ReserveData storage reserve) + internal + view + returns (uint256) + { + uint40 timestamp = reserve.lastUpdateTimestamp; + + //solium-disable-next-line + if (timestamp == uint40(block.timestamp)) { + //if the index was updated in the same block, no need to perform any calculation + return reserve.variableBorrowIndex; + } + + uint256 cumulated = + MathUtils.calculateCompoundedInterest(reserve.currentVariableBorrowRate, timestamp).rayMul( + reserve.variableBorrowIndex + ); + + return cumulated; + } + + /** + * @dev Updates the liquidity cumulative index and the variable borrow index. + * @param reserve the reserve object + **/ + function updateState(DataTypes.ReserveData storage reserve) internal { + uint256 scaledVariableDebt = + IVariableDebtToken(reserve.variableDebtTokenAddress).scaledTotalSupply(); + uint256 previousVariableBorrowIndex = reserve.variableBorrowIndex; + uint256 previousLiquidityIndex = reserve.liquidityIndex; + uint40 lastUpdatedTimestamp = reserve.lastUpdateTimestamp; + + (uint256 newLiquidityIndex, uint256 newVariableBorrowIndex) = + _updateIndexes( + reserve, + scaledVariableDebt, + previousLiquidityIndex, + previousVariableBorrowIndex, + lastUpdatedTimestamp + ); + + _mintToTreasury( + reserve, + scaledVariableDebt, + previousVariableBorrowIndex, + newLiquidityIndex, + newVariableBorrowIndex, + lastUpdatedTimestamp + ); + } + + /** + * @dev Accumulates a predefined amount of asset to the reserve as a fixed, instantaneous income. Used for example to accumulate + * the flashloan fee to the reserve, and spread it between all the depositors + * @param reserve The reserve object + * @param totalLiquidity The total liquidity available in the reserve + * @param amount The amount to accomulate + **/ + function cumulateToLiquidityIndex( + DataTypes.ReserveData storage reserve, + uint256 totalLiquidity, + uint256 amount + ) internal { + uint256 amountToLiquidityRatio = amount.wadToRay().rayDiv(totalLiquidity.wadToRay()); + + uint256 result = amountToLiquidityRatio.add(WadRayMath.ray()); + + result = result.rayMul(reserve.liquidityIndex); + require(result <= type(uint128).max, Errors.RL_LIQUIDITY_INDEX_OVERFLOW); + + reserve.liquidityIndex = uint128(result); + } + + /** + * @dev Initializes a reserve + * @param reserve The reserve object + * @param aTokenAddress The address of the overlying atoken contract + * @param interestRateStrategyAddress The address of the interest rate strategy contract + **/ + function init( + DataTypes.ReserveData storage reserve, + address aTokenAddress, + address stableDebtTokenAddress, + address variableDebtTokenAddress, + address interestRateStrategyAddress + ) external { + require(reserve.aTokenAddress == address(0), Errors.RL_RESERVE_ALREADY_INITIALIZED); + + reserve.liquidityIndex = uint128(WadRayMath.ray()); + reserve.variableBorrowIndex = uint128(WadRayMath.ray()); + reserve.aTokenAddress = aTokenAddress; + reserve.stableDebtTokenAddress = stableDebtTokenAddress; + reserve.variableDebtTokenAddress = variableDebtTokenAddress; + reserve.interestRateStrategyAddress = interestRateStrategyAddress; + } + + struct UpdateInterestRatesLocalVars { + address stableDebtTokenAddress; + uint256 availableLiquidity; + uint256 totalStableDebt; + uint256 newLiquidityRate; + uint256 newStableRate; + uint256 newVariableRate; + uint256 avgStableRate; + uint256 totalVariableDebt; + } + + /** + * @dev Updates the reserve current stable borrow rate, the current variable borrow rate and the current liquidity rate + * @param reserve The address of the reserve to be updated + * @param liquidityAdded The amount of liquidity added to the protocol (deposit or repay) in the previous action + * @param liquidityTaken The amount of liquidity taken from the protocol (redeem or borrow) + **/ + function updateInterestRates( + DataTypes.ReserveData storage reserve, + address reserveAddress, + address aTokenAddress, + uint256 liquidityAdded, + uint256 liquidityTaken + ) internal { + UpdateInterestRatesLocalVars memory vars; + + vars.stableDebtTokenAddress = reserve.stableDebtTokenAddress; + + (vars.totalStableDebt, vars.avgStableRate) = IStableDebtToken(vars.stableDebtTokenAddress) + .getTotalSupplyAndAvgRate(); + + //calculates the total variable debt locally using the scaled total supply instead + //of totalSupply(), as it's noticeably cheaper. Also, the index has been + //updated by the previous updateState() call + vars.totalVariableDebt = IVariableDebtToken(reserve.variableDebtTokenAddress) + .scaledTotalSupply() + .rayMul(reserve.variableBorrowIndex); + + ( + vars.newLiquidityRate, + vars.newStableRate, + vars.newVariableRate + ) = IReserveInterestRateStrategy(reserve.interestRateStrategyAddress).calculateInterestRates( + reserveAddress, + aTokenAddress, + liquidityAdded, + liquidityTaken, + vars.totalStableDebt, + vars.totalVariableDebt, + vars.avgStableRate, + reserve.configuration.getReserveFactor() + ); + require(vars.newLiquidityRate <= type(uint128).max, Errors.RL_LIQUIDITY_RATE_OVERFLOW); + require(vars.newStableRate <= type(uint128).max, Errors.RL_STABLE_BORROW_RATE_OVERFLOW); + require(vars.newVariableRate <= type(uint128).max, Errors.RL_VARIABLE_BORROW_RATE_OVERFLOW); + + reserve.currentLiquidityRate = uint128(vars.newLiquidityRate); + reserve.currentStableBorrowRate = uint128(vars.newStableRate); + reserve.currentVariableBorrowRate = uint128(vars.newVariableRate); + + emit ReserveDataUpdated( + reserveAddress, + vars.newLiquidityRate, + vars.newStableRate, + vars.newVariableRate, + reserve.liquidityIndex, + reserve.variableBorrowIndex + ); + } + + struct MintToTreasuryLocalVars { + uint256 currentStableDebt; + uint256 principalStableDebt; + uint256 previousStableDebt; + uint256 currentVariableDebt; + uint256 previousVariableDebt; + uint256 avgStableRate; + uint256 cumulatedStableInterest; + uint256 totalDebtAccrued; + uint256 amountToMint; + uint256 reserveFactor; + uint40 stableSupplyUpdatedTimestamp; + } + + /** + * @dev Mints part of the repaid interest to the reserve treasury as a function of the reserveFactor for the + * specific asset. + * @param reserve The reserve reserve to be updated + * @param scaledVariableDebt The current scaled total variable debt + * @param previousVariableBorrowIndex The variable borrow index before the last accumulation of the interest + * @param newLiquidityIndex The new liquidity index + * @param newVariableBorrowIndex The variable borrow index after the last accumulation of the interest + **/ + function _mintToTreasury( + DataTypes.ReserveData storage reserve, + uint256 scaledVariableDebt, + uint256 previousVariableBorrowIndex, + uint256 newLiquidityIndex, + uint256 newVariableBorrowIndex, + uint40 timestamp + ) internal { + MintToTreasuryLocalVars memory vars; + + vars.reserveFactor = reserve.configuration.getReserveFactor(); + + if (vars.reserveFactor == 0) { + return; + } + + //fetching the principal, total stable debt and the avg stable rate + ( + vars.principalStableDebt, + vars.currentStableDebt, + vars.avgStableRate, + vars.stableSupplyUpdatedTimestamp + ) = IStableDebtToken(reserve.stableDebtTokenAddress).getSupplyData(); + + //calculate the last principal variable debt + vars.previousVariableDebt = scaledVariableDebt.rayMul(previousVariableBorrowIndex); + + //calculate the new total supply after accumulation of the index + vars.currentVariableDebt = scaledVariableDebt.rayMul(newVariableBorrowIndex); + + //calculate the stable debt until the last timestamp update + vars.cumulatedStableInterest = MathUtils.calculateCompoundedInterest( + vars.avgStableRate, + vars.stableSupplyUpdatedTimestamp, + timestamp + ); + + vars.previousStableDebt = vars.principalStableDebt.rayMul(vars.cumulatedStableInterest); + + //debt accrued is the sum of the current debt minus the sum of the debt at the last update + vars.totalDebtAccrued = vars + .currentVariableDebt + .add(vars.currentStableDebt) + .sub(vars.previousVariableDebt) + .sub(vars.previousStableDebt); + + vars.amountToMint = vars.totalDebtAccrued.percentMul(vars.reserveFactor); + + if (vars.amountToMint != 0) { + IAToken(reserve.aTokenAddress).mintToTreasury(vars.amountToMint, newLiquidityIndex); + } + } + + /** + * @dev Updates the reserve indexes and the timestamp of the update + * @param reserve The reserve reserve to be updated + * @param scaledVariableDebt The scaled variable debt + * @param liquidityIndex The last stored liquidity index + * @param variableBorrowIndex The last stored variable borrow index + **/ + function _updateIndexes( + DataTypes.ReserveData storage reserve, + uint256 scaledVariableDebt, + uint256 liquidityIndex, + uint256 variableBorrowIndex, + uint40 timestamp + ) internal returns (uint256, uint256) { + uint256 currentLiquidityRate = reserve.currentLiquidityRate; + + uint256 newLiquidityIndex = liquidityIndex; + uint256 newVariableBorrowIndex = variableBorrowIndex; + + //only cumulating if there is any income being produced + if (currentLiquidityRate > 0) { + uint256 cumulatedLiquidityInterest = + MathUtils.calculateLinearInterest(currentLiquidityRate, timestamp); + newLiquidityIndex = cumulatedLiquidityInterest.rayMul(liquidityIndex); + require(newLiquidityIndex <= type(uint128).max, Errors.RL_LIQUIDITY_INDEX_OVERFLOW); + + reserve.liquidityIndex = uint128(newLiquidityIndex); + + //as the liquidity rate might come only from stable rate loans, we need to ensure + //that there is actual variable debt before accumulating + if (scaledVariableDebt != 0) { + uint256 cumulatedVariableBorrowInterest = + MathUtils.calculateCompoundedInterest(reserve.currentVariableBorrowRate, timestamp); + newVariableBorrowIndex = cumulatedVariableBorrowInterest.rayMul(variableBorrowIndex); + require( + newVariableBorrowIndex <= type(uint128).max, + Errors.RL_VARIABLE_BORROW_INDEX_OVERFLOW + ); + reserve.variableBorrowIndex = uint128(newVariableBorrowIndex); + } + } + + //solium-disable-next-line + reserve.lastUpdateTimestamp = uint40(block.timestamp); + return (newLiquidityIndex, newVariableBorrowIndex); + } +} diff --git a/external/contracts/aave/v2/lib/ValidationLogic.sol b/external/contracts/aave/v2/lib/ValidationLogic.sol new file mode 100644 index 000000000..080b792d3 --- /dev/null +++ b/external/contracts/aave/v2/lib/ValidationLogic.sol @@ -0,0 +1,469 @@ +// SPDX-License-Identifier: agpl-3.0 +pragma solidity 0.6.12; +pragma experimental ABIEncoderV2; + +import {SafeMath} from '../../../dependencies/openzeppelin/contracts/SafeMath.sol'; +import {IERC20} from '../../../dependencies/openzeppelin/contracts/IERC20.sol'; +import {ReserveLogic} from './ReserveLogic.sol'; +import {GenericLogic} from './GenericLogic.sol'; +import {WadRayMath} from '../math/WadRayMath.sol'; +import {PercentageMath} from '../math/PercentageMath.sol'; +import {SafeERC20} from '../../../dependencies/openzeppelin/contracts/SafeERC20.sol'; +import {ReserveConfiguration} from '../configuration/ReserveConfiguration.sol'; +import {UserConfiguration} from '../configuration/UserConfiguration.sol'; +import {Errors} from '../helpers/Errors.sol'; +import {Helpers} from '../helpers/Helpers.sol'; +import {IReserveInterestRateStrategy} from '../../../interfaces/IReserveInterestRateStrategy.sol'; +import {DataTypes} from '../types/DataTypes.sol'; + +/** + * @title ReserveLogic library + * @author Aave + * @notice Implements functions to validate the different actions of the protocol + */ +library ValidationLogic { + using ReserveLogic for DataTypes.ReserveData; + using SafeMath for uint256; + using WadRayMath for uint256; + using PercentageMath for uint256; + using SafeERC20 for IERC20; + using ReserveConfiguration for DataTypes.ReserveConfigurationMap; + using UserConfiguration for DataTypes.UserConfigurationMap; + + uint256 public constant REBALANCE_UP_LIQUIDITY_RATE_THRESHOLD = 4000; + uint256 public constant REBALANCE_UP_USAGE_RATIO_THRESHOLD = 0.95 * 1e27; //usage ratio of 95% + + /** + * @dev Validates a deposit action + * @param reserve The reserve object on which the user is depositing + * @param amount The amount to be deposited + */ + function validateDeposit(DataTypes.ReserveData storage reserve, uint256 amount) external view { + (bool isActive, bool isFrozen, , ) = reserve.configuration.getFlags(); + + require(amount != 0, Errors.VL_INVALID_AMOUNT); + require(isActive, Errors.VL_NO_ACTIVE_RESERVE); + require(!isFrozen, Errors.VL_RESERVE_FROZEN); + } + + /** + * @dev Validates a withdraw action + * @param reserveAddress The address of the reserve + * @param amount The amount to be withdrawn + * @param userBalance The balance of the user + * @param reservesData The reserves state + * @param userConfig The user configuration + * @param reserves The addresses of the reserves + * @param reservesCount The number of reserves + * @param oracle The price oracle + */ + function validateWithdraw( + address reserveAddress, + uint256 amount, + uint256 userBalance, + mapping(address => DataTypes.ReserveData) storage reservesData, + DataTypes.UserConfigurationMap storage userConfig, + mapping(uint256 => address) storage reserves, + uint256 reservesCount, + address oracle + ) external view { + require(amount != 0, Errors.VL_INVALID_AMOUNT); + require(amount <= userBalance, Errors.VL_NOT_ENOUGH_AVAILABLE_USER_BALANCE); + + (bool isActive, , , ) = reservesData[reserveAddress].configuration.getFlags(); + require(isActive, Errors.VL_NO_ACTIVE_RESERVE); + + require( + GenericLogic.balanceDecreaseAllowed( + reserveAddress, + msg.sender, + amount, + reservesData, + userConfig, + reserves, + reservesCount, + oracle + ), + Errors.VL_TRANSFER_NOT_ALLOWED + ); + } + + struct ValidateBorrowLocalVars { + uint256 currentLtv; + uint256 currentLiquidationThreshold; + uint256 amountOfCollateralNeededETH; + uint256 userCollateralBalanceETH; + uint256 userBorrowBalanceETH; + uint256 availableLiquidity; + uint256 healthFactor; + bool isActive; + bool isFrozen; + bool borrowingEnabled; + bool stableRateBorrowingEnabled; + } + + /** + * @dev Validates a borrow action + * @param asset The address of the asset to borrow + * @param reserve The reserve state from which the user is borrowing + * @param userAddress The address of the user + * @param amount The amount to be borrowed + * @param amountInETH The amount to be borrowed, in ETH + * @param interestRateMode The interest rate mode at which the user is borrowing + * @param maxStableLoanPercent The max amount of the liquidity that can be borrowed at stable rate, in percentage + * @param reservesData The state of all the reserves + * @param userConfig The state of the user for the specific reserve + * @param reserves The addresses of all the active reserves + * @param oracle The price oracle + */ + + function validateBorrow( + address asset, + DataTypes.ReserveData storage reserve, + address userAddress, + uint256 amount, + uint256 amountInETH, + uint256 interestRateMode, + uint256 maxStableLoanPercent, + mapping(address => DataTypes.ReserveData) storage reservesData, + DataTypes.UserConfigurationMap storage userConfig, + mapping(uint256 => address) storage reserves, + uint256 reservesCount, + address oracle + ) external view { + ValidateBorrowLocalVars memory vars; + + (vars.isActive, vars.isFrozen, vars.borrowingEnabled, vars.stableRateBorrowingEnabled) = reserve + .configuration + .getFlags(); + + require(vars.isActive, Errors.VL_NO_ACTIVE_RESERVE); + require(!vars.isFrozen, Errors.VL_RESERVE_FROZEN); + require(amount != 0, Errors.VL_INVALID_AMOUNT); + + require(vars.borrowingEnabled, Errors.VL_BORROWING_NOT_ENABLED); + + //validate interest rate mode + require( + uint256(DataTypes.InterestRateMode.VARIABLE) == interestRateMode || + uint256(DataTypes.InterestRateMode.STABLE) == interestRateMode, + Errors.VL_INVALID_INTEREST_RATE_MODE_SELECTED + ); + + ( + vars.userCollateralBalanceETH, + vars.userBorrowBalanceETH, + vars.currentLtv, + vars.currentLiquidationThreshold, + vars.healthFactor + ) = GenericLogic.calculateUserAccountData( + userAddress, + reservesData, + userConfig, + reserves, + reservesCount, + oracle + ); + + require(vars.userCollateralBalanceETH > 0, Errors.VL_COLLATERAL_BALANCE_IS_0); + + require( + vars.healthFactor > GenericLogic.HEALTH_FACTOR_LIQUIDATION_THRESHOLD, + Errors.VL_HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD + ); + + //add the current already borrowed amount to the amount requested to calculate the total collateral needed. + vars.amountOfCollateralNeededETH = vars.userBorrowBalanceETH.add(amountInETH).percentDiv( + vars.currentLtv + ); //LTV is calculated in percentage + + require( + vars.amountOfCollateralNeededETH <= vars.userCollateralBalanceETH, + Errors.VL_COLLATERAL_CANNOT_COVER_NEW_BORROW + ); + + /** + * Following conditions need to be met if the user is borrowing at a stable rate: + * 1. Reserve must be enabled for stable rate borrowing + * 2. Users cannot borrow from the reserve if their collateral is (mostly) the same currency + * they are borrowing, to prevent abuses. + * 3. Users will be able to borrow only a portion of the total available liquidity + **/ + + if (interestRateMode == uint256(DataTypes.InterestRateMode.STABLE)) { + //check if the borrow mode is stable and if stable rate borrowing is enabled on this reserve + + require(vars.stableRateBorrowingEnabled, Errors.VL_STABLE_BORROWING_NOT_ENABLED); + + require( + !userConfig.isUsingAsCollateral(reserve.id) || + reserve.configuration.getLtv() == 0 || + amount > IERC20(reserve.aTokenAddress).balanceOf(userAddress), + Errors.VL_COLLATERAL_SAME_AS_BORROWING_CURRENCY + ); + + vars.availableLiquidity = IERC20(asset).balanceOf(reserve.aTokenAddress); + + //calculate the max available loan size in stable rate mode as a percentage of the + //available liquidity + uint256 maxLoanSizeStable = vars.availableLiquidity.percentMul(maxStableLoanPercent); + + require(amount <= maxLoanSizeStable, Errors.VL_AMOUNT_BIGGER_THAN_MAX_LOAN_SIZE_STABLE); + } + } + + /** + * @dev Validates a repay action + * @param reserve The reserve state from which the user is repaying + * @param amountSent The amount sent for the repayment. Can be an actual value or uint(-1) + * @param onBehalfOf The address of the user msg.sender is repaying for + * @param stableDebt The borrow balance of the user + * @param variableDebt The borrow balance of the user + */ + function validateRepay( + DataTypes.ReserveData storage reserve, + uint256 amountSent, + DataTypes.InterestRateMode rateMode, + address onBehalfOf, + uint256 stableDebt, + uint256 variableDebt + ) external view { + bool isActive = reserve.configuration.getActive(); + + require(isActive, Errors.VL_NO_ACTIVE_RESERVE); + + require(amountSent > 0, Errors.VL_INVALID_AMOUNT); + + require( + (stableDebt > 0 && + DataTypes.InterestRateMode(rateMode) == DataTypes.InterestRateMode.STABLE) || + (variableDebt > 0 && + DataTypes.InterestRateMode(rateMode) == DataTypes.InterestRateMode.VARIABLE), + Errors.VL_NO_DEBT_OF_SELECTED_TYPE + ); + + require( + amountSent != uint256(-1) || msg.sender == onBehalfOf, + Errors.VL_NO_EXPLICIT_AMOUNT_TO_REPAY_ON_BEHALF + ); + } + + /** + * @dev Validates a swap of borrow rate mode. + * @param reserve The reserve state on which the user is swapping the rate + * @param userConfig The user reserves configuration + * @param stableDebt The stable debt of the user + * @param variableDebt The variable debt of the user + * @param currentRateMode The rate mode of the borrow + */ + function validateSwapRateMode( + DataTypes.ReserveData storage reserve, + DataTypes.UserConfigurationMap storage userConfig, + uint256 stableDebt, + uint256 variableDebt, + DataTypes.InterestRateMode currentRateMode + ) external view { + (bool isActive, bool isFrozen, , bool stableRateEnabled) = reserve.configuration.getFlags(); + + require(isActive, Errors.VL_NO_ACTIVE_RESERVE); + require(!isFrozen, Errors.VL_RESERVE_FROZEN); + + if (currentRateMode == DataTypes.InterestRateMode.STABLE) { + require(stableDebt > 0, Errors.VL_NO_STABLE_RATE_LOAN_IN_RESERVE); + } else if (currentRateMode == DataTypes.InterestRateMode.VARIABLE) { + require(variableDebt > 0, Errors.VL_NO_VARIABLE_RATE_LOAN_IN_RESERVE); + /** + * user wants to swap to stable, before swapping we need to ensure that + * 1. stable borrow rate is enabled on the reserve + * 2. user is not trying to abuse the reserve by depositing + * more collateral than he is borrowing, artificially lowering + * the interest rate, borrowing at variable, and switching to stable + **/ + require(stableRateEnabled, Errors.VL_STABLE_BORROWING_NOT_ENABLED); + + require( + !userConfig.isUsingAsCollateral(reserve.id) || + reserve.configuration.getLtv() == 0 || + stableDebt.add(variableDebt) > IERC20(reserve.aTokenAddress).balanceOf(msg.sender), + Errors.VL_COLLATERAL_SAME_AS_BORROWING_CURRENCY + ); + } else { + revert(Errors.VL_INVALID_INTEREST_RATE_MODE_SELECTED); + } + } + + /** + * @dev Validates a stable borrow rate rebalance action + * @param reserve The reserve state on which the user is getting rebalanced + * @param reserveAddress The address of the reserve + * @param stableDebtToken The stable debt token instance + * @param variableDebtToken The variable debt token instance + * @param aTokenAddress The address of the aToken contract + */ + function validateRebalanceStableBorrowRate( + DataTypes.ReserveData storage reserve, + address reserveAddress, + IERC20 stableDebtToken, + IERC20 variableDebtToken, + address aTokenAddress + ) external view { + (bool isActive, , , ) = reserve.configuration.getFlags(); + + require(isActive, Errors.VL_NO_ACTIVE_RESERVE); + + //if the usage ratio is below 95%, no rebalances are needed + uint256 totalDebt = + stableDebtToken.totalSupply().add(variableDebtToken.totalSupply()).wadToRay(); + uint256 availableLiquidity = IERC20(reserveAddress).balanceOf(aTokenAddress).wadToRay(); + uint256 usageRatio = totalDebt == 0 ? 0 : totalDebt.rayDiv(availableLiquidity.add(totalDebt)); + + //if the liquidity rate is below REBALANCE_UP_THRESHOLD of the max variable APR at 95% usage, + //then we allow rebalancing of the stable rate positions. + + uint256 currentLiquidityRate = reserve.currentLiquidityRate; + uint256 maxVariableBorrowRate = + IReserveInterestRateStrategy(reserve.interestRateStrategyAddress).getMaxVariableBorrowRate(); + + require( + usageRatio >= REBALANCE_UP_USAGE_RATIO_THRESHOLD && + currentLiquidityRate <= + maxVariableBorrowRate.percentMul(REBALANCE_UP_LIQUIDITY_RATE_THRESHOLD), + Errors.LP_INTEREST_RATE_REBALANCE_CONDITIONS_NOT_MET + ); + } + + /** + * @dev Validates the action of setting an asset as collateral + * @param reserve The state of the reserve that the user is enabling or disabling as collateral + * @param reserveAddress The address of the reserve + * @param reservesData The data of all the reserves + * @param userConfig The state of the user for the specific reserve + * @param reserves The addresses of all the active reserves + * @param oracle The price oracle + */ + function validateSetUseReserveAsCollateral( + DataTypes.ReserveData storage reserve, + address reserveAddress, + bool useAsCollateral, + mapping(address => DataTypes.ReserveData) storage reservesData, + DataTypes.UserConfigurationMap storage userConfig, + mapping(uint256 => address) storage reserves, + uint256 reservesCount, + address oracle + ) external view { + uint256 underlyingBalance = IERC20(reserve.aTokenAddress).balanceOf(msg.sender); + + require(underlyingBalance > 0, Errors.VL_UNDERLYING_BALANCE_NOT_GREATER_THAN_0); + + require( + useAsCollateral || + GenericLogic.balanceDecreaseAllowed( + reserveAddress, + msg.sender, + underlyingBalance, + reservesData, + userConfig, + reserves, + reservesCount, + oracle + ), + Errors.VL_DEPOSIT_ALREADY_IN_USE + ); + } + + /** + * @dev Validates a flashloan action + * @param assets The assets being flashborrowed + * @param amounts The amounts for each asset being borrowed + **/ + function validateFlashloan(address[] memory assets, uint256[] memory amounts) internal pure { + require(assets.length == amounts.length, Errors.VL_INCONSISTENT_FLASHLOAN_PARAMS); + } + + /** + * @dev Validates the liquidation action + * @param collateralReserve The reserve data of the collateral + * @param principalReserve The reserve data of the principal + * @param userConfig The user configuration + * @param userHealthFactor The user's health factor + * @param userStableDebt Total stable debt balance of the user + * @param userVariableDebt Total variable debt balance of the user + **/ + function validateLiquidationCall( + DataTypes.ReserveData storage collateralReserve, + DataTypes.ReserveData storage principalReserve, + DataTypes.UserConfigurationMap storage userConfig, + uint256 userHealthFactor, + uint256 userStableDebt, + uint256 userVariableDebt + ) internal view returns (uint256, string memory) { + if ( + !collateralReserve.configuration.getActive() || !principalReserve.configuration.getActive() + ) { + return ( + uint256(Errors.CollateralManagerErrors.NO_ACTIVE_RESERVE), + Errors.VL_NO_ACTIVE_RESERVE + ); + } + + if (userHealthFactor >= GenericLogic.HEALTH_FACTOR_LIQUIDATION_THRESHOLD) { + return ( + uint256(Errors.CollateralManagerErrors.HEALTH_FACTOR_ABOVE_THRESHOLD), + Errors.LPCM_HEALTH_FACTOR_NOT_BELOW_THRESHOLD + ); + } + + bool isCollateralEnabled = + collateralReserve.configuration.getLiquidationThreshold() > 0 && + userConfig.isUsingAsCollateral(collateralReserve.id); + + //if collateral isn't enabled as collateral by user, it cannot be liquidated + if (!isCollateralEnabled) { + return ( + uint256(Errors.CollateralManagerErrors.COLLATERAL_CANNOT_BE_LIQUIDATED), + Errors.LPCM_COLLATERAL_CANNOT_BE_LIQUIDATED + ); + } + + if (userStableDebt == 0 && userVariableDebt == 0) { + return ( + uint256(Errors.CollateralManagerErrors.CURRRENCY_NOT_BORROWED), + Errors.LPCM_SPECIFIED_CURRENCY_NOT_BORROWED_BY_USER + ); + } + + return (uint256(Errors.CollateralManagerErrors.NO_ERROR), Errors.LPCM_NO_ERRORS); + } + + /** + * @dev Validates an aToken transfer + * @param from The user from which the aTokens are being transferred + * @param reservesData The state of all the reserves + * @param userConfig The state of the user for the specific reserve + * @param reserves The addresses of all the active reserves + * @param oracle The price oracle + */ + function validateTransfer( + address from, + mapping(address => DataTypes.ReserveData) storage reservesData, + DataTypes.UserConfigurationMap storage userConfig, + mapping(uint256 => address) storage reserves, + uint256 reservesCount, + address oracle + ) internal view { + (, , , , uint256 healthFactor) = + GenericLogic.calculateUserAccountData( + from, + reservesData, + userConfig, + reserves, + reservesCount, + oracle + ); + + require( + healthFactor >= GenericLogic.HEALTH_FACTOR_LIQUIDATION_THRESHOLD, + Errors.VL_TRANSFER_NOT_ALLOWED + ); + } +} diff --git a/utils/contracts/aaveV2.ts b/utils/contracts/aaveV2.ts new file mode 100644 index 000000000..90112358b --- /dev/null +++ b/utils/contracts/aaveV2.ts @@ -0,0 +1,15 @@ +export { AaveV2AToken } from "../../typechain/AaveV2AToken"; +export { AaveV2DefaultReserveInterestRateStrategy } from "../../typechain/AaveV2DefaultReserveInterestRateStrategy"; +export { AaveV2LendingPool } from "../../typechain/AaveV2LendingPool"; +export { AaveV2LendingPoolAddressesProvider } from "../../typechain/AaveV2LendingPoolAddressesProvider"; +export { AaveV2LendingPoolCollateralManager } from "../../typechain/AaveV2LendingPoolCollateralManager"; +export { AaveV2LendingPoolConfigurator } from "../../typechain/AaveV2LendingPoolConfigurator"; +export { AaveV2ProtocolDataProvider } from "../../typechain/AaveV2ProtocolDataProvider"; +export { AaveV2StableDebtToken } from "../../typechain/AaveV2StableDebtToken"; +export { AaveV2StakedTokenIncentivesController } from "../../typechain/AaveV2StakedTokenIncentivesController"; +export { AaveV2VariableDebtToken } from "../../typechain/AaveV2VariableDebtToken"; + +// Libraries +export { GenericLogic } from "../../typechain/GenericLogic"; +export { ReserveLogic } from "../../typechain/ReserveLogic"; +export { ValidationLogic } from "../../typechain/ValidationLogic"; \ No newline at end of file From 7084a7732a97158d7e0a9b4c232966be44aee221 Mon Sep 17 00:00:00 2001 From: alpha-guy Date: Thu, 15 Jul 2021 20:21:01 +0530 Subject: [PATCH 05/19] Add interfaces to interfaces/external/aave-v2 --- .../external/aave-v2/ILendingPool.sol | 411 ++++++++++++++++++ .../aave-v2/ILendingPoolAddressesProvider.sol | 60 +++ .../aave-v2/IProtocolDataProvider.sol | 20 + .../external/aave-v2/lib/DataTypes.sol | 49 +++ 4 files changed, 540 insertions(+) create mode 100644 contracts/interfaces/external/aave-v2/ILendingPool.sol create mode 100644 contracts/interfaces/external/aave-v2/ILendingPoolAddressesProvider.sol create mode 100644 contracts/interfaces/external/aave-v2/IProtocolDataProvider.sol create mode 100644 contracts/interfaces/external/aave-v2/lib/DataTypes.sol diff --git a/contracts/interfaces/external/aave-v2/ILendingPool.sol b/contracts/interfaces/external/aave-v2/ILendingPool.sol new file mode 100644 index 000000000..4abb003ea --- /dev/null +++ b/contracts/interfaces/external/aave-v2/ILendingPool.sol @@ -0,0 +1,411 @@ +// SPDX-License-Identifier: agpl-3.0 +pragma solidity 0.6.10; +pragma experimental ABIEncoderV2; + +import { ILendingPoolAddressesProvider } from "./ILendingPoolAddressesProvider.sol"; +import { DataTypes } from "./lib/DataTypes.sol"; + +interface ILendingPool { + /** + * @dev Emitted on deposit() + * @param reserve The address of the underlying asset of the reserve + * @param user The address initiating the deposit + * @param onBehalfOf The beneficiary of the deposit, receiving the aTokens + * @param amount The amount deposited + * @param referral The referral code used + **/ + event Deposit( + address indexed reserve, + address user, + address indexed onBehalfOf, + uint256 amount, + uint16 indexed referral + ); + + /** + * @dev Emitted on withdraw() + * @param reserve The address of the underlyng asset being withdrawn + * @param user The address initiating the withdrawal, owner of aTokens + * @param to Address that will receive the underlying + * @param amount The amount to be withdrawn + **/ + event Withdraw(address indexed reserve, address indexed user, address indexed to, uint256 amount); + + /** + * @dev Emitted on borrow() and flashLoan() when debt needs to be opened + * @param reserve The address of the underlying asset being borrowed + * @param user The address of the user initiating the borrow(), receiving the funds on borrow() or just + * initiator of the transaction on flashLoan() + * @param onBehalfOf The address that will be getting the debt + * @param amount The amount borrowed out + * @param borrowRateMode The rate mode: 1 for Stable, 2 for Variable + * @param borrowRate The numeric rate at which the user has borrowed + * @param referral The referral code used + **/ + event Borrow( + address indexed reserve, + address user, + address indexed onBehalfOf, + uint256 amount, + uint256 borrowRateMode, + uint256 borrowRate, + uint16 indexed referral + ); + + /** + * @dev Emitted on repay() + * @param reserve The address of the underlying asset of the reserve + * @param user The beneficiary of the repayment, getting his debt reduced + * @param repayer The address of the user initiating the repay(), providing the funds + * @param amount The amount repaid + **/ + event Repay( + address indexed reserve, + address indexed user, + address indexed repayer, + uint256 amount + ); + + /** + * @dev Emitted on swapBorrowRateMode() + * @param reserve The address of the underlying asset of the reserve + * @param user The address of the user swapping his rate mode + * @param rateMode The rate mode that the user wants to swap to + **/ + event Swap(address indexed reserve, address indexed user, uint256 rateMode); + + /** + * @dev Emitted on setUserUseReserveAsCollateral() + * @param reserve The address of the underlying asset of the reserve + * @param user The address of the user enabling the usage as collateral + **/ + event ReserveUsedAsCollateralEnabled(address indexed reserve, address indexed user); + + /** + * @dev Emitted on setUserUseReserveAsCollateral() + * @param reserve The address of the underlying asset of the reserve + * @param user The address of the user enabling the usage as collateral + **/ + event ReserveUsedAsCollateralDisabled(address indexed reserve, address indexed user); + + /** + * @dev Emitted on rebalanceStableBorrowRate() + * @param reserve The address of the underlying asset of the reserve + * @param user The address of the user for which the rebalance has been executed + **/ + event RebalanceStableBorrowRate(address indexed reserve, address indexed user); + + /** + * @dev Emitted on flashLoan() + * @param target The address of the flash loan receiver contract + * @param initiator The address initiating the flash loan + * @param asset The address of the asset being flash borrowed + * @param amount The amount flash borrowed + * @param premium The fee flash borrowed + * @param referralCode The referral code used + **/ + event FlashLoan( + address indexed target, + address indexed initiator, + address indexed asset, + uint256 amount, + uint256 premium, + uint16 referralCode + ); + + /** + * @dev Emitted when the pause is triggered. + */ + event Paused(); + + /** + * @dev Emitted when the pause is lifted. + */ + event Unpaused(); + + /** + * @dev Emitted when a borrower is liquidated. This event is emitted by the LendingPool via + * LendingPoolCollateral manager using a DELEGATECALL + * This allows to have the events in the generated ABI for LendingPool. + * @param collateralAsset The address of the underlying asset used as collateral, to receive as result of the liquidation + * @param debtAsset The address of the underlying borrowed asset to be repaid with the liquidation + * @param user The address of the borrower getting liquidated + * @param debtToCover The debt amount of borrowed `asset` the liquidator wants to cover + * @param liquidatedCollateralAmount The amount of collateral received by the liiquidator + * @param liquidator The address of the liquidator + * @param receiveAToken `true` if the liquidators wants to receive the collateral aTokens, `false` if he wants + * to receive the underlying collateral asset directly + **/ + event LiquidationCall( + address indexed collateralAsset, + address indexed debtAsset, + address indexed user, + uint256 debtToCover, + uint256 liquidatedCollateralAmount, + address liquidator, + bool receiveAToken + ); + + /** + * @dev Emitted when the state of a reserve is updated. NOTE: This event is actually declared + * in the ReserveLogic library and emitted in the updateInterestRates() function. Since the function is internal, + * the event will actually be fired by the LendingPool contract. The event is therefore replicated here so it + * gets added to the LendingPool ABI + * @param reserve The address of the underlying asset of the reserve + * @param liquidityRate The new liquidity rate + * @param stableBorrowRate The new stable borrow rate + * @param variableBorrowRate The new variable borrow rate + * @param liquidityIndex The new liquidity index + * @param variableBorrowIndex The new variable borrow index + **/ + event ReserveDataUpdated( + address indexed reserve, + uint256 liquidityRate, + uint256 stableBorrowRate, + uint256 variableBorrowRate, + uint256 liquidityIndex, + uint256 variableBorrowIndex + ); + + /** + * @dev Deposits an `amount` of underlying asset into the reserve, receiving in return overlying aTokens. + * - E.g. User deposits 100 USDC and gets in return 100 aUSDC + * @param asset The address of the underlying asset to deposit + * @param amount The amount to be deposited + * @param onBehalfOf The address that will receive the aTokens, same as msg.sender if the user + * wants to receive them on his own wallet, or a different address if the beneficiary of aTokens + * is a different wallet + * @param referralCode Code used to register the integrator originating the operation, for potential rewards. + * 0 if the action is executed directly by the user, without any middle-man + **/ + function deposit( + address asset, + uint256 amount, + address onBehalfOf, + uint16 referralCode + ) external; + + /** + * @dev Withdraws an `amount` of underlying asset from the reserve, burning the equivalent aTokens owned + * E.g. User has 100 aUSDC, calls withdraw() and receives 100 USDC, burning the 100 aUSDC + * @param asset The address of the underlying asset to withdraw + * @param amount The underlying amount to be withdrawn + * - Send the value type(uint256).max in order to withdraw the whole aToken balance + * @param to Address that will receive the underlying, same as msg.sender if the user + * wants to receive it on his own wallet, or a different address if the beneficiary is a + * different wallet + * @return The final amount withdrawn + **/ + function withdraw( + address asset, + uint256 amount, + address to + ) external returns (uint256); + + /** + * @dev Allows users to borrow a specific `amount` of the reserve underlying asset, provided that the borrower + * already deposited enough collateral, or he was given enough allowance by a credit delegator on the + * corresponding debt token (StableDebtToken or VariableDebtToken) + * - E.g. User borrows 100 USDC passing as `onBehalfOf` his own address, receiving the 100 USDC in his wallet + * and 100 stable/variable debt tokens, depending on the `interestRateMode` + * @param asset The address of the underlying asset to borrow + * @param amount The amount to be borrowed + * @param interestRateMode The interest rate mode at which the user wants to borrow: 1 for Stable, 2 for Variable + * @param referralCode Code used to register the integrator originating the operation, for potential rewards. + * 0 if the action is executed directly by the user, without any middle-man + * @param onBehalfOf Address of the user who will receive the debt. Should be the address of the borrower itself + * calling the function if he wants to borrow against his own collateral, or the address of the credit delegator + * if he has been given credit delegation allowance + **/ + function borrow( + address asset, + uint256 amount, + uint256 interestRateMode, + uint16 referralCode, + address onBehalfOf + ) external; + + /** + * @notice Repays a borrowed `amount` on a specific reserve, burning the equivalent debt tokens owned + * - E.g. User repays 100 USDC, burning 100 variable/stable debt tokens of the `onBehalfOf` address + * @param asset The address of the borrowed underlying asset previously borrowed + * @param amount The amount to repay + * - Send the value type(uint256).max in order to repay the whole debt for `asset` on the specific `debtMode` + * @param rateMode The interest rate mode at of the debt the user wants to repay: 1 for Stable, 2 for Variable + * @param onBehalfOf Address of the user who will get his debt reduced/removed. Should be the address of the + * user calling the function if he wants to reduce/remove his own debt, or the address of any other + * other borrower whose debt should be removed + * @return The final amount repaid + **/ + function repay( + address asset, + uint256 amount, + uint256 rateMode, + address onBehalfOf + ) external returns (uint256); + + /** + * @dev Allows a borrower to swap his debt between stable and variable mode, or viceversa + * @param asset The address of the underlying asset borrowed + * @param rateMode The rate mode that the user wants to swap to + **/ + function swapBorrowRateMode(address asset, uint256 rateMode) external; + + /** + * @dev Rebalances the stable interest rate of a user to the current stable rate defined on the reserve. + * - Users can be rebalanced if the following conditions are satisfied: + * 1. Usage ratio is above 95% + * 2. the current deposit APY is below REBALANCE_UP_THRESHOLD * maxVariableBorrowRate, which means that too much has been + * borrowed at a stable rate and depositors are not earning enough + * @param asset The address of the underlying asset borrowed + * @param user The address of the user to be rebalanced + **/ + function rebalanceStableBorrowRate(address asset, address user) external; + + /** + * @dev Allows depositors to enable/disable a specific deposited asset as collateral + * @param asset The address of the underlying asset deposited + * @param useAsCollateral `true` if the user wants to use the deposit as collateral, `false` otherwise + **/ + function setUserUseReserveAsCollateral(address asset, bool useAsCollateral) external; + + /** + * @dev Function to liquidate a non-healthy position collateral-wise, with Health Factor below 1 + * - The caller (liquidator) covers `debtToCover` amount of debt of the user getting liquidated, and receives + * a proportionally amount of the `collateralAsset` plus a bonus to cover market risk + * @param collateralAsset The address of the underlying asset used as collateral, to receive as result of the liquidation + * @param debtAsset The address of the underlying borrowed asset to be repaid with the liquidation + * @param user The address of the borrower getting liquidated + * @param debtToCover The debt amount of borrowed `asset` the liquidator wants to cover + * @param receiveAToken `true` if the liquidators wants to receive the collateral aTokens, `false` if he wants + * to receive the underlying collateral asset directly + **/ + function liquidationCall( + address collateralAsset, + address debtAsset, + address user, + uint256 debtToCover, + bool receiveAToken + ) external; + + /** + * @dev Allows smartcontracts to access the liquidity of the pool within one transaction, + * as long as the amount taken plus a fee is returned. + * IMPORTANT There are security concerns for developers of flashloan receiver contracts that must be kept into consideration. + * For further details please visit https://developers.aave.com + * @param receiverAddress The address of the contract receiving the funds, implementing the IFlashLoanReceiver interface + * @param assets The addresses of the assets being flash-borrowed + * @param amounts The amounts amounts being flash-borrowed + * @param modes Types of the debt to open if the flash loan is not returned: + * 0 -> Don't open any debt, just revert if funds can't be transferred from the receiver + * 1 -> Open debt at stable rate for the value of the amount flash-borrowed to the `onBehalfOf` address + * 2 -> Open debt at variable rate for the value of the amount flash-borrowed to the `onBehalfOf` address + * @param onBehalfOf The address that will receive the debt in the case of using on `modes` 1 or 2 + * @param params Variadic packed params to pass to the receiver as extra information + * @param referralCode Code used to register the integrator originating the operation, for potential rewards. + * 0 if the action is executed directly by the user, without any middle-man + **/ + function flashLoan( + address receiverAddress, + address[] calldata assets, + uint256[] calldata amounts, + uint256[] calldata modes, + address onBehalfOf, + bytes calldata params, + uint16 referralCode + ) external; + + /** + * @dev Returns the user account data across all the reserves + * @param user The address of the user + * @return totalCollateralETH the total collateral in ETH of the user + * @return totalDebtETH the total debt in ETH of the user + * @return availableBorrowsETH the borrowing power left of the user + * @return currentLiquidationThreshold the liquidation threshold of the user + * @return ltv the loan to value of the user + * @return healthFactor the current health factor of the user + **/ + function getUserAccountData(address user) + external + view + returns ( + uint256 totalCollateralETH, + uint256 totalDebtETH, + uint256 availableBorrowsETH, + uint256 currentLiquidationThreshold, + uint256 ltv, + uint256 healthFactor + ); + + function initReserve( + address reserve, + address aTokenAddress, + address stableDebtAddress, + address variableDebtAddress, + address interestRateStrategyAddress + ) external; + + function setReserveInterestRateStrategyAddress(address reserve, address rateStrategyAddress) + external; + + function setConfiguration(address reserve, uint256 configuration) external; + + /** + * @dev Returns the configuration of the reserve + * @param asset The address of the underlying asset of the reserve + * @return The configuration of the reserve + **/ + function getConfiguration(address asset) + external + view + returns (DataTypes.ReserveConfigurationMap memory); + + /** + * @dev Returns the configuration of the user across all the reserves + * @param user The user address + * @return The configuration of the user + **/ + function getUserConfiguration(address user) + external + view + returns (DataTypes.UserConfigurationMap memory); + + /** + * @dev Returns the normalized income normalized income of the reserve + * @param asset The address of the underlying asset of the reserve + * @return The reserve's normalized income + */ + function getReserveNormalizedIncome(address asset) external view returns (uint256); + + /** + * @dev Returns the normalized variable debt per unit of asset + * @param asset The address of the underlying asset of the reserve + * @return The reserve normalized variable debt + */ + function getReserveNormalizedVariableDebt(address asset) external view returns (uint256); + + /** + * @dev Returns the state and configuration of the reserve + * @param asset The address of the underlying asset of the reserve + * @return The state of the reserve + **/ + function getReserveData(address asset) external view returns (DataTypes.ReserveData memory); + + function finalizeTransfer( + address asset, + address from, + address to, + uint256 amount, + uint256 balanceFromAfter, + uint256 balanceToBefore + ) external; + + function getReservesList() external view returns (address[] memory); + + function getAddressesProvider() external view returns (ILendingPoolAddressesProvider); + + function setPause(bool val) external; + + function paused() external view returns (bool); +} + diff --git a/contracts/interfaces/external/aave-v2/ILendingPoolAddressesProvider.sol b/contracts/interfaces/external/aave-v2/ILendingPoolAddressesProvider.sol new file mode 100644 index 000000000..ba7028a66 --- /dev/null +++ b/contracts/interfaces/external/aave-v2/ILendingPoolAddressesProvider.sol @@ -0,0 +1,60 @@ +// SPDX-License-Identifier: agpl-3.0 +pragma solidity 0.6.10; + +/** + * @title LendingPoolAddressesProvider contract + * @dev Main registry of addresses part of or connected to the protocol, including permissioned roles + * - Acting also as factory of proxies and admin of those, so with right to change its implementations + * - Owned by the Aave Governance + * @author Aave + **/ +interface ILendingPoolAddressesProvider { + event MarketIdSet(string newMarketId); + event LendingPoolUpdated(address indexed newAddress); + event ConfigurationAdminUpdated(address indexed newAddress); + event EmergencyAdminUpdated(address indexed newAddress); + event LendingPoolConfiguratorUpdated(address indexed newAddress); + event LendingPoolCollateralManagerUpdated(address indexed newAddress); + event PriceOracleUpdated(address indexed newAddress); + event LendingRateOracleUpdated(address indexed newAddress); + event ProxyCreated(bytes32 id, address indexed newAddress); + event AddressSet(bytes32 id, address indexed newAddress, bool hasProxy); + + function getMarketId() external view returns (string memory); + + function setMarketId(string calldata marketId) external; + + function setAddress(bytes32 id, address newAddress) external; + + function setAddressAsProxy(bytes32 id, address impl) external; + + function getAddress(bytes32 id) external view returns (address); + + function getLendingPool() external view returns (address); + + function setLendingPoolImpl(address pool) external; + + function getLendingPoolConfigurator() external view returns (address); + + function setLendingPoolConfiguratorImpl(address configurator) external; + + function getLendingPoolCollateralManager() external view returns (address); + + function setLendingPoolCollateralManager(address manager) external; + + function getPoolAdmin() external view returns (address); + + function setPoolAdmin(address admin) external; + + function getEmergencyAdmin() external view returns (address); + + function setEmergencyAdmin(address admin) external; + + function getPriceOracle() external view returns (address); + + function setPriceOracle(address priceOracle) external; + + function getLendingRateOracle() external view returns (address); + + function setLendingRateOracle(address lendingRateOracle) external; +} diff --git a/contracts/interfaces/external/aave-v2/IProtocolDataProvider.sol b/contracts/interfaces/external/aave-v2/IProtocolDataProvider.sol new file mode 100644 index 000000000..a84c8597d --- /dev/null +++ b/contracts/interfaces/external/aave-v2/IProtocolDataProvider.sol @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: agpl-3.0 +pragma solidity 0.6.10; +pragma experimental ABIEncoderV2; + +import {ILendingPoolAddressesProvider} from "./ILendingPoolAddressesProvider.sol"; + +interface IProtocolDataProvider { + struct TokenData { + string symbol; + address tokenAddress; + } + + function ADDRESSES_PROVIDER() external view returns (ILendingPoolAddressesProvider); + function getAllReservesTokens() external view returns (TokenData[] memory); + function getAllATokens() external view returns (TokenData[] memory); + function getReserveConfigurationData(address asset) external view returns (uint256 decimals, uint256 ltv, uint256 liquidationThreshold, uint256 liquidationBonus, uint256 reserveFactor, bool usageAsCollateralEnabled, bool borrowingEnabled, bool stableBorrowRateEnabled, bool isActive, bool isFrozen); + function getReserveData(address asset) external view returns (uint256 availableLiquidity, uint256 totalStableDebt, uint256 totalVariableDebt, uint256 liquidityRate, uint256 variableBorrowRate, uint256 stableBorrowRate, uint256 averageStableBorrowRate, uint256 liquidityIndex, uint256 variableBorrowIndex, uint40 lastUpdateTimestamp); + function getUserReserveData(address asset, address user) external view returns (uint256 currentATokenBalance, uint256 currentStableDebt, uint256 currentVariableDebt, uint256 principalStableDebt, uint256 scaledVariableDebt, uint256 stableBorrowRate, uint256 liquidityRate, uint40 stableRateLastUpdated, bool usageAsCollateralEnabled); + function getReserveTokensAddresses(address asset) external view returns (address aTokenAddress, address stableDebtTokenAddress, address variableDebtTokenAddress); +} \ No newline at end of file diff --git a/contracts/interfaces/external/aave-v2/lib/DataTypes.sol b/contracts/interfaces/external/aave-v2/lib/DataTypes.sol new file mode 100644 index 000000000..2d32de082 --- /dev/null +++ b/contracts/interfaces/external/aave-v2/lib/DataTypes.sol @@ -0,0 +1,49 @@ +// SPDX-License-Identifier: agpl-3.0 +pragma solidity 0.6.10; + +library DataTypes { + // refer to the whitepaper, section 1.1 basic concepts for a formal description of these properties. + struct ReserveData { + //stores the reserve configuration + ReserveConfigurationMap configuration; + //the liquidity index. Expressed in ray + uint128 liquidityIndex; + //variable borrow index. Expressed in ray + uint128 variableBorrowIndex; + //the current supply rate. Expressed in ray + uint128 currentLiquidityRate; + //the current variable borrow rate. Expressed in ray + uint128 currentVariableBorrowRate; + //the current stable borrow rate. Expressed in ray + uint128 currentStableBorrowRate; + uint40 lastUpdateTimestamp; + //tokens addresses + address aTokenAddress; + address stableDebtTokenAddress; + address variableDebtTokenAddress; + //address of the interest rate strategy + address interestRateStrategyAddress; + //the id of the reserve. Represents the position in the list of the active reserves + uint8 id; + } + + struct ReserveConfigurationMap { + //bit 0-15: LTV + //bit 16-31: Liq. threshold + //bit 32-47: Liq. bonus + //bit 48-55: Decimals + //bit 56: Reserve is active + //bit 57: reserve is frozen + //bit 58: borrowing is enabled + //bit 59: stable rate borrowing enabled + //bit 60-63: reserved + //bit 64-79: reserve factor + uint256 data; + } + + struct UserConfigurationMap { + uint256 data; + } + + enum InterestRateMode {NONE, STABLE, VARIABLE} +} From ba623bf5cce359d591b798e0d3581f851d8ad52e Mon Sep 17 00:00:00 2001 From: alpha-guy Date: Thu, 15 Jul 2021 20:22:11 +0530 Subject: [PATCH 06/19] Add AaveV2 library contract --- contracts/protocol/integration/lib/AaveV2.sol | 307 ++++++++++++++++++ 1 file changed, 307 insertions(+) create mode 100644 contracts/protocol/integration/lib/AaveV2.sol diff --git a/contracts/protocol/integration/lib/AaveV2.sol b/contracts/protocol/integration/lib/AaveV2.sol new file mode 100644 index 000000000..fa591affc --- /dev/null +++ b/contracts/protocol/integration/lib/AaveV2.sol @@ -0,0 +1,307 @@ +/* + Copyright 2021 Set Labs Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + SPDX-License-Identifier: Apache License, Version 2.0 +*/ + +pragma solidity 0.6.10; + +import { ISetToken } from "../../../interfaces/ISetToken.sol"; +import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; + +// TODO: Calculate the gas costs of having separate getter functions. + +/** + * @title AaveV2 + * @author Set Protocol + * + * Collection of helper functions for interacting with AaveV2 integrations. + */ +library AaveV2 { + /* ============ External ============ */ + + /** + * Get deposit calldata from SetToken + */ + function getDepositCalldata( + address _asset, + uint256 _amountNotional, + address _onBehalfOf, + uint16 _referralCode, + address _lendingPool + ) + public + pure + returns (address, uint256, bytes memory) + { + bytes memory callData = abi.encodeWithSignature( + "deposit(address,uint256,address,uint16)", + _asset, + _amountNotional, + _onBehalfOf, + _referralCode + ); + + return (_lendingPool, 0, callData); + } + + /** + * Invoke deposit on LendingPool from SetToken + */ + function invokeDeposit( + ISetToken _setToken, + IERC20 _asset, + uint256 _amountNotional, + address _lendingPool + ) + external + { + ( , , bytes memory depositCalldata) = getDepositCalldata( + address(_asset), + _amountNotional, + address(_setToken), + 0, + _lendingPool + ); + + _setToken.invoke(_lendingPool, 0, depositCalldata); + } + + /** + * Get withdraw calldata from SetToken + */ + function getWithdrawCalldata( + address _asset, + uint256 _amountNotional, + address _receiver, + address _lendingPool + ) + public + pure + returns (address, uint256, bytes memory) + { + bytes memory callData = abi.encodeWithSignature( + "withdraw(address,uint256,address)", + _asset, + _amountNotional, + _receiver + ); + + return (_lendingPool, 0, callData); + } + + /** + * Invoke withdraw on LendingPool from SetToken + */ + function invokeWithdraw( + ISetToken _setToken, + IERC20 _asset, + uint256 _amountNotional, + address _lendingPool + ) + external + { + ( , , bytes memory withdrawCalldata) = getWithdrawCalldata( + address(_asset), + _amountNotional, + address(_setToken), + _lendingPool + ); + + _setToken.invoke(_lendingPool, 0, withdrawCalldata); + } + + /** + * Get borrow calldata from SetToken + */ + function getBorrowCalldata( + address _asset, + uint256 _amountNotional, + uint256 _interestRateMode, + uint16 _referralCode, + address _onBehalfOf, + address _lendingPool + ) + public + pure + returns (address, uint256, bytes memory) + { + bytes memory callData = abi.encodeWithSignature( + "borrow(address,uint256,address)", + _asset, + _amountNotional, + _interestRateMode, + _referralCode, + _onBehalfOf + ); + + return (_lendingPool, 0, callData); + } + + /** + * Invoke borrow on LendingPool from SetToken + */ + function invokeBorrow( + ISetToken _setToken, + IERC20 _asset, + uint256 _amountNotional, + uint256 _interestRateMode, + address _lendingPool + ) + external + { + ( , , bytes memory borrowCalldata) = getBorrowCalldata( + address(_asset), + _amountNotional, + _interestRateMode, + 0, + address(_setToken), + _lendingPool + ); + + _setToken.invoke(_lendingPool, 0, borrowCalldata); + } + + /** + * Get repay calldata from SetToken + */ + function getRepayCalldata( + address _asset, + uint256 _amountNotional, + uint256 _interestRateMode, + address _onBehalfOf, + address _lendingPool + ) + public + pure + returns (address, uint256, bytes memory) + { + bytes memory callData = abi.encodeWithSignature( + "repay(address,uint256,address)", + _asset, + _amountNotional, + _interestRateMode, + _onBehalfOf + ); + + return (_lendingPool, 0, callData); + } + + /** + * Invoke repay on LendingPool from SetToken + */ + function invokeRepay( + ISetToken _setToken, + IERC20 _asset, + uint256 _amountNotional, + uint256 _interestRateMode, + address _lendingPool + ) + external + { + ( , , bytes memory repayCalldata) = getRepayCalldata( + address(_asset), + _amountNotional, + _interestRateMode, + address(_setToken), + _lendingPool + ); + + _setToken.invoke(_lendingPool, 0, repayCalldata); + } + + /** + * Get setUserUseReserveAsCollateral calldata from SetToken + */ + function getUseReserveAsCollateralCalldata( + address _asset, + bool _useAsCollateral, + address _lendingPool + ) + public + pure + returns (address, uint256, bytes memory) + { + bytes memory callData = abi.encodeWithSignature( + "setUserUseReserveAsCollateral(address,bool)", + _asset, + _useAsCollateral + ); + + return (_lendingPool, 0, callData); + } + + /** + * Invoke an asset to be used as collateral on Aave from SetToken + */ + function invokeUseAsCollateral( + ISetToken _setToken, + IERC20 _asset, + bool _useAsCollateral, + address _lendingPool + ) + external + { + ( , , bytes memory callData) = getUseReserveAsCollateralCalldata( + address(_asset), + _useAsCollateral, + _lendingPool + ); + + _setToken.invoke(_lendingPool, 0, callData); + } + + /** + * Get swapBorrowRate calldata from SetToken + */ + function getSwapBorrowRateCalldata( + address _asset, + uint256 _rateMode, + address _lendingPool + ) + public + pure + returns (address, uint256, bytes memory) + { + bytes memory callData = abi.encodeWithSignature( + "swapBorrowRateMode(address,uint256)", + _asset, + _rateMode + ); + + return (_lendingPool, 0, callData); + } + + /** + * Invoke to swap borrow rate of SetToken + * Note: Aave allows a borrower to toggle his debt between stable and variable mode + */ + function invokeSwapBorrowRate( + ISetToken _setToken, + IERC20 _asset, + uint256 _rateMode, + address _lendingPool + ) + external + { + ( , , bytes memory callData) = getSwapBorrowRateCalldata( + address(_asset), + _rateMode, + _lendingPool + ); + + _setToken.invoke(_lendingPool, 0, callData); + } +} \ No newline at end of file From 2668fc1395dd5f2756f0e66cb07669df4cb25778 Mon Sep 17 00:00:00 2001 From: alpha-guy Date: Thu, 15 Jul 2021 20:41:47 +0530 Subject: [PATCH 07/19] Add AaveV2 Mock contract * Add deployment utils for AaveV2 Library and mock contract --- .../protocol/integration/lib/AaveV2Mock.sol | 182 ++++++++++++++++++ utils/contracts/index.ts | 2 + utils/deploys/deployLibraries.ts | 6 + utils/deploys/deployMocks.ts | 16 +- 4 files changed, 205 insertions(+), 1 deletion(-) create mode 100644 contracts/mocks/protocol/integration/lib/AaveV2Mock.sol diff --git a/contracts/mocks/protocol/integration/lib/AaveV2Mock.sol b/contracts/mocks/protocol/integration/lib/AaveV2Mock.sol new file mode 100644 index 000000000..236007b29 --- /dev/null +++ b/contracts/mocks/protocol/integration/lib/AaveV2Mock.sol @@ -0,0 +1,182 @@ +/* + Copyright 2021 Set Labs Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + SPDX-License-Identifier: Apache License, Version 2.0 +*/ + +pragma solidity 0.6.10; + +import { ISetToken } from "../../../../interfaces/ISetToken.sol"; +import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; +import { AaveV2 } from "../../../../protocol/integration/lib/AaveV2.sol"; + +contract AaveV2Mock { + + /* ============ External ============ */ + + function testGetDepositCalldata( + address _asset, + uint256 _amountNotional, + address _onBehalfOf, + uint16 _referralCode, + address _lendingPool + ) + public + pure + returns (address, uint256, bytes memory) + { + AaveV2.getDepositCalldata(_asset, _amountNotional, _onBehalfOf, _referralCode, _lendingPool); + } + + function testInvokeDeposit( + ISetToken _setToken, + IERC20 _asset, + uint256 _amountNotional, + address _lendingPool + ) + external + { + AaveV2.invokeDeposit(_setToken, _asset, _amountNotional, _lendingPool); + } + + function testGetWithdrawCalldata( + address _asset, + uint256 _amountNotional, + address _receiver, + address _lendingPool + ) + public + pure + returns (address, uint256, bytes memory) + { + AaveV2.getWithdrawCalldata(_asset, _amountNotional, _receiver, _lendingPool); + } + + function testInvokeWithdraw( + ISetToken _setToken, + IERC20 _asset, + uint256 _amountNotional, + address _lendingPool + ) + external + { + AaveV2.invokeWithdraw(_setToken, _asset, _amountNotional, _lendingPool); + } + + function testGetBorrowCalldata( + address _asset, + uint256 _amountNotional, + uint256 _interestRateMode, + uint16 _referralCode, + address _onBehalfOf, + address _lendingPool + ) + public + pure + returns (address, uint256, bytes memory) + { + AaveV2.getBorrowCalldata(_asset, _amountNotional, _interestRateMode, _referralCode, _onBehalfOf, _lendingPool); + } + + function testInvokeBorrow( + ISetToken _setToken, + IERC20 _asset, + uint256 _amountNotional, + uint256 _interestRateMode, + address _lendingPool + ) + external + { + AaveV2.invokeBorrow(_setToken, _asset, _amountNotional, _interestRateMode, _lendingPool); + } + + function testGetRepayCalldata( + address _asset, + uint256 _amountNotional, + uint256 _interestRateMode, + address _onBehalfOf, + address _lendingPool + ) + public + pure + returns (address, uint256, bytes memory) + { + AaveV2.getRepayCalldata(_asset, _amountNotional, _interestRateMode, _onBehalfOf, _lendingPool); + } + + function testInvokeRepay( + ISetToken _setToken, + IERC20 _asset, + uint256 _amountNotional, + uint256 _interestRateMode, + address _lendingPool + ) + external + { + AaveV2.invokeRepay(_setToken, _asset, _amountNotional, _interestRateMode, _lendingPool); + } + + function testGetUseReserveAsCollateralCalldata( + address _asset, + bool _useAsCollateral, + address _lendingPool + ) + external + pure + returns (address, uint256, bytes memory) + { + AaveV2.getUseReserveAsCollateralCalldata(_asset, _useAsCollateral, _lendingPool); + } + + function testInvokeUseAsCollateral( + ISetToken _setToken, + IERC20 _asset, + bool _useAsCollateral, + address _lendingPool + ) + external + { + AaveV2.invokeUseAsCollateral(_setToken, _asset, _useAsCollateral, _lendingPool); + } + + function testGetSwapBorrowRateCalldata( + address _asset, + uint256 _rateMode, + address _lendingPool + ) + external + pure + returns (address, uint256, bytes memory) + { + AaveV2.getSwapBorrowRateCalldata(_asset, _rateMode, _lendingPool); + } + + function testInvokeSwapBorrowRate( + ISetToken _setToken, + IERC20 _asset, + uint256 _rateMode, + address _lendingPool + ) + external + { + AaveV2.invokeSwapBorrowRate(_setToken, _asset, _rateMode, _lendingPool); + } + + /* ============ Helper Functions ============ */ + + function initializeModuleOnSet(ISetToken _setToken) external { + _setToken.initializeModule(); + } +} \ No newline at end of file diff --git a/utils/contracts/index.ts b/utils/contracts/index.ts index a0341df19..044c46e4d 100644 --- a/utils/contracts/index.ts +++ b/utils/contracts/index.ts @@ -4,6 +4,8 @@ export { AaveLendingPoolCoreMock } from "../../typechain/AaveLendingPoolCoreMock export { AaveLendingPoolMock } from "../../typechain/AaveLendingPoolMock"; export { AaveMigrationWrapAdapter } from "../../typechain/AaveMigrationWrapAdapter"; export { AaveWrapAdapter } from "../../typechain/AaveWrapAdapter"; +export { AaveV2 } from "../../typechain/AaveV2"; +export { AaveV2Mock } from "../../typechain/AaveV2Mock"; export { AddressArrayUtilsMock } from "../../typechain/AddressArrayUtilsMock"; export { AirdropModule } from "../../typechain/AirdropModule"; export { AmmAdapterMock } from "../../typechain/AmmAdapterMock"; diff --git a/utils/deploys/deployLibraries.ts b/utils/deploys/deployLibraries.ts index 084cf3b31..f730d0057 100644 --- a/utils/deploys/deployLibraries.ts +++ b/utils/deploys/deployLibraries.ts @@ -1,10 +1,12 @@ import { Signer } from "ethers"; import { + AaveV2, Compound, } from "../contracts"; import { Compound__factory } from "../../typechain/factories/Compound__factory"; +import { AaveV2__factory } from "../../typechain/factories/AaveV2__factory"; export default class DeployLibraries { private _deployerSigner: Signer; @@ -16,4 +18,8 @@ export default class DeployLibraries { public async deployCompound(): Promise { return await new Compound__factory(this._deployerSigner).deploy(); } + + public async deployAaveV2(): Promise { + return await new AaveV2__factory(this._deployerSigner).deploy(); + } } diff --git a/utils/deploys/deployMocks.ts b/utils/deploys/deployMocks.ts index a30d5001f..b097cf874 100644 --- a/utils/deploys/deployMocks.ts +++ b/utils/deploys/deployMocks.ts @@ -42,7 +42,8 @@ import { Uint256ArrayUtilsMock, WrapAdapterMock, ZeroExMock, - YearnStrategyMock + YearnStrategyMock, + AaveV2Mock } from "../contracts"; import { convertLibraryNameToLinkId, ether } from "../common"; @@ -88,6 +89,7 @@ import { ZeroExMock__factory } from "../../typechain/factories/ZeroExMock__facto import { SynthMock__factory } from "../../typechain/factories/SynthMock__factory"; import { SynthetixExchangerMock__factory } from "../../typechain/factories/SynthetixExchangerMock__factory"; import { YearnStrategyMock__factory } from "../../typechain/factories/YearnStrategyMock__factory"; +import { AaveV2Mock__factory } from "../../typechain/factories/AaveV2Mock__factory"; export default class DeployMocks { private _deployerSigner: Signer; @@ -251,6 +253,18 @@ export default class DeployMocks { return await new AaveLendingPoolMock__factory(this._deployerSigner).deploy(aaveLendingPoolCore); } + public async deployAaveV2Mock(libraryName: string, libraryAddress: Address): Promise { + const linkId = convertLibraryNameToLinkId(libraryName); + + return await new AaveV2Mock__factory( + // @ts-ignore + { + [linkId]: libraryAddress, + }, + this._deployerSigner + ).deploy(); + } + public async deployClaimAdapterMock(): Promise { return await new ClaimAdapterMock__factory(this._deployerSigner).deploy(); } From e381d691272b35340e46b4e11d3bf36da2acfaff Mon Sep 17 00:00:00 2001 From: alpha-guy Date: Sun, 18 Jul 2021 14:01:12 +0530 Subject: [PATCH 08/19] Add AaveV2 fixture --- .../abi/aave/v2/AaveV2LendingRateOracle.json | 135 ++++++++++ external/abi/aave/v2/AaveV2Oracle.json | 246 +++++++++++++++++ external/abi/aave/v2/AaveV2PriceOracle.json | 116 ++++++++ utils/contracts/aaveV2.ts | 3 + utils/deploys/deployExternal.ts | 137 ++++++++++ utils/fixtures/aaveV2Fixture.ts | 247 ++++++++++++++++++ utils/fixtures/index.ts | 1 + utils/test/index.ts | 2 + 8 files changed, 887 insertions(+) create mode 100644 external/abi/aave/v2/AaveV2LendingRateOracle.json create mode 100644 external/abi/aave/v2/AaveV2Oracle.json create mode 100644 external/abi/aave/v2/AaveV2PriceOracle.json create mode 100644 utils/fixtures/aaveV2Fixture.ts diff --git a/external/abi/aave/v2/AaveV2LendingRateOracle.json b/external/abi/aave/v2/AaveV2LendingRateOracle.json new file mode 100644 index 000000000..fab55bcc7 --- /dev/null +++ b/external/abi/aave/v2/AaveV2LendingRateOracle.json @@ -0,0 +1,135 @@ +{ + "contractName": "AaveV2LendingRateOracle", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_asset", + "type": "address" + } + ], + "name": "getMarketBorrowRate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_asset", + "type": "address" + } + ], + "name": "getMarketLiquidityRate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_rate", + "type": "uint256" + } + ], + "name": "setMarketBorrowRate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_rate", + "type": "uint256" + } + ], + "name": "setMarketLiquidityRate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bytecode": "0x608060405234801561001057600080fd5b50600061001b61006a565b600080546001600160a01b0319166001600160a01b0383169081178255604051929350917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a35061006e565b3390565b6104d38061007d6000396000f3fe608060405234801561001057600080fd5b506004361061007d5760003560e01c80639f86a0ee1161005b5780639f86a0ee146100dc578063bb85c0bb14610108578063f2fde38b14610140578063fbe5ba1e146101665761007d565b8063715018a61461008257806372eb293d1461008c5780638da5cb5b146100b8575b600080fd5b61008a61018c565b005b61008a600480360360408110156100a257600080fd5b506001600160a01b03813516906020013561022e565b6100c06102a2565b604080516001600160a01b039092168252519081900360200190f35b61008a600480360360408110156100f257600080fd5b506001600160a01b0381351690602001356102b1565b61012e6004803603602081101561011e57600080fd5b50356001600160a01b0316610325565b60408051918252519081900360200190f35b61008a6004803603602081101561015657600080fd5b50356001600160a01b0316610340565b61012e6004803603602081101561017c57600080fd5b50356001600160a01b0316610438565b610194610453565b6000546001600160a01b039081169116146101e4576040805162461bcd60e51b8152602060048201819052602482015260008051602061047e833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b610236610453565b6000546001600160a01b03908116911614610286576040805162461bcd60e51b8152602060048201819052602482015260008051602061047e833981519152604482015290519081900360640190fd5b6001600160a01b03909116600090815260016020526040902055565b6000546001600160a01b031690565b6102b9610453565b6000546001600160a01b03908116911614610309576040805162461bcd60e51b8152602060048201819052602482015260008051602061047e833981519152604482015290519081900360640190fd5b6001600160a01b03909116600090815260026020526040902055565b6001600160a01b031660009081526001602052604090205490565b610348610453565b6000546001600160a01b03908116911614610398576040805162461bcd60e51b8152602060048201819052602482015260008051602061047e833981519152604482015290519081900360640190fd5b6001600160a01b0381166103dd5760405162461bcd60e51b81526004018080602001828103825260268152602001806104586026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b031660009081526002602052604090205490565b339056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573734f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572a26469706673582212201d7f473788a285376533f5b96c895378fdff2a709aa8154545daaf976c8f1f9f64736f6c634300060c0033", + "deployedBytecode": "", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/external/abi/aave/v2/AaveV2Oracle.json b/external/abi/aave/v2/AaveV2Oracle.json new file mode 100644 index 000000000..91143a582 --- /dev/null +++ b/external/abi/aave/v2/AaveV2Oracle.json @@ -0,0 +1,246 @@ +{ + "contractName": "AaveV2Oracle", + "abi": [ + { + "inputs": [ + { + "internalType": "address[]", + "name": "assets", + "type": "address[]" + }, + { + "internalType": "address[]", + "name": "sources", + "type": "address[]" + }, + { + "internalType": "address", + "name": "fallbackOracle", + "type": "address" + }, + { + "internalType": "address", + "name": "weth", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "source", + "type": "address" + } + ], + "name": "AssetSourceUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "fallbackOracle", + "type": "address" + } + ], + "name": "FallbackOracleUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "weth", + "type": "address" + } + ], + "name": "WethSet", + "type": "event" + }, + { + "inputs": [], + "name": "WETH", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "getAssetPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "assets", + "type": "address[]" + } + ], + "name": "getAssetsPrices", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getFallbackOracle", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "getSourceOfAsset", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "assets", + "type": "address[]" + }, + { + "internalType": "address[]", + "name": "sources", + "type": "address[]" + } + ], + "name": "setAssetSources", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "fallbackOracle", + "type": "address" + } + ], + "name": "setFallbackOracle", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bytecode": "0x60a06040523480156200001157600080fd5b5060405162000ead38038062000ead833981810160405260808110156200003757600080fd5b81019080805160405193929190846401000000008211156200005857600080fd5b9083019060208201858111156200006e57600080fd5b82518660208202830111640100000000821117156200008c57600080fd5b82525081516020918201928201910280838360005b83811015620000bb578181015183820152602001620000a1565b5050505090500160405260200180516040519392919084640100000000821115620000e557600080fd5b908301906020820185811115620000fb57600080fd5b82518660208202830111640100000000821117156200011957600080fd5b82525081516020918201928201910280838360005b83811015620001485781810151838201526020016200012e565b505050509190910160409081526020830151920151919350909150600090506200017162000222565b600080546001600160a01b0319166001600160a01b0383169081178255604051929350917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a350620001c68262000226565b620001d2848462000270565b6001600160601b0319606082901b166080526040516001600160a01b038216907f13a533084dcbb1cfe0dbea708ea977223c27c44d94f2fa3867a167c9cd340bf990600090a250505050620003bc565b3390565b600280546001600160a01b0319166001600160a01b0383169081179091556040517fce7a780d33665b1ea097af5f155e3821b809ecbaa839d3b33aa83ba28168cefb90600090a250565b8051825114620002c7576040805162461bcd60e51b815260206004820152601a60248201527f494e434f4e53495354454e545f504152414d535f4c454e475448000000000000604482015290519081900360640190fd5b60005b8251811015620003b757818181518110620002e157fe5b602002602001015160016000858481518110620002fa57fe5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a8154816001600160a01b0302191690836001600160a01b031602179055508181815181106200035357fe5b60200260200101516001600160a01b03168382815181106200037157fe5b60200260200101516001600160a01b03167f22c5b7b2d8561d39f7f210b6b326a1aa69f15311163082308ac4877db6339dc160405160405180910390a3600101620002ca565b505050565b60805160601c610ace620003df600039806105bc52806106005250610ace6000f3fe608060405234801561001057600080fd5b506004361061009e5760003560e01c80639d23d9f2116100665780639d23d9f214610125578063abfd5310146101e5578063ad5c4648146102a7578063b3596f07146102af578063f2fde38b146102e75761009e565b8063170aee73146100a35780636210308c146100cb578063715018a6146100ef5780638da5cb5b146100f757806392bf2be0146100ff575b600080fd5b6100c9600480360360208110156100b957600080fd5b50356001600160a01b031661030d565b005b6100d3610371565b604080516001600160a01b039092168252519081900360200190f35b6100c9610380565b6100d3610422565b6100d36004803603602081101561011557600080fd5b50356001600160a01b0316610431565b6101956004803603602081101561013b57600080fd5b81019060208101813564010000000081111561015657600080fd5b82018360208201111561016857600080fd5b8035906020019184602083028401116401000000008311171561018a57600080fd5b509092509050610452565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156101d15781810151838201526020016101b9565b505050509050019250505060405180910390f35b6100c9600480360360408110156101fb57600080fd5b81019060208101813564010000000081111561021657600080fd5b82018360208201111561022857600080fd5b8035906020019184602083028401116401000000008311171561024a57600080fd5b91939092909160208101903564010000000081111561026857600080fd5b82018360208201111561027a57600080fd5b8035906020019184602083028401116401000000008311171561029c57600080fd5b5090925090506104ef565b6100d36105ba565b6102d5600480360360208110156102c557600080fd5b50356001600160a01b03166105de565b60408051918252519081900360200190f35b6100c9600480360360208110156102fd57600080fd5b50356001600160a01b03166107c7565b6103156108bf565b6000546001600160a01b03908116911614610365576040805162461bcd60e51b81526020600482018190526024820152600080516020610a79833981519152604482015290519081900360640190fd5b61036e816108c3565b50565b6002546001600160a01b031690565b6103886108bf565b6000546001600160a01b039081169116146103d8576040805162461bcd60e51b81526020600482018190526024820152600080516020610a79833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b031690565b6001600160a01b03808216600090815260016020526040902054165b919050565b6060808267ffffffffffffffff8111801561046c57600080fd5b50604051908082528060200260200182016040528015610496578160200160208202803683370190505b50905060005b838110156104e7576104c88585838181106104b357fe5b905060200201356001600160a01b03166105de565b8282815181106104d457fe5b602090810291909101015260010161049c565b509392505050565b6104f76108bf565b6000546001600160a01b03908116911614610547576040805162461bcd60e51b81526020600482018190526024820152600080516020610a79833981519152604482015290519081900360640190fd5b6105b48484808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505060408051602080880282810182019093528782529093508792508691829185019084908082843760009201919091525061090d92505050565b50505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b6001600160a01b038082166000818152600160205260408120549092908116917f0000000000000000000000000000000000000000000000000000000000000000909116141561063957670de0b6b3a764000091505061044d565b6001600160a01b0381166106c9576002546040805163b3596f0760e01b81526001600160a01b0386811660048301529151919092169163b3596f07916024808301926020929190829003018186803b15801561069457600080fd5b505afa1580156106a8573d6000803e3d6000fd5b505050506040513d60208110156106be57600080fd5b5051915061044d9050565b6000816001600160a01b03166350d25bcd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561070457600080fd5b505afa158015610718573d6000803e3d6000fd5b505050506040513d602081101561072e57600080fd5b50519050600081131561074457915061044d9050565b6002546040805163b3596f0760e01b81526001600160a01b0387811660048301529151919092169163b3596f07916024808301926020929190829003018186803b15801561079157600080fd5b505afa1580156107a5573d6000803e3d6000fd5b505050506040513d60208110156107bb57600080fd5b5051925061044d915050565b6107cf6108bf565b6000546001600160a01b0390811691161461081f576040805162461bcd60e51b81526020600482018190526024820152600080516020610a79833981519152604482015290519081900360640190fd5b6001600160a01b0381166108645760405162461bcd60e51b8152600401808060200182810382526026815260200180610a536026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b3390565b600280546001600160a01b0319166001600160a01b0383169081179091556040517fce7a780d33665b1ea097af5f155e3821b809ecbaa839d3b33aa83ba28168cefb90600090a250565b8051825114610963576040805162461bcd60e51b815260206004820152601a60248201527f494e434f4e53495354454e545f504152414d535f4c454e475448000000000000604482015290519081900360640190fd5b60005b8251811015610a4d5781818151811061097b57fe5b60200260200101516001600085848151811061099357fe5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a8154816001600160a01b0302191690836001600160a01b031602179055508181815181106109eb57fe5b60200260200101516001600160a01b0316838281518110610a0857fe5b60200260200101516001600160a01b03167f22c5b7b2d8561d39f7f210b6b326a1aa69f15311163082308ac4877db6339dc160405160405180910390a3600101610966565b50505056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573734f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572a2646970667358221220c19dff02f9fbd1e192fa486447c21744e8c315bfb491564283359aabc2f3034c64736f6c634300060c0033", + "deployedBytecode": "", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/external/abi/aave/v2/AaveV2PriceOracle.json b/external/abi/aave/v2/AaveV2PriceOracle.json new file mode 100644 index 000000000..328415dc4 --- /dev/null +++ b/external/abi/aave/v2/AaveV2PriceOracle.json @@ -0,0 +1,116 @@ +{ + "contractName": "AaveV2PriceOracle", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "_asset", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_price", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "name": "AssetPriceUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "_price", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "name": "EthPriceUpdated", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_asset", + "type": "address" + } + ], + "name": "getAssetPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getEthUsdPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_price", + "type": "uint256" + } + ], + "name": "setAssetPrice", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_price", + "type": "uint256" + } + ], + "name": "setEthUsdPrice", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bytecode": "0x608060405234801561001057600080fd5b506101d0806100206000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c806351323f7214610051578063a0a8045e1461007f578063b3596f0714610099578063b951883a146100bf575b600080fd5b61007d6004803603604081101561006757600080fd5b506001600160a01b0381351690602001356100dc565b005b610087610137565b60408051918252519081900360200190f35b610087600480360360208110156100af57600080fd5b50356001600160a01b031661013d565b61007d600480360360208110156100d557600080fd5b5035610158565b6001600160a01b03821660008181526020818152604091829020849055815192835282018390524282820152517fce6e0b57367bae95ca7198e1172f653ea64a645c16ab586b4cefa9237bfc2d929181900360600190a15050565b60015490565b6001600160a01b031660009081526020819052604090205490565b60018190556040805182815242602082015281517fb4f35977939fa8b5ffe552d517a8ff5223046b1fdd3ee0068ae38d1e2b8d0016929181900390910190a15056fea26469706673582212201205be2202a7d039b951a92721e5484271318d14b8605f92cebf1a3998eb292a64736f6c634300060c0033", + "deployedBytecode": "", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/utils/contracts/aaveV2.ts b/utils/contracts/aaveV2.ts index 90112358b..b1445265d 100644 --- a/utils/contracts/aaveV2.ts +++ b/utils/contracts/aaveV2.ts @@ -4,7 +4,10 @@ export { AaveV2LendingPool } from "../../typechain/AaveV2LendingPool"; export { AaveV2LendingPoolAddressesProvider } from "../../typechain/AaveV2LendingPoolAddressesProvider"; export { AaveV2LendingPoolCollateralManager } from "../../typechain/AaveV2LendingPoolCollateralManager"; export { AaveV2LendingPoolConfigurator } from "../../typechain/AaveV2LendingPoolConfigurator"; +export { AaveV2LendingRateOracle } from "../../typechain/AaveV2LendingRateOracle"; +export { AaveV2Oracle } from "../../typechain/AaveV2Oracle"; export { AaveV2ProtocolDataProvider } from "../../typechain/AaveV2ProtocolDataProvider"; +export { AaveV2PriceOracle } from "../../typechain/AaveV2PriceOracle"; export { AaveV2StableDebtToken } from "../../typechain/AaveV2StableDebtToken"; export { AaveV2StakedTokenIncentivesController } from "../../typechain/AaveV2StakedTokenIncentivesController"; export { AaveV2VariableDebtToken } from "../../typechain/AaveV2VariableDebtToken"; diff --git a/utils/deploys/deployExternal.ts b/utils/deploys/deployExternal.ts index 4d46ab6ae..b1f91dd39 100644 --- a/utils/deploys/deployExternal.ts +++ b/utils/deploys/deployExternal.ts @@ -163,6 +163,40 @@ import { NonfungiblePositionManager__factory } from "../../typechain/factories/N import { Quoter__factory } from "../../typechain/factories/Quoter__factory"; import { NFTDescriptor__factory } from "../../typechain/factories/NFTDescriptor__factory"; +import { + GenericLogic, + ValidationLogic, + ReserveLogic, + AaveV2AToken, + AaveV2StakedTokenIncentivesController, + AaveV2StableDebtToken, + AaveV2VariableDebtToken, + AaveV2ProtocolDataProvider, + AaveV2LendingPool, + AaveV2LendingPoolAddressesProvider, + AaveV2LendingPoolConfigurator, + AaveV2LendingPoolCollateralManager, + AaveV2DefaultReserveInterestRateStrategy, + AaveV2LendingRateOracle, + AaveV2Oracle, + AaveV2PriceOracle +} from "../contracts/aaveV2"; +import { AaveV2LendingPool__factory } from "../../typechain/factories/AaveV2LendingPool__factory"; +import { AaveV2LendingPoolAddressesProvider__factory } from "../../typechain/factories/AaveV2LendingPoolAddressesProvider__factory"; +import { AaveV2ProtocolDataProvider__factory } from "../../typechain/factories/AaveV2ProtocolDataProvider__factory"; +import { AaveV2LendingPoolConfigurator__factory } from "../../typechain/factories/AaveV2LendingPoolConfigurator__factory"; +import { AaveV2LendingPoolCollateralManager__factory } from "../../typechain/factories/AaveV2LendingPoolCollateralManager__factory"; +import { AaveV2DefaultReserveInterestRateStrategy__factory } from "../../typechain/factories/AaveV2DefaultReserveInterestRateStrategy__factory"; +import { AaveV2AToken__factory } from "../../typechain/factories/AaveV2AToken__factory"; +import { AaveV2StableDebtToken__factory } from "../../typechain/factories/AaveV2StableDebtToken__factory"; +import { AaveV2VariableDebtToken__factory } from "../../typechain/factories/AaveV2VariableDebtToken__factory"; +import { AaveV2StakedTokenIncentivesController__factory } from "../../typechain/factories/AaveV2StakedTokenIncentivesController__factory"; +import { GenericLogic__factory } from "../../typechain/factories/GenericLogic__factory"; +import { ValidationLogic__factory } from "../../typechain/factories/ValidationLogic__factory"; +import { ReserveLogic__factory } from "../../typechain/factories/ReserveLogic__factory"; +import { AaveV2LendingRateOracle__factory } from "../../typechain/factories/AaveV2LendingRateOracle__factory"; +import { AaveV2Oracle__factory } from "../../typechain/factories/AaveV2Oracle__factory"; +import { AaveV2PriceOracle__factory } from "../../typechain/factories/AaveV2PriceOracle__factory"; export default class DeployExternalContracts { private _deployerSigner: Signer; @@ -400,6 +434,109 @@ export default class DeployExternalContracts { return await new LendToAaveMigrator__factory(this._deployerSigner).attach(lendToAaveMigratorAddress); } + // AAVE V2 + public async deployAaveV2LendingPoolAddressesProvider(marketId: string): Promise { + return await new AaveV2LendingPoolAddressesProvider__factory(this._deployerSigner).deploy(marketId); + } + + public async deployAaveV2LendingPool(validationLogicAddress: Address, reserveLogicAddress: Address): Promise { + return await new AaveV2LendingPool__factory( + { + ["__$de8c0cf1a7d7c36c802af9a64fb9d86036$__"]: validationLogicAddress, + ["__$22cd43a9dda9ce44e9b92ba393b88fb9ac$__"]: reserveLogicAddress, + }, + this._deployerSigner + ).deploy(); + } + + public async deployAaveV2LendingPoolConfigurator(): Promise { + return await new AaveV2LendingPoolConfigurator__factory(this._deployerSigner).deploy(); + } + + public async deployAaveV2LendingPoolCollateralManager(): Promise { + return await new AaveV2LendingPoolCollateralManager__factory(this._deployerSigner).deploy(); + } + + public async deployAaveV2LendingRateOracle(): Promise { + return await new AaveV2LendingRateOracle__factory(this._deployerSigner).deploy(); + } + + public async deployAaveV2Oracle( + assets: string[], + sources: [], + fallBackOracle: Address, + weth: Address): Promise { + return await new AaveV2Oracle__factory(this._deployerSigner).deploy(assets, sources, fallBackOracle, weth); + } + + public async deployAaveV2PriceOracle(): Promise { + return await new AaveV2PriceOracle__factory(this._deployerSigner).deploy(); + } + + public async deployAaveV2DefaultReserveInterestRateStrategy( + _AddressesProvider: Address, + _optimalUtilizationRate: BigNumberish = ether(1), + _baseVariableBorrowRate: BigNumberish = ether(1), + _variableRateSlope1: BigNumberish = ether(1), + _variableRateSlope2: BigNumberish = ether(1), + _stableRateSlope1: BigNumberish = ether(1), + _stableRateSlope2: BigNumberish = ether(1), + ): Promise { + return await new AaveV2DefaultReserveInterestRateStrategy__factory(this._deployerSigner).deploy( + _AddressesProvider, + _optimalUtilizationRate, + _baseVariableBorrowRate, + _variableRateSlope1, + _variableRateSlope2, + _stableRateSlope1, + _stableRateSlope2, + ); + } + + public async deployAaveV2ProtocolDataProvider(addressProvider: Address): Promise { + return await new AaveV2ProtocolDataProvider__factory(this._deployerSigner).deploy(addressProvider); + } + + public async deployAaveV2AToken(): Promise { + return await new AaveV2AToken__factory(this._deployerSigner).deploy(); + } + + public async deployAaveV2StableDebtToken(): Promise { + return await new AaveV2StableDebtToken__factory(this._deployerSigner).deploy(); + } + + public async deployAaveV2VariableDebtToken(): Promise { + return await new AaveV2VariableDebtToken__factory(this._deployerSigner).deploy(); + } + + public async deployAaveV2StakedTokenIncentivesController( + stakeToken: Address, + emissionManager: Address + ): Promise { + return await new AaveV2StakedTokenIncentivesController__factory(this._deployerSigner).deploy( + stakeToken, + emissionManager + ); + } + + // AAVE V2 LIBRARIES + public async deployGeneralLogic(): Promise { + return await new GenericLogic__factory(this._deployerSigner).deploy(); + } + + public async deployValidationLogic(genericLogicLibraryAddress: Address): Promise { + return await new ValidationLogic__factory( + { + ["__$52a8a86ab43135662ff256bbc95497e8e3$__"]: genericLogicLibraryAddress, + }, + this._deployerSigner).deploy(); + } + + public async deployReserveLogic(): Promise { + return await new ReserveLogic__factory(this._deployerSigner).deploy(); + } + + // AAVE V2 GOVERNANCE public async deployAaveGovernanceV2( _governanceStrategy: Address, _votingDelay: BigNumber, diff --git a/utils/fixtures/aaveV2Fixture.ts b/utils/fixtures/aaveV2Fixture.ts new file mode 100644 index 000000000..8654c3412 --- /dev/null +++ b/utils/fixtures/aaveV2Fixture.ts @@ -0,0 +1,247 @@ +import DeployHelper from "../deploys"; +import { Signer } from "ethers"; +import { JsonRpcProvider, Web3Provider } from "@ethersproject/providers"; +import { Address } from "../types"; +import { BigNumber, BigNumberish } from "@ethersproject/bignumber"; + +import { + AaveV2Oracle, + AaveV2PriceOracle, + AaveV2LendingPool, + AaveV2ProtocolDataProvider, + AaveV2LendingPoolConfigurator, + AaveV2LendingPoolAddressesProvider, + AaveV2LendingPoolCollateralManager, + AaveV2DefaultReserveInterestRateStrategy, + AaveV2LendingRateOracle +} from "../contracts/aaveV2"; + +// import { +// Executor, +// AaveGovernanceV2, +// AaveTokenV2Mintable +// } from "../contracts/aave"; + +import { ether, getRandomAddress } from "../common"; + +import { ADDRESS_ZERO } from "../constants"; + +export class AaveV2Fixture { + private _deployer: DeployHelper; + private _ownerSigner: Signer; + + public marketId: string; + public lendingPool: AaveV2LendingPool; + public protocolDataProvider: AaveV2ProtocolDataProvider; + public lendingPoolConfigurator: AaveV2LendingPoolConfigurator; + public lendingPoolCollateralManager: AaveV2LendingPoolCollateralManager; + public lendingPoolAddressesProvider: AaveV2LendingPoolAddressesProvider; + public reserveInterestRateStrategy: AaveV2DefaultReserveInterestRateStrategy; + + public priceOracle: AaveV2Oracle; + public fallbackOracle: AaveV2PriceOracle; + public lendingRateOracle: AaveV2LendingRateOracle; + + public treasuryAddress: Address; + public incentivesControllerAddress: Address; + + // TODO: move governance to this fixture + // public executor: Executor; + // public aaveGovernanceV2: AaveGovernanceV2; + // public aaveToken: AaveTokenV2Mintable; + // public stkAaveToken: AaveTokenV2Mintable; + // public governanceStrategy: GovernanceStrategy; + // public aaveProtoGovernance: AaveProtoGovernance; + // public aavePropositionPower: AavePropositionPower; + // public assetVotingWeightPower: AssetVotingWeightProvider; + // public governanceParamsProvider: GovernanceParamsProvider; + + constructor(provider: Web3Provider | JsonRpcProvider, ownerAddress: Address) { + this._ownerSigner = provider.getSigner(ownerAddress); + this._deployer = new DeployHelper(this._ownerSigner); + } + + public async initialize(weth: Address, dai: Address, marketId: string = "Commons"): Promise { + + this.marketId = marketId; + + // deploy libraries + const genericLogicLibraryAddress = (await this._deployer.external.deployGeneralLogic()).address; + const reserveLogicAddress = (await this._deployer.external.deployReserveLogic()).address; + const validationLogicAddress = (await this._deployer.external.deployValidationLogic(genericLogicLibraryAddress)).address; + + // deploy contracts + this.lendingPoolConfigurator = await this._deployer.external.deployAaveV2LendingPoolConfigurator(); + this.lendingPoolCollateralManager = await this._deployer.external.deployAaveV2LendingPoolCollateralManager(); + this.lendingPool = await this._deployer.external.deployAaveV2LendingPool(validationLogicAddress, reserveLogicAddress); + this.lendingPoolAddressesProvider = await this._deployer.external.deployAaveV2LendingPoolAddressesProvider(this.marketId); + this.protocolDataProvider = await this._deployer.external.deployAaveV2ProtocolDataProvider(this.lendingPoolAddressesProvider.address); + this.reserveInterestRateStrategy = await this._deployer.external.deployAaveV2DefaultReserveInterestRateStrategy( + this.lendingPoolAddressesProvider.address + ); + + // deploy oracles + this.lendingRateOracle = await this._deployer.external.deployAaveV2LendingRateOracle(); + // Aave V2 oracle relies on Chainlink oracle and their fallback oracle. For fixture, we would be deploying a mock fallback oracle + // with ability to set asset prices on it, which is comparitively easier than deploying multiple chainlink aggregators. + this.fallbackOracle = await this._deployer.external.deployAaveV2PriceOracle(); + this.priceOracle = await this._deployer.external.deployAaveV2Oracle([], [], this.fallbackOracle.address, weth); + + // set addresses in LendingPoolAddressProvider + await this.lendingPoolAddressesProvider.setPriceOracle(this.priceOracle.address); + await this.lendingPoolAddressesProvider.setLendingRateOracle(this.lendingRateOracle.address); + await this.lendingPoolAddressesProvider.setPoolAdmin(await this._ownerSigner.getAddress()); + await this.lendingPoolAddressesProvider.setLendingPoolCollateralManager(this.lendingPoolCollateralManager.address); + + // LendingPoolAddressProvider creates a new proxy contract and sets the passed in address as the implementation. + // We then fetch the proxy's address and attach it to the contract object, which allows us to use the contract object + // to call functions on the proxy + await this.lendingPoolAddressesProvider.setLendingPoolImpl(this.lendingPool.address); + const proxyPool = await this.lendingPoolAddressesProvider.getLendingPool(); + this.lendingPool = this.lendingPool.attach(proxyPool); + + await this.lendingPoolAddressesProvider.setLendingPoolConfiguratorImpl(this.lendingPoolConfigurator.address); + const proxyConfigurator = await this.lendingPoolAddressesProvider.getLendingPoolConfigurator(); + this.lendingPoolConfigurator = this.lendingPoolConfigurator.attach(proxyConfigurator); + + this.treasuryAddress = await getRandomAddress(); // Tokens are minted to the treasury, so it can't be zero address + this.incentivesControllerAddress = ADDRESS_ZERO; + + // set initial asset prices in ETH + await this.setAssetPriceInOracle(dai, ether(0.001)); // 1 ETH = 1000$ => 1 DAI = 0.001 ETH + + // set initial market rates + const oneRay = BigNumber.from(10).pow(27); // 1e27 + await this.setMarketBorrowRate(weth, oneRay.mul(3).div(100)); + await this.setMarketBorrowRate(dai, oneRay.mul(39).div(1000)); + + // Deploy WETH reserve + await this.deployReserve(weth, "WETH", BigNumber.from(18)); + await this.configureReserve( + weth, + BigNumber.from(8000), // base LTV: 80% + BigNumber.from(8250), // liquidation threshold: 82.5% + BigNumber.from(10500), // liquidation bonus: 105.00% + BigNumber.from(1000), // reserve factor: 10% + true, // enable borrowing on reserve + true // enable stable debts + ); + + // Deploy DAI reserve + await this.deployReserve(dai, "DAI", BigNumber.from(18)); + await this.configureReserve( + dai, + BigNumber.from(7500), // base LTV: 75% + BigNumber.from(8000), // liquidation threshold: 80% + BigNumber.from(10500), // liquidation bonus: 105.00% + BigNumber.from(1000), // reserve factor: 10% + true, // enable borrowing on reserve + true // enable stable debts + ); + + /* + TODO: Move governance to this fixture. + // Deploy Executor + this.executor = await this._deployer.external.deployExecutor( + await this._ownerSigner.getAddress(), + BigNumber.from(0), + BigNumber.from(0), + BigNumber.from(0), + MAX_UINT_256, + BigNumber.from(50), + BigNumber.from(100), + BigNumber.from(50), + ether(100) + ); + + this.aaveToken = await this._deployer.external.deployAaveTokenV2Mintable(); + await this.aaveToken.mint(await this._ownerSigner.getAddress(), ether(100000)); + this.stkAaveToken = await this._deployer.external.deployAaveTokenV2Mintable(); + await this.stkAaveToken.mint(await this._ownerSigner.getAddress(), ether(100000)); + + this.governanceStrategy = await this._deployer.external.deployGovernanceStrategy(this.aaveToken.address, this.stkAaveToken.address); + this.aaveGovernanceV2 = await this._deployer.external.deployAaveGovernanceV2( + this.governanceStrategy.address, + BigNumber.from(0), + await this._ownerSigner.getAddress(), + [this.executor.address] + ); + + this.aaveToken.connect(this._ownerSigner).transfer(await getRandomAddress(), 100); + this.stkAaveToken.connect(this._ownerSigner).transfer(await getRandomAddress(), 100); + await this._deployer.external.deployAaveV2StakedTokenIncentivesController( + this.stkAaveToken.address, this.executor.address + ) + + this.incentivesControllerAddress = (await this._deployer.external.deployAaveV2StakedTokenIncentivesController( + this.stkAaveToken.address, this.executor.address + )).address; + */ + } + + public async deployReserve( + underlyingAsset: Address, + underlyingAssetSymbol: string, + underlyingAssetDecimals: BigNumberish = 18, + treasuryAddress: Address = this.treasuryAddress, + incentivesControllerAddress: Address = this.incentivesControllerAddress, + interestRateStrategyAddress: Address = this.reserveInterestRateStrategy.address + ): Promise { + const aToken = await this._deployer.external.deployAaveV2AToken(); + const stableDebtToken = await this._deployer.external.deployAaveV2StableDebtToken(); + const variableDebtToken = await this._deployer.external.deployAaveV2VariableDebtToken(); + + await this.lendingPoolConfigurator.batchInitReserve( + [ + { + "aTokenImpl": aToken.address, + "stableDebtTokenImpl": stableDebtToken.address, + "variableDebtTokenImpl": variableDebtToken.address, + "underlyingAssetDecimals": underlyingAssetDecimals, + "interestRateStrategyAddress": interestRateStrategyAddress, + "underlyingAsset": underlyingAsset, + "treasury": treasuryAddress, + "incentivesController": incentivesControllerAddress, + "underlyingAssetName": underlyingAssetSymbol, + "aTokenName": `Aave interest bearing ${underlyingAssetSymbol}`, + "aTokenSymbol": `a${underlyingAssetSymbol}`, + "variableDebtTokenName": `Aave variable debt bearing ${underlyingAssetSymbol}`, + "variableDebtTokenSymbol": `variableDebt${underlyingAssetSymbol}`, + "stableDebtTokenName": `Aave stable debt bearing ${underlyingAssetSymbol}`, + "stableDebtTokenSymbol": `stableDebt${underlyingAssetSymbol}`, + "params": "0x", + }, + ] + ); + } + + public async configureReserve( + asset: Address, + baseLTV: BigNumberish, + liquidationThreshold: BigNumberish, + liquidationBonus: BigNumberish, + reserveFactor: BigNumberish, + borrowingEnabled: boolean, + stableBorrowingEnabled: boolean + ): Promise { + + await this.lendingPoolConfigurator.configureReserveAsCollateral( + asset, + baseLTV, + liquidationThreshold, + liquidationBonus + ); + if (borrowingEnabled) { + await this.lendingPoolConfigurator.enableBorrowingOnReserve(asset, stableBorrowingEnabled); + } + await this.lendingPoolConfigurator.setReserveFactor(asset, reserveFactor); + } + + public async setAssetPriceInOracle(asset: Address, price: BigNumberish): Promise { + await this.fallbackOracle.setAssetPrice(asset, price); + } + + public async setMarketBorrowRate(asset: Address, rate: BigNumberish): Promise { + this.lendingRateOracle.setMarketBorrowRate(asset, rate); + } +} diff --git a/utils/fixtures/index.ts b/utils/fixtures/index.ts index dd750ffe9..7bd918025 100644 --- a/utils/fixtures/index.ts +++ b/utils/fixtures/index.ts @@ -1,4 +1,5 @@ export { AaveFixture } from "./aaveFixture"; +export { AaveV2Fixture } from "./aaveV2Fixture"; export { BalancerFixture } from "./balancerFixture"; export { CompoundFixture } from "./compoundFixture"; export { CurveFixture } from "./curveFixture"; diff --git a/utils/test/index.ts b/utils/test/index.ts index dd49fb1ab..c5c760f3c 100644 --- a/utils/test/index.ts +++ b/utils/test/index.ts @@ -4,6 +4,7 @@ import { Address } from "../types"; import { AaveFixture, + AaveV2Fixture, BalancerFixture, CompoundFixture, CurveFixture, @@ -21,6 +22,7 @@ export const getSystemFixture = (ownerAddress: Address) => new SystemFixture(pro export const getProtocolUtils = () => new ProtocolUtils(provider); export const getBlockchainUtils = () => new Blockchain(provider); export const getAaveFixture = (ownerAddress: Address) => new AaveFixture(provider, ownerAddress); +export const getAaveV2Fixture = (ownerAdderss: Address) => new AaveV2Fixture(provider, ownerAdderss); export const getBalancerFixture = (ownerAddress: Address) => new BalancerFixture(provider, ownerAddress); export const getCurveFixture = (ownerAddress: Address) => new CurveFixture(provider, ownerAddress); export const getCompoundFixture = (ownerAddress: Address) => new CompoundFixture(provider, ownerAddress); From e1a87e290c85c7f4ebb0bac8e5276368a7212f36 Mon Sep 17 00:00:00 2001 From: alpha-guy Date: Sun, 18 Jul 2021 14:02:48 +0530 Subject: [PATCH 09/19] Add AaveV2 fixture tests --- test/fixtures/aaveV2.spec.ts | 113 +++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 test/fixtures/aaveV2.spec.ts diff --git a/test/fixtures/aaveV2.spec.ts b/test/fixtures/aaveV2.spec.ts new file mode 100644 index 000000000..3f56def4d --- /dev/null +++ b/test/fixtures/aaveV2.spec.ts @@ -0,0 +1,113 @@ +import "module-alias/register"; + +import { Account } from "@utils/test/types"; +import { + getAccounts, + getSystemFixture, + getWaffleExpect, + getAaveV2Fixture +} from "@utils/test/index"; +import { SystemFixture, AaveV2Fixture } from "@utils/fixtures"; +import { BigNumber } from "@ethersproject/bignumber"; +import { ether } from "@utils/common"; + +const expect = getWaffleExpect(); + +describe("AaveV2Fixture", async () => { + let owner: Account; + + let setup: SystemFixture; + let aaveSetup: AaveV2Fixture; + + before(async () => { + [ + owner, + ] = await getAccounts(); + + setup = getSystemFixture(owner.address); + aaveSetup = getAaveV2Fixture(owner.address); + + await setup.initialize(); + }); + + describe("#initialize", async () => { + async function subject(): Promise { + await aaveSetup.initialize(setup.weth.address, setup.dai.address); + } + + it("should deploy all contracts and set their addresses in the LendingPoolAddressProvider", async () => { + await subject(); + + const addressProvider = aaveSetup.lendingPoolAddressesProvider; + const lendingPoolAddress = await addressProvider.getLendingPool(); + const lendingPoolConfiuratorAddress = await addressProvider.getLendingPoolConfigurator(); + const lendingPoolCollateralManager = await addressProvider.getLendingPoolCollateralManager(); + + expect(lendingPoolAddress).to.eq(aaveSetup.lendingPool.address); + expect(lendingPoolConfiuratorAddress).to.eq(aaveSetup.lendingPoolConfigurator.address); + expect(lendingPoolCollateralManager).to.eq(aaveSetup.lendingPoolCollateralManager.address); + }); + + it("should deploy WETH reserve with correct configuration", async () => { + await subject(); + + const reservesList = await aaveSetup.lendingPool.getReservesList(); + const config = await aaveSetup.protocolDataProvider.getReserveConfigurationData(setup.weth.address); + + expect(reservesList).to.contain(setup.weth.address); + + expect(config.isActive).to.eq(true); + expect(config.isFrozen).to.eq(false); + expect(config.decimals).to.eq(BigNumber.from(18)); + expect(config.ltv).to.eq(BigNumber.from(8000)); + expect(config.liquidationThreshold).to.eq(BigNumber.from(8250)); + expect(config.liquidationBonus).to.eq(BigNumber.from(10500)); + expect(config.reserveFactor).to.eq(BigNumber.from(1000)); + expect(config.borrowingEnabled).to.eq(true); + expect(config.usageAsCollateralEnabled).to.eq(true); + expect(config.stableBorrowRateEnabled).to.eq(true); + }); + + it("should deploy DAI reserve with correct configuration", async () => { + await subject(); + + const reservesList = await aaveSetup.lendingPool.getReservesList(); + const config = await aaveSetup.protocolDataProvider.getReserveConfigurationData(setup.dai.address); + + expect(reservesList).to.contain(setup.weth.address); + + expect(config.isActive).to.eq(true); + expect(config.isFrozen).to.eq(false); + expect(config.decimals).to.eq(BigNumber.from(18)); + expect(config.ltv).to.eq(BigNumber.from(7500)); + expect(config.liquidationThreshold).to.eq(BigNumber.from(8000)); + expect(config.liquidationBonus).to.eq(BigNumber.from(10500)); + expect(config.reserveFactor).to.eq(BigNumber.from(1000)); + expect(config.borrowingEnabled).to.eq(true); + expect(config.usageAsCollateralEnabled).to.eq(true); + expect(config.stableBorrowRateEnabled).to.eq(true); + }); + + it("should set initial asset prices", async () => { + await subject(); + + const wethPriceInEth = await aaveSetup.priceOracle.getAssetPrice(setup.weth.address); + const daiPriceInEth = await aaveSetup.priceOracle.getAssetPrice(setup.dai.address); + + expect(wethPriceInEth).to.eq(ether(1)); + expect(daiPriceInEth).to.eq(ether(0.001)); + }); + + it("should set initial market rates", async () => { + const oneRay = BigNumber.from(10).pow(27); // 1e27 + + await subject(); + + const wethMarketBorrowRate = await aaveSetup.lendingRateOracle.getMarketBorrowRate(setup.weth.address); + const daiMarketBorrowRate = await aaveSetup.lendingRateOracle.getMarketBorrowRate(setup.dai.address); + + expect(wethMarketBorrowRate).to.eq(oneRay.mul(3).div(100)); + expect(daiMarketBorrowRate).to.eq(oneRay.mul(39).div(1000)); + }); + }); +}); \ No newline at end of file From 21a7179165d0d51bf1c1fef275e3d2c24902716f Mon Sep 17 00:00:00 2001 From: alpha-guy Date: Sun, 18 Jul 2021 18:26:16 +0530 Subject: [PATCH 10/19] Fix bug in AaveV2Mock and library contracts --- .../protocol/integration/lib/AaveV2Mock.sol | 24 +++++++++---------- contracts/protocol/integration/lib/AaveV2.sol | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/contracts/mocks/protocol/integration/lib/AaveV2Mock.sol b/contracts/mocks/protocol/integration/lib/AaveV2Mock.sol index 236007b29..f78090006 100644 --- a/contracts/mocks/protocol/integration/lib/AaveV2Mock.sol +++ b/contracts/mocks/protocol/integration/lib/AaveV2Mock.sol @@ -37,7 +37,7 @@ contract AaveV2Mock { pure returns (address, uint256, bytes memory) { - AaveV2.getDepositCalldata(_asset, _amountNotional, _onBehalfOf, _referralCode, _lendingPool); + return AaveV2.getDepositCalldata(_asset, _amountNotional, _onBehalfOf, _referralCode, _lendingPool); } function testInvokeDeposit( @@ -48,7 +48,7 @@ contract AaveV2Mock { ) external { - AaveV2.invokeDeposit(_setToken, _asset, _amountNotional, _lendingPool); + return AaveV2.invokeDeposit(_setToken, _asset, _amountNotional, _lendingPool); } function testGetWithdrawCalldata( @@ -61,7 +61,7 @@ contract AaveV2Mock { pure returns (address, uint256, bytes memory) { - AaveV2.getWithdrawCalldata(_asset, _amountNotional, _receiver, _lendingPool); + return AaveV2.getWithdrawCalldata(_asset, _amountNotional, _receiver, _lendingPool); } function testInvokeWithdraw( @@ -72,7 +72,7 @@ contract AaveV2Mock { ) external { - AaveV2.invokeWithdraw(_setToken, _asset, _amountNotional, _lendingPool); + return AaveV2.invokeWithdraw(_setToken, _asset, _amountNotional, _lendingPool); } function testGetBorrowCalldata( @@ -87,7 +87,7 @@ contract AaveV2Mock { pure returns (address, uint256, bytes memory) { - AaveV2.getBorrowCalldata(_asset, _amountNotional, _interestRateMode, _referralCode, _onBehalfOf, _lendingPool); + return AaveV2.getBorrowCalldata(_asset, _amountNotional, _interestRateMode, _referralCode, _onBehalfOf, _lendingPool); } function testInvokeBorrow( @@ -99,7 +99,7 @@ contract AaveV2Mock { ) external { - AaveV2.invokeBorrow(_setToken, _asset, _amountNotional, _interestRateMode, _lendingPool); + return AaveV2.invokeBorrow(_setToken, _asset, _amountNotional, _interestRateMode, _lendingPool); } function testGetRepayCalldata( @@ -113,7 +113,7 @@ contract AaveV2Mock { pure returns (address, uint256, bytes memory) { - AaveV2.getRepayCalldata(_asset, _amountNotional, _interestRateMode, _onBehalfOf, _lendingPool); + return AaveV2.getRepayCalldata(_asset, _amountNotional, _interestRateMode, _onBehalfOf, _lendingPool); } function testInvokeRepay( @@ -125,7 +125,7 @@ contract AaveV2Mock { ) external { - AaveV2.invokeRepay(_setToken, _asset, _amountNotional, _interestRateMode, _lendingPool); + return AaveV2.invokeRepay(_setToken, _asset, _amountNotional, _interestRateMode, _lendingPool); } function testGetUseReserveAsCollateralCalldata( @@ -137,7 +137,7 @@ contract AaveV2Mock { pure returns (address, uint256, bytes memory) { - AaveV2.getUseReserveAsCollateralCalldata(_asset, _useAsCollateral, _lendingPool); + return AaveV2.getUseReserveAsCollateralCalldata(_asset, _useAsCollateral, _lendingPool); } function testInvokeUseAsCollateral( @@ -148,7 +148,7 @@ contract AaveV2Mock { ) external { - AaveV2.invokeUseAsCollateral(_setToken, _asset, _useAsCollateral, _lendingPool); + return AaveV2.invokeUseAsCollateral(_setToken, _asset, _useAsCollateral, _lendingPool); } function testGetSwapBorrowRateCalldata( @@ -160,7 +160,7 @@ contract AaveV2Mock { pure returns (address, uint256, bytes memory) { - AaveV2.getSwapBorrowRateCalldata(_asset, _rateMode, _lendingPool); + return AaveV2.getSwapBorrowRateCalldata(_asset, _rateMode, _lendingPool); } function testInvokeSwapBorrowRate( @@ -171,7 +171,7 @@ contract AaveV2Mock { ) external { - AaveV2.invokeSwapBorrowRate(_setToken, _asset, _rateMode, _lendingPool); + return AaveV2.invokeSwapBorrowRate(_setToken, _asset, _rateMode, _lendingPool); } /* ============ Helper Functions ============ */ diff --git a/contracts/protocol/integration/lib/AaveV2.sol b/contracts/protocol/integration/lib/AaveV2.sol index fa591affc..f20c379e0 100644 --- a/contracts/protocol/integration/lib/AaveV2.sol +++ b/contracts/protocol/integration/lib/AaveV2.sol @@ -139,7 +139,7 @@ library AaveV2 { returns (address, uint256, bytes memory) { bytes memory callData = abi.encodeWithSignature( - "borrow(address,uint256,address)", + "borrow(address,uint256,uint256,uint16,address)", _asset, _amountNotional, _interestRateMode, @@ -189,7 +189,7 @@ library AaveV2 { returns (address, uint256, bytes memory) { bytes memory callData = abi.encodeWithSignature( - "repay(address,uint256,address)", + "repay(address,uint256,uint256,address)", _asset, _amountNotional, _interestRateMode, From 3b5d02c8dc816e5b53c37c404a2fc54c9478cacd Mon Sep 17 00:00:00 2001 From: alpha-guy Date: Mon, 19 Jul 2021 01:20:41 +0530 Subject: [PATCH 11/19] Add deployWethReserve and deployDaiReserve as separate functions in fixture --- test/fixtures/aaveV2.spec.ts | 80 +++++++++++------ utils/fixtures/aaveV2Fixture.ts | 151 ++++++++++++++++++-------------- 2 files changed, 140 insertions(+), 91 deletions(-) diff --git a/test/fixtures/aaveV2.spec.ts b/test/fixtures/aaveV2.spec.ts index 3f56def4d..fe80cd0d5 100644 --- a/test/fixtures/aaveV2.spec.ts +++ b/test/fixtures/aaveV2.spec.ts @@ -1,6 +1,11 @@ import "module-alias/register"; import { Account } from "@utils/test/types"; +import { + AaveV2AToken, + AaveV2StableDebtToken, + AaveV2VariableDebtToken +} from "@utils/contracts/aaveV2"; import { getAccounts, getSystemFixture, @@ -48,14 +53,45 @@ describe("AaveV2Fixture", async () => { expect(lendingPoolCollateralManager).to.eq(aaveSetup.lendingPoolCollateralManager.address); }); - it("should deploy WETH reserve with correct configuration", async () => { + it("should set initial asset prices and market rates", async () => { + const oneRay = BigNumber.from(10).pow(27); // 1e27 await subject(); + const wethPriceInEth = await aaveSetup.priceOracle.getAssetPrice(setup.weth.address); + const daiPriceInEth = await aaveSetup.priceOracle.getAssetPrice(setup.dai.address); + const wethMarketBorrowRate = await aaveSetup.lendingRateOracle.getMarketBorrowRate(setup.weth.address); + const daiMarketBorrowRate = await aaveSetup.lendingRateOracle.getMarketBorrowRate(setup.dai.address); + + expect(wethPriceInEth).to.eq(ether(1)); + expect(daiPriceInEth).to.eq(ether(0.001)); + expect(wethMarketBorrowRate).to.eq(oneRay.mul(3).div(100)); + expect(daiMarketBorrowRate).to.eq(oneRay.mul(39).div(1000)); + }); + }); + + describe("#deployWethReserve", async () => { + + beforeEach(async () => { + await aaveSetup.initialize(setup.weth.address, setup.dai.address); + }); + + async function subject(): Promise<[AaveV2AToken, AaveV2StableDebtToken, AaveV2VariableDebtToken]> { + return await aaveSetup.deployWethReserve(); + } + + it("should deploy WETH reserve with correct configuration", async () => { + const [aWETH, stableDebtWETH, variableDebtWETH] = await subject(); + const reservesList = await aaveSetup.lendingPool.getReservesList(); + const tokenAddresses = await aaveSetup.protocolDataProvider.getReserveTokensAddresses(setup.weth.address); const config = await aaveSetup.protocolDataProvider.getReserveConfigurationData(setup.weth.address); expect(reservesList).to.contain(setup.weth.address); + expect(aWETH.address).to.eq(tokenAddresses.aTokenAddress); + expect(stableDebtWETH.address).to.eq(tokenAddresses.stableDebtTokenAddress); + expect(variableDebtWETH.address).to.eq(tokenAddresses.variableDebtTokenAddress); + expect(config.isActive).to.eq(true); expect(config.isFrozen).to.eq(false); expect(config.decimals).to.eq(BigNumber.from(18)); @@ -67,14 +103,30 @@ describe("AaveV2Fixture", async () => { expect(config.usageAsCollateralEnabled).to.eq(true); expect(config.stableBorrowRateEnabled).to.eq(true); }); + }); + + describe("#deployDaiReserve", async () => { + + beforeEach(async () => { + await aaveSetup.initialize(setup.weth.address, setup.dai.address); + }); + + async function subject(): Promise<[AaveV2AToken, AaveV2StableDebtToken, AaveV2VariableDebtToken]> { + return await aaveSetup.deployDaiReserve(); + } it("should deploy DAI reserve with correct configuration", async () => { - await subject(); + const [aDAI, stableDebtDAI, variableDebtDAI] = await subject(); const reservesList = await aaveSetup.lendingPool.getReservesList(); + const tokenAddresses = await aaveSetup.protocolDataProvider.getReserveTokensAddresses(setup.dai.address); const config = await aaveSetup.protocolDataProvider.getReserveConfigurationData(setup.dai.address); - expect(reservesList).to.contain(setup.weth.address); + expect(reservesList).to.contain(setup.dai.address); + + expect(aDAI.address).to.eq(tokenAddresses.aTokenAddress); + expect(stableDebtDAI.address).to.eq(tokenAddresses.stableDebtTokenAddress); + expect(variableDebtDAI.address).to.eq(tokenAddresses.variableDebtTokenAddress); expect(config.isActive).to.eq(true); expect(config.isFrozen).to.eq(false); @@ -87,27 +139,5 @@ describe("AaveV2Fixture", async () => { expect(config.usageAsCollateralEnabled).to.eq(true); expect(config.stableBorrowRateEnabled).to.eq(true); }); - - it("should set initial asset prices", async () => { - await subject(); - - const wethPriceInEth = await aaveSetup.priceOracle.getAssetPrice(setup.weth.address); - const daiPriceInEth = await aaveSetup.priceOracle.getAssetPrice(setup.dai.address); - - expect(wethPriceInEth).to.eq(ether(1)); - expect(daiPriceInEth).to.eq(ether(0.001)); - }); - - it("should set initial market rates", async () => { - const oneRay = BigNumber.from(10).pow(27); // 1e27 - - await subject(); - - const wethMarketBorrowRate = await aaveSetup.lendingRateOracle.getMarketBorrowRate(setup.weth.address); - const daiMarketBorrowRate = await aaveSetup.lendingRateOracle.getMarketBorrowRate(setup.dai.address); - - expect(wethMarketBorrowRate).to.eq(oneRay.mul(3).div(100)); - expect(daiMarketBorrowRate).to.eq(oneRay.mul(39).div(1000)); - }); }); }); \ No newline at end of file diff --git a/utils/fixtures/aaveV2Fixture.ts b/utils/fixtures/aaveV2Fixture.ts index 8654c3412..764778d1c 100644 --- a/utils/fixtures/aaveV2Fixture.ts +++ b/utils/fixtures/aaveV2Fixture.ts @@ -13,7 +13,10 @@ import { AaveV2LendingPoolAddressesProvider, AaveV2LendingPoolCollateralManager, AaveV2DefaultReserveInterestRateStrategy, - AaveV2LendingRateOracle + AaveV2LendingRateOracle, + AaveV2AToken, + AaveV2StableDebtToken, + AaveV2VariableDebtToken } from "../contracts/aaveV2"; // import { @@ -30,6 +33,9 @@ export class AaveV2Fixture { private _deployer: DeployHelper; private _ownerSigner: Signer; + private weth: Address; + private dai: Address; + public marketId: string; public lendingPool: AaveV2LendingPool; public protocolDataProvider: AaveV2ProtocolDataProvider; @@ -63,6 +69,8 @@ export class AaveV2Fixture { public async initialize(weth: Address, dai: Address, marketId: string = "Commons"): Promise { + this.dai = dai; + this.weth = weth; this.marketId = marketId; // deploy libraries @@ -115,68 +123,44 @@ export class AaveV2Fixture { await this.setMarketBorrowRate(weth, oneRay.mul(3).div(100)); await this.setMarketBorrowRate(dai, oneRay.mul(39).div(1000)); - // Deploy WETH reserve - await this.deployReserve(weth, "WETH", BigNumber.from(18)); - await this.configureReserve( - weth, - BigNumber.from(8000), // base LTV: 80% - BigNumber.from(8250), // liquidation threshold: 82.5% - BigNumber.from(10500), // liquidation bonus: 105.00% - BigNumber.from(1000), // reserve factor: 10% - true, // enable borrowing on reserve - true // enable stable debts - ); - - // Deploy DAI reserve - await this.deployReserve(dai, "DAI", BigNumber.from(18)); - await this.configureReserve( - dai, - BigNumber.from(7500), // base LTV: 75% - BigNumber.from(8000), // liquidation threshold: 80% - BigNumber.from(10500), // liquidation bonus: 105.00% - BigNumber.from(1000), // reserve factor: 10% - true, // enable borrowing on reserve - true // enable stable debts - ); - /* - TODO: Move governance to this fixture. - // Deploy Executor - this.executor = await this._deployer.external.deployExecutor( - await this._ownerSigner.getAddress(), - BigNumber.from(0), - BigNumber.from(0), - BigNumber.from(0), - MAX_UINT_256, - BigNumber.from(50), - BigNumber.from(100), - BigNumber.from(50), - ether(100) - ); - - this.aaveToken = await this._deployer.external.deployAaveTokenV2Mintable(); - await this.aaveToken.mint(await this._ownerSigner.getAddress(), ether(100000)); - this.stkAaveToken = await this._deployer.external.deployAaveTokenV2Mintable(); - await this.stkAaveToken.mint(await this._ownerSigner.getAddress(), ether(100000)); - - this.governanceStrategy = await this._deployer.external.deployGovernanceStrategy(this.aaveToken.address, this.stkAaveToken.address); - this.aaveGovernanceV2 = await this._deployer.external.deployAaveGovernanceV2( - this.governanceStrategy.address, - BigNumber.from(0), - await this._ownerSigner.getAddress(), - [this.executor.address] - ); - - this.aaveToken.connect(this._ownerSigner).transfer(await getRandomAddress(), 100); - this.stkAaveToken.connect(this._ownerSigner).transfer(await getRandomAddress(), 100); - await this._deployer.external.deployAaveV2StakedTokenIncentivesController( - this.stkAaveToken.address, this.executor.address - ) - - this.incentivesControllerAddress = (await this._deployer.external.deployAaveV2StakedTokenIncentivesController( - this.stkAaveToken.address, this.executor.address - )).address; - */ + TODO: Move governance to this fixture. + // Deploy Executor + this.executor = await this._deployer.external.deployExecutor( + await this._ownerSigner.getAddress(), + BigNumber.from(0), + BigNumber.from(0), + BigNumber.from(0), + MAX_UINT_256, + BigNumber.from(50), + BigNumber.from(100), + BigNumber.from(50), + ether(100) + ); + + this.aaveToken = await this._deployer.external.deployAaveTokenV2Mintable(); + await this.aaveToken.mint(await this._ownerSigner.getAddress(), ether(100000)); + this.stkAaveToken = await this._deployer.external.deployAaveTokenV2Mintable(); + await this.stkAaveToken.mint(await this._ownerSigner.getAddress(), ether(100000)); + + this.governanceStrategy = await this._deployer.external.deployGovernanceStrategy(this.aaveToken.address, this.stkAaveToken.address); + this.aaveGovernanceV2 = await this._deployer.external.deployAaveGovernanceV2( + this.governanceStrategy.address, + BigNumber.from(0), + await this._ownerSigner.getAddress(), + [this.executor.address] + ); + + this.aaveToken.connect(this._ownerSigner).transfer(await getRandomAddress(), 100); + this.stkAaveToken.connect(this._ownerSigner).transfer(await getRandomAddress(), 100); + await this._deployer.external.deployAaveV2StakedTokenIncentivesController( + this.stkAaveToken.address, this.executor.address + ) + + this.incentivesControllerAddress = (await this._deployer.external.deployAaveV2StakedTokenIncentivesController( + this.stkAaveToken.address, this.executor.address + )).address; + */ } public async deployReserve( @@ -186,10 +170,10 @@ export class AaveV2Fixture { treasuryAddress: Address = this.treasuryAddress, incentivesControllerAddress: Address = this.incentivesControllerAddress, interestRateStrategyAddress: Address = this.reserveInterestRateStrategy.address - ): Promise { - const aToken = await this._deployer.external.deployAaveV2AToken(); - const stableDebtToken = await this._deployer.external.deployAaveV2StableDebtToken(); - const variableDebtToken = await this._deployer.external.deployAaveV2VariableDebtToken(); + ): Promise<[AaveV2AToken, AaveV2StableDebtToken, AaveV2VariableDebtToken]> { + let aToken = await this._deployer.external.deployAaveV2AToken(); + let stableDebtToken = await this._deployer.external.deployAaveV2StableDebtToken(); + let variableDebtToken = await this._deployer.external.deployAaveV2VariableDebtToken(); await this.lendingPoolConfigurator.batchInitReserve( [ @@ -213,6 +197,13 @@ export class AaveV2Fixture { }, ] ); + + const tokenAddresses = await this.protocolDataProvider.getReserveTokensAddresses(underlyingAsset); + aToken = aToken.attach(tokenAddresses.aTokenAddress); + stableDebtToken = stableDebtToken.attach(tokenAddresses.stableDebtTokenAddress); + variableDebtToken = variableDebtToken.attach(tokenAddresses.variableDebtTokenAddress); + + return [aToken, stableDebtToken, variableDebtToken]; } public async configureReserve( @@ -244,4 +235,32 @@ export class AaveV2Fixture { public async setMarketBorrowRate(asset: Address, rate: BigNumberish): Promise { this.lendingRateOracle.setMarketBorrowRate(asset, rate); } + + public async deployWethReserve(weth: Address = this.weth): Promise<[AaveV2AToken, AaveV2StableDebtToken, AaveV2VariableDebtToken]> { + const [aWETH, stableDebtWETH, variableDebtWETH] = await this.deployReserve(weth, "WETH", BigNumber.from(18)); + await this.configureReserve( + weth, + BigNumber.from(8000), // base LTV: 80% + BigNumber.from(8250), // liquidation threshold: 82.5% + BigNumber.from(10500), // liquidation bonus: 105.00% + BigNumber.from(1000), // reserve factor: 10% + true, // enable borrowing on reserve + true // enable stable debts + ); + return [aWETH, stableDebtWETH, variableDebtWETH]; + } + + public async deployDaiReserve(dai: Address = this.dai): Promise<[AaveV2AToken, AaveV2StableDebtToken, AaveV2VariableDebtToken]> { + const [aDAI, stableDebtDAI, variableDebtDAI] = await this.deployReserve(dai, "DAI", BigNumber.from(18)); + await this.configureReserve( + dai, + BigNumber.from(7500), // base LTV: 75% + BigNumber.from(8000), // liquidation threshold: 80% + BigNumber.from(10500), // liquidation bonus: 105.00% + BigNumber.from(1000), // reserve factor: 10% + true, // enable borrowing on reserve + true // enable stable debts + ); + return [aDAI, stableDebtDAI, variableDebtDAI]; + } } From 8865f16f8f8c30bf45229109077b0518c5d9994c Mon Sep 17 00:00:00 2001 From: alpha-guy Date: Mon, 19 Jul 2021 16:47:38 +0530 Subject: [PATCH 12/19] Add tests for Aave V2 Library contract --- .../protocol/integration/lib/AaveV2Mock.sol | 12 +- contracts/protocol/integration/lib/AaveV2.sol | 8 +- test/protocol/integration/lib/aaveV2.spec.ts | 689 ++++++++++++++++++ 3 files changed, 699 insertions(+), 10 deletions(-) create mode 100644 test/protocol/integration/lib/aaveV2.spec.ts diff --git a/contracts/mocks/protocol/integration/lib/AaveV2Mock.sol b/contracts/mocks/protocol/integration/lib/AaveV2Mock.sol index f78090006..115b6ead4 100644 --- a/contracts/mocks/protocol/integration/lib/AaveV2Mock.sol +++ b/contracts/mocks/protocol/integration/lib/AaveV2Mock.sol @@ -140,7 +140,7 @@ contract AaveV2Mock { return AaveV2.getUseReserveAsCollateralCalldata(_asset, _useAsCollateral, _lendingPool); } - function testInvokeUseAsCollateral( + function testInvokeUseReserveAsCollateral( ISetToken _setToken, IERC20 _asset, bool _useAsCollateral, @@ -148,10 +148,10 @@ contract AaveV2Mock { ) external { - return AaveV2.invokeUseAsCollateral(_setToken, _asset, _useAsCollateral, _lendingPool); + return AaveV2.invokeUseReserveAsCollateral(_setToken, _asset, _useAsCollateral, _lendingPool); } - function testGetSwapBorrowRateCalldata( + function testGetSwapBorrowRateModeCalldata( address _asset, uint256 _rateMode, address _lendingPool @@ -160,10 +160,10 @@ contract AaveV2Mock { pure returns (address, uint256, bytes memory) { - return AaveV2.getSwapBorrowRateCalldata(_asset, _rateMode, _lendingPool); + return AaveV2.getSwapBorrowRateModeCalldata(_asset, _rateMode, _lendingPool); } - function testInvokeSwapBorrowRate( + function testInvokeSwapBorrowRateMode( ISetToken _setToken, IERC20 _asset, uint256 _rateMode, @@ -171,7 +171,7 @@ contract AaveV2Mock { ) external { - return AaveV2.invokeSwapBorrowRate(_setToken, _asset, _rateMode, _lendingPool); + return AaveV2.invokeSwapBorrowRateMode(_setToken, _asset, _rateMode, _lendingPool); } /* ============ Helper Functions ============ */ diff --git a/contracts/protocol/integration/lib/AaveV2.sol b/contracts/protocol/integration/lib/AaveV2.sol index f20c379e0..6009760d7 100644 --- a/contracts/protocol/integration/lib/AaveV2.sol +++ b/contracts/protocol/integration/lib/AaveV2.sol @@ -246,7 +246,7 @@ library AaveV2 { /** * Invoke an asset to be used as collateral on Aave from SetToken */ - function invokeUseAsCollateral( + function invokeUseReserveAsCollateral( ISetToken _setToken, IERC20 _asset, bool _useAsCollateral, @@ -266,7 +266,7 @@ library AaveV2 { /** * Get swapBorrowRate calldata from SetToken */ - function getSwapBorrowRateCalldata( + function getSwapBorrowRateModeCalldata( address _asset, uint256 _rateMode, address _lendingPool @@ -288,7 +288,7 @@ library AaveV2 { * Invoke to swap borrow rate of SetToken * Note: Aave allows a borrower to toggle his debt between stable and variable mode */ - function invokeSwapBorrowRate( + function invokeSwapBorrowRateMode( ISetToken _setToken, IERC20 _asset, uint256 _rateMode, @@ -296,7 +296,7 @@ library AaveV2 { ) external { - ( , , bytes memory callData) = getSwapBorrowRateCalldata( + ( , , bytes memory callData) = getSwapBorrowRateModeCalldata( address(_asset), _rateMode, _lendingPool diff --git a/test/protocol/integration/lib/aaveV2.spec.ts b/test/protocol/integration/lib/aaveV2.spec.ts new file mode 100644 index 000000000..6b54602d1 --- /dev/null +++ b/test/protocol/integration/lib/aaveV2.spec.ts @@ -0,0 +1,689 @@ +import "module-alias/register"; +import { BigNumber } from "@ethersproject/bignumber"; + +import { Address } from "@utils/types"; +import { Account } from "@utils/test/types"; +import { AaveV2, AaveV2Mock, InvokeMock, SetToken } from "@utils/contracts"; +import DeployHelper from "@utils/deploys"; +import { + ether, +} from "@utils/index"; +import { + getAccounts, + getSystemFixture, + getWaffleExpect, + addSnapshotBeforeRestoreAfterEach, + getAaveV2Fixture, +} from "@utils/test/index"; +import { AaveV2Fixture, SystemFixture } from "@utils/fixtures"; +import { ADDRESS_ZERO, MAX_UINT_256, ONE, ZERO } from "@utils/constants"; +import { AaveV2AToken } from "@typechain/AaveV2AToken"; +import { AaveV2StableDebtToken } from "@typechain/AaveV2StableDebtToken"; +import { AaveV2VariableDebtToken } from "@typechain/AaveV2VariableDebtToken"; + +const expect = getWaffleExpect(); + +describe("AaveV2", () => { + let owner: Account; + let deployer: DeployHelper; + + let aaveLib: AaveV2; + let aaveLibMock: AaveV2Mock; + let invokeLibMock: InvokeMock; + let setup: SystemFixture; + let aaveSetup: AaveV2Fixture; + + let aWETH: AaveV2AToken; + let stableDebtDAI: AaveV2StableDebtToken; + let variableDebtDAI: AaveV2VariableDebtToken; + + let setToken: SetToken; + + const stableInterestRateMode = ONE; + const variableInterestRateMode = BigNumber.from(2); + + before(async () => { + [ + owner, + ] = await getAccounts(); + + deployer = new DeployHelper(owner.wallet); + setup = getSystemFixture(owner.address); + await setup.initialize(); + + aaveLib = await deployer.libraries.deployAaveV2(); + aaveLibMock = await deployer.mocks.deployAaveV2Mock( + "contracts/protocol/integration/lib/AaveV2.sol:AaveV2", + aaveLib.address + ); + invokeLibMock = await deployer.mocks.deployInvokeMock(); + await setup.controller.addModule(aaveLibMock.address); + await setup.controller.addModule(invokeLibMock.address); + + aaveSetup = getAaveV2Fixture(owner.address); + await aaveSetup.initialize(setup.weth.address, setup.dai.address); + + [aWETH, , ] = await aaveSetup.deployWethReserve(); + [, stableDebtDAI, variableDebtDAI] = await aaveSetup.deployDaiReserve(); + + // Create liquidity + await setup.weth.connect(owner.wallet).approve(aaveSetup.lendingPool.address, ether(100)); + await aaveSetup.lendingPool.connect(owner.wallet).deposit( + setup.weth.address, + ether(100), + owner.address, + ZERO + ); + await setup.dai.connect(owner.wallet).approve(aaveSetup.lendingPool.address, ether(1000)); + await aaveSetup.lendingPool.connect(owner.wallet).deposit( + setup.dai.address, + ether(1000), + owner.address, + ZERO + ); + + setToken = await setup.createSetToken( + [setup.dai.address, setup.weth.address], + [ether(1000), ether(10)], + [setup.issuanceModule.address, aaveLibMock.address, invokeLibMock.address] + ); + + await setup.issuanceModule.initialize(setToken.address, ADDRESS_ZERO); + await invokeLibMock.initializeModuleOnSet(setToken.address); + await aaveLibMock.initializeModuleOnSet(setToken.address); + + await setup.dai.approve(setup.issuanceModule.address, MAX_UINT_256); + await setup.weth.approve(setup.issuanceModule.address, MAX_UINT_256); + await setup.issuanceModule.issue(setToken.address, ether(1), owner.address); + }); + + addSnapshotBeforeRestoreAfterEach(); + + describe("#getDepositCalldata", async () => { + let subjectAsset: Address; + let subjectAmountNotional: BigNumber; + let subjectOnBehalfOf: Address; + let subjectReferralCode: BigNumber; + let subjectLendingPool: Address; + + beforeEach(async () => { + subjectAsset = setup.weth.address; + subjectAmountNotional = ether(1); + subjectOnBehalfOf = owner.address; + subjectReferralCode = ZERO; + subjectLendingPool = aaveSetup.lendingPool.address; + }); + + async function subject(): Promise { + return await aaveLibMock.testGetDepositCalldata( + subjectAsset, + subjectAmountNotional, + subjectOnBehalfOf, + subjectReferralCode, + subjectLendingPool + ); + } + + it("should get correct data", async () => { + const [target, value, calldata] = await subject(); + const expectedCalldata = aaveSetup.lendingPool.interface.encodeFunctionData("deposit", [ + subjectAsset, + subjectAmountNotional, + subjectOnBehalfOf, + subjectReferralCode, + ]); + + expect(target).to.eq(subjectLendingPool); + expect(value).to.eq(ZERO); + expect(calldata).to.eq(expectedCalldata); + }); + }); + + describe("#invokeDeposit", async () => { + let subjectSetToken: Address; + let subjectAsset: Address; + let subjectAmountNotional: BigNumber; + let subjectLendingPool: Address; + + beforeEach(async () => { + await invokeLibMock.testInvokeApprove(setToken.address, setup.weth.address, aaveSetup.lendingPool.address, MAX_UINT_256); + + subjectSetToken = setToken.address; + subjectAsset = setup.weth.address; + subjectAmountNotional = ether(1); + subjectLendingPool = aaveSetup.lendingPool.address; + }); + + async function subject(): Promise { + return await aaveLibMock.testInvokeDeposit( + subjectSetToken, + subjectAsset, + subjectAmountNotional, + subjectLendingPool + ); + } + + it("should mint aWETH", async () => { + const previousATokenBalance = await aWETH.balanceOf(setToken.address); + await subject(); + const currentATokenBalance = await aWETH.balanceOf(setToken.address); + const expectedATokenBalance = previousATokenBalance.add(subjectAmountNotional); + expect(currentATokenBalance).to.eq(expectedATokenBalance); + }); + }); + + describe("#getUseReserveAsCollateralCalldata", async () => { + let subjectAsset: Address; + let subjectUseAsCollateral: boolean; + let subjectLendingPool: Address; + + beforeEach(async () => { + subjectAsset = setup.weth.address; + subjectUseAsCollateral = true; + subjectLendingPool = aaveSetup.lendingPool.address; + }); + + async function subject(): Promise { + return await aaveLibMock.testGetUseReserveAsCollateralCalldata( + subjectAsset, + subjectUseAsCollateral, + subjectLendingPool + ); + } + + it("should get correct data", async () => { + const [target, value, calldata] = await subject(); + const expectedCalldata = aaveSetup.lendingPool.interface.encodeFunctionData("setUserUseReserveAsCollateral", [ + subjectAsset, + subjectUseAsCollateral, + ]); + + expect(target).to.eq(subjectLendingPool); + expect(value).to.eq(ZERO); + expect(calldata).to.eq(expectedCalldata); + }); + + describe("when use as collateral is false", async () => { + beforeEach(async () => { + subjectUseAsCollateral = false; + }); + + it("should get correct data", async () => { + const [target, value, calldata] = await subject(); + const expectedCalldata = aaveSetup.lendingPool.interface.encodeFunctionData("setUserUseReserveAsCollateral", [ + subjectAsset, + subjectUseAsCollateral, + ]); + + expect(target).to.eq(subjectLendingPool); + expect(value).to.eq(ZERO); + expect(calldata).to.eq(expectedCalldata); + }); + }); + }); + + describe("#invokeUseReserveAsCollateral", async () => { + let subjectSetToken: Address; + let subjectAsset: Address; + let subjectUseAsCollateral: boolean; + let subjectLendingPool: Address; + + beforeEach(async () => { + await invokeLibMock.testInvokeApprove(setToken.address, setup.weth.address, aaveSetup.lendingPool.address, MAX_UINT_256); + await aaveLibMock.testInvokeDeposit(setToken.address, setup.weth.address, ether(1), aaveSetup.lendingPool.address); + + subjectSetToken = setToken.address; + subjectAsset = setup.weth.address; + subjectUseAsCollateral = true; + subjectLendingPool = aaveSetup.lendingPool.address; + }); + + async function subject(): Promise { + return await aaveLibMock.testInvokeUseReserveAsCollateral( + subjectSetToken, + subjectAsset, + subjectUseAsCollateral, + subjectLendingPool + ); + } + + it("should set use reserve as collateral by SetToken to true", async () => { + await subject(); + const currentUseAsCollateral = (await aaveSetup.protocolDataProvider.getUserReserveData( + subjectAsset, + subjectSetToken + )).usageAsCollateralEnabled; + const expectedUseAsCollateral = true; + expect(currentUseAsCollateral).to.eq(expectedUseAsCollateral); + }); + + describe("when use as collateral is false", async () => { + beforeEach(async () => { + subjectUseAsCollateral = false; + }); + + it("should set use reserve as collateral by SetToken to false", async () => { + await subject(); + const currentUseAsCollateral = (await aaveSetup.protocolDataProvider.getUserReserveData( + subjectAsset, + subjectSetToken + )).usageAsCollateralEnabled; + const expectedUseAsCollateral = false; + expect(currentUseAsCollateral).to.eq(expectedUseAsCollateral); + }); + }); + }); + + describe("#getWithdrawCalldata", async () => { + let subjectAsset: Address; + let subjectAmountNotional: BigNumber; + let subjectReceiver: Address; + let subjectLendingPool: Address; + + beforeEach(async () => { + subjectAsset = setup.weth.address; + subjectAmountNotional = ether(1); + subjectReceiver = owner.address; + subjectLendingPool = aaveSetup.lendingPool.address; + }); + + async function subject(): Promise { + return await aaveLibMock.testGetWithdrawCalldata( + subjectAsset, + subjectAmountNotional, + subjectReceiver, + subjectLendingPool + ); + } + + it("should get correct data", async () => { + const [target, value, calldata] = await subject(); + const expectedCalldata = aaveSetup.lendingPool.interface.encodeFunctionData("withdraw", [ + subjectAsset, + subjectAmountNotional, + subjectReceiver, + ]); + + expect(target).to.eq(subjectLendingPool); + expect(value).to.eq(ZERO); + expect(calldata).to.eq(expectedCalldata); + }); + }); + + describe("#invokeWithdraw", async () => { + let subjectSetToken: Address; + let subjectAsset: Address; + let subjectAmountNotional: BigNumber; + let subjectLendingPool: Address; + + beforeEach(async () => { + await invokeLibMock.testInvokeApprove(setToken.address, setup.weth.address, aaveSetup.lendingPool.address, MAX_UINT_256); + await aaveLibMock.testInvokeDeposit(setToken.address, setup.weth.address, ether(1), aaveSetup.lendingPool.address); + + subjectSetToken = setToken.address; + subjectAsset = setup.weth.address; + subjectAmountNotional = ether(1); + subjectLendingPool = aaveSetup.lendingPool.address; + }); + + async function subject(): Promise { + return await aaveLibMock.testInvokeWithdraw( + subjectSetToken, + subjectAsset, + subjectAmountNotional, + subjectLendingPool + ); + } + + it("should burn aWETH and return underlying WETH", async () => { + const previousATokenBalance = await aWETH.balanceOf(setToken.address); + const previousUnderlyingBalance = await setup.weth.balanceOf(setToken.address); + await subject(); + const currentATokenBalance = await aWETH.balanceOf(setToken.address); + const currentUnderlyingBalance = await setup.weth.balanceOf(setToken.address); + + const expectedATokenBalance = previousATokenBalance.sub(subjectAmountNotional); + const expectedUnderlyingBalance = previousUnderlyingBalance.add(subjectAmountNotional); // 1:1 ratio for aTokena & underlying + + expect(currentATokenBalance).to.eq(expectedATokenBalance); + expect(currentUnderlyingBalance).to.eq(expectedUnderlyingBalance); + }); + }); + + describe("#getBorrowCalldata", async () => { + let subjectAsset: Address; + let subjectAmountNotional: BigNumber; + let subjectInterestRateMode: BigNumber; + let subjectReferralCode: BigNumber; + let subjectOnBehalfOf: Address; + let subjectLendingPool: Address; + + beforeEach(async () => { + subjectAsset = setup.weth.address; + subjectAmountNotional = ether(1); + subjectInterestRateMode = stableInterestRateMode; + subjectOnBehalfOf = owner.address; + subjectReferralCode = ZERO; + subjectLendingPool = aaveSetup.lendingPool.address; + }); + + async function subject(): Promise { + return await aaveLibMock.testGetBorrowCalldata( + subjectAsset, + subjectAmountNotional, + subjectInterestRateMode, + subjectReferralCode, + subjectOnBehalfOf, + subjectLendingPool + ); + } + + it("should get correct data", async () => { + const [target, value, calldata] = await subject(); + const expectedCalldata = aaveSetup.lendingPool.interface.encodeFunctionData("borrow", [ + subjectAsset, + subjectAmountNotional, + subjectInterestRateMode, + subjectReferralCode, + subjectOnBehalfOf, + ]); + + expect(target).to.eq(subjectLendingPool); + expect(value).to.eq(ZERO); + expect(calldata).to.eq(expectedCalldata); + }); + }); + + describe("#invokeBorrow", async () => { + let subjectSetToken: Address; + let subjectAsset: Address; + let subjectAmountNotional: BigNumber; + let subjectInterestRateMode: BigNumber; + let subjectLendingPool: Address; + + beforeEach(async () => { + await invokeLibMock.testInvokeApprove(setToken.address, setup.weth.address, aaveSetup.lendingPool.address, MAX_UINT_256); + await aaveLibMock.testInvokeDeposit(setToken.address, setup.weth.address, ether(1), aaveSetup.lendingPool.address); + await aaveLibMock.testInvokeUseReserveAsCollateral(setToken.address, setup.weth.address, true, aaveSetup.lendingPool.address); + + subjectSetToken = setToken.address; + subjectAsset = setup.dai.address; + subjectAmountNotional = ether(100); + subjectLendingPool = aaveSetup.lendingPool.address; + }); + + async function subject(): Promise { + return await aaveLibMock.testInvokeBorrow( + subjectSetToken, + subjectAsset, + subjectAmountNotional, + subjectInterestRateMode, + subjectLendingPool + ); + } + + describe("when selected intereset rate mode is stable", async () => { + beforeEach(async () => { + subjectInterestRateMode = stableInterestRateMode; + }); + + it("should mint stableDebtDAI", async () => { + const previousDebtTokenBalance = await stableDebtDAI.balanceOf(setToken.address); + await subject(); + const currentDebtTokenBalance = await stableDebtDAI.balanceOf(setToken.address); + const expectedDebtTokenBalance = previousDebtTokenBalance.add(subjectAmountNotional); + expect(currentDebtTokenBalance).to.eq(expectedDebtTokenBalance); + }); + }); + + describe("when selected intereset rate mode is variable", async () => { + beforeEach(async () => { + subjectInterestRateMode = variableInterestRateMode; + }); + + it("should mint variableDebtDAI", async () => { + const previousDebtTokenBalance = await variableDebtDAI.balanceOf(setToken.address); + await subject(); + const currentDebtTokenBalance = await variableDebtDAI.balanceOf(setToken.address); + const expectedDebtTokenBalance = previousDebtTokenBalance.add(subjectAmountNotional); + expect(currentDebtTokenBalance).to.eq(expectedDebtTokenBalance); + }); + }); + }); + + describe("#getRepayCalldata", async () => { + let subjectAsset: Address; + let subjectAmountNotional: BigNumber; + let subjectOnBehalfOf: Address; + let subjectInterestRateMode: BigNumber; + let subjectLendingPool: Address; + + beforeEach(async () => { + subjectAsset = setup.weth.address; + subjectAmountNotional = ether(1); + subjectOnBehalfOf = owner.address; + subjectInterestRateMode = variableInterestRateMode; + subjectLendingPool = aaveSetup.lendingPool.address; + }); + + async function subject(): Promise { + return await aaveLibMock.testGetRepayCalldata( + subjectAsset, + subjectAmountNotional, + subjectInterestRateMode, + subjectOnBehalfOf, + subjectLendingPool + ); + } + + it("should get correct data", async () => { + const [target, value, calldata] = await subject(); + const expectedCalldata = aaveSetup.lendingPool.interface.encodeFunctionData("repay", [ + subjectAsset, + subjectAmountNotional, + subjectInterestRateMode, + subjectOnBehalfOf, + ]); + + expect(target).to.eq(subjectLendingPool); + expect(value).to.eq(ZERO); + expect(calldata).to.eq(expectedCalldata); + }); + }); + + describe("#invokeRepay", async () => { + let subjectSetToken: Address; + let subjectAsset: Address; + let subjectAmountNotional: BigNumber; + let subjectInterestRateMode: BigNumber; + let subjectLendingPool: Address; + + beforeEach(async () => { + await invokeLibMock.testInvokeApprove(setToken.address, setup.weth.address, aaveSetup.lendingPool.address, MAX_UINT_256); + await aaveLibMock.testInvokeDeposit(setToken.address, setup.weth.address, ether(1), aaveSetup.lendingPool.address); + await aaveLibMock.testInvokeUseReserveAsCollateral(setToken.address, setup.weth.address, true, aaveSetup.lendingPool.address); + await invokeLibMock.testInvokeApprove(setToken.address, setup.dai.address, aaveSetup.lendingPool.address, MAX_UINT_256); // for repaying + + subjectSetToken = setToken.address; + subjectAsset = setup.dai.address; + subjectAmountNotional = ether(100); + subjectLendingPool = aaveSetup.lendingPool.address; + }); + + async function subject(): Promise { + return await aaveLibMock.testInvokeRepay( + subjectSetToken, + subjectAsset, + subjectAmountNotional, + subjectInterestRateMode, + subjectLendingPool + ); + } + + describe("when selected intereset rate mode is stable", async () => { + beforeEach(async () => { + await aaveLibMock.testInvokeBorrow( + subjectSetToken, + subjectAsset, + subjectAmountNotional, + stableInterestRateMode, // stable mode + subjectLendingPool + ); + + subjectInterestRateMode = stableInterestRateMode; + }); + + it("should repay DAI and burn stableDebtDAI", async () => { + // const previousDebtTokenBalance = await stableDebtDAI.balanceOf(setToken.address); + const previousUnderlyingBalance = await setup.dai.balanceOf(setToken.address); + await subject(); + // const currentDebtTokenBalance = await stableDebtDAI.balanceOf(setToken.address); + const currentUnderlyingBalance = await setup.dai.balanceOf(setToken.address); + + // const expectedDebtTokenBalance = previousDebtTokenBalance.sub(subjectAmountNotional); + const expectedUnderlyingBalance = previousUnderlyingBalance.sub(subjectAmountNotional); + + // expect(currentDebtTokenBalance).to.eq(expectedDebtTokenBalance); + expect(currentUnderlyingBalance).to.eq(expectedUnderlyingBalance); + }); + }); + + describe("when selected intereset rate mode is variable", async () => { + beforeEach(async () => { + await aaveLibMock.testInvokeBorrow( + subjectSetToken, + subjectAsset, + subjectAmountNotional, + variableInterestRateMode, // variable mode + subjectLendingPool + ); + + subjectInterestRateMode = variableInterestRateMode; + }); + + it("should repay DAI and burn variableDebtDAI", async () => { + // const previousDebtTokenBalance = await variableDebtDAI.balanceOf(setToken.address); + const previousUnderlyingBalance = await setup.dai.balanceOf(setToken.address); + await subject(); + // const currentDebtTokenBalance = await variableDebtDAI.balanceOf(setToken.address); + const currentUnderlyingBalance = await setup.dai.balanceOf(setToken.address); + + // const expectedDebtTokenBalance = previousDebtTokenBalance.sub(subjectAmountNotional); + const expectedUnderlyingBalance = previousUnderlyingBalance.sub(subjectAmountNotional); + + // expect(currentDebtTokenBalance).to.eq(expectedDebtTokenBalance); + expect(currentUnderlyingBalance).to.eq(expectedUnderlyingBalance); + }); + }); + }); + + describe("#getSwapBorrowRateModeCalldata", async () => { + let subjectAsset: Address; + let subjectRateMode: BigNumber; + let subjectLendingPool: Address; + + beforeEach(async () => { + subjectAsset = setup.weth.address; + subjectRateMode = stableInterestRateMode; + subjectLendingPool = aaveSetup.lendingPool.address; + }); + + async function subject(): Promise { + return await aaveLibMock.testGetSwapBorrowRateModeCalldata(subjectAsset, subjectRateMode, subjectLendingPool); + } + + it("should get correct data", async () => { + const [target, value, calldata] = await subject(); + const expectedCalldata = aaveSetup.lendingPool.interface.encodeFunctionData("swapBorrowRateMode", [ + subjectAsset, + subjectRateMode, + ]); + + expect(target).to.eq(subjectLendingPool); + expect(value).to.eq(ZERO); + expect(calldata).to.eq(expectedCalldata); + }); + + describe("when borrow rate mode is variable", async () => { + beforeEach(async () => { + subjectRateMode = variableInterestRateMode; + }); + + it("should get correct data", async () => { + const [target, value, calldata] = await subject(); + const expectedCalldata = aaveSetup.lendingPool.interface.encodeFunctionData("swapBorrowRateMode", [ + subjectAsset, + subjectRateMode, + ]); + + expect(target).to.eq(subjectLendingPool); + expect(value).to.eq(ZERO); + expect(calldata).to.eq(expectedCalldata); + }); + }); + }); + + describe("#invokeSwapBorrowRateMode", async () => { + let subjectSetToken: Address; + let subjectAsset: Address; + let subjectRateMode: BigNumber; + let subjectLendingPool: Address; + + beforeEach(async () => { + subjectSetToken = setToken.address; + subjectAsset = setup.dai.address; + subjectLendingPool = aaveSetup.lendingPool.address; + }); + + async function subject(): Promise { + return await aaveLibMock.testInvokeSwapBorrowRateMode( + subjectSetToken, + subjectAsset, + subjectRateMode, + subjectLendingPool + ); + } + + describe("when moving to stable mode from variable mode", async () => { + beforeEach(async () => { + await invokeLibMock.testInvokeApprove(setToken.address, setup.weth.address, aaveSetup.lendingPool.address, MAX_UINT_256); + await aaveLibMock.testInvokeDeposit(setToken.address, setup.weth.address, ether(1), aaveSetup.lendingPool.address); + await aaveLibMock.testInvokeUseReserveAsCollateral(setToken.address, setup.weth.address, true, aaveSetup.lendingPool.address); + // Borrow DAI in variable rate mode + await aaveLibMock.testInvokeBorrow(setToken.address, setup.dai.address, ether(100), variableInterestRateMode, aaveSetup.lendingPool.address); + + subjectRateMode = variableInterestRateMode; + }); + + it("should burn stableDebtDAI and mint equivalent amount of variableDebtDAI", async () => { + const previousStableDebtTokenBalance = await stableDebtDAI.balanceOf(setToken.address); + await subject(); + const currentVariableDebtTokenBalance = await variableDebtDAI.balanceOf(setToken.address); + + // expect(currentStableDebtTokenBalance).to.eq(ZERO); + expect(currentVariableDebtTokenBalance).to.eq(previousStableDebtTokenBalance); + }); + }); + + describe("when moving to variable mode from stable mode", async () => { + beforeEach(async () => { + await invokeLibMock.testInvokeApprove(setToken.address, setup.weth.address, aaveSetup.lendingPool.address, MAX_UINT_256); + await aaveLibMock.testInvokeDeposit(setToken.address, setup.weth.address, ether(1), aaveSetup.lendingPool.address); + await aaveLibMock.testInvokeUseReserveAsCollateral(setToken.address, setup.weth.address, true, aaveSetup.lendingPool.address); + // Borrow DAI in stable rate mode + await aaveLibMock.testInvokeBorrow(setToken.address, setup.dai.address, ether(100), stableInterestRateMode, aaveSetup.lendingPool.address); + + subjectRateMode = stableInterestRateMode; + }); + + it("should burn variableDebtDAI and mint equivalent amount of stableDebtDAI", async () => { + const previousVariableDebtTokenBalance = await variableDebtDAI.balanceOf(setToken.address); + await subject(); + const currentStableDebtTokenBalance = await stableDebtDAI.balanceOf(setToken.address); + + // expect(currentVariableDebtTokenBalance).to.eq(ZERO); + expect(currentStableDebtTokenBalance).to.eq(previousVariableDebtTokenBalance); + }); + }); + }); +}); \ No newline at end of file From b1ab176d1b60d275d59b252203acedb57ba637c5 Mon Sep 17 00:00:00 2001 From: alpha-guy Date: Thu, 22 Jul 2021 18:55:30 +0530 Subject: [PATCH 13/19] * Add javadocs & other suggested changes to Library and Mock contract --- .../protocol/integration/lib/AaveV2Mock.sol | 99 ++++++----- contracts/protocol/integration/lib/AaveV2.sol | 164 +++++++++++------- test/protocol/integration/lib/aaveV2.spec.ts | 88 +++++----- 3 files changed, 195 insertions(+), 156 deletions(-) diff --git a/contracts/mocks/protocol/integration/lib/AaveV2Mock.sol b/contracts/mocks/protocol/integration/lib/AaveV2Mock.sol index 115b6ead4..c3139e840 100644 --- a/contracts/mocks/protocol/integration/lib/AaveV2Mock.sol +++ b/contracts/mocks/protocol/integration/lib/AaveV2Mock.sol @@ -18,160 +18,167 @@ pragma solidity 0.6.10; -import { ISetToken } from "../../../../interfaces/ISetToken.sol"; -import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { AaveV2 } from "../../../../protocol/integration/lib/AaveV2.sol"; +import { ILendingPool } from "../../../../interfaces/external/aave-v2/ILendingPool.sol"; +import { ISetToken } from "../../../../interfaces/ISetToken.sol"; +/** + * @title AaveV2Mock + * @author Set Protocol + * + * Mock for AaveV2 Library contract. Used for testing AaveV2 Library contract, as the library + * contract can't be tested directly using ethers.js + */ contract AaveV2Mock { /* ============ External ============ */ function testGetDepositCalldata( + ILendingPool _lendingPool, address _asset, uint256 _amountNotional, address _onBehalfOf, - uint16 _referralCode, - address _lendingPool + uint16 _referralCode ) public pure returns (address, uint256, bytes memory) { - return AaveV2.getDepositCalldata(_asset, _amountNotional, _onBehalfOf, _referralCode, _lendingPool); + return AaveV2.getDepositCalldata(_lendingPool, _asset, _amountNotional, _onBehalfOf, _referralCode); } function testInvokeDeposit( ISetToken _setToken, - IERC20 _asset, - uint256 _amountNotional, - address _lendingPool + ILendingPool _lendingPool, + address _asset, + uint256 _amountNotional ) external { - return AaveV2.invokeDeposit(_setToken, _asset, _amountNotional, _lendingPool); + return AaveV2.invokeDeposit(_setToken, _lendingPool, _asset, _amountNotional); } function testGetWithdrawCalldata( + ILendingPool _lendingPool, address _asset, uint256 _amountNotional, - address _receiver, - address _lendingPool + address _receiver ) public pure returns (address, uint256, bytes memory) { - return AaveV2.getWithdrawCalldata(_asset, _amountNotional, _receiver, _lendingPool); + return AaveV2.getWithdrawCalldata(_lendingPool, _asset, _amountNotional, _receiver); } function testInvokeWithdraw( ISetToken _setToken, - IERC20 _asset, - uint256 _amountNotional, - address _lendingPool + ILendingPool _lendingPool, + address _asset, + uint256 _amountNotional ) external { - return AaveV2.invokeWithdraw(_setToken, _asset, _amountNotional, _lendingPool); + return AaveV2.invokeWithdraw(_setToken, _lendingPool, _asset, _amountNotional); } function testGetBorrowCalldata( + ILendingPool _lendingPool, address _asset, uint256 _amountNotional, uint256 _interestRateMode, uint16 _referralCode, - address _onBehalfOf, - address _lendingPool + address _onBehalfOf ) public pure returns (address, uint256, bytes memory) { - return AaveV2.getBorrowCalldata(_asset, _amountNotional, _interestRateMode, _referralCode, _onBehalfOf, _lendingPool); + return AaveV2.getBorrowCalldata(_lendingPool, _asset, _amountNotional, _interestRateMode, _referralCode, _onBehalfOf); } function testInvokeBorrow( ISetToken _setToken, - IERC20 _asset, + ILendingPool _lendingPool, + address _asset, uint256 _amountNotional, - uint256 _interestRateMode, - address _lendingPool + uint256 _interestRateMode ) external { - return AaveV2.invokeBorrow(_setToken, _asset, _amountNotional, _interestRateMode, _lendingPool); + return AaveV2.invokeBorrow(_setToken, _lendingPool, _asset, _amountNotional, _interestRateMode); } function testGetRepayCalldata( + ILendingPool _lendingPool, address _asset, uint256 _amountNotional, uint256 _interestRateMode, - address _onBehalfOf, - address _lendingPool + address _onBehalfOf ) public pure returns (address, uint256, bytes memory) { - return AaveV2.getRepayCalldata(_asset, _amountNotional, _interestRateMode, _onBehalfOf, _lendingPool); + return AaveV2.getRepayCalldata(_lendingPool, _asset, _amountNotional, _interestRateMode, _onBehalfOf); } function testInvokeRepay( ISetToken _setToken, - IERC20 _asset, + ILendingPool _lendingPool, + address _asset, uint256 _amountNotional, - uint256 _interestRateMode, - address _lendingPool + uint256 _interestRateMode ) external { - return AaveV2.invokeRepay(_setToken, _asset, _amountNotional, _interestRateMode, _lendingPool); + return AaveV2.invokeRepay(_setToken, _lendingPool, _asset, _amountNotional, _interestRateMode); } - function testGetUseReserveAsCollateralCalldata( + function testGetSetUserUseReserveAsCollateralCalldata( + ILendingPool _lendingPool, address _asset, - bool _useAsCollateral, - address _lendingPool + bool _useAsCollateral ) external pure returns (address, uint256, bytes memory) { - return AaveV2.getUseReserveAsCollateralCalldata(_asset, _useAsCollateral, _lendingPool); + return AaveV2.getSetUserUseReserveAsCollateralCalldata(_lendingPool, _asset, _useAsCollateral); } - function testInvokeUseReserveAsCollateral( + function testInvokeSetUserUseReserveAsCollateral( ISetToken _setToken, - IERC20 _asset, - bool _useAsCollateral, - address _lendingPool + ILendingPool _lendingPool, + address _asset, + bool _useAsCollateral ) external { - return AaveV2.invokeUseReserveAsCollateral(_setToken, _asset, _useAsCollateral, _lendingPool); + return AaveV2.invokeSetUserUseReserveAsCollateral(_setToken, _lendingPool, _asset, _useAsCollateral); } function testGetSwapBorrowRateModeCalldata( + ILendingPool _lendingPool, address _asset, - uint256 _rateMode, - address _lendingPool + uint256 _rateMode ) external pure returns (address, uint256, bytes memory) { - return AaveV2.getSwapBorrowRateModeCalldata(_asset, _rateMode, _lendingPool); + return AaveV2.getSwapBorrowRateModeCalldata(_lendingPool, _asset, _rateMode); } function testInvokeSwapBorrowRateMode( ISetToken _setToken, - IERC20 _asset, - uint256 _rateMode, - address _lendingPool + ILendingPool _lendingPool, + address _asset, + uint256 _rateMode ) external { - return AaveV2.invokeSwapBorrowRateMode(_setToken, _asset, _rateMode, _lendingPool); + return AaveV2.invokeSwapBorrowRateMode(_setToken, _lendingPool, _asset, _rateMode); } /* ============ Helper Functions ============ */ diff --git a/contracts/protocol/integration/lib/AaveV2.sol b/contracts/protocol/integration/lib/AaveV2.sol index 6009760d7..38f499819 100644 --- a/contracts/protocol/integration/lib/AaveV2.sol +++ b/contracts/protocol/integration/lib/AaveV2.sol @@ -18,8 +18,9 @@ pragma solidity 0.6.10; -import { ISetToken } from "../../../interfaces/ISetToken.sol"; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; +import { ILendingPool } from "../../../interfaces/external/aave-v2/ILendingPool.sol"; +import { ISetToken } from "../../../interfaces/ISetToken.sol"; // TODO: Calculate the gas costs of having separate getter functions. @@ -34,13 +35,16 @@ library AaveV2 { /** * Get deposit calldata from SetToken + * + * Deposits an `_amountNotional` of underlying asset into the reserve, receiving in return overlying aTokens. + * - E.g. User deposits 100 USDC and gets in return 100 aUSDC */ function getDepositCalldata( + ILendingPool _lendingPool, address _asset, uint256 _amountNotional, address _onBehalfOf, - uint16 _referralCode, - address _lendingPool + uint16 _referralCode ) public pure @@ -54,39 +58,45 @@ library AaveV2 { _referralCode ); - return (_lendingPool, 0, callData); + return (address(_lendingPool), 0, callData); } /** * Invoke deposit on LendingPool from SetToken + * + * Deposits an `_amountNotional` of underlying asset into the reserve, receiving in return overlying aTokens. + * - E.g. SetToken deposits 100 USDC and gets in return 100 aUSDC */ function invokeDeposit( ISetToken _setToken, - IERC20 _asset, - uint256 _amountNotional, - address _lendingPool + ILendingPool _lendingPool, + address _asset, + uint256 _amountNotional ) external { ( , , bytes memory depositCalldata) = getDepositCalldata( - address(_asset), + _lendingPool, + _asset, _amountNotional, address(_setToken), - 0, - _lendingPool + 0 ); - _setToken.invoke(_lendingPool, 0, depositCalldata); + _setToken.invoke(address(_lendingPool), 0, depositCalldata); } /** * Get withdraw calldata from SetToken + * + * Withdraws an `_amountNotional` of underlying asset from the reserve, burning the equivalent aTokens owned + * - E.g. User has 100 aUSDC, calls withdraw() and receives 100 USDC, burning the 100 aUSDC */ function getWithdrawCalldata( + ILendingPool _lendingPool, address _asset, uint256 _amountNotional, - address _receiver, - address _lendingPool + address _receiver ) public pure @@ -99,40 +109,47 @@ library AaveV2 { _receiver ); - return (_lendingPool, 0, callData); + return (address(_lendingPool), 0, callData); } /** * Invoke withdraw on LendingPool from SetToken + * + * Withdraws an `_amountNotional` of underlying asset from the reserve, burning the equivalent aTokens owned + * - E.g. SetToken has 100 aUSDC, and receives 100 USDC, burning the 100 aUSDC */ function invokeWithdraw( ISetToken _setToken, - IERC20 _asset, - uint256 _amountNotional, - address _lendingPool + ILendingPool _lendingPool, + address _asset, + uint256 _amountNotional ) external { ( , , bytes memory withdrawCalldata) = getWithdrawCalldata( - address(_asset), + _lendingPool, + _asset, _amountNotional, - address(_setToken), - _lendingPool + address(_setToken) ); - _setToken.invoke(_lendingPool, 0, withdrawCalldata); + _setToken.invoke(address(_lendingPool), 0, withdrawCalldata); } /** * Get borrow calldata from SetToken + * + * Allows users to borrow a specific `_amountNotional` of the reserve underlying `_asset`, provided that + * the borrower already deposited enough collateral, or he was given enough allowance by a credit delegator + * on the corresponding debt token (StableDebtToken or VariableDebtToken) */ function getBorrowCalldata( + ILendingPool _lendingPool, address _asset, uint256 _amountNotional, uint256 _interestRateMode, uint16 _referralCode, - address _onBehalfOf, - address _lendingPool + address _onBehalfOf ) public pure @@ -147,42 +164,49 @@ library AaveV2 { _onBehalfOf ); - return (_lendingPool, 0, callData); + return (address(_lendingPool), 0, callData); } /** * Invoke borrow on LendingPool from SetToken + * + * Allows SetToken to borrow a specific `_amountNotional` of the reserve underlying `_asset`, provided that + * the SetToken already deposited enough collateral, or it was given enough allowance by a credit delegator + * on the corresponding debt token (StableDebtToken or VariableDebtToken) */ function invokeBorrow( ISetToken _setToken, - IERC20 _asset, + ILendingPool _lendingPool, + address _asset, uint256 _amountNotional, - uint256 _interestRateMode, - address _lendingPool + uint256 _interestRateMode ) external { ( , , bytes memory borrowCalldata) = getBorrowCalldata( - address(_asset), + _lendingPool, + _asset, _amountNotional, _interestRateMode, 0, - address(_setToken), - _lendingPool + address(_setToken) ); - _setToken.invoke(_lendingPool, 0, borrowCalldata); + _setToken.invoke(address(_lendingPool), 0, borrowCalldata); } /** * Get repay calldata from SetToken + * + * Repays a borrowed `_amountNotional` on a specific `_asset` reserve, burning the equivalent debt tokens owned + * - E.g. User repays 100 USDC, burning 100 variable/stable debt tokens of the `onBehalfOf` address */ function getRepayCalldata( + ILendingPool _lendingPool, address _asset, uint256 _amountNotional, uint256 _interestRateMode, - address _onBehalfOf, - address _lendingPool + address _onBehalfOf ) public pure @@ -196,39 +220,44 @@ library AaveV2 { _onBehalfOf ); - return (_lendingPool, 0, callData); + return (address(_lendingPool), 0, callData); } /** * Invoke repay on LendingPool from SetToken + * + * Repays a borrowed `_amountNotional` on a specific `_asset` reserve, burning the equivalent debt tokens owned + * - E.g. SetToken repays 100 USDC, burning 100 variable/stable debt tokens */ function invokeRepay( ISetToken _setToken, - IERC20 _asset, + ILendingPool _lendingPool, + address _asset, uint256 _amountNotional, - uint256 _interestRateMode, - address _lendingPool + uint256 _interestRateMode ) external { ( , , bytes memory repayCalldata) = getRepayCalldata( - address(_asset), + _lendingPool, + _asset, _amountNotional, _interestRateMode, - address(_setToken), - _lendingPool + address(_setToken) ); - _setToken.invoke(_lendingPool, 0, repayCalldata); + _setToken.invoke(address(_lendingPool), 0, repayCalldata); } /** * Get setUserUseReserveAsCollateral calldata from SetToken + * + * Allows borrower to enable/disable a specific deposited asset as collateral */ - function getUseReserveAsCollateralCalldata( + function getSetUserUseReserveAsCollateralCalldata( + ILendingPool _lendingPool, address _asset, - bool _useAsCollateral, - address _lendingPool + bool _useAsCollateral ) public pure @@ -240,36 +269,40 @@ library AaveV2 { _useAsCollateral ); - return (_lendingPool, 0, callData); + return (address(_lendingPool), 0, callData); } /** * Invoke an asset to be used as collateral on Aave from SetToken + * + * Allows SetToken to enable/disable a specific deposited asset as collateral */ - function invokeUseReserveAsCollateral( + function invokeSetUserUseReserveAsCollateral( ISetToken _setToken, - IERC20 _asset, - bool _useAsCollateral, - address _lendingPool + ILendingPool _lendingPool, + address _asset, + bool _useAsCollateral ) external { - ( , , bytes memory callData) = getUseReserveAsCollateralCalldata( - address(_asset), - _useAsCollateral, - _lendingPool + ( , , bytes memory callData) = getSetUserUseReserveAsCollateralCalldata( + _lendingPool, + _asset, + _useAsCollateral ); - _setToken.invoke(_lendingPool, 0, callData); + _setToken.invoke(address(_lendingPool), 0, callData); } /** * Get swapBorrowRate calldata from SetToken + * + * Aave allows a borrower to toggle his debt between stable and variable mode */ function getSwapBorrowRateModeCalldata( + ILendingPool _lendingPool, address _asset, - uint256 _rateMode, - address _lendingPool + uint256 _rateMode ) public pure @@ -281,27 +314,28 @@ library AaveV2 { _rateMode ); - return (_lendingPool, 0, callData); + return (address(_lendingPool), 0, callData); } /** * Invoke to swap borrow rate of SetToken - * Note: Aave allows a borrower to toggle his debt between stable and variable mode + * + * Allows SetToken to toggle it's debt between stable and variable mode */ function invokeSwapBorrowRateMode( ISetToken _setToken, - IERC20 _asset, - uint256 _rateMode, - address _lendingPool + ILendingPool _lendingPool, + address _asset, + uint256 _rateMode ) external { ( , , bytes memory callData) = getSwapBorrowRateModeCalldata( - address(_asset), - _rateMode, - _lendingPool + _lendingPool, + _asset, + _rateMode ); - _setToken.invoke(_lendingPool, 0, callData); + _setToken.invoke(address(_lendingPool), 0, callData); } } \ No newline at end of file diff --git a/test/protocol/integration/lib/aaveV2.spec.ts b/test/protocol/integration/lib/aaveV2.spec.ts index 6b54602d1..fd1dc6e21 100644 --- a/test/protocol/integration/lib/aaveV2.spec.ts +++ b/test/protocol/integration/lib/aaveV2.spec.ts @@ -116,11 +116,11 @@ describe("AaveV2", () => { async function subject(): Promise { return await aaveLibMock.testGetDepositCalldata( + subjectLendingPool, subjectAsset, subjectAmountNotional, subjectOnBehalfOf, - subjectReferralCode, - subjectLendingPool + subjectReferralCode ); } @@ -157,9 +157,9 @@ describe("AaveV2", () => { async function subject(): Promise { return await aaveLibMock.testInvokeDeposit( subjectSetToken, + subjectLendingPool, subjectAsset, - subjectAmountNotional, - subjectLendingPool + subjectAmountNotional ); } @@ -172,7 +172,7 @@ describe("AaveV2", () => { }); }); - describe("#getUseReserveAsCollateralCalldata", async () => { + describe("#getSetUserUseReserveAsCollateralCalldata", async () => { let subjectAsset: Address; let subjectUseAsCollateral: boolean; let subjectLendingPool: Address; @@ -184,10 +184,10 @@ describe("AaveV2", () => { }); async function subject(): Promise { - return await aaveLibMock.testGetUseReserveAsCollateralCalldata( + return await aaveLibMock.testGetSetUserUseReserveAsCollateralCalldata( + subjectLendingPool, subjectAsset, - subjectUseAsCollateral, - subjectLendingPool + subjectUseAsCollateral ); } @@ -222,7 +222,7 @@ describe("AaveV2", () => { }); }); - describe("#invokeUseReserveAsCollateral", async () => { + describe("#invokeSetUserUseReserveAsCollateral", async () => { let subjectSetToken: Address; let subjectAsset: Address; let subjectUseAsCollateral: boolean; @@ -230,7 +230,7 @@ describe("AaveV2", () => { beforeEach(async () => { await invokeLibMock.testInvokeApprove(setToken.address, setup.weth.address, aaveSetup.lendingPool.address, MAX_UINT_256); - await aaveLibMock.testInvokeDeposit(setToken.address, setup.weth.address, ether(1), aaveSetup.lendingPool.address); + await aaveLibMock.testInvokeDeposit(setToken.address, aaveSetup.lendingPool.address, setup.weth.address, ether(1)); subjectSetToken = setToken.address; subjectAsset = setup.weth.address; @@ -239,11 +239,11 @@ describe("AaveV2", () => { }); async function subject(): Promise { - return await aaveLibMock.testInvokeUseReserveAsCollateral( + return await aaveLibMock.testInvokeSetUserUseReserveAsCollateral( subjectSetToken, + subjectLendingPool, subjectAsset, - subjectUseAsCollateral, - subjectLendingPool + subjectUseAsCollateral ); } @@ -289,10 +289,10 @@ describe("AaveV2", () => { async function subject(): Promise { return await aaveLibMock.testGetWithdrawCalldata( + subjectLendingPool, subjectAsset, subjectAmountNotional, - subjectReceiver, - subjectLendingPool + subjectReceiver ); } @@ -318,7 +318,7 @@ describe("AaveV2", () => { beforeEach(async () => { await invokeLibMock.testInvokeApprove(setToken.address, setup.weth.address, aaveSetup.lendingPool.address, MAX_UINT_256); - await aaveLibMock.testInvokeDeposit(setToken.address, setup.weth.address, ether(1), aaveSetup.lendingPool.address); + await aaveLibMock.testInvokeDeposit(setToken.address, aaveSetup.lendingPool.address, setup.weth.address, ether(1)); subjectSetToken = setToken.address; subjectAsset = setup.weth.address; @@ -329,9 +329,9 @@ describe("AaveV2", () => { async function subject(): Promise { return await aaveLibMock.testInvokeWithdraw( subjectSetToken, + subjectLendingPool, subjectAsset, - subjectAmountNotional, - subjectLendingPool + subjectAmountNotional ); } @@ -369,12 +369,12 @@ describe("AaveV2", () => { async function subject(): Promise { return await aaveLibMock.testGetBorrowCalldata( + subjectLendingPool, subjectAsset, subjectAmountNotional, subjectInterestRateMode, subjectReferralCode, - subjectOnBehalfOf, - subjectLendingPool + subjectOnBehalfOf ); } @@ -403,8 +403,8 @@ describe("AaveV2", () => { beforeEach(async () => { await invokeLibMock.testInvokeApprove(setToken.address, setup.weth.address, aaveSetup.lendingPool.address, MAX_UINT_256); - await aaveLibMock.testInvokeDeposit(setToken.address, setup.weth.address, ether(1), aaveSetup.lendingPool.address); - await aaveLibMock.testInvokeUseReserveAsCollateral(setToken.address, setup.weth.address, true, aaveSetup.lendingPool.address); + await aaveLibMock.testInvokeDeposit(setToken.address, aaveSetup.lendingPool.address, setup.weth.address, ether(1)); + await aaveLibMock.testInvokeSetUserUseReserveAsCollateral(setToken.address, aaveSetup.lendingPool.address, setup.weth.address, true); subjectSetToken = setToken.address; subjectAsset = setup.dai.address; @@ -415,10 +415,10 @@ describe("AaveV2", () => { async function subject(): Promise { return await aaveLibMock.testInvokeBorrow( subjectSetToken, + subjectLendingPool, subjectAsset, subjectAmountNotional, - subjectInterestRateMode, - subjectLendingPool + subjectInterestRateMode ); } @@ -468,11 +468,11 @@ describe("AaveV2", () => { async function subject(): Promise { return await aaveLibMock.testGetRepayCalldata( + subjectLendingPool, subjectAsset, subjectAmountNotional, subjectInterestRateMode, - subjectOnBehalfOf, - subjectLendingPool + subjectOnBehalfOf ); } @@ -500,8 +500,8 @@ describe("AaveV2", () => { beforeEach(async () => { await invokeLibMock.testInvokeApprove(setToken.address, setup.weth.address, aaveSetup.lendingPool.address, MAX_UINT_256); - await aaveLibMock.testInvokeDeposit(setToken.address, setup.weth.address, ether(1), aaveSetup.lendingPool.address); - await aaveLibMock.testInvokeUseReserveAsCollateral(setToken.address, setup.weth.address, true, aaveSetup.lendingPool.address); + await aaveLibMock.testInvokeDeposit(setToken.address, aaveSetup.lendingPool.address, setup.weth.address, ether(1)); + await aaveLibMock.testInvokeSetUserUseReserveAsCollateral(setToken.address, aaveSetup.lendingPool.address, setup.weth.address, true); await invokeLibMock.testInvokeApprove(setToken.address, setup.dai.address, aaveSetup.lendingPool.address, MAX_UINT_256); // for repaying subjectSetToken = setToken.address; @@ -513,10 +513,10 @@ describe("AaveV2", () => { async function subject(): Promise { return await aaveLibMock.testInvokeRepay( subjectSetToken, + subjectLendingPool, subjectAsset, subjectAmountNotional, - subjectInterestRateMode, - subjectLendingPool + subjectInterestRateMode ); } @@ -524,10 +524,10 @@ describe("AaveV2", () => { beforeEach(async () => { await aaveLibMock.testInvokeBorrow( subjectSetToken, + subjectLendingPool, subjectAsset, subjectAmountNotional, - stableInterestRateMode, // stable mode - subjectLendingPool + stableInterestRateMode // stable mode ); subjectInterestRateMode = stableInterestRateMode; @@ -552,10 +552,10 @@ describe("AaveV2", () => { beforeEach(async () => { await aaveLibMock.testInvokeBorrow( subjectSetToken, + subjectLendingPool, subjectAsset, subjectAmountNotional, - variableInterestRateMode, // variable mode - subjectLendingPool + variableInterestRateMode // variable mode ); subjectInterestRateMode = variableInterestRateMode; @@ -589,7 +589,7 @@ describe("AaveV2", () => { }); async function subject(): Promise { - return await aaveLibMock.testGetSwapBorrowRateModeCalldata(subjectAsset, subjectRateMode, subjectLendingPool); + return await aaveLibMock.testGetSwapBorrowRateModeCalldata(subjectLendingPool, subjectAsset, subjectRateMode); } it("should get correct data", async () => { @@ -630,6 +630,10 @@ describe("AaveV2", () => { let subjectLendingPool: Address; beforeEach(async () => { + await invokeLibMock.testInvokeApprove(setToken.address, setup.weth.address, aaveSetup.lendingPool.address, MAX_UINT_256); + await aaveLibMock.testInvokeDeposit(setToken.address, aaveSetup.lendingPool.address, setup.weth.address, ether(1)); + await aaveLibMock.testInvokeSetUserUseReserveAsCollateral(setToken.address, aaveSetup.lendingPool.address, setup.weth.address, true); + subjectSetToken = setToken.address; subjectAsset = setup.dai.address; subjectLendingPool = aaveSetup.lendingPool.address; @@ -638,19 +642,16 @@ describe("AaveV2", () => { async function subject(): Promise { return await aaveLibMock.testInvokeSwapBorrowRateMode( subjectSetToken, + subjectLendingPool, subjectAsset, - subjectRateMode, - subjectLendingPool + subjectRateMode ); } describe("when moving to stable mode from variable mode", async () => { beforeEach(async () => { - await invokeLibMock.testInvokeApprove(setToken.address, setup.weth.address, aaveSetup.lendingPool.address, MAX_UINT_256); - await aaveLibMock.testInvokeDeposit(setToken.address, setup.weth.address, ether(1), aaveSetup.lendingPool.address); - await aaveLibMock.testInvokeUseReserveAsCollateral(setToken.address, setup.weth.address, true, aaveSetup.lendingPool.address); // Borrow DAI in variable rate mode - await aaveLibMock.testInvokeBorrow(setToken.address, setup.dai.address, ether(100), variableInterestRateMode, aaveSetup.lendingPool.address); + await aaveLibMock.testInvokeBorrow(setToken.address, aaveSetup.lendingPool.address, setup.dai.address, ether(100), variableInterestRateMode); subjectRateMode = variableInterestRateMode; }); @@ -667,11 +668,8 @@ describe("AaveV2", () => { describe("when moving to variable mode from stable mode", async () => { beforeEach(async () => { - await invokeLibMock.testInvokeApprove(setToken.address, setup.weth.address, aaveSetup.lendingPool.address, MAX_UINT_256); - await aaveLibMock.testInvokeDeposit(setToken.address, setup.weth.address, ether(1), aaveSetup.lendingPool.address); - await aaveLibMock.testInvokeUseReserveAsCollateral(setToken.address, setup.weth.address, true, aaveSetup.lendingPool.address); // Borrow DAI in stable rate mode - await aaveLibMock.testInvokeBorrow(setToken.address, setup.dai.address, ether(100), stableInterestRateMode, aaveSetup.lendingPool.address); + await aaveLibMock.testInvokeBorrow(setToken.address, aaveSetup.lendingPool.address, setup.dai.address, ether(100), stableInterestRateMode); subjectRateMode = stableInterestRateMode; }); From 0f851f108ef7259654d15e5443db269ecd7dd3ee Mon Sep 17 00:00:00 2001 From: alpha-guy Date: Thu, 22 Jul 2021 21:34:09 +0530 Subject: [PATCH 14/19] Add suggested changes to fixture * Initialize weth and dai reserves in initialize() function * Improve comments --- test/fixtures/aaveV2.spec.ts | 45 +---- test/protocol/integration/lib/aaveV2.spec.ts | 5 +- utils/fixtures/aaveV2Fixture.ts | 193 ++++++++++--------- 3 files changed, 115 insertions(+), 128 deletions(-) diff --git a/test/fixtures/aaveV2.spec.ts b/test/fixtures/aaveV2.spec.ts index fe80cd0d5..7abae8769 100644 --- a/test/fixtures/aaveV2.spec.ts +++ b/test/fixtures/aaveV2.spec.ts @@ -1,11 +1,6 @@ import "module-alias/register"; import { Account } from "@utils/test/types"; -import { - AaveV2AToken, - AaveV2StableDebtToken, - AaveV2VariableDebtToken -} from "@utils/contracts/aaveV2"; import { getAccounts, getSystemFixture, @@ -67,30 +62,20 @@ describe("AaveV2Fixture", async () => { expect(wethMarketBorrowRate).to.eq(oneRay.mul(3).div(100)); expect(daiMarketBorrowRate).to.eq(oneRay.mul(39).div(1000)); }); - }); - - describe("#deployWethReserve", async () => { - - beforeEach(async () => { - await aaveSetup.initialize(setup.weth.address, setup.dai.address); - }); - - async function subject(): Promise<[AaveV2AToken, AaveV2StableDebtToken, AaveV2VariableDebtToken]> { - return await aaveSetup.deployWethReserve(); - } it("should deploy WETH reserve with correct configuration", async () => { - const [aWETH, stableDebtWETH, variableDebtWETH] = await subject(); + await subject(); + const wethReserveTokens = aaveSetup.wethReserveTokens; const reservesList = await aaveSetup.lendingPool.getReservesList(); const tokenAddresses = await aaveSetup.protocolDataProvider.getReserveTokensAddresses(setup.weth.address); const config = await aaveSetup.protocolDataProvider.getReserveConfigurationData(setup.weth.address); expect(reservesList).to.contain(setup.weth.address); - expect(aWETH.address).to.eq(tokenAddresses.aTokenAddress); - expect(stableDebtWETH.address).to.eq(tokenAddresses.stableDebtTokenAddress); - expect(variableDebtWETH.address).to.eq(tokenAddresses.variableDebtTokenAddress); + expect(wethReserveTokens.aToken.address).to.eq(tokenAddresses.aTokenAddress); + expect(wethReserveTokens.stableDebtToken.address).to.eq(tokenAddresses.stableDebtTokenAddress); + expect(wethReserveTokens.variableDebtToken.address).to.eq(tokenAddresses.variableDebtTokenAddress); expect(config.isActive).to.eq(true); expect(config.isFrozen).to.eq(false); @@ -103,30 +88,20 @@ describe("AaveV2Fixture", async () => { expect(config.usageAsCollateralEnabled).to.eq(true); expect(config.stableBorrowRateEnabled).to.eq(true); }); - }); - - describe("#deployDaiReserve", async () => { - - beforeEach(async () => { - await aaveSetup.initialize(setup.weth.address, setup.dai.address); - }); - - async function subject(): Promise<[AaveV2AToken, AaveV2StableDebtToken, AaveV2VariableDebtToken]> { - return await aaveSetup.deployDaiReserve(); - } it("should deploy DAI reserve with correct configuration", async () => { - const [aDAI, stableDebtDAI, variableDebtDAI] = await subject(); + await subject(); + const daiReserveTokens = aaveSetup.daiReserveTokens; const reservesList = await aaveSetup.lendingPool.getReservesList(); const tokenAddresses = await aaveSetup.protocolDataProvider.getReserveTokensAddresses(setup.dai.address); const config = await aaveSetup.protocolDataProvider.getReserveConfigurationData(setup.dai.address); expect(reservesList).to.contain(setup.dai.address); - expect(aDAI.address).to.eq(tokenAddresses.aTokenAddress); - expect(stableDebtDAI.address).to.eq(tokenAddresses.stableDebtTokenAddress); - expect(variableDebtDAI.address).to.eq(tokenAddresses.variableDebtTokenAddress); + expect(daiReserveTokens.aToken.address).to.eq(tokenAddresses.aTokenAddress); + expect(daiReserveTokens.stableDebtToken.address).to.eq(tokenAddresses.stableDebtTokenAddress); + expect(daiReserveTokens.variableDebtToken.address).to.eq(tokenAddresses.variableDebtTokenAddress); expect(config.isActive).to.eq(true); expect(config.isFrozen).to.eq(false); diff --git a/test/protocol/integration/lib/aaveV2.spec.ts b/test/protocol/integration/lib/aaveV2.spec.ts index fd1dc6e21..fb7fdf3f0 100644 --- a/test/protocol/integration/lib/aaveV2.spec.ts +++ b/test/protocol/integration/lib/aaveV2.spec.ts @@ -63,8 +63,9 @@ describe("AaveV2", () => { aaveSetup = getAaveV2Fixture(owner.address); await aaveSetup.initialize(setup.weth.address, setup.dai.address); - [aWETH, , ] = await aaveSetup.deployWethReserve(); - [, stableDebtDAI, variableDebtDAI] = await aaveSetup.deployDaiReserve(); + aWETH = aaveSetup.wethReserveTokens.aToken; + stableDebtDAI = aaveSetup.daiReserveTokens.stableDebtToken; + variableDebtDAI = aaveSetup.daiReserveTokens.variableDebtToken; // Create liquidity await setup.weth.connect(owner.wallet).approve(aaveSetup.lendingPool.address, ether(100)); diff --git a/utils/fixtures/aaveV2Fixture.ts b/utils/fixtures/aaveV2Fixture.ts index 764778d1c..4b27156ce 100644 --- a/utils/fixtures/aaveV2Fixture.ts +++ b/utils/fixtures/aaveV2Fixture.ts @@ -29,12 +29,18 @@ import { ether, getRandomAddress } from "../common"; import { ADDRESS_ZERO } from "../constants"; +export interface ReserveTokens { + aToken: AaveV2AToken; + stableDebtToken: AaveV2StableDebtToken; + variableDebtToken: AaveV2VariableDebtToken; +} + export class AaveV2Fixture { private _deployer: DeployHelper; private _ownerSigner: Signer; - private weth: Address; - private dai: Address; + public wethReserveTokens: ReserveTokens; + public daiReserveTokens: ReserveTokens; public marketId: string; public lendingPool: AaveV2LendingPool; @@ -67,10 +73,12 @@ export class AaveV2Fixture { this._deployer = new DeployHelper(this._ownerSigner); } - public async initialize(weth: Address, dai: Address, marketId: string = "Commons"): Promise { - - this.dai = dai; - this.weth = weth; + public async initialize( + weth: Address, + dai: Address, + marketId: string = "Commons", + daiPriceInEth: BigNumber = ether(0.001) // 1 DAI = 0.001 ETH + ): Promise { this.marketId = marketId; // deploy libraries @@ -116,65 +124,60 @@ export class AaveV2Fixture { this.incentivesControllerAddress = ADDRESS_ZERO; // set initial asset prices in ETH - await this.setAssetPriceInOracle(dai, ether(0.001)); // 1 ETH = 1000$ => 1 DAI = 0.001 ETH + await this.setAssetPriceInOracle(dai, daiPriceInEth); // set initial market rates + // As per Aave's interest rate model, if U < U_optimal, R_t = R_0 + (U_t/U_optimal) * R_slope1 + // When U_t = 0, R_t = R_0 + // R_0 is the interest rate when utilization is 0 (it's the intercept for the above linear equation) + // And for higher precision it is expressed in Rays const oneRay = BigNumber.from(10).pow(27); // 1e27 await this.setMarketBorrowRate(weth, oneRay.mul(3).div(100)); await this.setMarketBorrowRate(dai, oneRay.mul(39).div(1000)); - /* - TODO: Move governance to this fixture. - // Deploy Executor - this.executor = await this._deployer.external.deployExecutor( - await this._ownerSigner.getAddress(), - BigNumber.from(0), - BigNumber.from(0), - BigNumber.from(0), - MAX_UINT_256, - BigNumber.from(50), - BigNumber.from(100), - BigNumber.from(50), - ether(100) + // Deploy and configure WETH reserve + this.wethReserveTokens = await this.createAndEnableReserve( + weth, "WETH", BigNumber.from(18), + BigNumber.from(8000), // base LTV: 80% + BigNumber.from(8250), // liquidation threshold: 82.5% + BigNumber.from(10500), // liquidation bonus: 105.00% + BigNumber.from(1000), // reserve factor: 10% + true, // enable borrowing on reserve + true // enable stable debts ); - this.aaveToken = await this._deployer.external.deployAaveTokenV2Mintable(); - await this.aaveToken.mint(await this._ownerSigner.getAddress(), ether(100000)); - this.stkAaveToken = await this._deployer.external.deployAaveTokenV2Mintable(); - await this.stkAaveToken.mint(await this._ownerSigner.getAddress(), ether(100000)); - - this.governanceStrategy = await this._deployer.external.deployGovernanceStrategy(this.aaveToken.address, this.stkAaveToken.address); - this.aaveGovernanceV2 = await this._deployer.external.deployAaveGovernanceV2( - this.governanceStrategy.address, - BigNumber.from(0), - await this._ownerSigner.getAddress(), - [this.executor.address] + // Deploy and configure DAI reserve + this.daiReserveTokens = await this.createAndEnableReserve( + dai, "DAI", BigNumber.from(18), + BigNumber.from(7500), // base LTV: 75% + BigNumber.from(8000), // liquidation threshold: 80% + BigNumber.from(10500), // liquidation bonus: 105.00% + BigNumber.from(1000), // reserve factor: 10% + true, // enable borrowing on reserve + true // enable stable debts ); - - this.aaveToken.connect(this._ownerSigner).transfer(await getRandomAddress(), 100); - this.stkAaveToken.connect(this._ownerSigner).transfer(await getRandomAddress(), 100); - await this._deployer.external.deployAaveV2StakedTokenIncentivesController( - this.stkAaveToken.address, this.executor.address - ) - - this.incentivesControllerAddress = (await this._deployer.external.deployAaveV2StakedTokenIncentivesController( - this.stkAaveToken.address, this.executor.address - )).address; - */ } - public async deployReserve( + public async createAndEnableReserve( underlyingAsset: Address, underlyingAssetSymbol: string, - underlyingAssetDecimals: BigNumberish = 18, + underlyingAssetDecimals: BigNumberish, + baseLTV: BigNumberish, + liquidationThreshold: BigNumberish, + liquidationBonus: BigNumberish, + reserveFactor: BigNumberish, + borrowingEnabled: boolean, + stableBorrowingEnabled: boolean, treasuryAddress: Address = this.treasuryAddress, incentivesControllerAddress: Address = this.incentivesControllerAddress, interestRateStrategyAddress: Address = this.reserveInterestRateStrategy.address - ): Promise<[AaveV2AToken, AaveV2StableDebtToken, AaveV2VariableDebtToken]> { + ): Promise { + let aToken = await this._deployer.external.deployAaveV2AToken(); let stableDebtToken = await this._deployer.external.deployAaveV2StableDebtToken(); let variableDebtToken = await this._deployer.external.deployAaveV2VariableDebtToken(); + // init reserve await this.lendingPoolConfigurator.batchInitReserve( [ { @@ -198,69 +201,77 @@ export class AaveV2Fixture { ] ); - const tokenAddresses = await this.protocolDataProvider.getReserveTokensAddresses(underlyingAsset); - aToken = aToken.attach(tokenAddresses.aTokenAddress); - stableDebtToken = stableDebtToken.attach(tokenAddresses.stableDebtTokenAddress); - variableDebtToken = variableDebtToken.attach(tokenAddresses.variableDebtTokenAddress); - - return [aToken, stableDebtToken, variableDebtToken]; - } - - public async configureReserve( - asset: Address, - baseLTV: BigNumberish, - liquidationThreshold: BigNumberish, - liquidationBonus: BigNumberish, - reserveFactor: BigNumberish, - borrowingEnabled: boolean, - stableBorrowingEnabled: boolean - ): Promise { - + // configure reserve await this.lendingPoolConfigurator.configureReserveAsCollateral( - asset, + underlyingAsset, baseLTV, liquidationThreshold, liquidationBonus ); if (borrowingEnabled) { - await this.lendingPoolConfigurator.enableBorrowingOnReserve(asset, stableBorrowingEnabled); + await this.lendingPoolConfigurator.enableBorrowingOnReserve(underlyingAsset, stableBorrowingEnabled); } - await this.lendingPoolConfigurator.setReserveFactor(asset, reserveFactor); + await this.lendingPoolConfigurator.setReserveFactor(underlyingAsset, reserveFactor); + + // LendingPoolConfigurator creates a new proxy contract and sets the passed in address as the implementation. + // We then fetch the proxy's address and attach it to the contract object, which allows us to use the contract object + // to call functions on the proxy + const [aTokenProxy, stableDebtTokenProxy, variableDebtTokenProxy] = await this.protocolDataProvider.getReserveTokensAddresses( + underlyingAsset + ); + aToken = aToken.attach(aTokenProxy); + stableDebtToken = stableDebtToken.attach(stableDebtTokenProxy); + variableDebtToken = variableDebtToken.attach(variableDebtTokenProxy); + + return { aToken, stableDebtToken, variableDebtToken }; } - public async setAssetPriceInOracle(asset: Address, price: BigNumberish): Promise { - await this.fallbackOracle.setAssetPrice(asset, price); + public async setAssetPriceInOracle(asset: Address, priceInEth: BigNumberish): Promise { + await this.fallbackOracle.setAssetPrice(asset, priceInEth); } public async setMarketBorrowRate(asset: Address, rate: BigNumberish): Promise { this.lendingRateOracle.setMarketBorrowRate(asset, rate); } + /* + private async initializeGovernance(): Promise { - public async deployWethReserve(weth: Address = this.weth): Promise<[AaveV2AToken, AaveV2StableDebtToken, AaveV2VariableDebtToken]> { - const [aWETH, stableDebtWETH, variableDebtWETH] = await this.deployReserve(weth, "WETH", BigNumber.from(18)); - await this.configureReserve( - weth, - BigNumber.from(8000), // base LTV: 80% - BigNumber.from(8250), // liquidation threshold: 82.5% - BigNumber.from(10500), // liquidation bonus: 105.00% - BigNumber.from(1000), // reserve factor: 10% - true, // enable borrowing on reserve - true // enable stable debts + TODO: Move governance to this fixture. + // Deploy Executor + this.executor = await this._deployer.external.deployExecutor( + await this._ownerSigner.getAddress(), + BigNumber.from(0), + BigNumber.from(0), + BigNumber.from(0), + MAX_UINT_256, + BigNumber.from(50), + BigNumber.from(100), + BigNumber.from(50), + ether(100) ); - return [aWETH, stableDebtWETH, variableDebtWETH]; - } - public async deployDaiReserve(dai: Address = this.dai): Promise<[AaveV2AToken, AaveV2StableDebtToken, AaveV2VariableDebtToken]> { - const [aDAI, stableDebtDAI, variableDebtDAI] = await this.deployReserve(dai, "DAI", BigNumber.from(18)); - await this.configureReserve( - dai, - BigNumber.from(7500), // base LTV: 75% - BigNumber.from(8000), // liquidation threshold: 80% - BigNumber.from(10500), // liquidation bonus: 105.00% - BigNumber.from(1000), // reserve factor: 10% - true, // enable borrowing on reserve - true // enable stable debts + this.aaveToken = await this._deployer.external.deployAaveTokenV2Mintable(); + await this.aaveToken.mint(await this._ownerSigner.getAddress(), ether(100000)); + this.stkAaveToken = await this._deployer.external.deployAaveTokenV2Mintable(); + await this.stkAaveToken.mint(await this._ownerSigner.getAddress(), ether(100000)); + + this.governanceStrategy = await this._deployer.external.deployGovernanceStrategy(this.aaveToken.address, this.stkAaveToken.address); + this.aaveGovernanceV2 = await this._deployer.external.deployAaveGovernanceV2( + this.governanceStrategy.address, + BigNumber.from(0), + await this._ownerSigner.getAddress(), + [this.executor.address] ); - return [aDAI, stableDebtDAI, variableDebtDAI]; + + this.aaveToken.connect(this._ownerSigner).transfer(await getRandomAddress(), 100); + this.stkAaveToken.connect(this._ownerSigner).transfer(await getRandomAddress(), 100); + await this._deployer.external.deployAaveV2StakedTokenIncentivesController( + this.stkAaveToken.address, this.executor.address + ) + + this.incentivesControllerAddress = (await this._deployer.external.deployAaveV2StakedTokenIncentivesController( + this.stkAaveToken.address, this.executor.address + )).address; } + */ } From 4a7ae1fe29f2f79bc5d92805811d60aa3a45c32a Mon Sep 17 00:00:00 2001 From: alpha-guy Date: Fri, 23 Jul 2021 00:51:21 +0530 Subject: [PATCH 15/19] Return values from library --- .../mocks/protocol/integration/lib/AaveV2Mock.sol | 2 ++ contracts/protocol/integration/lib/AaveV2.sol | 10 ++++++++-- utils/fixtures/aaveV2Fixture.ts | 5 ++--- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/contracts/mocks/protocol/integration/lib/AaveV2Mock.sol b/contracts/mocks/protocol/integration/lib/AaveV2Mock.sol index c3139e840..9fc1b5d21 100644 --- a/contracts/mocks/protocol/integration/lib/AaveV2Mock.sol +++ b/contracts/mocks/protocol/integration/lib/AaveV2Mock.sol @@ -78,6 +78,7 @@ contract AaveV2Mock { uint256 _amountNotional ) external + returns (uint256) { return AaveV2.invokeWithdraw(_setToken, _lendingPool, _asset, _amountNotional); } @@ -131,6 +132,7 @@ contract AaveV2Mock { uint256 _interestRateMode ) external + returns (uint256) { return AaveV2.invokeRepay(_setToken, _lendingPool, _asset, _amountNotional, _interestRateMode); } diff --git a/contracts/protocol/integration/lib/AaveV2.sol b/contracts/protocol/integration/lib/AaveV2.sol index 38f499819..b1f8624fd 100644 --- a/contracts/protocol/integration/lib/AaveV2.sol +++ b/contracts/protocol/integration/lib/AaveV2.sol @@ -117,6 +117,8 @@ library AaveV2 { * * Withdraws an `_amountNotional` of underlying asset from the reserve, burning the equivalent aTokens owned * - E.g. SetToken has 100 aUSDC, and receives 100 USDC, burning the 100 aUSDC + * + * @return uint256 The final amount withdrawn */ function invokeWithdraw( ISetToken _setToken, @@ -125,6 +127,7 @@ library AaveV2 { uint256 _amountNotional ) external + returns (uint256) { ( , , bytes memory withdrawCalldata) = getWithdrawCalldata( _lendingPool, @@ -133,7 +136,7 @@ library AaveV2 { address(_setToken) ); - _setToken.invoke(address(_lendingPool), 0, withdrawCalldata); + return abi.decode(_setToken.invoke(address(_lendingPool), 0, withdrawCalldata), (uint256)); } /** @@ -228,6 +231,8 @@ library AaveV2 { * * Repays a borrowed `_amountNotional` on a specific `_asset` reserve, burning the equivalent debt tokens owned * - E.g. SetToken repays 100 USDC, burning 100 variable/stable debt tokens + * + * @return uint256 The final amount repaid */ function invokeRepay( ISetToken _setToken, @@ -237,6 +242,7 @@ library AaveV2 { uint256 _interestRateMode ) external + returns (uint256) { ( , , bytes memory repayCalldata) = getRepayCalldata( _lendingPool, @@ -246,7 +252,7 @@ library AaveV2 { address(_setToken) ); - _setToken.invoke(address(_lendingPool), 0, repayCalldata); + return abi.decode(_setToken.invoke(address(_lendingPool), 0, repayCalldata), (uint256)); } /** diff --git a/utils/fixtures/aaveV2Fixture.ts b/utils/fixtures/aaveV2Fixture.ts index 4b27156ce..e0cdf0ec6 100644 --- a/utils/fixtures/aaveV2Fixture.ts +++ b/utils/fixtures/aaveV2Fixture.ts @@ -126,12 +126,11 @@ export class AaveV2Fixture { // set initial asset prices in ETH await this.setAssetPriceInOracle(dai, daiPriceInEth); - // set initial market rates - // As per Aave's interest rate model, if U < U_optimal, R_t = R_0 + (U_t/U_optimal) * R_slope1 - // When U_t = 0, R_t = R_0 + // As per Aave's interest rate model, if U < U_optimal, R_t = R_0 + (U_t/U_optimal) * R_slope1, when U_t = 0, R_t = R_0 // R_0 is the interest rate when utilization is 0 (it's the intercept for the above linear equation) // And for higher precision it is expressed in Rays const oneRay = BigNumber.from(10).pow(27); // 1e27 + // set initial market rates (R_0) await this.setMarketBorrowRate(weth, oneRay.mul(3).div(100)); await this.setMarketBorrowRate(dai, oneRay.mul(39).div(1000)); From cecf55d295a139b7441c409942d105a8b3de7f1c Mon Sep 17 00:00:00 2001 From: alpha-guy Date: Fri, 23 Jul 2021 16:46:24 +0530 Subject: [PATCH 16/19] Add detailed javadocs to library contract --- contracts/protocol/integration/lib/AaveV2.sol | 113 ++++++++++++++++-- 1 file changed, 102 insertions(+), 11 deletions(-) diff --git a/contracts/protocol/integration/lib/AaveV2.sol b/contracts/protocol/integration/lib/AaveV2.sol index b1f8624fd..73efd2b30 100644 --- a/contracts/protocol/integration/lib/AaveV2.sol +++ b/contracts/protocol/integration/lib/AaveV2.sol @@ -22,8 +22,6 @@ import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { ILendingPool } from "../../../interfaces/external/aave-v2/ILendingPool.sol"; import { ISetToken } from "../../../interfaces/ISetToken.sol"; -// TODO: Calculate the gas costs of having separate getter functions. - /** * @title AaveV2 * @author Set Protocol @@ -38,6 +36,18 @@ library AaveV2 { * * Deposits an `_amountNotional` of underlying asset into the reserve, receiving in return overlying aTokens. * - E.g. User deposits 100 USDC and gets in return 100 aUSDC + * @param _lendingPool Address of the LendingPool contract + * @param _asset The address of the underlying asset to deposit + * @param _amountNotional The amount to be deposited + * @param _onBehalfOf The address that will receive the aTokens, same as msg.sender if the user + * wants to receive them on his own wallet, or a different address if the beneficiary of aTokens + * is a different wallet + * @param _referralCode Code used to register the integrator originating the operation, for potential rewards. + * 0 if the action is executed directly by the user, without any middle-man + * + * @return address Target contract address + * @return uint256 Call value + * @return bytes Deposit calldata */ function getDepositCalldata( ILendingPool _lendingPool, @@ -66,6 +76,10 @@ library AaveV2 { * * Deposits an `_amountNotional` of underlying asset into the reserve, receiving in return overlying aTokens. * - E.g. SetToken deposits 100 USDC and gets in return 100 aUSDC + * @param _setToken Address of the SetToken + * @param _lendingPool Address of the LendingPool contract + * @param _asset The address of the underlying asset to deposit + * @param _amountNotional The amount to be deposited */ function invokeDeposit( ISetToken _setToken, @@ -91,6 +105,17 @@ library AaveV2 { * * Withdraws an `_amountNotional` of underlying asset from the reserve, burning the equivalent aTokens owned * - E.g. User has 100 aUSDC, calls withdraw() and receives 100 USDC, burning the 100 aUSDC + * @param _lendingPool Address of the LendingPool contract + * @param _asset The address of the underlying asset to withdraw + * @param _amountNotional The underlying amount to be withdrawn + * Note: Passing type(uint256).max will withdraw the entire aToken balance + * @param _receiver Address that will receive the underlying, same as msg.sender if the user + * wants to receive it on his own wallet, or a different address if the beneficiary is a + * different wallet + * + * @return address Target contract address + * @return uint256 Call value + * @return bytes Withdraw calldata */ function getWithdrawCalldata( ILendingPool _lendingPool, @@ -118,7 +143,13 @@ library AaveV2 { * Withdraws an `_amountNotional` of underlying asset from the reserve, burning the equivalent aTokens owned * - E.g. SetToken has 100 aUSDC, and receives 100 USDC, burning the 100 aUSDC * - * @return uint256 The final amount withdrawn + * @param _setToken Address of the SetToken + * @param _lendingPool Address of the LendingPool contract + * @param _asset The address of the underlying asset to withdraw + * @param _amountNotional The underlying amount to be withdrawn + * Note: Passing type(uint256).max will withdraw the entire aToken balance + * + * @return uint256 The final amount withdrawn */ function invokeWithdraw( ISetToken _setToken, @@ -142,10 +173,25 @@ library AaveV2 { /** * Get borrow calldata from SetToken * - * Allows users to borrow a specific `_amountNotional` of the reserve underlying `_asset`, provided that - * the borrower already deposited enough collateral, or he was given enough allowance by a credit delegator - * on the corresponding debt token (StableDebtToken or VariableDebtToken) - */ + * Allows users to borrow a specific `_amountNotional` of the reserve underlying `_asset`, provided that + * the borrower already deposited enough collateral, or he was given enough allowance by a credit delegator + * on the corresponding debt token (StableDebtToken or VariableDebtToken) + * + * @param _lendingPool Address of the LendingPool contract + * @param _asset The address of the underlying asset to borrow + * @param _amountNotional The amount to be borrowed + * @param _interestRateMode The interest rate mode at which the user wants to borrow: 1 for Stable, 2 for Variable + * @param _referralCode Code used to register the integrator originating the operation, for potential rewards. + * 0 if the action is executed directly by the user, without any middle-man + * @param _onBehalfOf Address of the user who will receive the debt. Should be the address of the borrower itself + * calling the function if he wants to borrow against his own collateral, or the address of the + * credit delegator if he has been given credit delegation allowance + * + * + * @return address Target contract address + * @return uint256 Call value + * @return bytes Borrow calldata + */ function getBorrowCalldata( ILendingPool _lendingPool, address _asset, @@ -176,7 +222,12 @@ library AaveV2 { * Allows SetToken to borrow a specific `_amountNotional` of the reserve underlying `_asset`, provided that * the SetToken already deposited enough collateral, or it was given enough allowance by a credit delegator * on the corresponding debt token (StableDebtToken or VariableDebtToken) - */ + * @param _setToken Address of the SetToken + * @param _lendingPool Address of the LendingPool contract + * @param _asset The address of the underlying asset to borrow + * @param _amountNotional The amount to be borrowed + * @param _interestRateMode The interest rate mode at which the user wants to borrow: 1 for Stable, 2 for Variable + */ function invokeBorrow( ISetToken _setToken, ILendingPool _lendingPool, @@ -203,6 +254,18 @@ library AaveV2 { * * Repays a borrowed `_amountNotional` on a specific `_asset` reserve, burning the equivalent debt tokens owned * - E.g. User repays 100 USDC, burning 100 variable/stable debt tokens of the `onBehalfOf` address + * @param _lendingPool Address of the LendingPool contract + * @param _asset The address of the borrowed underlying asset previously borrowed + * @param _amountNotional The amount to repay + * Note: Passing type(uint256).max will repay the whole debt for `_asset` on the specific `_interestRateMode` + * @param _interestRateMode The interest rate mode at of the debt the user wants to repay: 1 for Stable, 2 for Variable + * @param _onBehalfOf Address of the user who will get his debt reduced/removed. Should be the address of the + * user calling the function if he wants to reduce/remove his own debt, or the address of any other + * other borrower whose debt should be removed + * + * @return address Target contract address + * @return uint256 Call value + * @return bytes Repay calldata */ function getRepayCalldata( ILendingPool _lendingPool, @@ -231,8 +294,14 @@ library AaveV2 { * * Repays a borrowed `_amountNotional` on a specific `_asset` reserve, burning the equivalent debt tokens owned * - E.g. SetToken repays 100 USDC, burning 100 variable/stable debt tokens - * - * @return uint256 The final amount repaid + * @param _setToken Address of the SetToken + * @param _lendingPool Address of the LendingPool contract + * @param _asset The address of the borrowed underlying asset previously borrowed + * @param _amountNotional The amount to repay + * Note: Passing type(uint256).max will repay the whole debt for `_asset` on the specific `_interestRateMode` + * @param _interestRateMode The interest rate mode at of the debt the user wants to repay: 1 for Stable, 2 for Variable + * + * @return uint256 The final amount repaid */ function invokeRepay( ISetToken _setToken, @@ -259,6 +328,13 @@ library AaveV2 { * Get setUserUseReserveAsCollateral calldata from SetToken * * Allows borrower to enable/disable a specific deposited asset as collateral + * @param _lendingPool Address of the LendingPool contract + * @param _asset The address of the underlying asset deposited + * @param _useAsCollateral `true` if the user wants to use the deposit as collateral, `false` otherwise + * + * @return address Target contract address + * @return uint256 Call value + * @return bytes SetUserUseReserveAsCollateral calldata */ function getSetUserUseReserveAsCollateralCalldata( ILendingPool _lendingPool, @@ -282,6 +358,10 @@ library AaveV2 { * Invoke an asset to be used as collateral on Aave from SetToken * * Allows SetToken to enable/disable a specific deposited asset as collateral + * @param _setToken Address of the SetToken + * @param _lendingPool Address of the LendingPool contract + * @param _asset The address of the underlying asset deposited + * @param _useAsCollateral `true` if the user wants to use the deposit as collateral, `false` otherwise */ function invokeSetUserUseReserveAsCollateral( ISetToken _setToken, @@ -303,7 +383,14 @@ library AaveV2 { /** * Get swapBorrowRate calldata from SetToken * - * Aave allows a borrower to toggle his debt between stable and variable mode + * Allows a borrower to toggle his debt between stable and variable mode + * @param _lendingPool Address of the LendingPool contract + * @param _asset The address of the underlying asset borrowed + * @param _rateMode The rate mode that the user wants to swap to + * + * @return address Target contract address + * @return uint256 Call value + * @return bytes SwapBorrowRate calldata */ function getSwapBorrowRateModeCalldata( ILendingPool _lendingPool, @@ -327,6 +414,10 @@ library AaveV2 { * Invoke to swap borrow rate of SetToken * * Allows SetToken to toggle it's debt between stable and variable mode + * @param _setToken Address of the SetToken + * @param _lendingPool Address of the LendingPool contract + * @param _asset The address of the underlying asset borrowed + * @param _rateMode The rate mode that the user wants to swap to */ function invokeSwapBorrowRateMode( ISetToken _setToken, From ac2180d861b0e09d2df60e51232e0155ace33468 Mon Sep 17 00:00:00 2001 From: alpha-guy Date: Fri, 23 Jul 2021 16:47:02 +0530 Subject: [PATCH 17/19] Fix tests: Remove unnecessary checks --- test/protocol/integration/lib/aaveV2.spec.ts | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/test/protocol/integration/lib/aaveV2.spec.ts b/test/protocol/integration/lib/aaveV2.spec.ts index fb7fdf3f0..7e207ef00 100644 --- a/test/protocol/integration/lib/aaveV2.spec.ts +++ b/test/protocol/integration/lib/aaveV2.spec.ts @@ -13,7 +13,7 @@ import { getSystemFixture, getWaffleExpect, addSnapshotBeforeRestoreAfterEach, - getAaveV2Fixture, + getAaveV2Fixture } from "@utils/test/index"; import { AaveV2Fixture, SystemFixture } from "@utils/fixtures"; import { ADDRESS_ZERO, MAX_UINT_256, ONE, ZERO } from "@utils/constants"; @@ -535,16 +535,11 @@ describe("AaveV2", () => { }); it("should repay DAI and burn stableDebtDAI", async () => { - // const previousDebtTokenBalance = await stableDebtDAI.balanceOf(setToken.address); const previousUnderlyingBalance = await setup.dai.balanceOf(setToken.address); await subject(); - // const currentDebtTokenBalance = await stableDebtDAI.balanceOf(setToken.address); const currentUnderlyingBalance = await setup.dai.balanceOf(setToken.address); - // const expectedDebtTokenBalance = previousDebtTokenBalance.sub(subjectAmountNotional); const expectedUnderlyingBalance = previousUnderlyingBalance.sub(subjectAmountNotional); - - // expect(currentDebtTokenBalance).to.eq(expectedDebtTokenBalance); expect(currentUnderlyingBalance).to.eq(expectedUnderlyingBalance); }); }); @@ -563,16 +558,10 @@ describe("AaveV2", () => { }); it("should repay DAI and burn variableDebtDAI", async () => { - // const previousDebtTokenBalance = await variableDebtDAI.balanceOf(setToken.address); const previousUnderlyingBalance = await setup.dai.balanceOf(setToken.address); await subject(); - // const currentDebtTokenBalance = await variableDebtDAI.balanceOf(setToken.address); const currentUnderlyingBalance = await setup.dai.balanceOf(setToken.address); - - // const expectedDebtTokenBalance = previousDebtTokenBalance.sub(subjectAmountNotional); const expectedUnderlyingBalance = previousUnderlyingBalance.sub(subjectAmountNotional); - - // expect(currentDebtTokenBalance).to.eq(expectedDebtTokenBalance); expect(currentUnderlyingBalance).to.eq(expectedUnderlyingBalance); }); }); @@ -661,8 +650,6 @@ describe("AaveV2", () => { const previousStableDebtTokenBalance = await stableDebtDAI.balanceOf(setToken.address); await subject(); const currentVariableDebtTokenBalance = await variableDebtDAI.balanceOf(setToken.address); - - // expect(currentStableDebtTokenBalance).to.eq(ZERO); expect(currentVariableDebtTokenBalance).to.eq(previousStableDebtTokenBalance); }); }); @@ -679,8 +666,6 @@ describe("AaveV2", () => { const previousVariableDebtTokenBalance = await variableDebtDAI.balanceOf(setToken.address); await subject(); const currentStableDebtTokenBalance = await stableDebtDAI.balanceOf(setToken.address); - - // expect(currentVariableDebtTokenBalance).to.eq(ZERO); expect(currentStableDebtTokenBalance).to.eq(previousVariableDebtTokenBalance); }); }); From c2912b73c6129663a94d59e3480bc57c19f61c3a Mon Sep 17 00:00:00 2001 From: alpha-guy Date: Sat, 24 Jul 2021 02:03:04 +0530 Subject: [PATCH 18/19] Untabify javadocs --- contracts/protocol/integration/lib/AaveV2.sol | 194 +++++++++--------- 1 file changed, 97 insertions(+), 97 deletions(-) diff --git a/contracts/protocol/integration/lib/AaveV2.sol b/contracts/protocol/integration/lib/AaveV2.sol index 73efd2b30..5a9f7a7c0 100644 --- a/contracts/protocol/integration/lib/AaveV2.sol +++ b/contracts/protocol/integration/lib/AaveV2.sol @@ -36,18 +36,18 @@ library AaveV2 { * * Deposits an `_amountNotional` of underlying asset into the reserve, receiving in return overlying aTokens. * - E.g. User deposits 100 USDC and gets in return 100 aUSDC - * @param _lendingPool Address of the LendingPool contract - * @param _asset The address of the underlying asset to deposit - * @param _amountNotional The amount to be deposited - * @param _onBehalfOf The address that will receive the aTokens, same as msg.sender if the user - * wants to receive them on his own wallet, or a different address if the beneficiary of aTokens - * is a different wallet - * @param _referralCode Code used to register the integrator originating the operation, for potential rewards. - * 0 if the action is executed directly by the user, without any middle-man - * - * @return address Target contract address - * @return uint256 Call value - * @return bytes Deposit calldata + * @param _lendingPool Address of the LendingPool contract + * @param _asset The address of the underlying asset to deposit + * @param _amountNotional The amount to be deposited + * @param _onBehalfOf The address that will receive the aTokens, same as msg.sender if the user + * wants to receive them on his own wallet, or a different address if the beneficiary of aTokens + * is a different wallet + * @param _referralCode Code used to register the integrator originating the operation, for potential rewards. + * 0 if the action is executed directly by the user, without any middle-man + * + * @return address Target contract address + * @return uint256 Call value + * @return bytes Deposit calldata */ function getDepositCalldata( ILendingPool _lendingPool, @@ -76,10 +76,10 @@ library AaveV2 { * * Deposits an `_amountNotional` of underlying asset into the reserve, receiving in return overlying aTokens. * - E.g. SetToken deposits 100 USDC and gets in return 100 aUSDC - * @param _setToken Address of the SetToken - * @param _lendingPool Address of the LendingPool contract - * @param _asset The address of the underlying asset to deposit - * @param _amountNotional The amount to be deposited + * @param _setToken Address of the SetToken + * @param _lendingPool Address of the LendingPool contract + * @param _asset The address of the underlying asset to deposit + * @param _amountNotional The amount to be deposited */ function invokeDeposit( ISetToken _setToken, @@ -105,17 +105,17 @@ library AaveV2 { * * Withdraws an `_amountNotional` of underlying asset from the reserve, burning the equivalent aTokens owned * - E.g. User has 100 aUSDC, calls withdraw() and receives 100 USDC, burning the 100 aUSDC - * @param _lendingPool Address of the LendingPool contract - * @param _asset The address of the underlying asset to withdraw - * @param _amountNotional The underlying amount to be withdrawn - * Note: Passing type(uint256).max will withdraw the entire aToken balance - * @param _receiver Address that will receive the underlying, same as msg.sender if the user - * wants to receive it on his own wallet, or a different address if the beneficiary is a - * different wallet - * - * @return address Target contract address - * @return uint256 Call value - * @return bytes Withdraw calldata + * @param _lendingPool Address of the LendingPool contract + * @param _asset The address of the underlying asset to withdraw + * @param _amountNotional The underlying amount to be withdrawn + * Note: Passing type(uint256).max will withdraw the entire aToken balance + * @param _receiver Address that will receive the underlying, same as msg.sender if the user + * wants to receive it on his own wallet, or a different address if the beneficiary is a + * different wallet + * + * @return address Target contract address + * @return uint256 Call value + * @return bytes Withdraw calldata */ function getWithdrawCalldata( ILendingPool _lendingPool, @@ -143,12 +143,12 @@ library AaveV2 { * Withdraws an `_amountNotional` of underlying asset from the reserve, burning the equivalent aTokens owned * - E.g. SetToken has 100 aUSDC, and receives 100 USDC, burning the 100 aUSDC * - * @param _setToken Address of the SetToken - * @param _lendingPool Address of the LendingPool contract + * @param _setToken Address of the SetToken + * @param _lendingPool Address of the LendingPool contract * @param _asset The address of the underlying asset to withdraw * @param _amountNotional The underlying amount to be withdrawn * Note: Passing type(uint256).max will withdraw the entire aToken balance - * + * * @return uint256 The final amount withdrawn */ function invokeWithdraw( @@ -173,25 +173,25 @@ library AaveV2 { /** * Get borrow calldata from SetToken * - * Allows users to borrow a specific `_amountNotional` of the reserve underlying `_asset`, provided that - * the borrower already deposited enough collateral, or he was given enough allowance by a credit delegator - * on the corresponding debt token (StableDebtToken or VariableDebtToken) - * - * @param _lendingPool Address of the LendingPool contract - * @param _asset The address of the underlying asset to borrow - * @param _amountNotional The amount to be borrowed - * @param _interestRateMode The interest rate mode at which the user wants to borrow: 1 for Stable, 2 for Variable - * @param _referralCode Code used to register the integrator originating the operation, for potential rewards. - * 0 if the action is executed directly by the user, without any middle-man - * @param _onBehalfOf Address of the user who will receive the debt. Should be the address of the borrower itself - * calling the function if he wants to borrow against his own collateral, or the address of the - * credit delegator if he has been given credit delegation allowance - * - * - * @return address Target contract address - * @return uint256 Call value - * @return bytes Borrow calldata - */ + * Allows users to borrow a specific `_amountNotional` of the reserve underlying `_asset`, provided that + * the borrower already deposited enough collateral, or he was given enough allowance by a credit delegator + * on the corresponding debt token (StableDebtToken or VariableDebtToken) + * + * @param _lendingPool Address of the LendingPool contract + * @param _asset The address of the underlying asset to borrow + * @param _amountNotional The amount to be borrowed + * @param _interestRateMode The interest rate mode at which the user wants to borrow: 1 for Stable, 2 for Variable + * @param _referralCode Code used to register the integrator originating the operation, for potential rewards. + * 0 if the action is executed directly by the user, without any middle-man + * @param _onBehalfOf Address of the user who will receive the debt. Should be the address of the borrower itself + * calling the function if he wants to borrow against his own collateral, or the address of the + * credit delegator if he has been given credit delegation allowance + * + * + * @return address Target contract address + * @return uint256 Call value + * @return bytes Borrow calldata + */ function getBorrowCalldata( ILendingPool _lendingPool, address _asset, @@ -222,12 +222,12 @@ library AaveV2 { * Allows SetToken to borrow a specific `_amountNotional` of the reserve underlying `_asset`, provided that * the SetToken already deposited enough collateral, or it was given enough allowance by a credit delegator * on the corresponding debt token (StableDebtToken or VariableDebtToken) - * @param _setToken Address of the SetToken - * @param _lendingPool Address of the LendingPool contract - * @param _asset The address of the underlying asset to borrow - * @param _amountNotional The amount to be borrowed - * @param _interestRateMode The interest rate mode at which the user wants to borrow: 1 for Stable, 2 for Variable - */ + * @param _setToken Address of the SetToken + * @param _lendingPool Address of the LendingPool contract + * @param _asset The address of the underlying asset to borrow + * @param _amountNotional The amount to be borrowed + * @param _interestRateMode The interest rate mode at which the user wants to borrow: 1 for Stable, 2 for Variable + */ function invokeBorrow( ISetToken _setToken, ILendingPool _lendingPool, @@ -254,18 +254,18 @@ library AaveV2 { * * Repays a borrowed `_amountNotional` on a specific `_asset` reserve, burning the equivalent debt tokens owned * - E.g. User repays 100 USDC, burning 100 variable/stable debt tokens of the `onBehalfOf` address - * @param _lendingPool Address of the LendingPool contract - * @param _asset The address of the borrowed underlying asset previously borrowed - * @param _amountNotional The amount to repay - * Note: Passing type(uint256).max will repay the whole debt for `_asset` on the specific `_interestRateMode` - * @param _interestRateMode The interest rate mode at of the debt the user wants to repay: 1 for Stable, 2 for Variable - * @param _onBehalfOf Address of the user who will get his debt reduced/removed. Should be the address of the - * user calling the function if he wants to reduce/remove his own debt, or the address of any other - * other borrower whose debt should be removed - * - * @return address Target contract address - * @return uint256 Call value - * @return bytes Repay calldata + * @param _lendingPool Address of the LendingPool contract + * @param _asset The address of the borrowed underlying asset previously borrowed + * @param _amountNotional The amount to repay + * Note: Passing type(uint256).max will repay the whole debt for `_asset` on the specific `_interestRateMode` + * @param _interestRateMode The interest rate mode at of the debt the user wants to repay: 1 for Stable, 2 for Variable + * @param _onBehalfOf Address of the user who will get his debt reduced/removed. Should be the address of the + * user calling the function if he wants to reduce/remove his own debt, or the address of any other + * other borrower whose debt should be removed + * + * @return address Target contract address + * @return uint256 Call value + * @return bytes Repay calldata */ function getRepayCalldata( ILendingPool _lendingPool, @@ -294,14 +294,14 @@ library AaveV2 { * * Repays a borrowed `_amountNotional` on a specific `_asset` reserve, burning the equivalent debt tokens owned * - E.g. SetToken repays 100 USDC, burning 100 variable/stable debt tokens - * @param _setToken Address of the SetToken - * @param _lendingPool Address of the LendingPool contract - * @param _asset The address of the borrowed underlying asset previously borrowed - * @param _amountNotional The amount to repay - * Note: Passing type(uint256).max will repay the whole debt for `_asset` on the specific `_interestRateMode` - * @param _interestRateMode The interest rate mode at of the debt the user wants to repay: 1 for Stable, 2 for Variable - * - * @return uint256 The final amount repaid + * @param _setToken Address of the SetToken + * @param _lendingPool Address of the LendingPool contract + * @param _asset The address of the borrowed underlying asset previously borrowed + * @param _amountNotional The amount to repay + * Note: Passing type(uint256).max will repay the whole debt for `_asset` on the specific `_interestRateMode` + * @param _interestRateMode The interest rate mode at of the debt the user wants to repay: 1 for Stable, 2 for Variable + * + * @return uint256 The final amount repaid */ function invokeRepay( ISetToken _setToken, @@ -328,13 +328,13 @@ library AaveV2 { * Get setUserUseReserveAsCollateral calldata from SetToken * * Allows borrower to enable/disable a specific deposited asset as collateral - * @param _lendingPool Address of the LendingPool contract - * @param _asset The address of the underlying asset deposited - * @param _useAsCollateral `true` if the user wants to use the deposit as collateral, `false` otherwise - * - * @return address Target contract address - * @return uint256 Call value - * @return bytes SetUserUseReserveAsCollateral calldata + * @param _lendingPool Address of the LendingPool contract + * @param _asset The address of the underlying asset deposited + * @param _useAsCollateral true` if the user wants to use the deposit as collateral, `false` otherwise + * + * @return address Target contract address + * @return uint256 Call value + * @return bytes SetUserUseReserveAsCollateral calldata */ function getSetUserUseReserveAsCollateralCalldata( ILendingPool _lendingPool, @@ -358,10 +358,10 @@ library AaveV2 { * Invoke an asset to be used as collateral on Aave from SetToken * * Allows SetToken to enable/disable a specific deposited asset as collateral - * @param _setToken Address of the SetToken - * @param _lendingPool Address of the LendingPool contract - * @param _asset The address of the underlying asset deposited - * @param _useAsCollateral `true` if the user wants to use the deposit as collateral, `false` otherwise + * @param _setToken Address of the SetToken + * @param _lendingPool Address of the LendingPool contract + * @param _asset The address of the underlying asset deposited + * @param _useAsCollateral true` if the user wants to use the deposit as collateral, `false` otherwise */ function invokeSetUserUseReserveAsCollateral( ISetToken _setToken, @@ -384,13 +384,13 @@ library AaveV2 { * Get swapBorrowRate calldata from SetToken * * Allows a borrower to toggle his debt between stable and variable mode - * @param _lendingPool Address of the LendingPool contract - * @param _asset The address of the underlying asset borrowed - * @param _rateMode The rate mode that the user wants to swap to - * - * @return address Target contract address - * @return uint256 Call value - * @return bytes SwapBorrowRate calldata + * @param _lendingPool Address of the LendingPool contract + * @param _asset The address of the underlying asset borrowed + * @param _rateMode The rate mode that the user wants to swap to + * + * @return address Target contract address + * @return uint256 Call value + * @return bytes SwapBorrowRate calldata */ function getSwapBorrowRateModeCalldata( ILendingPool _lendingPool, @@ -414,10 +414,10 @@ library AaveV2 { * Invoke to swap borrow rate of SetToken * * Allows SetToken to toggle it's debt between stable and variable mode - * @param _setToken Address of the SetToken - * @param _lendingPool Address of the LendingPool contract - * @param _asset The address of the underlying asset borrowed - * @param _rateMode The rate mode that the user wants to swap to + * @param _setToken Address of the SetToken + * @param _lendingPool Address of the LendingPool contract + * @param _asset The address of the underlying asset borrowed + * @param _rateMode The rate mode that the user wants to swap to */ function invokeSwapBorrowRateMode( ISetToken _setToken, From f4d82ea2f87d3d01f67eab9bc23d7df30b0491db Mon Sep 17 00:00:00 2001 From: alpha-guy Date: Sat, 24 Jul 2021 02:07:11 +0530 Subject: [PATCH 19/19] Remove extra line --- contracts/protocol/integration/lib/AaveV2.sol | 1 - 1 file changed, 1 deletion(-) diff --git a/contracts/protocol/integration/lib/AaveV2.sol b/contracts/protocol/integration/lib/AaveV2.sol index 5a9f7a7c0..f622273a6 100644 --- a/contracts/protocol/integration/lib/AaveV2.sol +++ b/contracts/protocol/integration/lib/AaveV2.sol @@ -187,7 +187,6 @@ library AaveV2 { * calling the function if he wants to borrow against his own collateral, or the address of the * credit delegator if he has been given credit delegation allowance * - * * @return address Target contract address * @return uint256 Call value * @return bytes Borrow calldata