From b3b28d4360f7484ab522bc242d19d7d61b4729f9 Mon Sep 17 00:00:00 2001 From: "@layinka" Date: Thu, 10 Feb 2022 20:59:00 +0100 Subject: [PATCH 01/38] implemented AAVE savings protocol for AAVE coin --- .../plugins/Savings/protocols/AAVEProtocol.ts | 311 +++++ .../src/plugins/Savings/protocols/index.ts | 3 +- packages/mask/src/plugins/Savings/types.ts | 3 +- packages/web3-constants/evm/savings.json | 65 +- .../web3-contracts/abis/AaveLendingPool.json | 1079 +++++++++++++++++ .../abis/AaveLendingPoolAddressProvider.json | 477 ++++++++ .../abis/AaveProtocolDataProvider.json | 298 +++++ .../abis/AaveStableDebtToken.json | 324 +++++ .../web3-contracts/types/AaveLendingPool.d.ts | 440 +++++++ .../types/AaveLendingPoolAddressProvider.d.ts | 309 +++++ .../types/AaveProtocolDataProvider.d.ts | 120 ++ .../types/AaveStableDebtToken.d.ts | 124 ++ 12 files changed, 3550 insertions(+), 3 deletions(-) create mode 100644 packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts create mode 100644 packages/web3-contracts/abis/AaveLendingPool.json create mode 100644 packages/web3-contracts/abis/AaveLendingPoolAddressProvider.json create mode 100644 packages/web3-contracts/abis/AaveProtocolDataProvider.json create mode 100644 packages/web3-contracts/abis/AaveStableDebtToken.json create mode 100644 packages/web3-contracts/types/AaveLendingPool.d.ts create mode 100644 packages/web3-contracts/types/AaveLendingPoolAddressProvider.d.ts create mode 100644 packages/web3-contracts/types/AaveProtocolDataProvider.d.ts create mode 100644 packages/web3-contracts/types/AaveStableDebtToken.d.ts diff --git a/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts b/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts new file mode 100644 index 000000000000..484a85000a42 --- /dev/null +++ b/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts @@ -0,0 +1,311 @@ +import type Web3 from 'web3' +import type { AbiItem } from 'web3-utils' +import { + EthereumTokenType, + ChainId, + getSavingsConstants, + createContract, + FungibleTokenDetailed, + ZERO_ADDRESS, +} from '@masknet/web3-shared-evm' +import type { AaveLendingPool } from '@masknet/web3-contracts/types/AaveLendingPool' +import type { AaveLendingPoolAddressProvider } from '@masknet/web3-contracts/types/AaveLendingPoolAddressProvider' + +import AaveLendingPoolAddressProviderABI from '@masknet/web3-contracts/abis/AaveLendingPoolAddressProvider.json' +import AaveLendingPoolABI from '@masknet/web3-contracts/abis/AaveLendingPool.json' +import BigNumber from 'bignumber.js' +import { ProtocolCategory, SavingsNetwork, SavingsProtocol, ProtocolType } from '../types' + +export interface AaveContract { + type: EthereumTokenType + chainName: string + subgraphUrl: string + aaveLendingPoolAddressProviderContract: string + aaveContract: string + stEthContract: string +} + +export const AaveContracts: { [key: number]: AaveContract } = { + [ChainId.Mainnet]: { + type: EthereumTokenType.ERC20, + chainName: 'Ethereum', + subgraphUrl: getSavingsConstants(ChainId.Mainnet).AAVE_SUBGRAPHS || '', + aaveLendingPoolAddressProviderContract: + getSavingsConstants(ChainId.Mainnet).AAVELendingPoolAddressProviderContract || ZERO_ADDRESS, + aaveContract: getSavingsConstants(ChainId.Mainnet).AAVE || ZERO_ADDRESS, + stEthContract: getSavingsConstants(ChainId.Mainnet).LIDO_STETH || ZERO_ADDRESS, + }, + [ChainId.Gorli]: { + type: EthereumTokenType.ERC20, + chainName: 'Kovan', + subgraphUrl: getSavingsConstants(ChainId.Kovan).AAVE_SUBGRAPHS || '', + aaveLendingPoolAddressProviderContract: + getSavingsConstants(ChainId.Kovan).AAVELendingPoolAddressProviderContract || ZERO_ADDRESS, + aaveContract: getSavingsConstants(ChainId.Kovan).AAVE || ZERO_ADDRESS, + stEthContract: getSavingsConstants(ChainId.Kovan).LIDO_STETH || ZERO_ADDRESS, + }, +} + +export class AAVEProtocol implements SavingsProtocol { + public category = ProtocolCategory.ETH + public type = ProtocolType.AAVE + public name = 'AAVE' + public image = 'aave' + public base = 'ETH' + public pair = 'aAAVE' + public decimals = 18 + public apr = '0.00' + public balance = new BigNumber('0') + public availableNetworks: SavingsNetwork[] = [ + { + chainId: ChainId.Mainnet, + chainName: 'Ethereum', + contractAddress: getSavingsConstants(ChainId.Mainnet).AAVE || ZERO_ADDRESS, + }, + { + chainId: ChainId.Kovan, + chainName: 'Kovan', + contractAddress: getSavingsConstants(ChainId.Kovan).AAVE || ZERO_ADDRESS, + }, + ] + + public getFungibleTokenDetails(chainId: ChainId): FungibleTokenDetailed { + let contractAddress = '' + + for (const network of this.availableNetworks) { + if (network.chainId === chainId) { + contractAddress = network.contractAddress + } + } + + return { + type: 1, + chainId: chainId, + address: contractAddress, + symbol: 'aAAVE', + decimals: 18, + name: 'AAVE Interest Bearing AAVE', + logoURI: [ + // 'https://static.debank.com/image/eth_token/logo_url/0xae7ab96520de3a18e5e111b5eaab095312d7fe84/f768023f77be7a2ea23c37f25b272048.png', + 'https://tokens.1inch.io/0xffc97d72e13e01096502cb8eb52dee56f74dad7b.png', + ], + } + } + + public async getApr(chainId?: ChainId) { + try { + const subgraphUrl = AaveContracts[chainId ?? ChainId.Kovan].subgraphUrl + const body = JSON.stringify({ + query: `{ + reserves (where: { + underlyingAsset: "${AaveContracts[chainId ?? ChainId.Kovan].aaveContract}" + }) { + id + name + underlyingAsset + price { + id + } + liquidityRate + } + }`, + }) + const response = await fetch(subgraphUrl, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: body, + }) + const fullResponse = await response.json() + const liquidityRate = +fullResponse.data.reserves[0].liquidityRate + + const RAY = 10 ** 27 // 10 to the power 27 + const SECONDS_PER_YEAR = 31536000 + // APY and APR are returned here as decimals, multiply by 100 to get the percents + const apr = liquidityRate / RAY + this.apr = apr.toFixed(2) + return apr.toFixed(2) + } catch (error) { + console.log('AAVE `getApr()` error', error) + // Default APR + this.apr = '0.17' + return '0.17' + } + } + + public async getBalance(chainId: ChainId, web3: Web3, account: string) { + try { + const subgraphUrl = AaveContracts[chainId ?? ChainId.Kovan].subgraphUrl + const reserveBody = JSON.stringify({ + query: `{ + reserves (where: { + underlyingAsset: "${AaveContracts[chainId ?? ChainId.Kovan].aaveContract}" + }) { + id + name + underlyingAsset + } + }`, + }) + + const reserveResponse = await fetch(subgraphUrl, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: reserveBody, + }) + const fullResponse = await reserveResponse.json() + const reserveId = fullResponse.data.reserves[0].id + + // Get User Reserve + const userReserveBody = JSON.stringify({ + query: `{ + userReserves(where: { + user: "${account}", + reserve: "${reserveId}" + + }) { + id + scaledATokenBalance + currentATokenBalance + reserve{ + id + symbol + underlyingAsset + decimals + } + user { + id + } + } + }`, + }) + + const userReserveResponse = await fetch(subgraphUrl, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: userReserveBody, + }) + const userResponse = await userReserveResponse.json() + + const balance = userResponse.data.userReserves[0].currentATokenBalance + this.balance = new BigNumber(balance || '0') + return this.balance + } catch (error) { + console.log('AAVE `getBalance()` error', error) + this.balance = new BigNumber('0') + return this.balance + } + } + + public async depositEstimate(account: string, chainId: ChainId, web3: Web3, value: BigNumber.Value) { + try { + const lPoolAdressProviderContract = createContract( + web3, + getSavingsConstants(chainId).AAVELendingPoolAddressProviderContract || ZERO_ADDRESS, + AaveLendingPoolAddressProviderABI as AbiItem[], + ) + + const poolAddress = await lPoolAdressProviderContract?.methods.getLendingPool().call() + + const contract = createContract( + web3, + poolAddress || ZERO_ADDRESS, + AaveLendingPoolABI as AbiItem[], + ) + const gasEstimate = await contract?.methods + .deposit(getSavingsConstants(chainId).AAVE || ZERO_ADDRESS, value.toString(), account, '0') + .estimateGas({ + from: account, + }) + + return new BigNumber(gasEstimate || 0) + } catch (error) { + console.error('AAVE `depositEstimate()` Error', error) + return new BigNumber(0) + } + } + + public async deposit(account: string, chainId: ChainId, web3: Web3, value: BigNumber.Value) { + try { + const lPoolAdressProviderContract = createContract( + web3, + getSavingsConstants(chainId).AAVELendingPoolAddressProviderContract || ZERO_ADDRESS, + AaveLendingPoolAddressProviderABI as AbiItem[], + ) + + const poolAddress = await lPoolAdressProviderContract?.methods.getLendingPool().call() + + const contract = createContract( + web3, + poolAddress || ZERO_ADDRESS, + AaveLendingPoolABI as AbiItem[], + ) + + await contract?.methods + .deposit(getSavingsConstants(chainId).AAVE || ZERO_ADDRESS, value.toString(), account, '0') + .send({ + from: account, + gas: 300000, + }) + return true + } catch (error) { + console.error('AAVE `deposit()` Error', error) + return false + } + } + + public async withdrawEstimate(account: string, chainId: ChainId, web3: Web3, value: BigNumber.Value) { + try { + const lPoolAdressProviderContract = createContract( + web3, + getSavingsConstants(chainId).AAVELendingPoolAddressProviderContract || ZERO_ADDRESS, + AaveLendingPoolAddressProviderABI as AbiItem[], + ) + + const poolAddress = await lPoolAdressProviderContract?.methods.getLendingPool().call() + + const contract = createContract( + web3, + poolAddress || ZERO_ADDRESS, + AaveLendingPoolABI as AbiItem[], + ) + const gasEstimate = await contract?.methods + .withdraw(getSavingsConstants(chainId).AAVE || ZERO_ADDRESS, value.toString(), account) + .estimateGas({ + from: account, + }) + return new BigNumber(gasEstimate || 0) + } catch (error) { + console.error('AAVE `withdrawEstimate()` Error', error) + return new BigNumber(0) + } + } + + public async withdraw(account: string, chainId: ChainId, web3: Web3, value: BigNumber.Value) { + try { + const lPoolAdressProviderContract = createContract( + web3, + getSavingsConstants(chainId).AAVELendingPoolAddressProviderContract || ZERO_ADDRESS, + AaveLendingPoolAddressProviderABI as AbiItem[], + ) + + const poolAddress = await lPoolAdressProviderContract?.methods.getLendingPool().call() + + const contract = createContract( + web3, + poolAddress || ZERO_ADDRESS, + AaveLendingPoolABI as AbiItem[], + ) + await contract?.methods + .withdraw(getSavingsConstants(chainId).AAVE || ZERO_ADDRESS, value.toString(), account) + .send({ + from: account, + }) + return true + } catch (error) { + console.error('AAVE `withdraw()` Error', error) + return false + } + } +} + +export default new AAVEProtocol() diff --git a/packages/mask/src/plugins/Savings/protocols/index.ts b/packages/mask/src/plugins/Savings/protocols/index.ts index 460cbef77532..ddf92b78e92f 100644 --- a/packages/mask/src/plugins/Savings/protocols/index.ts +++ b/packages/mask/src/plugins/Savings/protocols/index.ts @@ -1,4 +1,5 @@ import type { SavingsProtocol } from '../types' import LidoProtocol from './LDOProtocol' +import AAVEProtocol from './AAVEProtocol' -export const SavingsProtocols: SavingsProtocol[] = [LidoProtocol] +export const SavingsProtocols: SavingsProtocol[] = [LidoProtocol, AAVEProtocol] diff --git a/packages/mask/src/plugins/Savings/types.ts b/packages/mask/src/plugins/Savings/types.ts index 5a690fef29a5..c46e6bcd717a 100644 --- a/packages/mask/src/plugins/Savings/types.ts +++ b/packages/mask/src/plugins/Savings/types.ts @@ -14,6 +14,7 @@ export enum ProtocolCategory { export enum ProtocolType { Lido = 0, + AAVE = 1, } export interface SavingsProtocol { @@ -29,7 +30,7 @@ export interface SavingsProtocol { balance: BigNumber getFungibleTokenDetails(chainId: ChainId): FungibleTokenDetailed - getApr(): Promise + getApr(chainId?: ChainId): Promise getBalance(chainId: ChainId, web3: Web3, account: string): Promise depositEstimate(account: string, chainId: ChainId, web3: Web3, value: BigNumber.Value): Promise deposit(account: string, chainId: ChainId, web3: Web3, value: BigNumber.Value): Promise diff --git a/packages/web3-constants/evm/savings.json b/packages/web3-constants/evm/savings.json index 0f58f923eb48..ddd568ae6338 100644 --- a/packages/web3-constants/evm/savings.json +++ b/packages/web3-constants/evm/savings.json @@ -58,5 +58,68 @@ "Fantom": "", "Aurora": "", "Aurora_Testnet": "" - } + }, + + "AAVE_SUBGRAPHS": { + "Mainnet": "https://api.thegraph.com/subgraphs/name/aave/protocol-v2", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "https://api.thegraph.com/subgraphs/name/aave/protocol-v2-kovan", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + + "AAVELendingPoolAddressProviderContract": { + "Mainnet": "0xb53c1a33016b2dc2ff3653530bff1848a515c8c5", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "​​0x88757f2f99175387ab4c6a4b3067c77a695b0349", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + + "AAVE": { + "Mainnet": "0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "0xb597cd8d3217ea6477232f9217fa70837ff667af", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, } diff --git a/packages/web3-contracts/abis/AaveLendingPool.json b/packages/web3-contracts/abis/AaveLendingPool.json new file mode 100644 index 000000000000..daa6448eb0e9 --- /dev/null +++ b/packages/web3-contracts/abis/AaveLendingPool.json @@ -0,0 +1,1079 @@ +[ + { + "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" + } +] diff --git a/packages/web3-contracts/abis/AaveLendingPoolAddressProvider.json b/packages/web3-contracts/abis/AaveLendingPoolAddressProvider.json new file mode 100644 index 000000000000..f4c8b0543ad9 --- /dev/null +++ b/packages/web3-contracts/abis/AaveLendingPoolAddressProvider.json @@ -0,0 +1,477 @@ +[ + { + "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" + } +] + diff --git a/packages/web3-contracts/abis/AaveProtocolDataProvider.json b/packages/web3-contracts/abis/AaveProtocolDataProvider.json new file mode 100644 index 000000000000..c3aff397f64b --- /dev/null +++ b/packages/web3-contracts/abis/AaveProtocolDataProvider.json @@ -0,0 +1,298 @@ +[ + { + "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" + } +] + diff --git a/packages/web3-contracts/abis/AaveStableDebtToken.json b/packages/web3-contracts/abis/AaveStableDebtToken.json new file mode 100644 index 000000000000..dbc3adf3c4ce --- /dev/null +++ b/packages/web3-contracts/abis/AaveStableDebtToken.json @@ -0,0 +1,324 @@ +[ + { + "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": "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" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "delegatee", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "approveDelegation", + "outputs": [], + "stateMutability": "nonpayable", + "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": "getAverageStableRate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "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": "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": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "principalBalanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } +] + diff --git a/packages/web3-contracts/types/AaveLendingPool.d.ts b/packages/web3-contracts/types/AaveLendingPool.d.ts new file mode 100644 index 000000000000..47273dcf7b3e --- /dev/null +++ b/packages/web3-contracts/types/AaveLendingPool.d.ts @@ -0,0 +1,440 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import BN from "bn.js"; +import { ContractOptions } from "web3-eth-contract"; +import { EventLog } from "web3-core"; +import { EventEmitter } from "events"; +import { + Callback, + PayableTransactionObject, + NonPayableTransactionObject, + BlockType, + ContractEventLog, + BaseContract, +} from "./types"; + +export interface EventOptions { + filter?: object; + fromBlock?: BlockType; + topics?: string[]; +} + +export type Borrow = ContractEventLog<{ + reserve: string; + user: string; + onBehalfOf: string; + amount: string; + borrowRateMode: string; + borrowRate: string; + referral: string; + 0: string; + 1: string; + 2: string; + 3: string; + 4: string; + 5: string; + 6: string; +}>; +export type Deposit = ContractEventLog<{ + reserve: string; + user: string; + onBehalfOf: string; + amount: string; + referral: string; + 0: string; + 1: string; + 2: string; + 3: string; + 4: string; +}>; +export type FlashLoan = ContractEventLog<{ + target: string; + initiator: string; + asset: string; + amount: string; + premium: string; + referralCode: string; + 0: string; + 1: string; + 2: string; + 3: string; + 4: string; + 5: string; +}>; +export type LiquidationCall = ContractEventLog<{ + collateralAsset: string; + debtAsset: string; + user: string; + debtToCover: string; + liquidatedCollateralAmount: string; + liquidator: string; + receiveAToken: boolean; + 0: string; + 1: string; + 2: string; + 3: string; + 4: string; + 5: string; + 6: boolean; +}>; +export type Paused = ContractEventLog<{}>; +export type RebalanceStableBorrowRate = ContractEventLog<{ + reserve: string; + user: string; + 0: string; + 1: string; +}>; +export type Repay = ContractEventLog<{ + reserve: string; + user: string; + repayer: string; + amount: string; + 0: string; + 1: string; + 2: string; + 3: string; +}>; +export type ReserveDataUpdated = ContractEventLog<{ + reserve: string; + liquidityRate: string; + stableBorrowRate: string; + variableBorrowRate: string; + liquidityIndex: string; + variableBorrowIndex: string; + 0: string; + 1: string; + 2: string; + 3: string; + 4: string; + 5: string; +}>; +export type ReserveUsedAsCollateralDisabled = ContractEventLog<{ + reserve: string; + user: string; + 0: string; + 1: string; +}>; +export type ReserveUsedAsCollateralEnabled = ContractEventLog<{ + reserve: string; + user: string; + 0: string; + 1: string; +}>; +export type Swap = ContractEventLog<{ + reserve: string; + user: string; + rateMode: string; + 0: string; + 1: string; + 2: string; +}>; +export type Unpaused = ContractEventLog<{}>; +export type Withdraw = ContractEventLog<{ + reserve: string; + user: string; + to: string; + amount: string; + 0: string; + 1: string; + 2: string; + 3: string; +}>; + +export interface AaveLendingPool extends BaseContract { + constructor( + jsonInterface: any[], + address?: string, + options?: ContractOptions + ): AaveLendingPool; + clone(): AaveLendingPool; + methods: { + FLASHLOAN_PREMIUM_TOTAL(): NonPayableTransactionObject; + + LENDINGPOOL_REVISION(): NonPayableTransactionObject; + + MAX_NUMBER_RESERVES(): NonPayableTransactionObject; + + MAX_STABLE_RATE_BORROW_SIZE_PERCENT(): NonPayableTransactionObject; + + borrow( + asset: string, + amount: number | string | BN, + interestRateMode: number | string | BN, + referralCode: number | string | BN, + onBehalfOf: string + ): NonPayableTransactionObject; + + deposit( + asset: string, + amount: number | string | BN, + onBehalfOf: string, + referralCode: number | string | BN + ): NonPayableTransactionObject; + + finalizeTransfer( + asset: string, + from: string, + to: string, + amount: number | string | BN, + balanceFromBefore: number | string | BN, + balanceToBefore: number | string | BN + ): NonPayableTransactionObject; + + flashLoan( + receiverAddress: string, + assets: string[], + amounts: (number | string | BN)[], + modes: (number | string | BN)[], + onBehalfOf: string, + params: string | number[], + referralCode: number | string | BN + ): NonPayableTransactionObject; + + getAddressesProvider(): NonPayableTransactionObject; + + getConfiguration(asset: string): NonPayableTransactionObject<[string]>; + + getReserveData( + asset: string + ): NonPayableTransactionObject< + [ + [string], + string, + string, + string, + string, + string, + string, + string, + string, + string, + string, + string + ] + >; + + getReserveNormalizedIncome( + asset: string + ): NonPayableTransactionObject; + + getReserveNormalizedVariableDebt( + asset: string + ): NonPayableTransactionObject; + + getReservesList(): NonPayableTransactionObject; + + getUserAccountData(user: string): NonPayableTransactionObject<{ + totalCollateralETH: string; + totalDebtETH: string; + availableBorrowsETH: string; + currentLiquidationThreshold: string; + ltv: string; + healthFactor: string; + 0: string; + 1: string; + 2: string; + 3: string; + 4: string; + 5: string; + }>; + + getUserConfiguration(user: string): NonPayableTransactionObject<[string]>; + + initReserve( + asset: string, + aTokenAddress: string, + stableDebtAddress: string, + variableDebtAddress: string, + interestRateStrategyAddress: string + ): NonPayableTransactionObject; + + initialize(provider: string): NonPayableTransactionObject; + + liquidationCall( + collateralAsset: string, + debtAsset: string, + user: string, + debtToCover: number | string | BN, + receiveAToken: boolean + ): NonPayableTransactionObject; + + paused(): NonPayableTransactionObject; + + rebalanceStableBorrowRate( + asset: string, + user: string + ): NonPayableTransactionObject; + + repay( + asset: string, + amount: number | string | BN, + rateMode: number | string | BN, + onBehalfOf: string + ): NonPayableTransactionObject; + + setConfiguration( + asset: string, + configuration: number | string | BN + ): NonPayableTransactionObject; + + setPause(val: boolean): NonPayableTransactionObject; + + setReserveInterestRateStrategyAddress( + asset: string, + rateStrategyAddress: string + ): NonPayableTransactionObject; + + setUserUseReserveAsCollateral( + asset: string, + useAsCollateral: boolean + ): NonPayableTransactionObject; + + swapBorrowRateMode( + asset: string, + rateMode: number | string | BN + ): NonPayableTransactionObject; + + withdraw( + asset: string, + amount: number | string | BN, + to: string + ): NonPayableTransactionObject; + }; + events: { + Borrow(cb?: Callback): EventEmitter; + Borrow(options?: EventOptions, cb?: Callback): EventEmitter; + + Deposit(cb?: Callback): EventEmitter; + Deposit(options?: EventOptions, cb?: Callback): EventEmitter; + + FlashLoan(cb?: Callback): EventEmitter; + FlashLoan(options?: EventOptions, cb?: Callback): EventEmitter; + + LiquidationCall(cb?: Callback): EventEmitter; + LiquidationCall( + options?: EventOptions, + cb?: Callback + ): EventEmitter; + + Paused(cb?: Callback): EventEmitter; + Paused(options?: EventOptions, cb?: Callback): EventEmitter; + + RebalanceStableBorrowRate( + cb?: Callback + ): EventEmitter; + RebalanceStableBorrowRate( + options?: EventOptions, + cb?: Callback + ): EventEmitter; + + Repay(cb?: Callback): EventEmitter; + Repay(options?: EventOptions, cb?: Callback): EventEmitter; + + ReserveDataUpdated(cb?: Callback): EventEmitter; + ReserveDataUpdated( + options?: EventOptions, + cb?: Callback + ): EventEmitter; + + ReserveUsedAsCollateralDisabled( + cb?: Callback + ): EventEmitter; + ReserveUsedAsCollateralDisabled( + options?: EventOptions, + cb?: Callback + ): EventEmitter; + + ReserveUsedAsCollateralEnabled( + cb?: Callback + ): EventEmitter; + ReserveUsedAsCollateralEnabled( + options?: EventOptions, + cb?: Callback + ): EventEmitter; + + Swap(cb?: Callback): EventEmitter; + Swap(options?: EventOptions, cb?: Callback): EventEmitter; + + Unpaused(cb?: Callback): EventEmitter; + Unpaused(options?: EventOptions, cb?: Callback): EventEmitter; + + Withdraw(cb?: Callback): EventEmitter; + Withdraw(options?: EventOptions, cb?: Callback): EventEmitter; + + allEvents(options?: EventOptions, cb?: Callback): EventEmitter; + }; + + once(event: "Borrow", cb: Callback): void; + once(event: "Borrow", options: EventOptions, cb: Callback): void; + + once(event: "Deposit", cb: Callback): void; + once(event: "Deposit", options: EventOptions, cb: Callback): void; + + once(event: "FlashLoan", cb: Callback): void; + once( + event: "FlashLoan", + options: EventOptions, + cb: Callback + ): void; + + once(event: "LiquidationCall", cb: Callback): void; + once( + event: "LiquidationCall", + options: EventOptions, + cb: Callback + ): void; + + once(event: "Paused", cb: Callback): void; + once(event: "Paused", options: EventOptions, cb: Callback): void; + + once( + event: "RebalanceStableBorrowRate", + cb: Callback + ): void; + once( + event: "RebalanceStableBorrowRate", + options: EventOptions, + cb: Callback + ): void; + + once(event: "Repay", cb: Callback): void; + once(event: "Repay", options: EventOptions, cb: Callback): void; + + once(event: "ReserveDataUpdated", cb: Callback): void; + once( + event: "ReserveDataUpdated", + options: EventOptions, + cb: Callback + ): void; + + once( + event: "ReserveUsedAsCollateralDisabled", + cb: Callback + ): void; + once( + event: "ReserveUsedAsCollateralDisabled", + options: EventOptions, + cb: Callback + ): void; + + once( + event: "ReserveUsedAsCollateralEnabled", + cb: Callback + ): void; + once( + event: "ReserveUsedAsCollateralEnabled", + options: EventOptions, + cb: Callback + ): void; + + once(event: "Swap", cb: Callback): void; + once(event: "Swap", options: EventOptions, cb: Callback): void; + + once(event: "Unpaused", cb: Callback): void; + once(event: "Unpaused", options: EventOptions, cb: Callback): void; + + once(event: "Withdraw", cb: Callback): void; + once(event: "Withdraw", options: EventOptions, cb: Callback): void; +} diff --git a/packages/web3-contracts/types/AaveLendingPoolAddressProvider.d.ts b/packages/web3-contracts/types/AaveLendingPoolAddressProvider.d.ts new file mode 100644 index 000000000000..49c21652747a --- /dev/null +++ b/packages/web3-contracts/types/AaveLendingPoolAddressProvider.d.ts @@ -0,0 +1,309 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import BN from "bn.js"; +import { ContractOptions } from "web3-eth-contract"; +import { EventLog } from "web3-core"; +import { EventEmitter } from "events"; +import { + Callback, + PayableTransactionObject, + NonPayableTransactionObject, + BlockType, + ContractEventLog, + BaseContract, +} from "./types"; + +export interface EventOptions { + filter?: object; + fromBlock?: BlockType; + topics?: string[]; +} + +export type AddressSet = ContractEventLog<{ + id: string; + newAddress: string; + hasProxy: boolean; + 0: string; + 1: string; + 2: boolean; +}>; +export type ConfigurationAdminUpdated = ContractEventLog<{ + newAddress: string; + 0: string; +}>; +export type EmergencyAdminUpdated = ContractEventLog<{ + newAddress: string; + 0: string; +}>; +export type LendingPoolCollateralManagerUpdated = ContractEventLog<{ + newAddress: string; + 0: string; +}>; +export type LendingPoolConfiguratorUpdated = ContractEventLog<{ + newAddress: string; + 0: string; +}>; +export type LendingPoolUpdated = ContractEventLog<{ + newAddress: string; + 0: string; +}>; +export type LendingRateOracleUpdated = ContractEventLog<{ + newAddress: string; + 0: string; +}>; +export type MarketIdSet = ContractEventLog<{ + newMarketId: string; + 0: string; +}>; +export type OwnershipTransferred = ContractEventLog<{ + previousOwner: string; + newOwner: string; + 0: string; + 1: string; +}>; +export type PriceOracleUpdated = ContractEventLog<{ + newAddress: string; + 0: string; +}>; +export type ProxyCreated = ContractEventLog<{ + id: string; + newAddress: string; + 0: string; + 1: string; +}>; + +export interface AaveLendingPoolAddressProvider extends BaseContract { + constructor( + jsonInterface: any[], + address?: string, + options?: ContractOptions + ): AaveLendingPoolAddressProvider; + clone(): AaveLendingPoolAddressProvider; + methods: { + getAddress(id: string | number[]): NonPayableTransactionObject; + + getEmergencyAdmin(): NonPayableTransactionObject; + + getLendingPool(): NonPayableTransactionObject; + + getLendingPoolCollateralManager(): NonPayableTransactionObject; + + getLendingPoolConfigurator(): NonPayableTransactionObject; + + getLendingRateOracle(): NonPayableTransactionObject; + + getMarketId(): NonPayableTransactionObject; + + getPoolAdmin(): NonPayableTransactionObject; + + getPriceOracle(): NonPayableTransactionObject; + + owner(): NonPayableTransactionObject; + + renounceOwnership(): NonPayableTransactionObject; + + setAddress( + id: string | number[], + newAddress: string + ): NonPayableTransactionObject; + + setAddressAsProxy( + id: string | number[], + implementationAddress: string + ): NonPayableTransactionObject; + + setEmergencyAdmin( + emergencyAdmin: string + ): NonPayableTransactionObject; + + setLendingPoolCollateralManager( + manager: string + ): NonPayableTransactionObject; + + setLendingPoolConfiguratorImpl( + configurator: string + ): NonPayableTransactionObject; + + setLendingPoolImpl(pool: string): NonPayableTransactionObject; + + setLendingRateOracle( + lendingRateOracle: string + ): NonPayableTransactionObject; + + setMarketId(marketId: string): NonPayableTransactionObject; + + setPoolAdmin(admin: string): NonPayableTransactionObject; + + setPriceOracle(priceOracle: string): NonPayableTransactionObject; + + transferOwnership(newOwner: string): NonPayableTransactionObject; + }; + events: { + AddressSet(cb?: Callback): EventEmitter; + AddressSet(options?: EventOptions, cb?: Callback): EventEmitter; + + ConfigurationAdminUpdated( + cb?: Callback + ): EventEmitter; + ConfigurationAdminUpdated( + options?: EventOptions, + cb?: Callback + ): EventEmitter; + + EmergencyAdminUpdated(cb?: Callback): EventEmitter; + EmergencyAdminUpdated( + options?: EventOptions, + cb?: Callback + ): EventEmitter; + + LendingPoolCollateralManagerUpdated( + cb?: Callback + ): EventEmitter; + LendingPoolCollateralManagerUpdated( + options?: EventOptions, + cb?: Callback + ): EventEmitter; + + LendingPoolConfiguratorUpdated( + cb?: Callback + ): EventEmitter; + LendingPoolConfiguratorUpdated( + options?: EventOptions, + cb?: Callback + ): EventEmitter; + + LendingPoolUpdated(cb?: Callback): EventEmitter; + LendingPoolUpdated( + options?: EventOptions, + cb?: Callback + ): EventEmitter; + + LendingRateOracleUpdated( + cb?: Callback + ): EventEmitter; + LendingRateOracleUpdated( + options?: EventOptions, + cb?: Callback + ): EventEmitter; + + MarketIdSet(cb?: Callback): EventEmitter; + MarketIdSet( + options?: EventOptions, + cb?: Callback + ): EventEmitter; + + OwnershipTransferred(cb?: Callback): EventEmitter; + OwnershipTransferred( + options?: EventOptions, + cb?: Callback + ): EventEmitter; + + PriceOracleUpdated(cb?: Callback): EventEmitter; + PriceOracleUpdated( + options?: EventOptions, + cb?: Callback + ): EventEmitter; + + ProxyCreated(cb?: Callback): EventEmitter; + ProxyCreated( + options?: EventOptions, + cb?: Callback + ): EventEmitter; + + allEvents(options?: EventOptions, cb?: Callback): EventEmitter; + }; + + once(event: "AddressSet", cb: Callback): void; + once( + event: "AddressSet", + options: EventOptions, + cb: Callback + ): void; + + once( + event: "ConfigurationAdminUpdated", + cb: Callback + ): void; + once( + event: "ConfigurationAdminUpdated", + options: EventOptions, + cb: Callback + ): void; + + once( + event: "EmergencyAdminUpdated", + cb: Callback + ): void; + once( + event: "EmergencyAdminUpdated", + options: EventOptions, + cb: Callback + ): void; + + once( + event: "LendingPoolCollateralManagerUpdated", + cb: Callback + ): void; + once( + event: "LendingPoolCollateralManagerUpdated", + options: EventOptions, + cb: Callback + ): void; + + once( + event: "LendingPoolConfiguratorUpdated", + cb: Callback + ): void; + once( + event: "LendingPoolConfiguratorUpdated", + options: EventOptions, + cb: Callback + ): void; + + once(event: "LendingPoolUpdated", cb: Callback): void; + once( + event: "LendingPoolUpdated", + options: EventOptions, + cb: Callback + ): void; + + once( + event: "LendingRateOracleUpdated", + cb: Callback + ): void; + once( + event: "LendingRateOracleUpdated", + options: EventOptions, + cb: Callback + ): void; + + once(event: "MarketIdSet", cb: Callback): void; + once( + event: "MarketIdSet", + options: EventOptions, + cb: Callback + ): void; + + once(event: "OwnershipTransferred", cb: Callback): void; + once( + event: "OwnershipTransferred", + options: EventOptions, + cb: Callback + ): void; + + once(event: "PriceOracleUpdated", cb: Callback): void; + once( + event: "PriceOracleUpdated", + options: EventOptions, + cb: Callback + ): void; + + once(event: "ProxyCreated", cb: Callback): void; + once( + event: "ProxyCreated", + options: EventOptions, + cb: Callback + ): void; +} diff --git a/packages/web3-contracts/types/AaveProtocolDataProvider.d.ts b/packages/web3-contracts/types/AaveProtocolDataProvider.d.ts new file mode 100644 index 000000000000..57555766109e --- /dev/null +++ b/packages/web3-contracts/types/AaveProtocolDataProvider.d.ts @@ -0,0 +1,120 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import BN from "bn.js"; +import { ContractOptions } from "web3-eth-contract"; +import { EventLog } from "web3-core"; +import { EventEmitter } from "events"; +import { + Callback, + PayableTransactionObject, + NonPayableTransactionObject, + BlockType, + ContractEventLog, + BaseContract, +} from "./types"; + +export interface EventOptions { + filter?: object; + fromBlock?: BlockType; + topics?: string[]; +} + +export interface AaveProtocolDataProvider extends BaseContract { + constructor( + jsonInterface: any[], + address?: string, + options?: ContractOptions + ): AaveProtocolDataProvider; + clone(): AaveProtocolDataProvider; + methods: { + ADDRESSES_PROVIDER(): NonPayableTransactionObject; + + getAllATokens(): NonPayableTransactionObject<[string, string][]>; + + getAllReservesTokens(): NonPayableTransactionObject<[string, string][]>; + + getReserveConfigurationData(asset: string): NonPayableTransactionObject<{ + decimals: string; + ltv: string; + liquidationThreshold: string; + liquidationBonus: string; + reserveFactor: string; + usageAsCollateralEnabled: boolean; + borrowingEnabled: boolean; + stableBorrowRateEnabled: boolean; + isActive: boolean; + isFrozen: boolean; + 0: string; + 1: string; + 2: string; + 3: string; + 4: string; + 5: boolean; + 6: boolean; + 7: boolean; + 8: boolean; + 9: boolean; + }>; + + getReserveData(asset: string): NonPayableTransactionObject<{ + availableLiquidity: string; + totalStableDebt: string; + totalVariableDebt: string; + liquidityRate: string; + variableBorrowRate: string; + stableBorrowRate: string; + averageStableBorrowRate: string; + liquidityIndex: string; + variableBorrowIndex: string; + lastUpdateTimestamp: string; + 0: string; + 1: string; + 2: string; + 3: string; + 4: string; + 5: string; + 6: string; + 7: string; + 8: string; + 9: string; + }>; + + getReserveTokensAddresses(asset: string): NonPayableTransactionObject<{ + aTokenAddress: string; + stableDebtTokenAddress: string; + variableDebtTokenAddress: string; + 0: string; + 1: string; + 2: string; + }>; + + getUserReserveData( + asset: string, + user: string + ): NonPayableTransactionObject<{ + currentATokenBalance: string; + currentStableDebt: string; + currentVariableDebt: string; + principalStableDebt: string; + scaledVariableDebt: string; + stableBorrowRate: string; + liquidityRate: string; + stableRateLastUpdated: string; + usageAsCollateralEnabled: boolean; + 0: string; + 1: string; + 2: string; + 3: string; + 4: string; + 5: string; + 6: string; + 7: string; + 8: boolean; + }>; + }; + events: { + allEvents(options?: EventOptions, cb?: Callback): EventEmitter; + }; +} diff --git a/packages/web3-contracts/types/AaveStableDebtToken.d.ts b/packages/web3-contracts/types/AaveStableDebtToken.d.ts new file mode 100644 index 000000000000..c850b4fb9e02 --- /dev/null +++ b/packages/web3-contracts/types/AaveStableDebtToken.d.ts @@ -0,0 +1,124 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import BN from "bn.js"; +import { ContractOptions } from "web3-eth-contract"; +import { EventLog } from "web3-core"; +import { EventEmitter } from "events"; +import { + Callback, + PayableTransactionObject, + NonPayableTransactionObject, + BlockType, + ContractEventLog, + BaseContract, +} from "./types"; + +export interface EventOptions { + filter?: object; + fromBlock?: BlockType; + topics?: string[]; +} + +export type Burn = ContractEventLog<{ + user: string; + amount: string; + currentBalance: string; + balanceIncrease: string; + avgStableRate: string; + newTotalSupply: string; + 0: string; + 1: string; + 2: string; + 3: string; + 4: string; + 5: string; +}>; +export type Mint = ContractEventLog<{ + user: string; + onBehalfOf: string; + amount: string; + currentBalance: string; + balanceIncrease: string; + newRate: string; + avgStableRate: string; + newTotalSupply: string; + 0: string; + 1: string; + 2: string; + 3: string; + 4: string; + 5: string; + 6: string; + 7: string; +}>; + +export interface AaveStableDebtToken extends BaseContract { + constructor( + jsonInterface: any[], + address?: string, + options?: ContractOptions + ): AaveStableDebtToken; + clone(): AaveStableDebtToken; + methods: { + approveDelegation( + delegatee: string, + amount: number | string | BN + ): NonPayableTransactionObject; + + borrowAllowance( + fromUser: string, + toUser: string + ): NonPayableTransactionObject; + + burn( + user: string, + amount: number | string | BN + ): NonPayableTransactionObject; + + getAverageStableRate(): NonPayableTransactionObject; + + getSupplyData(): NonPayableTransactionObject<{ + 0: string; + 1: string; + 2: string; + 3: string; + }>; + + getTotalSupplyAndAvgRate(): NonPayableTransactionObject<{ + 0: string; + 1: string; + }>; + + getTotalSupplyLastUpdated(): NonPayableTransactionObject; + + getUserLastUpdated(user: string): NonPayableTransactionObject; + + getUserStableRate(user: string): NonPayableTransactionObject; + + mint( + user: string, + onBehalfOf: string, + amount: number | string | BN, + rate: number | string | BN + ): NonPayableTransactionObject; + + principalBalanceOf(user: string): NonPayableTransactionObject; + }; + events: { + Burn(cb?: Callback): EventEmitter; + Burn(options?: EventOptions, cb?: Callback): EventEmitter; + + Mint(cb?: Callback): EventEmitter; + Mint(options?: EventOptions, cb?: Callback): EventEmitter; + + allEvents(options?: EventOptions, cb?: Callback): EventEmitter; + }; + + once(event: "Burn", cb: Callback): void; + once(event: "Burn", options: EventOptions, cb: Callback): void; + + once(event: "Mint", cb: Callback): void; + once(event: "Mint", options: EventOptions, cb: Callback): void; +} From 17a303ec804db62c780e063bd29666bcb24a39f2 Mon Sep 17 00:00:00 2001 From: "@layinka" Date: Fri, 11 Feb 2022 17:09:39 +0100 Subject: [PATCH 02/38] Finished adding aAave to savings protocol --- .../mask/src/plugins/Savings/protocols/AAVEProtocol.ts | 8 ++++---- packages/web3-constants/evm/savings.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts b/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts index 484a85000a42..ee58ecb91bf3 100644 --- a/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts +++ b/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts @@ -94,11 +94,11 @@ export class AAVEProtocol implements SavingsProtocol { public async getApr(chainId?: ChainId) { try { - const subgraphUrl = AaveContracts[chainId ?? ChainId.Kovan].subgraphUrl + const subgraphUrl = getSavingsConstants(chainId ?? ChainId.Kovan).AAVE_SUBGRAPHS || '' const body = JSON.stringify({ query: `{ reserves (where: { - underlyingAsset: "${AaveContracts[chainId ?? ChainId.Kovan].aaveContract}" + underlyingAsset: "${getSavingsConstants(chainId ?? ChainId.Kovan).AAVE || ZERO_ADDRESS}" }) { id name @@ -134,11 +134,11 @@ export class AAVEProtocol implements SavingsProtocol { public async getBalance(chainId: ChainId, web3: Web3, account: string) { try { - const subgraphUrl = AaveContracts[chainId ?? ChainId.Kovan].subgraphUrl + const subgraphUrl = getSavingsConstants(chainId ?? ChainId.Kovan).AAVE_SUBGRAPHS || '' const reserveBody = JSON.stringify({ query: `{ reserves (where: { - underlyingAsset: "${AaveContracts[chainId ?? ChainId.Kovan].aaveContract}" + underlyingAsset: "${getSavingsConstants(chainId ?? ChainId.Kovan).AAVE || ZERO_ADDRESS}" }) { id name diff --git a/packages/web3-constants/evm/savings.json b/packages/web3-constants/evm/savings.json index ddd568ae6338..b4f4e295218b 100644 --- a/packages/web3-constants/evm/savings.json +++ b/packages/web3-constants/evm/savings.json @@ -121,5 +121,5 @@ "Fantom": "", "Aurora": "", "Aurora_Testnet": "" - }, + } } From 61627b4230457324199f89832e3d98cd10026162 Mon Sep 17 00:00:00 2001 From: layinka Date: Mon, 14 Feb 2022 18:58:39 +0100 Subject: [PATCH 03/38] Update: use Zero Contant in place of BigNumber(0) Co-authored-by: septs --- packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts b/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts index ee58ecb91bf3..9d822989a731 100644 --- a/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts +++ b/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts @@ -55,7 +55,7 @@ export class AAVEProtocol implements SavingsProtocol { public pair = 'aAAVE' public decimals = 18 public apr = '0.00' - public balance = new BigNumber('0') + public balance = ZERO public availableNetworks: SavingsNetwork[] = [ { chainId: ChainId.Mainnet, From 43e2ec4e1d115b8d744a9676e2601623abaad75d Mon Sep 17 00:00:00 2001 From: "@layinka" Date: Mon, 14 Feb 2022 19:48:56 +0100 Subject: [PATCH 04/38] refactored aave protocols/AAVEProtocol.ts --- .../plugins/Savings/SNSAdaptor/IconURL.tsx | 1 + .../Savings/SNSAdaptor/assets/aave.png | Bin 0 -> 43947 bytes .../plugins/Savings/protocols/AAVEProtocol.ts | 71 +++++++++++++----- packages/web3-constants/evm/savings.json | 2 +- 4 files changed, 54 insertions(+), 20 deletions(-) create mode 100644 packages/mask/src/plugins/Savings/SNSAdaptor/assets/aave.png diff --git a/packages/mask/src/plugins/Savings/SNSAdaptor/IconURL.tsx b/packages/mask/src/plugins/Savings/SNSAdaptor/IconURL.tsx index cd1196af0236..8a050b94820b 100644 --- a/packages/mask/src/plugins/Savings/SNSAdaptor/IconURL.tsx +++ b/packages/mask/src/plugins/Savings/SNSAdaptor/IconURL.tsx @@ -1,4 +1,5 @@ export const IconURLs: Readonly> = { lido: new URL('./assets/lido.png', import.meta.url).toString(), eth: new URL('./assets/eth.png', import.meta.url).toString(), + aave: new URL('./assets/aave.png', import.meta.url).toString(), } diff --git a/packages/mask/src/plugins/Savings/SNSAdaptor/assets/aave.png b/packages/mask/src/plugins/Savings/SNSAdaptor/assets/aave.png new file mode 100644 index 0000000000000000000000000000000000000000..de6347b97ebcb9f9b07daa075dd5b2e9517701b3 GIT binary patch literal 43947 zcmV)ZK&!urP)004R>004l5008;`004mK004C`008P>0026e000+ooVrmw0065t zNkl`?9S(a)w|k=1)0VY)87~u*H7(1V7Pi`Mt>&tYD@bBrh$^58YoQj@UiDs{ ziOiRI^PF?<1FEP85TNQskf`O=d-*c+o_o%BzVm&=%vgNf(2q_4J=uSqcmta-fKHr8 z=ZSvw5P;r`r+QGXJo)TsfBG{dmz^1uze@5w0c+d4dn@0^xM^ii`t|zt=*0?*U=>Di z7y6Qy1TZ50U3}c24_XWWH`F5EjUQnb2GRNa{+Zna7mxN#%#3$ZehImg*B8 zg$}X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1(b4SHr7Hn^Og~DHnQQ(>w9nO z#=R}ei+(u(oD0F=PlC+g{v)_8e2+`F}LLtia-WSVDemU{i2k~)sFG%#+Ry;8M4`(DSUp51TWg5Dd7N;`kM zyx^Au!15uFrXV0Z1Z?{UVCUcfdIq08yzS%-KVDAQB?C$Ta40qljTf|oNCSs|f{R+K zdkPJm-F;i%jNWU2-Rp}BetCyq4gkx?Ydp3EbbxOG+nxrt4IM$x$g5*LGh@R|rKbZZ zX^<**aS;T3N7JzMh_IrrG2hhH*tc;LcCP^PH>L}{Z+WpV2Y}_{^kfV{8PRwY=y@FI zISMq50!_!J!>=R%Qt@x{fziVUd*+ikYh1M^;m0@k6uI)N8qwDb( web3, - getSavingsConstants(chainId).AAVELendingPoolAddressProviderContract || ZERO_ADDRESS, + aaveLPoolAddress, AaveLendingPoolAddressProviderABI as AbiItem[], ) @@ -228,7 +257,7 @@ export class AAVEProtocol implements SavingsProtocol { try { const lPoolAdressProviderContract = createContract( web3, - getSavingsConstants(chainId).AAVELendingPoolAddressProviderContract || ZERO_ADDRESS, + getSavingsConstants(chainId).AAVE_LENDING_POOL_ADDRESSES_PROVIDER_CONTRACT_ADDRESS || ZERO_ADDRESS, AaveLendingPoolAddressProviderABI as AbiItem[], ) @@ -240,11 +269,13 @@ export class AAVEProtocol implements SavingsProtocol { AaveLendingPoolABI as AbiItem[], ) + const gasEstimate = await this.depositEstimate(account, chainId, web3, value) + await contract?.methods .deposit(getSavingsConstants(chainId).AAVE || ZERO_ADDRESS, value.toString(), account, '0') .send({ from: account, - gas: 300000, + gas: gasEstimate.toNumber(), }) return true } catch (error) { @@ -257,7 +288,7 @@ export class AAVEProtocol implements SavingsProtocol { try { const lPoolAdressProviderContract = createContract( web3, - getSavingsConstants(chainId).AAVELendingPoolAddressProviderContract || ZERO_ADDRESS, + getSavingsConstants(chainId).AAVE_LENDING_POOL_ADDRESSES_PROVIDER_CONTRACT_ADDRESS || ZERO_ADDRESS, AaveLendingPoolAddressProviderABI as AbiItem[], ) @@ -284,12 +315,13 @@ export class AAVEProtocol implements SavingsProtocol { try { const lPoolAdressProviderContract = createContract( web3, - getSavingsConstants(chainId).AAVELendingPoolAddressProviderContract || ZERO_ADDRESS, + getSavingsConstants(chainId).AAVE_LENDING_POOL_ADDRESSES_PROVIDER_CONTRACT_ADDRESS || ZERO_ADDRESS, AaveLendingPoolAddressProviderABI as AbiItem[], ) const poolAddress = await lPoolAdressProviderContract?.methods.getLendingPool().call() + const gasEstimate = await this.withdrawEstimate(account, chainId, web3, value) const contract = createContract( web3, poolAddress || ZERO_ADDRESS, @@ -299,6 +331,7 @@ export class AAVEProtocol implements SavingsProtocol { .withdraw(getSavingsConstants(chainId).AAVE || ZERO_ADDRESS, value.toString(), account) .send({ from: account, + gas: gasEstimate.toNumber(), }) return true } catch (error) { diff --git a/packages/web3-constants/evm/savings.json b/packages/web3-constants/evm/savings.json index b4f4e295218b..4ff427d29b7d 100644 --- a/packages/web3-constants/evm/savings.json +++ b/packages/web3-constants/evm/savings.json @@ -81,7 +81,7 @@ "Aurora_Testnet": "" }, - "AAVELendingPoolAddressProviderContract": { + "AAVE_LENDING_POOL_ADDRESSES_PROVIDER_CONTRACT_ADDRESS": { "Mainnet": "0xb53c1a33016b2dc2ff3653530bff1848a515c8c5", "Ropsten": "", "Rinkeby": "", From 6f3e08db14a3cfce464615034768436f64d402d1 Mon Sep 17 00:00:00 2001 From: "@layinka" Date: Tue, 22 Feb 2022 18:14:29 +0100 Subject: [PATCH 05/38] refactor deposit and depositestimate. refactor AaveContracts indexer --- .../plugins/Savings/protocols/AAVEProtocol.ts | 101 ++++++++---------- 1 file changed, 43 insertions(+), 58 deletions(-) diff --git a/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts b/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts index 6a964a6ab516..0d6c5142e329 100644 --- a/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts +++ b/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts @@ -26,25 +26,18 @@ export interface AaveContract { stEthContract: string } -export const AaveContracts: { [key: number]: AaveContract } = { - [ChainId.Mainnet]: { - type: EthereumTokenType.ERC20, - chainName: 'Ethereum', - subgraphUrl: getSavingsConstants(ChainId.Mainnet).AAVE_SUBGRAPHS || '', - aaveLendingPoolAddressProviderContract: - getSavingsConstants(ChainId.Mainnet).AAVE_LENDING_POOL_ADDRESSES_PROVIDER_CONTRACT_ADDRESS || ZERO_ADDRESS, - aaveContract: getSavingsConstants(ChainId.Mainnet).AAVE || ZERO_ADDRESS, - stEthContract: getSavingsConstants(ChainId.Mainnet).LIDO_STETH || ZERO_ADDRESS, - }, - [ChainId.Gorli]: { +export function getAaveContract(chainId: ChainId): AaveContract { + const constants = getSavingsConstants(chainId) + + return { type: EthereumTokenType.ERC20, - chainName: 'Kovan', - subgraphUrl: getSavingsConstants(ChainId.Kovan).AAVE_SUBGRAPHS || '', + chainName: ChainId[chainId], + subgraphUrl: constants.AAVE_SUBGRAPHS ?? '', aaveLendingPoolAddressProviderContract: - getSavingsConstants(ChainId.Kovan).AAVE_LENDING_POOL_ADDRESSES_PROVIDER_CONTRACT_ADDRESS || ZERO_ADDRESS, - aaveContract: getSavingsConstants(ChainId.Kovan).AAVE || ZERO_ADDRESS, - stEthContract: getSavingsConstants(ChainId.Kovan).LIDO_STETH || ZERO_ADDRESS, - }, + constants.AAVE_LENDING_POOL_ADDRESSES_PROVIDER_CONTRACT_ADDRESS ?? ZERO_ADDRESS, + aaveContract: constants.AAVE ?? ZERO_ADDRESS, + stEthContract: constants.LIDO_STETH ?? ZERO_ADDRESS, + } } export class AAVEProtocol implements SavingsProtocol { @@ -225,26 +218,10 @@ export class AAVEProtocol implements SavingsProtocol { public async depositEstimate(account: string, chainId: ChainId, web3: Web3, value: BigNumber.Value) { try { - const aaveLPoolAddress = - getSavingsConstants(chainId).AAVE_LENDING_POOL_ADDRESSES_PROVIDER_CONTRACT_ADDRESS || ZERO_ADDRESS - const lPoolAdressProviderContract = createContract( - web3, - aaveLPoolAddress, - AaveLendingPoolAddressProviderABI as AbiItem[], - ) - - const poolAddress = await lPoolAdressProviderContract?.methods.getLendingPool().call() - - const contract = createContract( - web3, - poolAddress || ZERO_ADDRESS, - AaveLendingPoolABI as AbiItem[], - ) - const gasEstimate = await contract?.methods - .deposit(getSavingsConstants(chainId).AAVE || ZERO_ADDRESS, value.toString(), account, '0') - .estimateGas({ - from: account, - }) + const operation = await this.createDepositTokenOperation(account, chainId, web3, value) + const gasEstimate = await operation.estimateGas({ + from: account, + }) return new BigNumber(gasEstimate || 0) } catch (error) { @@ -253,30 +230,38 @@ export class AAVEProtocol implements SavingsProtocol { } } + private async createDepositTokenOperation(account: string, chainId: ChainId, web3: Web3, value: BigNumber.Value) { + const aaveLPoolAddress = + getSavingsConstants(chainId).AAVE_LENDING_POOL_ADDRESSES_PROVIDER_CONTRACT_ADDRESS || ZERO_ADDRESS + const lPoolAdressProviderContract = createContract( + web3, + aaveLPoolAddress, + AaveLendingPoolAddressProviderABI as AbiItem[], + ) + + const poolAddress = await lPoolAdressProviderContract?.methods.getLendingPool().call() + + const contract = createContract( + web3, + poolAddress || ZERO_ADDRESS, + AaveLendingPoolABI as AbiItem[], + ) + return contract?.methods.deposit( + getSavingsConstants(chainId).AAVE || ZERO_ADDRESS, + value.toString(), + account, + '0', + ) + } + public async deposit(account: string, chainId: ChainId, web3: Web3, value: BigNumber.Value) { try { - const lPoolAdressProviderContract = createContract( - web3, - getSavingsConstants(chainId).AAVE_LENDING_POOL_ADDRESSES_PROVIDER_CONTRACT_ADDRESS || ZERO_ADDRESS, - AaveLendingPoolAddressProviderABI as AbiItem[], - ) - - const poolAddress = await lPoolAdressProviderContract?.methods.getLendingPool().call() - - const contract = createContract( - web3, - poolAddress || ZERO_ADDRESS, - AaveLendingPoolABI as AbiItem[], - ) - const gasEstimate = await this.depositEstimate(account, chainId, web3, value) - - await contract?.methods - .deposit(getSavingsConstants(chainId).AAVE || ZERO_ADDRESS, value.toString(), account, '0') - .send({ - from: account, - gas: gasEstimate.toNumber(), - }) + const operation = await this.createDepositTokenOperation(account, chainId, web3, value) + await operation.send({ + from: account, + gas: gasEstimate.toNumber(), + }) return true } catch (error) { console.error('AAVE `deposit()` Error', error) From e89bec8ef02807d25f5cf33788dbcc42c390e953 Mon Sep 17 00:00:00 2001 From: "@layinka" Date: Sat, 26 Feb 2022 14:44:11 +0100 Subject: [PATCH 06/38] refactor AaveContracts for mutliple coins --- .../plugins/Savings/protocols/AAVEProtocol.ts | 112 ++++++++++-------- 1 file changed, 64 insertions(+), 48 deletions(-) diff --git a/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts b/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts index 0d6c5142e329..65fe2897fc65 100644 --- a/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts +++ b/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts @@ -17,6 +17,12 @@ import BigNumber from 'bignumber.js' import { ProtocolCategory, SavingsNetwork, SavingsProtocol, ProtocolType } from '../types' import { pow10, ZERO } from '@masknet/web3-shared-base' +export interface ContractListArray { + [index: string]: { + address: string + } +} + export interface AaveContract { type: EthereumTokenType chainName: string @@ -24,6 +30,7 @@ export interface AaveContract { aaveLendingPoolAddressProviderContract: string aaveContract: string stEthContract: string + assetContractAddresses: ContractListArray } export function getAaveContract(chainId: ChainId): AaveContract { @@ -36,62 +43,67 @@ export function getAaveContract(chainId: ChainId): AaveContract { aaveLendingPoolAddressProviderContract: constants.AAVE_LENDING_POOL_ADDRESSES_PROVIDER_CONTRACT_ADDRESS ?? ZERO_ADDRESS, aaveContract: constants.AAVE ?? ZERO_ADDRESS, - stEthContract: constants.LIDO_STETH ?? ZERO_ADDRESS, + stEthContract: constants.AAVE ?? ZERO_ADDRESS, + assetContractAddresses: { + AAVE: { address: constants.AAVE ?? ZERO_ADDRESS }, + }, } } export class AAVEProtocol implements SavingsProtocol { - public category = ProtocolCategory.ETH - public type = ProtocolType.AAVE - public name = 'AAVE' - public image = 'aave' - public base = 'AAVE' - public pair = 'aAAVE' - public decimals = 18 public apr = '0.00' public balance = ZERO - public availableNetworks: SavingsNetwork[] = [ - { - chainId: ChainId.Mainnet, - chainName: 'Ethereum', - contractAddress: getSavingsConstants(ChainId.Mainnet).AAVE || ZERO_ADDRESS, - }, - { - chainId: ChainId.Kovan, - chainName: 'Kovan', - contractAddress: getSavingsConstants(ChainId.Kovan).AAVE || ZERO_ADDRESS, - }, - ] - public readonly DEFAULT_APR = '0.17' - public getFungibleTokenDetails(chainId: ChainId): FungibleTokenDetailed { - let contractAddress = '' + public availableNetworks: SavingsNetwork[] = [] - for (const network of this.availableNetworks) { - if (network.chainId === chainId) { - contractAddress = network.contractAddress - } - } + public constructor( + public category = ProtocolCategory.ETH, + public type = ProtocolType.AAVE, + public name = 'AAVE', + public symbol = 'AAVE', + public image = 'aave', + public base = 'AAVE', // Used as key in savings.json + public pair = 'aAAVE', + public decimals = 18, + public underLyingAssetName = 'AAVE Interest Bearing AAVE', + public logoURI: string[] = ['https://tokens.1inch.io/0xffc97d72e13e01096502cb8eb52dee56f74dad7b.png'], + ) { + // this.constants = getSavingsConstants(chainId) + + this.availableNetworks = [ + { + chainId: ChainId.Mainnet, + chainName: 'Ethereum', + contractAddress: (getSavingsConstants(ChainId.Mainnet) as any)[this.base] || ZERO_ADDRESS, + }, + { + chainId: ChainId.Kovan, + chainName: 'Kovan', + contractAddress: (getSavingsConstants(ChainId.Kovan) as any)[this.base] || ZERO_ADDRESS, + }, + ] + } + public getFungibleTokenDetails(chainId: ChainId): FungibleTokenDetailed { return { type: 1, chainId: chainId, - address: contractAddress, - symbol: 'aAAVE', - decimals: 18, - name: 'AAVE Interest Bearing AAVE', - logoURI: ['https://tokens.1inch.io/0xffc97d72e13e01096502cb8eb52dee56f74dad7b.png'], + address: (getSavingsConstants(chainId) as any)[this.base], + symbol: this.symbol, + decimals: this.decimals, + name: this.underLyingAssetName, + logoURI: this.logoURI, } } - public async getApr(chainId?: ChainId) { + public async getApr(chainId: ChainId) { try { - const subgraphUrl = getSavingsConstants(chainId ?? ChainId.Kovan).AAVE_SUBGRAPHS || '' + const subgraphUrl = getSavingsConstants(chainId).AAVE_SUBGRAPHS || '' const body = JSON.stringify({ query: `{ reserves (where: { - underlyingAsset: "${getSavingsConstants(chainId ?? ChainId.Kovan).AAVE || ZERO_ADDRESS}" + underlyingAsset: "${(getSavingsConstants(chainId) as any)[this.base] || ZERO_ADDRESS}" }) { id name @@ -123,8 +135,9 @@ export class AAVEProtocol implements SavingsProtocol { const RAY = pow10(27) // 10 to the power 27 const SECONDS_PER_YEAR = 31536000 + // APY and APR are returned here as decimals, multiply by 100 to get the percents - const apr = liquidityRate / RAY + const apr = new BigNumber(liquidityRate).div(RAY) this.apr = apr.toFixed(2) return apr.toFixed(2) } catch (error) { @@ -137,11 +150,11 @@ export class AAVEProtocol implements SavingsProtocol { public async getBalance(chainId: ChainId, web3: Web3, account: string) { try { - const subgraphUrl = getSavingsConstants(chainId ?? ChainId.Kovan).AAVE_SUBGRAPHS || '' + const subgraphUrl = getSavingsConstants(chainId).AAVE_SUBGRAPHS || '' const reserveBody = JSON.stringify({ query: `{ reserves (where: { - underlyingAsset: "${getSavingsConstants(chainId ?? ChainId.Kovan).AAVE || ZERO_ADDRESS}" + underlyingAsset: "${(getSavingsConstants(chainId) as any)[this.base] || ZERO_ADDRESS}" }) { id name @@ -219,7 +232,7 @@ export class AAVEProtocol implements SavingsProtocol { public async depositEstimate(account: string, chainId: ChainId, web3: Web3, value: BigNumber.Value) { try { const operation = await this.createDepositTokenOperation(account, chainId, web3, value) - const gasEstimate = await operation.estimateGas({ + const gasEstimate = await operation?.estimateGas({ from: account, }) @@ -247,7 +260,7 @@ export class AAVEProtocol implements SavingsProtocol { AaveLendingPoolABI as AbiItem[], ) return contract?.methods.deposit( - getSavingsConstants(chainId).AAVE || ZERO_ADDRESS, + (getSavingsConstants(chainId) as any)[this.base] || ZERO_ADDRESS, value.toString(), account, '0', @@ -258,11 +271,14 @@ export class AAVEProtocol implements SavingsProtocol { try { const gasEstimate = await this.depositEstimate(account, chainId, web3, value) const operation = await this.createDepositTokenOperation(account, chainId, web3, value) - await operation.send({ - from: account, - gas: gasEstimate.toNumber(), - }) - return true + if (operation) { + await operation.send({ + from: account, + gas: gasEstimate.toNumber(), + }) + return true + } + return false } catch (error) { console.error('AAVE `deposit()` Error', error) return false @@ -285,7 +301,7 @@ export class AAVEProtocol implements SavingsProtocol { AaveLendingPoolABI as AbiItem[], ) const gasEstimate = await contract?.methods - .withdraw(getSavingsConstants(chainId).AAVE || ZERO_ADDRESS, value.toString(), account) + .withdraw((getSavingsConstants(chainId) as any)[this.base] || ZERO_ADDRESS, value.toString(), account) .estimateGas({ from: account, }) @@ -313,7 +329,7 @@ export class AAVEProtocol implements SavingsProtocol { AaveLendingPoolABI as AbiItem[], ) await contract?.methods - .withdraw(getSavingsConstants(chainId).AAVE || ZERO_ADDRESS, value.toString(), account) + .withdraw((getSavingsConstants(chainId) as any)[this.base] || ZERO_ADDRESS, value.toString(), account) .send({ from: account, gas: gasEstimate.toNumber(), From f92a3696dab2cb79a4bb92f783441efa1fdccc2b Mon Sep 17 00:00:00 2001 From: layinka Date: Sun, 27 Feb 2022 19:48:50 +0100 Subject: [PATCH 07/38] Update packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts Co-authored-by: guanbinrui <52657989+guanbinrui@users.noreply.github.com> --- packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts b/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts index 65fe2897fc65..1e67ad883386 100644 --- a/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts +++ b/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts @@ -63,7 +63,7 @@ export class AAVEProtocol implements SavingsProtocol { public name = 'AAVE', public symbol = 'AAVE', public image = 'aave', - public base = 'AAVE', // Used as key in savings.json + public base: keyof Savings = 'AAVE', public pair = 'aAAVE', public decimals = 18, public underLyingAssetName = 'AAVE Interest Bearing AAVE', From f29864e7eea99d22fc960b5f5812703ddc10957c Mon Sep 17 00:00:00 2001 From: "@layinka" Date: Sun, 27 Feb 2022 20:03:39 +0100 Subject: [PATCH 08/38] refactor AaveContracts --- .../plugins/Savings/protocols/AAVEProtocol.ts | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts b/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts index 1e67ad883386..a1d8629d999b 100644 --- a/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts +++ b/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts @@ -87,7 +87,7 @@ export class AAVEProtocol implements SavingsProtocol { public getFungibleTokenDetails(chainId: ChainId): FungibleTokenDetailed { return { - type: 1, + type: EthereumTokenType.ERC20, chainId: chainId, address: (getSavingsConstants(chainId) as any)[this.base], symbol: this.symbol, @@ -100,6 +100,11 @@ export class AAVEProtocol implements SavingsProtocol { public async getApr(chainId: ChainId) { try { const subgraphUrl = getSavingsConstants(chainId).AAVE_SUBGRAPHS || '' + if (!subgraphUrl) { + this.apr = this.DEFAULT_APR + return this.apr + } + const body = JSON.stringify({ query: `{ reserves (where: { @@ -239,7 +244,7 @@ export class AAVEProtocol implements SavingsProtocol { return new BigNumber(gasEstimate || 0) } catch (error) { console.error('AAVE `depositEstimate()` Error', error) - return new BigNumber(0) + return ZERO } } @@ -261,7 +266,7 @@ export class AAVEProtocol implements SavingsProtocol { ) return contract?.methods.deposit( (getSavingsConstants(chainId) as any)[this.base] || ZERO_ADDRESS, - value.toString(), + new BigNumber(value).toFixed(), account, '0', ) @@ -301,14 +306,18 @@ export class AAVEProtocol implements SavingsProtocol { AaveLendingPoolABI as AbiItem[], ) const gasEstimate = await contract?.methods - .withdraw((getSavingsConstants(chainId) as any)[this.base] || ZERO_ADDRESS, value.toString(), account) + .withdraw( + (getSavingsConstants(chainId) as any)[this.base] || ZERO_ADDRESS, + new BigNumber(value).toFixed(), + account, + ) .estimateGas({ from: account, }) return new BigNumber(gasEstimate || 0) } catch (error) { console.error('AAVE `withdrawEstimate()` Error', error) - return new BigNumber(0) + return ZERO } } @@ -329,7 +338,11 @@ export class AAVEProtocol implements SavingsProtocol { AaveLendingPoolABI as AbiItem[], ) await contract?.methods - .withdraw((getSavingsConstants(chainId) as any)[this.base] || ZERO_ADDRESS, value.toString(), account) + .withdraw( + (getSavingsConstants(chainId) as any)[this.base] || ZERO_ADDRESS, + new BigNumber(value).toFixed(), + account, + ) .send({ from: account, gas: gasEstimate.toNumber(), From 80b6239a2dff446e9cc77abfb4e4a7350baf01c4 Mon Sep 17 00:00:00 2001 From: "@layinka" Date: Tue, 1 Mar 2022 14:40:43 +0100 Subject: [PATCH 09/38] add aave coins --- .../mask/src/plugins/Savings/constants.ts | 220 ++++++++++++++++++ .../plugins/Savings/protocols/AAVEProtocol.ts | 18 +- 2 files changed, 237 insertions(+), 1 deletion(-) diff --git a/packages/mask/src/plugins/Savings/constants.ts b/packages/mask/src/plugins/Savings/constants.ts index b6e77632bb66..f42e7b1fb12e 100644 --- a/packages/mask/src/plugins/Savings/constants.ts +++ b/packages/mask/src/plugins/Savings/constants.ts @@ -1,2 +1,222 @@ export const SAVINGS_PLUGIN_NAME = 'Savings' export const SAVINGS_PLUGIN_ID = 'com.savings' + +export const AAVE_PAIRS = [ + { + name: 'USDT', + pair: 'aUSDT', + decimals: 6, + underLyingAssetName: 'aUSDT', + logoURI: ['https://tokens.1inch.io/0xdac17f958d2ee523a2206206994597c13d831ec7.png'], + }, + { + name: 'WBTC', + pair: 'aWBTC', + decimals: 8, + underLyingAssetName: 'aWBTC', + logoURI: ['https://tokens.1inch.io/0x2260fac5e5542a773aa44fbcfedf7c193bc2c599.png'], + }, + { + name: 'WETH', + pair: 'aWETH', + decimals: 18, + underLyingAssetName: 'aWETH', + logoURI: ['https://tokens.1inch.io/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png'], + }, + { + name: 'YFI', + pair: 'aYFI', + decimals: 18, + underLyingAssetName: 'aYFI', + logoURI: ['https://tokens.1inch.io/0x0bc529c00c6401aef6d220be8c6ea1667f6ad93e.png'], + }, + { + name: 'ZRX', + pair: 'aZRX', + decimals: 18, + underLyingAssetName: 'aZRX', + logoURI: ['https://tokens.1inch.io/0xe41d2489571d322189246dafa5ebde1f4699f498.png'], + }, + { + name: 'UNI', + pair: 'aUNI', + decimals: 18, + underLyingAssetName: 'aUNI', + logoURI: ['https://tokens.1inch.io/0x1f9840a85d5af5bf1d1762f925bdaddc4201f984.png'], + }, + { + name: 'AAVE', + pair: 'aAAVE', + decimals: 18, + underLyingAssetName: 'aAAVE', + logoURI: ['https://tokens.1inch.io/0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9.png'], + }, + { + name: 'BAT', + pair: 'aBAT', + decimals: 18, + underLyingAssetName: 'aBAT', + logoURI: ['https://tokens.1inch.io/0x0d8775f648430679a709e98d2b0cb6250d2887ef.png'], + }, + { + name: 'BUSD', + pair: 'aBUSD', + decimals: 18, + underLyingAssetName: 'aBUSD', + logoURI: ['https://tokens.1inch.io/0x4fabb145d64652a948d72533023f6e7a623c7c53.png'], + }, + { + name: 'DAI', + pair: 'aDAI', + decimals: 18, + underLyingAssetName: 'aDAI', + logoURI: ['https://tokens.1inch.io/0x6b175474e89094c44da98b954eedeac495271d0f.png'], + }, + { + name: 'ENJ', + pair: 'aENJ', + decimals: 18, + underLyingAssetName: 'aENJ', + logoURI: ['https://tokens.1inch.io/0xf629cbd94d3791c9250152bd8dfbdf380e2a3b9c.png'], + }, + { + name: 'KNC', + pair: 'aKNC', + decimals: 18, + underLyingAssetName: 'aKNC', + logoURI: ['https://tokens.1inch.io/0xdd974d5c2e2928dea5f71b9825b8b646686bd200.png'], + }, + { + name: 'LINK', + pair: 'aLINK', + decimals: 18, + underLyingAssetName: 'aLINK', + logoURI: ['https://tokens.1inch.io/0x514910771af9ca656af840dff83e8264ecf986ca.png'], + }, + { + name: 'MANA', + pair: 'aMANA', + decimals: 18, + underLyingAssetName: 'aMANA', + logoURI: ['https://tokens.1inch.io/0x0f5d2fb29fb7d3cfee444a200298f468908cc942.png'], + }, + { + name: 'MKR', + pair: 'aMKR', + decimals: 18, + underLyingAssetName: 'aMKR', + logoURI: ['https://tokens.1inch.io/0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2.png'], + }, + { + name: 'REN', + pair: 'aREN', + decimals: 18, + underLyingAssetName: 'aREN', + logoURI: ['https://tokens.1inch.io/0x408e41876cccdc0f92210600ef50372656052a38.png'], + }, + { + name: 'SNX', + pair: 'aSNX', + decimals: 18, + underLyingAssetName: 'aSNX', + logoURI: ['https://tokens.1inch.io/0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f.png'], + }, + { + name: 'sUSD', + pair: 'aSUSD', + decimals: 18, + underLyingAssetName: 'aSUSD', + logoURI: ['https://tokens.1inch.io/0x57ab1ec28d129707052df4df418d58a2d46d5f51.png'], + }, + { + name: 'TUSD', + pair: 'aTUSD', + decimals: 18, + underLyingAssetName: 'aTUSD', + logoURI: ['https://tokens.1inch.io/0x0000000000085d4780b73119b644ae5ecd22b376.png'], + }, + { + name: 'USDC', + pair: 'aUSDC', + decimals: 6, + underLyingAssetName: 'aUSDC', + logoURI: ['https://tokens.1inch.io/0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48.png'], + }, + { + name: 'CRV', + pair: 'aCRV', + decimals: 18, + underLyingAssetName: 'aCRV', + logoURI: ['https://tokens.1inch.io/0xd533a949740bb3306d119cc777fa900ba034cd52.png'], + }, + { + name: 'GUSD', + pair: 'aGUSD', + decimals: 2, + underLyingAssetName: 'aGUSD', + logoURI: ['https://tokens.1inch.io/0x056fd409e1d7a124bd7017459dfea2f387b6d5cd.png'], + }, + { + name: 'BAL', + pair: 'aBAL', + decimals: 18, + underLyingAssetName: 'aBAL', + logoURI: ['https://tokens.1inch.io/0xba100000625a3754423978a60c9317c58a424e3d.png'], + }, + { + name: 'xSUSHI', + pair: 'aXSUSHI', + decimals: 18, + underLyingAssetName: 'aXSUSHI', + logoURI: ['https://tokens.1inch.io/0x8798249c2e607446efb7ad49ec89dd1865ff4272.png'], + }, + { + name: 'renFIL', + pair: 'aRENFIL', + decimals: 18, + underLyingAssetName: 'aRENFIL', + logoURI: ['https://tokens.1inch.io/0xd5147bc8e386d91cc5dbe72099dac6c9b99276f5.png'], + }, + { + name: 'RAI', + pair: 'aRAI', + decimals: 18, + underLyingAssetName: 'aRAI', + logoURI: ['https://tokens.1inch.io/0x03ab458634910aad20ef5f1c8ee96f1d6ac54919.png'], + }, + { + name: 'AMPL', + pair: 'aAMPL', + decimals: 9, + underLyingAssetName: 'aAMPL', + logoURI: ['https://tokens.1inch.io/0xd46ba6d942050d489dbd938a2c909a5d5039a161.png'], + }, + { + name: 'USDP', + pair: 'aUSDP', + decimals: 18, + underLyingAssetName: 'aUSDP', + logoURI: ['https://tokens.1inch.io/0x8e870d67f660d95d5be530380d0ec0bd388289e1.png'], + }, + { + name: 'DPI', + pair: 'aDPI', + decimals: 18, + underLyingAssetName: 'aDPI', + logoURI: ['https://tokens.1inch.io/0x1494ca1f11d487c2bbe4543e90080aeba4ba3c2b.png'], + }, + { + name: 'FRAX', + pair: 'aFRAX', + decimals: 18, + underLyingAssetName: 'aFRAX', + logoURI: ['https://tokens.1inch.io/0x853d955acef822db058eb8505911ed77f175b99e.png'], + }, + { + name: 'FEI', + pair: 'aFEI', + decimals: 18, + underLyingAssetName: 'aFEI', + logoURI: ['https://tokens.1inch.io/0x956f47f50a910163d8bf957cf5846d573e7f87ca.png'], + }, +] diff --git a/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts b/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts index a1d8629d999b..cef7a13f4ddc 100644 --- a/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts +++ b/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts @@ -16,6 +16,8 @@ import AaveLendingPoolABI from '@masknet/web3-contracts/abis/AaveLendingPool.jso import BigNumber from 'bignumber.js' import { ProtocolCategory, SavingsNetwork, SavingsProtocol, ProtocolType } from '../types' import { pow10, ZERO } from '@masknet/web3-shared-base' +import Savings from '@masknet/web3-constants/evm/savings.json' +import { AAVE_PAIRS } from '../constants' export interface ContractListArray { [index: string]: { @@ -355,4 +357,18 @@ export class AAVEProtocol implements SavingsProtocol { } } -export default new AAVEProtocol() +export default AAVE_PAIRS.map( + (p) => + new AAVEProtocol( + ProtocolCategory.ETH, + ProtocolType.AAVE, + p.name, + p.name, + p.name.toLowerCase(), + p.name, + p.pair, + p.decimals, + p.underLyingAssetName, + p.logoURI, + ), +) From 4e016d2a53222b1d696c69a55be62626cd6d2dce Mon Sep 17 00:00:00 2001 From: "@layinka" Date: Tue, 1 Mar 2022 14:45:40 +0100 Subject: [PATCH 10/38] refactor --- .../plugins/Savings/protocols/AAVEProtocol.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts b/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts index cef7a13f4ddc..b30942f13a75 100644 --- a/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts +++ b/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts @@ -77,12 +77,12 @@ export class AAVEProtocol implements SavingsProtocol { { chainId: ChainId.Mainnet, chainName: 'Ethereum', - contractAddress: (getSavingsConstants(ChainId.Mainnet) as any)[this.base] || ZERO_ADDRESS, + contractAddress: getSavingsConstants(ChainId.Mainnet)[this.base] || ZERO_ADDRESS, }, { chainId: ChainId.Kovan, chainName: 'Kovan', - contractAddress: (getSavingsConstants(ChainId.Kovan) as any)[this.base] || ZERO_ADDRESS, + contractAddress: getSavingsConstants(ChainId.Kovan)[this.base] || ZERO_ADDRESS, }, ] } @@ -91,7 +91,7 @@ export class AAVEProtocol implements SavingsProtocol { return { type: EthereumTokenType.ERC20, chainId: chainId, - address: (getSavingsConstants(chainId) as any)[this.base], + address: getSavingsConstants(chainId)[this.base], symbol: this.symbol, decimals: this.decimals, name: this.underLyingAssetName, @@ -110,7 +110,7 @@ export class AAVEProtocol implements SavingsProtocol { const body = JSON.stringify({ query: `{ reserves (where: { - underlyingAsset: "${(getSavingsConstants(chainId) as any)[this.base] || ZERO_ADDRESS}" + underlyingAsset: "${getSavingsConstants(chainId)[this.base] || ZERO_ADDRESS}" }) { id name @@ -161,7 +161,7 @@ export class AAVEProtocol implements SavingsProtocol { const reserveBody = JSON.stringify({ query: `{ reserves (where: { - underlyingAsset: "${(getSavingsConstants(chainId) as any)[this.base] || ZERO_ADDRESS}" + underlyingAsset: "${getSavingsConstants(chainId)[this.base] || ZERO_ADDRESS}" }) { id name @@ -267,7 +267,7 @@ export class AAVEProtocol implements SavingsProtocol { AaveLendingPoolABI as AbiItem[], ) return contract?.methods.deposit( - (getSavingsConstants(chainId) as any)[this.base] || ZERO_ADDRESS, + getSavingsConstants(chainId)[this.base] || ZERO_ADDRESS, new BigNumber(value).toFixed(), account, '0', @@ -309,7 +309,7 @@ export class AAVEProtocol implements SavingsProtocol { ) const gasEstimate = await contract?.methods .withdraw( - (getSavingsConstants(chainId) as any)[this.base] || ZERO_ADDRESS, + getSavingsConstants(chainId)[this.base] || ZERO_ADDRESS, new BigNumber(value).toFixed(), account, ) @@ -341,7 +341,7 @@ export class AAVEProtocol implements SavingsProtocol { ) await contract?.methods .withdraw( - (getSavingsConstants(chainId) as any)[this.base] || ZERO_ADDRESS, + getSavingsConstants(chainId)[this.base] || ZERO_ADDRESS, new BigNumber(value).toFixed(), account, ) From 356f8446687138e17863bda820958fc47bcb2bee Mon Sep 17 00:00:00 2001 From: layinka Date: Wed, 2 Mar 2022 08:07:59 +0100 Subject: [PATCH 11/38] Update packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts Co-authored-by: guanbinrui <52657989+guanbinrui@users.noreply.github.com> --- packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts b/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts index b30942f13a75..55dbfb293034 100644 --- a/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts +++ b/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts @@ -71,8 +71,6 @@ export class AAVEProtocol implements SavingsProtocol { public underLyingAssetName = 'AAVE Interest Bearing AAVE', public logoURI: string[] = ['https://tokens.1inch.io/0xffc97d72e13e01096502cb8eb52dee56f74dad7b.png'], ) { - // this.constants = getSavingsConstants(chainId) - this.availableNetworks = [ { chainId: ChainId.Mainnet, From c13238ab0da77a1e2fdd9aa56f550a08273d826a Mon Sep 17 00:00:00 2001 From: layinka Date: Wed, 2 Mar 2022 08:08:13 +0100 Subject: [PATCH 12/38] Update packages/mask/src/plugins/Savings/protocols/index.ts Co-authored-by: guanbinrui <52657989+guanbinrui@users.noreply.github.com> --- packages/mask/src/plugins/Savings/protocols/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mask/src/plugins/Savings/protocols/index.ts b/packages/mask/src/plugins/Savings/protocols/index.ts index ddf92b78e92f..a7a3d54e92f5 100644 --- a/packages/mask/src/plugins/Savings/protocols/index.ts +++ b/packages/mask/src/plugins/Savings/protocols/index.ts @@ -2,4 +2,4 @@ import type { SavingsProtocol } from '../types' import LidoProtocol from './LDOProtocol' import AAVEProtocol from './AAVEProtocol' -export const SavingsProtocols: SavingsProtocol[] = [LidoProtocol, AAVEProtocol] +export const SavingsProtocols: SavingsProtocol[] = [LidoProtocol, ...AAVEProtocols] From 9ac3b791ffc9caafa17e27db05bd409cccadf7ed Mon Sep 17 00:00:00 2001 From: guanbinrui Date: Thu, 3 Mar 2022 15:28:05 +0800 Subject: [PATCH 13/38] refactor: lido to use new protocol --- packages/mask/package.json | 1 + .../plugins/Savings/SNSAdaptor/IconURL.tsx | 9 +- .../Savings/SNSAdaptor/SavingsDialog.tsx | 37 +- .../Savings/SNSAdaptor/SavingsForm.tsx | 52 +- .../Savings/SNSAdaptor/SavingsTable.tsx | 126 +- .../mask/src/plugins/Savings/constants.ts | 9 + .../plugins/Savings/protocols/AAVEProtocol.ts | 27 +- .../plugins/Savings/protocols/LDOProtocol.ts | 114 +- .../src/plugins/Savings/protocols/index.ts | 7 +- packages/mask/src/plugins/Savings/types.ts | 56 +- packages/web3-constants/evm/savings.json | 43 +- packages/web3-constants/evm/token.json | 23 + .../web3-contracts/abis/AaveLendingPool.json | 2154 ++++++++--------- .../abis/AaveLendingPoolAddressProvider.json | 949 ++++---- .../abis/AaveProtocolDataProvider.json | 591 +++-- .../abis/AaveStableDebtToken.json | 643 +++-- .../web3-contracts/types/AaveLendingPool.d.ts | 757 +++--- .../types/AaveLendingPoolAddressProvider.d.ts | 461 ++-- .../types/AaveProtocolDataProvider.d.ts | 202 +- .../types/AaveStableDebtToken.d.ts | 207 +- pnpm-lock.yaml | 8 +- 21 files changed, 3114 insertions(+), 3362 deletions(-) diff --git a/packages/mask/package.json b/packages/mask/package.json index 7e41746e9210..6d0a95263a08 100644 --- a/packages/mask/package.json +++ b/packages/mask/package.json @@ -33,6 +33,7 @@ "@masknet/shared-base": "workspace:*", "@masknet/theme": "workspace:*", "@masknet/web3-contracts": "workspace:*", + "@masknet/web3-constants": "workspace:*", "@masknet/web3-providers": "workspace:*", "@masknet/web3-shared-base": "workspace:*", "@masknet/web3-shared-evm": "workspace:*", diff --git a/packages/mask/src/plugins/Savings/SNSAdaptor/IconURL.tsx b/packages/mask/src/plugins/Savings/SNSAdaptor/IconURL.tsx index 8a050b94820b..718a431cd33c 100644 --- a/packages/mask/src/plugins/Savings/SNSAdaptor/IconURL.tsx +++ b/packages/mask/src/plugins/Savings/SNSAdaptor/IconURL.tsx @@ -1,5 +1,6 @@ -export const IconURLs: Readonly> = { - lido: new URL('./assets/lido.png', import.meta.url).toString(), - eth: new URL('./assets/eth.png', import.meta.url).toString(), - aave: new URL('./assets/aave.png', import.meta.url).toString(), +import { ProtocolType } from '../types' + +export const ProviderIconURLs: Record = { + [ProtocolType.Lido]: new URL('./assets/lido.png', import.meta.url).toString(), + [ProtocolType.AAVE]: new URL('./assets/aave.png', import.meta.url).toString(), } diff --git a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsDialog.tsx b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsDialog.tsx index efeab7b60eb3..36693954e23c 100644 --- a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsDialog.tsx +++ b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsDialog.tsx @@ -1,8 +1,8 @@ -import { useState, useMemo } from 'react' +import { useState } from 'react' import { useAsync } from 'react-use' import { Typography, DialogContent } from '@mui/material' -import { ChainId, getChainIdFromNetworkType, useChainId } from '@masknet/web3-shared-evm' import { isDashboardPage } from '@masknet/shared-base' +import { ChainId, getChainIdFromNetworkType, useChainId } from '@masknet/web3-shared-evm' import { useI18N } from '../../../utils' import { EMPTY_LIST } from '../../../../utils-pure' import { InjectedDialog } from '../../../components/shared/InjectedDialog' @@ -12,20 +12,20 @@ import { TargetChainIdContext } from '../../Trader/trader/useTargetChainIdContex import { FolderTabPanel, FolderTabs } from '@masknet/theme' import { NetworkTab } from '../../../components/shared/NetworkTab' import { WalletRPC } from '../../Wallet/messages' -import { ProtocolCategory, ProtocolType, TabType } from '../types' -import { SavingsProtocols } from '../protocols' +import { ProtocolType, SavingsProtocol, TabType } from '../types' import { useStyles } from './SavingsDialogStyles' import { SavingsTable } from './SavingsTable' import { SavingsForm } from './SavingsForm' -interface SavingsDialogProps { +export interface SavingsDialogProps { open: boolean + protocols: SavingsProtocol[] onClose?: () => void onSwapDialogOpen?: () => void } -export function SavingsDialog({ open, onClose, onSwapDialogOpen }: SavingsDialogProps) { +export function SavingsDialog({ open, protocols, onClose, onSwapDialogOpen }: SavingsDialogProps) { const { t } = useI18N() const isDashboard = isDashboardPage() const { classes } = useStyles({ isDashboard }) @@ -40,34 +40,19 @@ export function SavingsDialog({ open, onClose, onSwapDialogOpen }: SavingsDialog return networks.map((network) => getChainIdFromNetworkType(network)) }, []) - const mappableProtocols = useMemo(() => { - return Object.keys(ProtocolCategory) - .map((category) => ({ - category, - protocols: SavingsProtocols.filter( - (protocol) => protocol.category.toLowerCase() === category.toLowerCase(), - ), - })) - .filter((categorizedProtocol) => - categorizedProtocol.protocols.some(({ availableNetworks }) => - availableNetworks.some((network) => network.chainId === chainId), - ), - ) - }, [chainId]) - return ( { if (selectedProtocol === null) { onClose?.() } else { setSelectedProtocol(null) } - }} - title={t('plugin_savings')}> + }}> {!isDashboard ? (
@@ -86,7 +71,7 @@ export function SavingsDialog({ open, onClose, onSwapDialogOpen }: SavingsDialog />
- {mappableProtocols.length === 0 ? ( + {protocols.length === 0 ? ( {t('plugin_no_protocol_available')} @@ -96,7 +81,7 @@ export function SavingsDialog({ open, onClose, onSwapDialogOpen }: SavingsDialog @@ -105,7 +90,7 @@ export function SavingsDialog({ open, onClose, onSwapDialogOpen }: SavingsDialog diff --git a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsForm.tsx b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsForm.tsx index 893430dc27ee..51745fd8d975 100644 --- a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsForm.tsx +++ b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsForm.tsx @@ -1,8 +1,9 @@ -import BigNumber from 'bignumber.js' -import { Typography } from '@mui/material' import { useState, useMemo } from 'react' import { useAsync } from 'react-use' +import BigNumber from 'bignumber.js' +import { Typography } from '@mui/material' import { unreachable } from '@dimensiondev/kit' +import { isLessThan, rightShift } from '@masknet/web3-shared-base' import { EthereumTokenType, useNativeTokenDetailed, @@ -16,10 +17,9 @@ import { TokenAmountPanel, FormattedCurrency, LoadingAnimation } from '@masknet/ import { useTokenPrice } from '../../Wallet/hooks/useTokenPrice' import { useI18N } from '../../../utils' import { useStyles } from './SavingsFormStyles' -import { IconURLs } from './IconURL' +import { ProviderIconURLs } from './IconURL' import { TabType, ProtocolType } from '../types' import { SavingsProtocols } from '../protocols' -import { isLessThan, rightShift } from '@masknet/web3-shared-base' import { EthereumWalletConnectedBoundary } from '../../../web3/UI/EthereumWalletConnectedBoundary' import { EthereumChainBoundary } from '../../../web3/UI/EthereumChainBoundary' import { ActionButtonPromise } from '../../../extension/options-page/DashboardComponents/ActionButton' @@ -37,7 +37,6 @@ export function SavingsForm({ chainId, selectedProtocol, tab, onClose, onSwapDia const { t } = useI18N() const { classes } = useStyles() const protocol = SavingsProtocols[selectedProtocol] - const targetChainId = chainId const { value: nativeTokenDetailed } = useNativeTokenDetailed() const web3 = useWeb3({ chainId }) @@ -47,7 +46,7 @@ export function SavingsForm({ chainId, selectedProtocol, tab, onClose, onSwapDia const [estimatedGas, setEstimatedGas] = useState(new BigNumber('0')) const [loading, setLoading] = useState(false) - const { value: nativeTokenBalance } = useFungibleTokenBalance(EthereumTokenType.Native, '', targetChainId) + const { value: nativeTokenBalance } = useFungibleTokenBalance(EthereumTokenType.Native, '', chainId) // #region form variables const tokenAmount = useMemo(() => new BigNumber(rightShift(inputAmount || '0', 18)), [inputAmount]) @@ -59,14 +58,19 @@ export function SavingsForm({ chainId, selectedProtocol, tab, onClose, onSwapDia useAsync(async () => { if (!(inputAsBN.toNumber() > 0)) return - setLoading(true) - const gasEstimate = - tab === TabType.Deposit - ? await protocol.depositEstimate(account, targetChainId, web3, inputAsBN) - : await protocol.withdrawEstimate(account, targetChainId, web3, inputAsBN) - setEstimatedGas(gasEstimate) - setLoading(false) - }, [protocol, chainId, inputAmount]) + try { + setLoading(true) + setEstimatedGas( + tab === TabType.Deposit + ? await protocol.depositEstimate(account, chainId, web3, inputAsBN) + : await protocol.withdrawEstimate(account, chainId, web3, inputAsBN), + ) + } catch { + // do nothing + } finally { + setLoading(false) + } + }, [chainId, tab, protocol, inputAsBN]) // #endregion // #region form validation @@ -76,7 +80,7 @@ export function SavingsForm({ chainId, selectedProtocol, tab, onClose, onSwapDia if (isLessThan(balanceAsBN.minus(estimatedGas), tokenAmount)) { return t('plugin_trader_error_insufficient_balance', { - symbol: tab === TabType.Deposit ? protocol.base : protocol.pair, + symbol: tab === TabType.Deposit ? protocol.bareToken.symbol : protocol.stakeToken.symbol, }) } @@ -136,7 +140,7 @@ export function SavingsForm({ chainId, selectedProtocol, tab, onClose, onSwapDia
- + {protocol.pair} {t('plugin_savings_apr')}% @@ -145,7 +149,7 @@ export function SavingsForm({ chainId, selectedProtocol, tab, onClose, onSwapDia
{ switch (tab) { case TabType.Deposit: - if (!(await protocol.deposit(account, targetChainId, web3, tokenAmount))) { - throw new Error('Could not deposit') + if (!(await protocol.deposit(account, chainId, web3, tokenAmount))) { + throw new Error('Failed to deposit token.') } return case TabType.Withdraw: @@ -190,15 +194,15 @@ export function SavingsForm({ chainId, selectedProtocol, tab, onClose, onSwapDia case ProtocolType.Lido: dispatchTradeStore({ type: AllProviderTradeActionType.UPDATE_INPUT_TOKEN, - token: protocol.getFungibleTokenDetails(targetChainId), + token: protocol.stakeToken, }) onClose?.() onSwapDialogOpen?.() return default: - if (!(await protocol.withdraw(account, targetChainId, web3, tokenAmount))) { - throw new Error('Could not withdraw') + if (!(await protocol.withdraw(account, chainId, web3, tokenAmount))) { + throw new Error('Failed to withdraw token.') } return } diff --git a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsTable.tsx b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsTable.tsx index 6fb7685bf44d..c854dede6cb2 100644 --- a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsTable.tsx +++ b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsTable.tsx @@ -2,13 +2,12 @@ import { useAsync } from 'react-use' import { Box, Grid, Button, Typography } from '@mui/material' import { makeStyles } from '@masknet/theme' import { FormattedBalance } from '@masknet/shared' -import { useWeb3, useAccount, formatBalance } from '@masknet/web3-shared-evm' import { isZero, rightShift } from '@masknet/web3-shared-base' -import type { ChainId } from '@masknet/web3-shared-evm' -import { IconURLs } from './IconURL' +import { ChainId, useWeb3, useAccount, formatBalance } from '@masknet/web3-shared-evm' +import { ProviderIconURLs } from './IconURL' import { useI18N } from '../../../utils' -import { ProtocolType, SavingsProtocol, TabType } from '../types' import { SavingsProtocols } from '../protocols' +import { TabType, ProtocolType, SavingsProtocol } from '../types' const useStyles = makeStyles()((theme, props) => ({ containerWrap: { @@ -55,20 +54,15 @@ const useStyles = makeStyles()((theme, props) => ({ }, })) -export interface MappableProtocol { - category: string - protocols: SavingsProtocol[] -} - export interface SavingsTableProps { chainId: ChainId tab: TabType - mappableProtocols: MappableProtocol[] - setSelectedProtocol(protocol: ProtocolType): void + protocols: SavingsProtocol[] setTab(tab: TabType): void + setSelectedProtocol(protocol: ProtocolType): void } -export function SavingsTable({ chainId, tab, mappableProtocols, setSelectedProtocol, setTab }: SavingsTableProps) { +export function SavingsTable({ chainId, tab, protocols, setSelectedProtocol, setTab }: SavingsTableProps) { const { t } = useI18N() const { classes } = useStyles() @@ -78,10 +72,10 @@ export function SavingsTable({ chainId, tab, mappableProtocols, setSelectedProto // Only fetch protocol APR and Balance on chainId change useAsync(async () => { for (const protocol of SavingsProtocols) { - await protocol.getApr() - await protocol.getBalance(chainId, web3, account) + await protocol.updateApr(chainId, web3) + await protocol.updateBalance(chainId, web3, account) } - }, [chainId]) + }, [chainId, web3, account]) return ( @@ -100,68 +94,46 @@ export function SavingsTable({ chainId, tab, mappableProtocols, setSelectedProto - {mappableProtocols.map((categorizedProtocol) => { - const protocols = categorizedProtocol.protocols - if (protocols.length === 1) { - const protocol = protocols[0] - - return ( - - -
- - -
-
- {protocol.category.toUpperCase()} - - {protocol.name} - -
-
- - {protocol.apr}% - - - - - - - - - -
- ) - } else { - /* - * - * @TODO: Add mappable protocols with chevron to toggle - * currency pairs to expand and collapse as according to Figma - * - * Reference: - * https://www.figma.com/file/gVkQ67y285b4FXVV1KPThN/TwitterV1?node-id=17600%3A374185 - * - */ - return <> - } - })} + {protocols.map((protocol) => ( + + +
+ +
+
+ + {protocol.bareToken.name} + +
+
+ + {protocol.apr}% + + + + + + + + + +
+ ))}
) } diff --git a/packages/mask/src/plugins/Savings/constants.ts b/packages/mask/src/plugins/Savings/constants.ts index f42e7b1fb12e..29356b87f4f7 100644 --- a/packages/mask/src/plugins/Savings/constants.ts +++ b/packages/mask/src/plugins/Savings/constants.ts @@ -1,6 +1,15 @@ +import { ChainId, createERC20Tokens, createNativeToken, FungibleTokenDetailed } from '@masknet/web3-shared-evm' + export const SAVINGS_PLUGIN_NAME = 'Savings' export const SAVINGS_PLUGIN_ID = 'com.savings' +export const LDO_PAIRS: [FungibleTokenDetailed, FungibleTokenDetailed][] = [ + [ + createNativeToken(ChainId.Mainnet), + createERC20Tokens('LDO_ADDRESS', 'Lido DAO Token', 'LDO', 18)[ChainId.Mainnet], + ], +] + export const AAVE_PAIRS = [ { name: 'USDT', diff --git a/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts b/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts index 55dbfb293034..4f2fa6ea446f 100644 --- a/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts +++ b/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts @@ -14,9 +14,9 @@ import type { AaveLendingPoolAddressProvider } from '@masknet/web3-contracts/typ import AaveLendingPoolAddressProviderABI from '@masknet/web3-contracts/abis/AaveLendingPoolAddressProvider.json' import AaveLendingPoolABI from '@masknet/web3-contracts/abis/AaveLendingPool.json' import BigNumber from 'bignumber.js' -import { ProtocolCategory, SavingsNetwork, SavingsProtocol, ProtocolType } from '../types' +import { ProtocolCategory, SavingsNetwork, SavingsProtocol, ProtocolType, ProtocolToken } from '../types' import { pow10, ZERO } from '@masknet/web3-shared-base' -import Savings from '@masknet/web3-constants/evm/savings.json' +import type Savings from '@masknet/web3-constants/evm/savings.json' import { AAVE_PAIRS } from '../constants' export interface ContractListArray { @@ -65,7 +65,7 @@ export class AAVEProtocol implements SavingsProtocol { public name = 'AAVE', public symbol = 'AAVE', public image = 'aave', - public base: keyof Savings = 'AAVE', + public base: keyof typeof AAVE_PAIRS = 'AAVE', public pair = 'aAAVE', public decimals = 18, public underLyingAssetName = 'AAVE Interest Bearing AAVE', @@ -84,8 +84,21 @@ export class AAVEProtocol implements SavingsProtocol { }, ] } + token: ProtocolToken - public getFungibleTokenDetails(chainId: ChainId): FungibleTokenDetailed { + public bareTokenDetailed(chainId: ChainId): FungibleTokenDetailed { + return { + type: EthereumTokenType.ERC20, + chainId: chainId, + address: getSavingsConstants(chainId)[this.base], + symbol: this.symbol, + decimals: this.decimals, + name: this.underLyingAssetName, + logoURI: this.logoURI, + } + } + + public stakeTokenDetailed(chainId: ChainId): FungibleTokenDetailed { return { type: EthereumTokenType.ERC20, chainId: chainId, @@ -163,7 +176,7 @@ export class AAVEProtocol implements SavingsProtocol { }) { id name - underlyingAsset + underlyingAsset } }`, }) @@ -188,10 +201,10 @@ export class AAVEProtocol implements SavingsProtocol { // Get User Reserve const userReserveBody = JSON.stringify({ query: `{ - userReserves(where: { + userReserves(where: { user: "${account}", reserve: "${reserveId}" - + }) { id scaledATokenBalance diff --git a/packages/mask/src/plugins/Savings/protocols/LDOProtocol.ts b/packages/mask/src/plugins/Savings/protocols/LDOProtocol.ts index 4c1664fbabac..24287d92f218 100644 --- a/packages/mask/src/plugins/Savings/protocols/LDOProtocol.ts +++ b/packages/mask/src/plugins/Savings/protocols/LDOProtocol.ts @@ -1,7 +1,6 @@ import type Web3 from 'web3' import type { AbiItem } from 'web3-utils' import { - EthereumTokenType, ChainId, getSavingsConstants, createContract, @@ -11,105 +10,52 @@ import { import type { Lido } from '@masknet/web3-contracts/types/Lido' import LidoABI from '@masknet/web3-contracts/abis/Lido.json' import BigNumber from 'bignumber.js' -import { ProtocolCategory, SavingsNetwork, SavingsProtocol, ProtocolType } from '../types' +import { SavingsProtocol, ProtocolType } from '../types' +import { ZERO } from '@masknet/web3-shared-base' -export interface LidoContract { - type: EthereumTokenType - chainName: string - ldoContract: string - stEthContract: string -} +export class LidoProtocol implements SavingsProtocol { + private _apr = '0.00' + private _balance = ZERO -export const LidoContracts: { [key: number]: LidoContract } = { - [ChainId.Mainnet]: { - type: EthereumTokenType.ERC20, - chainName: 'Ethereum', - ldoContract: getSavingsConstants(ChainId.Mainnet).LIDO || ZERO_ADDRESS, - stEthContract: getSavingsConstants(ChainId.Mainnet).LIDO_STETH || ZERO_ADDRESS, - }, - [ChainId.Gorli]: { - type: EthereumTokenType.ERC20, - chainName: 'Gorli', - ldoContract: getSavingsConstants(ChainId.Gorli).LIDO || ZERO_ADDRESS, - stEthContract: getSavingsConstants(ChainId.Gorli).LIDO_STETH || ZERO_ADDRESS, - }, -} + readonly type = ProtocolType.Lido -export class LidoProtocol implements SavingsProtocol { - public category = ProtocolCategory.ETH - public type = ProtocolType.Lido - public name = 'Lido' - public image = 'lido' - public base = 'ETH' - public pair = 'stETH' - public decimals = 18 - public apr = '0.00' - public balance = new BigNumber('0') - public availableNetworks: SavingsNetwork[] = [ - { - chainId: ChainId.Mainnet, - chainName: 'Ethereum', - contractAddress: getSavingsConstants(ChainId.Mainnet).LIDO_STETH || ZERO_ADDRESS, - }, - { - chainId: ChainId.Gorli, - chainName: 'Gorli', - contractAddress: getSavingsConstants(ChainId.Gorli).LIDO_STETH || ZERO_ADDRESS, - }, - ] + constructor(public readonly pair: [FungibleTokenDetailed, FungibleTokenDetailed]) {} - public getFungibleTokenDetails(chainId: ChainId): FungibleTokenDetailed { - let contractAddress = '' + get apr() { + return this._apr + } - for (const network of this.availableNetworks) { - if (network.chainId === chainId) { - contractAddress = network.contractAddress - } - } + get balance() { + return this._balance + } - return { - type: 1, - chainId: chainId, - address: contractAddress, - symbol: 'stETH', - decimals: 18, - name: 'Liquid staked Ether 2.0', - logoURI: [ - 'https://static.debank.com/image/eth_token/logo_url/0xae7ab96520de3a18e5e111b5eaab095312d7fe84/f768023f77be7a2ea23c37f25b272048.png', - 'https://tokens.1inch.io/0xae7ab96520de3a18e5e111b5eaab095312d7fe84.png', - ], - } + get bareToken() { + return this.pair[0] + } + + get stakeToken() { + return this.pair[1] } - public async getApr() { + async updateApr(chainId: ChainId, web3: Web3): Promise { try { - const LidoAprUrl = 'https://cors.r2d2.to/?https://stake.lido.fi/api/steth-apr' - const response = await fetch(LidoAprUrl) - const apr = await response.text() - this.apr = apr - return apr - } catch (error) { - console.log('LDO `getApr()` error', error) - // Default APR is 5.30% - this.apr = '5.30' - return '5.30' + const response = await fetch('https://cors.r2d2.to/?https://stake.lido.fi/api/steth-apr') + this._apr = await response.text() + } catch { + // the default APR is 5.30% + this._apr = '5.30' } } - - public async getBalance(chainId: ChainId, web3: Web3, account: string) { + async updateBalance(chainId: ChainId, web3: Web3, account: string): Promise { try { const contract = createContract( web3, getSavingsConstants(chainId).LIDO_STETH || ZERO_ADDRESS, LidoABI as AbiItem[], ) - const balance = await contract?.methods.balanceOf(account).call() - this.balance = new BigNumber(balance || '0') - return this.balance + this._balance = new BigNumber((await contract?.methods.balanceOf(account).call()) ?? '0') } catch (error) { - console.log('LDO `getBalance()` error', error) - this.balance = new BigNumber('0') - return this.balance + this._balance = ZERO } } @@ -155,7 +101,7 @@ export class LidoProtocol implements SavingsProtocol { } public async withdrawEstimate(account: string, chainId: ChainId, web3: Web3, value: BigNumber.Value) { - return new BigNumber('0') + return ZERO } public async withdraw(account: string, chainId: ChainId, web3: Web3, value: BigNumber.Value) { @@ -176,5 +122,3 @@ export class LidoProtocol implements SavingsProtocol { return false } } - -export default new LidoProtocol() diff --git a/packages/mask/src/plugins/Savings/protocols/index.ts b/packages/mask/src/plugins/Savings/protocols/index.ts index a7a3d54e92f5..6154e861091f 100644 --- a/packages/mask/src/plugins/Savings/protocols/index.ts +++ b/packages/mask/src/plugins/Savings/protocols/index.ts @@ -1,5 +1,6 @@ +import { LDO_PAIRS } from '../constants' import type { SavingsProtocol } from '../types' -import LidoProtocol from './LDOProtocol' -import AAVEProtocol from './AAVEProtocol' +import { LidoProtocol } from './LDOProtocol' +// import AAVEProtocol from './AAVEProtocol' -export const SavingsProtocols: SavingsProtocol[] = [LidoProtocol, ...AAVEProtocols] +export const SavingsProtocols: SavingsProtocol[] = [...LDO_PAIRS.map((pair) => new LidoProtocol(pair))] diff --git a/packages/mask/src/plugins/Savings/types.ts b/packages/mask/src/plugins/Savings/types.ts index c46e6bcd717a..5dec892e7314 100644 --- a/packages/mask/src/plugins/Savings/types.ts +++ b/packages/mask/src/plugins/Savings/types.ts @@ -1,44 +1,42 @@ -import type BigNumber from 'bignumber.js' import type Web3 from 'web3' +import type BigNumber from 'bignumber.js' import type { ChainId, FungibleTokenDetailed } from '@masknet/web3-shared-evm' -export interface SavingsNetwork { - chainId: ChainId - chainName: string - contractAddress: string -} - -export enum ProtocolCategory { - ETH = 'eth', +export enum TabType { + Deposit = 'deposit', + Withdraw = 'withdraw', } export enum ProtocolType { Lido = 0, AAVE = 1, } - export interface SavingsProtocol { - category: ProtocolCategory - type: ProtocolType - name: string - image: string - base: string - pair: string - decimals: number - availableNetworks: SavingsNetwork[] - apr: string - balance: BigNumber - - getFungibleTokenDetails(chainId: ChainId): FungibleTokenDetailed - getApr(chainId?: ChainId): Promise - getBalance(chainId: ChainId, web3: Web3, account: string): Promise + readonly type: ProtocolType + + /** + * annual percentage rate + */ + readonly apr: string + + /** + * the amount of staked tokens of the latest found account + */ + readonly balance: BigNumber + + /** + * combine a bare token and a staked token with being a pair + */ + readonly pair: [FungibleTokenDetailed, FungibleTokenDetailed] + + readonly bareToken: FungibleTokenDetailed + readonly stakeToken: FungibleTokenDetailed + + updateApr(chainId: ChainId, web3: Web3): Promise + updateBalance(chainId: ChainId, web3: Web3, account: string): Promise + depositEstimate(account: string, chainId: ChainId, web3: Web3, value: BigNumber.Value): Promise deposit(account: string, chainId: ChainId, web3: Web3, value: BigNumber.Value): Promise withdrawEstimate(account: string, chainId: ChainId, web3: Web3, value: BigNumber.Value): Promise withdraw(account: string, chainId: ChainId, web3: Web3, value: BigNumber.Value): Promise } - -export enum TabType { - Deposit = 'deposit', - Withdraw = 'withdraw', -} diff --git a/packages/web3-constants/evm/savings.json b/packages/web3-constants/evm/savings.json index 4ff427d29b7d..11f809ea9f57 100644 --- a/packages/web3-constants/evm/savings.json +++ b/packages/web3-constants/evm/savings.json @@ -1,10 +1,10 @@ { - "LIDO": { - "Mainnet": "0x5A98FcBEA516Cf06857215779Fd812CA3beF1B32", + "AAVE": { + "Mainnet": "0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9", "Ropsten": "", "Rinkeby": "", - "Kovan": "", - "Gorli": "0x56340274fB5a72af1A3C6609061c451De7961Bd4", + "Kovan": "0xb597cd8d3217ea6477232f9217fa70837ff667af", + "Gorli": "", "BSC": "", "BSCT": "", "Matic": "", @@ -19,12 +19,12 @@ "Aurora": "", "Aurora_Testnet": "" }, - "LIDO_STETH": { - "Mainnet": "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84", + "LIDO": { + "Mainnet": "0x5A98FcBEA516Cf06857215779Fd812CA3beF1B32", "Ropsten": "", "Rinkeby": "", "Kovan": "", - "Gorli": "0x1643E812aE58766192Cf7D2Cf9567dF2C37e9B7F", + "Gorli": "0x56340274fB5a72af1A3C6609061c451De7961Bd4", "BSC": "", "BSCT": "", "Matic": "", @@ -39,12 +39,12 @@ "Aurora": "", "Aurora_Testnet": "" }, - "LIDO_REFERRAL_ADDRESS": { - "Mainnet": "0x278D7e418a28ff763eEeDf29238CD6dfcade3A3a", + "LIDO_STETH": { + "Mainnet": "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84", "Ropsten": "", "Rinkeby": "", "Kovan": "", - "Gorli": "0x278D7e418a28ff763eEeDf29238CD6dfcade3A3a", + "Gorli": "0x1643E812aE58766192Cf7D2Cf9567dF2C37e9B7F", "BSC": "", "BSCT": "", "Matic": "", @@ -59,13 +59,12 @@ "Aurora": "", "Aurora_Testnet": "" }, - - "AAVE_SUBGRAPHS": { - "Mainnet": "https://api.thegraph.com/subgraphs/name/aave/protocol-v2", + "LIDO_REFERRAL_ADDRESS": { + "Mainnet": "0x278D7e418a28ff763eEeDf29238CD6dfcade3A3a", "Ropsten": "", "Rinkeby": "", - "Kovan": "https://api.thegraph.com/subgraphs/name/aave/protocol-v2-kovan", - "Gorli": "", + "Kovan": "", + "Gorli": "0x278D7e418a28ff763eEeDf29238CD6dfcade3A3a", "BSC": "", "BSCT": "", "Matic": "", @@ -80,12 +79,11 @@ "Aurora": "", "Aurora_Testnet": "" }, - - "AAVE_LENDING_POOL_ADDRESSES_PROVIDER_CONTRACT_ADDRESS": { - "Mainnet": "0xb53c1a33016b2dc2ff3653530bff1848a515c8c5", + "AAVE_SUBGRAPHS": { + "Mainnet": "https://api.thegraph.com/subgraphs/name/aave/protocol-v2", "Ropsten": "", "Rinkeby": "", - "Kovan": "​​0x88757f2f99175387ab4c6a4b3067c77a695b0349", + "Kovan": "https://api.thegraph.com/subgraphs/name/aave/protocol-v2-kovan", "Gorli": "", "BSC": "", "BSCT": "", @@ -101,12 +99,11 @@ "Aurora": "", "Aurora_Testnet": "" }, - - "AAVE": { - "Mainnet": "0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9", + "AAVE_LENDING_POOL_ADDRESSES_PROVIDER_CONTRACT_ADDRESS": { + "Mainnet": "0xb53c1a33016b2dc2ff3653530bff1848a515c8c5", "Ropsten": "", "Rinkeby": "", - "Kovan": "0xb597cd8d3217ea6477232f9217fa70837ff667af", + "Kovan": "​0x88757f2f99175387ab4c6a4b3067c77a695b0349", "Gorli": "", "BSC": "", "BSCT": "", diff --git a/packages/web3-constants/evm/token.json b/packages/web3-constants/evm/token.json index f6fe2360d0d4..79f6ce3e19cd 100644 --- a/packages/web3-constants/evm/token.json +++ b/packages/web3-constants/evm/token.json @@ -19,6 +19,29 @@ "Aurora": "0xC9BdeEd33CD01541e1eeD10f90519d2C06Fe3feB", "Aurora_Testnet": "" }, + "LDO_ADDRESS": { + "Mainnet": "0x5a98fcbea516cf06857215779fd812ca3bef1b32" + }, + "LDO_stETH": { + "Mainnet": "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "0x1643E812aE58766192Cf7D2Cf9567dF2C37e9B7F", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, "USDC_ADDRESS": { "Mainnet": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", "Ropsten": "0x0D9C8723B343A8368BebE0B5E89273fF8D712e3C", diff --git a/packages/web3-contracts/abis/AaveLendingPool.json b/packages/web3-contracts/abis/AaveLendingPool.json index daa6448eb0e9..1c3250f32ba7 100644 --- a/packages/web3-contracts/abis/AaveLendingPool.json +++ b/packages/web3-contracts/abis/AaveLendingPool.json @@ -1,1079 +1,1079 @@ [ - { - "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" - } + { + "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" + } ] diff --git a/packages/web3-contracts/abis/AaveLendingPoolAddressProvider.json b/packages/web3-contracts/abis/AaveLendingPoolAddressProvider.json index f4c8b0543ad9..33baf06e9a14 100644 --- a/packages/web3-contracts/abis/AaveLendingPoolAddressProvider.json +++ b/packages/web3-contracts/abis/AaveLendingPoolAddressProvider.json @@ -1,477 +1,476 @@ [ - { - "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" - } + { + "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" + } ] - diff --git a/packages/web3-contracts/abis/AaveProtocolDataProvider.json b/packages/web3-contracts/abis/AaveProtocolDataProvider.json index c3aff397f64b..5a1f00ca2e73 100644 --- a/packages/web3-contracts/abis/AaveProtocolDataProvider.json +++ b/packages/web3-contracts/abis/AaveProtocolDataProvider.json @@ -1,298 +1,297 @@ [ - { - "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" - } + { + "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" + } ] - diff --git a/packages/web3-contracts/abis/AaveStableDebtToken.json b/packages/web3-contracts/abis/AaveStableDebtToken.json index dbc3adf3c4ce..b99658486c2e 100644 --- a/packages/web3-contracts/abis/AaveStableDebtToken.json +++ b/packages/web3-contracts/abis/AaveStableDebtToken.json @@ -1,324 +1,323 @@ [ - { - "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": "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" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "delegatee", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "approveDelegation", - "outputs": [], - "stateMutability": "nonpayable", - "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": "getAverageStableRate", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "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": "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": [ - { - "internalType": "address", - "name": "user", - "type": "address" - } - ], - "name": "principalBalanceOf", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - } + { + "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": "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" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "delegatee", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "approveDelegation", + "outputs": [], + "stateMutability": "nonpayable", + "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": "getAverageStableRate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "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": "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": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "principalBalanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } ] - diff --git a/packages/web3-contracts/types/AaveLendingPool.d.ts b/packages/web3-contracts/types/AaveLendingPool.d.ts index 47273dcf7b3e..927c8b6d8bc9 100644 --- a/packages/web3-contracts/types/AaveLendingPool.d.ts +++ b/packages/web3-contracts/types/AaveLendingPool.d.ts @@ -2,439 +2,362 @@ /* tslint:disable */ /* eslint-disable */ -import BN from "bn.js"; -import { ContractOptions } from "web3-eth-contract"; -import { EventLog } from "web3-core"; -import { EventEmitter } from "events"; +import BN from 'bn.js' +import { ContractOptions } from 'web3-eth-contract' +import { EventLog } from 'web3-core' +import { EventEmitter } from 'events' import { - Callback, - PayableTransactionObject, - NonPayableTransactionObject, - BlockType, - ContractEventLog, - BaseContract, -} from "./types"; + Callback, + PayableTransactionObject, + NonPayableTransactionObject, + BlockType, + ContractEventLog, + BaseContract, +} from './types' export interface EventOptions { - filter?: object; - fromBlock?: BlockType; - topics?: string[]; + filter?: object + fromBlock?: BlockType + topics?: string[] } export type Borrow = ContractEventLog<{ - reserve: string; - user: string; - onBehalfOf: string; - amount: string; - borrowRateMode: string; - borrowRate: string; - referral: string; - 0: string; - 1: string; - 2: string; - 3: string; - 4: string; - 5: string; - 6: string; -}>; + reserve: string + user: string + onBehalfOf: string + amount: string + borrowRateMode: string + borrowRate: string + referral: string + 0: string + 1: string + 2: string + 3: string + 4: string + 5: string + 6: string +}> export type Deposit = ContractEventLog<{ - reserve: string; - user: string; - onBehalfOf: string; - amount: string; - referral: string; - 0: string; - 1: string; - 2: string; - 3: string; - 4: string; -}>; + reserve: string + user: string + onBehalfOf: string + amount: string + referral: string + 0: string + 1: string + 2: string + 3: string + 4: string +}> export type FlashLoan = ContractEventLog<{ - target: string; - initiator: string; - asset: string; - amount: string; - premium: string; - referralCode: string; - 0: string; - 1: string; - 2: string; - 3: string; - 4: string; - 5: string; -}>; + target: string + initiator: string + asset: string + amount: string + premium: string + referralCode: string + 0: string + 1: string + 2: string + 3: string + 4: string + 5: string +}> export type LiquidationCall = ContractEventLog<{ - collateralAsset: string; - debtAsset: string; - user: string; - debtToCover: string; - liquidatedCollateralAmount: string; - liquidator: string; - receiveAToken: boolean; - 0: string; - 1: string; - 2: string; - 3: string; - 4: string; - 5: string; - 6: boolean; -}>; -export type Paused = ContractEventLog<{}>; + collateralAsset: string + debtAsset: string + user: string + debtToCover: string + liquidatedCollateralAmount: string + liquidator: string + receiveAToken: boolean + 0: string + 1: string + 2: string + 3: string + 4: string + 5: string + 6: boolean +}> +export type Paused = ContractEventLog<{}> export type RebalanceStableBorrowRate = ContractEventLog<{ - reserve: string; - user: string; - 0: string; - 1: string; -}>; + reserve: string + user: string + 0: string + 1: string +}> export type Repay = ContractEventLog<{ - reserve: string; - user: string; - repayer: string; - amount: string; - 0: string; - 1: string; - 2: string; - 3: string; -}>; + reserve: string + user: string + repayer: string + amount: string + 0: string + 1: string + 2: string + 3: string +}> export type ReserveDataUpdated = ContractEventLog<{ - reserve: string; - liquidityRate: string; - stableBorrowRate: string; - variableBorrowRate: string; - liquidityIndex: string; - variableBorrowIndex: string; - 0: string; - 1: string; - 2: string; - 3: string; - 4: string; - 5: string; -}>; + reserve: string + liquidityRate: string + stableBorrowRate: string + variableBorrowRate: string + liquidityIndex: string + variableBorrowIndex: string + 0: string + 1: string + 2: string + 3: string + 4: string + 5: string +}> export type ReserveUsedAsCollateralDisabled = ContractEventLog<{ - reserve: string; - user: string; - 0: string; - 1: string; -}>; + reserve: string + user: string + 0: string + 1: string +}> export type ReserveUsedAsCollateralEnabled = ContractEventLog<{ - reserve: string; - user: string; - 0: string; - 1: string; -}>; + reserve: string + user: string + 0: string + 1: string +}> export type Swap = ContractEventLog<{ - reserve: string; - user: string; - rateMode: string; - 0: string; - 1: string; - 2: string; -}>; -export type Unpaused = ContractEventLog<{}>; + reserve: string + user: string + rateMode: string + 0: string + 1: string + 2: string +}> +export type Unpaused = ContractEventLog<{}> export type Withdraw = ContractEventLog<{ - reserve: string; - user: string; - to: string; - amount: string; - 0: string; - 1: string; - 2: string; - 3: string; -}>; + reserve: string + user: string + to: string + amount: string + 0: string + 1: string + 2: string + 3: string +}> export interface AaveLendingPool extends BaseContract { - constructor( - jsonInterface: any[], - address?: string, - options?: ContractOptions - ): AaveLendingPool; - clone(): AaveLendingPool; - methods: { - FLASHLOAN_PREMIUM_TOTAL(): NonPayableTransactionObject; - - LENDINGPOOL_REVISION(): NonPayableTransactionObject; - - MAX_NUMBER_RESERVES(): NonPayableTransactionObject; - - MAX_STABLE_RATE_BORROW_SIZE_PERCENT(): NonPayableTransactionObject; - - borrow( - asset: string, - amount: number | string | BN, - interestRateMode: number | string | BN, - referralCode: number | string | BN, - onBehalfOf: string - ): NonPayableTransactionObject; - - deposit( - asset: string, - amount: number | string | BN, - onBehalfOf: string, - referralCode: number | string | BN - ): NonPayableTransactionObject; - - finalizeTransfer( - asset: string, - from: string, - to: string, - amount: number | string | BN, - balanceFromBefore: number | string | BN, - balanceToBefore: number | string | BN - ): NonPayableTransactionObject; - - flashLoan( - receiverAddress: string, - assets: string[], - amounts: (number | string | BN)[], - modes: (number | string | BN)[], - onBehalfOf: string, - params: string | number[], - referralCode: number | string | BN - ): NonPayableTransactionObject; - - getAddressesProvider(): NonPayableTransactionObject; - - getConfiguration(asset: string): NonPayableTransactionObject<[string]>; - - getReserveData( - asset: string - ): NonPayableTransactionObject< - [ - [string], - string, - string, - string, - string, - string, - string, - string, - string, - string, - string, - string - ] - >; - - getReserveNormalizedIncome( - asset: string - ): NonPayableTransactionObject; - - getReserveNormalizedVariableDebt( - asset: string - ): NonPayableTransactionObject; - - getReservesList(): NonPayableTransactionObject; - - getUserAccountData(user: string): NonPayableTransactionObject<{ - totalCollateralETH: string; - totalDebtETH: string; - availableBorrowsETH: string; - currentLiquidationThreshold: string; - ltv: string; - healthFactor: string; - 0: string; - 1: string; - 2: string; - 3: string; - 4: string; - 5: string; - }>; - - getUserConfiguration(user: string): NonPayableTransactionObject<[string]>; - - initReserve( - asset: string, - aTokenAddress: string, - stableDebtAddress: string, - variableDebtAddress: string, - interestRateStrategyAddress: string - ): NonPayableTransactionObject; - - initialize(provider: string): NonPayableTransactionObject; - - liquidationCall( - collateralAsset: string, - debtAsset: string, - user: string, - debtToCover: number | string | BN, - receiveAToken: boolean - ): NonPayableTransactionObject; - - paused(): NonPayableTransactionObject; - - rebalanceStableBorrowRate( - asset: string, - user: string - ): NonPayableTransactionObject; - - repay( - asset: string, - amount: number | string | BN, - rateMode: number | string | BN, - onBehalfOf: string - ): NonPayableTransactionObject; - - setConfiguration( - asset: string, - configuration: number | string | BN - ): NonPayableTransactionObject; - - setPause(val: boolean): NonPayableTransactionObject; - - setReserveInterestRateStrategyAddress( - asset: string, - rateStrategyAddress: string - ): NonPayableTransactionObject; - - setUserUseReserveAsCollateral( - asset: string, - useAsCollateral: boolean - ): NonPayableTransactionObject; - - swapBorrowRateMode( - asset: string, - rateMode: number | string | BN - ): NonPayableTransactionObject; - - withdraw( - asset: string, - amount: number | string | BN, - to: string - ): NonPayableTransactionObject; - }; - events: { - Borrow(cb?: Callback): EventEmitter; - Borrow(options?: EventOptions, cb?: Callback): EventEmitter; - - Deposit(cb?: Callback): EventEmitter; - Deposit(options?: EventOptions, cb?: Callback): EventEmitter; - - FlashLoan(cb?: Callback): EventEmitter; - FlashLoan(options?: EventOptions, cb?: Callback): EventEmitter; - - LiquidationCall(cb?: Callback): EventEmitter; - LiquidationCall( - options?: EventOptions, - cb?: Callback - ): EventEmitter; - - Paused(cb?: Callback): EventEmitter; - Paused(options?: EventOptions, cb?: Callback): EventEmitter; - - RebalanceStableBorrowRate( - cb?: Callback - ): EventEmitter; - RebalanceStableBorrowRate( - options?: EventOptions, - cb?: Callback - ): EventEmitter; - - Repay(cb?: Callback): EventEmitter; - Repay(options?: EventOptions, cb?: Callback): EventEmitter; - - ReserveDataUpdated(cb?: Callback): EventEmitter; - ReserveDataUpdated( - options?: EventOptions, - cb?: Callback - ): EventEmitter; - - ReserveUsedAsCollateralDisabled( - cb?: Callback - ): EventEmitter; - ReserveUsedAsCollateralDisabled( - options?: EventOptions, - cb?: Callback - ): EventEmitter; - - ReserveUsedAsCollateralEnabled( - cb?: Callback - ): EventEmitter; - ReserveUsedAsCollateralEnabled( - options?: EventOptions, - cb?: Callback - ): EventEmitter; - - Swap(cb?: Callback): EventEmitter; - Swap(options?: EventOptions, cb?: Callback): EventEmitter; - - Unpaused(cb?: Callback): EventEmitter; - Unpaused(options?: EventOptions, cb?: Callback): EventEmitter; - - Withdraw(cb?: Callback): EventEmitter; - Withdraw(options?: EventOptions, cb?: Callback): EventEmitter; - - allEvents(options?: EventOptions, cb?: Callback): EventEmitter; - }; - - once(event: "Borrow", cb: Callback): void; - once(event: "Borrow", options: EventOptions, cb: Callback): void; - - once(event: "Deposit", cb: Callback): void; - once(event: "Deposit", options: EventOptions, cb: Callback): void; - - once(event: "FlashLoan", cb: Callback): void; - once( - event: "FlashLoan", - options: EventOptions, - cb: Callback - ): void; - - once(event: "LiquidationCall", cb: Callback): void; - once( - event: "LiquidationCall", - options: EventOptions, - cb: Callback - ): void; - - once(event: "Paused", cb: Callback): void; - once(event: "Paused", options: EventOptions, cb: Callback): void; - - once( - event: "RebalanceStableBorrowRate", - cb: Callback - ): void; - once( - event: "RebalanceStableBorrowRate", - options: EventOptions, - cb: Callback - ): void; - - once(event: "Repay", cb: Callback): void; - once(event: "Repay", options: EventOptions, cb: Callback): void; - - once(event: "ReserveDataUpdated", cb: Callback): void; - once( - event: "ReserveDataUpdated", - options: EventOptions, - cb: Callback - ): void; - - once( - event: "ReserveUsedAsCollateralDisabled", - cb: Callback - ): void; - once( - event: "ReserveUsedAsCollateralDisabled", - options: EventOptions, - cb: Callback - ): void; - - once( - event: "ReserveUsedAsCollateralEnabled", - cb: Callback - ): void; - once( - event: "ReserveUsedAsCollateralEnabled", - options: EventOptions, - cb: Callback - ): void; - - once(event: "Swap", cb: Callback): void; - once(event: "Swap", options: EventOptions, cb: Callback): void; - - once(event: "Unpaused", cb: Callback): void; - once(event: "Unpaused", options: EventOptions, cb: Callback): void; - - once(event: "Withdraw", cb: Callback): void; - once(event: "Withdraw", options: EventOptions, cb: Callback): void; + constructor(jsonInterface: any[], address?: string, options?: ContractOptions): AaveLendingPool + clone(): AaveLendingPool + methods: { + FLASHLOAN_PREMIUM_TOTAL(): NonPayableTransactionObject + + LENDINGPOOL_REVISION(): NonPayableTransactionObject + + MAX_NUMBER_RESERVES(): NonPayableTransactionObject + + MAX_STABLE_RATE_BORROW_SIZE_PERCENT(): NonPayableTransactionObject + + borrow( + asset: string, + amount: number | string | BN, + interestRateMode: number | string | BN, + referralCode: number | string | BN, + onBehalfOf: string, + ): NonPayableTransactionObject + + deposit( + asset: string, + amount: number | string | BN, + onBehalfOf: string, + referralCode: number | string | BN, + ): NonPayableTransactionObject + + finalizeTransfer( + asset: string, + from: string, + to: string, + amount: number | string | BN, + balanceFromBefore: number | string | BN, + balanceToBefore: number | string | BN, + ): NonPayableTransactionObject + + flashLoan( + receiverAddress: string, + assets: string[], + amounts: (number | string | BN)[], + modes: (number | string | BN)[], + onBehalfOf: string, + params: string | number[], + referralCode: number | string | BN, + ): NonPayableTransactionObject + + getAddressesProvider(): NonPayableTransactionObject + + getConfiguration(asset: string): NonPayableTransactionObject<[string]> + + getReserveData( + asset: string, + ): NonPayableTransactionObject< + [[string], string, string, string, string, string, string, string, string, string, string, string] + > + + getReserveNormalizedIncome(asset: string): NonPayableTransactionObject + + getReserveNormalizedVariableDebt(asset: string): NonPayableTransactionObject + + getReservesList(): NonPayableTransactionObject + + getUserAccountData(user: string): NonPayableTransactionObject<{ + totalCollateralETH: string + totalDebtETH: string + availableBorrowsETH: string + currentLiquidationThreshold: string + ltv: string + healthFactor: string + 0: string + 1: string + 2: string + 3: string + 4: string + 5: string + }> + + getUserConfiguration(user: string): NonPayableTransactionObject<[string]> + + initReserve( + asset: string, + aTokenAddress: string, + stableDebtAddress: string, + variableDebtAddress: string, + interestRateStrategyAddress: string, + ): NonPayableTransactionObject + + initialize(provider: string): NonPayableTransactionObject + + liquidationCall( + collateralAsset: string, + debtAsset: string, + user: string, + debtToCover: number | string | BN, + receiveAToken: boolean, + ): NonPayableTransactionObject + + paused(): NonPayableTransactionObject + + rebalanceStableBorrowRate(asset: string, user: string): NonPayableTransactionObject + + repay( + asset: string, + amount: number | string | BN, + rateMode: number | string | BN, + onBehalfOf: string, + ): NonPayableTransactionObject + + setConfiguration(asset: string, configuration: number | string | BN): NonPayableTransactionObject + + setPause(val: boolean): NonPayableTransactionObject + + setReserveInterestRateStrategyAddress( + asset: string, + rateStrategyAddress: string, + ): NonPayableTransactionObject + + setUserUseReserveAsCollateral(asset: string, useAsCollateral: boolean): NonPayableTransactionObject + + swapBorrowRateMode(asset: string, rateMode: number | string | BN): NonPayableTransactionObject + + withdraw(asset: string, amount: number | string | BN, to: string): NonPayableTransactionObject + } + events: { + Borrow(cb?: Callback): EventEmitter + Borrow(options?: EventOptions, cb?: Callback): EventEmitter + + Deposit(cb?: Callback): EventEmitter + Deposit(options?: EventOptions, cb?: Callback): EventEmitter + + FlashLoan(cb?: Callback): EventEmitter + FlashLoan(options?: EventOptions, cb?: Callback): EventEmitter + + LiquidationCall(cb?: Callback): EventEmitter + LiquidationCall(options?: EventOptions, cb?: Callback): EventEmitter + + Paused(cb?: Callback): EventEmitter + Paused(options?: EventOptions, cb?: Callback): EventEmitter + + RebalanceStableBorrowRate(cb?: Callback): EventEmitter + RebalanceStableBorrowRate(options?: EventOptions, cb?: Callback): EventEmitter + + Repay(cb?: Callback): EventEmitter + Repay(options?: EventOptions, cb?: Callback): EventEmitter + + ReserveDataUpdated(cb?: Callback): EventEmitter + ReserveDataUpdated(options?: EventOptions, cb?: Callback): EventEmitter + + ReserveUsedAsCollateralDisabled(cb?: Callback): EventEmitter + ReserveUsedAsCollateralDisabled( + options?: EventOptions, + cb?: Callback, + ): EventEmitter + + ReserveUsedAsCollateralEnabled(cb?: Callback): EventEmitter + ReserveUsedAsCollateralEnabled( + options?: EventOptions, + cb?: Callback, + ): EventEmitter + + Swap(cb?: Callback): EventEmitter + Swap(options?: EventOptions, cb?: Callback): EventEmitter + + Unpaused(cb?: Callback): EventEmitter + Unpaused(options?: EventOptions, cb?: Callback): EventEmitter + + Withdraw(cb?: Callback): EventEmitter + Withdraw(options?: EventOptions, cb?: Callback): EventEmitter + + allEvents(options?: EventOptions, cb?: Callback): EventEmitter + } + + once(event: 'Borrow', cb: Callback): void + once(event: 'Borrow', options: EventOptions, cb: Callback): void + + once(event: 'Deposit', cb: Callback): void + once(event: 'Deposit', options: EventOptions, cb: Callback): void + + once(event: 'FlashLoan', cb: Callback): void + once(event: 'FlashLoan', options: EventOptions, cb: Callback): void + + once(event: 'LiquidationCall', cb: Callback): void + once(event: 'LiquidationCall', options: EventOptions, cb: Callback): void + + once(event: 'Paused', cb: Callback): void + once(event: 'Paused', options: EventOptions, cb: Callback): void + + once(event: 'RebalanceStableBorrowRate', cb: Callback): void + once(event: 'RebalanceStableBorrowRate', options: EventOptions, cb: Callback): void + + once(event: 'Repay', cb: Callback): void + once(event: 'Repay', options: EventOptions, cb: Callback): void + + once(event: 'ReserveDataUpdated', cb: Callback): void + once(event: 'ReserveDataUpdated', options: EventOptions, cb: Callback): void + + once(event: 'ReserveUsedAsCollateralDisabled', cb: Callback): void + once( + event: 'ReserveUsedAsCollateralDisabled', + options: EventOptions, + cb: Callback, + ): void + + once(event: 'ReserveUsedAsCollateralEnabled', cb: Callback): void + once( + event: 'ReserveUsedAsCollateralEnabled', + options: EventOptions, + cb: Callback, + ): void + + once(event: 'Swap', cb: Callback): void + once(event: 'Swap', options: EventOptions, cb: Callback): void + + once(event: 'Unpaused', cb: Callback): void + once(event: 'Unpaused', options: EventOptions, cb: Callback): void + + once(event: 'Withdraw', cb: Callback): void + once(event: 'Withdraw', options: EventOptions, cb: Callback): void } diff --git a/packages/web3-contracts/types/AaveLendingPoolAddressProvider.d.ts b/packages/web3-contracts/types/AaveLendingPoolAddressProvider.d.ts index 49c21652747a..1b04de4f3b88 100644 --- a/packages/web3-contracts/types/AaveLendingPoolAddressProvider.d.ts +++ b/packages/web3-contracts/types/AaveLendingPoolAddressProvider.d.ts @@ -2,308 +2,207 @@ /* tslint:disable */ /* eslint-disable */ -import BN from "bn.js"; -import { ContractOptions } from "web3-eth-contract"; -import { EventLog } from "web3-core"; -import { EventEmitter } from "events"; +import BN from 'bn.js' +import { ContractOptions } from 'web3-eth-contract' +import { EventLog } from 'web3-core' +import { EventEmitter } from 'events' import { - Callback, - PayableTransactionObject, - NonPayableTransactionObject, - BlockType, - ContractEventLog, - BaseContract, -} from "./types"; + Callback, + PayableTransactionObject, + NonPayableTransactionObject, + BlockType, + ContractEventLog, + BaseContract, +} from './types' export interface EventOptions { - filter?: object; - fromBlock?: BlockType; - topics?: string[]; + filter?: object + fromBlock?: BlockType + topics?: string[] } export type AddressSet = ContractEventLog<{ - id: string; - newAddress: string; - hasProxy: boolean; - 0: string; - 1: string; - 2: boolean; -}>; + id: string + newAddress: string + hasProxy: boolean + 0: string + 1: string + 2: boolean +}> export type ConfigurationAdminUpdated = ContractEventLog<{ - newAddress: string; - 0: string; -}>; + newAddress: string + 0: string +}> export type EmergencyAdminUpdated = ContractEventLog<{ - newAddress: string; - 0: string; -}>; + newAddress: string + 0: string +}> export type LendingPoolCollateralManagerUpdated = ContractEventLog<{ - newAddress: string; - 0: string; -}>; + newAddress: string + 0: string +}> export type LendingPoolConfiguratorUpdated = ContractEventLog<{ - newAddress: string; - 0: string; -}>; + newAddress: string + 0: string +}> export type LendingPoolUpdated = ContractEventLog<{ - newAddress: string; - 0: string; -}>; + newAddress: string + 0: string +}> export type LendingRateOracleUpdated = ContractEventLog<{ - newAddress: string; - 0: string; -}>; + newAddress: string + 0: string +}> export type MarketIdSet = ContractEventLog<{ - newMarketId: string; - 0: string; -}>; + newMarketId: string + 0: string +}> export type OwnershipTransferred = ContractEventLog<{ - previousOwner: string; - newOwner: string; - 0: string; - 1: string; -}>; + previousOwner: string + newOwner: string + 0: string + 1: string +}> export type PriceOracleUpdated = ContractEventLog<{ - newAddress: string; - 0: string; -}>; + newAddress: string + 0: string +}> export type ProxyCreated = ContractEventLog<{ - id: string; - newAddress: string; - 0: string; - 1: string; -}>; + id: string + newAddress: string + 0: string + 1: string +}> export interface AaveLendingPoolAddressProvider extends BaseContract { - constructor( - jsonInterface: any[], - address?: string, - options?: ContractOptions - ): AaveLendingPoolAddressProvider; - clone(): AaveLendingPoolAddressProvider; - methods: { - getAddress(id: string | number[]): NonPayableTransactionObject; + constructor(jsonInterface: any[], address?: string, options?: ContractOptions): AaveLendingPoolAddressProvider + clone(): AaveLendingPoolAddressProvider + methods: { + getAddress(id: string | number[]): NonPayableTransactionObject - getEmergencyAdmin(): NonPayableTransactionObject; + getEmergencyAdmin(): NonPayableTransactionObject - getLendingPool(): NonPayableTransactionObject; + getLendingPool(): NonPayableTransactionObject - getLendingPoolCollateralManager(): NonPayableTransactionObject; + getLendingPoolCollateralManager(): NonPayableTransactionObject - getLendingPoolConfigurator(): NonPayableTransactionObject; - - getLendingRateOracle(): NonPayableTransactionObject; + getLendingPoolConfigurator(): NonPayableTransactionObject - getMarketId(): NonPayableTransactionObject; - - getPoolAdmin(): NonPayableTransactionObject; - - getPriceOracle(): NonPayableTransactionObject; - - owner(): NonPayableTransactionObject; - - renounceOwnership(): NonPayableTransactionObject; - - setAddress( - id: string | number[], - newAddress: string - ): NonPayableTransactionObject; - - setAddressAsProxy( - id: string | number[], - implementationAddress: string - ): NonPayableTransactionObject; - - setEmergencyAdmin( - emergencyAdmin: string - ): NonPayableTransactionObject; - - setLendingPoolCollateralManager( - manager: string - ): NonPayableTransactionObject; - - setLendingPoolConfiguratorImpl( - configurator: string - ): NonPayableTransactionObject; - - setLendingPoolImpl(pool: string): NonPayableTransactionObject; - - setLendingRateOracle( - lendingRateOracle: string - ): NonPayableTransactionObject; - - setMarketId(marketId: string): NonPayableTransactionObject; - - setPoolAdmin(admin: string): NonPayableTransactionObject; - - setPriceOracle(priceOracle: string): NonPayableTransactionObject; - - transferOwnership(newOwner: string): NonPayableTransactionObject; - }; - events: { - AddressSet(cb?: Callback): EventEmitter; - AddressSet(options?: EventOptions, cb?: Callback): EventEmitter; - - ConfigurationAdminUpdated( - cb?: Callback - ): EventEmitter; - ConfigurationAdminUpdated( - options?: EventOptions, - cb?: Callback - ): EventEmitter; - - EmergencyAdminUpdated(cb?: Callback): EventEmitter; - EmergencyAdminUpdated( - options?: EventOptions, - cb?: Callback - ): EventEmitter; - - LendingPoolCollateralManagerUpdated( - cb?: Callback - ): EventEmitter; - LendingPoolCollateralManagerUpdated( - options?: EventOptions, - cb?: Callback - ): EventEmitter; - - LendingPoolConfiguratorUpdated( - cb?: Callback - ): EventEmitter; - LendingPoolConfiguratorUpdated( - options?: EventOptions, - cb?: Callback - ): EventEmitter; - - LendingPoolUpdated(cb?: Callback): EventEmitter; - LendingPoolUpdated( - options?: EventOptions, - cb?: Callback - ): EventEmitter; - - LendingRateOracleUpdated( - cb?: Callback - ): EventEmitter; - LendingRateOracleUpdated( - options?: EventOptions, - cb?: Callback - ): EventEmitter; - - MarketIdSet(cb?: Callback): EventEmitter; - MarketIdSet( - options?: EventOptions, - cb?: Callback - ): EventEmitter; - - OwnershipTransferred(cb?: Callback): EventEmitter; - OwnershipTransferred( - options?: EventOptions, - cb?: Callback - ): EventEmitter; - - PriceOracleUpdated(cb?: Callback): EventEmitter; - PriceOracleUpdated( - options?: EventOptions, - cb?: Callback - ): EventEmitter; - - ProxyCreated(cb?: Callback): EventEmitter; - ProxyCreated( - options?: EventOptions, - cb?: Callback - ): EventEmitter; - - allEvents(options?: EventOptions, cb?: Callback): EventEmitter; - }; - - once(event: "AddressSet", cb: Callback): void; - once( - event: "AddressSet", - options: EventOptions, - cb: Callback - ): void; - - once( - event: "ConfigurationAdminUpdated", - cb: Callback - ): void; - once( - event: "ConfigurationAdminUpdated", - options: EventOptions, - cb: Callback - ): void; - - once( - event: "EmergencyAdminUpdated", - cb: Callback - ): void; - once( - event: "EmergencyAdminUpdated", - options: EventOptions, - cb: Callback - ): void; - - once( - event: "LendingPoolCollateralManagerUpdated", - cb: Callback - ): void; - once( - event: "LendingPoolCollateralManagerUpdated", - options: EventOptions, - cb: Callback - ): void; - - once( - event: "LendingPoolConfiguratorUpdated", - cb: Callback - ): void; - once( - event: "LendingPoolConfiguratorUpdated", - options: EventOptions, - cb: Callback - ): void; - - once(event: "LendingPoolUpdated", cb: Callback): void; - once( - event: "LendingPoolUpdated", - options: EventOptions, - cb: Callback - ): void; - - once( - event: "LendingRateOracleUpdated", - cb: Callback - ): void; - once( - event: "LendingRateOracleUpdated", - options: EventOptions, - cb: Callback - ): void; - - once(event: "MarketIdSet", cb: Callback): void; - once( - event: "MarketIdSet", - options: EventOptions, - cb: Callback - ): void; - - once(event: "OwnershipTransferred", cb: Callback): void; - once( - event: "OwnershipTransferred", - options: EventOptions, - cb: Callback - ): void; - - once(event: "PriceOracleUpdated", cb: Callback): void; - once( - event: "PriceOracleUpdated", - options: EventOptions, - cb: Callback - ): void; - - once(event: "ProxyCreated", cb: Callback): void; - once( - event: "ProxyCreated", - options: EventOptions, - cb: Callback - ): void; + getLendingRateOracle(): NonPayableTransactionObject + + getMarketId(): NonPayableTransactionObject + + getPoolAdmin(): NonPayableTransactionObject + + getPriceOracle(): NonPayableTransactionObject + + owner(): NonPayableTransactionObject + + renounceOwnership(): NonPayableTransactionObject + + setAddress(id: string | number[], newAddress: string): NonPayableTransactionObject + + setAddressAsProxy(id: string | number[], implementationAddress: string): NonPayableTransactionObject + + setEmergencyAdmin(emergencyAdmin: string): NonPayableTransactionObject + + setLendingPoolCollateralManager(manager: string): NonPayableTransactionObject + + setLendingPoolConfiguratorImpl(configurator: string): NonPayableTransactionObject + + setLendingPoolImpl(pool: string): NonPayableTransactionObject + + setLendingRateOracle(lendingRateOracle: string): NonPayableTransactionObject + + setMarketId(marketId: string): NonPayableTransactionObject + + setPoolAdmin(admin: string): NonPayableTransactionObject + + setPriceOracle(priceOracle: string): NonPayableTransactionObject + + transferOwnership(newOwner: string): NonPayableTransactionObject + } + events: { + AddressSet(cb?: Callback): EventEmitter + AddressSet(options?: EventOptions, cb?: Callback): EventEmitter + + ConfigurationAdminUpdated(cb?: Callback): EventEmitter + ConfigurationAdminUpdated(options?: EventOptions, cb?: Callback): EventEmitter + + EmergencyAdminUpdated(cb?: Callback): EventEmitter + EmergencyAdminUpdated(options?: EventOptions, cb?: Callback): EventEmitter + + LendingPoolCollateralManagerUpdated(cb?: Callback): EventEmitter + LendingPoolCollateralManagerUpdated( + options?: EventOptions, + cb?: Callback, + ): EventEmitter + + LendingPoolConfiguratorUpdated(cb?: Callback): EventEmitter + LendingPoolConfiguratorUpdated( + options?: EventOptions, + cb?: Callback, + ): EventEmitter + + LendingPoolUpdated(cb?: Callback): EventEmitter + LendingPoolUpdated(options?: EventOptions, cb?: Callback): EventEmitter + + LendingRateOracleUpdated(cb?: Callback): EventEmitter + LendingRateOracleUpdated(options?: EventOptions, cb?: Callback): EventEmitter + + MarketIdSet(cb?: Callback): EventEmitter + MarketIdSet(options?: EventOptions, cb?: Callback): EventEmitter + + OwnershipTransferred(cb?: Callback): EventEmitter + OwnershipTransferred(options?: EventOptions, cb?: Callback): EventEmitter + + PriceOracleUpdated(cb?: Callback): EventEmitter + PriceOracleUpdated(options?: EventOptions, cb?: Callback): EventEmitter + + ProxyCreated(cb?: Callback): EventEmitter + ProxyCreated(options?: EventOptions, cb?: Callback): EventEmitter + + allEvents(options?: EventOptions, cb?: Callback): EventEmitter + } + + once(event: 'AddressSet', cb: Callback): void + once(event: 'AddressSet', options: EventOptions, cb: Callback): void + + once(event: 'ConfigurationAdminUpdated', cb: Callback): void + once(event: 'ConfigurationAdminUpdated', options: EventOptions, cb: Callback): void + + once(event: 'EmergencyAdminUpdated', cb: Callback): void + once(event: 'EmergencyAdminUpdated', options: EventOptions, cb: Callback): void + + once(event: 'LendingPoolCollateralManagerUpdated', cb: Callback): void + once( + event: 'LendingPoolCollateralManagerUpdated', + options: EventOptions, + cb: Callback, + ): void + + once(event: 'LendingPoolConfiguratorUpdated', cb: Callback): void + once( + event: 'LendingPoolConfiguratorUpdated', + options: EventOptions, + cb: Callback, + ): void + + once(event: 'LendingPoolUpdated', cb: Callback): void + once(event: 'LendingPoolUpdated', options: EventOptions, cb: Callback): void + + once(event: 'LendingRateOracleUpdated', cb: Callback): void + once(event: 'LendingRateOracleUpdated', options: EventOptions, cb: Callback): void + + once(event: 'MarketIdSet', cb: Callback): void + once(event: 'MarketIdSet', options: EventOptions, cb: Callback): void + + once(event: 'OwnershipTransferred', cb: Callback): void + once(event: 'OwnershipTransferred', options: EventOptions, cb: Callback): void + + once(event: 'PriceOracleUpdated', cb: Callback): void + once(event: 'PriceOracleUpdated', options: EventOptions, cb: Callback): void + + once(event: 'ProxyCreated', cb: Callback): void + once(event: 'ProxyCreated', options: EventOptions, cb: Callback): void } diff --git a/packages/web3-contracts/types/AaveProtocolDataProvider.d.ts b/packages/web3-contracts/types/AaveProtocolDataProvider.d.ts index 57555766109e..c55d154bef05 100644 --- a/packages/web3-contracts/types/AaveProtocolDataProvider.d.ts +++ b/packages/web3-contracts/types/AaveProtocolDataProvider.d.ts @@ -2,119 +2,115 @@ /* tslint:disable */ /* eslint-disable */ -import BN from "bn.js"; -import { ContractOptions } from "web3-eth-contract"; -import { EventLog } from "web3-core"; -import { EventEmitter } from "events"; +import BN from 'bn.js' +import { ContractOptions } from 'web3-eth-contract' +import { EventLog } from 'web3-core' +import { EventEmitter } from 'events' import { - Callback, - PayableTransactionObject, - NonPayableTransactionObject, - BlockType, - ContractEventLog, - BaseContract, -} from "./types"; + Callback, + PayableTransactionObject, + NonPayableTransactionObject, + BlockType, + ContractEventLog, + BaseContract, +} from './types' export interface EventOptions { - filter?: object; - fromBlock?: BlockType; - topics?: string[]; + filter?: object + fromBlock?: BlockType + topics?: string[] } export interface AaveProtocolDataProvider extends BaseContract { - constructor( - jsonInterface: any[], - address?: string, - options?: ContractOptions - ): AaveProtocolDataProvider; - clone(): AaveProtocolDataProvider; - methods: { - ADDRESSES_PROVIDER(): NonPayableTransactionObject; + constructor(jsonInterface: any[], address?: string, options?: ContractOptions): AaveProtocolDataProvider + clone(): AaveProtocolDataProvider + methods: { + ADDRESSES_PROVIDER(): NonPayableTransactionObject - getAllATokens(): NonPayableTransactionObject<[string, string][]>; + getAllATokens(): NonPayableTransactionObject<[string, string][]> - getAllReservesTokens(): NonPayableTransactionObject<[string, string][]>; + getAllReservesTokens(): NonPayableTransactionObject<[string, string][]> - getReserveConfigurationData(asset: string): NonPayableTransactionObject<{ - decimals: string; - ltv: string; - liquidationThreshold: string; - liquidationBonus: string; - reserveFactor: string; - usageAsCollateralEnabled: boolean; - borrowingEnabled: boolean; - stableBorrowRateEnabled: boolean; - isActive: boolean; - isFrozen: boolean; - 0: string; - 1: string; - 2: string; - 3: string; - 4: string; - 5: boolean; - 6: boolean; - 7: boolean; - 8: boolean; - 9: boolean; - }>; + getReserveConfigurationData(asset: string): NonPayableTransactionObject<{ + decimals: string + ltv: string + liquidationThreshold: string + liquidationBonus: string + reserveFactor: string + usageAsCollateralEnabled: boolean + borrowingEnabled: boolean + stableBorrowRateEnabled: boolean + isActive: boolean + isFrozen: boolean + 0: string + 1: string + 2: string + 3: string + 4: string + 5: boolean + 6: boolean + 7: boolean + 8: boolean + 9: boolean + }> - getReserveData(asset: string): NonPayableTransactionObject<{ - availableLiquidity: string; - totalStableDebt: string; - totalVariableDebt: string; - liquidityRate: string; - variableBorrowRate: string; - stableBorrowRate: string; - averageStableBorrowRate: string; - liquidityIndex: string; - variableBorrowIndex: string; - lastUpdateTimestamp: string; - 0: string; - 1: string; - 2: string; - 3: string; - 4: string; - 5: string; - 6: string; - 7: string; - 8: string; - 9: string; - }>; + getReserveData(asset: string): NonPayableTransactionObject<{ + availableLiquidity: string + totalStableDebt: string + totalVariableDebt: string + liquidityRate: string + variableBorrowRate: string + stableBorrowRate: string + averageStableBorrowRate: string + liquidityIndex: string + variableBorrowIndex: string + lastUpdateTimestamp: string + 0: string + 1: string + 2: string + 3: string + 4: string + 5: string + 6: string + 7: string + 8: string + 9: string + }> - getReserveTokensAddresses(asset: string): NonPayableTransactionObject<{ - aTokenAddress: string; - stableDebtTokenAddress: string; - variableDebtTokenAddress: string; - 0: string; - 1: string; - 2: string; - }>; + getReserveTokensAddresses(asset: string): NonPayableTransactionObject<{ + aTokenAddress: string + stableDebtTokenAddress: string + variableDebtTokenAddress: string + 0: string + 1: string + 2: string + }> - getUserReserveData( - asset: string, - user: string - ): NonPayableTransactionObject<{ - currentATokenBalance: string; - currentStableDebt: string; - currentVariableDebt: string; - principalStableDebt: string; - scaledVariableDebt: string; - stableBorrowRate: string; - liquidityRate: string; - stableRateLastUpdated: string; - usageAsCollateralEnabled: boolean; - 0: string; - 1: string; - 2: string; - 3: string; - 4: string; - 5: string; - 6: string; - 7: string; - 8: boolean; - }>; - }; - events: { - allEvents(options?: EventOptions, cb?: Callback): EventEmitter; - }; + getUserReserveData( + asset: string, + user: string, + ): NonPayableTransactionObject<{ + currentATokenBalance: string + currentStableDebt: string + currentVariableDebt: string + principalStableDebt: string + scaledVariableDebt: string + stableBorrowRate: string + liquidityRate: string + stableRateLastUpdated: string + usageAsCollateralEnabled: boolean + 0: string + 1: string + 2: string + 3: string + 4: string + 5: string + 6: string + 7: string + 8: boolean + }> + } + events: { + allEvents(options?: EventOptions, cb?: Callback): EventEmitter + } } diff --git a/packages/web3-contracts/types/AaveStableDebtToken.d.ts b/packages/web3-contracts/types/AaveStableDebtToken.d.ts index c850b4fb9e02..5b407b64a865 100644 --- a/packages/web3-contracts/types/AaveStableDebtToken.d.ts +++ b/packages/web3-contracts/types/AaveStableDebtToken.d.ts @@ -2,123 +2,110 @@ /* tslint:disable */ /* eslint-disable */ -import BN from "bn.js"; -import { ContractOptions } from "web3-eth-contract"; -import { EventLog } from "web3-core"; -import { EventEmitter } from "events"; +import BN from 'bn.js' +import { ContractOptions } from 'web3-eth-contract' +import { EventLog } from 'web3-core' +import { EventEmitter } from 'events' import { - Callback, - PayableTransactionObject, - NonPayableTransactionObject, - BlockType, - ContractEventLog, - BaseContract, -} from "./types"; + Callback, + PayableTransactionObject, + NonPayableTransactionObject, + BlockType, + ContractEventLog, + BaseContract, +} from './types' export interface EventOptions { - filter?: object; - fromBlock?: BlockType; - topics?: string[]; + filter?: object + fromBlock?: BlockType + topics?: string[] } export type Burn = ContractEventLog<{ - user: string; - amount: string; - currentBalance: string; - balanceIncrease: string; - avgStableRate: string; - newTotalSupply: string; - 0: string; - 1: string; - 2: string; - 3: string; - 4: string; - 5: string; -}>; + user: string + amount: string + currentBalance: string + balanceIncrease: string + avgStableRate: string + newTotalSupply: string + 0: string + 1: string + 2: string + 3: string + 4: string + 5: string +}> export type Mint = ContractEventLog<{ - user: string; - onBehalfOf: string; - amount: string; - currentBalance: string; - balanceIncrease: string; - newRate: string; - avgStableRate: string; - newTotalSupply: string; - 0: string; - 1: string; - 2: string; - 3: string; - 4: string; - 5: string; - 6: string; - 7: string; -}>; + user: string + onBehalfOf: string + amount: string + currentBalance: string + balanceIncrease: string + newRate: string + avgStableRate: string + newTotalSupply: string + 0: string + 1: string + 2: string + 3: string + 4: string + 5: string + 6: string + 7: string +}> export interface AaveStableDebtToken extends BaseContract { - constructor( - jsonInterface: any[], - address?: string, - options?: ContractOptions - ): AaveStableDebtToken; - clone(): AaveStableDebtToken; - methods: { - approveDelegation( - delegatee: string, - amount: number | string | BN - ): NonPayableTransactionObject; - - borrowAllowance( - fromUser: string, - toUser: string - ): NonPayableTransactionObject; - - burn( - user: string, - amount: number | string | BN - ): NonPayableTransactionObject; - - getAverageStableRate(): NonPayableTransactionObject; - - getSupplyData(): NonPayableTransactionObject<{ - 0: string; - 1: string; - 2: string; - 3: string; - }>; - - getTotalSupplyAndAvgRate(): NonPayableTransactionObject<{ - 0: string; - 1: string; - }>; - - getTotalSupplyLastUpdated(): NonPayableTransactionObject; - - getUserLastUpdated(user: string): NonPayableTransactionObject; - - getUserStableRate(user: string): NonPayableTransactionObject; - - mint( - user: string, - onBehalfOf: string, - amount: number | string | BN, - rate: number | string | BN - ): NonPayableTransactionObject; - - principalBalanceOf(user: string): NonPayableTransactionObject; - }; - events: { - Burn(cb?: Callback): EventEmitter; - Burn(options?: EventOptions, cb?: Callback): EventEmitter; - - Mint(cb?: Callback): EventEmitter; - Mint(options?: EventOptions, cb?: Callback): EventEmitter; - - allEvents(options?: EventOptions, cb?: Callback): EventEmitter; - }; - - once(event: "Burn", cb: Callback): void; - once(event: "Burn", options: EventOptions, cb: Callback): void; - - once(event: "Mint", cb: Callback): void; - once(event: "Mint", options: EventOptions, cb: Callback): void; + constructor(jsonInterface: any[], address?: string, options?: ContractOptions): AaveStableDebtToken + clone(): AaveStableDebtToken + methods: { + approveDelegation(delegatee: string, amount: number | string | BN): NonPayableTransactionObject + + borrowAllowance(fromUser: string, toUser: string): NonPayableTransactionObject + + burn(user: string, amount: number | string | BN): NonPayableTransactionObject + + getAverageStableRate(): NonPayableTransactionObject + + getSupplyData(): NonPayableTransactionObject<{ + 0: string + 1: string + 2: string + 3: string + }> + + getTotalSupplyAndAvgRate(): NonPayableTransactionObject<{ + 0: string + 1: string + }> + + getTotalSupplyLastUpdated(): NonPayableTransactionObject + + getUserLastUpdated(user: string): NonPayableTransactionObject + + getUserStableRate(user: string): NonPayableTransactionObject + + mint( + user: string, + onBehalfOf: string, + amount: number | string | BN, + rate: number | string | BN, + ): NonPayableTransactionObject + + principalBalanceOf(user: string): NonPayableTransactionObject + } + events: { + Burn(cb?: Callback): EventEmitter + Burn(options?: EventOptions, cb?: Callback): EventEmitter + + Mint(cb?: Callback): EventEmitter + Mint(options?: EventOptions, cb?: Callback): EventEmitter + + allEvents(options?: EventOptions, cb?: Callback): EventEmitter + } + + once(event: 'Burn', cb: Callback): void + once(event: 'Burn', options: EventOptions, cb: Callback): void + + once(event: 'Mint', cb: Callback): void + once(event: 'Mint', options: EventOptions, cb: Callback): void } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 92663eed3ce5..85e41297d14d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -309,6 +309,7 @@ importers: '@masknet/shared': workspace:* '@masknet/shared-base': workspace:* '@masknet/theme': workspace:* + '@masknet/web3-constants': workspace:* '@masknet/web3-contracts': workspace:* '@masknet/web3-providers': workspace:* '@masknet/web3-shared-base': workspace:* @@ -445,6 +446,7 @@ importers: '@masknet/shared': link:../shared '@masknet/shared-base': link:../shared-base '@masknet/theme': link:../theme + '@masknet/web3-constants': link:../web3-constants '@masknet/web3-contracts': link:../web3-contracts '@masknet/web3-providers': link:../web3-providers '@masknet/web3-shared-base': link:../web3-shared/base @@ -9452,7 +9454,7 @@ packages: resolution: {integrity: sha512-oagLNqpfNv7CvmyMoexMDNyVDSiq1rya0AEUgcLlNHdHgNl6U/hi8xY370n5y+ZIFEXOx0J4B1qF2NDjMRxklA==} engines: {node: '>=6.0.0'} dependencies: - pvutils: 1.0.17 + pvutils: 1.1.3 dev: false /assert-plus/1.0.0: @@ -19982,8 +19984,8 @@ packages: tslib: 2.3.1 dev: false - /pvutils/1.0.17: - resolution: {integrity: sha512-wLHYUQxWaXVQvKnwIDWFVKDJku9XDCvyhhxoq8dc5MFdIlRenyPI9eSfEtcvgHgD7FlvCyGAlWgOzRnZD99GZQ==} + /pvutils/1.1.3: + resolution: {integrity: sha512-pMpnA0qRdFp32b1sJl1wOJNxZLQ2cbQx+k6tjNtZ8CpvVhNqEPRgivZ2WOUev2YMajecdH7ctUPDvEe87nariQ==} engines: {node: '>=6.0.0'} dev: false From a81ba1217c5eb1f854f0d1de156451e69c2ec142 Mon Sep 17 00:00:00 2001 From: guanbinrui Date: Thu, 3 Mar 2022 17:10:44 +0800 Subject: [PATCH 14/38] refactor: aave to use new protocol --- packages/mask/package.json | 1 - .../Savings/SNSAdaptor/SavingsDialog.tsx | 43 +- .../Savings/SNSAdaptor/SavingsForm.tsx | 21 +- .../Savings/SNSAdaptor/SavingsFormStyles.tsx | 1 + .../Savings/SNSAdaptor/SavingsTable.tsx | 39 +- .../mask/src/plugins/Savings/constants.ts | 440 +++++++++--------- .../plugins/Savings/protocols/AAVEProtocol.ts | 188 ++------ .../plugins/Savings/protocols/LDOProtocol.ts | 6 +- .../src/plugins/Savings/protocols/index.ts | 10 +- packages/web3-constants/evm/token.json | 39 +- pnpm-lock.yaml | 2 - 11 files changed, 363 insertions(+), 427 deletions(-) diff --git a/packages/mask/package.json b/packages/mask/package.json index 6d0a95263a08..7e41746e9210 100644 --- a/packages/mask/package.json +++ b/packages/mask/package.json @@ -33,7 +33,6 @@ "@masknet/shared-base": "workspace:*", "@masknet/theme": "workspace:*", "@masknet/web3-contracts": "workspace:*", - "@masknet/web3-constants": "workspace:*", "@masknet/web3-providers": "workspace:*", "@masknet/web3-shared-base": "workspace:*", "@masknet/web3-shared-evm": "workspace:*", diff --git a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsDialog.tsx b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsDialog.tsx index 36693954e23c..8712c5a9a3f2 100644 --- a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsDialog.tsx +++ b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsDialog.tsx @@ -1,7 +1,8 @@ -import { useState } from 'react' +import { useMemo, useState } from 'react' import { useAsync } from 'react-use' import { Typography, DialogContent } from '@mui/material' import { isDashboardPage } from '@masknet/shared-base' +import { FolderTabPanel, FolderTabs } from '@masknet/theme' import { ChainId, getChainIdFromNetworkType, useChainId } from '@masknet/web3-shared-evm' import { useI18N } from '../../../utils' import { EMPTY_LIST } from '../../../../utils-pure' @@ -9,23 +10,21 @@ import { InjectedDialog } from '../../../components/shared/InjectedDialog' import { WalletStatusBox } from '../../../components/shared/WalletStatusBox' import { AllProviderTradeContext } from '../../Trader/trader/useAllProviderTradeContext' import { TargetChainIdContext } from '../../Trader/trader/useTargetChainIdContext' -import { FolderTabPanel, FolderTabs } from '@masknet/theme' import { NetworkTab } from '../../../components/shared/NetworkTab' import { WalletRPC } from '../../Wallet/messages' -import { ProtocolType, SavingsProtocol, TabType } from '../types' - +import { SavingsProtocol, TabType } from '../types' import { useStyles } from './SavingsDialogStyles' import { SavingsTable } from './SavingsTable' import { SavingsForm } from './SavingsForm' +import { SavingsProtocols } from '../protocols' export interface SavingsDialogProps { open: boolean - protocols: SavingsProtocol[] onClose?: () => void onSwapDialogOpen?: () => void } -export function SavingsDialog({ open, protocols, onClose, onSwapDialogOpen }: SavingsDialogProps) { +export function SavingsDialog({ open, onClose, onSwapDialogOpen }: SavingsDialogProps) { const { t } = useI18N() const isDashboard = isDashboardPage() const { classes } = useStyles({ isDashboard }) @@ -33,13 +32,15 @@ export function SavingsDialog({ open, protocols, onClose, onSwapDialogOpen }: Sa const currentChainId = useChainId() const [chainId, setChainId] = useState(currentChainId) const [tab, setTab] = useState(TabType.Deposit) - const [selectedProtocol, setSelectedProtocol] = useState(null) + const [selectedProtocol, setSelectedProtocol] = useState(null) const { value: chains = EMPTY_LIST } = useAsync(async () => { const networks = await WalletRPC.getSupportedNetworks() return networks.map((network) => getChainIdFromNetworkType(network)) }, []) + const protocols = useMemo(() => SavingsProtocols.filter((x) => x.bareToken.chainId === chainId), [chainId]) + return ( @@ -60,7 +61,15 @@ export function SavingsDialog({ open, protocols, onClose, onSwapDialogOpen }: Sa
) : null} - {selectedProtocol === null ? ( + {selectedProtocol ? ( + + ) : ( <>
{protocols.length === 0 ? ( - + {t('plugin_no_protocol_available')} ) : ( - + - + )}
- ) : ( - )} diff --git a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsForm.tsx b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsForm.tsx index 51745fd8d975..f45fc4469b69 100644 --- a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsForm.tsx +++ b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsForm.tsx @@ -13,13 +13,11 @@ import { formatCurrency, formatBalance, } from '@masknet/web3-shared-evm' -import { TokenAmountPanel, FormattedCurrency, LoadingAnimation } from '@masknet/shared' +import { TokenAmountPanel, FormattedCurrency, LoadingAnimation, TokenIcon } from '@masknet/shared' import { useTokenPrice } from '../../Wallet/hooks/useTokenPrice' import { useI18N } from '../../../utils' import { useStyles } from './SavingsFormStyles' -import { ProviderIconURLs } from './IconURL' -import { TabType, ProtocolType } from '../types' -import { SavingsProtocols } from '../protocols' +import { TabType, ProtocolType, SavingsProtocol } from '../types' import { EthereumWalletConnectedBoundary } from '../../../web3/UI/EthereumWalletConnectedBoundary' import { EthereumChainBoundary } from '../../../web3/UI/EthereumChainBoundary' import { ActionButtonPromise } from '../../../extension/options-page/DashboardComponents/ActionButton' @@ -27,16 +25,15 @@ import { AllProviderTradeActionType, AllProviderTradeContext } from '../../Trade export interface SavingsFormProps { chainId: number - selectedProtocol: ProtocolType + protocol: SavingsProtocol tab: TabType onClose?: () => void onSwapDialogOpen?: () => void } -export function SavingsForm({ chainId, selectedProtocol, tab, onClose, onSwapDialogOpen }: SavingsFormProps) { +export function SavingsForm({ chainId, protocol, tab, onClose, onSwapDialogOpen }: SavingsFormProps) { const { t } = useI18N() const { classes } = useStyles() - const protocol = SavingsProtocols[selectedProtocol] const { value: nativeTokenDetailed } = useNativeTokenDetailed() const web3 = useWeb3({ chainId }) @@ -139,11 +136,11 @@ export function SavingsForm({ chainId, selectedProtocol, tab, onClose, onSwapDia )}
- - - {protocol.pair} {t('plugin_savings_apr')}% + + + {protocol.bareToken.name} {t('plugin_savings_apr')}% - + {protocol.apr}%
@@ -168,7 +165,7 @@ export function SavingsForm({ chainId, selectedProtocol, tab, onClose, onSwapDia variant="contained" init={ needsSwap - ? 'Swap ' + protocol.pair + ? 'Swap ' + protocol.bareToken.symbol : validationMessage || (tab === TabType.Deposit ? t('plugin_savings_deposit') + ' ' + protocol.bareToken.symbol diff --git a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsFormStyles.tsx b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsFormStyles.tsx index ed6a7499b176..21146da0d84c 100644 --- a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsFormStyles.tsx +++ b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsFormStyles.tsx @@ -39,6 +39,7 @@ export const useStyles = makeStyles()((theme, props) => ({ fontWeight: 'bold', }, rowImage: { + width: '24px', height: '24px', margin: '0 5px 0 0', }, diff --git a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsTable.tsx b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsTable.tsx index c854dede6cb2..5987d5988613 100644 --- a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsTable.tsx +++ b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsTable.tsx @@ -1,12 +1,11 @@ import { useAsync } from 'react-use' -import { Box, Grid, Button, Typography } from '@mui/material' import { makeStyles } from '@masknet/theme' -import { FormattedBalance } from '@masknet/shared' +import { Box, Grid, Button, Typography } from '@mui/material' +import { FormattedBalance, TokenIcon } from '@masknet/shared' import { isZero, rightShift } from '@masknet/web3-shared-base' import { ChainId, useWeb3, useAccount, formatBalance } from '@masknet/web3-shared-evm' import { ProviderIconURLs } from './IconURL' import { useI18N } from '../../../utils' -import { SavingsProtocols } from '../protocols' import { TabType, ProtocolType, SavingsProtocol } from '../types' const useStyles = makeStyles()((theme, props) => ({ @@ -16,18 +15,23 @@ const useStyles = makeStyles()((theme, props) => ({ tableHeader: { display: 'flex', background: theme.palette.mode === 'light' ? '#F6F8F8' : '#17191D', - borderRadius: '8px', + borderRadius: theme.spacing(1), margin: '0 0 15px 0', }, tableRow: { display: 'flex', background: theme.palette.mode === 'light' ? '#F6F8F8' : '#17191D', - borderRadius: '8px', + borderRadius: theme.spacing(1), + marginBottom: theme.spacing(1), + + '&:last-child': { + marginBottom: '0', + }, }, tableItem: { display: 'flex', background: theme.palette.mode === 'light' ? '#F6F8F8' : '#17191D', - borderRadius: '8px', + borderRadius: theme.spacing(1), }, tableCell: { display: 'flex', @@ -40,18 +44,16 @@ const useStyles = makeStyles()((theme, props) => ({ margin: '0 20px 0 0', }, logo: { + width: '32px', height: '32px', }, logoMini: { height: '16px', position: 'absolute', - bottom: '3px', + bottom: 0, right: '-5px', }, - protocolLabel: { - fontSize: 12, - opacity: 0.5, - }, + protocolLabel: {}, })) export interface SavingsTableProps { @@ -59,10 +61,10 @@ export interface SavingsTableProps { tab: TabType protocols: SavingsProtocol[] setTab(tab: TabType): void - setSelectedProtocol(protocol: ProtocolType): void + setSelectedProtocol(protocol: SavingsProtocol): void } -export function SavingsTable({ chainId, tab, protocols, setSelectedProtocol, setTab }: SavingsTableProps) { +export function SavingsTable({ chainId, tab, protocols, setTab, setSelectedProtocol }: SavingsTableProps) { const { t } = useI18N() const { classes } = useStyles() @@ -71,11 +73,11 @@ export function SavingsTable({ chainId, tab, protocols, setSelectedProtocol, set // Only fetch protocol APR and Balance on chainId change useAsync(async () => { - for (const protocol of SavingsProtocols) { + for (const protocol of protocols) { await protocol.updateApr(chainId, web3) await protocol.updateBalance(chainId, web3, account) } - }, [chainId, web3, account]) + }, [chainId, web3, account, protocols]) return ( @@ -98,6 +100,11 @@ export function SavingsTable({ chainId, tab, protocols, setSelectedProtocol, set
+
@@ -126,8 +133,8 @@ export function SavingsTable({ chainId, tab, protocols, setSelectedProtocol, set color="primary" disabled={tab === TabType.Withdraw ? isZero(protocol.balance) : false} onClick={() => { - setSelectedProtocol(protocol.type) setTab(tab) + setSelectedProtocol(protocol) }}> {tab === TabType.Deposit ? t('plugin_savings_deposit') : t('plugin_savings_withdraw')} diff --git a/packages/mask/src/plugins/Savings/constants.ts b/packages/mask/src/plugins/Savings/constants.ts index 29356b87f4f7..bb2ea40ce848 100644 --- a/packages/mask/src/plugins/Savings/constants.ts +++ b/packages/mask/src/plugins/Savings/constants.ts @@ -10,222 +10,226 @@ export const LDO_PAIRS: [FungibleTokenDetailed, FungibleTokenDetailed][] = [ ], ] -export const AAVE_PAIRS = [ - { - name: 'USDT', - pair: 'aUSDT', - decimals: 6, - underLyingAssetName: 'aUSDT', - logoURI: ['https://tokens.1inch.io/0xdac17f958d2ee523a2206206994597c13d831ec7.png'], - }, - { - name: 'WBTC', - pair: 'aWBTC', - decimals: 8, - underLyingAssetName: 'aWBTC', - logoURI: ['https://tokens.1inch.io/0x2260fac5e5542a773aa44fbcfedf7c193bc2c599.png'], - }, - { - name: 'WETH', - pair: 'aWETH', - decimals: 18, - underLyingAssetName: 'aWETH', - logoURI: ['https://tokens.1inch.io/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png'], - }, - { - name: 'YFI', - pair: 'aYFI', - decimals: 18, - underLyingAssetName: 'aYFI', - logoURI: ['https://tokens.1inch.io/0x0bc529c00c6401aef6d220be8c6ea1667f6ad93e.png'], - }, - { - name: 'ZRX', - pair: 'aZRX', - decimals: 18, - underLyingAssetName: 'aZRX', - logoURI: ['https://tokens.1inch.io/0xe41d2489571d322189246dafa5ebde1f4699f498.png'], - }, - { - name: 'UNI', - pair: 'aUNI', - decimals: 18, - underLyingAssetName: 'aUNI', - logoURI: ['https://tokens.1inch.io/0x1f9840a85d5af5bf1d1762f925bdaddc4201f984.png'], - }, - { - name: 'AAVE', - pair: 'aAAVE', - decimals: 18, - underLyingAssetName: 'aAAVE', - logoURI: ['https://tokens.1inch.io/0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9.png'], - }, - { - name: 'BAT', - pair: 'aBAT', - decimals: 18, - underLyingAssetName: 'aBAT', - logoURI: ['https://tokens.1inch.io/0x0d8775f648430679a709e98d2b0cb6250d2887ef.png'], - }, - { - name: 'BUSD', - pair: 'aBUSD', - decimals: 18, - underLyingAssetName: 'aBUSD', - logoURI: ['https://tokens.1inch.io/0x4fabb145d64652a948d72533023f6e7a623c7c53.png'], - }, - { - name: 'DAI', - pair: 'aDAI', - decimals: 18, - underLyingAssetName: 'aDAI', - logoURI: ['https://tokens.1inch.io/0x6b175474e89094c44da98b954eedeac495271d0f.png'], - }, - { - name: 'ENJ', - pair: 'aENJ', - decimals: 18, - underLyingAssetName: 'aENJ', - logoURI: ['https://tokens.1inch.io/0xf629cbd94d3791c9250152bd8dfbdf380e2a3b9c.png'], - }, - { - name: 'KNC', - pair: 'aKNC', - decimals: 18, - underLyingAssetName: 'aKNC', - logoURI: ['https://tokens.1inch.io/0xdd974d5c2e2928dea5f71b9825b8b646686bd200.png'], - }, - { - name: 'LINK', - pair: 'aLINK', - decimals: 18, - underLyingAssetName: 'aLINK', - logoURI: ['https://tokens.1inch.io/0x514910771af9ca656af840dff83e8264ecf986ca.png'], - }, - { - name: 'MANA', - pair: 'aMANA', - decimals: 18, - underLyingAssetName: 'aMANA', - logoURI: ['https://tokens.1inch.io/0x0f5d2fb29fb7d3cfee444a200298f468908cc942.png'], - }, - { - name: 'MKR', - pair: 'aMKR', - decimals: 18, - underLyingAssetName: 'aMKR', - logoURI: ['https://tokens.1inch.io/0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2.png'], - }, - { - name: 'REN', - pair: 'aREN', - decimals: 18, - underLyingAssetName: 'aREN', - logoURI: ['https://tokens.1inch.io/0x408e41876cccdc0f92210600ef50372656052a38.png'], - }, - { - name: 'SNX', - pair: 'aSNX', - decimals: 18, - underLyingAssetName: 'aSNX', - logoURI: ['https://tokens.1inch.io/0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f.png'], - }, - { - name: 'sUSD', - pair: 'aSUSD', - decimals: 18, - underLyingAssetName: 'aSUSD', - logoURI: ['https://tokens.1inch.io/0x57ab1ec28d129707052df4df418d58a2d46d5f51.png'], - }, - { - name: 'TUSD', - pair: 'aTUSD', - decimals: 18, - underLyingAssetName: 'aTUSD', - logoURI: ['https://tokens.1inch.io/0x0000000000085d4780b73119b644ae5ecd22b376.png'], - }, - { - name: 'USDC', - pair: 'aUSDC', - decimals: 6, - underLyingAssetName: 'aUSDC', - logoURI: ['https://tokens.1inch.io/0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48.png'], - }, - { - name: 'CRV', - pair: 'aCRV', - decimals: 18, - underLyingAssetName: 'aCRV', - logoURI: ['https://tokens.1inch.io/0xd533a949740bb3306d119cc777fa900ba034cd52.png'], - }, - { - name: 'GUSD', - pair: 'aGUSD', - decimals: 2, - underLyingAssetName: 'aGUSD', - logoURI: ['https://tokens.1inch.io/0x056fd409e1d7a124bd7017459dfea2f387b6d5cd.png'], - }, - { - name: 'BAL', - pair: 'aBAL', - decimals: 18, - underLyingAssetName: 'aBAL', - logoURI: ['https://tokens.1inch.io/0xba100000625a3754423978a60c9317c58a424e3d.png'], - }, - { - name: 'xSUSHI', - pair: 'aXSUSHI', - decimals: 18, - underLyingAssetName: 'aXSUSHI', - logoURI: ['https://tokens.1inch.io/0x8798249c2e607446efb7ad49ec89dd1865ff4272.png'], - }, - { - name: 'renFIL', - pair: 'aRENFIL', - decimals: 18, - underLyingAssetName: 'aRENFIL', - logoURI: ['https://tokens.1inch.io/0xd5147bc8e386d91cc5dbe72099dac6c9b99276f5.png'], - }, - { - name: 'RAI', - pair: 'aRAI', - decimals: 18, - underLyingAssetName: 'aRAI', - logoURI: ['https://tokens.1inch.io/0x03ab458634910aad20ef5f1c8ee96f1d6ac54919.png'], - }, - { - name: 'AMPL', - pair: 'aAMPL', - decimals: 9, - underLyingAssetName: 'aAMPL', - logoURI: ['https://tokens.1inch.io/0xd46ba6d942050d489dbd938a2c909a5d5039a161.png'], - }, - { - name: 'USDP', - pair: 'aUSDP', - decimals: 18, - underLyingAssetName: 'aUSDP', - logoURI: ['https://tokens.1inch.io/0x8e870d67f660d95d5be530380d0ec0bd388289e1.png'], - }, - { - name: 'DPI', - pair: 'aDPI', - decimals: 18, - underLyingAssetName: 'aDPI', - logoURI: ['https://tokens.1inch.io/0x1494ca1f11d487c2bbe4543e90080aeba4ba3c2b.png'], - }, - { - name: 'FRAX', - pair: 'aFRAX', - decimals: 18, - underLyingAssetName: 'aFRAX', - logoURI: ['https://tokens.1inch.io/0x853d955acef822db058eb8505911ed77f175b99e.png'], - }, - { - name: 'FEI', - pair: 'aFEI', - decimals: 18, - underLyingAssetName: 'aFEI', - logoURI: ['https://tokens.1inch.io/0x956f47f50a910163d8bf957cf5846d573e7f87ca.png'], - }, +export const AAVE_PAIRS: [FungibleTokenDetailed, FungibleTokenDetailed][] = [ + [ + createERC20Tokens('USDT_ADDRESS', 'Tether USD', 'USDT', 6)[ChainId.Mainnet], + createERC20Tokens('aUSDT_ADDRESS', 'Aave Interest bearing USDT', 'aUSDT', 6)[ChainId.Mainnet], + ], + // { + // name: 'USDT', + // pair: 'aUSDT', + // decimals: 6, + // underLyingAssetName: 'aUSDT', + // logoURI: ['https://tokens.1inch.io/0xdac17f958d2ee523a2206206994597c13d831ec7.png'], + // }, + // { + // name: 'WBTC', + // pair: 'aWBTC', + // decimals: 8, + // underLyingAssetName: 'aWBTC', + // logoURI: ['https://tokens.1inch.io/0x2260fac5e5542a773aa44fbcfedf7c193bc2c599.png'], + // }, + // { + // name: 'WETH', + // pair: 'aWETH', + // decimals: 18, + // underLyingAssetName: 'aWETH', + // logoURI: ['https://tokens.1inch.io/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png'], + // }, + // { + // name: 'YFI', + // pair: 'aYFI', + // decimals: 18, + // underLyingAssetName: 'aYFI', + // logoURI: ['https://tokens.1inch.io/0x0bc529c00c6401aef6d220be8c6ea1667f6ad93e.png'], + // }, + // { + // name: 'ZRX', + // pair: 'aZRX', + // decimals: 18, + // underLyingAssetName: 'aZRX', + // logoURI: ['https://tokens.1inch.io/0xe41d2489571d322189246dafa5ebde1f4699f498.png'], + // }, + // { + // name: 'UNI', + // pair: 'aUNI', + // decimals: 18, + // underLyingAssetName: 'aUNI', + // logoURI: ['https://tokens.1inch.io/0x1f9840a85d5af5bf1d1762f925bdaddc4201f984.png'], + // }, + // { + // name: 'AAVE', + // pair: 'aAAVE', + // decimals: 18, + // underLyingAssetName: 'aAAVE', + // logoURI: ['https://tokens.1inch.io/0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9.png'], + // }, + // { + // name: 'BAT', + // pair: 'aBAT', + // decimals: 18, + // underLyingAssetName: 'aBAT', + // logoURI: ['https://tokens.1inch.io/0x0d8775f648430679a709e98d2b0cb6250d2887ef.png'], + // }, + // { + // name: 'BUSD', + // pair: 'aBUSD', + // decimals: 18, + // underLyingAssetName: 'aBUSD', + // logoURI: ['https://tokens.1inch.io/0x4fabb145d64652a948d72533023f6e7a623c7c53.png'], + // }, + // { + // name: 'DAI', + // pair: 'aDAI', + // decimals: 18, + // underLyingAssetName: 'aDAI', + // logoURI: ['https://tokens.1inch.io/0x6b175474e89094c44da98b954eedeac495271d0f.png'], + // }, + // { + // name: 'ENJ', + // pair: 'aENJ', + // decimals: 18, + // underLyingAssetName: 'aENJ', + // logoURI: ['https://tokens.1inch.io/0xf629cbd94d3791c9250152bd8dfbdf380e2a3b9c.png'], + // }, + // { + // name: 'KNC', + // pair: 'aKNC', + // decimals: 18, + // underLyingAssetName: 'aKNC', + // logoURI: ['https://tokens.1inch.io/0xdd974d5c2e2928dea5f71b9825b8b646686bd200.png'], + // }, + // { + // name: 'LINK', + // pair: 'aLINK', + // decimals: 18, + // underLyingAssetName: 'aLINK', + // logoURI: ['https://tokens.1inch.io/0x514910771af9ca656af840dff83e8264ecf986ca.png'], + // }, + // { + // name: 'MANA', + // pair: 'aMANA', + // decimals: 18, + // underLyingAssetName: 'aMANA', + // logoURI: ['https://tokens.1inch.io/0x0f5d2fb29fb7d3cfee444a200298f468908cc942.png'], + // }, + // { + // name: 'MKR', + // pair: 'aMKR', + // decimals: 18, + // underLyingAssetName: 'aMKR', + // logoURI: ['https://tokens.1inch.io/0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2.png'], + // }, + // { + // name: 'REN', + // pair: 'aREN', + // decimals: 18, + // underLyingAssetName: 'aREN', + // logoURI: ['https://tokens.1inch.io/0x408e41876cccdc0f92210600ef50372656052a38.png'], + // }, + // { + // name: 'SNX', + // pair: 'aSNX', + // decimals: 18, + // underLyingAssetName: 'aSNX', + // logoURI: ['https://tokens.1inch.io/0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f.png'], + // }, + // { + // name: 'sUSD', + // pair: 'aSUSD', + // decimals: 18, + // underLyingAssetName: 'aSUSD', + // logoURI: ['https://tokens.1inch.io/0x57ab1ec28d129707052df4df418d58a2d46d5f51.png'], + // }, + // { + // name: 'TUSD', + // pair: 'aTUSD', + // decimals: 18, + // underLyingAssetName: 'aTUSD', + // logoURI: ['https://tokens.1inch.io/0x0000000000085d4780b73119b644ae5ecd22b376.png'], + // }, + // { + // name: 'USDC', + // pair: 'aUSDC', + // decimals: 6, + // underLyingAssetName: 'aUSDC', + // logoURI: ['https://tokens.1inch.io/0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48.png'], + // }, + // { + // name: 'CRV', + // pair: 'aCRV', + // decimals: 18, + // underLyingAssetName: 'aCRV', + // logoURI: ['https://tokens.1inch.io/0xd533a949740bb3306d119cc777fa900ba034cd52.png'], + // }, + // { + // name: 'GUSD', + // pair: 'aGUSD', + // decimals: 2, + // underLyingAssetName: 'aGUSD', + // logoURI: ['https://tokens.1inch.io/0x056fd409e1d7a124bd7017459dfea2f387b6d5cd.png'], + // }, + // { + // name: 'BAL', + // pair: 'aBAL', + // decimals: 18, + // underLyingAssetName: 'aBAL', + // logoURI: ['https://tokens.1inch.io/0xba100000625a3754423978a60c9317c58a424e3d.png'], + // }, + // { + // name: 'xSUSHI', + // pair: 'aXSUSHI', + // decimals: 18, + // underLyingAssetName: 'aXSUSHI', + // logoURI: ['https://tokens.1inch.io/0x8798249c2e607446efb7ad49ec89dd1865ff4272.png'], + // }, + // { + // name: 'renFIL', + // pair: 'aRENFIL', + // decimals: 18, + // underLyingAssetName: 'aRENFIL', + // logoURI: ['https://tokens.1inch.io/0xd5147bc8e386d91cc5dbe72099dac6c9b99276f5.png'], + // }, + // { + // name: 'RAI', + // pair: 'aRAI', + // decimals: 18, + // underLyingAssetName: 'aRAI', + // logoURI: ['https://tokens.1inch.io/0x03ab458634910aad20ef5f1c8ee96f1d6ac54919.png'], + // }, + // { + // name: 'AMPL', + // pair: 'aAMPL', + // decimals: 9, + // underLyingAssetName: 'aAMPL', + // logoURI: ['https://tokens.1inch.io/0xd46ba6d942050d489dbd938a2c909a5d5039a161.png'], + // }, + // { + // name: 'USDP', + // pair: 'aUSDP', + // decimals: 18, + // underLyingAssetName: 'aUSDP', + // logoURI: ['https://tokens.1inch.io/0x8e870d67f660d95d5be530380d0ec0bd388289e1.png'], + // }, + // { + // name: 'DPI', + // pair: 'aDPI', + // decimals: 18, + // underLyingAssetName: 'aDPI', + // logoURI: ['https://tokens.1inch.io/0x1494ca1f11d487c2bbe4543e90080aeba4ba3c2b.png'], + // }, + // { + // name: 'FRAX', + // pair: 'aFRAX', + // decimals: 18, + // underLyingAssetName: 'aFRAX', + // logoURI: ['https://tokens.1inch.io/0x853d955acef822db058eb8505911ed77f175b99e.png'], + // }, + // { + // name: 'FEI', + // pair: 'aFEI', + // decimals: 18, + // underLyingAssetName: 'aFEI', + // logoURI: ['https://tokens.1inch.io/0x956f47f50a910163d8bf957cf5846d573e7f87ca.png'], + // }, ] diff --git a/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts b/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts index 4f2fa6ea446f..06bc7f698884 100644 --- a/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts +++ b/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts @@ -1,7 +1,8 @@ +import BigNumber from 'bignumber.js' +import { pow10, ZERO } from '@masknet/web3-shared-base' import type Web3 from 'web3' import type { AbiItem } from 'web3-utils' import { - EthereumTokenType, ChainId, getSavingsConstants, createContract, @@ -10,118 +11,51 @@ import { } from '@masknet/web3-shared-evm' import type { AaveLendingPool } from '@masknet/web3-contracts/types/AaveLendingPool' import type { AaveLendingPoolAddressProvider } from '@masknet/web3-contracts/types/AaveLendingPoolAddressProvider' - import AaveLendingPoolAddressProviderABI from '@masknet/web3-contracts/abis/AaveLendingPoolAddressProvider.json' import AaveLendingPoolABI from '@masknet/web3-contracts/abis/AaveLendingPool.json' -import BigNumber from 'bignumber.js' -import { ProtocolCategory, SavingsNetwork, SavingsProtocol, ProtocolType, ProtocolToken } from '../types' -import { pow10, ZERO } from '@masknet/web3-shared-base' -import type Savings from '@masknet/web3-constants/evm/savings.json' -import { AAVE_PAIRS } from '../constants' +import { ProtocolType, SavingsProtocol } from '../types' -export interface ContractListArray { - [index: string]: { - address: string - } -} +export class AAVEProtocol implements SavingsProtocol { + static DEFAULT_APR = '0.17' -export interface AaveContract { - type: EthereumTokenType - chainName: string - subgraphUrl: string - aaveLendingPoolAddressProviderContract: string - aaveContract: string - stEthContract: string - assetContractAddresses: ContractListArray -} + private _apr = '0.00' + private _balance = ZERO + + constructor(readonly pair: [FungibleTokenDetailed, FungibleTokenDetailed]) {} -export function getAaveContract(chainId: ChainId): AaveContract { - const constants = getSavingsConstants(chainId) - - return { - type: EthereumTokenType.ERC20, - chainName: ChainId[chainId], - subgraphUrl: constants.AAVE_SUBGRAPHS ?? '', - aaveLendingPoolAddressProviderContract: - constants.AAVE_LENDING_POOL_ADDRESSES_PROVIDER_CONTRACT_ADDRESS ?? ZERO_ADDRESS, - aaveContract: constants.AAVE ?? ZERO_ADDRESS, - stEthContract: constants.AAVE ?? ZERO_ADDRESS, - assetContractAddresses: { - AAVE: { address: constants.AAVE ?? ZERO_ADDRESS }, - }, + get type() { + return ProtocolType.AAVE } -} -export class AAVEProtocol implements SavingsProtocol { - public apr = '0.00' - public balance = ZERO - public readonly DEFAULT_APR = '0.17' - - public availableNetworks: SavingsNetwork[] = [] - - public constructor( - public category = ProtocolCategory.ETH, - public type = ProtocolType.AAVE, - public name = 'AAVE', - public symbol = 'AAVE', - public image = 'aave', - public base: keyof typeof AAVE_PAIRS = 'AAVE', - public pair = 'aAAVE', - public decimals = 18, - public underLyingAssetName = 'AAVE Interest Bearing AAVE', - public logoURI: string[] = ['https://tokens.1inch.io/0xffc97d72e13e01096502cb8eb52dee56f74dad7b.png'], - ) { - this.availableNetworks = [ - { - chainId: ChainId.Mainnet, - chainName: 'Ethereum', - contractAddress: getSavingsConstants(ChainId.Mainnet)[this.base] || ZERO_ADDRESS, - }, - { - chainId: ChainId.Kovan, - chainName: 'Kovan', - contractAddress: getSavingsConstants(ChainId.Kovan)[this.base] || ZERO_ADDRESS, - }, - ] + get apr() { + return this._apr } - token: ProtocolToken - - public bareTokenDetailed(chainId: ChainId): FungibleTokenDetailed { - return { - type: EthereumTokenType.ERC20, - chainId: chainId, - address: getSavingsConstants(chainId)[this.base], - symbol: this.symbol, - decimals: this.decimals, - name: this.underLyingAssetName, - logoURI: this.logoURI, - } + + get balance() { + return this._balance } - public stakeTokenDetailed(chainId: ChainId): FungibleTokenDetailed { - return { - type: EthereumTokenType.ERC20, - chainId: chainId, - address: getSavingsConstants(chainId)[this.base], - symbol: this.symbol, - decimals: this.decimals, - name: this.underLyingAssetName, - logoURI: this.logoURI, - } + get bareToken() { + return this.pair[0] + } + + get stakeToken() { + return this.pair[1] } - public async getApr(chainId: ChainId) { + public async updateApr(chainId: ChainId, web3: Web3) { try { const subgraphUrl = getSavingsConstants(chainId).AAVE_SUBGRAPHS || '' + if (!subgraphUrl) { - this.apr = this.DEFAULT_APR - return this.apr + this._apr = AAVEProtocol.DEFAULT_APR + return } const body = JSON.stringify({ query: `{ reserves (where: { - underlyingAsset: "${getSavingsConstants(chainId)[this.base] || ZERO_ADDRESS}" + underlyingAsset: "${this.bareToken.address}" }) { id name @@ -155,24 +89,19 @@ export class AAVEProtocol implements SavingsProtocol { const SECONDS_PER_YEAR = 31536000 // APY and APR are returned here as decimals, multiply by 100 to get the percents - const apr = new BigNumber(liquidityRate).div(RAY) - this.apr = apr.toFixed(2) - return apr.toFixed(2) + this._apr = new BigNumber(liquidityRate).div(RAY).toFixed(2) } catch (error) { - console.log('AAVE `getApr()` error', error) - // Default APR - this.apr = this.DEFAULT_APR - return this.apr + this._apr = AAVEProtocol.DEFAULT_APR } } - public async getBalance(chainId: ChainId, web3: Web3, account: string) { + public async updateBalance(chainId: ChainId, web3: Web3, account: string) { try { const subgraphUrl = getSavingsConstants(chainId).AAVE_SUBGRAPHS || '' const reserveBody = JSON.stringify({ query: `{ reserves (where: { - underlyingAsset: "${getSavingsConstants(chainId)[this.base] || ZERO_ADDRESS}" + underlyingAsset: "${this.bareToken.address}" }) { id name @@ -237,13 +166,9 @@ export class AAVEProtocol implements SavingsProtocol { } } = await userReserveResponse.json() - const balance = userResponse.data.userReserves[0].currentATokenBalance - this.balance = new BigNumber(balance || '0') - return this.balance + this._balance = new BigNumber(userResponse.data.userReserves[0].currentATokenBalance || '0') } catch (error) { - console.log('AAVE `getBalance()` error', error) - this.balance = new BigNumber('0') - return this.balance + this._balance = ZERO } } @@ -256,7 +181,6 @@ export class AAVEProtocol implements SavingsProtocol { return new BigNumber(gasEstimate || 0) } catch (error) { - console.error('AAVE `depositEstimate()` Error', error) return ZERO } } @@ -277,12 +201,7 @@ export class AAVEProtocol implements SavingsProtocol { poolAddress || ZERO_ADDRESS, AaveLendingPoolABI as AbiItem[], ) - return contract?.methods.deposit( - getSavingsConstants(chainId)[this.base] || ZERO_ADDRESS, - new BigNumber(value).toFixed(), - account, - '0', - ) + return contract?.methods.deposit(this.bareToken.address, new BigNumber(value).toFixed(), account, '0') } public async deposit(account: string, chainId: ChainId, web3: Web3, value: BigNumber.Value) { @@ -298,7 +217,6 @@ export class AAVEProtocol implements SavingsProtocol { } return false } catch (error) { - console.error('AAVE `deposit()` Error', error) return false } } @@ -319,17 +237,12 @@ export class AAVEProtocol implements SavingsProtocol { AaveLendingPoolABI as AbiItem[], ) const gasEstimate = await contract?.methods - .withdraw( - getSavingsConstants(chainId)[this.base] || ZERO_ADDRESS, - new BigNumber(value).toFixed(), - account, - ) + .withdraw(this.bareToken.address, new BigNumber(value).toFixed(), account) .estimateGas({ from: account, }) return new BigNumber(gasEstimate || 0) } catch (error) { - console.error('AAVE `withdrawEstimate()` Error', error) return ZERO } } @@ -350,36 +263,13 @@ export class AAVEProtocol implements SavingsProtocol { poolAddress || ZERO_ADDRESS, AaveLendingPoolABI as AbiItem[], ) - await contract?.methods - .withdraw( - getSavingsConstants(chainId)[this.base] || ZERO_ADDRESS, - new BigNumber(value).toFixed(), - account, - ) - .send({ - from: account, - gas: gasEstimate.toNumber(), - }) + await contract?.methods.withdraw(this.bareToken.address, new BigNumber(value).toFixed(), account).send({ + from: account, + gas: gasEstimate.toNumber(), + }) return true } catch (error) { - console.error('AAVE `withdraw()` Error', error) return false } } } - -export default AAVE_PAIRS.map( - (p) => - new AAVEProtocol( - ProtocolCategory.ETH, - ProtocolType.AAVE, - p.name, - p.name, - p.name.toLowerCase(), - p.name, - p.pair, - p.decimals, - p.underLyingAssetName, - p.logoURI, - ), -) diff --git a/packages/mask/src/plugins/Savings/protocols/LDOProtocol.ts b/packages/mask/src/plugins/Savings/protocols/LDOProtocol.ts index 24287d92f218..1388564d69ec 100644 --- a/packages/mask/src/plugins/Savings/protocols/LDOProtocol.ts +++ b/packages/mask/src/plugins/Savings/protocols/LDOProtocol.ts @@ -1,5 +1,6 @@ import type Web3 from 'web3' import type { AbiItem } from 'web3-utils' +import BigNumber from 'bignumber.js' import { ChainId, getSavingsConstants, @@ -7,11 +8,10 @@ import { FungibleTokenDetailed, ZERO_ADDRESS, } from '@masknet/web3-shared-evm' +import { ZERO } from '@masknet/web3-shared-base' import type { Lido } from '@masknet/web3-contracts/types/Lido' import LidoABI from '@masknet/web3-contracts/abis/Lido.json' -import BigNumber from 'bignumber.js' import { SavingsProtocol, ProtocolType } from '../types' -import { ZERO } from '@masknet/web3-shared-base' export class LidoProtocol implements SavingsProtocol { private _apr = '0.00' @@ -19,7 +19,7 @@ export class LidoProtocol implements SavingsProtocol { readonly type = ProtocolType.Lido - constructor(public readonly pair: [FungibleTokenDetailed, FungibleTokenDetailed]) {} + constructor(readonly pair: [FungibleTokenDetailed, FungibleTokenDetailed]) {} get apr() { return this._apr diff --git a/packages/mask/src/plugins/Savings/protocols/index.ts b/packages/mask/src/plugins/Savings/protocols/index.ts index 6154e861091f..c4e741db42d2 100644 --- a/packages/mask/src/plugins/Savings/protocols/index.ts +++ b/packages/mask/src/plugins/Savings/protocols/index.ts @@ -1,6 +1,8 @@ -import { LDO_PAIRS } from '../constants' -import type { SavingsProtocol } from '../types' +import { AAVE_PAIRS, LDO_PAIRS } from '../constants' import { LidoProtocol } from './LDOProtocol' -// import AAVEProtocol from './AAVEProtocol' +import { AAVEProtocol } from './AAVEProtocol' -export const SavingsProtocols: SavingsProtocol[] = [...LDO_PAIRS.map((pair) => new LidoProtocol(pair))] +export const SavingsProtocols = [ + ...LDO_PAIRS.map((pair) => new LidoProtocol(pair)), + ...AAVE_PAIRS.map((pair) => new AAVEProtocol(pair)), +] diff --git a/packages/web3-constants/evm/token.json b/packages/web3-constants/evm/token.json index 79f6ce3e19cd..0c1ce938f720 100644 --- a/packages/web3-constants/evm/token.json +++ b/packages/web3-constants/evm/token.json @@ -20,7 +20,24 @@ "Aurora_Testnet": "" }, "LDO_ADDRESS": { - "Mainnet": "0x5a98fcbea516cf06857215779fd812ca3bef1b32" + "Mainnet": "0x5a98fcbea516cf06857215779fd812ca3bef1b32", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" }, "LDO_stETH": { "Mainnet": "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84", @@ -82,6 +99,26 @@ "Aurora": "0x4988a896b1227218e4a686fde5eabdcabd91571f", "Aurora_Testnet": "" }, + "aUSDT_ADDRESS": { + "Mainnet": "0x71fc860F7D3A592A4a98740e39dB31d25db65ae8", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "0x1643E812aE58766192Cf7D2Cf9567dF2C37e9B7F", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, "HUSD_ADDRESS": { "Mainnet": "0xdf574c24545e5ffecb9a659c229253d4111d87e1", "Ropsten": "", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 85e41297d14d..a422ad98a556 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -309,7 +309,6 @@ importers: '@masknet/shared': workspace:* '@masknet/shared-base': workspace:* '@masknet/theme': workspace:* - '@masknet/web3-constants': workspace:* '@masknet/web3-contracts': workspace:* '@masknet/web3-providers': workspace:* '@masknet/web3-shared-base': workspace:* @@ -446,7 +445,6 @@ importers: '@masknet/shared': link:../shared '@masknet/shared-base': link:../shared-base '@masknet/theme': link:../theme - '@masknet/web3-constants': link:../web3-constants '@masknet/web3-contracts': link:../web3-contracts '@masknet/web3-providers': link:../web3-providers '@masknet/web3-shared-base': link:../web3-shared/base From 9cebd5150a7a4e94064cde969b61d1c1b9b17d1a Mon Sep 17 00:00:00 2001 From: "@layinka" Date: Thu, 3 Mar 2022 12:42:13 +0100 Subject: [PATCH 15/38] Added aave coins to savings json --- packages/web3-constants/evm/savings.json | 604 ++++++++++++++++++++++- 1 file changed, 603 insertions(+), 1 deletion(-) diff --git a/packages/web3-constants/evm/savings.json b/packages/web3-constants/evm/savings.json index 4ff427d29b7d..cdeac159aa38 100644 --- a/packages/web3-constants/evm/savings.json +++ b/packages/web3-constants/evm/savings.json @@ -121,5 +121,607 @@ "Fantom": "", "Aurora": "", "Aurora_Testnet": "" - } + }, + + "USDT" : { + "Mainnet" : "0xdAC17F958D2ee523a2206206994597C13D831ec7", + "Ropsten" : "", + "Rinkeby" : "", + "Kovan" : "0x13512979ADE267AB5100878E2e0f485B568328a4", + "Gorli" : "", + "BSC" : "", + "BSCT" : "", + "Matic" : "", + "Mumbai" : "", + "Arbitrum" : "", + "Arbitrum_Rinkeby" : "", + "xDai" : "", + "Avalanche" : "", + "Avalanche_Fuji" : "", + "Celo" : "", + "Fantom" : "", + "Aurora" : "", + "Aurora_Testnet" : "" + }, + "WBTC" : { + "Mainnet" : "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599", + "Ropsten" : "", + "Rinkeby" : "", + "Kovan" : "0xD1B98B6607330172f1D991521145A22BCe793277", + "Gorli" : "", + "BSC" : "", + "BSCT" : "", + "Matic" : "", + "Mumbai" : "", + "Arbitrum" : "", + "Arbitrum_Rinkeby" : "", + "xDai" : "", + "Avalanche" : "", + "Avalanche_Fuji" : "", + "Celo" : "", + "Fantom" : "", + "Aurora" : "", + "Aurora_Testnet" : "" + }, + "WETH" : { + "Mainnet" : "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", + "Ropsten" : "", + "Rinkeby" : "", + "Kovan" : "0xd0A1E359811322d97991E03f863a0C30C2cF029C", + "Gorli" : "", + "BSC" : "", + "BSCT" : "", + "Matic" : "", + "Mumbai" : "", + "Arbitrum" : "", + "Arbitrum_Rinkeby" : "", + "xDai" : "", + "Avalanche" : "", + "Avalanche_Fuji" : "", + "Celo" : "", + "Fantom" : "", + "Aurora" : "", + "Aurora_Testnet" : "" + }, + "YFI" : { + "Mainnet" : "0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e", + "Ropsten" : "", + "Rinkeby" : "", + "Kovan" : "0xb7c325266ec274fEb1354021D27FA3E3379D840d", + "Gorli" : "", + "BSC" : "", + "BSCT" : "", + "Matic" : "", + "Mumbai" : "", + "Arbitrum" : "", + "Arbitrum_Rinkeby" : "", + "xDai" : "", + "Avalanche" : "", + "Avalanche_Fuji" : "", + "Celo" : "", + "Fantom" : "", + "Aurora" : "", + "Aurora_Testnet" : "" + }, + "ZRX" : { + "Mainnet" : "0xE41d2489571d322189246DaFA5ebDe1F4699F498", + "Ropsten" : "", + "Rinkeby" : "", + "Kovan" : "0xD0d76886cF8D952ca26177EB7CfDf83bad08C00C", + "Gorli" : "", + "BSC" : "", + "BSCT" : "", + "Matic" : "", + "Mumbai" : "", + "Arbitrum" : "", + "Arbitrum_Rinkeby" : "", + "xDai" : "", + "Avalanche" : "", + "Avalanche_Fuji" : "", + "Celo" : "", + "Fantom" : "", + "Aurora" : "", + "Aurora_Testnet" : "" + }, + "UNI" : { + "Mainnet" : "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984", + "Ropsten" : "", + "Rinkeby" : "", + "Kovan" : "0x075A36BA8846C6B6F53644fDd3bf17E5151789DC", + "Gorli" : "", + "BSC" : "", + "BSCT" : "", + "Matic" : "", + "Mumbai" : "", + "Arbitrum" : "", + "Arbitrum_Rinkeby" : "", + "xDai" : "", + "Avalanche" : "", + "Avalanche_Fuji" : "", + "Celo" : "", + "Fantom" : "", + "Aurora" : "", + "Aurora_Testnet" : "" + }, + + "BAT" : { + "Mainnet" : "0x0D8775F648430679A709E98d2b0Cb6250d2887EF", + "Ropsten" : "", + "Rinkeby" : "", + "Kovan" : "0x2d12186Fbb9f9a8C28B3FfdD4c42920f8539D738", + "Gorli" : "", + "BSC" : "", + "BSCT" : "", + "Matic" : "", + "Mumbai" : "", + "Arbitrum" : "", + "Arbitrum_Rinkeby" : "", + "xDai" : "", + "Avalanche" : "", + "Avalanche_Fuji" : "", + "Celo" : "", + "Fantom" : "", + "Aurora" : "", + "Aurora_Testnet" : "" + }, + "BUSD" : { + "Mainnet" : "0x4Fabb145d64652a948d72533023f6E7A623C7C53", + "Ropsten" : "", + "Rinkeby" : "", + "Kovan" : "0x4c6E1EFC12FDfD568186b7BAEc0A43fFfb4bCcCf", + "Gorli" : "", + "BSC" : "", + "BSCT" : "", + "Matic" : "", + "Mumbai" : "", + "Arbitrum" : "", + "Arbitrum_Rinkeby" : "", + "xDai" : "", + "Avalanche" : "", + "Avalanche_Fuji" : "", + "Celo" : "", + "Fantom" : "", + "Aurora" : "", + "Aurora_Testnet" : "" + }, + "DAI" : { + "Mainnet" : "0x6B175474E89094C44Da98b954EedeAC495271d0F", + "Ropsten" : "", + "Rinkeby" : "", + "Kovan" : "0xFf795577d9AC8bD7D90Ee22b6C1703490b6512FD", + "Gorli" : "", + "BSC" : "", + "BSCT" : "", + "Matic" : "", + "Mumbai" : "", + "Arbitrum" : "", + "Arbitrum_Rinkeby" : "", + "xDai" : "", + "Avalanche" : "", + "Avalanche_Fuji" : "", + "Celo" : "", + "Fantom" : "", + "Aurora" : "", + "Aurora_Testnet" : "" + }, + "ENJ" : { + "Mainnet" : "0xF629cBd94d3791C9250152BD8dfBDF380E2a3B9c", + "Ropsten" : "", + "Rinkeby" : "", + "Kovan" : "0xC64f90Cd7B564D3ab580eb20a102A8238E218be2", + "Gorli" : "", + "BSC" : "", + "BSCT" : "", + "Matic" : "", + "Mumbai" : "", + "Arbitrum" : "", + "Arbitrum_Rinkeby" : "", + "xDai" : "", + "Avalanche" : "", + "Avalanche_Fuji" : "", + "Celo" : "", + "Fantom" : "", + "Aurora" : "", + "Aurora_Testnet" : "" + }, + "KNC" : { + "Mainnet" : "0xdd974D5C2e2928deA5F71b9825b8b646686BD200", + "Ropsten" : "", + "Rinkeby" : "", + "Kovan" : "0x3F80c39c0b96A0945f9F0E9f55d8A8891c5671A8", + "Gorli" : "", + "BSC" : "", + "BSCT" : "", + "Matic" : "", + "Mumbai" : "", + "Arbitrum" : "", + "Arbitrum_Rinkeby" : "", + "xDai" : "", + "Avalanche" : "", + "Avalanche_Fuji" : "", + "Celo" : "", + "Fantom" : "", + "Aurora" : "", + "Aurora_Testnet" : "" + }, + "LINK" : { + "Mainnet" : "0x514910771AF9Ca656af840dff83E8264EcF986CA", + "Ropsten" : "", + "Rinkeby" : "", + "Kovan" : "0xAD5ce863aE3E4E9394Ab43d4ba0D80f419F61789", + "Gorli" : "", + "BSC" : "", + "BSCT" : "", + "Matic" : "", + "Mumbai" : "", + "Arbitrum" : "", + "Arbitrum_Rinkeby" : "", + "xDai" : "", + "Avalanche" : "", + "Avalanche_Fuji" : "", + "Celo" : "", + "Fantom" : "", + "Aurora" : "", + "Aurora_Testnet" : "" + }, + "MANA" : { + "Mainnet" : "0x0F5D2fB29fb7d3CFeE444a200298f468908cC942", + "Ropsten" : "", + "Rinkeby" : "", + "Kovan" : "0x738Dc6380157429e957d223e6333Dc385c85Fec7", + "Gorli" : "", + "BSC" : "", + "BSCT" : "", + "Matic" : "", + "Mumbai" : "", + "Arbitrum" : "", + "Arbitrum_Rinkeby" : "", + "xDai" : "", + "Avalanche" : "", + "Avalanche_Fuji" : "", + "Celo" : "", + "Fantom" : "", + "Aurora" : "", + "Aurora_Testnet" : "" + }, + "MKR" : { + "Mainnet" : "0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2", + "Ropsten" : "", + "Rinkeby" : "", + "Kovan" : "0x61e4CAE3DA7FD189e52a4879C7B8067D7C2Cc0FA", + "Gorli" : "", + "BSC" : "", + "BSCT" : "", + "Matic" : "", + "Mumbai" : "", + "Arbitrum" : "", + "Arbitrum_Rinkeby" : "", + "xDai" : "", + "Avalanche" : "", + "Avalanche_Fuji" : "", + "Celo" : "", + "Fantom" : "", + "Aurora" : "", + "Aurora_Testnet" : "" + }, + "REN" : { + "Mainnet" : "0x408e41876cCCDC0F92210600ef50372656052a38", + "Ropsten" : "", + "Rinkeby" : "", + "Kovan" : "0x5eebf65A6746eed38042353Ba84c8e37eD58Ac6f", + "Gorli" : "", + "BSC" : "", + "BSCT" : "", + "Matic" : "", + "Mumbai" : "", + "Arbitrum" : "", + "Arbitrum_Rinkeby" : "", + "xDai" : "", + "Avalanche" : "", + "Avalanche_Fuji" : "", + "Celo" : "", + "Fantom" : "", + "Aurora" : "", + "Aurora_Testnet" : "" + }, + "SNX" : { + "Mainnet" : "0xC011a73ee8576Fb46F5E1c5751cA3B9Fe0af2a6F", + "Ropsten" : "", + "Rinkeby" : "", + "Kovan" : "0x7FDb81B0b8a010dd4FFc57C3fecbf145BA8Bd947", + "Gorli" : "", + "BSC" : "", + "BSCT" : "", + "Matic" : "", + "Mumbai" : "", + "Arbitrum" : "", + "Arbitrum_Rinkeby" : "", + "xDai" : "", + "Avalanche" : "", + "Avalanche_Fuji" : "", + "Celo" : "", + "Fantom" : "", + "Aurora" : "", + "Aurora_Testnet" : "" + }, + "sUSD" : { + "Mainnet" : "0x57Ab1ec28D129707052df4dF418D58a2D46d5f51", + "Ropsten" : "", + "Rinkeby" : "", + "Kovan" : "0x99b267b9D96616f906D53c26dECf3C5672401282", + "Gorli" : "", + "BSC" : "", + "BSCT" : "", + "Matic" : "", + "Mumbai" : "", + "Arbitrum" : "", + "Arbitrum_Rinkeby" : "", + "xDai" : "", + "Avalanche" : "", + "Avalanche_Fuji" : "", + "Celo" : "", + "Fantom" : "", + "Aurora" : "", + "Aurora_Testnet" : "" + }, + "TUSD" : { + "Mainnet" : "0x0000000000085d4780B73119b644AE5ecd22b376", + "Ropsten" : "", + "Rinkeby" : "", + "Kovan" : "0x016750AC630F711882812f24Dba6c95b9D35856d", + "Gorli" : "", + "BSC" : "", + "BSCT" : "", + "Matic" : "", + "Mumbai" : "", + "Arbitrum" : "", + "Arbitrum_Rinkeby" : "", + "xDai" : "", + "Avalanche" : "", + "Avalanche_Fuji" : "", + "Celo" : "", + "Fantom" : "", + "Aurora" : "", + "Aurora_Testnet" : "" + }, + "USDC" : { + "Mainnet" : "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", + "Ropsten" : "", + "Rinkeby" : "", + "Kovan" : "0xe22da380ee6B445bb8273C81944ADEB6E8450422", + "Gorli" : "", + "BSC" : "", + "BSCT" : "", + "Matic" : "", + "Mumbai" : "", + "Arbitrum" : "", + "Arbitrum_Rinkeby" : "", + "xDai" : "", + "Avalanche" : "", + "Avalanche_Fuji" : "", + "Celo" : "", + "Fantom" : "", + "Aurora" : "", + "Aurora_Testnet" : "" + }, + "CRV" : { + "Mainnet" : "0xD533a949740bb3306d119CC777fa900bA034cd52", + "Ropsten" : "", + "Rinkeby" : "", + "Kovan" : "", + "Gorli" : "", + "BSC" : "", + "BSCT" : "", + "Matic" : "", + "Mumbai" : "", + "Arbitrum" : "", + "Arbitrum_Rinkeby" : "", + "xDai" : "", + "Avalanche" : "", + "Avalanche_Fuji" : "", + "Celo" : "", + "Fantom" : "", + "Aurora" : "", + "Aurora_Testnet" : "" + }, + "GUSD" : { + "Mainnet" : "0x056Fd409E1d7A124BD7017459dFEa2F387b6d5Cd", + "Ropsten" : "", + "Rinkeby" : "", + "Kovan" : "", + "Gorli" : "", + "BSC" : "", + "BSCT" : "", + "Matic" : "", + "Mumbai" : "", + "Arbitrum" : "", + "Arbitrum_Rinkeby" : "", + "xDai" : "", + "Avalanche" : "", + "Avalanche_Fuji" : "", + "Celo" : "", + "Fantom" : "", + "Aurora" : "", + "Aurora_Testnet" : "" + }, + "BAL" : { + "Mainnet" : "0xba100000625a3754423978a60c9317c58a424e3D", + "Ropsten" : "", + "Rinkeby" : "", + "Kovan" : "", + "Gorli" : "", + "BSC" : "", + "BSCT" : "", + "Matic" : "", + "Mumbai" : "", + "Arbitrum" : "", + "Arbitrum_Rinkeby" : "", + "xDai" : "", + "Avalanche" : "", + "Avalanche_Fuji" : "", + "Celo" : "", + "Fantom" : "", + "Aurora" : "", + "Aurora_Testnet" : "" + }, + "xSUSHI" : { + "Mainnet" : "0x8798249c2E607446EfB7Ad49eC89dD1865Ff4272", + "Ropsten" : "", + "Rinkeby" : "", + "Kovan" : "", + "Gorli" : "", + "BSC" : "", + "BSCT" : "", + "Matic" : "", + "Mumbai" : "", + "Arbitrum" : "", + "Arbitrum_Rinkeby" : "", + "xDai" : "", + "Avalanche" : "", + "Avalanche_Fuji" : "", + "Celo" : "", + "Fantom" : "", + "Aurora" : "", + "Aurora_Testnet" : "" + }, + "renFIL" : { + "Mainnet" : "0xD5147bc8e386d91Cc5DBE72099DAC6C9b99276F5", + "Ropsten" : "", + "Rinkeby" : "", + "Kovan" : "", + "Gorli" : "", + "BSC" : "", + "BSCT" : "", + "Matic" : "", + "Mumbai" : "", + "Arbitrum" : "", + "Arbitrum_Rinkeby" : "", + "xDai" : "", + "Avalanche" : "", + "Avalanche_Fuji" : "", + "Celo" : "", + "Fantom" : "", + "Aurora" : "", + "Aurora_Testnet" : "" + }, + "RAI" : { + "Mainnet" : "0x03ab458634910AaD20eF5f1C8ee96F1D6ac54919", + "Ropsten" : "", + "Rinkeby" : "", + "Kovan" : "", + "Gorli" : "", + "BSC" : "", + "BSCT" : "", + "Matic" : "", + "Mumbai" : "", + "Arbitrum" : "", + "Arbitrum_Rinkeby" : "", + "xDai" : "", + "Avalanche" : "", + "Avalanche_Fuji" : "", + "Celo" : "", + "Fantom" : "", + "Aurora" : "", + "Aurora_Testnet" : "" + }, + "AMPL" : { + "Mainnet" : "0xD46bA6D942050d489DBd938a2C909A5d5039A161", + "Ropsten" : "", + "Rinkeby" : "", + "Kovan" : "0x3E0437898a5667a4769B1Ca5A34aAB1ae7E81377", + "Gorli" : "", + "BSC" : "", + "BSCT" : "", + "Matic" : "", + "Mumbai" : "", + "Arbitrum" : "", + "Arbitrum_Rinkeby" : "", + "xDai" : "", + "Avalanche" : "", + "Avalanche_Fuji" : "", + "Celo" : "", + "Fantom" : "", + "Aurora" : "", + "Aurora_Testnet" : "" + }, + "USDP" : { + "Mainnet" : "0x8E870D67F660D95d5be530380D0eC0bd388289E1", + "Ropsten" : "", + "Rinkeby" : "", + "Kovan" : "", + "Gorli" : "", + "BSC" : "", + "BSCT" : "", + "Matic" : "", + "Mumbai" : "", + "Arbitrum" : "", + "Arbitrum_Rinkeby" : "", + "xDai" : "", + "Avalanche" : "", + "Avalanche_Fuji" : "", + "Celo" : "", + "Fantom" : "", + "Aurora" : "", + "Aurora_Testnet" : "" + }, + "DPI" : { + "Mainnet" : "0x1494CA1F11D487c2bBe4543E90080AeBa4BA3C2b", + "Ropsten" : "", + "Rinkeby" : "", + "Kovan" : "", + "Gorli" : "", + "BSC" : "", + "BSCT" : "", + "Matic" : "", + "Mumbai" : "", + "Arbitrum" : "", + "Arbitrum_Rinkeby" : "", + "xDai" : "", + "Avalanche" : "", + "Avalanche_Fuji" : "", + "Celo" : "", + "Fantom" : "", + "Aurora" : "", + "Aurora_Testnet" : "" + }, + "FRAX" : { + "Mainnet" : "0x853d955aCEf822Db058eb8505911ED77F175b99e", + "Ropsten" : "", + "Rinkeby" : "", + "Kovan" : "", + "Gorli" : "", + "BSC" : "", + "BSCT" : "", + "Matic" : "", + "Mumbai" : "", + "Arbitrum" : "", + "Arbitrum_Rinkeby" : "", + "xDai" : "", + "Avalanche" : "", + "Avalanche_Fuji" : "", + "Celo" : "", + "Fantom" : "", + "Aurora" : "", + "Aurora_Testnet" : "" + }, + "FEI" : { + "Mainnet" : "0x956F47F50A910163D8BF957Cf5846D573E7f87CA", + "Ropsten" : "", + "Rinkeby" : "", + "Kovan" : "", + "Gorli" : "", + "BSC" : "", + "BSCT" : "", + "Matic" : "", + "Mumbai" : "", + "Arbitrum" : "", + "Arbitrum_Rinkeby" : "", + "xDai" : "", + "Avalanche" : "", + "Avalanche_Fuji" : "", + "Celo" : "", + "Fantom" : "", + "Aurora" : "", + "Aurora_Testnet" : "" + } } From d07dccdd3467815196a99b19e9b4e85d81dd86c9 Mon Sep 17 00:00:00 2001 From: "@layinka" Date: Thu, 3 Mar 2022 13:23:04 +0100 Subject: [PATCH 16/38] refactored token list --- .../mask/src/plugins/Savings/constants.ts | 120 +++ packages/web3-constants/evm/token.json | 885 +++++++++++++++++- 2 files changed, 1004 insertions(+), 1 deletion(-) diff --git a/packages/mask/src/plugins/Savings/constants.ts b/packages/mask/src/plugins/Savings/constants.ts index bb2ea40ce848..a1765ad29604 100644 --- a/packages/mask/src/plugins/Savings/constants.ts +++ b/packages/mask/src/plugins/Savings/constants.ts @@ -15,6 +15,126 @@ export const AAVE_PAIRS: [FungibleTokenDetailed, FungibleTokenDetailed][] = [ createERC20Tokens('USDT_ADDRESS', 'Tether USD', 'USDT', 6)[ChainId.Mainnet], createERC20Tokens('aUSDT_ADDRESS', 'Aave Interest bearing USDT', 'aUSDT', 6)[ChainId.Mainnet], ], + [ + createERC20Tokens('WBTC_ADDRESS', 'WBTC', 'WBTC', 8)[ChainId.Mainnet], + createERC20Tokens('aWBTC_ADDRESS', 'aWBTC', 'aWBTC', 8)[ChainId.Mainnet], + ], + [ + createERC20Tokens('WETH_ADDRESS', 'WETH', 'WETH', 18)[ChainId.Mainnet], + createERC20Tokens('aWETH_ADDRESS', 'aWETH', 'aWETH', 18)[ChainId.Mainnet], + ], + [ + createERC20Tokens('YFI_ADDRESS', 'YFI', 'YFI', 18)[ChainId.Mainnet], + createERC20Tokens('aYFI_ADDRESS', 'aYFI', 'aYFI', 18)[ChainId.Mainnet], + ], + [ + createERC20Tokens('ZRX_ADDRESS', 'ZRX', 'ZRX', 18)[ChainId.Mainnet], + createERC20Tokens('aZRX_ADDRESS', 'aZRX', 'aZRX', 18)[ChainId.Mainnet], + ], + [ + createERC20Tokens('UNI_ADDRESS', 'UNI', 'UNI', 18)[ChainId.Mainnet], + createERC20Tokens('aUNI_ADDRESS', 'aUNI', 'aUNI', 18)[ChainId.Mainnet], + ], + [ + createERC20Tokens('AAVE_ADDRESS', 'AAVE', 'AAVE', 18)[ChainId.Mainnet], + createERC20Tokens('aAAVE_ADDRESS', 'aAAVE', 'aAAVE', 18)[ChainId.Mainnet], + ], + [ + createERC20Tokens('BAT_ADDRESS', 'BAT', 'BAT', 18)[ChainId.Mainnet], + createERC20Tokens('aBAT_ADDRESS', 'aBAT', 'aBAT', 18)[ChainId.Mainnet], + ], + [ + createERC20Tokens('BUSD_ADDRESS', 'BUSD', 'BUSD', 18)[ChainId.Mainnet], + createERC20Tokens('aBUSD_ADDRESS', 'aBUSD', 'aBUSD', 18)[ChainId.Mainnet], + ], + [ + createERC20Tokens('DAI_ADDRESS', 'DAI', 'DAI', 18)[ChainId.Mainnet], + createERC20Tokens('aDAI_ADDRESS', 'aDAI', 'aDAI', 18)[ChainId.Mainnet], + ], + [ + createERC20Tokens('ENJ_ADDRESS', 'ENJ', 'ENJ', 18)[ChainId.Mainnet], + createERC20Tokens('aENJ_ADDRESS', 'aENJ', 'aENJ', 18)[ChainId.Mainnet], + ], + [ + createERC20Tokens('KNC_ADDRESS', 'KNC', 'KNC', 18)[ChainId.Mainnet], + createERC20Tokens('aKNC_ADDRESS', 'aKNC', 'aKNC', 18)[ChainId.Mainnet], + ], + [ + createERC20Tokens('LINK_ADDRESS', 'LINK', 'LINK', 18)[ChainId.Mainnet], + createERC20Tokens('aLINK_ADDRESS', 'aLINK', 'aLINK', 18)[ChainId.Mainnet], + ], + [ + createERC20Tokens('MANA_ADDRESS', 'MANA', 'MANA', 18)[ChainId.Mainnet], + createERC20Tokens('aMANA_ADDRESS', 'aMANA', 'aMANA', 18)[ChainId.Mainnet], + ], + [ + createERC20Tokens('MKR_ADDRESS', 'MKR', 'MKR', 18)[ChainId.Mainnet], + createERC20Tokens('aMKR_ADDRESS', 'aMKR', 'aMKR', 18)[ChainId.Mainnet], + ], + [ + createERC20Tokens('REN_ADDRESS', 'REN', 'REN', 18)[ChainId.Mainnet], + createERC20Tokens('aREN_ADDRESS', 'aREN', 'aREN', 18)[ChainId.Mainnet], + ], + [ + createERC20Tokens('SNX_ADDRESS', 'SNX', 'SNX', 18)[ChainId.Mainnet], + createERC20Tokens('aSNX_ADDRESS', 'aSNX', 'aSNX', 18)[ChainId.Mainnet], + ], + [ + createERC20Tokens('sUSD_ADDRESS', 'sUSD', 'sUSD', 18)[ChainId.Mainnet], + createERC20Tokens('aSUSD_ADDRESS', 'aSUSD', 'aSUSD', 18)[ChainId.Mainnet], + ], + [ + createERC20Tokens('TUSD_ADDRESS', 'TUSD', 'TUSD', 18)[ChainId.Mainnet], + createERC20Tokens('aTUSD_ADDRESS', 'aTUSD', 'aTUSD', 18)[ChainId.Mainnet], + ], + [ + createERC20Tokens('USDC_ADDRESS', 'USDC', 'USDC', 6)[ChainId.Mainnet], + createERC20Tokens('aUSDC_ADDRESS', 'aUSDC', 'aUSDC', 6)[ChainId.Mainnet], + ], + [ + createERC20Tokens('CRV_ADDRESS', 'CRV', 'CRV', 18)[ChainId.Mainnet], + createERC20Tokens('aCRV_ADDRESS', 'aCRV', 'aCRV', 18)[ChainId.Mainnet], + ], + [ + createERC20Tokens('GUSD_ADDRESS', 'GUSD', 'GUSD', 2)[ChainId.Mainnet], + createERC20Tokens('aGUSD_ADDRESS', 'aGUSD', 'aGUSD', 2)[ChainId.Mainnet], + ], + [ + createERC20Tokens('BAL_ADDRESS', 'BAL', 'BAL', 18)[ChainId.Mainnet], + createERC20Tokens('aBAL_ADDRESS', 'aBAL', 'aBAL', 18)[ChainId.Mainnet], + ], + [ + createERC20Tokens('xSUSHI_ADDRESS', 'xSUSHI', 'xSUSHI', 18)[ChainId.Mainnet], + createERC20Tokens('aXSUSHI_ADDRESS', 'aXSUSHI', 'aXSUSHI', 18)[ChainId.Mainnet], + ], + [ + createERC20Tokens('renFIL_ADDRESS', 'renFIL', 'renFIL', 18)[ChainId.Mainnet], + createERC20Tokens('aRENFIL_ADDRESS', 'aRENFIL', 'aRENFIL', 18)[ChainId.Mainnet], + ], + [ + createERC20Tokens('RAI_ADDRESS', 'RAI', 'RAI', 18)[ChainId.Mainnet], + createERC20Tokens('aRAI_ADDRESS', 'aRAI', 'aRAI', 18)[ChainId.Mainnet], + ], + [ + createERC20Tokens('AMPL_ADDRESS', 'AMPL', 'AMPL', 9)[ChainId.Mainnet], + createERC20Tokens('aAMPL_ADDRESS', 'aAMPL', 'aAMPL', 9)[ChainId.Mainnet], + ], + [ + createERC20Tokens('USDP_ADDRESS', 'USDP', 'USDP', 18)[ChainId.Mainnet], + createERC20Tokens('aUSDP_ADDRESS', 'aUSDP', 'aUSDP', 18)[ChainId.Mainnet], + ], + [ + createERC20Tokens('DPI_ADDRESS', 'DPI', 'DPI', 18)[ChainId.Mainnet], + createERC20Tokens('aDPI_ADDRESS', 'aDPI', 'aDPI', 18)[ChainId.Mainnet], + ], + [ + createERC20Tokens('FRAX_ADDRESS', 'FRAX', 'FRAX', 18)[ChainId.Mainnet], + createERC20Tokens('aFRAX_ADDRESS', 'aFRAX', 'aFRAX', 18)[ChainId.Mainnet], + ], + [ + createERC20Tokens('FEI_ADDRESS', 'FEI', 'FEI', 18)[ChainId.Mainnet], + createERC20Tokens('aFEI_ADDRESS', 'aFEI', 'aFEI', 18)[ChainId.Mainnet], + ], // { // name: 'USDT', // pair: 'aUSDT', diff --git a/packages/web3-constants/evm/token.json b/packages/web3-constants/evm/token.json index 0c1ce938f720..dbca4c7d349a 100644 --- a/packages/web3-constants/evm/token.json +++ b/packages/web3-constants/evm/token.json @@ -998,5 +998,888 @@ "Fantom": "0x0000000000000000000000000000000000000000", "Aurora": "0x0000000000000000000000000000000000000000", "Aurora_Testnet": "" - } + }, + +Skipping USDC_ADDRESS , it already exists +Skipping AMPL_ADDRESS , it already exists +Addresses is "WETH_ADDRESS": { + "Mainnet": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + "aWETH_ADDRESS": { + "Mainnet": "0x030bA81f1c18d280636F32af80b9AAd02Cf0854e", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + "ZRX_ADDRESS": { + "Mainnet": "0xE41d2489571d322189246DaFA5ebDe1F4699F498", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + "aZRX_ADDRESS": { + "Mainnet": "0xDf7FF54aAcAcbFf42dfe29DD6144A69b629f8C9e", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + "UNI_ADDRESS": { + "Mainnet": "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + "aUNI_ADDRESS": { + "Mainnet": "0xB9D7CB55f463405CDfBe4E90a6D2Df01C2B92BF1", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + "AAVE_ADDRESS": { + "Mainnet": "0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + "aAAVE_ADDRESS": { + "Mainnet": "0xFFC97d72E13E01096502Cb8Eb52dEe56f74DAD7B", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + "BAT_ADDRESS": { + "Mainnet": "0x0D8775F648430679A709E98d2b0Cb6250d2887EF", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + "aBAT_ADDRESS": { + "Mainnet": "0x05Ec93c0365baAeAbF7AefFb0972ea7ECdD39CF1", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + "ENJ_ADDRESS": { + "Mainnet": "0xF629cBd94d3791C9250152BD8dfBDF380E2a3B9c", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + "aENJ_ADDRESS": { + "Mainnet": "0xaC6Df26a590F08dcC95D5a4705ae8abbc88509Ef", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + "KNC_ADDRESS": { + "Mainnet": "0xdd974D5C2e2928deA5F71b9825b8b646686BD200", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + "aKNC_ADDRESS": { + "Mainnet": "0x39C6b3e42d6A679d7D776778Fe880BC9487C2EDA", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + "LINK_ADDRESS": { + "Mainnet": "0x514910771AF9Ca656af840dff83E8264EcF986CA", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + "aLINK_ADDRESS": { + "Mainnet": "0xa06bC25B5805d5F8d82847D191Cb4Af5A3e873E0", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + "MANA_ADDRESS": { + "Mainnet": "0x0F5D2fB29fb7d3CFeE444a200298f468908cC942", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + "aMANA_ADDRESS": { + "Mainnet": "0xa685a61171bb30d4072B338c80Cb7b2c865c873E", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + "REN_ADDRESS": { + "Mainnet": "0x408e41876cCCDC0F92210600ef50372656052a38", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + "aREN_ADDRESS": { + "Mainnet": "0xCC12AbE4ff81c9378D670De1b57F8e0Dd228D77a", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + "SNX_ADDRESS": { + "Mainnet": "0xC011a73ee8576Fb46F5E1c5751cA3B9Fe0af2a6F", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + "aSNX_ADDRESS": { + "Mainnet": "0x35f6B052C598d933D69A4EEC4D04c73A191fE6c2", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + "TUSD_ADDRESS": { + "Mainnet": "0x0000000000085d4780B73119b644AE5ecd22b376", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + "aTUSD_ADDRESS": { + "Mainnet": "0x101cc05f4A51C0319f570d5E146a8C625198e636", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + "CRV_ADDRESS": { + "Mainnet": "0xD533a949740bb3306d119CC777fa900bA034cd52", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + "aCRV_ADDRESS": { + "Mainnet": "0x8dAE6Cb04688C62d939ed9B68d32Bc62e49970b1", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + "GUSD_ADDRESS": { + "Mainnet": "0x056Fd409E1d7A124BD7017459dFEa2F387b6d5Cd", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + "aGUSD_ADDRESS": { + "Mainnet": "0xD37EE7e4f452C6638c96536e68090De8cBcdb583", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + "BAL_ADDRESS": { + "Mainnet": "0xba100000625a3754423978a60c9317c58a424e3D", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + "aBAL_ADDRESS": { + "Mainnet": "0x272F97b7a56a387aE942350bBC7Df5700f8a4576", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + "xSUSHI_ADDRESS": { + "Mainnet": "0x8798249c2E607446EfB7Ad49eC89dD1865Ff4272", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + "aXSUSHI_ADDRESS": { + "Mainnet": "0xF256CC7847E919FAc9B808cC216cAc87CCF2f47a", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + "renFIL_ADDRESS": { + "Mainnet": "0xD5147bc8e386d91Cc5DBE72099DAC6C9b99276F5", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + "aRENFIL_ADDRESS": { + "Mainnet": "0x514cd6756CCBe28772d4Cb81bC3156BA9d1744aa", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + "RAI_ADDRESS": { + "Mainnet": "0x03ab458634910AaD20eF5f1C8ee96F1D6ac54919", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + "aRAI_ADDRESS": { + "Mainnet": "0xc9BC48c72154ef3e5425641a3c747242112a46AF", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + "USDP_ADDRESS": { + "Mainnet": "0x8E870D67F660D95d5be530380D0eC0bd388289E1", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + "aUSDP_ADDRESS": { + "Mainnet": "0x2e8F4bdbE3d47d7d7DE490437AeA9915D930F1A3", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + "DPI_ADDRESS": { + "Mainnet": "0x1494CA1F11D487c2bBe4543E90080AeBa4BA3C2b", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + "aDPI_ADDRESS": { + "Mainnet": "0x6F634c6135D2EBD550000ac92F494F9CB8183dAe", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + "FRAX_ADDRESS": { + "Mainnet": "0x853d955aCEf822Db058eb8505911ED77F175b99e", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + "aFRAX_ADDRESS": { + "Mainnet": "0xd4937682df3C8aEF4FE912A96A74121C0829E664", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + "FEI_ADDRESS": { + "Mainnet": "0x956F47F50A910163D8BF957Cf5846D573E7f87CA", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + "aFEI_ADDRESS": { + "Mainnet": "0x683923dB55Fead99A79Fa01A27EeC3cB19679cC3", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, } From ec06a89d6ba6d3ed24fce7eb8a172bb2a54e1b61 Mon Sep 17 00:00:00 2001 From: "@layinka" Date: Mon, 7 Mar 2022 09:35:46 +0100 Subject: [PATCH 17/38] refactored token list --- packages/web3-constants/evm/token.json | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/web3-constants/evm/token.json b/packages/web3-constants/evm/token.json index dbca4c7d349a..045aff5b3306 100644 --- a/packages/web3-constants/evm/token.json +++ b/packages/web3-constants/evm/token.json @@ -999,10 +999,7 @@ "Aurora": "0x0000000000000000000000000000000000000000", "Aurora_Testnet": "" }, - -Skipping USDC_ADDRESS , it already exists -Skipping AMPL_ADDRESS , it already exists -Addresses is "WETH_ADDRESS": { + "WETH_ADDRESS": { "Mainnet": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", "Ropsten": "", "Rinkeby": "", @@ -1881,5 +1878,5 @@ Addresses is "WETH_ADDRESS": { "Fantom": "", "Aurora": "", "Aurora_Testnet": "" - }, + } } From 01bf37bcebe42f7c2f9fc121bb3e365d94fc682d Mon Sep 17 00:00:00 2001 From: guanbinrui Date: Tue, 8 Mar 2022 11:50:48 +0800 Subject: [PATCH 18/38] refactor: remove legacy test tokens --- .../src/plugins/Trader/constants/trader.ts | 5 - packages/web3-constants/evm/token.json | 100 ------------------ 2 files changed, 105 deletions(-) diff --git a/packages/mask/src/plugins/Trader/constants/trader.ts b/packages/mask/src/plugins/Trader/constants/trader.ts index 6f8cdc2d5594..1deb2331cb78 100644 --- a/packages/mask/src/plugins/Trader/constants/trader.ts +++ b/packages/mask/src/plugins/Trader/constants/trader.ts @@ -12,11 +12,6 @@ export const HUSD = createERC20Tokens('HUSD_ADDRESS', 'Huobi USD', 'HUSD', 6) export const BUSD = createERC20Tokens('BUSD_ADDRESS', 'Huobi USD', 'BUSD', 6) export const COMP = createERC20Tokens('COMP_ADDRESS', 'Compound', 'COMP', 18) export const MKR = createERC20Tokens('MKR_ADDRESS', 'Maker', 'MKR', 18) -export const MSKA = createERC20Tokens('MSKA_ADDRESS', 'Mask A', 'MSKA', 18) -export const MSKB = createERC20Tokens('MSKB_ADDRESS', 'Mask B', 'MSKB', 18) -export const MSKC = createERC20Tokens('MSKC_ADDRESS', 'Mask C', 'MSKC', 18) -export const MSKD = createERC20Tokens('MSKD_ADDRESS', 'Mask D', 'MSKD', 18) -export const MSKE = createERC20Tokens('MSKE_ADDRESS', 'Mask E', 'MSKE', 18) export const DAI = createERC20Tokens('DAI_ADDRESS', 'Dai Stablecoin', 'DAI', 18) export const DAIe = createERC20Tokens('DAI_ADDRESS', 'Dai Stablecoin', 'DAI.e', 18) export const AMPL = createERC20Tokens('AMPL_ADDRESS', 'Ampleforth', 'AMPL', 18) diff --git a/packages/web3-constants/evm/token.json b/packages/web3-constants/evm/token.json index 045aff5b3306..3d867dd1e645 100644 --- a/packages/web3-constants/evm/token.json +++ b/packages/web3-constants/evm/token.json @@ -239,106 +239,6 @@ "Aurora": "", "Aurora_Testnet": "" }, - "MSKA_ADDRESS": { - "Mainnet": "", - "Ropsten": "0xe54bf69054da160c597f8b5177924b9e4b81e930", - "Rinkeby": "0x960B816d6dD03eD514c03F56788279154348Ea37", - "Kovan": "", - "Gorli": "", - "BSC": "", - "BSCT": "", - "Matic": "", - "Mumbai": "", - "Arbitrum": "", - "Arbitrum_Rinkeby": "", - "xDai": "", - "Avalanche": "", - "Avalanche_Fuji": "", - "Celo": "", - "Fantom": "", - "Aurora": "", - "Aurora_Testnet": "" - }, - "MSKB_ADDRESS": { - "Mainnet": "", - "Ropsten": "0xe379c7a6ba07575a5a49d8f8ebfd04921b86917d", - "Rinkeby": "0xFa4Bddbc85c0aC7a543c4b59dCfb5deB17F67D8E", - "Kovan": "", - "Gorli": "", - "BSC": "", - "BSCT": "", - "Matic": "", - "Mumbai": "", - "Arbitrum": "", - "Arbitrum_Rinkeby": "", - "xDai": "", - "Avalanche": "", - "Avalanche_Fuji": "", - "Celo": "", - "Fantom": "", - "Aurora": "", - "Aurora_Testnet": "" - }, - "MSKC_ADDRESS": { - "Mainnet": "", - "Ropsten": "0xb1465b954f893d921566d8bb4092b6f03fc8c313", - "Rinkeby": "0xbE88c0E7029929f50c81690275395Da1d05745B0", - "Kovan": "", - "Gorli": "", - "BSC": "", - "BSCT": "", - "Matic": "", - "Mumbai": "", - "Arbitrum": "", - "Arbitrum_Rinkeby": "", - "xDai": "", - "Avalanche": "", - "Avalanche_Fuji": "", - "Celo": "", - "Fantom": "", - "Aurora": "", - "Aurora_Testnet": "" - }, - "MSKD_ADDRESS": { - "Mainnet": "", - "Ropsten": "0x49A6D6FE38405e21C4402CcEacd23636AbE301bf", - "Rinkeby": "0x57b9bD626507421d82C7542e2877D72fE7815aFd", - "Kovan": "", - "Gorli": "", - "BSC": "", - "BSCT": "", - "Matic": "", - "Mumbai": "", - "Arbitrum": "", - "Arbitrum_Rinkeby": "", - "xDai": "", - "Avalanche": "", - "Avalanche_Fuji": "", - "Celo": "", - "Fantom": "", - "Aurora": "", - "Aurora_Testnet": "" - }, - "MSKE_ADDRESS": { - "Mainnet": "", - "Ropsten": "0xE8f4dDB8c8b655B4e161d3480522d1d576561A4D", - "Rinkeby": "0xB46e44E06B89798Af11b8fE456b4796dc9026cE0", - "Kovan": "", - "Gorli": "", - "BSC": "", - "BSCT": "", - "Matic": "", - "Mumbai": "", - "Arbitrum": "", - "Arbitrum_Rinkeby": "", - "xDai": "", - "Avalanche": "", - "Avalanche_Fuji": "", - "Celo": "", - "Fantom": "", - "Aurora": "", - "Aurora_Testnet": "" - }, "DAI_ADDRESS": { "Mainnet": "0x6B175474E89094C44Da98b954EedeAC495271d0F", "Ropsten": "0x31f42841c2db5173425b5223809cf3a38fede360", From ce32732b1f680672ae7a6a116679d6ba11699ed4 Mon Sep 17 00:00:00 2001 From: guanbinrui Date: Tue, 8 Mar 2022 11:55:15 +0800 Subject: [PATCH 19/38] refactor: remove commented code --- .../mask/src/plugins/Savings/constants.ts | 217 ------------------ 1 file changed, 217 deletions(-) diff --git a/packages/mask/src/plugins/Savings/constants.ts b/packages/mask/src/plugins/Savings/constants.ts index a1765ad29604..b6b8b4de5001 100644 --- a/packages/mask/src/plugins/Savings/constants.ts +++ b/packages/mask/src/plugins/Savings/constants.ts @@ -135,221 +135,4 @@ export const AAVE_PAIRS: [FungibleTokenDetailed, FungibleTokenDetailed][] = [ createERC20Tokens('FEI_ADDRESS', 'FEI', 'FEI', 18)[ChainId.Mainnet], createERC20Tokens('aFEI_ADDRESS', 'aFEI', 'aFEI', 18)[ChainId.Mainnet], ], - // { - // name: 'USDT', - // pair: 'aUSDT', - // decimals: 6, - // underLyingAssetName: 'aUSDT', - // logoURI: ['https://tokens.1inch.io/0xdac17f958d2ee523a2206206994597c13d831ec7.png'], - // }, - // { - // name: 'WBTC', - // pair: 'aWBTC', - // decimals: 8, - // underLyingAssetName: 'aWBTC', - // logoURI: ['https://tokens.1inch.io/0x2260fac5e5542a773aa44fbcfedf7c193bc2c599.png'], - // }, - // { - // name: 'WETH', - // pair: 'aWETH', - // decimals: 18, - // underLyingAssetName: 'aWETH', - // logoURI: ['https://tokens.1inch.io/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png'], - // }, - // { - // name: 'YFI', - // pair: 'aYFI', - // decimals: 18, - // underLyingAssetName: 'aYFI', - // logoURI: ['https://tokens.1inch.io/0x0bc529c00c6401aef6d220be8c6ea1667f6ad93e.png'], - // }, - // { - // name: 'ZRX', - // pair: 'aZRX', - // decimals: 18, - // underLyingAssetName: 'aZRX', - // logoURI: ['https://tokens.1inch.io/0xe41d2489571d322189246dafa5ebde1f4699f498.png'], - // }, - // { - // name: 'UNI', - // pair: 'aUNI', - // decimals: 18, - // underLyingAssetName: 'aUNI', - // logoURI: ['https://tokens.1inch.io/0x1f9840a85d5af5bf1d1762f925bdaddc4201f984.png'], - // }, - // { - // name: 'AAVE', - // pair: 'aAAVE', - // decimals: 18, - // underLyingAssetName: 'aAAVE', - // logoURI: ['https://tokens.1inch.io/0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9.png'], - // }, - // { - // name: 'BAT', - // pair: 'aBAT', - // decimals: 18, - // underLyingAssetName: 'aBAT', - // logoURI: ['https://tokens.1inch.io/0x0d8775f648430679a709e98d2b0cb6250d2887ef.png'], - // }, - // { - // name: 'BUSD', - // pair: 'aBUSD', - // decimals: 18, - // underLyingAssetName: 'aBUSD', - // logoURI: ['https://tokens.1inch.io/0x4fabb145d64652a948d72533023f6e7a623c7c53.png'], - // }, - // { - // name: 'DAI', - // pair: 'aDAI', - // decimals: 18, - // underLyingAssetName: 'aDAI', - // logoURI: ['https://tokens.1inch.io/0x6b175474e89094c44da98b954eedeac495271d0f.png'], - // }, - // { - // name: 'ENJ', - // pair: 'aENJ', - // decimals: 18, - // underLyingAssetName: 'aENJ', - // logoURI: ['https://tokens.1inch.io/0xf629cbd94d3791c9250152bd8dfbdf380e2a3b9c.png'], - // }, - // { - // name: 'KNC', - // pair: 'aKNC', - // decimals: 18, - // underLyingAssetName: 'aKNC', - // logoURI: ['https://tokens.1inch.io/0xdd974d5c2e2928dea5f71b9825b8b646686bd200.png'], - // }, - // { - // name: 'LINK', - // pair: 'aLINK', - // decimals: 18, - // underLyingAssetName: 'aLINK', - // logoURI: ['https://tokens.1inch.io/0x514910771af9ca656af840dff83e8264ecf986ca.png'], - // }, - // { - // name: 'MANA', - // pair: 'aMANA', - // decimals: 18, - // underLyingAssetName: 'aMANA', - // logoURI: ['https://tokens.1inch.io/0x0f5d2fb29fb7d3cfee444a200298f468908cc942.png'], - // }, - // { - // name: 'MKR', - // pair: 'aMKR', - // decimals: 18, - // underLyingAssetName: 'aMKR', - // logoURI: ['https://tokens.1inch.io/0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2.png'], - // }, - // { - // name: 'REN', - // pair: 'aREN', - // decimals: 18, - // underLyingAssetName: 'aREN', - // logoURI: ['https://tokens.1inch.io/0x408e41876cccdc0f92210600ef50372656052a38.png'], - // }, - // { - // name: 'SNX', - // pair: 'aSNX', - // decimals: 18, - // underLyingAssetName: 'aSNX', - // logoURI: ['https://tokens.1inch.io/0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f.png'], - // }, - // { - // name: 'sUSD', - // pair: 'aSUSD', - // decimals: 18, - // underLyingAssetName: 'aSUSD', - // logoURI: ['https://tokens.1inch.io/0x57ab1ec28d129707052df4df418d58a2d46d5f51.png'], - // }, - // { - // name: 'TUSD', - // pair: 'aTUSD', - // decimals: 18, - // underLyingAssetName: 'aTUSD', - // logoURI: ['https://tokens.1inch.io/0x0000000000085d4780b73119b644ae5ecd22b376.png'], - // }, - // { - // name: 'USDC', - // pair: 'aUSDC', - // decimals: 6, - // underLyingAssetName: 'aUSDC', - // logoURI: ['https://tokens.1inch.io/0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48.png'], - // }, - // { - // name: 'CRV', - // pair: 'aCRV', - // decimals: 18, - // underLyingAssetName: 'aCRV', - // logoURI: ['https://tokens.1inch.io/0xd533a949740bb3306d119cc777fa900ba034cd52.png'], - // }, - // { - // name: 'GUSD', - // pair: 'aGUSD', - // decimals: 2, - // underLyingAssetName: 'aGUSD', - // logoURI: ['https://tokens.1inch.io/0x056fd409e1d7a124bd7017459dfea2f387b6d5cd.png'], - // }, - // { - // name: 'BAL', - // pair: 'aBAL', - // decimals: 18, - // underLyingAssetName: 'aBAL', - // logoURI: ['https://tokens.1inch.io/0xba100000625a3754423978a60c9317c58a424e3d.png'], - // }, - // { - // name: 'xSUSHI', - // pair: 'aXSUSHI', - // decimals: 18, - // underLyingAssetName: 'aXSUSHI', - // logoURI: ['https://tokens.1inch.io/0x8798249c2e607446efb7ad49ec89dd1865ff4272.png'], - // }, - // { - // name: 'renFIL', - // pair: 'aRENFIL', - // decimals: 18, - // underLyingAssetName: 'aRENFIL', - // logoURI: ['https://tokens.1inch.io/0xd5147bc8e386d91cc5dbe72099dac6c9b99276f5.png'], - // }, - // { - // name: 'RAI', - // pair: 'aRAI', - // decimals: 18, - // underLyingAssetName: 'aRAI', - // logoURI: ['https://tokens.1inch.io/0x03ab458634910aad20ef5f1c8ee96f1d6ac54919.png'], - // }, - // { - // name: 'AMPL', - // pair: 'aAMPL', - // decimals: 9, - // underLyingAssetName: 'aAMPL', - // logoURI: ['https://tokens.1inch.io/0xd46ba6d942050d489dbd938a2c909a5d5039a161.png'], - // }, - // { - // name: 'USDP', - // pair: 'aUSDP', - // decimals: 18, - // underLyingAssetName: 'aUSDP', - // logoURI: ['https://tokens.1inch.io/0x8e870d67f660d95d5be530380d0ec0bd388289e1.png'], - // }, - // { - // name: 'DPI', - // pair: 'aDPI', - // decimals: 18, - // underLyingAssetName: 'aDPI', - // logoURI: ['https://tokens.1inch.io/0x1494ca1f11d487c2bbe4543e90080aeba4ba3c2b.png'], - // }, - // { - // name: 'FRAX', - // pair: 'aFRAX', - // decimals: 18, - // underLyingAssetName: 'aFRAX', - // logoURI: ['https://tokens.1inch.io/0x853d955acef822db058eb8505911ed77f175b99e.png'], - // }, - // { - // name: 'FEI', - // pair: 'aFEI', - // decimals: 18, - // underLyingAssetName: 'aFEI', - // logoURI: ['https://tokens.1inch.io/0x956f47f50a910163d8bf957cf5846d573e7f87ca.png'], - // }, ] From c17e32b9e3a65f37a6861d77cfbdbe78364ba548 Mon Sep 17 00:00:00 2001 From: guanbinrui Date: Tue, 8 Mar 2022 12:10:57 +0800 Subject: [PATCH 20/38] fix: ldo stake token --- .../mask/src/plugins/Savings/constants.ts | 2 +- packages/web3-constants/evm/token.json | 22 +------------------ 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/packages/mask/src/plugins/Savings/constants.ts b/packages/mask/src/plugins/Savings/constants.ts index b6b8b4de5001..4f800312198b 100644 --- a/packages/mask/src/plugins/Savings/constants.ts +++ b/packages/mask/src/plugins/Savings/constants.ts @@ -6,7 +6,7 @@ export const SAVINGS_PLUGIN_ID = 'com.savings' export const LDO_PAIRS: [FungibleTokenDetailed, FungibleTokenDetailed][] = [ [ createNativeToken(ChainId.Mainnet), - createERC20Tokens('LDO_ADDRESS', 'Lido DAO Token', 'LDO', 18)[ChainId.Mainnet], + createERC20Tokens('LDO_stETH_ADDRESS', 'Liquid staked Ether 2.0', 'stETH', 18)[ChainId.Mainnet], ], ] diff --git a/packages/web3-constants/evm/token.json b/packages/web3-constants/evm/token.json index 3d867dd1e645..4b9af517cafb 100644 --- a/packages/web3-constants/evm/token.json +++ b/packages/web3-constants/evm/token.json @@ -19,27 +19,7 @@ "Aurora": "0xC9BdeEd33CD01541e1eeD10f90519d2C06Fe3feB", "Aurora_Testnet": "" }, - "LDO_ADDRESS": { - "Mainnet": "0x5a98fcbea516cf06857215779fd812ca3bef1b32", - "Ropsten": "", - "Rinkeby": "", - "Kovan": "", - "Gorli": "", - "BSC": "", - "BSCT": "", - "Matic": "", - "Mumbai": "", - "Arbitrum": "", - "Arbitrum_Rinkeby": "", - "xDai": "", - "Avalanche": "", - "Avalanche_Fuji": "", - "Celo": "", - "Fantom": "", - "Aurora": "", - "Aurora_Testnet": "" - }, - "LDO_stETH": { + "LDO_stETH_ADDRESS": { "Mainnet": "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84", "Ropsten": "", "Rinkeby": "", From c2dcb90025622bcf87b21490af362b79a1b46691 Mon Sep 17 00:00:00 2001 From: guanbinrui Date: Tue, 8 Mar 2022 12:23:30 +0800 Subject: [PATCH 21/38] fix: build error --- packages/mask/src/plugins/Trader/constants/uniswap.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/mask/src/plugins/Trader/constants/uniswap.ts b/packages/mask/src/plugins/Trader/constants/uniswap.ts index ae337d9f65e2..227db6fb4664 100644 --- a/packages/mask/src/plugins/Trader/constants/uniswap.ts +++ b/packages/mask/src/plugins/Trader/constants/uniswap.ts @@ -1,7 +1,7 @@ import { ChainId } from '@masknet/web3-shared-evm' import { Percent } from '@uniswap/sdk-core' import JSBI from 'jsbi' -import { AMPL, DAI, MSKA, MSKB, MSKC, USDC, USDT, WBTC, WNATIVE, WNATIVE_ONLY } from './trader' +import { AMPL, DAI, USDC, USDT, WBTC, WNATIVE, WNATIVE_ONLY } from './trader' import type { ERC20AgainstToken, ERC20TokenCustomizedBase } from './types' /** @@ -21,7 +21,6 @@ export const UNISWAP_BASE_AGAINST_TOKENS: ERC20AgainstToken = { ...WNATIVE_ONLY, [ChainId.Mainnet]: [WNATIVE, DAI, USDC, USDT, WBTC].map((x) => x[ChainId.Mainnet]), [ChainId.Matic]: [WNATIVE, DAI, USDC, USDT, WBTC].map((x) => x[ChainId.Matic]), - [ChainId.Rinkeby]: [WNATIVE, MSKA, MSKB, MSKC].map((x) => x[ChainId.Rinkeby]), } export const MAX_HOP = 3 From 98473b3648f6c7e573f2a1f8ff691db4e1612133 Mon Sep 17 00:00:00 2001 From: "@layinka" Date: Tue, 8 Mar 2022 08:14:48 +0100 Subject: [PATCH 22/38] added some missing tokens --- packages/web3-constants/evm/token.json | 167 +++++++++++++++++++++++++ 1 file changed, 167 insertions(+) diff --git a/packages/web3-constants/evm/token.json b/packages/web3-constants/evm/token.json index 045aff5b3306..635a705f9409 100644 --- a/packages/web3-constants/evm/token.json +++ b/packages/web3-constants/evm/token.json @@ -1878,5 +1878,172 @@ "Fantom": "", "Aurora": "", "Aurora_Testnet": "" + }, + "aWBTC_ADDRESS": { + "Mainnet": "0x9ff58f4fFB29fA2266Ab25e75e2A8b3503311656", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + + "aYFI_ADDRESS": { + "Mainnet": "0x5165d24277cD063F5ac44Efd447B27025e888f37", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + + "aBUSD_ADDRESS": { + "Mainnet": "0xA361718326c15715591c299427c62086F69923D9", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + + "aDAI_ADDRESS": { + "Mainnet": "0x028171bCA77440897B824Ca71D1c56caC55b68A3", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + + "aMKR_ADDRESS": { + "Mainnet": "0xc713e5E149D5D0715DcD1c156a020976e7E56B88", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + + "aSUSD_ADDRESS": { + "Mainnet": "0x6C5024Cd4F8A59110119C56f8933403A539555EB", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + + "aUSDC_ADDRESS": { + "Mainnet": "0xBcca60bB61934080951369a648Fb03DF4F96263C", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + + "aAMPL_ADDRESS": { + "Mainnet": "0x1E6bb68Acec8fefBD87D192bE09bb274170a0548", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" } } From 0725c920d699e5b074d3ca3952dc3cf6e4b7a65c Mon Sep 17 00:00:00 2001 From: guanbinrui Date: Tue, 8 Mar 2022 15:41:28 +0800 Subject: [PATCH 23/38] refactor: remove legacy test tokens --- cspell.json | 8 -------- packages/mask/src/plugins/Trader/constants/sushiswap.ts | 4 ---- packages/mask/src/plugins/Trader/constants/trisolaris.ts | 3 +-- 3 files changed, 1 insertion(+), 14 deletions(-) diff --git a/cspell.json b/cspell.json index aa4c82a87783..bda32aaaf9ef 100644 --- a/cspell.json +++ b/cspell.json @@ -152,9 +152,6 @@ "monospace", "mooniswap", "msgpack", - "mska", - "mskb", - "mskc", "multicall", "multihop", "mutex", @@ -326,11 +323,6 @@ "metaplex", "metaswap", "misaka", - "mska", - "mskb", - "mskc", - "mskd", - "mske", "nft", "nftred", "nftx", diff --git a/packages/mask/src/plugins/Trader/constants/sushiswap.ts b/packages/mask/src/plugins/Trader/constants/sushiswap.ts index 1c77a8e30c71..1320f3c79bb8 100644 --- a/packages/mask/src/plugins/Trader/constants/sushiswap.ts +++ b/packages/mask/src/plugins/Trader/constants/sushiswap.ts @@ -1,9 +1,6 @@ import { ChainId } from '@masknet/web3-shared-evm' import { DAI, - MSKA, - MSKB, - MSKC, RUNE, USDC, USDT, @@ -29,7 +26,6 @@ export const SUSHISWAP_CUSTOM_BASES: ERC20TokenCustomizedBase = {} export const SUSHISWAP_BASE_AGAINST_TOKENS: ERC20AgainstToken = { ...WNATIVE_ONLY, [ChainId.Mainnet]: [WNATIVE, DAI, USDC, USDT, WBTC, RUNE, NFTX, STETH].map((x) => x[ChainId.Mainnet]), - [ChainId.Rinkeby]: [WNATIVE, MSKA, MSKB, MSKC].map((x) => x[ChainId.Rinkeby]), [ChainId.Matic]: [WNATIVE, USDC, WBTC, DAI, USDT].map((x) => x[ChainId.Matic]), [ChainId.BSC]: [WNATIVE, DAI, BUSD, USDC, USDT, BTCB].map((x) => x[ChainId.BSC]), [ChainId.xDai]: [WNATIVE, USDC, USDT, WBTC].map((x) => x[ChainId.xDai]), diff --git a/packages/mask/src/plugins/Trader/constants/trisolaris.ts b/packages/mask/src/plugins/Trader/constants/trisolaris.ts index cee359af11ed..3e0222e19a44 100644 --- a/packages/mask/src/plugins/Trader/constants/trisolaris.ts +++ b/packages/mask/src/plugins/Trader/constants/trisolaris.ts @@ -1,5 +1,5 @@ import { ChainId } from '@masknet/web3-shared-evm' -import { DAI, MSKA, MSKB, MSKC, USDC, USDT, WBTC, WNATIVE, WNATIVE_ONLY } from './trader' +import { DAI, USDC, USDT, WBTC, WNATIVE, WNATIVE_ONLY } from './trader' import type { ERC20AgainstToken, ERC20TokenCustomizedBase } from './types' /** @@ -10,7 +10,6 @@ export const TRISOLARIS_CUSTOM_BASES: ERC20TokenCustomizedBase = {} export const TRISOLARIS_BASE_AGAINST_TOKENS: ERC20AgainstToken = { ...WNATIVE_ONLY, - [ChainId.Rinkeby]: [WNATIVE, MSKA, MSKB, MSKC].map((x) => x[ChainId.Rinkeby]), [ChainId.Matic]: [WNATIVE, USDC, WBTC, DAI, USDT].map((x) => x[ChainId.Matic]), [ChainId.Aurora]: [WNATIVE, DAI, USDT, USDC, WBTC].map((x) => x[ChainId.Aurora]), } From 7c04ee69ea3fa0e43e04115104835d78e7de0e08 Mon Sep 17 00:00:00 2001 From: guanbinrui Date: Tue, 8 Mar 2022 15:56:02 +0800 Subject: [PATCH 24/38] refactor: separate constants --- .../Savings/SNSAdaptor/SavingsDialog.tsx | 7 +- .../Savings/SNSAdaptor/SavingsForm.tsx | 8 +- .../plugins/Savings/protocols/AAVEProtocol.ts | 12 +- .../plugins/Savings/protocols/LDOProtocol.ts | 12 +- packages/web3-constants/evm/aave.json | 42 + packages/web3-constants/evm/lido.json | 42 + packages/web3-constants/evm/savings.json | 724 ------------------ packages/web3-constants/evm/token.json | 20 + packages/web3-shared/evm/constants/index.ts | 10 +- 9 files changed, 131 insertions(+), 746 deletions(-) create mode 100644 packages/web3-constants/evm/aave.json create mode 100644 packages/web3-constants/evm/lido.json delete mode 100644 packages/web3-constants/evm/savings.json diff --git a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsDialog.tsx b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsDialog.tsx index 5867ef726e7a..55eb7d20ba5f 100644 --- a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsDialog.tsx +++ b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsDialog.tsx @@ -61,12 +61,7 @@ export function SavingsDialog({ open, onClose }: SavingsDialogProps) { ) : null} {selectedProtocol ? ( - + ) : ( <>
diff --git a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsForm.tsx b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsForm.tsx index 0205ec9508f3..5fdacceb561e 100644 --- a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsForm.tsx +++ b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsForm.tsx @@ -13,7 +13,13 @@ import { formatCurrency, formatBalance, } from '@masknet/web3-shared-evm' -import { TokenAmountPanel, FormattedCurrency, LoadingAnimation, TokenIcon, useRemoteControlledDialog } from '@masknet/shared' +import { + TokenAmountPanel, + FormattedCurrency, + LoadingAnimation, + TokenIcon, + useRemoteControlledDialog, +} from '@masknet/shared' import { useTokenPrice } from '../../Wallet/hooks/useTokenPrice' import { useI18N } from '../../../utils' import { useStyles } from './SavingsFormStyles' diff --git a/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts b/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts index 06bc7f698884..50a449c8882c 100644 --- a/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts +++ b/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts @@ -4,7 +4,7 @@ import type Web3 from 'web3' import type { AbiItem } from 'web3-utils' import { ChainId, - getSavingsConstants, + getAaveConstants, createContract, FungibleTokenDetailed, ZERO_ADDRESS, @@ -45,7 +45,7 @@ export class AAVEProtocol implements SavingsProtocol { public async updateApr(chainId: ChainId, web3: Web3) { try { - const subgraphUrl = getSavingsConstants(chainId).AAVE_SUBGRAPHS || '' + const subgraphUrl = getAaveConstants(chainId).AAVE_SUBGRAPHS || '' if (!subgraphUrl) { this._apr = AAVEProtocol.DEFAULT_APR @@ -97,7 +97,7 @@ export class AAVEProtocol implements SavingsProtocol { public async updateBalance(chainId: ChainId, web3: Web3, account: string) { try { - const subgraphUrl = getSavingsConstants(chainId).AAVE_SUBGRAPHS || '' + const subgraphUrl = getAaveConstants(chainId).AAVE_SUBGRAPHS || '' const reserveBody = JSON.stringify({ query: `{ reserves (where: { @@ -187,7 +187,7 @@ export class AAVEProtocol implements SavingsProtocol { private async createDepositTokenOperation(account: string, chainId: ChainId, web3: Web3, value: BigNumber.Value) { const aaveLPoolAddress = - getSavingsConstants(chainId).AAVE_LENDING_POOL_ADDRESSES_PROVIDER_CONTRACT_ADDRESS || ZERO_ADDRESS + getAaveConstants(chainId).AAVE_LENDING_POOL_ADDRESSES_PROVIDER_CONTRACT_ADDRESS || ZERO_ADDRESS const lPoolAdressProviderContract = createContract( web3, aaveLPoolAddress, @@ -225,7 +225,7 @@ export class AAVEProtocol implements SavingsProtocol { try { const lPoolAdressProviderContract = createContract( web3, - getSavingsConstants(chainId).AAVE_LENDING_POOL_ADDRESSES_PROVIDER_CONTRACT_ADDRESS || ZERO_ADDRESS, + getAaveConstants(chainId).AAVE_LENDING_POOL_ADDRESSES_PROVIDER_CONTRACT_ADDRESS || ZERO_ADDRESS, AaveLendingPoolAddressProviderABI as AbiItem[], ) @@ -251,7 +251,7 @@ export class AAVEProtocol implements SavingsProtocol { try { const lPoolAdressProviderContract = createContract( web3, - getSavingsConstants(chainId).AAVE_LENDING_POOL_ADDRESSES_PROVIDER_CONTRACT_ADDRESS || ZERO_ADDRESS, + getAaveConstants(chainId).AAVE_LENDING_POOL_ADDRESSES_PROVIDER_CONTRACT_ADDRESS || ZERO_ADDRESS, AaveLendingPoolAddressProviderABI as AbiItem[], ) diff --git a/packages/mask/src/plugins/Savings/protocols/LDOProtocol.ts b/packages/mask/src/plugins/Savings/protocols/LDOProtocol.ts index 1388564d69ec..686eb9be3fc4 100644 --- a/packages/mask/src/plugins/Savings/protocols/LDOProtocol.ts +++ b/packages/mask/src/plugins/Savings/protocols/LDOProtocol.ts @@ -3,7 +3,7 @@ import type { AbiItem } from 'web3-utils' import BigNumber from 'bignumber.js' import { ChainId, - getSavingsConstants, + getLidoConstants, createContract, FungibleTokenDetailed, ZERO_ADDRESS, @@ -50,7 +50,7 @@ export class LidoProtocol implements SavingsProtocol { try { const contract = createContract( web3, - getSavingsConstants(chainId).LIDO_STETH || ZERO_ADDRESS, + getLidoConstants(chainId).LIDO_stETH_ADDRESS || ZERO_ADDRESS, LidoABI as AbiItem[], ) this._balance = new BigNumber((await contract?.methods.balanceOf(account).call()) ?? '0') @@ -63,11 +63,11 @@ export class LidoProtocol implements SavingsProtocol { try { const contract = createContract( web3, - getSavingsConstants(chainId).LIDO_STETH || ZERO_ADDRESS, + getLidoConstants(chainId).LIDO_stETH_ADDRESS || ZERO_ADDRESS, LidoABI as AbiItem[], ) const gasEstimate = await contract?.methods - .submit(getSavingsConstants(chainId).LIDO_REFERRAL_ADDRESS || ZERO_ADDRESS) + .submit(getLidoConstants(chainId).LIDO_REFERRAL_ADDRESS || ZERO_ADDRESS) .estimateGas({ from: account, value: value.toString(), @@ -84,10 +84,10 @@ export class LidoProtocol implements SavingsProtocol { try { const contract = createContract( web3, - getSavingsConstants(chainId).LIDO_STETH || ZERO_ADDRESS, + getLidoConstants(chainId).LIDO_stETH_ADDRESS || ZERO_ADDRESS, LidoABI as AbiItem[], ) - await contract?.methods.submit(getSavingsConstants(chainId).LIDO_REFERRAL_ADDRESS || ZERO_ADDRESS).send({ + await contract?.methods.submit(getLidoConstants(chainId).LIDO_REFERRAL_ADDRESS || ZERO_ADDRESS).send({ from: account, value: value.toString(), gas: 300000, diff --git a/packages/web3-constants/evm/aave.json b/packages/web3-constants/evm/aave.json new file mode 100644 index 000000000000..74dafe5d476a --- /dev/null +++ b/packages/web3-constants/evm/aave.json @@ -0,0 +1,42 @@ +{ + "AAVE_SUBGRAPHS": { + "Mainnet": "https://api.thegraph.com/subgraphs/name/aave/protocol-v2", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "https://api.thegraph.com/subgraphs/name/aave/protocol-v2-kovan", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + "AAVE_LENDING_POOL_ADDRESSES_PROVIDER_CONTRACT_ADDRESS": { + "Mainnet": "0xb53c1a33016b2dc2ff3653530bff1848a515c8c5", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "​0x88757f2f99175387ab4c6a4b3067c77a695b0349", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + } +} diff --git a/packages/web3-constants/evm/lido.json b/packages/web3-constants/evm/lido.json new file mode 100644 index 000000000000..5b88bd5868e3 --- /dev/null +++ b/packages/web3-constants/evm/lido.json @@ -0,0 +1,42 @@ +{ + "LIDO_stETH_ADDRESS": { + "Mainnet": "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "0x1643E812aE58766192Cf7D2Cf9567dF2C37e9B7F", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, + "LIDO_REFERRAL_ADDRESS": { + "Mainnet": "0x934b510d4c9103e6a87aef13b816fb080286d649", + "Ropsten": "0x934b510d4c9103e6a87aef13b816fb080286d649", + "Rinkeby": "0x934b510d4c9103e6a87aef13b816fb080286d649", + "Kovan": "0x934b510d4c9103e6a87aef13b816fb080286d649", + "Gorli": "0x934b510d4c9103e6a87aef13b816fb080286d649", + "BSC": "0x934b510d4c9103e6a87aef13b816fb080286d649", + "BSCT": "0x934b510d4c9103e6a87aef13b816fb080286d649", + "Matic": "0x934b510d4c9103e6a87aef13b816fb080286d649", + "Mumbai": "0x934b510d4c9103e6a87aef13b816fb080286d649", + "Arbitrum": "0x934b510d4c9103e6a87aef13b816fb080286d649", + "Arbitrum_Rinkeby": "0x934b510d4c9103e6a87aef13b816fb080286d649", + "xDai": "0x934b510d4c9103e6a87aef13b816fb080286d649", + "Avalanche": "0x934b510d4c9103e6a87aef13b816fb080286d649", + "Avalanche_Fuji": "0x934b510d4c9103e6a87aef13b816fb080286d649", + "Celo": "0x934b510d4c9103e6a87aef13b816fb080286d649", + "Fantom": "0x934b510d4c9103e6a87aef13b816fb080286d649", + "Aurora": "0x934b510d4c9103e6a87aef13b816fb080286d649", + "Aurora_Testnet": "0x934b510d4c9103e6a87aef13b816fb080286d649" + } +} diff --git a/packages/web3-constants/evm/savings.json b/packages/web3-constants/evm/savings.json deleted file mode 100644 index 288299df2df0..000000000000 --- a/packages/web3-constants/evm/savings.json +++ /dev/null @@ -1,724 +0,0 @@ -{ - "AAVE": { - "Mainnet": "0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9", - "Ropsten": "", - "Rinkeby": "", - "Kovan": "0xb597cd8d3217ea6477232f9217fa70837ff667af", - "Gorli": "", - "BSC": "", - "BSCT": "", - "Matic": "", - "Mumbai": "", - "Arbitrum": "", - "Arbitrum_Rinkeby": "", - "xDai": "", - "Avalanche": "", - "Avalanche_Fuji": "", - "Celo": "", - "Fantom": "", - "Aurora": "", - "Aurora_Testnet": "" - }, - "LIDO": { - "Mainnet": "0x5A98FcBEA516Cf06857215779Fd812CA3beF1B32", - "Ropsten": "", - "Rinkeby": "", - "Kovan": "", - "Gorli": "0x56340274fB5a72af1A3C6609061c451De7961Bd4", - "BSC": "", - "BSCT": "", - "Matic": "", - "Mumbai": "", - "Arbitrum": "", - "Arbitrum_Rinkeby": "", - "xDai": "", - "Avalanche": "", - "Avalanche_Fuji": "", - "Celo": "", - "Fantom": "", - "Aurora": "", - "Aurora_Testnet": "" - }, - "LIDO_STETH": { - "Mainnet": "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84", - "Ropsten": "", - "Rinkeby": "", - "Kovan": "", - "Gorli": "0x1643E812aE58766192Cf7D2Cf9567dF2C37e9B7F", - "BSC": "", - "BSCT": "", - "Matic": "", - "Mumbai": "", - "Arbitrum": "", - "Arbitrum_Rinkeby": "", - "xDai": "", - "Avalanche": "", - "Avalanche_Fuji": "", - "Celo": "", - "Fantom": "", - "Aurora": "", - "Aurora_Testnet": "" - }, - "LIDO_REFERRAL_ADDRESS": { - "Mainnet": "0x278D7e418a28ff763eEeDf29238CD6dfcade3A3a", - "Ropsten": "", - "Rinkeby": "", - "Kovan": "", - "Gorli": "0x278D7e418a28ff763eEeDf29238CD6dfcade3A3a", - "BSC": "", - "BSCT": "", - "Matic": "", - "Mumbai": "", - "Arbitrum": "", - "Arbitrum_Rinkeby": "", - "xDai": "", - "Avalanche": "", - "Avalanche_Fuji": "", - "Celo": "", - "Fantom": "", - "Aurora": "", - "Aurora_Testnet": "" - }, - "AAVE_SUBGRAPHS": { - "Mainnet": "https://api.thegraph.com/subgraphs/name/aave/protocol-v2", - "Ropsten": "", - "Rinkeby": "", - "Kovan": "https://api.thegraph.com/subgraphs/name/aave/protocol-v2-kovan", - "Gorli": "", - "BSC": "", - "BSCT": "", - "Matic": "", - "Mumbai": "", - "Arbitrum": "", - "Arbitrum_Rinkeby": "", - "xDai": "", - "Avalanche": "", - "Avalanche_Fuji": "", - "Celo": "", - "Fantom": "", - "Aurora": "", - "Aurora_Testnet": "" - }, - "AAVE_LENDING_POOL_ADDRESSES_PROVIDER_CONTRACT_ADDRESS": { - "Mainnet": "0xb53c1a33016b2dc2ff3653530bff1848a515c8c5", - "Ropsten": "", - "Rinkeby": "", - "Kovan": "​0x88757f2f99175387ab4c6a4b3067c77a695b0349", - "Gorli": "", - "BSC": "", - "BSCT": "", - "Matic": "", - "Mumbai": "", - "Arbitrum": "", - "Arbitrum_Rinkeby": "", - "xDai": "", - "Avalanche": "", - "Avalanche_Fuji": "", - "Celo": "", - "Fantom": "", - "Aurora": "", - "Aurora_Testnet": "" - }, - - "USDT" : { - "Mainnet" : "0xdAC17F958D2ee523a2206206994597C13D831ec7", - "Ropsten" : "", - "Rinkeby" : "", - "Kovan" : "0x13512979ADE267AB5100878E2e0f485B568328a4", - "Gorli" : "", - "BSC" : "", - "BSCT" : "", - "Matic" : "", - "Mumbai" : "", - "Arbitrum" : "", - "Arbitrum_Rinkeby" : "", - "xDai" : "", - "Avalanche" : "", - "Avalanche_Fuji" : "", - "Celo" : "", - "Fantom" : "", - "Aurora" : "", - "Aurora_Testnet" : "" - }, - "WBTC" : { - "Mainnet" : "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599", - "Ropsten" : "", - "Rinkeby" : "", - "Kovan" : "0xD1B98B6607330172f1D991521145A22BCe793277", - "Gorli" : "", - "BSC" : "", - "BSCT" : "", - "Matic" : "", - "Mumbai" : "", - "Arbitrum" : "", - "Arbitrum_Rinkeby" : "", - "xDai" : "", - "Avalanche" : "", - "Avalanche_Fuji" : "", - "Celo" : "", - "Fantom" : "", - "Aurora" : "", - "Aurora_Testnet" : "" - }, - "WETH" : { - "Mainnet" : "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", - "Ropsten" : "", - "Rinkeby" : "", - "Kovan" : "0xd0A1E359811322d97991E03f863a0C30C2cF029C", - "Gorli" : "", - "BSC" : "", - "BSCT" : "", - "Matic" : "", - "Mumbai" : "", - "Arbitrum" : "", - "Arbitrum_Rinkeby" : "", - "xDai" : "", - "Avalanche" : "", - "Avalanche_Fuji" : "", - "Celo" : "", - "Fantom" : "", - "Aurora" : "", - "Aurora_Testnet" : "" - }, - "YFI" : { - "Mainnet" : "0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e", - "Ropsten" : "", - "Rinkeby" : "", - "Kovan" : "0xb7c325266ec274fEb1354021D27FA3E3379D840d", - "Gorli" : "", - "BSC" : "", - "BSCT" : "", - "Matic" : "", - "Mumbai" : "", - "Arbitrum" : "", - "Arbitrum_Rinkeby" : "", - "xDai" : "", - "Avalanche" : "", - "Avalanche_Fuji" : "", - "Celo" : "", - "Fantom" : "", - "Aurora" : "", - "Aurora_Testnet" : "" - }, - "ZRX" : { - "Mainnet" : "0xE41d2489571d322189246DaFA5ebDe1F4699F498", - "Ropsten" : "", - "Rinkeby" : "", - "Kovan" : "0xD0d76886cF8D952ca26177EB7CfDf83bad08C00C", - "Gorli" : "", - "BSC" : "", - "BSCT" : "", - "Matic" : "", - "Mumbai" : "", - "Arbitrum" : "", - "Arbitrum_Rinkeby" : "", - "xDai" : "", - "Avalanche" : "", - "Avalanche_Fuji" : "", - "Celo" : "", - "Fantom" : "", - "Aurora" : "", - "Aurora_Testnet" : "" - }, - "UNI" : { - "Mainnet" : "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984", - "Ropsten" : "", - "Rinkeby" : "", - "Kovan" : "0x075A36BA8846C6B6F53644fDd3bf17E5151789DC", - "Gorli" : "", - "BSC" : "", - "BSCT" : "", - "Matic" : "", - "Mumbai" : "", - "Arbitrum" : "", - "Arbitrum_Rinkeby" : "", - "xDai" : "", - "Avalanche" : "", - "Avalanche_Fuji" : "", - "Celo" : "", - "Fantom" : "", - "Aurora" : "", - "Aurora_Testnet" : "" - }, - - "BAT" : { - "Mainnet" : "0x0D8775F648430679A709E98d2b0Cb6250d2887EF", - "Ropsten" : "", - "Rinkeby" : "", - "Kovan" : "0x2d12186Fbb9f9a8C28B3FfdD4c42920f8539D738", - "Gorli" : "", - "BSC" : "", - "BSCT" : "", - "Matic" : "", - "Mumbai" : "", - "Arbitrum" : "", - "Arbitrum_Rinkeby" : "", - "xDai" : "", - "Avalanche" : "", - "Avalanche_Fuji" : "", - "Celo" : "", - "Fantom" : "", - "Aurora" : "", - "Aurora_Testnet" : "" - }, - "BUSD" : { - "Mainnet" : "0x4Fabb145d64652a948d72533023f6E7A623C7C53", - "Ropsten" : "", - "Rinkeby" : "", - "Kovan" : "0x4c6E1EFC12FDfD568186b7BAEc0A43fFfb4bCcCf", - "Gorli" : "", - "BSC" : "", - "BSCT" : "", - "Matic" : "", - "Mumbai" : "", - "Arbitrum" : "", - "Arbitrum_Rinkeby" : "", - "xDai" : "", - "Avalanche" : "", - "Avalanche_Fuji" : "", - "Celo" : "", - "Fantom" : "", - "Aurora" : "", - "Aurora_Testnet" : "" - }, - "DAI" : { - "Mainnet" : "0x6B175474E89094C44Da98b954EedeAC495271d0F", - "Ropsten" : "", - "Rinkeby" : "", - "Kovan" : "0xFf795577d9AC8bD7D90Ee22b6C1703490b6512FD", - "Gorli" : "", - "BSC" : "", - "BSCT" : "", - "Matic" : "", - "Mumbai" : "", - "Arbitrum" : "", - "Arbitrum_Rinkeby" : "", - "xDai" : "", - "Avalanche" : "", - "Avalanche_Fuji" : "", - "Celo" : "", - "Fantom" : "", - "Aurora" : "", - "Aurora_Testnet" : "" - }, - "ENJ" : { - "Mainnet" : "0xF629cBd94d3791C9250152BD8dfBDF380E2a3B9c", - "Ropsten" : "", - "Rinkeby" : "", - "Kovan" : "0xC64f90Cd7B564D3ab580eb20a102A8238E218be2", - "Gorli" : "", - "BSC" : "", - "BSCT" : "", - "Matic" : "", - "Mumbai" : "", - "Arbitrum" : "", - "Arbitrum_Rinkeby" : "", - "xDai" : "", - "Avalanche" : "", - "Avalanche_Fuji" : "", - "Celo" : "", - "Fantom" : "", - "Aurora" : "", - "Aurora_Testnet" : "" - }, - "KNC" : { - "Mainnet" : "0xdd974D5C2e2928deA5F71b9825b8b646686BD200", - "Ropsten" : "", - "Rinkeby" : "", - "Kovan" : "0x3F80c39c0b96A0945f9F0E9f55d8A8891c5671A8", - "Gorli" : "", - "BSC" : "", - "BSCT" : "", - "Matic" : "", - "Mumbai" : "", - "Arbitrum" : "", - "Arbitrum_Rinkeby" : "", - "xDai" : "", - "Avalanche" : "", - "Avalanche_Fuji" : "", - "Celo" : "", - "Fantom" : "", - "Aurora" : "", - "Aurora_Testnet" : "" - }, - "LINK" : { - "Mainnet" : "0x514910771AF9Ca656af840dff83E8264EcF986CA", - "Ropsten" : "", - "Rinkeby" : "", - "Kovan" : "0xAD5ce863aE3E4E9394Ab43d4ba0D80f419F61789", - "Gorli" : "", - "BSC" : "", - "BSCT" : "", - "Matic" : "", - "Mumbai" : "", - "Arbitrum" : "", - "Arbitrum_Rinkeby" : "", - "xDai" : "", - "Avalanche" : "", - "Avalanche_Fuji" : "", - "Celo" : "", - "Fantom" : "", - "Aurora" : "", - "Aurora_Testnet" : "" - }, - "MANA" : { - "Mainnet" : "0x0F5D2fB29fb7d3CFeE444a200298f468908cC942", - "Ropsten" : "", - "Rinkeby" : "", - "Kovan" : "0x738Dc6380157429e957d223e6333Dc385c85Fec7", - "Gorli" : "", - "BSC" : "", - "BSCT" : "", - "Matic" : "", - "Mumbai" : "", - "Arbitrum" : "", - "Arbitrum_Rinkeby" : "", - "xDai" : "", - "Avalanche" : "", - "Avalanche_Fuji" : "", - "Celo" : "", - "Fantom" : "", - "Aurora" : "", - "Aurora_Testnet" : "" - }, - "MKR" : { - "Mainnet" : "0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2", - "Ropsten" : "", - "Rinkeby" : "", - "Kovan" : "0x61e4CAE3DA7FD189e52a4879C7B8067D7C2Cc0FA", - "Gorli" : "", - "BSC" : "", - "BSCT" : "", - "Matic" : "", - "Mumbai" : "", - "Arbitrum" : "", - "Arbitrum_Rinkeby" : "", - "xDai" : "", - "Avalanche" : "", - "Avalanche_Fuji" : "", - "Celo" : "", - "Fantom" : "", - "Aurora" : "", - "Aurora_Testnet" : "" - }, - "REN" : { - "Mainnet" : "0x408e41876cCCDC0F92210600ef50372656052a38", - "Ropsten" : "", - "Rinkeby" : "", - "Kovan" : "0x5eebf65A6746eed38042353Ba84c8e37eD58Ac6f", - "Gorli" : "", - "BSC" : "", - "BSCT" : "", - "Matic" : "", - "Mumbai" : "", - "Arbitrum" : "", - "Arbitrum_Rinkeby" : "", - "xDai" : "", - "Avalanche" : "", - "Avalanche_Fuji" : "", - "Celo" : "", - "Fantom" : "", - "Aurora" : "", - "Aurora_Testnet" : "" - }, - "SNX" : { - "Mainnet" : "0xC011a73ee8576Fb46F5E1c5751cA3B9Fe0af2a6F", - "Ropsten" : "", - "Rinkeby" : "", - "Kovan" : "0x7FDb81B0b8a010dd4FFc57C3fecbf145BA8Bd947", - "Gorli" : "", - "BSC" : "", - "BSCT" : "", - "Matic" : "", - "Mumbai" : "", - "Arbitrum" : "", - "Arbitrum_Rinkeby" : "", - "xDai" : "", - "Avalanche" : "", - "Avalanche_Fuji" : "", - "Celo" : "", - "Fantom" : "", - "Aurora" : "", - "Aurora_Testnet" : "" - }, - "sUSD" : { - "Mainnet" : "0x57Ab1ec28D129707052df4dF418D58a2D46d5f51", - "Ropsten" : "", - "Rinkeby" : "", - "Kovan" : "0x99b267b9D96616f906D53c26dECf3C5672401282", - "Gorli" : "", - "BSC" : "", - "BSCT" : "", - "Matic" : "", - "Mumbai" : "", - "Arbitrum" : "", - "Arbitrum_Rinkeby" : "", - "xDai" : "", - "Avalanche" : "", - "Avalanche_Fuji" : "", - "Celo" : "", - "Fantom" : "", - "Aurora" : "", - "Aurora_Testnet" : "" - }, - "TUSD" : { - "Mainnet" : "0x0000000000085d4780B73119b644AE5ecd22b376", - "Ropsten" : "", - "Rinkeby" : "", - "Kovan" : "0x016750AC630F711882812f24Dba6c95b9D35856d", - "Gorli" : "", - "BSC" : "", - "BSCT" : "", - "Matic" : "", - "Mumbai" : "", - "Arbitrum" : "", - "Arbitrum_Rinkeby" : "", - "xDai" : "", - "Avalanche" : "", - "Avalanche_Fuji" : "", - "Celo" : "", - "Fantom" : "", - "Aurora" : "", - "Aurora_Testnet" : "" - }, - "USDC" : { - "Mainnet" : "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", - "Ropsten" : "", - "Rinkeby" : "", - "Kovan" : "0xe22da380ee6B445bb8273C81944ADEB6E8450422", - "Gorli" : "", - "BSC" : "", - "BSCT" : "", - "Matic" : "", - "Mumbai" : "", - "Arbitrum" : "", - "Arbitrum_Rinkeby" : "", - "xDai" : "", - "Avalanche" : "", - "Avalanche_Fuji" : "", - "Celo" : "", - "Fantom" : "", - "Aurora" : "", - "Aurora_Testnet" : "" - }, - "CRV" : { - "Mainnet" : "0xD533a949740bb3306d119CC777fa900bA034cd52", - "Ropsten" : "", - "Rinkeby" : "", - "Kovan" : "", - "Gorli" : "", - "BSC" : "", - "BSCT" : "", - "Matic" : "", - "Mumbai" : "", - "Arbitrum" : "", - "Arbitrum_Rinkeby" : "", - "xDai" : "", - "Avalanche" : "", - "Avalanche_Fuji" : "", - "Celo" : "", - "Fantom" : "", - "Aurora" : "", - "Aurora_Testnet" : "" - }, - "GUSD" : { - "Mainnet" : "0x056Fd409E1d7A124BD7017459dFEa2F387b6d5Cd", - "Ropsten" : "", - "Rinkeby" : "", - "Kovan" : "", - "Gorli" : "", - "BSC" : "", - "BSCT" : "", - "Matic" : "", - "Mumbai" : "", - "Arbitrum" : "", - "Arbitrum_Rinkeby" : "", - "xDai" : "", - "Avalanche" : "", - "Avalanche_Fuji" : "", - "Celo" : "", - "Fantom" : "", - "Aurora" : "", - "Aurora_Testnet" : "" - }, - "BAL" : { - "Mainnet" : "0xba100000625a3754423978a60c9317c58a424e3D", - "Ropsten" : "", - "Rinkeby" : "", - "Kovan" : "", - "Gorli" : "", - "BSC" : "", - "BSCT" : "", - "Matic" : "", - "Mumbai" : "", - "Arbitrum" : "", - "Arbitrum_Rinkeby" : "", - "xDai" : "", - "Avalanche" : "", - "Avalanche_Fuji" : "", - "Celo" : "", - "Fantom" : "", - "Aurora" : "", - "Aurora_Testnet" : "" - }, - "xSUSHI" : { - "Mainnet" : "0x8798249c2E607446EfB7Ad49eC89dD1865Ff4272", - "Ropsten" : "", - "Rinkeby" : "", - "Kovan" : "", - "Gorli" : "", - "BSC" : "", - "BSCT" : "", - "Matic" : "", - "Mumbai" : "", - "Arbitrum" : "", - "Arbitrum_Rinkeby" : "", - "xDai" : "", - "Avalanche" : "", - "Avalanche_Fuji" : "", - "Celo" : "", - "Fantom" : "", - "Aurora" : "", - "Aurora_Testnet" : "" - }, - "renFIL" : { - "Mainnet" : "0xD5147bc8e386d91Cc5DBE72099DAC6C9b99276F5", - "Ropsten" : "", - "Rinkeby" : "", - "Kovan" : "", - "Gorli" : "", - "BSC" : "", - "BSCT" : "", - "Matic" : "", - "Mumbai" : "", - "Arbitrum" : "", - "Arbitrum_Rinkeby" : "", - "xDai" : "", - "Avalanche" : "", - "Avalanche_Fuji" : "", - "Celo" : "", - "Fantom" : "", - "Aurora" : "", - "Aurora_Testnet" : "" - }, - "RAI" : { - "Mainnet" : "0x03ab458634910AaD20eF5f1C8ee96F1D6ac54919", - "Ropsten" : "", - "Rinkeby" : "", - "Kovan" : "", - "Gorli" : "", - "BSC" : "", - "BSCT" : "", - "Matic" : "", - "Mumbai" : "", - "Arbitrum" : "", - "Arbitrum_Rinkeby" : "", - "xDai" : "", - "Avalanche" : "", - "Avalanche_Fuji" : "", - "Celo" : "", - "Fantom" : "", - "Aurora" : "", - "Aurora_Testnet" : "" - }, - "AMPL" : { - "Mainnet" : "0xD46bA6D942050d489DBd938a2C909A5d5039A161", - "Ropsten" : "", - "Rinkeby" : "", - "Kovan" : "0x3E0437898a5667a4769B1Ca5A34aAB1ae7E81377", - "Gorli" : "", - "BSC" : "", - "BSCT" : "", - "Matic" : "", - "Mumbai" : "", - "Arbitrum" : "", - "Arbitrum_Rinkeby" : "", - "xDai" : "", - "Avalanche" : "", - "Avalanche_Fuji" : "", - "Celo" : "", - "Fantom" : "", - "Aurora" : "", - "Aurora_Testnet" : "" - }, - "USDP" : { - "Mainnet" : "0x8E870D67F660D95d5be530380D0eC0bd388289E1", - "Ropsten" : "", - "Rinkeby" : "", - "Kovan" : "", - "Gorli" : "", - "BSC" : "", - "BSCT" : "", - "Matic" : "", - "Mumbai" : "", - "Arbitrum" : "", - "Arbitrum_Rinkeby" : "", - "xDai" : "", - "Avalanche" : "", - "Avalanche_Fuji" : "", - "Celo" : "", - "Fantom" : "", - "Aurora" : "", - "Aurora_Testnet" : "" - }, - "DPI" : { - "Mainnet" : "0x1494CA1F11D487c2bBe4543E90080AeBa4BA3C2b", - "Ropsten" : "", - "Rinkeby" : "", - "Kovan" : "", - "Gorli" : "", - "BSC" : "", - "BSCT" : "", - "Matic" : "", - "Mumbai" : "", - "Arbitrum" : "", - "Arbitrum_Rinkeby" : "", - "xDai" : "", - "Avalanche" : "", - "Avalanche_Fuji" : "", - "Celo" : "", - "Fantom" : "", - "Aurora" : "", - "Aurora_Testnet" : "" - }, - "FRAX" : { - "Mainnet" : "0x853d955aCEf822Db058eb8505911ED77F175b99e", - "Ropsten" : "", - "Rinkeby" : "", - "Kovan" : "", - "Gorli" : "", - "BSC" : "", - "BSCT" : "", - "Matic" : "", - "Mumbai" : "", - "Arbitrum" : "", - "Arbitrum_Rinkeby" : "", - "xDai" : "", - "Avalanche" : "", - "Avalanche_Fuji" : "", - "Celo" : "", - "Fantom" : "", - "Aurora" : "", - "Aurora_Testnet" : "" - }, - "FEI" : { - "Mainnet" : "0x956F47F50A910163D8BF957Cf5846D573E7f87CA", - "Ropsten" : "", - "Rinkeby" : "", - "Kovan" : "", - "Gorli" : "", - "BSC" : "", - "BSCT" : "", - "Matic" : "", - "Mumbai" : "", - "Arbitrum" : "", - "Arbitrum_Rinkeby" : "", - "xDai" : "", - "Avalanche" : "", - "Avalanche_Fuji" : "", - "Celo" : "", - "Fantom" : "", - "Aurora" : "", - "Aurora_Testnet" : "" - } -} diff --git a/packages/web3-constants/evm/token.json b/packages/web3-constants/evm/token.json index 7ab4f9ac4c3e..f0f3137e47a4 100644 --- a/packages/web3-constants/evm/token.json +++ b/packages/web3-constants/evm/token.json @@ -999,6 +999,26 @@ "Aurora": "", "Aurora_Testnet": "" }, + "LIDO_ADDRESS": { + "Mainnet": "0x5A98FcBEA516Cf06857215779Fd812CA3beF1B32", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "0x56340274fB5a72af1A3C6609061c451De7961Bd4", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" + }, "AAVE_ADDRESS": { "Mainnet": "0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9", "Ropsten": "", diff --git a/packages/web3-shared/evm/constants/index.ts b/packages/web3-shared/evm/constants/index.ts index c2cdd789ac82..100f2d079646 100644 --- a/packages/web3-shared/evm/constants/index.ts +++ b/packages/web3-shared/evm/constants/index.ts @@ -24,7 +24,8 @@ import SpaceStationGalaxy from '@masknet/web3-constants/evm/space-station-galaxy import OpenseaAPI from '@masknet/web3-constants/evm/opensea-api.json' import CryptoArtAI from '@masknet/web3-constants/evm/cryptoartai.json' import ArtBlocks from '@masknet/web3-constants/evm/artblocks.json' -import Savings from '@masknet/web3-constants/evm/savings.json' +import Aave from '@masknet/web3-constants/evm/aave.json' +import Lido from '@masknet/web3-constants/evm/lido.json' import { hookTransform, transform, transformFromJSON } from './utils' function getEnvConstants(key: 'WEB3_CONSTANTS_RPC') { @@ -118,5 +119,8 @@ export const useArtBlocksConstants = hookTransform(getArtBlocksConstants) export const getNftRedPacketConstants = transform(NftRedPacket) export const useNftRedPacketConstants = hookTransform(getNftRedPacketConstants) -export const getSavingsConstants = transform(Savings) -export const useSavingsConstants = hookTransform(getSavingsConstants) +export const getLidoConstants = transform(Aave) +export const useLidoConstants = hookTransform(getLidoConstants) + +export const getAaveConstants = transform(Lido) +export const useAaveConstants = hookTransform(getAaveConstants) From dd8d84c3887d133fbd93dd639b59df7b0afa3f96 Mon Sep 17 00:00:00 2001 From: "@layinka" Date: Tue, 8 Mar 2022 09:01:08 +0100 Subject: [PATCH 25/38] Trailing whitespace --- packages/web3-constants/evm/savings.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/web3-constants/evm/savings.json b/packages/web3-constants/evm/savings.json index 288299df2df0..9a3af6afd3b0 100644 --- a/packages/web3-constants/evm/savings.json +++ b/packages/web3-constants/evm/savings.json @@ -239,8 +239,7 @@ "Fantom" : "", "Aurora" : "", "Aurora_Testnet" : "" - }, - + }, "BAT" : { "Mainnet" : "0x0D8775F648430679A709E98d2b0Cb6250d2887EF", "Ropsten" : "", From 94959c1299f036de1295db530ef01b4fcca7f4fa Mon Sep 17 00:00:00 2001 From: guanbinrui Date: Tue, 8 Mar 2022 16:03:49 +0800 Subject: [PATCH 26/38] fix: build error --- cspell.json | 13 +++++++++++-- .../src/plugins/Savings/protocols/AAVEProtocol.ts | 12 ++++++------ packages/web3-shared/evm/constants/index.ts | 8 ++++---- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/cspell.json b/cspell.json index bda32aaaf9ef..e0212c12e560 100644 --- a/cspell.json +++ b/cspell.json @@ -261,7 +261,11 @@ "xlarge", "xlink", "zerion", - "zubin" + "zubin", + "rebalance", + "repayer", + "flashloan", + "lendingpool" ], "ignoreWords": [ "aicanft", @@ -371,7 +375,12 @@ "walletlink", "wnative", "xdescribe", - "xtest" + "xtest", + "gusd", + "xsushi", + "renfil", + "usdp", + "frax" ], "ignoreRegExpList": ["/@servie/"], "overrides": [ diff --git a/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts b/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts index 50a449c8882c..49b1669c5479 100644 --- a/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts +++ b/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts @@ -188,13 +188,13 @@ export class AAVEProtocol implements SavingsProtocol { private async createDepositTokenOperation(account: string, chainId: ChainId, web3: Web3, value: BigNumber.Value) { const aaveLPoolAddress = getAaveConstants(chainId).AAVE_LENDING_POOL_ADDRESSES_PROVIDER_CONTRACT_ADDRESS || ZERO_ADDRESS - const lPoolAdressProviderContract = createContract( + const lPoolAddressProviderContract = createContract( web3, aaveLPoolAddress, AaveLendingPoolAddressProviderABI as AbiItem[], ) - const poolAddress = await lPoolAdressProviderContract?.methods.getLendingPool().call() + const poolAddress = await lPoolAddressProviderContract?.methods.getLendingPool().call() const contract = createContract( web3, @@ -223,13 +223,13 @@ export class AAVEProtocol implements SavingsProtocol { public async withdrawEstimate(account: string, chainId: ChainId, web3: Web3, value: BigNumber.Value) { try { - const lPoolAdressProviderContract = createContract( + const lPoolAddressProviderContract = createContract( web3, getAaveConstants(chainId).AAVE_LENDING_POOL_ADDRESSES_PROVIDER_CONTRACT_ADDRESS || ZERO_ADDRESS, AaveLendingPoolAddressProviderABI as AbiItem[], ) - const poolAddress = await lPoolAdressProviderContract?.methods.getLendingPool().call() + const poolAddress = await lPoolAddressProviderContract?.methods.getLendingPool().call() const contract = createContract( web3, @@ -249,13 +249,13 @@ export class AAVEProtocol implements SavingsProtocol { public async withdraw(account: string, chainId: ChainId, web3: Web3, value: BigNumber.Value) { try { - const lPoolAdressProviderContract = createContract( + const lPoolAddressProviderContract = createContract( web3, getAaveConstants(chainId).AAVE_LENDING_POOL_ADDRESSES_PROVIDER_CONTRACT_ADDRESS || ZERO_ADDRESS, AaveLendingPoolAddressProviderABI as AbiItem[], ) - const poolAddress = await lPoolAdressProviderContract?.methods.getLendingPool().call() + const poolAddress = await lPoolAddressProviderContract?.methods.getLendingPool().call() const gasEstimate = await this.withdrawEstimate(account, chainId, web3, value) const contract = createContract( diff --git a/packages/web3-shared/evm/constants/index.ts b/packages/web3-shared/evm/constants/index.ts index 100f2d079646..3349da548295 100644 --- a/packages/web3-shared/evm/constants/index.ts +++ b/packages/web3-shared/evm/constants/index.ts @@ -119,8 +119,8 @@ export const useArtBlocksConstants = hookTransform(getArtBlocksConstants) export const getNftRedPacketConstants = transform(NftRedPacket) export const useNftRedPacketConstants = hookTransform(getNftRedPacketConstants) -export const getLidoConstants = transform(Aave) -export const useLidoConstants = hookTransform(getLidoConstants) - -export const getAaveConstants = transform(Lido) +export const getAaveConstants = transform(Aave) export const useAaveConstants = hookTransform(getAaveConstants) + +export const getLidoConstants = transform(Lido) +export const useLidoConstants = hookTransform(getLidoConstants) From 5165e453c0c0f9ad1496b0108574ad5ed1e1034c Mon Sep 17 00:00:00 2001 From: guanbinrui Date: Wed, 9 Mar 2022 12:22:34 +0800 Subject: [PATCH 27/38] fix: build error --- packages/mask/src/plugins/Savings/SNSAdaptor/SavingsTable.tsx | 2 +- packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts | 4 ++-- packages/mask/src/plugins/Trader/constants/uniswap.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsTable.tsx b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsTable.tsx index 5987d5988613..1a628a310608 100644 --- a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsTable.tsx +++ b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsTable.tsx @@ -6,7 +6,7 @@ import { isZero, rightShift } from '@masknet/web3-shared-base' import { ChainId, useWeb3, useAccount, formatBalance } from '@masknet/web3-shared-evm' import { ProviderIconURLs } from './IconURL' import { useI18N } from '../../../utils' -import { TabType, ProtocolType, SavingsProtocol } from '../types' +import { TabType, SavingsProtocol } from '../types' const useStyles = makeStyles()((theme, props) => ({ containerWrap: { diff --git a/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts b/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts index 49b1669c5479..31eb011ab028 100644 --- a/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts +++ b/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts @@ -1,7 +1,7 @@ -import BigNumber from 'bignumber.js' -import { pow10, ZERO } from '@masknet/web3-shared-base' import type Web3 from 'web3' import type { AbiItem } from 'web3-utils' +import BigNumber from 'bignumber.js' +import { pow10, ZERO } from '@masknet/web3-shared-base' import { ChainId, getAaveConstants, diff --git a/packages/mask/src/plugins/Trader/constants/uniswap.ts b/packages/mask/src/plugins/Trader/constants/uniswap.ts index 227db6fb4664..4308f19d5d3f 100644 --- a/packages/mask/src/plugins/Trader/constants/uniswap.ts +++ b/packages/mask/src/plugins/Trader/constants/uniswap.ts @@ -1,6 +1,6 @@ +import JSBI from 'jsbi' import { ChainId } from '@masknet/web3-shared-evm' import { Percent } from '@uniswap/sdk-core' -import JSBI from 'jsbi' import { AMPL, DAI, USDC, USDT, WBTC, WNATIVE, WNATIVE_ONLY } from './trader' import type { ERC20AgainstToken, ERC20TokenCustomizedBase } from './types' From b14d755d2feb882be8d171b6b55c429e0a9abddf Mon Sep 17 00:00:00 2001 From: "@layinka" Date: Tue, 15 Mar 2022 12:19:40 +0100 Subject: [PATCH 28/38] change APR to prcent --- packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts b/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts index 50a449c8882c..4c5be3fab5b6 100644 --- a/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts +++ b/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts @@ -56,6 +56,7 @@ export class AAVEProtocol implements SavingsProtocol { query: `{ reserves (where: { underlyingAsset: "${this.bareToken.address}" + pool : "0xb53c1a33016b2dc2ff3653530bff1848a515c8c5" }) { id name @@ -89,7 +90,7 @@ export class AAVEProtocol implements SavingsProtocol { const SECONDS_PER_YEAR = 31536000 // APY and APR are returned here as decimals, multiply by 100 to get the percents - this._apr = new BigNumber(liquidityRate).div(RAY).toFixed(2) + this._apr = new BigNumber(liquidityRate).times(100).div(RAY).toFixed(2) } catch (error) { this._apr = AAVEProtocol.DEFAULT_APR } @@ -102,6 +103,7 @@ export class AAVEProtocol implements SavingsProtocol { query: `{ reserves (where: { underlyingAsset: "${this.bareToken.address}" + pool : "0xb53c1a33016b2dc2ff3653530bff1848a515c8c5" }) { id name From 67234be2b25fa764bfae174d3db186b473717679 Mon Sep 17 00:00:00 2001 From: nuanyang233 <528944303@qq.com> Date: Wed, 16 Mar 2022 17:24:10 +0800 Subject: [PATCH 29/38] fix: bugfix --- .../Savings/SNSAdaptor/SavingsDialog.tsx | 2 +- .../Savings/SNSAdaptor/SavingsForm.tsx | 46 +++++++++++-------- .../Savings/SNSAdaptor/SavingsTable.tsx | 4 +- 3 files changed, 31 insertions(+), 21 deletions(-) diff --git a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsDialog.tsx b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsDialog.tsx index 55eb7d20ba5f..278dfe63a255 100644 --- a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsDialog.tsx +++ b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsDialog.tsx @@ -44,7 +44,7 @@ export function SavingsDialog({ open, onClose }: SavingsDialogProps) { { if (selectedProtocol === null) { diff --git a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsForm.tsx b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsForm.tsx index 5fdacceb561e..9ccc306c1a78 100644 --- a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsForm.tsx +++ b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsForm.tsx @@ -6,12 +6,13 @@ import { unreachable } from '@dimensiondev/kit' import { isLessThan, rightShift } from '@masknet/web3-shared-base' import { EthereumTokenType, - useNativeTokenDetailed, useFungibleTokenBalance, useWeb3, useAccount, formatCurrency, formatBalance, + isSameAddress, + useTokenConstants, } from '@masknet/web3-shared-evm' import { TokenAmountPanel, @@ -41,13 +42,12 @@ export function SavingsForm({ chainId, protocol, tab, onClose }: SavingsFormProp const { t } = useI18N() const { classes } = useStyles() - const { value: nativeTokenDetailed } = useNativeTokenDetailed() const web3 = useWeb3({ chainId }) const account = useAccount() + const { NATIVE_TOKEN_ADDRESS } = useTokenConstants() const [inputAmount, setInputAmount] = useState('') const [estimatedGas, setEstimatedGas] = useState(new BigNumber('0')) - const [loading, setLoading] = useState(false) const { value: nativeTokenBalance } = useFungibleTokenBalance(EthereumTokenType.Native, '', chainId) @@ -70,34 +70,41 @@ export function SavingsForm({ chainId, protocol, tab, onClose }: SavingsFormProp }, [protocol, openSwapDialog]) // #region form variables - const tokenAmount = useMemo(() => new BigNumber(rightShift(inputAmount || '0', 18)), [inputAmount]) - const inputAsBN = useMemo(() => new BigNumber(rightShift(inputAmount, 18)), [inputAmount]) + const { value: inputTokenBalance } = useFungibleTokenBalance( + isSameAddress(protocol.bareToken.address, NATIVE_TOKEN_ADDRESS) + ? EthereumTokenType.Native + : protocol.bareToken.type ?? EthereumTokenType.Native, + protocol.bareToken.address, + chainId, + ) + const tokenAmount = useMemo( + () => new BigNumber(rightShift(inputAmount || '0', protocol.bareToken.decimals)), + [inputAmount, protocol.bareToken.decimals], + ) const balanceAsBN = useMemo( - () => (TabType.Deposit ? new BigNumber(nativeTokenBalance || '0') : protocol.balance), - [nativeTokenBalance, protocol.balance], + () => (tab === TabType.Deposit ? new BigNumber(inputTokenBalance || '0') : protocol.balance), + [tab, protocol.balance, inputTokenBalance], ) - useAsync(async () => { - if (!(inputAsBN.toNumber() > 0)) return + const { loading } = useAsync(async () => { + if (!(tokenAmount.toNumber() > 0)) return try { - setLoading(true) setEstimatedGas( tab === TabType.Deposit - ? await protocol.depositEstimate(account, chainId, web3, inputAsBN) - : await protocol.withdrawEstimate(account, chainId, web3, inputAsBN), + ? await protocol.depositEstimate(account, chainId, web3, tokenAmount) + : await protocol.withdrawEstimate(account, chainId, web3, tokenAmount), ) } catch { // do nothing - } finally { - setLoading(false) + console.log('Failed to estimate gas') } - }, [chainId, tab, protocol, inputAsBN]) + }, [chainId, tab, protocol, tokenAmount]) // #endregion // #region form validation const validationMessage = useMemo(() => { if (tokenAmount.isZero() || !inputAmount) return t('plugin_trader_error_amount_absence') - if (isLessThan(inputAsBN, 0)) return t('plugin_trade_error_input_amount_less_minimum_amount') + if (isLessThan(tokenAmount, 0)) return t('plugin_trade_error_input_amount_less_minimum_amount') if (isLessThan(balanceAsBN.minus(estimatedGas), tokenAmount)) { return t('plugin_trader_error_insufficient_balance', { @@ -108,7 +115,10 @@ export function SavingsForm({ chainId, protocol, tab, onClose }: SavingsFormProp return '' }, [inputAmount, tokenAmount, nativeTokenBalance, balanceAsBN]) - const tokenPrice = useTokenPrice(chainId, undefined) + const tokenPrice = useTokenPrice( + chainId, + !isSameAddress(protocol.bareToken.address, NATIVE_TOKEN_ADDRESS) ? protocol.bareToken.address : undefined, + ) const tokenValueUSD = useMemo( () => (inputAmount ? new BigNumber(inputAmount).times(tokenPrice).toFixed(2) : '0'), @@ -128,7 +138,7 @@ export function SavingsForm({ chainId, protocol, tab, onClose }: SavingsFormProp maxAmount={balanceAsBN.minus(estimatedGas).toString()} balance={balanceAsBN.toString()} label={t('plugin_savings_amount')} - token={nativeTokenDetailed} + token={protocol.bareToken} onAmountChange={setInputAmount} InputProps={{ classes: { root: classes.inputTextField } }} MaxChipProps={{ classes: { root: classes.maxChip } }} diff --git a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsTable.tsx b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsTable.tsx index 1a628a310608..27c24065a9dd 100644 --- a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsTable.tsx +++ b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsTable.tsx @@ -96,8 +96,8 @@ export function SavingsTable({ chainId, tab, protocols, setTab, setSelectedProto - {protocols.map((protocol) => ( - + {protocols.map((protocol, index) => ( +
Date: Thu, 17 Mar 2022 16:56:33 +0800 Subject: [PATCH 30/38] fix: add approval boundary --- .../Savings/SNSAdaptor/SavingsForm.tsx | 115 +++++++++++------- packages/web3-constants/evm/aave.json | 2 +- 2 files changed, 71 insertions(+), 46 deletions(-) diff --git a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsForm.tsx b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsForm.tsx index 9ccc306c1a78..21edb5a9a1bd 100644 --- a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsForm.tsx +++ b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsForm.tsx @@ -13,6 +13,9 @@ import { formatBalance, isSameAddress, useTokenConstants, + createERC20Token, + getAaveConstants, + ZERO_ADDRESS, } from '@masknet/web3-shared-evm' import { TokenAmountPanel, @@ -30,6 +33,7 @@ import { EthereumChainBoundary } from '../../../web3/UI/EthereumChainBoundary' import { ActionButtonPromise } from '../../../extension/options-page/DashboardComponents/ActionButton' import { PluginTraderMessages } from '../../Trader/messages' import type { Coin } from '../../Trader/types' +import { EthereumERC20TokenApprovedBoundary } from '../../../web3/UI/EthereumERC20TokenApprovedBoundary' export interface SavingsFormProps { chainId: number @@ -45,7 +49,6 @@ export function SavingsForm({ chainId, protocol, tab, onClose }: SavingsFormProp const web3 = useWeb3({ chainId }) const account = useAccount() const { NATIVE_TOKEN_ADDRESS } = useTokenConstants() - const [inputAmount, setInputAmount] = useState('') const [estimatedGas, setEstimatedGas] = useState(new BigNumber('0')) @@ -126,6 +129,21 @@ export function SavingsForm({ chainId, protocol, tab, onClose }: SavingsFormProp ) // #endregion + const { approveToken, approveAmount, approveAddress } = useMemo(() => { + const token = protocol.bareToken + const aavePoolAddress = + getAaveConstants(chainId).AAVE_LENDING_POOL_ADDRESSES_PROVIDER_CONTRACT_ADDRESS || ZERO_ADDRESS + + return { + approveToken: + token.type === EthereumTokenType.ERC20 + ? createERC20Token(chainId, token.address, token.decimals, token.name, token.symbol) + : undefined, + approveAmount: new BigNumber(inputAmount).shiftedBy(token.decimals), + approveAddress: aavePoolAddress, + } + }, [protocol.bareToken, inputAmount, chainId]) + const needsSwap = protocol.type === ProtocolType.Lido && tab === TabType.Withdraw return ( @@ -186,51 +204,58 @@ export function SavingsForm({ chainId, protocol, tab, onClose }: SavingsFormProp - { - switch (tab) { - case TabType.Deposit: - if (!(await protocol.deposit(account, chainId, web3, tokenAmount))) { - throw new Error('Failed to deposit token.') - } - return - case TabType.Withdraw: - switch (protocol.type) { - case ProtocolType.Lido: - onClose?.() - onConvertClick() - return - default: - if (!(await protocol.withdraw(account, chainId, web3, tokenAmount))) { - throw new Error('Failed to withdraw token.') - } - return - } - default: - unreachable(tab) + + + failed={t('failed')} + failedOnClick="use executor" + complete={t('done')} + disabled={validationMessage !== '' && !needsSwap} + noUpdateEffect + executor={async () => { + switch (tab) { + case TabType.Deposit: + if (!(await protocol.deposit(account, chainId, web3, tokenAmount))) { + throw new Error('Failed to deposit token.') + } + return + case TabType.Withdraw: + switch (protocol.type) { + case ProtocolType.Lido: + onClose?.() + onConvertClick() + return + default: + if (!(await protocol.withdraw(account, chainId, web3, tokenAmount))) { + throw new Error('Failed to withdraw token.') + } + return + } + default: + unreachable(tab) + } + }} + /> +
diff --git a/packages/web3-constants/evm/aave.json b/packages/web3-constants/evm/aave.json index 74dafe5d476a..79b592a6f189 100644 --- a/packages/web3-constants/evm/aave.json +++ b/packages/web3-constants/evm/aave.json @@ -23,7 +23,7 @@ "Mainnet": "0xb53c1a33016b2dc2ff3653530bff1848a515c8c5", "Ropsten": "", "Rinkeby": "", - "Kovan": "​0x88757f2f99175387ab4c6a4b3067c77a695b0349", + "Kovan": "0x88757f2f99175387ab4c6a4b3067c77a695b0349", "Gorli": "", "BSC": "", "BSCT": "", From 31eed534c49de4a1dd71dda3fef368dde3516d99 Mon Sep 17 00:00:00 2001 From: nuanyang233 <528944303@qq.com> Date: Fri, 18 Mar 2022 00:23:25 +0800 Subject: [PATCH 31/38] fix: bugfix for pool address --- .../Savings/SNSAdaptor/SavingsForm.tsx | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsForm.tsx b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsForm.tsx index 21edb5a9a1bd..2b0930a70cc9 100644 --- a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsForm.tsx +++ b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsForm.tsx @@ -16,6 +16,7 @@ import { createERC20Token, getAaveConstants, ZERO_ADDRESS, + createContract, } from '@masknet/web3-shared-evm' import { TokenAmountPanel, @@ -34,6 +35,9 @@ import { ActionButtonPromise } from '../../../extension/options-page/DashboardCo import { PluginTraderMessages } from '../../Trader/messages' import type { Coin } from '../../Trader/types' import { EthereumERC20TokenApprovedBoundary } from '../../../web3/UI/EthereumERC20TokenApprovedBoundary' +import type { AaveLendingPoolAddressProvider } from '@masknet/web3-contracts/types/AaveLendingPoolAddressProvider' +import AaveLendingPoolAddressProviderABI from '@masknet/web3-contracts/abis/AaveLendingPoolAddressProvider.json' +import type { AbiItem } from 'web3-utils' export interface SavingsFormProps { chainId: number @@ -129,18 +133,26 @@ export function SavingsForm({ chainId, protocol, tab, onClose }: SavingsFormProp ) // #endregion - const { approveToken, approveAmount, approveAddress } = useMemo(() => { + const { value: approvalData } = useAsync(async () => { const token = protocol.bareToken const aavePoolAddress = getAaveConstants(chainId).AAVE_LENDING_POOL_ADDRESSES_PROVIDER_CONTRACT_ADDRESS || ZERO_ADDRESS + const lPoolAddressProviderContract = createContract( + web3, + aavePoolAddress, + AaveLendingPoolAddressProviderABI as AbiItem[], + ) + + const poolAddress = await lPoolAddressProviderContract?.methods.getLendingPool().call() + return { approveToken: token.type === EthereumTokenType.ERC20 ? createERC20Token(chainId, token.address, token.decimals, token.name, token.symbol) : undefined, approveAmount: new BigNumber(inputAmount).shiftedBy(token.decimals), - approveAddress: aavePoolAddress, + approveAddress: poolAddress, } }, [protocol.bareToken, inputAmount, chainId]) @@ -205,9 +217,9 @@ export function SavingsForm({ chainId, protocol, tab, onClose }: SavingsFormProp ActionButtonProps={{ color: 'primary', classes: { root: classes.button } }} classes={{ connectWallet: classes.connectWallet, button: classes.button }}> + amount={approvalData?.approveAmount.toFixed() ?? ''} + token={approvalData?.approveToken} + spender={approvalData?.approveAddress}> Date: Fri, 18 Mar 2022 11:43:53 +0100 Subject: [PATCH 32/38] Bug Fix: updatebalance --- .../plugins/Savings/protocols/AAVEProtocol.ts | 89 +++++++------------ 1 file changed, 34 insertions(+), 55 deletions(-) diff --git a/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts b/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts index 64b9acbb1b4a..58094bad74bb 100644 --- a/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts +++ b/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts @@ -14,6 +14,8 @@ import type { AaveLendingPoolAddressProvider } from '@masknet/web3-contracts/typ import AaveLendingPoolAddressProviderABI from '@masknet/web3-contracts/abis/AaveLendingPoolAddressProvider.json' import AaveLendingPoolABI from '@masknet/web3-contracts/abis/AaveLendingPool.json' import { ProtocolType, SavingsProtocol } from '../types' +import type { ERC20 } from '@masknet/web3-contracts/types/ERC20' +import ERC20ABI from '@masknet/web3-contracts/abis/ERC20.json' export class AAVEProtocol implements SavingsProtocol { static DEFAULT_APR = '0.17' @@ -96,80 +98,56 @@ export class AAVEProtocol implements SavingsProtocol { } } + public async updateBalance(chainId: ChainId, web3: Web3, account: string) { try { + const subgraphUrl = getAaveConstants(chainId).AAVE_SUBGRAPHS || '' - const reserveBody = JSON.stringify({ + + if (!subgraphUrl) { + this._apr = AAVEProtocol.DEFAULT_APR + return + } + + const body = JSON.stringify({ query: `{ reserves (where: { underlyingAsset: "${this.bareToken.address}" pool : "0xb53c1a33016b2dc2ff3653530bff1848a515c8c5" }) { id - name - underlyingAsset - } - }`, - }) - - const reserveResponse = await fetch(subgraphUrl, { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: reserveBody, - }) - const fullResponse: { - data: { - reserves: { - id: string - name: string - decimals: number - underlyingAsset: string - }[] - } - } = await reserveResponse.json() - const reserveId = fullResponse.data.reserves[0].id - - // Get User Reserve - const userReserveBody = JSON.stringify({ - query: `{ - userReserves(where: { - user: "${account}", - reserve: "${reserveId}" - - }) { + aToken { id - scaledATokenBalance - currentATokenBalance - reserve{ - id - symbol - underlyingAsset - decimals - } - user { - id - } } - }`, + } + }`, }) - - const userReserveResponse = await fetch(subgraphUrl, { + const response = await fetch(subgraphUrl, { method: 'POST', headers: { 'Content-Type': 'application/json' }, - body: userReserveBody, + body: body, }) - - const userResponse: { + + const fullResponse: { data: { - userReserves: { - scaledATokenBalance: string - currentATokenBalance: string + reserves: { + aToken: { + id: string + } }[] } - } = await userReserveResponse.json() - - this._balance = new BigNumber(userResponse.data.userReserves[0].currentATokenBalance || '0') + } = await response.json() + + const aTokenId = fullResponse.data.reserves[0].aToken.id; + const contract = createContract( + web3, + aTokenId || ZERO_ADDRESS, + ERC20ABI as AbiItem[], + ) + this._balance = new BigNumber((await contract?.methods.balanceOf(account).call()) ?? '0') + } catch (error) { + console.error('AAVE BALANCE ERROR: ',error) this._balance = ZERO } } @@ -183,6 +161,7 @@ export class AAVEProtocol implements SavingsProtocol { return new BigNumber(gasEstimate || 0) } catch (error) { + console.error('AAVE DEPOSITESTIMATE ERROR: ',error) return ZERO } } From a3a0b540558553cacd0c3316226effa1a06eecd7 Mon Sep 17 00:00:00 2001 From: nuanyang233 <528944303@qq.com> Date: Sat, 19 Mar 2022 00:35:12 +0800 Subject: [PATCH 33/38] fix: update balance after deposit and withdraw --- .../Savings/SNSAdaptor/SavingsForm.tsx | 54 ++++++++++--------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsForm.tsx b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsForm.tsx index 2b0930a70cc9..f3259a40f201 100644 --- a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsForm.tsx +++ b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsForm.tsx @@ -1,7 +1,7 @@ import BigNumber from 'bignumber.js' import { Typography } from '@mui/material' import { useState, useMemo, useCallback } from 'react' -import { useAsync } from 'react-use' +import { useAsync, useAsyncFn } from 'react-use' import { unreachable } from '@dimensiondev/kit' import { isLessThan, rightShift } from '@masknet/web3-shared-base' import { @@ -156,6 +156,34 @@ export function SavingsForm({ chainId, protocol, tab, onClose }: SavingsFormProp } }, [protocol.bareToken, inputAmount, chainId]) + const [, executor] = useAsyncFn(async () => { + switch (tab) { + case TabType.Deposit: + if (!(await protocol.deposit(account, chainId, web3, tokenAmount))) { + throw new Error('Failed to deposit token.') + } else { + await protocol.updateBalance(chainId, web3, account) + } + return + case TabType.Withdraw: + switch (protocol.type) { + case ProtocolType.Lido: + onClose?.() + onConvertClick() + return + default: + if (!(await protocol.withdraw(account, chainId, web3, tokenAmount))) { + throw new Error('Failed to withdraw token.') + } else { + await protocol.updateBalance(chainId, web3, account) + } + return + } + default: + unreachable(tab) + } + }, [tab, protocol, account, chainId, web3, tokenAmount]) + const needsSwap = protocol.type === ProtocolType.Lido && tab === TabType.Withdraw return ( @@ -243,29 +271,7 @@ export function SavingsForm({ chainId, protocol, tab, onClose }: SavingsFormProp complete={t('done')} disabled={validationMessage !== '' && !needsSwap} noUpdateEffect - executor={async () => { - switch (tab) { - case TabType.Deposit: - if (!(await protocol.deposit(account, chainId, web3, tokenAmount))) { - throw new Error('Failed to deposit token.') - } - return - case TabType.Withdraw: - switch (protocol.type) { - case ProtocolType.Lido: - onClose?.() - onConvertClick() - return - default: - if (!(await protocol.withdraw(account, chainId, web3, tokenAmount))) { - throw new Error('Failed to withdraw token.') - } - return - } - default: - unreachable(tab) - } - }} + executor={executor} /> From c1dc9907cd0495ae5edf9788be9dc26612e609c4 Mon Sep 17 00:00:00 2001 From: nuanyang233 <528944303@qq.com> Date: Sat, 19 Mar 2022 00:43:58 +0800 Subject: [PATCH 34/38] chore: word spell --- .../plugins/Savings/protocols/AAVEProtocol.ts | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts b/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts index 58094bad74bb..1316209b7536 100644 --- a/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts +++ b/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts @@ -98,10 +98,8 @@ export class AAVEProtocol implements SavingsProtocol { } } - public async updateBalance(chainId: ChainId, web3: Web3, account: string) { try { - const subgraphUrl = getAaveConstants(chainId).AAVE_SUBGRAPHS || '' if (!subgraphUrl) { @@ -127,27 +125,22 @@ export class AAVEProtocol implements SavingsProtocol { headers: { 'Content-Type': 'application/json' }, body: body, }) - + const fullResponse: { data: { - reserves: { + reserves: { aToken: { id: string } }[] } } = await response.json() - - const aTokenId = fullResponse.data.reserves[0].aToken.id; - const contract = createContract( - web3, - aTokenId || ZERO_ADDRESS, - ERC20ABI as AbiItem[], - ) + + const aTokenId = fullResponse.data.reserves[0].aToken.id + const contract = createContract(web3, aTokenId || ZERO_ADDRESS, ERC20ABI as AbiItem[]) this._balance = new BigNumber((await contract?.methods.balanceOf(account).call()) ?? '0') - } catch (error) { - console.error('AAVE BALANCE ERROR: ',error) + console.error('AAVE BALANCE ERROR: ', error) this._balance = ZERO } } @@ -161,7 +154,7 @@ export class AAVEProtocol implements SavingsProtocol { return new BigNumber(gasEstimate || 0) } catch (error) { - console.error('AAVE DEPOSITESTIMATE ERROR: ',error) + console.error('AAVE deposit estimate ERROR: ', error) return ZERO } } From a492d7f95b4022dfdfebd1995d8926c75d525106 Mon Sep 17 00:00:00 2001 From: nuanyang233 Date: Tue, 22 Mar 2022 14:56:52 +0800 Subject: [PATCH 35/38] fix: bugfix for token icon --- packages/mask/src/plugins/Savings/SNSAdaptor/SavingsTable.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsTable.tsx b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsTable.tsx index 27c24065a9dd..6b18d2efd831 100644 --- a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsTable.tsx +++ b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsTable.tsx @@ -104,6 +104,7 @@ export function SavingsTable({ chainId, tab, protocols, setTab, setSelectedProto name={protocol.bareToken.name} address={protocol.bareToken.address} classes={{ icon: classes.logo }} + chainId={chainId} />
From eddd73a15e7725dae196b75c0ed0b474b5f03c8e Mon Sep 17 00:00:00 2001 From: nuanyang233 Date: Tue, 22 Mar 2022 17:44:34 +0800 Subject: [PATCH 36/38] fix: bugfix --- packages/mask/shared-ui/locales/en-US.json | 2 +- .../Savings/SNSAdaptor/SavingsDialog.tsx | 2 +- .../Savings/SNSAdaptor/SavingsForm.tsx | 124 +++++++++------ .../Savings/SNSAdaptor/SavingsTable.tsx | 145 +++++++++++------- 4 files changed, 168 insertions(+), 105 deletions(-) diff --git a/packages/mask/shared-ui/locales/en-US.json b/packages/mask/shared-ui/locales/en-US.json index c629e6b73793..8c60bd73027d 100644 --- a/packages/mask/shared-ui/locales/en-US.json +++ b/packages/mask/shared-ui/locales/en-US.json @@ -424,7 +424,7 @@ "plugin_trader_data_source": "Data Source", "plugin_trader_price_updated": "Price Updated", "plugin_savings": "Savings", - "plugin_savings_type": "Type", + "plugin_savings_asset": "Asset", "plugin_no_protocol_available": "No savings protocols available on this network", "plugin_savings_apr": "APR", "plugin_savings_wallet": "Wallet", diff --git a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsDialog.tsx b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsDialog.tsx index 278dfe63a255..2fa4e43ecc30 100644 --- a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsDialog.tsx +++ b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsDialog.tsx @@ -92,7 +92,7 @@ export function SavingsDialog({ open, onClose }: SavingsDialogProps) { !x.balance.isZero())} setTab={setTab} setSelectedProtocol={setSelectedProtocol} /> diff --git a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsForm.tsx b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsForm.tsx index f67da70c45e4..d700ba4748b7 100644 --- a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsForm.tsx +++ b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsForm.tsx @@ -181,6 +181,83 @@ export function SavingsForm({ chainId, protocol, tab, onClose }: SavingsFormProp const needsSwap = protocol.type === ProtocolType.Lido && tab === TabType.Withdraw + const buttonDom = useMemo(() => { + if (tab === TabType.Deposit) + return ( + + + + + + + + ) + + return ( + + + + + + ) + }, [executor, validationMessage, needsSwap, protocol, tab, approvalData, chainId]) + return (
{needsSwap ? null : ( @@ -225,52 +302,7 @@ export function SavingsForm({ chainId, protocol, tab, onClose }: SavingsFormProp {protocol.apr}%
- - - - - - - - + {buttonDom}
) } diff --git a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsTable.tsx b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsTable.tsx index 6b18d2efd831..5e43f5d1c421 100644 --- a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsTable.tsx +++ b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsTable.tsx @@ -1,12 +1,12 @@ import { useAsync } from 'react-use' import { makeStyles } from '@masknet/theme' -import { Box, Grid, Button, Typography } from '@mui/material' +import { Box, Button, Grid, Typography, CircularProgress } from '@mui/material' import { FormattedBalance, TokenIcon } from '@masknet/shared' import { isZero, rightShift } from '@masknet/web3-shared-base' -import { ChainId, useWeb3, useAccount, formatBalance } from '@masknet/web3-shared-evm' +import { ChainId, formatBalance, isSameAddress, useAccount, useAssets, useWeb3 } from '@masknet/web3-shared-evm' import { ProviderIconURLs } from './IconURL' import { useI18N } from '../../../utils' -import { TabType, SavingsProtocol } from '../types' +import { SavingsProtocol, TabType } from '../types' const useStyles = makeStyles()((theme, props) => ({ containerWrap: { @@ -54,6 +54,13 @@ const useStyles = makeStyles()((theme, props) => ({ right: '-5px', }, protocolLabel: {}, + loading: { + display: 'flex', + justifyContent: 'center', + alignItems: 'center', + minHeight: 300, + width: '100%', + }, })) export interface SavingsTableProps { @@ -69,26 +76,36 @@ export function SavingsTable({ chainId, tab, protocols, setTab, setSelectedProto const { classes } = useStyles() const web3 = useWeb3({ chainId }) + const account = useAccount() + const { value: assets, loading: getAssetsLoading } = useAssets( + protocols.map((x) => x.bareToken), + chainId, + ) + // Only fetch protocol APR and Balance on chainId change - useAsync(async () => { - for (const protocol of protocols) { - await protocol.updateApr(chainId, web3) - await protocol.updateBalance(chainId, web3, account) - } + const { loading } = useAsync(async () => { + await Promise.all( + protocols.map(async (protocol) => { + protocol.updateApr(chainId, web3) + protocol.updateBalance(chainId, web3, account) + }), + ) }, [chainId, web3, account, protocols]) return ( - {t('plugin_savings_type')} + {t('plugin_savings_asset')} - - {t('plugin_savings_apr')} - - + {tab === TabType.Deposit ? ( + + {t('plugin_savings_apr')} + + ) : null} + {t('plugin_savings_wallet')} @@ -96,52 +113,66 @@ export function SavingsTable({ chainId, tab, protocols, setTab, setSelectedProto - {protocols.map((protocol, index) => ( - - -
- - -
-
- - {protocol.bareToken.name} + {loading || getAssetsLoading ? ( +
+ +
+ ) : ( + protocols.map((protocol, index) => ( + + +
+ + +
+
+ + {protocol.bareToken.name} + +
+
+ {tab === TabType.Deposit ? ( + + {protocol.apr}% + + ) : null} + + + + isSameAddress(x.token.address, protocol.bareToken.address), + )?.balance + : protocol.balance + } + decimals={protocol.bareToken.decimals} + significant={6} + minimumBalance={rightShift(10, protocol.bareToken.decimals - 6)} + formatter={formatBalance} + /> -
-
- - {protocol.apr}% + + + +
- - - - - - - - -
- ))} + )) + )}
) } From a8a0c173334c22c7c15451a2960c516f8b220a3b Mon Sep 17 00:00:00 2001 From: "@layinka" Date: Sat, 26 Mar 2022 09:25:02 +0100 Subject: [PATCH 37/38] get asset list from aave sdk --- .../Savings/SNSAdaptor/SavingsDialog.tsx | 60 ++++++++++++++++++- .../plugins/Savings/protocols/AAVEProtocol.ts | 5 ++ packages/web3-constants/evm/aave.json | 20 +++++++ 3 files changed, 82 insertions(+), 3 deletions(-) diff --git a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsDialog.tsx b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsDialog.tsx index 2fa4e43ecc30..cb1f9c6218f4 100644 --- a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsDialog.tsx +++ b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsDialog.tsx @@ -3,7 +3,7 @@ import { useAsync } from 'react-use' import { Typography, DialogContent } from '@mui/material' import { isDashboardPage } from '@masknet/shared-base' import { FolderTabPanel, FolderTabs } from '@masknet/theme' -import { ChainId, getChainIdFromNetworkType, useChainId } from '@masknet/web3-shared-evm' +import { createContract, ChainId, FungibleTokenDetailed, getChainIdFromNetworkType, useChainId, useWeb3, EthereumTokenType, useFungibleTokensDetailed, getAaveConstants, ZERO_ADDRESS } from '@masknet/web3-shared-evm' import { useI18N } from '../../../utils' import { EMPTY_LIST } from '../../../../utils-pure' import { InjectedDialog } from '../../../components/shared/InjectedDialog' @@ -16,7 +16,24 @@ import { SavingsProtocol, TabType } from '../types' import { useStyles } from './SavingsDialogStyles' import { SavingsTable } from './SavingsTable' import { SavingsForm } from './SavingsForm' -import { SavingsProtocols } from '../protocols' +import type { AaveProtocolDataProvider } from '@masknet/web3-contracts/types/AaveProtocolDataProvider' +import AaveProtocolDataProviderABI from '@masknet/web3-contracts/abis/AaveProtocolDataProvider.json' +import { LidoProtocol } from '../protocols/LDOProtocol' +import { AAVEProtocol } from '../protocols/AAVEProtocol' +import { LDO_PAIRS } from '../constants' +import type { AbiItem } from 'web3-utils' + +function splitToPair (a: FungibleTokenDetailed[] | undefined ){ + if(!a ){ + return [] + } + return a.reduce(function(result: any, value, index, array) { + if (index % 2 === 0){ + result.push(array.slice(index, index + 2)); + } + return result; + }, []); +} export interface SavingsDialogProps { open: boolean @@ -30,6 +47,8 @@ export function SavingsDialog({ open, onClose }: SavingsDialogProps) { const currentChainId = useChainId() const [chainId, setChainId] = useState(currentChainId) + + const web3 = useWeb3({ chainId }) const [tab, setTab] = useState(TabType.Deposit) const [selectedProtocol, setSelectedProtocol] = useState(null) @@ -38,7 +57,42 @@ export function SavingsDialog({ open, onClose }: SavingsDialogProps) { return networks.map((network) => getChainIdFromNetworkType(network)) }, []) - const protocols = useMemo(() => SavingsProtocols.filter((x) => x.bareToken.chainId === chainId), [chainId]) + + const [aaveTokens, setAaveTokens] = useState([]); + + const { loading } = useAsync(async () => { + if( chainId !== ChainId.Mainnet ){ + setAaveTokens([]); + return; + } + // @ts-ignore + const address = getAaveConstants(chainId).AAVE_PROTOCOL_DATA_PROVIDER_CONTRACT_ADDRESS || ZERO_ADDRESS + const protocolDataContract = createContract( + web3, + address, + AaveProtocolDataProviderABI as AbiItem[] + ) + + const tokens = await protocolDataContract?.methods.getAllReservesTokens().call() + + const aTokens = await protocolDataContract?.methods.getAllATokens().call() + + const fullTokens = tokens?.map((token)=>{ + return [ + token[1], + aTokens?.filter( f=> f[0].toUpperCase() === `a${token[0]}`.toUpperCase())[0][1] + ] + }) + // @ts-ignore + setAaveTokens(fullTokens) + }, [web3, chainId]) + + const {loading: loadingTokenDetails, value : detailedAaveTokens} = useFungibleTokensDetailed(aaveTokens.flat().map(m=>{ return {address: m, type: EthereumTokenType.ERC20 } } ), chainId) + + const protocols = useMemo(() => [ + ...LDO_PAIRS.filter((x) => x[0].chainId === chainId).map((pair) => new LidoProtocol(pair)), + ...splitToPair(detailedAaveTokens).map((pair: any) => new AAVEProtocol(pair)) + ], [chainId, detailedAaveTokens]) return ( diff --git a/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts b/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts index 1316209b7536..b88b6807333d 100644 --- a/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts +++ b/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts @@ -11,7 +11,10 @@ import { } from '@masknet/web3-shared-evm' import type { AaveLendingPool } from '@masknet/web3-contracts/types/AaveLendingPool' import type { AaveLendingPoolAddressProvider } from '@masknet/web3-contracts/types/AaveLendingPoolAddressProvider' + + import AaveLendingPoolAddressProviderABI from '@masknet/web3-contracts/abis/AaveLendingPoolAddressProvider.json' +import AaveProtocolDataProviderABI from '@masknet/web3-contracts/abis/AaveProtocolDataProvider.json' import AaveLendingPoolABI from '@masknet/web3-contracts/abis/AaveLendingPool.json' import { ProtocolType, SavingsProtocol } from '../types' import type { ERC20 } from '@masknet/web3-contracts/types/ERC20' @@ -94,6 +97,7 @@ export class AAVEProtocol implements SavingsProtocol { // APY and APR are returned here as decimals, multiply by 100 to get the percents this._apr = new BigNumber(liquidityRate).times(100).div(RAY).toFixed(2) } catch (error) { + console.error('AAVE: Apr Error:', error) this._apr = AAVEProtocol.DEFAULT_APR } } @@ -159,6 +163,7 @@ export class AAVEProtocol implements SavingsProtocol { } } + private async createDepositTokenOperation(account: string, chainId: ChainId, web3: Web3, value: BigNumber.Value) { const aaveLPoolAddress = getAaveConstants(chainId).AAVE_LENDING_POOL_ADDRESSES_PROVIDER_CONTRACT_ADDRESS || ZERO_ADDRESS diff --git a/packages/web3-constants/evm/aave.json b/packages/web3-constants/evm/aave.json index 79b592a6f189..1967d793a144 100644 --- a/packages/web3-constants/evm/aave.json +++ b/packages/web3-constants/evm/aave.json @@ -38,5 +38,25 @@ "Fantom": "", "Aurora": "", "Aurora_Testnet": "" + }, + "AAVE_PROTOCOL_DATA_PROVIDER_CONTRACT_ADDRESS": { + "Mainnet": "0x057835Ad21a177dbdd3090bB1CAE03EaCF78Fc6d", + "Ropsten": "", + "Rinkeby": "", + "Kovan": "", + "Gorli": "", + "BSC": "", + "BSCT": "", + "Matic": "", + "Mumbai": "", + "Arbitrum": "", + "Arbitrum_Rinkeby": "", + "xDai": "", + "Avalanche": "", + "Avalanche_Fuji": "", + "Celo": "", + "Fantom": "", + "Aurora": "", + "Aurora_Testnet": "" } } From 47cd02227527c49aeb341736e48b439c20620fb6 Mon Sep 17 00:00:00 2001 From: nuanyang233 Date: Tue, 29 Mar 2022 20:03:54 +0800 Subject: [PATCH 38/38] fix: bugfix --- .../mask/src/plugins/Savings/SNSAdaptor/SavingsDialog.tsx | 7 ++++++- .../mask/src/plugins/Savings/SNSAdaptor/SavingsTable.tsx | 2 +- packages/web3-shared/evm/hooks/useERC20TokenDetailed.ts | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsDialog.tsx b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsDialog.tsx index 0d8e6a4804df..9632a626f126 100644 --- a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsDialog.tsx +++ b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsDialog.tsx @@ -1,5 +1,5 @@ import { useMemo, useState } from 'react' -import { useAsync } from 'react-use' +import { useAsync, useUpdateEffect } from 'react-use' import { Typography, DialogContent } from '@mui/material' import { isDashboardPage, EMPTY_LIST } from '@masknet/shared-base' import { FolderTabPanel, FolderTabs } from '@masknet/theme' @@ -96,6 +96,7 @@ export function SavingsDialog({ open, onClose }: SavingsDialogProps) { }) ?? [], chainId, ) + const protocols = useMemo( () => [ ...LDO_PAIRS.filter((x) => x[0].chainId === chainId).map((pair) => new LidoProtocol(pair)), @@ -104,6 +105,10 @@ export function SavingsDialog({ open, onClose }: SavingsDialogProps) { [chainId, detailedAaveTokens], ) + useUpdateEffect(() => { + setChainId(currentChainId) + }, [currentChainId]) + return ( diff --git a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsTable.tsx b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsTable.tsx index a4c4400f2274..a47db0bcf228 100644 --- a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsTable.tsx +++ b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsTable.tsx @@ -14,7 +14,7 @@ const useStyles = makeStyles()((theme, props) => ({ }, tableContainer: { maxHeight: 350, - overflow: 'scroll', + overflowY: 'scroll', }, tableHeader: { display: 'flex', diff --git a/packages/web3-shared/evm/hooks/useERC20TokenDetailed.ts b/packages/web3-shared/evm/hooks/useERC20TokenDetailed.ts index 85bea6c89210..1a52e4da03b6 100644 --- a/packages/web3-shared/evm/hooks/useERC20TokenDetailed.ts +++ b/packages/web3-shared/evm/hooks/useERC20TokenDetailed.ts @@ -27,8 +27,8 @@ export function useFungibleTokensDetailed(listOfToken: Pick listOfToken.map((t) => t.address), [JSON.stringify(listOfToken)]) - const erc20TokenContracts = useERC20TokenContracts(listOfAddress) - const erc20TokenBytes32Contracts = useERC20TokenBytes32Contracts(listOfAddress) + const erc20TokenContracts = useERC20TokenContracts(listOfAddress, chainId) + const erc20TokenBytes32Contracts = useERC20TokenBytes32Contracts(listOfAddress, chainId) return useAsyncRetry( async () =>