mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Merge branch 'feat/data-helpers' into feat/renameing
This commit is contained in:
commit
438ab0fca1
|
@ -6,6 +6,8 @@ import {accounts} from './test-wallets.js';
|
||||||
import {eEthereumNetwork} from './helpers/types';
|
import {eEthereumNetwork} from './helpers/types';
|
||||||
import {BUIDLEREVM_CHAINID, COVERAGE_CHAINID} from './helpers/buidler-constants';
|
import {BUIDLEREVM_CHAINID, COVERAGE_CHAINID} from './helpers/buidler-constants';
|
||||||
|
|
||||||
|
require('dotenv').config();
|
||||||
|
|
||||||
usePlugin('@nomiclabs/buidler-ethers');
|
usePlugin('@nomiclabs/buidler-ethers');
|
||||||
usePlugin('buidler-typechain');
|
usePlugin('buidler-typechain');
|
||||||
usePlugin('solidity-coverage');
|
usePlugin('solidity-coverage');
|
||||||
|
@ -24,7 +26,7 @@ const MNEMONIC = process.env.MNEMONIC || '';
|
||||||
|
|
||||||
// Prevent to load scripts before compilation and typechain
|
// Prevent to load scripts before compilation and typechain
|
||||||
if (!SKIP_LOAD) {
|
if (!SKIP_LOAD) {
|
||||||
['misc', 'migrations', 'dev', 'full'].forEach((folder) => {
|
['misc', 'deployments', 'migrations', 'dev', 'full'].forEach((folder) => {
|
||||||
const tasksPath = path.join(__dirname, 'tasks', folder);
|
const tasksPath = path.join(__dirname, 'tasks', folder);
|
||||||
fs.readdirSync(tasksPath)
|
fs.readdirSync(tasksPath)
|
||||||
.filter((pth) => pth.includes('.ts'))
|
.filter((pth) => pth.includes('.ts'))
|
||||||
|
|
|
@ -11,16 +11,27 @@ interface IUiPoolDataProvider {
|
||||||
string name;
|
string name;
|
||||||
string symbol;
|
string symbol;
|
||||||
uint256 decimals;
|
uint256 decimals;
|
||||||
uint256 ltv;
|
uint256 baseLTVasCollateral;
|
||||||
uint256 liquidationThreshold;
|
uint256 reserveLiquidationThreshold;
|
||||||
uint256 liquidationBonus;
|
uint256 reserveLiquidationBonus;
|
||||||
uint256 reserveFactor;
|
uint256 reserveFactor;
|
||||||
bool usageAsCollateralEnabled;
|
bool usageAsCollateralEnabled;
|
||||||
bool borrowingEnabled;
|
bool borrowingEnabled;
|
||||||
bool stableBorrowRateEnabled;
|
bool stableBorrowRateEnabled;
|
||||||
bool isActive;
|
bool isActive;
|
||||||
bool isFrozen;
|
bool isFrozen;
|
||||||
ReserveLogic.ReserveData baseData;
|
// base data
|
||||||
|
uint128 liquidityIndex;
|
||||||
|
uint128 variableBorrowIndex;
|
||||||
|
uint128 liquidityRate;
|
||||||
|
uint128 variableBorrowRate;
|
||||||
|
uint128 stableBorrowRate;
|
||||||
|
uint40 lastUpdateTimestamp;
|
||||||
|
address aTokenAddress;
|
||||||
|
address stableDebtTokenAddress;
|
||||||
|
address variableDebtTokenAddress;
|
||||||
|
address interestRateStrategyAddress;
|
||||||
|
//
|
||||||
uint256 availableLiquidity;
|
uint256 availableLiquidity;
|
||||||
uint256 totalPrincipalStableDebt;
|
uint256 totalPrincipalStableDebt;
|
||||||
uint256 averageStableRate;
|
uint256 averageStableRate;
|
||||||
|
|
|
@ -12,9 +12,12 @@ import {IVariableDebtToken} from '../tokenization/interfaces/IVariableDebtToken.
|
||||||
import {IStableDebtToken} from '../tokenization/interfaces/IStableDebtToken.sol';
|
import {IStableDebtToken} from '../tokenization/interfaces/IStableDebtToken.sol';
|
||||||
|
|
||||||
import {WadRayMath} from '../libraries/math/WadRayMath.sol';
|
import {WadRayMath} from '../libraries/math/WadRayMath.sol';
|
||||||
|
import {ReserveLogic} from '../libraries/logic/ReserveLogic.sol';
|
||||||
import {ReserveConfiguration} from '../libraries/configuration/ReserveConfiguration.sol';
|
import {ReserveConfiguration} from '../libraries/configuration/ReserveConfiguration.sol';
|
||||||
import {UserConfiguration} from '../libraries/configuration/UserConfiguration.sol';
|
import {UserConfiguration} from '../libraries/configuration/UserConfiguration.sol';
|
||||||
import '../lendingpool/DefaultReserveInterestRateStrategy.sol';
|
import {
|
||||||
|
DefaultReserveInterestRateStrategy
|
||||||
|
} from '../lendingpool/DefaultReserveInterestRateStrategy.sol';
|
||||||
|
|
||||||
contract UiPoolDataProvider is IUiPoolDataProvider {
|
contract UiPoolDataProvider is IUiPoolDataProvider {
|
||||||
using WadRayMath for uint256;
|
using WadRayMath for uint256;
|
||||||
|
@ -66,11 +69,23 @@ contract UiPoolDataProvider is IUiPoolDataProvider {
|
||||||
reserveData.underlyingAsset = reserves[i];
|
reserveData.underlyingAsset = reserves[i];
|
||||||
|
|
||||||
// reserve current state
|
// reserve current state
|
||||||
reserveData.baseData = lendingPool.getReserveData(reserveData.underlyingAsset);
|
ReserveLogic.ReserveData memory baseData = lendingPool.getReserveData(
|
||||||
|
reserveData.underlyingAsset
|
||||||
|
);
|
||||||
|
reserveData.liquidityIndex = baseData.liquidityIndex;
|
||||||
|
reserveData.variableBorrowIndex = baseData.variableBorrowIndex;
|
||||||
|
reserveData.liquidityRate = baseData.currentLiquidityRate;
|
||||||
|
reserveData.variableBorrowRate = baseData.currentVariableBorrowRate;
|
||||||
|
reserveData.stableBorrowRate = baseData.currentStableBorrowRate;
|
||||||
|
reserveData.lastUpdateTimestamp = baseData.lastUpdateTimestamp;
|
||||||
|
reserveData.aTokenAddress = baseData.aTokenAddress;
|
||||||
|
reserveData.stableDebtTokenAddress = baseData.stableDebtTokenAddress;
|
||||||
|
reserveData.variableDebtTokenAddress = baseData.variableDebtTokenAddress;
|
||||||
|
reserveData.interestRateStrategyAddress = baseData.interestRateStrategyAddress;
|
||||||
reserveData.priceInEth = oracle.getAssetPrice(reserveData.underlyingAsset);
|
reserveData.priceInEth = oracle.getAssetPrice(reserveData.underlyingAsset);
|
||||||
|
|
||||||
reserveData.availableLiquidity = IERC20Detailed(reserveData.underlyingAsset).balanceOf(
|
reserveData.availableLiquidity = IERC20Detailed(reserveData.underlyingAsset).balanceOf(
|
||||||
reserveData.baseData.aTokenAddress
|
reserveData.aTokenAddress
|
||||||
);
|
);
|
||||||
(
|
(
|
||||||
reserveData.totalPrincipalStableDebt,
|
reserveData.totalPrincipalStableDebt,
|
||||||
|
@ -88,62 +103,58 @@ contract UiPoolDataProvider is IUiPoolDataProvider {
|
||||||
// reserve configuration
|
// reserve configuration
|
||||||
|
|
||||||
// we're getting this info from the aToken, because some of assets can be not compliant with ETC20Detailed
|
// we're getting this info from the aToken, because some of assets can be not compliant with ETC20Detailed
|
||||||
reserveData.symbol = IERC20Detailed(reserveData.baseData.aTokenAddress).symbol();
|
reserveData.symbol = IERC20Detailed(reserveData.aTokenAddress).symbol();
|
||||||
reserveData.name = '';
|
reserveData.name = '';
|
||||||
|
|
||||||
(
|
(
|
||||||
reserveData.ltv,
|
reserveData.baseLTVasCollateral,
|
||||||
reserveData.liquidationThreshold,
|
reserveData.reserveLiquidationThreshold,
|
||||||
reserveData.liquidationBonus,
|
reserveData.reserveLiquidationBonus,
|
||||||
reserveData.decimals,
|
reserveData.decimals,
|
||||||
reserveData.reserveFactor
|
reserveData.reserveFactor
|
||||||
) = reserveData.baseData.configuration.getParamsMemory();
|
) = baseData.configuration.getParamsMemory();
|
||||||
(
|
(
|
||||||
reserveData.isActive,
|
reserveData.isActive,
|
||||||
reserveData.isFrozen,
|
reserveData.isFrozen,
|
||||||
reserveData.borrowingEnabled,
|
reserveData.borrowingEnabled,
|
||||||
reserveData.stableBorrowRateEnabled
|
reserveData.stableBorrowRateEnabled
|
||||||
) = reserveData.baseData.configuration.getFlagsMemory();
|
) = baseData.configuration.getFlagsMemory();
|
||||||
reserveData.usageAsCollateralEnabled = reserveData.ltv != 0;
|
reserveData.usageAsCollateralEnabled = reserveData.baseLTVasCollateral != 0;
|
||||||
(
|
(
|
||||||
reserveData.variableRateSlope1,
|
reserveData.variableRateSlope1,
|
||||||
reserveData.variableRateSlope2,
|
reserveData.variableRateSlope2,
|
||||||
reserveData.stableRateSlope1,
|
reserveData.stableRateSlope1,
|
||||||
reserveData.stableRateSlope2
|
reserveData.stableRateSlope2
|
||||||
) = getInterestRateStrategySlopes(
|
) = getInterestRateStrategySlopes(
|
||||||
DefaultReserveInterestRateStrategy(reserveData.baseData.interestRateStrategyAddress)
|
DefaultReserveInterestRateStrategy(reserveData.interestRateStrategyAddress)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (user != address(0)) {
|
if (user != address(0)) {
|
||||||
// user reserve data
|
// user reserve data
|
||||||
userReservesData[i].underlyingAsset = reserveData.underlyingAsset;
|
userReservesData[i].underlyingAsset = reserveData.underlyingAsset;
|
||||||
userReservesData[i].scaledATokenBalance = IAToken(reserveData.baseData.aTokenAddress)
|
userReservesData[i].principalATokenBalance = IAToken(reserveData.aTokenAddress)
|
||||||
.scaledBalanceOf(user);
|
.scaledBalanceOf(user);
|
||||||
userReservesData[i].usageAsCollateralEnabledOnUser = userConfig.isUsingAsCollateral(i);
|
userReservesData[i].usageAsCollateralEnabledOnUser = userConfig.isUsingAsCollateral(i);
|
||||||
|
|
||||||
if (userConfig.isBorrowing(i)) {
|
if (userConfig.isBorrowing(i)) {
|
||||||
userReservesData[i].scaledVariableDebt = IVariableDebtToken(
|
userReservesData[i].scaledVariableDebt = IVariableDebtToken(
|
||||||
reserveData
|
reserveData
|
||||||
.baseData
|
|
||||||
.variableDebtTokenAddress
|
.variableDebtTokenAddress
|
||||||
)
|
)
|
||||||
.scaledBalanceOf(user);
|
.scaledBalanceOf(user);
|
||||||
userReservesData[i].principalStableDebt = IStableDebtToken(
|
userReservesData[i].principalStableDebt = IStableDebtToken(
|
||||||
reserveData
|
reserveData
|
||||||
.baseData
|
|
||||||
.stableDebtTokenAddress
|
.stableDebtTokenAddress
|
||||||
)
|
)
|
||||||
.principalBalanceOf(user);
|
.principalBalanceOf(user);
|
||||||
if (userReservesData[i].principalStableDebt != 0) {
|
if (userReservesData[i].principalStableDebt != 0) {
|
||||||
userReservesData[i].stableBorrowRate = IStableDebtToken(
|
userReservesData[i].stableBorrowRate = IStableDebtToken(
|
||||||
reserveData
|
reserveData
|
||||||
.baseData
|
|
||||||
.stableDebtTokenAddress
|
.stableDebtTokenAddress
|
||||||
)
|
)
|
||||||
.getUserStableRate(user);
|
.getUserStableRate(user);
|
||||||
userReservesData[i].stableBorrowLastUpdateTimestamp = IStableDebtToken(
|
userReservesData[i].stableBorrowLastUpdateTimestamp = IStableDebtToken(
|
||||||
reserveData
|
reserveData
|
||||||
.baseData
|
|
||||||
.stableDebtTokenAddress
|
.stableDebtTokenAddress
|
||||||
)
|
)
|
||||||
.getUserLastUpdated(user);
|
.getUserLastUpdated(user);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import BigNumber from 'bignumber.js';
|
import BigNumber from 'bignumber.js';
|
||||||
import {MockTokenMap} from './contracts-helpers';
|
import {MockTokenMap} from './contracts-helpers';
|
||||||
|
import {UiPoolDataProviderFactory} from '../types';
|
||||||
|
|
||||||
export interface SymbolMap<T> {
|
export interface SymbolMap<T> {
|
||||||
[symbol: string]: T;
|
[symbol: string]: T;
|
||||||
|
@ -57,6 +58,7 @@ export enum eContractid {
|
||||||
TokenDistributor = 'TokenDistributor',
|
TokenDistributor = 'TokenDistributor',
|
||||||
StableAndVariableTokensHelper = 'StableAndVariableTokensHelper',
|
StableAndVariableTokensHelper = 'StableAndVariableTokensHelper',
|
||||||
ATokensAndRatesHelper = 'ATokensAndRatesHelper',
|
ATokensAndRatesHelper = 'ATokensAndRatesHelper',
|
||||||
|
UiPoolDataProvider = 'UiPoolDataProvider',
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
6
package-lock.json
generated
6
package-lock.json
generated
|
@ -3763,6 +3763,12 @@
|
||||||
"integrity": "sha512-6QvTW9mrGeIegrFXdtQi9pk7O/nSK6lSdXW2eqUspN5LWD7UTji2Fqw5V2YLjBpHEoU9Xl/eUWNpDeZvoyOv2w==",
|
"integrity": "sha512-6QvTW9mrGeIegrFXdtQi9pk7O/nSK6lSdXW2eqUspN5LWD7UTji2Fqw5V2YLjBpHEoU9Xl/eUWNpDeZvoyOv2w==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"dotenv": {
|
||||||
|
"version": "8.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz",
|
||||||
|
"integrity": "sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"download": {
|
"download": {
|
||||||
"version": "7.1.0",
|
"version": "7.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/download/-/download-7.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/download/-/download-7.1.0.tgz",
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
"dev:coverage": "buidler coverage --network coverage",
|
"dev:coverage": "buidler coverage --network coverage",
|
||||||
"dev:deployment": "buidler dev-deployment",
|
"dev:deployment": "buidler dev-deployment",
|
||||||
"dev:deployExample": "buidler deploy-Example",
|
"dev:deployExample": "buidler deploy-Example",
|
||||||
|
"dev:deployUIProvider": "npm run buidler:kovan deploy-UiPoolDataProvider",
|
||||||
"dev:prettier": "prettier --write .",
|
"dev:prettier": "prettier --write .",
|
||||||
"ci:test": "npm run compile && npm run types-gen && npm run test",
|
"ci:test": "npm run compile && npm run types-gen && npm run test",
|
||||||
"ci:clean": "rm -rf ./artifacts ./cache ./types"
|
"ci:clean": "rm -rf ./artifacts ./cache ./types"
|
||||||
|
@ -70,6 +71,7 @@
|
||||||
"chai": "4.2.0",
|
"chai": "4.2.0",
|
||||||
"chai-bignumber": "3.0.0",
|
"chai-bignumber": "3.0.0",
|
||||||
"chai-bn": "^0.2.1",
|
"chai-bn": "^0.2.1",
|
||||||
|
"dotenv": "^8.2.0",
|
||||||
"eth-sig-util": "2.5.3",
|
"eth-sig-util": "2.5.3",
|
||||||
"ethereum-waffle": "3.0.2",
|
"ethereum-waffle": "3.0.2",
|
||||||
"ethereumjs-util": "7.0.2",
|
"ethereumjs-util": "7.0.2",
|
||||||
|
|
27
tasks/deployments/deploy-UiPoolDataProvider.ts
Normal file
27
tasks/deployments/deploy-UiPoolDataProvider.ts
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
import {task} from '@nomiclabs/buidler/config';
|
||||||
|
|
||||||
|
import {UiPoolDataProviderFactory} from '../../types';
|
||||||
|
import {verifyContract} from '../../helpers/etherscan-verification';
|
||||||
|
import {eContractid} from '../../helpers/types';
|
||||||
|
|
||||||
|
task(`deploy-${eContractid.UiPoolDataProvider}`, `Deploys the UiPoolDataProvider contract`)
|
||||||
|
.addFlag('verify', 'Verify UiPoolDataProvider contract via Etherscan API.')
|
||||||
|
.setAction(async ({verify}, localBRE) => {
|
||||||
|
await localBRE.run('set-bre');
|
||||||
|
|
||||||
|
if (!localBRE.network.config.chainId) {
|
||||||
|
throw new Error('INVALID_CHAIN_ID');
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`\n- UiPoolDataProvider deployment`);
|
||||||
|
|
||||||
|
console.log(`\tDeploying UiPoolDataProvider implementation ...`);
|
||||||
|
const uiPoolDataProvider = await new UiPoolDataProviderFactory(
|
||||||
|
await localBRE.ethers.provider.getSigner()
|
||||||
|
).deploy();
|
||||||
|
await uiPoolDataProvider.deployTransaction.wait();
|
||||||
|
console.log('uiPoolDataProvider.address', uiPoolDataProvider.address);
|
||||||
|
await verifyContract(eContractid.UiPoolDataProvider, uiPoolDataProvider.address, []);
|
||||||
|
|
||||||
|
console.log(`\tFinished UiPoolDataProvider proxy and implementation deployment`);
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user