From 01231103216610b113e0d81fb5515e3a554e3b95 Mon Sep 17 00:00:00 2001 From: sakulstra Date: Thu, 2 Nov 2023 11:36:22 +0100 Subject: [PATCH 1/2] feat: add ui pool data provider abis --- scripts/configs/abis.ts | 10 +- scripts/generateABIs.ts | 17 +- src/ts/abis/IUiPoolDataProviderV2.ts | 573 +++++++++++++++++++++++++++ src/ts/abis/IUiPoolDataProviderV3.ts | 573 +++++++++++++++++++++++++++ 4 files changed, 1168 insertions(+), 5 deletions(-) create mode 100644 src/ts/abis/IUiPoolDataProviderV2.ts create mode 100644 src/ts/abis/IUiPoolDataProviderV3.ts diff --git a/scripts/configs/abis.ts b/scripts/configs/abis.ts index 9b77739a..6fb5bc0c 100644 --- a/scripts/configs/abis.ts +++ b/scripts/configs/abis.ts @@ -1,5 +1,5 @@ -import {ChainId} from '../generator/chains'; import {governanceConfigMainnet} from './governance/ethereum'; +import {mainnetProtoV2Pool, mainnetProtoV3Pool} from './pools/ethereum'; export const ABI_INTERFACES = [ 'IAaveGovernanceV2', @@ -41,4 +41,12 @@ export const DOWNLOAD_ABI_INTERFACES = [ address: governanceConfigMainnet.ADDRESSES.VM_DATA_HELPER, name: 'IVotingMachineDataHelper', }, + { + address: mainnetProtoV3Pool.additionalAddresses.UI_POOL_DATA_PROVIDER, + name: 'IUiPoolDataProviderV3', + }, + { + address: mainnetProtoV2Pool.additionalAddresses.UI_POOL_DATA_PROVIDER, + name: 'IUiPoolDataProviderV2', + }, ]; diff --git a/scripts/generateABIs.ts b/scripts/generateABIs.ts index a3fa8300..8ee29c56 100644 --- a/scripts/generateABIs.ts +++ b/scripts/generateABIs.ts @@ -6,11 +6,15 @@ import {ABI_INTERFACES, DOWNLOAD_ABI_INTERFACES} from './configs/abis'; const awaitableExec = util.promisify(exec); -export async function generateABIs() { +export async function generateABIs(removeExisting: boolean) { if (existsSync('./src/ts/abis')) { - rmSync('./src/ts/abis', {recursive: true}); + if (removeExisting) { + rmSync('./src/ts/abis', {recursive: true}); + mkdirSync('./src/ts/abis'); + } + } else { + mkdirSync('./src/ts/abis'); } - mkdirSync('./src/ts/abis'); for (const INTERFACE of ABI_INTERFACES) { const {stdout, stderr} = await awaitableExec(`forge inspect ${INTERFACE} abi`); if (stderr) { @@ -25,13 +29,18 @@ export async function generateABIs() { ); } for (const INTERFACE of DOWNLOAD_ABI_INTERFACES) { + const fileName = `./src/ts/abis/${INTERFACE.name}.ts`; + if (existsSync(fileName)) { + console.log(`skipping download of abi ${INTERFACE.name} as it already exists`); + continue; + } const {stdout, stderr} = await awaitableExec(`cast interface -j ${INTERFACE.address}`); if (stderr) { throw new Error(`Failed to generate abi for ${INTERFACE.name} from ${INTERFACE.address}`); } const varName = `${INTERFACE.name}_ABI`; writeFileSync( - `./src/ts/abis/${INTERFACE.name}.ts`, + fileName, prefixWithGeneratedWarning( `export const ${varName} = ${JSON.stringify(JSON.parse(stdout.trim()), null, 2)} as const;`, ), diff --git a/src/ts/abis/IUiPoolDataProviderV2.ts b/src/ts/abis/IUiPoolDataProviderV2.ts new file mode 100644 index 00000000..cb873732 --- /dev/null +++ b/src/ts/abis/IUiPoolDataProviderV2.ts @@ -0,0 +1,573 @@ +// AUTOGENERATED - MANUALLY CHANGES WILL BE REVERTED BY THE GENERATOR +export const IUiPoolDataProviderV2_ABI = [ + { + inputs: [ + { + internalType: 'contract IChainlinkAggregator', + name: '_networkBaseTokenPriceInUsdProxyAggregator', + type: 'address', + components: [], + }, + { + internalType: 'contract IChainlinkAggregator', + name: '_marketReferenceCurrencyPriceInUsdProxyAggregator', + type: 'address', + components: [], + }, + ], + stateMutability: 'nonpayable', + type: 'constructor', + outputs: [], + }, + { + inputs: [], + stateMutability: 'view', + type: 'function', + name: 'ETH_CURRENCY_UNIT', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + components: [], + }, + ], + }, + { + inputs: [], + stateMutability: 'view', + type: 'function', + name: 'MKRAddress', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + components: [], + }, + ], + }, + { + inputs: [ + { + internalType: 'bytes32', + name: '_bytes32', + type: 'bytes32', + components: [], + }, + ], + stateMutability: 'pure', + type: 'function', + name: 'bytes32ToString', + outputs: [ + { + internalType: 'string', + name: '', + type: 'string', + components: [], + }, + ], + }, + { + inputs: [ + { + internalType: 'contract ILendingPoolAddressesProvider', + name: 'provider', + type: 'address', + components: [], + }, + ], + stateMutability: 'view', + type: 'function', + name: 'getReservesData', + outputs: [ + { + internalType: 'struct IUiPoolDataProviderV3.AggregatedReserveData[]', + name: '', + type: 'tuple[]', + components: [ + { + internalType: 'address', + name: 'underlyingAsset', + type: 'address', + components: [], + }, + { + internalType: 'string', + name: 'name', + type: 'string', + components: [], + }, + { + internalType: 'string', + name: 'symbol', + type: 'string', + components: [], + }, + { + internalType: 'uint256', + name: 'decimals', + type: 'uint256', + components: [], + }, + { + internalType: 'uint256', + name: 'baseLTVasCollateral', + type: 'uint256', + components: [], + }, + { + internalType: 'uint256', + name: 'reserveLiquidationThreshold', + type: 'uint256', + components: [], + }, + { + internalType: 'uint256', + name: 'reserveLiquidationBonus', + type: 'uint256', + components: [], + }, + { + internalType: 'uint256', + name: 'reserveFactor', + type: 'uint256', + components: [], + }, + { + internalType: 'bool', + name: 'usageAsCollateralEnabled', + type: 'bool', + components: [], + }, + { + internalType: 'bool', + name: 'borrowingEnabled', + type: 'bool', + components: [], + }, + { + internalType: 'bool', + name: 'stableBorrowRateEnabled', + type: 'bool', + components: [], + }, + { + internalType: 'bool', + name: 'isActive', + type: 'bool', + components: [], + }, + { + internalType: 'bool', + name: 'isFrozen', + type: 'bool', + components: [], + }, + { + internalType: 'uint128', + name: 'liquidityIndex', + type: 'uint128', + components: [], + }, + { + internalType: 'uint128', + name: 'variableBorrowIndex', + type: 'uint128', + components: [], + }, + { + internalType: 'uint128', + name: 'liquidityRate', + type: 'uint128', + components: [], + }, + { + internalType: 'uint128', + name: 'variableBorrowRate', + type: 'uint128', + components: [], + }, + { + internalType: 'uint128', + name: 'stableBorrowRate', + type: 'uint128', + components: [], + }, + { + internalType: 'uint40', + name: 'lastUpdateTimestamp', + type: 'uint40', + components: [], + }, + { + internalType: 'address', + name: 'aTokenAddress', + type: 'address', + components: [], + }, + { + internalType: 'address', + name: 'stableDebtTokenAddress', + type: 'address', + components: [], + }, + { + internalType: 'address', + name: 'variableDebtTokenAddress', + type: 'address', + components: [], + }, + { + internalType: 'address', + name: 'interestRateStrategyAddress', + type: 'address', + components: [], + }, + { + internalType: 'uint256', + name: 'availableLiquidity', + type: 'uint256', + components: [], + }, + { + internalType: 'uint256', + name: 'totalPrincipalStableDebt', + type: 'uint256', + components: [], + }, + { + internalType: 'uint256', + name: 'averageStableRate', + type: 'uint256', + components: [], + }, + { + internalType: 'uint256', + name: 'stableDebtLastUpdateTimestamp', + type: 'uint256', + components: [], + }, + { + internalType: 'uint256', + name: 'totalScaledVariableDebt', + type: 'uint256', + components: [], + }, + { + internalType: 'uint256', + name: 'priceInMarketReferenceCurrency', + type: 'uint256', + components: [], + }, + { + internalType: 'address', + name: 'priceOracle', + type: 'address', + components: [], + }, + { + internalType: 'uint256', + name: 'variableRateSlope1', + type: 'uint256', + components: [], + }, + { + internalType: 'uint256', + name: 'variableRateSlope2', + type: 'uint256', + components: [], + }, + { + internalType: 'uint256', + name: 'stableRateSlope1', + type: 'uint256', + components: [], + }, + { + internalType: 'uint256', + name: 'stableRateSlope2', + type: 'uint256', + components: [], + }, + { + internalType: 'uint256', + name: 'baseStableBorrowRate', + type: 'uint256', + components: [], + }, + { + internalType: 'uint256', + name: 'baseVariableBorrowRate', + type: 'uint256', + components: [], + }, + { + internalType: 'uint256', + name: 'optimalUsageRatio', + type: 'uint256', + components: [], + }, + { + internalType: 'bool', + name: 'isPaused', + type: 'bool', + components: [], + }, + { + internalType: 'bool', + name: 'isSiloedBorrowing', + type: 'bool', + components: [], + }, + { + internalType: 'uint128', + name: 'accruedToTreasury', + type: 'uint128', + components: [], + }, + { + internalType: 'uint128', + name: 'unbacked', + type: 'uint128', + components: [], + }, + { + internalType: 'uint128', + name: 'isolationModeTotalDebt', + type: 'uint128', + components: [], + }, + { + internalType: 'bool', + name: 'flashLoanEnabled', + type: 'bool', + components: [], + }, + { + internalType: 'uint256', + name: 'debtCeiling', + type: 'uint256', + components: [], + }, + { + internalType: 'uint256', + name: 'debtCeilingDecimals', + type: 'uint256', + components: [], + }, + { + internalType: 'uint8', + name: 'eModeCategoryId', + type: 'uint8', + components: [], + }, + { + internalType: 'uint256', + name: 'borrowCap', + type: 'uint256', + components: [], + }, + { + internalType: 'uint256', + name: 'supplyCap', + type: 'uint256', + components: [], + }, + { + internalType: 'uint16', + name: 'eModeLtv', + type: 'uint16', + components: [], + }, + { + internalType: 'uint16', + name: 'eModeLiquidationThreshold', + type: 'uint16', + components: [], + }, + { + internalType: 'uint16', + name: 'eModeLiquidationBonus', + type: 'uint16', + components: [], + }, + { + internalType: 'address', + name: 'eModePriceSource', + type: 'address', + components: [], + }, + { + internalType: 'string', + name: 'eModeLabel', + type: 'string', + components: [], + }, + { + internalType: 'bool', + name: 'borrowableInIsolation', + type: 'bool', + components: [], + }, + ], + }, + { + internalType: 'struct IUiPoolDataProviderV3.BaseCurrencyInfo', + name: '', + type: 'tuple', + components: [ + { + internalType: 'uint256', + name: 'marketReferenceCurrencyUnit', + type: 'uint256', + components: [], + }, + { + internalType: 'int256', + name: 'marketReferenceCurrencyPriceInUsd', + type: 'int256', + components: [], + }, + { + internalType: 'int256', + name: 'networkBaseTokenPriceInUsd', + type: 'int256', + components: [], + }, + { + internalType: 'uint8', + name: 'networkBaseTokenPriceDecimals', + type: 'uint8', + components: [], + }, + ], + }, + ], + }, + { + inputs: [ + { + internalType: 'contract ILendingPoolAddressesProvider', + name: 'provider', + type: 'address', + components: [], + }, + ], + stateMutability: 'view', + type: 'function', + name: 'getReservesList', + outputs: [ + { + internalType: 'address[]', + name: '', + type: 'address[]', + components: [], + }, + ], + }, + { + inputs: [ + { + internalType: 'contract ILendingPoolAddressesProvider', + name: 'provider', + type: 'address', + components: [], + }, + { + internalType: 'address', + name: 'user', + type: 'address', + components: [], + }, + ], + stateMutability: 'view', + type: 'function', + name: 'getUserReservesData', + outputs: [ + { + internalType: 'struct IUiPoolDataProviderV3.UserReserveData[]', + name: '', + type: 'tuple[]', + components: [ + { + internalType: 'address', + name: 'underlyingAsset', + type: 'address', + components: [], + }, + { + internalType: 'uint256', + name: 'scaledATokenBalance', + type: 'uint256', + components: [], + }, + { + internalType: 'bool', + name: 'usageAsCollateralEnabledOnUser', + type: 'bool', + components: [], + }, + { + internalType: 'uint256', + name: 'stableBorrowRate', + type: 'uint256', + components: [], + }, + { + internalType: 'uint256', + name: 'scaledVariableDebt', + type: 'uint256', + components: [], + }, + { + internalType: 'uint256', + name: 'principalStableDebt', + type: 'uint256', + components: [], + }, + { + internalType: 'uint256', + name: 'stableBorrowLastUpdateTimestamp', + type: 'uint256', + components: [], + }, + ], + }, + { + internalType: 'uint8', + name: '', + type: 'uint8', + components: [], + }, + ], + }, + { + inputs: [], + stateMutability: 'view', + type: 'function', + name: 'marketReferenceCurrencyPriceInUsdProxyAggregator', + outputs: [ + { + internalType: 'contract IChainlinkAggregator', + name: '', + type: 'address', + components: [], + }, + ], + }, + { + inputs: [], + stateMutability: 'view', + type: 'function', + name: 'networkBaseTokenPriceInUsdProxyAggregator', + outputs: [ + { + internalType: 'contract IChainlinkAggregator', + name: '', + type: 'address', + components: [], + }, + ], + }, +] as const; diff --git a/src/ts/abis/IUiPoolDataProviderV3.ts b/src/ts/abis/IUiPoolDataProviderV3.ts new file mode 100644 index 00000000..96a4800d --- /dev/null +++ b/src/ts/abis/IUiPoolDataProviderV3.ts @@ -0,0 +1,573 @@ +// AUTOGENERATED - MANUALLY CHANGES WILL BE REVERTED BY THE GENERATOR +export const IUiPoolDataProviderV3_ABI = [ + { + inputs: [ + { + internalType: 'contract IEACAggregatorProxy', + name: '_networkBaseTokenPriceInUsdProxyAggregator', + type: 'address', + components: [], + }, + { + internalType: 'contract IEACAggregatorProxy', + name: '_marketReferenceCurrencyPriceInUsdProxyAggregator', + type: 'address', + components: [], + }, + ], + stateMutability: 'nonpayable', + type: 'constructor', + outputs: [], + }, + { + inputs: [], + stateMutability: 'view', + type: 'function', + name: 'ETH_CURRENCY_UNIT', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + components: [], + }, + ], + }, + { + inputs: [], + stateMutability: 'view', + type: 'function', + name: 'MKR_ADDRESS', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + components: [], + }, + ], + }, + { + inputs: [ + { + internalType: 'bytes32', + name: '_bytes32', + type: 'bytes32', + components: [], + }, + ], + stateMutability: 'pure', + type: 'function', + name: 'bytes32ToString', + outputs: [ + { + internalType: 'string', + name: '', + type: 'string', + components: [], + }, + ], + }, + { + inputs: [ + { + internalType: 'contract IPoolAddressesProvider', + name: 'provider', + type: 'address', + components: [], + }, + ], + stateMutability: 'view', + type: 'function', + name: 'getReservesData', + outputs: [ + { + internalType: 'struct IUiPoolDataProviderV3.AggregatedReserveData[]', + name: '', + type: 'tuple[]', + components: [ + { + internalType: 'address', + name: 'underlyingAsset', + type: 'address', + components: [], + }, + { + internalType: 'string', + name: 'name', + type: 'string', + components: [], + }, + { + internalType: 'string', + name: 'symbol', + type: 'string', + components: [], + }, + { + internalType: 'uint256', + name: 'decimals', + type: 'uint256', + components: [], + }, + { + internalType: 'uint256', + name: 'baseLTVasCollateral', + type: 'uint256', + components: [], + }, + { + internalType: 'uint256', + name: 'reserveLiquidationThreshold', + type: 'uint256', + components: [], + }, + { + internalType: 'uint256', + name: 'reserveLiquidationBonus', + type: 'uint256', + components: [], + }, + { + internalType: 'uint256', + name: 'reserveFactor', + type: 'uint256', + components: [], + }, + { + internalType: 'bool', + name: 'usageAsCollateralEnabled', + type: 'bool', + components: [], + }, + { + internalType: 'bool', + name: 'borrowingEnabled', + type: 'bool', + components: [], + }, + { + internalType: 'bool', + name: 'stableBorrowRateEnabled', + type: 'bool', + components: [], + }, + { + internalType: 'bool', + name: 'isActive', + type: 'bool', + components: [], + }, + { + internalType: 'bool', + name: 'isFrozen', + type: 'bool', + components: [], + }, + { + internalType: 'uint128', + name: 'liquidityIndex', + type: 'uint128', + components: [], + }, + { + internalType: 'uint128', + name: 'variableBorrowIndex', + type: 'uint128', + components: [], + }, + { + internalType: 'uint128', + name: 'liquidityRate', + type: 'uint128', + components: [], + }, + { + internalType: 'uint128', + name: 'variableBorrowRate', + type: 'uint128', + components: [], + }, + { + internalType: 'uint128', + name: 'stableBorrowRate', + type: 'uint128', + components: [], + }, + { + internalType: 'uint40', + name: 'lastUpdateTimestamp', + type: 'uint40', + components: [], + }, + { + internalType: 'address', + name: 'aTokenAddress', + type: 'address', + components: [], + }, + { + internalType: 'address', + name: 'stableDebtTokenAddress', + type: 'address', + components: [], + }, + { + internalType: 'address', + name: 'variableDebtTokenAddress', + type: 'address', + components: [], + }, + { + internalType: 'address', + name: 'interestRateStrategyAddress', + type: 'address', + components: [], + }, + { + internalType: 'uint256', + name: 'availableLiquidity', + type: 'uint256', + components: [], + }, + { + internalType: 'uint256', + name: 'totalPrincipalStableDebt', + type: 'uint256', + components: [], + }, + { + internalType: 'uint256', + name: 'averageStableRate', + type: 'uint256', + components: [], + }, + { + internalType: 'uint256', + name: 'stableDebtLastUpdateTimestamp', + type: 'uint256', + components: [], + }, + { + internalType: 'uint256', + name: 'totalScaledVariableDebt', + type: 'uint256', + components: [], + }, + { + internalType: 'uint256', + name: 'priceInMarketReferenceCurrency', + type: 'uint256', + components: [], + }, + { + internalType: 'address', + name: 'priceOracle', + type: 'address', + components: [], + }, + { + internalType: 'uint256', + name: 'variableRateSlope1', + type: 'uint256', + components: [], + }, + { + internalType: 'uint256', + name: 'variableRateSlope2', + type: 'uint256', + components: [], + }, + { + internalType: 'uint256', + name: 'stableRateSlope1', + type: 'uint256', + components: [], + }, + { + internalType: 'uint256', + name: 'stableRateSlope2', + type: 'uint256', + components: [], + }, + { + internalType: 'uint256', + name: 'baseStableBorrowRate', + type: 'uint256', + components: [], + }, + { + internalType: 'uint256', + name: 'baseVariableBorrowRate', + type: 'uint256', + components: [], + }, + { + internalType: 'uint256', + name: 'optimalUsageRatio', + type: 'uint256', + components: [], + }, + { + internalType: 'bool', + name: 'isPaused', + type: 'bool', + components: [], + }, + { + internalType: 'bool', + name: 'isSiloedBorrowing', + type: 'bool', + components: [], + }, + { + internalType: 'uint128', + name: 'accruedToTreasury', + type: 'uint128', + components: [], + }, + { + internalType: 'uint128', + name: 'unbacked', + type: 'uint128', + components: [], + }, + { + internalType: 'uint128', + name: 'isolationModeTotalDebt', + type: 'uint128', + components: [], + }, + { + internalType: 'bool', + name: 'flashLoanEnabled', + type: 'bool', + components: [], + }, + { + internalType: 'uint256', + name: 'debtCeiling', + type: 'uint256', + components: [], + }, + { + internalType: 'uint256', + name: 'debtCeilingDecimals', + type: 'uint256', + components: [], + }, + { + internalType: 'uint8', + name: 'eModeCategoryId', + type: 'uint8', + components: [], + }, + { + internalType: 'uint256', + name: 'borrowCap', + type: 'uint256', + components: [], + }, + { + internalType: 'uint256', + name: 'supplyCap', + type: 'uint256', + components: [], + }, + { + internalType: 'uint16', + name: 'eModeLtv', + type: 'uint16', + components: [], + }, + { + internalType: 'uint16', + name: 'eModeLiquidationThreshold', + type: 'uint16', + components: [], + }, + { + internalType: 'uint16', + name: 'eModeLiquidationBonus', + type: 'uint16', + components: [], + }, + { + internalType: 'address', + name: 'eModePriceSource', + type: 'address', + components: [], + }, + { + internalType: 'string', + name: 'eModeLabel', + type: 'string', + components: [], + }, + { + internalType: 'bool', + name: 'borrowableInIsolation', + type: 'bool', + components: [], + }, + ], + }, + { + internalType: 'struct IUiPoolDataProviderV3.BaseCurrencyInfo', + name: '', + type: 'tuple', + components: [ + { + internalType: 'uint256', + name: 'marketReferenceCurrencyUnit', + type: 'uint256', + components: [], + }, + { + internalType: 'int256', + name: 'marketReferenceCurrencyPriceInUsd', + type: 'int256', + components: [], + }, + { + internalType: 'int256', + name: 'networkBaseTokenPriceInUsd', + type: 'int256', + components: [], + }, + { + internalType: 'uint8', + name: 'networkBaseTokenPriceDecimals', + type: 'uint8', + components: [], + }, + ], + }, + ], + }, + { + inputs: [ + { + internalType: 'contract IPoolAddressesProvider', + name: 'provider', + type: 'address', + components: [], + }, + ], + stateMutability: 'view', + type: 'function', + name: 'getReservesList', + outputs: [ + { + internalType: 'address[]', + name: '', + type: 'address[]', + components: [], + }, + ], + }, + { + inputs: [ + { + internalType: 'contract IPoolAddressesProvider', + name: 'provider', + type: 'address', + components: [], + }, + { + internalType: 'address', + name: 'user', + type: 'address', + components: [], + }, + ], + stateMutability: 'view', + type: 'function', + name: 'getUserReservesData', + outputs: [ + { + internalType: 'struct IUiPoolDataProviderV3.UserReserveData[]', + name: '', + type: 'tuple[]', + components: [ + { + internalType: 'address', + name: 'underlyingAsset', + type: 'address', + components: [], + }, + { + internalType: 'uint256', + name: 'scaledATokenBalance', + type: 'uint256', + components: [], + }, + { + internalType: 'bool', + name: 'usageAsCollateralEnabledOnUser', + type: 'bool', + components: [], + }, + { + internalType: 'uint256', + name: 'stableBorrowRate', + type: 'uint256', + components: [], + }, + { + internalType: 'uint256', + name: 'scaledVariableDebt', + type: 'uint256', + components: [], + }, + { + internalType: 'uint256', + name: 'principalStableDebt', + type: 'uint256', + components: [], + }, + { + internalType: 'uint256', + name: 'stableBorrowLastUpdateTimestamp', + type: 'uint256', + components: [], + }, + ], + }, + { + internalType: 'uint8', + name: '', + type: 'uint8', + components: [], + }, + ], + }, + { + inputs: [], + stateMutability: 'view', + type: 'function', + name: 'marketReferenceCurrencyPriceInUsdProxyAggregator', + outputs: [ + { + internalType: 'contract IEACAggregatorProxy', + name: '', + type: 'address', + components: [], + }, + ], + }, + { + inputs: [], + stateMutability: 'view', + type: 'function', + name: 'networkBaseTokenPriceInUsdProxyAggregator', + outputs: [ + { + internalType: 'contract IEACAggregatorProxy', + name: '', + type: 'address', + components: [], + }, + ], + }, +] as const; From b0be4323b36c080b3d87cbe9fc66e6ad9aa927dd Mon Sep 17 00:00:00 2001 From: sakulstra Date: Thu, 2 Nov 2023 11:53:13 +0100 Subject: [PATCH 2/2] fix: don't fetch power strategy --- scripts/abi/uipooldata_provider.ts | 410 ------------- scripts/configs/abis.ts | 6 +- scripts/configs/governance/ethereum.ts | 2 + scripts/configs/types.ts | 1 + scripts/generator/governanceV3Generator.ts | 9 +- scripts/generator/protocolV2Generator.ts | 4 +- scripts/generator/protocolV3Generator.ts | 4 +- src/AaveV2Avalanche.sol | 4 +- src/AaveV2Ethereum.sol | 4 +- src/AaveV2EthereumAMM.sol | 4 +- src/AaveV2Polygon.sol | 4 +- src/AaveV3Arbitrum.sol | 4 +- src/AaveV3Avalanche.sol | 4 +- src/AaveV3Base.sol | 4 +- src/AaveV3Ethereum.sol | 4 +- src/AaveV3Metis.sol | 4 +- src/AaveV3Optimism.sol | 4 +- src/AaveV3Polygon.sol | 4 +- src/ts/AaveAddressBook.ts | 1 + src/ts/AaveV2Avalanche.ts | 4 +- src/ts/AaveV2Ethereum.ts | 4 +- src/ts/AaveV2EthereumAMM.ts | 4 +- src/ts/AaveV2Polygon.ts | 4 +- src/ts/AaveV3Arbitrum.ts | 4 +- src/ts/AaveV3Avalanche.ts | 4 +- src/ts/AaveV3Base.ts | 4 +- src/ts/AaveV3Ethereum.ts | 4 +- src/ts/AaveV3Metis.ts | 4 +- src/ts/AaveV3Optimism.ts | 4 +- src/ts/AaveV3Polygon.ts | 4 +- ...taProviderV3.ts => IUiPoolDataProvider.ts} | 2 +- src/ts/abis/IUiPoolDataProviderV2.ts | 573 ------------------ 32 files changed, 59 insertions(+), 1041 deletions(-) delete mode 100644 scripts/abi/uipooldata_provider.ts rename src/ts/abis/{IUiPoolDataProviderV3.ts => IUiPoolDataProvider.ts} (99%) delete mode 100644 src/ts/abis/IUiPoolDataProviderV2.ts diff --git a/scripts/abi/uipooldata_provider.ts b/scripts/abi/uipooldata_provider.ts deleted file mode 100644 index 8fe05a0b..00000000 --- a/scripts/abi/uipooldata_provider.ts +++ /dev/null @@ -1,410 +0,0 @@ -export const UI_POOL_DATA_PROVIDER_ABI = [ - { - inputs: [ - { - internalType: 'contract IEACAggregatorProxy', - name: '_networkBaseTokenPriceInUsdProxyAggregator', - type: 'address', - }, - { - internalType: 'contract IEACAggregatorProxy', - name: '_marketReferenceCurrencyPriceInUsdProxyAggregator', - type: 'address', - }, - ], - stateMutability: 'nonpayable', - type: 'constructor', - }, - { - inputs: [], - name: 'ETH_CURRENCY_UNIT', - outputs: [{internalType: 'uint256', name: '', type: 'uint256'}], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'MKR_ADDRESS', - outputs: [{internalType: 'address', name: '', type: 'address'}], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [{internalType: 'bytes32', name: '_bytes32', type: 'bytes32'}], - name: 'bytes32ToString', - outputs: [{internalType: 'string', name: '', type: 'string'}], - stateMutability: 'pure', - type: 'function', - }, - { - inputs: [ - { - internalType: 'contract IPoolAddressesProvider', - name: 'provider', - type: 'address', - }, - ], - name: 'getReservesData', - outputs: [ - { - components: [ - { - internalType: 'address', - name: 'underlyingAsset', - type: 'address', - }, - {internalType: 'string', name: 'name', type: 'string'}, - {internalType: 'string', name: 'symbol', type: 'string'}, - {internalType: 'uint256', name: 'decimals', type: 'uint256'}, - { - internalType: 'uint256', - name: 'baseLTVasCollateral', - type: 'uint256', - }, - { - internalType: 'uint256', - name: 'reserveLiquidationThreshold', - type: 'uint256', - }, - { - internalType: 'uint256', - name: 'reserveLiquidationBonus', - 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'}, - { - internalType: 'uint128', - name: 'liquidityIndex', - type: 'uint128', - }, - { - internalType: 'uint128', - name: 'variableBorrowIndex', - type: 'uint128', - }, - { - internalType: 'uint128', - name: 'liquidityRate', - type: 'uint128', - }, - { - internalType: 'uint128', - name: 'variableBorrowRate', - type: 'uint128', - }, - { - internalType: 'uint128', - name: 'stableBorrowRate', - 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: 'uint256', - name: 'availableLiquidity', - type: 'uint256', - }, - { - internalType: 'uint256', - name: 'totalPrincipalStableDebt', - type: 'uint256', - }, - { - internalType: 'uint256', - name: 'averageStableRate', - type: 'uint256', - }, - { - internalType: 'uint256', - name: 'stableDebtLastUpdateTimestamp', - type: 'uint256', - }, - { - internalType: 'uint256', - name: 'totalScaledVariableDebt', - type: 'uint256', - }, - { - internalType: 'uint256', - name: 'priceInMarketReferenceCurrency', - type: 'uint256', - }, - { - internalType: 'address', - name: 'priceOracle', - type: 'address', - }, - { - internalType: 'uint256', - name: 'variableRateSlope1', - type: 'uint256', - }, - { - internalType: 'uint256', - name: 'variableRateSlope2', - type: 'uint256', - }, - { - internalType: 'uint256', - name: 'stableRateSlope1', - type: 'uint256', - }, - { - internalType: 'uint256', - name: 'stableRateSlope2', - type: 'uint256', - }, - { - internalType: 'uint256', - name: 'baseStableBorrowRate', - type: 'uint256', - }, - { - internalType: 'uint256', - name: 'baseVariableBorrowRate', - type: 'uint256', - }, - { - internalType: 'uint256', - name: 'optimalUsageRatio', - type: 'uint256', - }, - {internalType: 'bool', name: 'isPaused', type: 'bool'}, - { - internalType: 'bool', - name: 'isSiloedBorrowing', - type: 'bool', - }, - { - internalType: 'uint128', - name: 'accruedToTreasury', - type: 'uint128', - }, - {internalType: 'uint128', name: 'unbacked', type: 'uint128'}, - { - internalType: 'uint128', - name: 'isolationModeTotalDebt', - type: 'uint128', - }, - { - internalType: 'bool', - name: 'flashLoanEnabled', - type: 'bool', - }, - { - internalType: 'uint256', - name: 'debtCeiling', - type: 'uint256', - }, - { - internalType: 'uint256', - name: 'debtCeilingDecimals', - type: 'uint256', - }, - { - internalType: 'uint8', - name: 'eModeCategoryId', - type: 'uint8', - }, - {internalType: 'uint256', name: 'borrowCap', type: 'uint256'}, - {internalType: 'uint256', name: 'supplyCap', type: 'uint256'}, - {internalType: 'uint16', name: 'eModeLtv', type: 'uint16'}, - { - internalType: 'uint16', - name: 'eModeLiquidationThreshold', - type: 'uint16', - }, - { - internalType: 'uint16', - name: 'eModeLiquidationBonus', - type: 'uint16', - }, - { - internalType: 'address', - name: 'eModePriceSource', - type: 'address', - }, - {internalType: 'string', name: 'eModeLabel', type: 'string'}, - { - internalType: 'bool', - name: 'borrowableInIsolation', - type: 'bool', - }, - ], - internalType: 'struct IUiPoolDataProviderV3.AggregatedReserveData[]', - name: '', - type: 'tuple[]', - }, - { - components: [ - { - internalType: 'uint256', - name: 'marketReferenceCurrencyUnit', - type: 'uint256', - }, - { - internalType: 'int256', - name: 'marketReferenceCurrencyPriceInUsd', - type: 'int256', - }, - { - internalType: 'int256', - name: 'networkBaseTokenPriceInUsd', - type: 'int256', - }, - { - internalType: 'uint8', - name: 'networkBaseTokenPriceDecimals', - type: 'uint8', - }, - ], - internalType: 'struct IUiPoolDataProviderV3.BaseCurrencyInfo', - name: '', - type: 'tuple', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'contract IPoolAddressesProvider', - name: 'provider', - type: 'address', - }, - ], - name: 'getReservesList', - outputs: [{internalType: 'address[]', name: '', type: 'address[]'}], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'contract IPoolAddressesProvider', - name: 'provider', - type: 'address', - }, - {internalType: 'address', name: 'user', type: 'address'}, - ], - name: 'getUserReservesData', - outputs: [ - { - components: [ - { - internalType: 'address', - name: 'underlyingAsset', - type: 'address', - }, - { - internalType: 'uint256', - name: 'scaledATokenBalance', - type: 'uint256', - }, - { - internalType: 'bool', - name: 'usageAsCollateralEnabledOnUser', - type: 'bool', - }, - { - internalType: 'uint256', - name: 'stableBorrowRate', - type: 'uint256', - }, - { - internalType: 'uint256', - name: 'scaledVariableDebt', - type: 'uint256', - }, - { - internalType: 'uint256', - name: 'principalStableDebt', - type: 'uint256', - }, - { - internalType: 'uint256', - name: 'stableBorrowLastUpdateTimestamp', - type: 'uint256', - }, - ], - internalType: 'struct IUiPoolDataProviderV3.UserReserveData[]', - name: '', - type: 'tuple[]', - }, - {internalType: 'uint8', name: '', type: 'uint8'}, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'marketReferenceCurrencyPriceInUsdProxyAggregator', - outputs: [ - { - internalType: 'contract IEACAggregatorProxy', - name: '', - type: 'address', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'networkBaseTokenPriceInUsdProxyAggregator', - outputs: [ - { - internalType: 'contract IEACAggregatorProxy', - name: '', - type: 'address', - }, - ], - stateMutability: 'view', - type: 'function', - }, -] as const; diff --git a/scripts/configs/abis.ts b/scripts/configs/abis.ts index 6fb5bc0c..310bdfd6 100644 --- a/scripts/configs/abis.ts +++ b/scripts/configs/abis.ts @@ -43,10 +43,6 @@ export const DOWNLOAD_ABI_INTERFACES = [ }, { address: mainnetProtoV3Pool.additionalAddresses.UI_POOL_DATA_PROVIDER, - name: 'IUiPoolDataProviderV3', - }, - { - address: mainnetProtoV2Pool.additionalAddresses.UI_POOL_DATA_PROVIDER, - name: 'IUiPoolDataProviderV2', + name: 'IUiPoolDataProvider', }, ]; diff --git a/scripts/configs/governance/ethereum.ts b/scripts/configs/governance/ethereum.ts index 1586b947..71c18ede 100644 --- a/scripts/configs/governance/ethereum.ts +++ b/scripts/configs/governance/ethereum.ts @@ -28,6 +28,7 @@ export const governanceConfigGoerli: GovernanceConfig = { PC_DATA_HELPER: '0xbd2db358f3C82F2883132A6584e22F38A979e768', META_DELEGATE_HELPER: '0x1966133c190475E8385Dc1b4150B5f81c70DC578', GOV_DATA_HELPER: '0x160e2d1456B815d6a3d281218538dd6E2e3C841f', + GOVERNANCE_POWER_STRATEGY: '0x1ba21Fb1bDF4234CAe0AD1e02cF6750d7938E358', }, }; @@ -47,5 +48,6 @@ export const governanceConfigMainnet: GovernanceConfig = { VM_DATA_HELPER: '0x77976B51569896523EE215962Ee91ff236Fa50E8', META_DELEGATE_HELPER: '0x94363B11b37BC3ffe43AB09cff5A010352FE85dC', EMERGENCY_REGISTRY: '0x73C6Fb358dDA8e84D50e98A98F7c0dF32e15C7e9', + GOVERNANCE_POWER_STRATEGY: '0xa198Fac58E02A5C5F8F7e877895d50cFa9ad1E04', }, }; diff --git a/scripts/configs/types.ts b/scripts/configs/types.ts index 5697099a..749f3520 100644 --- a/scripts/configs/types.ts +++ b/scripts/configs/types.ts @@ -25,6 +25,7 @@ export type GovernanceV3Addresses = { PC_DATA_HELPER?: Hex; META_DELEGATE_HELPER?: Hex; EMERGENCY_REGISTRY?: Hex; + GOVERNANCE_POWER_STRATEGY?: Hex; }; export interface GovernanceConfig { diff --git a/scripts/generator/governanceV3Generator.ts b/scripts/generator/governanceV3Generator.ts index 923ce598..bae1ca20 100644 --- a/scripts/generator/governanceV3Generator.ts +++ b/scripts/generator/governanceV3Generator.ts @@ -74,10 +74,11 @@ function getGovernancePowerStrategy(governance: Address, publicClient: PublicCli async function getGovernanceV3Addresses({CHAIN_ID, ADDRESSES}: GovernanceConfig) { let addresses: Addresses = {...ADDRESSES}; if (ADDRESSES.GOVERNANCE) { - addresses.GOVERNANCE_POWER_STRATEGY = await getGovernancePowerStrategy( - ADDRESSES.GOVERNANCE, - RPC_PROVIDERS[CHAIN_ID], - ); + // TODO: comment back in when governance v3 is live + // addresses.GOVERNANCE_POWER_STRATEGY = await getGovernancePowerStrategy( + // ADDRESSES.GOVERNANCE, + // RPC_PROVIDERS[CHAIN_ID], + // ); addresses.GOVERNANCE = {value: addresses.GOVERNANCE, type: 'IGovernanceCore'}; } diff --git a/scripts/generator/protocolV2Generator.ts b/scripts/generator/protocolV2Generator.ts index 9864a047..3ef51875 100644 --- a/scripts/generator/protocolV2Generator.ts +++ b/scripts/generator/protocolV2Generator.ts @@ -1,6 +1,5 @@ import {Hex, PublicClient, getContract} from 'viem'; import {AddressInfo, PoolConfig, ReserveData} from '../configs/types'; -import {UI_POOL_DATA_PROVIDER_ABI} from '../abi/uipooldata_provider'; import {RPC_PROVIDERS} from './clients'; import {appendFileSync, writeFileSync} from 'fs'; import { @@ -15,6 +14,7 @@ import {LENDING_POOL_V2_ABI} from '../abi/lending_pool_v2_abi'; import {A_TOKEN_V2_ABI} from '../abi/aToken_v2_abi'; import {INCENTIVES_CONTROLLER_ABI} from '../abi/incentivesController_abi'; import {generateAssetsLibrary} from './assetsLibraryGenerator'; +import {IUiPoolDataProvider_ABI} from '../../src/ts/abis/IUiPoolDataProvider'; export interface PoolV2Addresses { POOL_ADDRESSES_PROVIDER: AddressInfo; @@ -106,7 +106,7 @@ export async function getPoolV2Addresses(pool: PoolConfig): Promise