From 2e2c82927b5aa14c47088604c629c0c8ca46db82 Mon Sep 17 00:00:00 2001 From: Bob Date: Mon, 22 Jul 2024 16:16:15 +0800 Subject: [PATCH] feat: add aave-like supply and borrow enable status to reserve tokens (#69) feat: add aave-like supply and borrow enable status to reserve tokens --------- Co-authored-by: Bob Lu --- .changeset/gorgeous-items-complain.md | 5 + package.json | 2 +- src/logics/aave-v2/configs.ts | 2 + src/logics/aave-v2/logic.borrow.ts | 56 +- src/logics/aave-v2/logic.deposit.ts | 69 +- src/logics/aave-v2/logic.repay.ts | 70 +- src/logics/aave-v2/logic.withdraw.ts | 62 +- .../aave-v2/scripts/refresh-tokens-data.ts | 26 - src/logics/aave-v2/service.test.ts | 30 +- src/logics/aave-v2/service.ts | 198 +- src/logics/aave-v2/types.ts | 9 +- src/logics/aave-v3/configs.ts | 2 + src/logics/aave-v3/logic.borrow.ts | 56 +- src/logics/aave-v3/logic.repay.ts | 70 +- src/logics/aave-v3/logic.supply.ts | 65 +- src/logics/aave-v3/logic.withdraw.ts | 62 +- .../aave-v3/scripts/refresh-tokens-data.ts | 26 - src/logics/aave-v3/service.test.ts | 30 +- src/logics/aave-v3/service.ts | 207 +- src/logics/aave-v3/types.ts | 9 +- .../openocean-v2/logic.swap-token.test.ts | 4 +- src/logics/radiant-v2/configs.ts | 2 + src/logics/radiant-v2/logic.borrow.ts | 56 +- src/logics/radiant-v2/logic.deposit.ts | 69 +- src/logics/radiant-v2/logic.repay.ts | 70 +- src/logics/radiant-v2/logic.withdraw.ts | 62 +- .../radiant-v2/scripts/refresh-tokens-data.ts | 26 - src/logics/radiant-v2/service.test.ts | 30 +- src/logics/radiant-v2/service.ts | 203 +- src/logics/radiant-v2/types.ts | 9 +- src/logics/spark/configs.ts | 2 + src/logics/spark/logic.borrow.ts | 56 +- src/logics/spark/logic.repay.ts | 70 +- src/logics/spark/logic.supply.ts | 65 +- src/logics/spark/logic.withdraw.ts | 62 +- .../spark/scripts/refresh-tokens-data.ts | 26 - src/logics/spark/service.test.ts | 30 +- src/logics/spark/service.ts | 202 +- src/logics/spark/types.ts | 9 +- src/logics/stargate/configs.ts | 2 +- src/modules/aavev2/abis/AToken.json | 762 +++++++ .../aavev2/abis/AaveV2FlashLoanCallback.json | 130 ++ src/modules/aavev2/abis/DebtTokenBase.json | 44 + src/modules/aavev2/abis/LendingPool.json | 1079 +++++++++ .../abis/LendingPoolAddressesProvider.json | 476 ++++ .../aavev2/abis/ProtocolDataProvider.json | 297 +++ src/modules/aavev2/contracts/AToken.ts | 823 +++++++ .../contracts/AaveV2FlashLoanCallback.ts | 167 ++ src/modules/aavev2/contracts/DebtTokenBase.ts | 104 + src/modules/aavev2/contracts/LendingPool.ts | 1224 +++++++++++ .../contracts/LendingPoolAddressesProvider.ts | 572 +++++ .../aavev2/contracts/ProtocolDataProvider.ts | 331 +++ src/modules/aavev2/contracts/common.ts | 30 + .../contracts/factories/AToken__factory.ts | 780 +++++++ .../AaveV2FlashLoanCallback__factory.ts | 148 ++ .../factories/DebtTokenBase__factory.ts | 62 + .../LendingPoolAddressesProvider__factory.ts | 497 +++++ .../factories/LendingPool__factory.ts | 1097 ++++++++++ .../ProtocolDataProvider__factory.ts | 315 +++ .../aavev2/contracts/factories/index.ts | 9 + src/modules/aavev2/contracts/index.ts | 16 + src/modules/aavev2/index.ts | 6 + src/modules/aavev2/logic.borrow.ts | 53 + src/modules/aavev2/logic.deposit.ts | 52 + src/modules/aavev2/logic.repay.ts | 69 + src/modules/aavev2/logic.withdraw.ts | 49 + src/modules/aavev2/types.ts | 17 + src/modules/aavev2/utils.ts | 28 + src/modules/aavev3/abis/AToken.json | 912 ++++++++ .../aavev3/abis/AaveV3FlashLoanCallback.json | 130 ++ src/modules/aavev3/abis/DebtTokenBase.json | 176 ++ src/modules/aavev3/abis/Pool.json | 1721 +++++++++++++++ .../aavev3/abis/PoolAddressesProvider.json | 498 +++++ src/modules/aavev3/abis/PoolDataProvider.json | 523 +++++ src/modules/aavev3/contracts/AToken.ts | 1025 +++++++++ .../contracts/AaveV3FlashLoanCallback.ts | 167 ++ src/modules/aavev3/contracts/DebtTokenBase.ts | 256 +++ src/modules/aavev3/contracts/Pool.ts | 1924 +++++++++++++++++ .../aavev3/contracts/PoolAddressesProvider.ts | 579 +++++ .../aavev3/contracts/PoolDataProvider.ts | 556 +++++ src/modules/aavev3/contracts/common.ts | 30 + .../contracts/factories/AToken__factory.ts | 930 ++++++++ .../AaveV3FlashLoanCallback__factory.ts | 148 ++ .../factories/DebtTokenBase__factory.ts | 194 ++ .../PoolAddressesProvider__factory.ts | 516 +++++ .../factories/PoolDataProvider__factory.ts | 541 +++++ .../contracts/factories/Pool__factory.ts | 1739 +++++++++++++++ .../aavev3/contracts/factories/index.ts | 9 + src/modules/aavev3/contracts/index.ts | 16 + src/modules/aavev3/index.ts | 5 + src/modules/aavev3/logic.borrow.ts | 53 + src/modules/aavev3/logic.repay.ts | 69 + src/modules/aavev3/logic.supply.ts | 66 + src/modules/aavev3/logic.withdraw.ts | 63 + src/modules/aavev3/types.ts | 17 + test/logics/openocean-v2/swap-token.test.ts | 6 +- yarn.lock | 15 + 97 files changed, 22796 insertions(+), 1436 deletions(-) create mode 100644 .changeset/gorgeous-items-complain.md delete mode 100644 src/logics/aave-v2/scripts/refresh-tokens-data.ts delete mode 100644 src/logics/aave-v3/scripts/refresh-tokens-data.ts delete mode 100644 src/logics/radiant-v2/scripts/refresh-tokens-data.ts delete mode 100644 src/logics/spark/scripts/refresh-tokens-data.ts create mode 100644 src/modules/aavev2/abis/AToken.json create mode 100644 src/modules/aavev2/abis/AaveV2FlashLoanCallback.json create mode 100644 src/modules/aavev2/abis/DebtTokenBase.json create mode 100644 src/modules/aavev2/abis/LendingPool.json create mode 100644 src/modules/aavev2/abis/LendingPoolAddressesProvider.json create mode 100644 src/modules/aavev2/abis/ProtocolDataProvider.json create mode 100644 src/modules/aavev2/contracts/AToken.ts create mode 100644 src/modules/aavev2/contracts/AaveV2FlashLoanCallback.ts create mode 100644 src/modules/aavev2/contracts/DebtTokenBase.ts create mode 100644 src/modules/aavev2/contracts/LendingPool.ts create mode 100644 src/modules/aavev2/contracts/LendingPoolAddressesProvider.ts create mode 100644 src/modules/aavev2/contracts/ProtocolDataProvider.ts create mode 100644 src/modules/aavev2/contracts/common.ts create mode 100644 src/modules/aavev2/contracts/factories/AToken__factory.ts create mode 100644 src/modules/aavev2/contracts/factories/AaveV2FlashLoanCallback__factory.ts create mode 100644 src/modules/aavev2/contracts/factories/DebtTokenBase__factory.ts create mode 100644 src/modules/aavev2/contracts/factories/LendingPoolAddressesProvider__factory.ts create mode 100644 src/modules/aavev2/contracts/factories/LendingPool__factory.ts create mode 100644 src/modules/aavev2/contracts/factories/ProtocolDataProvider__factory.ts create mode 100644 src/modules/aavev2/contracts/factories/index.ts create mode 100644 src/modules/aavev2/contracts/index.ts create mode 100644 src/modules/aavev2/index.ts create mode 100644 src/modules/aavev2/logic.borrow.ts create mode 100644 src/modules/aavev2/logic.deposit.ts create mode 100644 src/modules/aavev2/logic.repay.ts create mode 100644 src/modules/aavev2/logic.withdraw.ts create mode 100644 src/modules/aavev2/types.ts create mode 100644 src/modules/aavev2/utils.ts create mode 100644 src/modules/aavev3/abis/AToken.json create mode 100644 src/modules/aavev3/abis/AaveV3FlashLoanCallback.json create mode 100644 src/modules/aavev3/abis/DebtTokenBase.json create mode 100644 src/modules/aavev3/abis/Pool.json create mode 100644 src/modules/aavev3/abis/PoolAddressesProvider.json create mode 100644 src/modules/aavev3/abis/PoolDataProvider.json create mode 100644 src/modules/aavev3/contracts/AToken.ts create mode 100644 src/modules/aavev3/contracts/AaveV3FlashLoanCallback.ts create mode 100644 src/modules/aavev3/contracts/DebtTokenBase.ts create mode 100644 src/modules/aavev3/contracts/Pool.ts create mode 100644 src/modules/aavev3/contracts/PoolAddressesProvider.ts create mode 100644 src/modules/aavev3/contracts/PoolDataProvider.ts create mode 100644 src/modules/aavev3/contracts/common.ts create mode 100644 src/modules/aavev3/contracts/factories/AToken__factory.ts create mode 100644 src/modules/aavev3/contracts/factories/AaveV3FlashLoanCallback__factory.ts create mode 100644 src/modules/aavev3/contracts/factories/DebtTokenBase__factory.ts create mode 100644 src/modules/aavev3/contracts/factories/PoolAddressesProvider__factory.ts create mode 100644 src/modules/aavev3/contracts/factories/PoolDataProvider__factory.ts create mode 100644 src/modules/aavev3/contracts/factories/Pool__factory.ts create mode 100644 src/modules/aavev3/contracts/factories/index.ts create mode 100644 src/modules/aavev3/contracts/index.ts create mode 100644 src/modules/aavev3/index.ts create mode 100644 src/modules/aavev3/logic.borrow.ts create mode 100644 src/modules/aavev3/logic.repay.ts create mode 100644 src/modules/aavev3/logic.supply.ts create mode 100644 src/modules/aavev3/logic.withdraw.ts create mode 100644 src/modules/aavev3/types.ts diff --git a/.changeset/gorgeous-items-complain.md b/.changeset/gorgeous-items-complain.md new file mode 100644 index 00000000..eaea90aa --- /dev/null +++ b/.changeset/gorgeous-items-complain.md @@ -0,0 +1,5 @@ +--- +'@protocolink/logics': minor +--- + +add aave-like supply and borrow enable status to reserve tokens diff --git a/package.json b/package.json index 14fabd24..73c147fd 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ }, "dependencies": { "@paraswap/sdk": "^6.6.0", - "@protocolink/common": "^0.4.1", + "@protocolink/common": "^0.4.2", "@protocolink/core": "^0.5.0", "@protocolink/smart-accounts": "^0.1.3", "@types/lodash": "^4.14.195", diff --git a/src/logics/aave-v2/configs.ts b/src/logics/aave-v2/configs.ts index ab346997..8c9ecd22 100644 --- a/src/logics/aave-v2/configs.ts +++ b/src/logics/aave-v2/configs.ts @@ -1,5 +1,7 @@ import * as common from '@protocolink/common'; +export const protocolId = 'aave-v2'; + type ContractNames = 'ProtocolDataProvider' | 'AaveV2FlashLoanCallback'; export interface Config { diff --git a/src/logics/aave-v2/logic.borrow.ts b/src/logics/aave-v2/logic.borrow.ts index 7017d2d7..40bec848 100644 --- a/src/logics/aave-v2/logic.borrow.ts +++ b/src/logics/aave-v2/logic.borrow.ts @@ -1,53 +1,23 @@ -import { InterestRateMode } from './types'; -import { LendingPool__factory } from './contracts'; import { Service } from './service'; -import * as common from '@protocolink/common'; +import * as aavev2 from 'src/modules/aavev2'; import * as core from '@protocolink/core'; -import { supportedChainIds } from './configs'; +import { protocolId, supportedChainIds } from './configs'; +import { providers } from 'ethers'; -export type BorrowLogicTokenList = common.Token[]; +export type BorrowLogicFields = aavev2.BorrowLogicFields; -export type BorrowLogicFields = core.TokenOutFields<{ interestRateMode: InterestRateMode; referralCode?: number }>; +export type BorrowLogicOptions = aavev2.BorrowLogicOptions; -export type BorrowLogicOptions = Pick; +export type BorrowLogicTokenList = aavev2.BorrowLogicTokenList; -export class BorrowLogic extends core.Logic implements core.LogicTokenListInterface, core.LogicBuilderInterface { - static id = 'borrow'; - static protocolId = 'aave-v2'; +export class BorrowLogic + extends aavev2.BorrowLogic + implements core.LogicTokenListInterface, core.LogicBuilderInterface +{ + static protocolId = protocolId; static readonly supportedChainIds = supportedChainIds; - async getTokenList() { - const service = new Service(this.chainId, this.provider); - const tokens = await service.getAssets(); - - const tokenList: BorrowLogicTokenList = []; - for (const token of tokens) { - if (token.isWrapped) { - tokenList.push(token.unwrapped); - } - tokenList.push(token); - } - - return tokenList; - } - - async build(fields: BorrowLogicFields, options: BorrowLogicOptions) { - const { output, interestRateMode, referralCode = 0 } = fields; - const { account } = options; - - const tokenOut = output.token.wrapped; - - const service = new Service(this.chainId, this.provider); - const to = await service.getLendingPoolAddress(); - const data = LendingPool__factory.createInterface().encodeFunctionData('borrow', [ - tokenOut.address, - output.amountWei, - interestRateMode, - referralCode, - account, - ]); - const wrapMode = output.token.isNative ? core.WrapMode.unwrapAfter : core.WrapMode.none; - - return core.newLogic({ to, data, wrapMode }); + constructor(chainId: number, provider?: providers.Provider) { + super({ chainId, provider, service: new Service(chainId, provider) }); } } diff --git a/src/logics/aave-v2/logic.deposit.ts b/src/logics/aave-v2/logic.deposit.ts index 404e8e8b..a378cfd5 100644 --- a/src/logics/aave-v2/logic.deposit.ts +++ b/src/logics/aave-v2/logic.deposit.ts @@ -1,68 +1,27 @@ -import { LendingPool__factory } from './contracts'; import { Service } from './service'; -import * as common from '@protocolink/common'; -import * as core from '@protocolink/core'; -import { supportedChainIds } from './configs'; +import * as aavev2 from 'src/modules/aavev2'; +import { protocolId, supportedChainIds } from './configs'; +import { providers } from 'ethers'; -export type DepositLogicTokenList = [common.Token, common.Token][]; +export type DepositLogicTokenList = aavev2.DepositLogicTokenList; -export type DepositLogicParams = core.TokenToTokenExactInParams; +export type DepositLogicParams = aavev2.DepositLogicParams; -export type DepositLogicFields = core.TokenToTokenExactInFields<{ referralCode?: number }>; +export type DepositLogicFields = aavev2.DepositLogicFields; -export type DepositLogicOptions = Pick; +export type DepositLogicOptions = aavev2.DepositLogicOptions; -export class DepositLogic - extends core.Logic - implements core.LogicTokenListInterface, core.LogicOracleInterface, core.LogicBuilderInterface -{ - static id = 'deposit'; - static protocolId = 'aave-v2'; +export class DepositLogic extends aavev2.DepositLogics { + static protocolId = protocolId; static readonly supportedChainIds = supportedChainIds; - async getTokenList() { - const service = new Service(this.chainId, this.provider); - const reserveTokens = await service.getReserveTokens(); - - const tokenList: DepositLogicTokenList = []; - for (const reserveToken of reserveTokens) { - if (reserveToken.asset.isWrapped) { - tokenList.push([reserveToken.asset.unwrapped, reserveToken.aToken]); - } - tokenList.push([reserveToken.asset, reserveToken.aToken]); - } - - return tokenList; + constructor(chainId: number, provider?: providers.Provider) { + super({ chainId, provider, service: new Service(chainId, provider) }); } - async quote(params: DepositLogicParams) { - const { input, tokenOut } = params; - const output = new common.TokenAmount(tokenOut, input.amount); - - return { input, output }; - } - - async build(fields: DepositLogicFields, options: DepositLogicOptions) { - const { input, balanceBps, referralCode = 0 } = fields; - const { account } = options; - - const tokenIn = input.token.wrapped; - const agent = await this.calcAgent(account); - - const service = new Service(this.chainId, this.provider); - const to = await service.getLendingPoolAddress(); - const data = LendingPool__factory.createInterface().encodeFunctionData('deposit', [ - tokenIn.address, - input.amountWei, - agent, - referralCode, - ]); - const amountOffset = balanceBps ? common.getParamOffset(1) : undefined; - const inputs = [ - core.newLogicInput({ input: new common.TokenAmount(tokenIn, input.amount), balanceBps, amountOffset }), - ]; - const wrapMode = input.token.isNative ? core.WrapMode.wrapBefore : core.WrapMode.none; + async getTokenList() { + const reserveTokens = await this.service.getSupplyTokens(); - return core.newLogic({ to, data, inputs, wrapMode }); + return aavev2.createDepositTokenList(reserveTokens, 'aToken'); } } diff --git a/src/logics/aave-v2/logic.repay.ts b/src/logics/aave-v2/logic.repay.ts index 90d31d4b..85f3ecfb 100644 --- a/src/logics/aave-v2/logic.repay.ts +++ b/src/logics/aave-v2/logic.repay.ts @@ -1,73 +1,23 @@ -import { InterestRateMode } from './types'; -import { LendingPool__factory } from './contracts'; import { Service } from './service'; -import * as common from '@protocolink/common'; +import * as aavev2 from 'src/modules/aavev2'; import * as core from '@protocolink/core'; -import { supportedChainIds } from './configs'; +import { protocolId, supportedChainIds } from './configs'; +import { providers } from 'ethers'; -export type RepayLogicTokenList = common.Token[]; +export type RepayLogicTokenList = aavev2.RepayLogicTokenList; -export type RepayLogicParams = core.RepayParams<{ interestRateMode: InterestRateMode }>; +export type RepayLogicParams = aavev2.RepayLogicParams; -export type RepayLogicFields = core.RepayFields<{ interestRateMode: InterestRateMode }>; +export type RepayLogicFields = aavev2.RepayLogicFields; export class RepayLogic - extends core.Logic + extends aavev2.RepayLogic implements core.LogicTokenListInterface, core.LogicOracleInterface, core.LogicBuilderInterface { - static id = 'repay'; - static protocolId = 'aave-v2'; + static protocolId = protocolId; static readonly supportedChainIds = supportedChainIds; - async getTokenList() { - const service = new Service(this.chainId, this.provider); - const tokens = await service.getAssets(); - - const tokenList: RepayLogicTokenList = []; - for (const token of tokens) { - if (token.isWrapped) { - tokenList.push(token.unwrapped); - } - tokenList.push(token); - } - - return tokenList; - } - - async quote(params: RepayLogicParams) { - const { borrower, tokenIn, interestRateMode } = params; - - const service = new Service(this.chainId, this.provider); - const { currentStableDebt, currentVariableDebt } = await service.protocolDataProvider.getUserReserveData( - tokenIn.wrapped.address, - borrower - ); - const currentDebt = interestRateMode === InterestRateMode.variable ? currentVariableDebt : currentStableDebt; - const amountWei = common.calcSlippage(currentDebt, -1); // slightly higher than the current borrowed amount - const input = new common.TokenAmount(tokenIn).setWei(amountWei); - - return { borrower, interestRateMode, input }; - } - - async build(fields: RepayLogicFields) { - const { input, interestRateMode, borrower, balanceBps } = fields; - - const tokenIn = input.token.wrapped; - - const service = new Service(this.chainId, this.provider); - const to = await service.getLendingPoolAddress(); - const data = LendingPool__factory.createInterface().encodeFunctionData('repay', [ - tokenIn.address, - input.amountWei, - interestRateMode, - borrower, - ]); - const amountOffset = balanceBps ? common.getParamOffset(1) : undefined; - const inputs = [ - core.newLogicInput({ input: new common.TokenAmount(tokenIn, input.amount), balanceBps, amountOffset }), - ]; - const wrapMode = input.token.isNative ? core.WrapMode.wrapBefore : core.WrapMode.none; - - return core.newLogic({ to, data, inputs, wrapMode }); + constructor(chainId: number, provider?: providers.Provider) { + super({ chainId, provider, service: new Service(chainId, provider) }); } } diff --git a/src/logics/aave-v2/logic.withdraw.ts b/src/logics/aave-v2/logic.withdraw.ts index ee1d8506..63a3872d 100644 --- a/src/logics/aave-v2/logic.withdraw.ts +++ b/src/logics/aave-v2/logic.withdraw.ts @@ -1,65 +1,31 @@ -import { LendingPool__factory } from './contracts'; import { Service } from './service'; -import * as common from '@protocolink/common'; +import * as aavev2 from 'src/modules/aavev2'; import * as core from '@protocolink/core'; -import { supportedChainIds } from './configs'; +import { protocolId, supportedChainIds } from './configs'; +import { providers } from 'ethers'; -export type WithdrawLogicTokenList = [common.Token, common.Token][]; +export type WithdrawLogicTokenList = aavev2.WithdrawLogicTokenList; -export type WithdrawLogicParams = core.TokenToTokenExactInParams; +export type WithdrawLogicParams = aavev2.WithdrawLogicParams; -export type WithdrawLogicFields = core.TokenToTokenExactInFields; +export type WithdrawLogicFields = aavev2.WithdrawLogicFields; -export type WithdrawLogicOptions = Pick; +export type WithdrawLogicOptions = aavev2.WithdrawLogicOptions; export class WithdrawLogic - extends core.Logic + extends aavev2.WithdrawLogic implements core.LogicTokenListInterface, core.LogicOracleInterface, core.LogicBuilderInterface { - static id = 'withdraw'; - static protocolId = 'aave-v2'; + static protocolId = protocolId; static readonly supportedChainIds = supportedChainIds; - async getTokenList() { - const service = new Service(this.chainId, this.provider); - const reserveTokens = await service.getReserveTokens(); - - const tokenList: WithdrawLogicTokenList = []; - for (const reserveToken of reserveTokens) { - if (reserveToken.asset.isWrapped) { - tokenList.push([reserveToken.aToken, reserveToken.asset.unwrapped]); - } - tokenList.push([reserveToken.aToken, reserveToken.asset]); - } - - return tokenList; + constructor(chainId: number, provider?: providers.Provider) { + super({ chainId, provider, service: new Service(chainId, provider) }); } - async quote(params: WithdrawLogicParams) { - const { input, tokenOut } = params; - const output = new common.TokenAmount(tokenOut, input.amount); - - return { input, output }; - } - - async build(fields: WithdrawLogicFields, options: WithdrawLogicOptions) { - const { input, output, balanceBps } = fields; - const { account } = options; - - const tokenOut = output.token.wrapped; - const agent = await this.calcAgent(account); - - const service = new Service(this.chainId, this.provider); - const to = await service.getLendingPoolAddress(); - const data = LendingPool__factory.createInterface().encodeFunctionData('withdraw', [ - tokenOut.address, - input.amountWei, - agent, - ]); - const amountOffset = balanceBps ? common.getParamOffset(1) : undefined; - const inputs = [core.newLogicInput({ input, balanceBps, amountOffset })]; - const wrapMode = output.token.isNative ? core.WrapMode.unwrapAfter : core.WrapMode.none; + async getTokenList() { + const reserveTokens = await this.service.getSupplyTokens(); - return core.newLogic({ to, data, inputs, wrapMode }); + return aavev2.createWithdrawTokenList(reserveTokens, 'aToken'); } } diff --git a/src/logics/aave-v2/scripts/refresh-tokens-data.ts b/src/logics/aave-v2/scripts/refresh-tokens-data.ts deleted file mode 100644 index f21ddab0..00000000 --- a/src/logics/aave-v2/scripts/refresh-tokens-data.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { Service } from '../service'; -import * as common from '@protocolink/common'; -import fs from 'fs-extra'; -import { resolve } from 'path'; - -export default async function () { - const chainIds = [common.ChainId.mainnet]; - - for (const chainId of chainIds) { - const service = new Service(chainId); - const reserveTokens = await service.getReserveTokens(); - - const tokenMap = reserveTokens.reduce((accumulator, reserveToken) => { - if (reserveToken.asset.isWrapped) { - const unwrapped = reserveToken.asset.unwrapped; - accumulator[unwrapped.symbol] = unwrapped; - } - accumulator[reserveToken.asset.symbol] = reserveToken.asset; - accumulator[reserveToken.aToken.symbol] = reserveToken.aToken; - return accumulator; - }, {} as Record); - - const tokenDataPath = resolve(__dirname, '..', 'tokens', 'data', `${common.toNetworkId(chainId)}.json`); - fs.outputJSONSync(tokenDataPath, tokenMap, { spaces: 2 }); - } -} diff --git a/src/logics/aave-v2/service.test.ts b/src/logics/aave-v2/service.test.ts index 7f1564a0..fdaaf3fa 100644 --- a/src/logics/aave-v2/service.test.ts +++ b/src/logics/aave-v2/service.test.ts @@ -7,12 +7,36 @@ import omit from 'lodash/omit'; describe('AaveV2 Service', function () { const chainIds = [common.ChainId.mainnet]; - context('Test getReserveTokensAddresses', function () { + context('Test getReserveTokens', () => { + chainIds.forEach((chainId) => { + it(common.toNetworkId(chainId), async () => { + const service = new Service(chainId); + const { reserveTokens, reserveMap } = await service.getReserveTokens(); + + expect(reserveTokens).to.have.lengthOf.above(0); + expect(Object.keys(reserveMap)).to.have.lengthOf.above(0); + }); + }); + }); + + context('Test getSupplyTokens', function () { + chainIds.forEach((chainId) => { + it(common.toNetworkId(chainId), async function () { + const service = new Service(chainId); + const supplyTokens = await service.getSupplyTokens(); + expect(supplyTokens).to.have.lengthOf.above(0); + expect(supplyTokens.every(({ isSupplyEnabled }) => isSupplyEnabled)).to.be.true; + }); + }); + }); + + context('Test getBorrowTokens', function () { chainIds.forEach((chainId) => { it(common.toNetworkId(chainId), async function () { const service = new Service(chainId); - const reserveTokensAddresses = await service.getReserveTokensAddresses(); - expect(reserveTokensAddresses).to.have.lengthOf.above(0); + const borrowTokens = await service.getBorrowTokens(); + expect(borrowTokens).to.have.lengthOf.above(0); + expect(borrowTokens.every(({ isBorrowEnabled }) => isBorrowEnabled)).to.be.true; }); }); }); diff --git a/src/logics/aave-v2/service.ts b/src/logics/aave-v2/service.ts index 23b08527..6cae34e2 100644 --- a/src/logics/aave-v2/service.ts +++ b/src/logics/aave-v2/service.ts @@ -1,18 +1,11 @@ import { - AToken__factory, DebtTokenBase__factory, LendingPoolAddressesProvider__factory, LendingPool__factory, ProtocolDataProvider, ProtocolDataProvider__factory, } from './contracts'; -import { - FlashLoanAssetInfo, - FlashLoanConfiguration, - InterestRateMode, - ReserveTokens, - ReserveTokensAddress, -} from './types'; +import { FlashLoanAssetInfo, FlashLoanConfiguration, InterestRateMode, ReserveTokens } from './types'; import { LendingPoolInterface } from './contracts/LendingPool'; import { ProtocolDataProviderInterface } from './contracts/ProtocolDataProvider'; import * as common from '@protocolink/common'; @@ -65,150 +58,127 @@ export class Service extends common.Web3Toolkit { return this.lendingPoolAddress; } - private assetAddresses?: string[]; + private reserveTokens?: ReserveTokens[]; + private reserveMap?: Record; + + async getReserveTokens() { + if (!this.reserveTokens || !this.reserveMap) { + const tokenAddresses: string[] = []; + const reserveTokens: ReserveTokens[] = []; + const reserveMap: Record = {}; - async getAssetAddresses() { - if (!this.assetAddresses) { const lendingPoolAddress = await this.getLendingPoolAddress(); const assetAddresses = await LendingPool__factory.connect(lendingPoolAddress, this.provider).getReservesList(); - const calls: common.Multicall3.CallStruct[] = assetAddresses.map((assetAddress) => ({ - target: this.protocolDataProvider.address, - callData: this.protocolDataProviderIface.encodeFunctionData('getReserveConfigurationData', [assetAddress]), - })); + const calls: common.Multicall3.CallStruct[] = assetAddresses.flatMap((assetAddress) => [ + { + target: this.protocolDataProvider.address, + callData: this.protocolDataProviderIface.encodeFunctionData('getReserveConfigurationData', [assetAddress]), + }, + { + target: this.protocolDataProvider.address, + callData: this.protocolDataProviderIface.encodeFunctionData('getReserveTokensAddresses', [assetAddress]), + }, + ]); const { returnData } = await this.multicall3.callStatic.aggregate(calls); - this.assetAddresses = []; - for (let i = 0; i < assetAddresses.length; i++) { - const assetAddress = assetAddresses[i]; - const { isActive, isFrozen } = this.protocolDataProviderIface.decodeFunctionResult( + assetAddresses.forEach((assetAddress, i) => { + const { isActive, isFrozen, borrowingEnabled } = this.protocolDataProviderIface.decodeFunctionResult( 'getReserveConfigurationData', - returnData[i] + returnData[i * 2] ); - if (isActive && !isFrozen) this.assetAddresses.push(assetAddress); - } - } - return this.assetAddresses; - } + const { aTokenAddress, stableDebtTokenAddress, variableDebtTokenAddress } = + this.protocolDataProviderIface.decodeFunctionResult('getReserveTokensAddresses', returnData[i * 2 + 1]); + + reserveMap[assetAddress] = { + isSupplyEnabled: isActive && !isFrozen, + isBorrowEnabled: isActive && !isFrozen && borrowingEnabled, + }; - private reserveTokensAddresses?: ReserveTokensAddress[]; + tokenAddresses.push(assetAddress, aTokenAddress, stableDebtTokenAddress, variableDebtTokenAddress); + }); - async getReserveTokensAddresses() { - if (!this.reserveTokensAddresses) { - const assetAddresses = await this.getAssetAddresses(); + const tokens = await this.getTokens(tokenAddresses); - const calls: common.Multicall3.CallStruct[] = assetAddresses.map((asset) => ({ - target: this.protocolDataProvider.address, - callData: this.protocolDataProviderIface.encodeFunctionData('getReserveTokensAddresses', [asset]), - })); - const { returnData } = await this.multicall3.callStatic.aggregate(calls); + for (let i = 0; i < tokens.length; i += 4) { + const asset = tokens[i]; + const aToken = tokens[i + 1]; + const stableDebtToken = tokens[i + 2]; + const variableDebtToken = tokens[i + 3]; - this.reserveTokensAddresses = []; - for (let i = 0; i < assetAddresses.length; i++) { - const assetAddress = assetAddresses[i]; - const { aTokenAddress, stableDebtTokenAddress, variableDebtTokenAddress } = - this.protocolDataProviderIface.decodeFunctionResult('getReserveTokensAddresses', returnData[i]); - this.reserveTokensAddresses.push({ - assetAddress, - aTokenAddress, - stableDebtTokenAddress, - variableDebtTokenAddress, - }); + const reserveToken: ReserveTokens = { + ...reserveMap[asset.address], + asset, + aToken, + stableDebtToken, + variableDebtToken, + }; + + reserveTokens.push(reserveToken); + + reserveMap[asset.address] = reserveToken; + + // Add aToken address as key for quick lookup + reserveMap[aToken.address] = reserveToken; } + + this.reserveTokens = reserveTokens; + this.reserveMap = reserveMap; } - return this.reserveTokensAddresses; + return { reserveTokens: this.reserveTokens, reserveMap: this.reserveMap }; } - private assets?: common.Token[]; - async getAssets() { - if (!this.assets) { - const assetAddresses = await this.getAssetAddresses(); - this.assets = await this.getTokens(assetAddresses); - } - return this.assets; + const { reserveTokens } = await this.getReserveTokens(); + return reserveTokens.map(({ asset }) => asset); } - private aTokens?: common.Token[]; - async getATokens() { - if (!this.aTokens) { - const reserveTokensAddresses = await this.getReserveTokensAddresses(); - const aTokenAddresses = reserveTokensAddresses.map((reserveTokensAddress) => reserveTokensAddress.aTokenAddress); - this.aTokens = await this.getTokens(aTokenAddresses); - } - return this.aTokens; + const { reserveTokens } = await this.getReserveTokens(); + return reserveTokens.map(({ aToken }) => aToken); } - private reserveTokens?: ReserveTokens[]; - - async getReserveTokens() { - if (!this.reserveTokens) { - const reserveTokensAddresses = await this.getReserveTokensAddresses(); - const tokenAddresses = reserveTokensAddresses.reduce((accumulator, reserveTokensAddress) => { - accumulator.push(reserveTokensAddress.assetAddress); - accumulator.push(reserveTokensAddress.aTokenAddress); - accumulator.push(reserveTokensAddress.stableDebtTokenAddress); - accumulator.push(reserveTokensAddress.variableDebtTokenAddress); - return accumulator; - }, []); - const tokens = await this.getTokens(tokenAddresses); - - this.reserveTokens = []; - let j = 0; - for (let i = 0; i < reserveTokensAddresses.length; i++) { - const asset = tokens[j]; - j++; - const aToken = tokens[j]; - j++; - const stableDebtToken = tokens[j]; - j++; - const variableDebtToken = tokens[j]; - j++; - this.reserveTokens.push({ asset, aToken, stableDebtToken, variableDebtToken }); - } - } + async getSupplyTokens() { + const { reserveTokens } = await this.getReserveTokens(); + return reserveTokens.filter(({ isSupplyEnabled }) => isSupplyEnabled); + } - return this.reserveTokens; + async getBorrowTokens() { + const { reserveTokens } = await this.getReserveTokens(); + return reserveTokens.filter(({ isBorrowEnabled }) => isBorrowEnabled); } async toAToken(asset: common.Token) { - const { aTokenAddress } = await this.protocolDataProvider.getReserveTokensAddresses(asset.wrapped.address); - return this.getToken(aTokenAddress); - } + const { reserveMap } = await this.getReserveTokens(); - async toATokens(assets: common.Token[]) { - const calls: common.Multicall3.CallStruct[] = assets.map((asset) => ({ - target: this.protocolDataProvider.address, - callData: this.protocolDataProviderIface.encodeFunctionData('getReserveTokensAddresses', [asset.wrapped.address]), - })); - const { returnData } = await this.multicall3.callStatic.aggregate(calls); + const aToken = reserveMap[asset.wrapped.address]?.aToken; + invariant(aToken?.address !== constants.AddressZero, `unsupported asset: ${asset.wrapped.address}`); - const aTokenAddresses: string[] = []; - for (let i = 0; i < assets.length; i++) { - const { aTokenAddress } = this.protocolDataProviderIface.decodeFunctionResult( - 'getReserveTokensAddresses', - returnData[i] - ); - invariant(aTokenAddress !== constants.AddressZero, `unsupported asset: ${assets[i].wrapped.address}`); - aTokenAddresses.push(aTokenAddress); - } + return aToken; + } - return this.getTokens(aTokenAddresses); + async toATokens(assets: common.Token[]) { + return Promise.all(assets.map((asset) => this.toAToken(asset))); } async toAsset(aToken: common.Token) { - const assetAddress = await AToken__factory.connect(aToken.address, this.provider).UNDERLYING_ASSET_ADDRESS(); - return this.getToken(assetAddress); + const { reserveMap } = await this.getReserveTokens(); + + const asset = reserveMap[aToken.address]?.asset; + invariant(asset, `unsupported aToken: ${aToken.address}`); + + return asset; } async getDebtTokenAddress(asset: common.Token, interestRateMode: InterestRateMode) { - const { stableDebtTokenAddress, variableDebtTokenAddress } = - await this.protocolDataProvider.getReserveTokensAddresses(asset.wrapped.address); + const { reserveMap } = await this.getReserveTokens(); + + const { stableDebtToken, variableDebtToken } = reserveMap[asset.wrapped.address]; + invariant(stableDebtToken || variableDebtToken, `unsupported aToken: ${asset.wrapped.address}`); - return interestRateMode === InterestRateMode.variable ? variableDebtTokenAddress : stableDebtTokenAddress; + return interestRateMode === InterestRateMode.variable ? variableDebtToken.address : stableDebtToken.address; } async getFlashLoanPremiumTotal() { diff --git a/src/logics/aave-v2/types.ts b/src/logics/aave-v2/types.ts index 3583e875..158db369 100644 --- a/src/logics/aave-v2/types.ts +++ b/src/logics/aave-v2/types.ts @@ -1,17 +1,12 @@ import * as common from '@protocolink/common'; -export interface ReserveTokensAddress { - assetAddress: string; - aTokenAddress: string; - stableDebtTokenAddress: string; - variableDebtTokenAddress: string; -} - export interface ReserveTokens { asset: common.Token; aToken: common.Token; stableDebtToken: common.Token; variableDebtToken: common.Token; + isSupplyEnabled: boolean; + isBorrowEnabled: boolean; } export enum InterestRateMode { diff --git a/src/logics/aave-v3/configs.ts b/src/logics/aave-v3/configs.ts index 29b0884d..98373b9b 100644 --- a/src/logics/aave-v3/configs.ts +++ b/src/logics/aave-v3/configs.ts @@ -1,5 +1,7 @@ import * as common from '@protocolink/common'; +export const protocolId = 'aave-v3'; + type ContractNames = 'PoolDataProvider' | 'AaveV3FlashLoanCallback'; export interface Config { diff --git a/src/logics/aave-v3/logic.borrow.ts b/src/logics/aave-v3/logic.borrow.ts index 7d129a80..1070ee6f 100644 --- a/src/logics/aave-v3/logic.borrow.ts +++ b/src/logics/aave-v3/logic.borrow.ts @@ -1,53 +1,23 @@ -import { InterestRateMode } from './types'; -import { Pool__factory } from './contracts'; import { Service } from './service'; -import * as common from '@protocolink/common'; +import * as aavev3 from 'src/modules/aavev3'; import * as core from '@protocolink/core'; -import { supportedChainIds } from './configs'; +import { protocolId, supportedChainIds } from './configs'; +import { providers } from 'ethers'; -export type BorrowLogicTokenList = common.Token[]; +export type BorrowLogicTokenList = aavev3.BorrowLogicTokenList; -export type BorrowLogicFields = core.TokenOutFields<{ interestRateMode: InterestRateMode; referralCode?: number }>; +export type BorrowLogicFields = aavev3.BorrowLogicFields; -export type BorrowLogicOptions = Pick; +export type BorrowLogicOptions = aavev3.BorrowLogicOptions; -export class BorrowLogic extends core.Logic implements core.LogicTokenListInterface, core.LogicBuilderInterface { - static id = 'borrow'; - static protocolId = 'aave-v3'; +export class BorrowLogic + extends aavev3.BorrowLogic + implements core.LogicTokenListInterface, core.LogicBuilderInterface +{ + static protocolId = protocolId; static readonly supportedChainIds = supportedChainIds; - async getTokenList() { - const service = new Service(this.chainId, this.provider); - const tokens = await service.getAssets(); - - const tokenList: BorrowLogicTokenList = []; - for (const token of tokens) { - if (token.isWrapped) { - tokenList.push(token.unwrapped); - } - tokenList.push(token); - } - - return tokenList; - } - - async build(fields: BorrowLogicFields, options: BorrowLogicOptions) { - const { output, interestRateMode, referralCode = 0 } = fields; - const { account } = options; - - const tokenOut = output.token.wrapped; - - const service = new Service(this.chainId, this.provider); - const to = await service.getPoolAddress(); - const data = Pool__factory.createInterface().encodeFunctionData('borrow', [ - tokenOut.address, - output.amountWei, - interestRateMode, - referralCode, - account, - ]); - const wrapMode = output.token.isNative ? core.WrapMode.unwrapAfter : core.WrapMode.none; - - return core.newLogic({ to, data, wrapMode }); + constructor(chainId: number, provider?: providers.Provider) { + super({ chainId, provider, service: new Service(chainId, provider) }); } } diff --git a/src/logics/aave-v3/logic.repay.ts b/src/logics/aave-v3/logic.repay.ts index 15c7424a..f3b67ede 100644 --- a/src/logics/aave-v3/logic.repay.ts +++ b/src/logics/aave-v3/logic.repay.ts @@ -1,73 +1,23 @@ -import { InterestRateMode } from './types'; -import { Pool__factory } from './contracts'; import { Service } from './service'; -import * as common from '@protocolink/common'; +import * as aavev3 from 'src/modules/aavev3'; import * as core from '@protocolink/core'; -import { supportedChainIds } from './configs'; +import { protocolId, supportedChainIds } from './configs'; +import { providers } from 'ethers'; -export type RepayLogicTokenList = common.Token[]; +export type RepayLogicTokenList = aavev3.RepayLogicTokenList; -export type RepayLogicParams = core.RepayParams<{ interestRateMode: InterestRateMode }>; +export type RepayLogicParams = aavev3.RepayLogicParams; -export type RepayLogicFields = core.RepayFields<{ interestRateMode: InterestRateMode }>; +export type RepayLogicFields = aavev3.RepayLogicFields; export class RepayLogic - extends core.Logic + extends aavev3.RepayLogic implements core.LogicTokenListInterface, core.LogicOracleInterface, core.LogicBuilderInterface { - static id = 'repay'; - static protocolId = 'aave-v3'; + static protocolId = protocolId; static readonly supportedChainIds = supportedChainIds; - async getTokenList() { - const service = new Service(this.chainId, this.provider); - const tokens = await service.getAssets(); - - const tokenList: RepayLogicTokenList = []; - for (const token of tokens) { - if (token.isWrapped) { - tokenList.push(token.unwrapped); - } - tokenList.push(token); - } - - return tokenList; - } - - async quote(params: RepayLogicParams) { - const { borrower, tokenIn, interestRateMode } = params; - - const service = new Service(this.chainId, this.provider); - const { currentStableDebt, currentVariableDebt } = await service.poolDataProvider.getUserReserveData( - tokenIn.wrapped.address, - borrower - ); - const currentDebt = interestRateMode === InterestRateMode.variable ? currentVariableDebt : currentStableDebt; - const amountWei = common.calcSlippage(currentDebt, -1); // slightly higher than the current borrowed amount - const input = new common.TokenAmount(tokenIn).setWei(amountWei); - - return { borrower, interestRateMode, input }; - } - - async build(fields: RepayLogicFields) { - const { input, interestRateMode, borrower, balanceBps } = fields; - - const tokenIn = input.token.wrapped; - - const service = new Service(this.chainId, this.provider); - const to = await service.getPoolAddress(); - const data = Pool__factory.createInterface().encodeFunctionData('repay', [ - tokenIn.address, - input.amountWei, - interestRateMode, - borrower, - ]); - const amountOffset = balanceBps ? common.getParamOffset(1) : undefined; - const inputs = [ - core.newLogicInput({ input: new common.TokenAmount(tokenIn, input.amount), balanceBps, amountOffset }), - ]; - const wrapMode = input.token.isNative ? core.WrapMode.wrapBefore : core.WrapMode.none; - - return core.newLogic({ to, data, inputs, wrapMode }); + constructor(chainId: number, provider?: providers.Provider) { + super({ chainId, provider, service: new Service(chainId, provider) }); } } diff --git a/src/logics/aave-v3/logic.supply.ts b/src/logics/aave-v3/logic.supply.ts index 1c96b9ac..86b43f32 100644 --- a/src/logics/aave-v3/logic.supply.ts +++ b/src/logics/aave-v3/logic.supply.ts @@ -1,68 +1,25 @@ -import { Pool__factory } from './contracts'; import { Service } from './service'; -import * as common from '@protocolink/common'; +import * as aavev3 from 'src/modules/aavev3'; import * as core from '@protocolink/core'; -import { supportedChainIds } from './configs'; +import { protocolId, supportedChainIds } from './configs'; +import { providers } from 'ethers'; -export type SupplyLogicTokenList = [common.Token, common.Token][]; +export type SupplyLogicTokenList = aavev3.SupplyLogicTokenList; -export type SupplyLogicParams = core.TokenToTokenExactInParams; +export type SupplyLogicParams = aavev3.SupplyLogicParams; -export type SupplyLogicFields = core.TokenToTokenExactInFields<{ referralCode?: number }>; +export type SupplyLogicFields = aavev3.SupplyLogicFields; -export type SupplyLogicOptions = Pick; +export type SupplyLogicOptions = aavev3.SupplyLogicOptions; export class SupplyLogic - extends core.Logic + extends aavev3.SupplyLogics implements core.LogicTokenListInterface, core.LogicOracleInterface, core.LogicBuilderInterface { - static id = 'supply'; - static protocolId = 'aave-v3'; + static protocolId = protocolId; static readonly supportedChainIds = supportedChainIds; - async getTokenList() { - const service = new Service(this.chainId, this.provider); - const reserveTokens = await service.getReserveTokens(); - - const tokenList: SupplyLogicTokenList = []; - for (const reserveToken of reserveTokens) { - if (reserveToken.asset.isWrapped) { - tokenList.push([reserveToken.asset.unwrapped, reserveToken.aToken]); - } - tokenList.push([reserveToken.asset, reserveToken.aToken]); - } - - return tokenList; - } - - async quote(params: SupplyLogicParams) { - const { input, tokenOut } = params; - const output = new common.TokenAmount(tokenOut, input.amount); - - return { input, output }; - } - - async build(fields: SupplyLogicFields, options: SupplyLogicOptions) { - const { input, balanceBps, referralCode = 0 } = fields; - const { account } = options; - - const tokenIn = input.token.wrapped; - const agent = await this.calcAgent(account); - - const service = new Service(this.chainId, this.provider); - const to = await service.getPoolAddress(); - const data = Pool__factory.createInterface().encodeFunctionData('supply', [ - tokenIn.address, - input.amountWei, - agent, - referralCode, - ]); - const amountOffset = balanceBps ? common.getParamOffset(1) : undefined; - const inputs = [ - core.newLogicInput({ input: new common.TokenAmount(tokenIn, input.amount), balanceBps, amountOffset }), - ]; - const wrapMode = input.token.isNative ? core.WrapMode.wrapBefore : core.WrapMode.none; - - return core.newLogic({ to, data, inputs, wrapMode }); + constructor(chainId: number, provider?: providers.Provider) { + super({ chainId, provider, service: new Service(chainId, provider) }); } } diff --git a/src/logics/aave-v3/logic.withdraw.ts b/src/logics/aave-v3/logic.withdraw.ts index e4f86b03..524a744b 100644 --- a/src/logics/aave-v3/logic.withdraw.ts +++ b/src/logics/aave-v3/logic.withdraw.ts @@ -1,65 +1,25 @@ -import { Pool__factory } from './contracts'; import { Service } from './service'; -import * as common from '@protocolink/common'; +import * as aavev3 from 'src/modules/aavev3'; import * as core from '@protocolink/core'; -import { supportedChainIds } from './configs'; +import { protocolId, supportedChainIds } from './configs'; +import { providers } from 'ethers'; -export type WithdrawLogicTokenList = [common.Token, common.Token][]; +export type WithdrawLogicTokenList = aavev3.WithdrawLogicTokenList; -export type WithdrawLogicParams = core.TokenToTokenExactInParams; +export type WithdrawLogicParams = aavev3.WithdrawLogicParams; -export type WithdrawLogicFields = core.TokenToTokenExactInFields; +export type WithdrawLogicFields = aavev3.WithdrawLogicFields; -export type WithdrawLogicOptions = Pick; +export type WithdrawLogicOptions = aavev3.WithdrawLogicOptions; export class WithdrawLogic - extends core.Logic + extends aavev3.WithdrawLogic implements core.LogicTokenListInterface, core.LogicOracleInterface, core.LogicBuilderInterface { - static id = 'withdraw'; - static protocolId = 'aave-v3'; + static protocolId = protocolId; static readonly supportedChainIds = supportedChainIds; - async getTokenList() { - const service = new Service(this.chainId, this.provider); - const reserveTokens = await service.getReserveTokens(); - - const tokenList: WithdrawLogicTokenList = []; - for (const reserveToken of reserveTokens) { - if (reserveToken.asset.isWrapped) { - tokenList.push([reserveToken.aToken, reserveToken.asset.unwrapped]); - } - tokenList.push([reserveToken.aToken, reserveToken.asset]); - } - - return tokenList; - } - - async quote(params: WithdrawLogicParams) { - const { input, tokenOut } = params; - const output = new common.TokenAmount(tokenOut, input.amount); - - return { input, output }; - } - - async build(fields: WithdrawLogicFields, options: WithdrawLogicOptions) { - const { input, output, balanceBps } = fields; - const { account } = options; - - const tokenOut = output.token.wrapped; - const agent = await this.calcAgent(account); - - const service = new Service(this.chainId, this.provider); - const to = await service.getPoolAddress(); - const data = Pool__factory.createInterface().encodeFunctionData('withdraw', [ - tokenOut.address, - input.amountWei, - agent, - ]); - const amountOffset = balanceBps ? common.getParamOffset(1) : undefined; - const inputs = [core.newLogicInput({ input, balanceBps, amountOffset })]; - const wrapMode = output.token.isNative ? core.WrapMode.unwrapAfter : core.WrapMode.none; - - return core.newLogic({ to, data, inputs, wrapMode }); + constructor(chainId: number, provider?: providers.Provider) { + super({ chainId, provider, service: new Service(chainId, provider) }); } } diff --git a/src/logics/aave-v3/scripts/refresh-tokens-data.ts b/src/logics/aave-v3/scripts/refresh-tokens-data.ts deleted file mode 100644 index f21ddab0..00000000 --- a/src/logics/aave-v3/scripts/refresh-tokens-data.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { Service } from '../service'; -import * as common from '@protocolink/common'; -import fs from 'fs-extra'; -import { resolve } from 'path'; - -export default async function () { - const chainIds = [common.ChainId.mainnet]; - - for (const chainId of chainIds) { - const service = new Service(chainId); - const reserveTokens = await service.getReserveTokens(); - - const tokenMap = reserveTokens.reduce((accumulator, reserveToken) => { - if (reserveToken.asset.isWrapped) { - const unwrapped = reserveToken.asset.unwrapped; - accumulator[unwrapped.symbol] = unwrapped; - } - accumulator[reserveToken.asset.symbol] = reserveToken.asset; - accumulator[reserveToken.aToken.symbol] = reserveToken.aToken; - return accumulator; - }, {} as Record); - - const tokenDataPath = resolve(__dirname, '..', 'tokens', 'data', `${common.toNetworkId(chainId)}.json`); - fs.outputJSONSync(tokenDataPath, tokenMap, { spaces: 2 }); - } -} diff --git a/src/logics/aave-v3/service.test.ts b/src/logics/aave-v3/service.test.ts index ab5836c7..e9fa97c5 100644 --- a/src/logics/aave-v3/service.test.ts +++ b/src/logics/aave-v3/service.test.ts @@ -7,12 +7,36 @@ import omit from 'lodash/omit'; describe('AaveV3 Service', function () { const chainIds = [common.ChainId.mainnet]; - context('Test getReserveTokensAddresses', function () { + context('Test getReserveTokens', function () { chainIds.forEach((chainId) => { it(common.toNetworkId(chainId), async function () { const service = new Service(chainId); - const reserveTokensAddresses = await service.getReserveTokensAddresses(); - expect(reserveTokensAddresses).to.have.lengthOf.above(0); + const { reserveTokens, reserveMap } = await service.getReserveTokens(); + + expect(reserveTokens).to.have.lengthOf.above(0); + expect(Object.keys(reserveMap)).to.have.lengthOf.above(0); + }); + }); + }); + + context('Test getSupplyTokens', function () { + chainIds.forEach((chainId) => { + it(common.toNetworkId(chainId), async function () { + const service = new Service(chainId); + const supplyTokens = await service.getSupplyTokens(); + expect(supplyTokens).to.have.lengthOf.above(0); + expect(supplyTokens.every(({ isSupplyEnabled }) => isSupplyEnabled)).to.be.true; + }); + }); + }); + + context('Test getBorrowTokens', function () { + chainIds.forEach((chainId) => { + it(common.toNetworkId(chainId), async function () { + const service = new Service(chainId); + const borrowTokens = await service.getBorrowTokens(); + expect(borrowTokens).to.have.lengthOf.above(0); + expect(borrowTokens.every(({ isBorrowEnabled }) => isBorrowEnabled)).to.be.true; }); }); }); diff --git a/src/logics/aave-v3/service.ts b/src/logics/aave-v3/service.ts index bbea225f..953dc173 100644 --- a/src/logics/aave-v3/service.ts +++ b/src/logics/aave-v3/service.ts @@ -1,18 +1,11 @@ import { - AToken__factory, DebtTokenBase__factory, PoolAddressesProvider__factory, PoolDataProvider, PoolDataProvider__factory, Pool__factory, } from './contracts'; -import { - FlashLoanAssetInfo, - FlashLoanConfiguration, - InterestRateMode, - ReserveTokens, - ReserveTokensAddress, -} from './types'; +import { FlashLoanAssetInfo, FlashLoanConfiguration, InterestRateMode, ReserveTokens } from './types'; import { PoolDataProviderInterface } from './contracts/PoolDataProvider'; import { PoolInterface } from './contracts/Pool'; import * as common from '@protocolink/common'; @@ -62,153 +55,135 @@ export class Service extends common.Web3Toolkit { return this.poolAddress; } - private assetAddresses?: string[]; + private reserveTokens?: ReserveTokens[]; + private reserveMap?: Record; + + async getReserveTokens() { + if (!this.reserveTokens || !this.reserveMap) { + const tokenAddresses: string[] = []; + const reserveTokens: ReserveTokens[] = []; + const reserveMap: Record = {}; - async getAssetAddresses() { - if (!this.assetAddresses) { const poolAddress = await this.getPoolAddress(); const assetAddresses = await Pool__factory.connect(poolAddress, this.provider).getReservesList(); - const calls: common.Multicall3.CallStruct[] = assetAddresses.map((assetAddress) => ({ - target: this.poolDataProvider.address, - callData: this.poolDataProviderIface.encodeFunctionData('getReserveConfigurationData', [assetAddress]), - })); + const calls: common.Multicall3.CallStruct[] = assetAddresses.flatMap((assetAddress) => [ + { + target: this.poolDataProvider.address, + callData: this.poolDataProviderIface.encodeFunctionData('getReserveConfigurationData', [assetAddress]), + }, + { + target: this.poolDataProvider.address, + callData: this.poolDataProviderIface.encodeFunctionData('getReserveTokensAddresses', [assetAddress]), + }, + ]); const { returnData } = await this.multicall3.callStatic.aggregate(calls); - this.assetAddresses = []; - for (let i = 0; i < assetAddresses.length; i++) { - const assetAddress = assetAddresses[i]; - const { isActive, isFrozen } = this.poolDataProviderIface.decodeFunctionResult( + assetAddresses.forEach((assetAddress, i) => { + const { isActive, isFrozen, borrowingEnabled } = this.poolDataProviderIface.decodeFunctionResult( 'getReserveConfigurationData', - returnData[i] + returnData[i * 2] ); - if (isActive && !isFrozen) this.assetAddresses.push(assetAddress); - } - } - return this.assetAddresses; - } + const { aTokenAddress, stableDebtTokenAddress, variableDebtTokenAddress } = + this.poolDataProviderIface.decodeFunctionResult('getReserveTokensAddresses', returnData[i * 2 + 1]); + + reserveMap[assetAddress] = { + isSupplyEnabled: isActive && !isFrozen, + isBorrowEnabled: isActive && !isFrozen && borrowingEnabled, + }; - private reserveTokensAddresses?: ReserveTokensAddress[]; + tokenAddresses.push(assetAddress, aTokenAddress, stableDebtTokenAddress, variableDebtTokenAddress); + }); - async getReserveTokensAddresses() { - if (!this.reserveTokensAddresses) { - const assetAddresses = await this.getAssetAddresses(); + const tokens = await this.getTokens(tokenAddresses); - const calls: common.Multicall3.CallStruct[] = assetAddresses.map((asset) => ({ - target: this.poolDataProvider.address, - callData: this.poolDataProviderIface.encodeFunctionData('getReserveTokensAddresses', [asset]), - })); - const { returnData } = await this.multicall3.callStatic.aggregate(calls); + for (let i = 0; i < tokens.length; i += 4) { + const asset = tokens[i]; + const aToken = tokens[i + 1]; + const stableDebtToken = tokens[i + 2]; + const variableDebtToken = tokens[i + 3]; - this.reserveTokensAddresses = []; - for (let i = 0; i < assetAddresses.length; i++) { - const assetAddress = assetAddresses[i]; - const { aTokenAddress, stableDebtTokenAddress, variableDebtTokenAddress } = - this.poolDataProviderIface.decodeFunctionResult('getReserveTokensAddresses', returnData[i]); - this.reserveTokensAddresses.push({ - assetAddress, - aTokenAddress, - stableDebtTokenAddress, - variableDebtTokenAddress, - }); + const reserveToken: ReserveTokens = { + ...reserveMap[asset.address], + asset, + aToken, + stableDebtToken, + variableDebtToken, + }; + + reserveTokens.push(reserveToken); + + reserveMap[asset.address] = reserveToken; + + // Add aToken address as key for quick lookup + reserveMap[aToken.address] = reserveToken; } + + this.reserveTokens = reserveTokens; + this.reserveMap = reserveMap; } - return this.reserveTokensAddresses; + return { reserveTokens: this.reserveTokens, reserveMap: this.reserveMap }; } - private assets?: common.Token[]; - async getAssets() { - if (!this.assets) { - const assetAddresses = await this.getAssetAddresses(); - this.assets = await this.getTokens(assetAddresses); - } - return this.assets; + const { reserveTokens } = await this.getReserveTokens(); + return reserveTokens.map(({ asset }) => asset); } - private aTokens?: common.Token[]; - async getATokens() { - if (!this.aTokens) { - const reserveTokensAddresses = await this.getReserveTokensAddresses(); - const aTokenAddresses = reserveTokensAddresses.map((reserveTokensAddress) => reserveTokensAddress.aTokenAddress); - this.aTokens = await this.getTokens(aTokenAddresses); - } - return this.aTokens; + const { reserveTokens } = await this.getReserveTokens(); + return reserveTokens.map(({ aToken }) => aToken); } - private reserveTokens?: ReserveTokens[]; - - async getReserveTokens() { - if (!this.reserveTokens) { - const reserveTokensAddresses = await this.getReserveTokensAddresses(); - const tokenAddresses = reserveTokensAddresses.reduce((accumulator, reserveTokensAddress) => { - accumulator.push(reserveTokensAddress.assetAddress); - accumulator.push(reserveTokensAddress.aTokenAddress); - accumulator.push(reserveTokensAddress.stableDebtTokenAddress); - accumulator.push(reserveTokensAddress.variableDebtTokenAddress); - return accumulator; - }, []); - const tokens = await this.getTokens(tokenAddresses); - - this.reserveTokens = []; - let j = 0; - for (let i = 0; i < reserveTokensAddresses.length; i++) { - const asset = tokens[j]; - j++; - const aToken = tokens[j]; - j++; - const stableDebtToken = tokens[j]; - j++; - const variableDebtToken = tokens[j]; - j++; - this.reserveTokens.push({ asset, aToken, stableDebtToken, variableDebtToken }); - } - } + async getSupplyTokens() { + const { reserveTokens } = await this.getReserveTokens(); + + // GHO cannot be supplied to the Aave V3 Ethereum market. + // This restriction is not reflected in the poolDataProvider contract, + // so we need to filter it out manually + return reserveTokens.filter(({ isSupplyEnabled, asset }) => { + if (!isSupplyEnabled) return false; + if (this.chainId === common.ChainId.mainnet && asset.symbol === 'GHO') return false; + return true; + }); + } - return this.reserveTokens; + async getBorrowTokens() { + const { reserveTokens } = await this.getReserveTokens(); + return reserveTokens.filter(({ isBorrowEnabled }) => isBorrowEnabled); } async toAToken(asset: common.Token) { - const { aTokenAddress } = await this.poolDataProvider.getReserveTokensAddresses(asset.wrapped.address); - invariant(aTokenAddress !== constants.AddressZero, `unsupported asset: ${asset.wrapped.address}`); + const { reserveMap } = await this.getReserveTokens(); + + const aToken = reserveMap[asset.wrapped.address]?.aToken; + invariant(aToken?.address !== constants.AddressZero, `unsupported asset: ${asset.wrapped.address}`); - return this.getToken(aTokenAddress); + return aToken; } async toATokens(assets: common.Token[]) { - const calls: common.Multicall3.CallStruct[] = assets.map((asset) => ({ - target: this.poolDataProvider.address, - callData: this.poolDataProviderIface.encodeFunctionData('getReserveTokensAddresses', [asset.wrapped.address]), - })); - const { returnData } = await this.multicall3.callStatic.aggregate(calls); - - const aTokenAddresses: string[] = []; - for (let i = 0; i < assets.length; i++) { - const { aTokenAddress } = this.poolDataProviderIface.decodeFunctionResult( - 'getReserveTokensAddresses', - returnData[i] - ); - invariant(aTokenAddress !== constants.AddressZero, `unsupported asset: ${assets[i].wrapped.address}`); - aTokenAddresses.push(aTokenAddress); - } - - return this.getTokens(aTokenAddresses); + return Promise.all(assets.map((asset) => this.toAToken(asset))); } async toAsset(aToken: common.Token) { - const assetAddress = await AToken__factory.connect(aToken.address, this.provider).UNDERLYING_ASSET_ADDRESS(); - return this.getToken(assetAddress); + const { reserveMap } = await this.getReserveTokens(); + + const asset = reserveMap[aToken.address]?.asset; + invariant(asset, `unsupported aToken: ${aToken.address}`); + + return asset; } async getDebtTokenAddress(asset: common.Token, interestRateMode: InterestRateMode) { - const { stableDebtTokenAddress, variableDebtTokenAddress } = await this.poolDataProvider.getReserveTokensAddresses( - asset.wrapped.address - ); + const { reserveMap } = await this.getReserveTokens(); + + const { stableDebtToken, variableDebtToken } = reserveMap[asset.wrapped.address]; + invariant(stableDebtToken || variableDebtToken, `unsupported aToken: ${asset.wrapped.address}`); - return interestRateMode === InterestRateMode.variable ? variableDebtTokenAddress : stableDebtTokenAddress; + return interestRateMode === InterestRateMode.variable ? variableDebtToken.address : stableDebtToken.address; } async getFlashLoanPremiumTotal() { diff --git a/src/logics/aave-v3/types.ts b/src/logics/aave-v3/types.ts index 4408ccce..04ad2fae 100644 --- a/src/logics/aave-v3/types.ts +++ b/src/logics/aave-v3/types.ts @@ -1,17 +1,12 @@ import * as common from '@protocolink/common'; -export interface ReserveTokensAddress { - assetAddress: string; - aTokenAddress: string; - stableDebtTokenAddress: string; - variableDebtTokenAddress: string; -} - export interface ReserveTokens { asset: common.Token; aToken: common.Token; stableDebtToken: common.Token; variableDebtToken: common.Token; + isSupplyEnabled: boolean; + isBorrowEnabled: boolean; } export enum InterestRateMode { diff --git a/src/logics/openocean-v2/logic.swap-token.test.ts b/src/logics/openocean-v2/logic.swap-token.test.ts index 1e1ab83d..632c3465 100644 --- a/src/logics/openocean-v2/logic.swap-token.test.ts +++ b/src/logics/openocean-v2/logic.swap-token.test.ts @@ -31,7 +31,7 @@ describe('OpenOceanV2 SwapTokenLogic', function () { { chainId: common.ChainId.metis, fields: { - input: new common.TokenAmount(common.metisTokens['METIS(ERC20)'], '1'), + input: new common.TokenAmount(common.metisTokens.METIS, '1'), output: new common.TokenAmount(common.metisTokens['m.USDC'], '0'), slippage: 100, }, @@ -41,7 +41,7 @@ describe('OpenOceanV2 SwapTokenLogic', function () { chainId: common.ChainId.metis, fields: { input: new common.TokenAmount(common.metisTokens['m.USDC'], '1'), - output: new common.TokenAmount(common.metisTokens['METIS(ERC20)'], '0'), + output: new common.TokenAmount(common.metisTokens.METIS, '0'), slippage: 100, }, options: { account: '0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa' }, diff --git a/src/logics/radiant-v2/configs.ts b/src/logics/radiant-v2/configs.ts index f1d5e092..51c54fc0 100644 --- a/src/logics/radiant-v2/configs.ts +++ b/src/logics/radiant-v2/configs.ts @@ -1,5 +1,7 @@ import * as common from '@protocolink/common'; +export const protocolId = 'radiant-v2'; + type ContractNames = 'ProtocolDataProvider' | 'RadiantV2FlashLoanCallback'; export interface Config { diff --git a/src/logics/radiant-v2/logic.borrow.ts b/src/logics/radiant-v2/logic.borrow.ts index 0bc6f40b..40bec848 100644 --- a/src/logics/radiant-v2/logic.borrow.ts +++ b/src/logics/radiant-v2/logic.borrow.ts @@ -1,53 +1,23 @@ -import { InterestRateMode } from './types'; -import { LendingPool__factory } from './contracts'; import { Service } from './service'; -import * as common from '@protocolink/common'; +import * as aavev2 from 'src/modules/aavev2'; import * as core from '@protocolink/core'; -import { supportedChainIds } from './configs'; +import { protocolId, supportedChainIds } from './configs'; +import { providers } from 'ethers'; -export type BorrowLogicTokenList = common.Token[]; +export type BorrowLogicFields = aavev2.BorrowLogicFields; -export type BorrowLogicFields = core.TokenOutFields<{ interestRateMode: InterestRateMode; referralCode?: number }>; +export type BorrowLogicOptions = aavev2.BorrowLogicOptions; -export type BorrowLogicOptions = Pick; +export type BorrowLogicTokenList = aavev2.BorrowLogicTokenList; -export class BorrowLogic extends core.Logic implements core.LogicTokenListInterface, core.LogicBuilderInterface { - static id = 'borrow'; - static protocolId = 'radiant-v2'; +export class BorrowLogic + extends aavev2.BorrowLogic + implements core.LogicTokenListInterface, core.LogicBuilderInterface +{ + static protocolId = protocolId; static readonly supportedChainIds = supportedChainIds; - async getTokenList() { - const service = new Service(this.chainId, this.provider); - const tokens = await service.getAssets(); - - const tokenList: BorrowLogicTokenList = []; - for (const token of tokens) { - if (token.isWrapped) { - tokenList.push(token.unwrapped); - } - tokenList.push(token); - } - - return tokenList; - } - - async build(fields: BorrowLogicFields, options: BorrowLogicOptions) { - const { output, interestRateMode, referralCode = 0 } = fields; - const { account } = options; - - const tokenOut = output.token.wrapped; - - const service = new Service(this.chainId, this.provider); - const to = await service.getLendingPoolAddress(); - const data = LendingPool__factory.createInterface().encodeFunctionData('borrow', [ - tokenOut.address, - output.amountWei, - interestRateMode, - referralCode, - account, - ]); - const wrapMode = output.token.isNative ? core.WrapMode.unwrapAfter : core.WrapMode.none; - - return core.newLogic({ to, data, wrapMode }); + constructor(chainId: number, provider?: providers.Provider) { + super({ chainId, provider, service: new Service(chainId, provider) }); } } diff --git a/src/logics/radiant-v2/logic.deposit.ts b/src/logics/radiant-v2/logic.deposit.ts index 60c4b5c7..33086a84 100644 --- a/src/logics/radiant-v2/logic.deposit.ts +++ b/src/logics/radiant-v2/logic.deposit.ts @@ -1,68 +1,27 @@ -import { LendingPool__factory } from './contracts'; import { Service } from './service'; -import * as common from '@protocolink/common'; -import * as core from '@protocolink/core'; -import { supportedChainIds } from './configs'; +import * as aavev2 from 'src/modules/aavev2'; +import { protocolId, supportedChainIds } from './configs'; +import { providers } from 'ethers'; -export type DepositLogicTokenList = [common.Token, common.Token][]; +export type DepositLogicTokenList = aavev2.DepositLogicTokenList; -export type DepositLogicParams = core.TokenToTokenExactInParams; +export type DepositLogicParams = aavev2.DepositLogicParams; -export type DepositLogicFields = core.TokenToTokenExactInFields<{ referralCode?: number }>; +export type DepositLogicFields = aavev2.DepositLogicFields; -export type DepositLogicOptions = Pick; +export type DepositLogicOptions = aavev2.DepositLogicOptions; -export class DepositLogic - extends core.Logic - implements core.LogicTokenListInterface, core.LogicOracleInterface, core.LogicBuilderInterface -{ - static id = 'deposit'; - static protocolId = 'radiant-v2'; +export class DepositLogic extends aavev2.DepositLogics { + static protocolId = protocolId; static readonly supportedChainIds = supportedChainIds; - async getTokenList() { - const service = new Service(this.chainId, this.provider); - const reserveTokens = await service.getReserveTokens(); - - const tokenList: DepositLogicTokenList = []; - for (const reserveToken of reserveTokens) { - if (reserveToken.asset.isWrapped) { - tokenList.push([reserveToken.asset.unwrapped, reserveToken.rToken]); - } - tokenList.push([reserveToken.asset, reserveToken.rToken]); - } - - return tokenList; + constructor(chainId: number, provider?: providers.Provider) { + super({ chainId, provider, service: new Service(chainId, provider) }); } - async quote(params: DepositLogicParams) { - const { input, tokenOut } = params; - const output = new common.TokenAmount(tokenOut, input.amount); - - return { input, output }; - } - - async build(fields: DepositLogicFields, options: DepositLogicOptions) { - const { input, balanceBps, referralCode = 0 } = fields; - const { account } = options; - - const tokenIn = input.token.wrapped; - const agent = await this.calcAgent(account); - - const service = new Service(this.chainId, this.provider); - const to = await service.getLendingPoolAddress(); - const data = LendingPool__factory.createInterface().encodeFunctionData('deposit', [ - tokenIn.address, - input.amountWei, - agent, - referralCode, - ]); - const amountOffset = balanceBps ? common.getParamOffset(1) : undefined; - const inputs = [ - core.newLogicInput({ input: new common.TokenAmount(tokenIn, input.amount), balanceBps, amountOffset }), - ]; - const wrapMode = input.token.isNative ? core.WrapMode.wrapBefore : core.WrapMode.none; + async getTokenList() { + const reserveTokens = await this.service.getSupplyTokens(); - return core.newLogic({ to, data, inputs, wrapMode }); + return aavev2.createDepositTokenList(reserveTokens, 'rToken'); } } diff --git a/src/logics/radiant-v2/logic.repay.ts b/src/logics/radiant-v2/logic.repay.ts index 60b473ab..85f3ecfb 100644 --- a/src/logics/radiant-v2/logic.repay.ts +++ b/src/logics/radiant-v2/logic.repay.ts @@ -1,73 +1,23 @@ -import { InterestRateMode } from './types'; -import { LendingPool__factory } from './contracts'; import { Service } from './service'; -import * as common from '@protocolink/common'; +import * as aavev2 from 'src/modules/aavev2'; import * as core from '@protocolink/core'; -import { supportedChainIds } from './configs'; +import { protocolId, supportedChainIds } from './configs'; +import { providers } from 'ethers'; -export type RepayLogicTokenList = common.Token[]; +export type RepayLogicTokenList = aavev2.RepayLogicTokenList; -export type RepayLogicParams = core.RepayParams<{ interestRateMode: InterestRateMode }>; +export type RepayLogicParams = aavev2.RepayLogicParams; -export type RepayLogicFields = core.RepayFields<{ interestRateMode: InterestRateMode }>; +export type RepayLogicFields = aavev2.RepayLogicFields; export class RepayLogic - extends core.Logic + extends aavev2.RepayLogic implements core.LogicTokenListInterface, core.LogicOracleInterface, core.LogicBuilderInterface { - static id = 'repay'; - static protocolId = 'radiant-v2'; + static protocolId = protocolId; static readonly supportedChainIds = supportedChainIds; - async getTokenList() { - const service = new Service(this.chainId, this.provider); - const tokens = await service.getAssets(); - - const tokenList: RepayLogicTokenList = []; - for (const token of tokens) { - if (token.isWrapped) { - tokenList.push(token.unwrapped); - } - tokenList.push(token); - } - - return tokenList; - } - - async quote(params: RepayLogicParams) { - const { borrower, tokenIn, interestRateMode } = params; - - const service = new Service(this.chainId, this.provider); - const { currentStableDebt, currentVariableDebt } = await service.protocolDataProvider.getUserReserveData( - tokenIn.wrapped.address, - borrower - ); - const currentDebt = interestRateMode === InterestRateMode.variable ? currentVariableDebt : currentStableDebt; - const amountWei = common.calcSlippage(currentDebt, -1); // slightly higher than the current borrowed amount - const input = new common.TokenAmount(tokenIn).setWei(amountWei); - - return { borrower, interestRateMode, input }; - } - - async build(fields: RepayLogicFields) { - const { input, interestRateMode, borrower, balanceBps } = fields; - - const tokenIn = input.token.wrapped; - - const service = new Service(this.chainId, this.provider); - const to = await service.getLendingPoolAddress(); - const data = LendingPool__factory.createInterface().encodeFunctionData('repay', [ - tokenIn.address, - input.amountWei, - interestRateMode, - borrower, - ]); - const amountOffset = balanceBps ? common.getParamOffset(1) : undefined; - const inputs = [ - core.newLogicInput({ input: new common.TokenAmount(tokenIn, input.amount), balanceBps, amountOffset }), - ]; - const wrapMode = input.token.isNative ? core.WrapMode.wrapBefore : core.WrapMode.none; - - return core.newLogic({ to, data, inputs, wrapMode }); + constructor(chainId: number, provider?: providers.Provider) { + super({ chainId, provider, service: new Service(chainId, provider) }); } } diff --git a/src/logics/radiant-v2/logic.withdraw.ts b/src/logics/radiant-v2/logic.withdraw.ts index 46567db9..4400122a 100644 --- a/src/logics/radiant-v2/logic.withdraw.ts +++ b/src/logics/radiant-v2/logic.withdraw.ts @@ -1,65 +1,31 @@ -import { LendingPool__factory } from './contracts'; import { Service } from './service'; -import * as common from '@protocolink/common'; +import * as aavev2 from 'src/modules/aavev2'; import * as core from '@protocolink/core'; -import { supportedChainIds } from './configs'; +import { protocolId, supportedChainIds } from './configs'; +import { providers } from 'ethers'; -export type WithdrawLogicTokenList = [common.Token, common.Token][]; +export type WithdrawLogicTokenList = aavev2.WithdrawLogicTokenList; -export type WithdrawLogicParams = core.TokenToTokenExactInParams; +export type WithdrawLogicParams = aavev2.WithdrawLogicParams; -export type WithdrawLogicFields = core.TokenToTokenExactInFields; +export type WithdrawLogicFields = aavev2.WithdrawLogicFields; -export type WithdrawLogicOptions = Pick; +export type WithdrawLogicOptions = aavev2.WithdrawLogicOptions; export class WithdrawLogic - extends core.Logic + extends aavev2.WithdrawLogic implements core.LogicTokenListInterface, core.LogicOracleInterface, core.LogicBuilderInterface { - static id = 'withdraw'; - static protocolId = 'radiant-v2'; + static protocolId = protocolId; static readonly supportedChainIds = supportedChainIds; - async getTokenList() { - const service = new Service(this.chainId, this.provider); - const reserveTokens = await service.getReserveTokens(); - - const tokenList: WithdrawLogicTokenList = []; - for (const reserveToken of reserveTokens) { - if (reserveToken.asset.isWrapped) { - tokenList.push([reserveToken.rToken, reserveToken.asset.unwrapped]); - } - tokenList.push([reserveToken.rToken, reserveToken.asset]); - } - - return tokenList; + constructor(chainId: number, provider?: providers.Provider) { + super({ chainId, provider, service: new Service(chainId, provider) }); } - async quote(params: WithdrawLogicParams) { - const { input, tokenOut } = params; - const output = new common.TokenAmount(tokenOut, input.amount); - - return { input, output }; - } - - async build(fields: WithdrawLogicFields, options: WithdrawLogicOptions) { - const { input, output, balanceBps } = fields; - const { account } = options; - - const tokenOut = output.token.wrapped; - const agent = await this.calcAgent(account); - - const service = new Service(this.chainId, this.provider); - const to = await service.getLendingPoolAddress(); - const data = LendingPool__factory.createInterface().encodeFunctionData('withdraw', [ - tokenOut.address, - input.amountWei, - agent, - ]); - const amountOffset = balanceBps ? common.getParamOffset(1) : undefined; - const inputs = [core.newLogicInput({ input, balanceBps, amountOffset })]; - const wrapMode = output.token.isNative ? core.WrapMode.unwrapAfter : core.WrapMode.none; + async getTokenList() { + const reserveTokens = await this.service.getSupplyTokens(); - return core.newLogic({ to, data, inputs, wrapMode }); + return aavev2.createWithdrawTokenList(reserveTokens, 'rToken'); } } diff --git a/src/logics/radiant-v2/scripts/refresh-tokens-data.ts b/src/logics/radiant-v2/scripts/refresh-tokens-data.ts deleted file mode 100644 index 1010c4d8..00000000 --- a/src/logics/radiant-v2/scripts/refresh-tokens-data.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { Service } from '../service'; -import * as common from '@protocolink/common'; -import fs from 'fs-extra'; -import { resolve } from 'path'; - -export default async () => { - const chainIds = [common.ChainId.arbitrum]; - - for (const chainId of chainIds) { - const service = new Service(chainId); - const reserveTokens = await service.getReserveTokens(); - - const tokenMap = reserveTokens.reduce((accumulator, reserveToken) => { - if (reserveToken.asset.isWrapped) { - const unwrapped = reserveToken.asset.unwrapped; - accumulator[unwrapped.symbol] = unwrapped; - } - accumulator[reserveToken.asset.symbol] = reserveToken.asset; - accumulator[reserveToken.rToken.symbol] = reserveToken.rToken; - return accumulator; - }, {} as Record); - - const tokenDataPath = resolve(__dirname, '..', 'tokens', 'data', `${common.toNetworkId(chainId)}.json`); - fs.outputJSONSync(tokenDataPath, tokenMap, { spaces: 2 }); - } -}; diff --git a/src/logics/radiant-v2/service.test.ts b/src/logics/radiant-v2/service.test.ts index 06cf1412..b6bae280 100644 --- a/src/logics/radiant-v2/service.test.ts +++ b/src/logics/radiant-v2/service.test.ts @@ -7,12 +7,36 @@ import omit from 'lodash/omit'; describe('RadiantV2 Service', () => { const chainIds = [common.ChainId.arbitrum]; - context('Test getReserveTokensAddresses', () => { + context('Test getReserveTokens', () => { chainIds.forEach((chainId) => { it(common.toNetworkId(chainId), async () => { const service = new Service(chainId); - const reserveTokensAddresses = await service.getReserveTokensAddresses(); - expect(reserveTokensAddresses).to.have.lengthOf.above(0); + const { reserveTokens, reserveMap } = await service.getReserveTokens(); + + expect(reserveTokens).to.have.lengthOf.above(0); + expect(Object.keys(reserveMap)).to.have.lengthOf.above(0); + }); + }); + }); + + context('Test getSupplyTokens', function () { + chainIds.forEach((chainId) => { + it(common.toNetworkId(chainId), async function () { + const service = new Service(chainId); + const supplyTokens = await service.getSupplyTokens(); + expect(supplyTokens).to.have.lengthOf.above(0); + expect(supplyTokens.every(({ isSupplyEnabled }) => isSupplyEnabled)).to.be.true; + }); + }); + }); + + context('Test getBorrowTokens', function () { + chainIds.forEach((chainId) => { + it(common.toNetworkId(chainId), async function () { + const service = new Service(chainId); + const borrowTokens = await service.getBorrowTokens(); + expect(borrowTokens).to.have.lengthOf.above(0); + expect(borrowTokens.every(({ isBorrowEnabled }) => isBorrowEnabled)).to.be.true; }); }); }); diff --git a/src/logics/radiant-v2/service.ts b/src/logics/radiant-v2/service.ts index 93d1b40f..1e0d29aa 100644 --- a/src/logics/radiant-v2/service.ts +++ b/src/logics/radiant-v2/service.ts @@ -1,18 +1,11 @@ import { - AToken__factory, DebtTokenBase__factory, LendingPoolAddressesProvider__factory, LendingPool__factory, ProtocolDataProvider, ProtocolDataProvider__factory, } from './contracts'; -import { - FlashLoanAssetInfo, - FlashLoanConfiguration, - InterestRateMode, - ReserveTokens, - ReserveTokensAddress, -} from './types'; +import { FlashLoanAssetInfo, FlashLoanConfiguration, InterestRateMode, ReserveTokens } from './types'; import { LendingPoolInterface } from './contracts/LendingPool'; import { ProtocolDataProviderInterface } from './contracts/ProtocolDataProvider'; import * as common from '@protocolink/common'; @@ -65,150 +58,134 @@ export class Service extends common.Web3Toolkit { return this.lendingPoolAddress; } - private assetAddresses?: string[]; + private reserveTokens?: ReserveTokens[]; + private reserveMap?: Record; + + async getReserveTokens() { + if (!this.reserveTokens || !this.reserveMap) { + const tokenAddresses: string[] = []; + const reserveTokens: ReserveTokens[] = []; + const reserveMap: Record = {}; - async getAssetAddresses() { - if (!this.assetAddresses) { const lendingPoolAddress = await this.getLendingPoolAddress(); const assetAddresses = await LendingPool__factory.connect(lendingPoolAddress, this.provider).getReservesList(); - const calls: common.Multicall3.CallStruct[] = assetAddresses.map((assetAddress) => ({ - target: this.protocolDataProvider.address, - callData: this.protocolDataProviderIface.encodeFunctionData('getReserveConfigurationData', [assetAddress]), - })); + const calls: common.Multicall3.CallStruct[] = assetAddresses.flatMap((assetAddress) => [ + { + target: this.protocolDataProvider.address, + callData: this.protocolDataProviderIface.encodeFunctionData('getReserveConfigurationData', [assetAddress]), + }, + { + target: this.protocolDataProvider.address, + callData: this.protocolDataProviderIface.encodeFunctionData('getReserveTokensAddresses', [assetAddress]), + }, + ]); const { returnData } = await this.multicall3.callStatic.aggregate(calls); - this.assetAddresses = []; - for (let i = 0; i < assetAddresses.length; i++) { - const assetAddress = assetAddresses[i]; - const { isActive, isFrozen } = this.protocolDataProviderIface.decodeFunctionResult( + assetAddresses.forEach((assetAddress, i) => { + const { isActive, isFrozen, borrowingEnabled } = this.protocolDataProviderIface.decodeFunctionResult( 'getReserveConfigurationData', - returnData[i] + returnData[i * 2] ); - if (isActive && !isFrozen) this.assetAddresses.push(assetAddress); - } - } - return this.assetAddresses; - } + const { rTokenAddress, stableDebtTokenAddress, variableDebtTokenAddress } = + this.protocolDataProviderIface.decodeFunctionResult('getReserveTokensAddresses', returnData[i * 2 + 1]); - private reserveTokensAddresses?: ReserveTokensAddress[]; + reserveMap[assetAddress] = { + isSupplyEnabled: isActive && !isFrozen, + isBorrowEnabled: isActive && !isFrozen && borrowingEnabled, + }; - async getReserveTokensAddresses() { - if (!this.reserveTokensAddresses) { - const assetAddresses = await this.getAssetAddresses(); + tokenAddresses.push(assetAddress, rTokenAddress, stableDebtTokenAddress, variableDebtTokenAddress); + }); - const calls: common.Multicall3.CallStruct[] = assetAddresses.map((asset) => ({ - target: this.protocolDataProvider.address, - callData: this.protocolDataProviderIface.encodeFunctionData('getReserveTokensAddresses', [asset]), - })); - const { returnData } = await this.multicall3.callStatic.aggregate(calls); + const tokens = await this.getTokens(tokenAddresses); - this.reserveTokensAddresses = []; - for (let i = 0; i < assetAddresses.length; i++) { - const assetAddress = assetAddresses[i]; - const { rTokenAddress, stableDebtTokenAddress, variableDebtTokenAddress } = - this.protocolDataProviderIface.decodeFunctionResult('getReserveTokensAddresses', returnData[i]); - this.reserveTokensAddresses.push({ - assetAddress, - rTokenAddress, - stableDebtTokenAddress, - variableDebtTokenAddress, - }); - } - } + for (let i = 0; i < tokens.length; i += 4) { + const asset = tokens[i]; + const rToken = tokens[i + 1]; + const stableDebtToken = tokens[i + 2]; + const variableDebtToken = tokens[i + 3]; - return this.reserveTokensAddresses; - } + const reserveToken: ReserveTokens = { + ...reserveMap[asset.address], + asset, + rToken, + stableDebtToken, + variableDebtToken, + }; - private assets?: common.Token[]; + reserveTokens.push(reserveToken); - async getAssets() { - if (!this.assets) { - const assetAddresses = await this.getAssetAddresses(); - this.assets = await this.getTokens(assetAddresses); - } - return this.assets; - } + reserveMap[asset.address] = reserveToken; - private rTokens?: common.Token[]; + // Add rToken address as key for quick lookup + reserveMap[rToken.address] = reserveToken; + } - async getRTokens() { - if (!this.rTokens) { - const reserveTokensAddresses = await this.getReserveTokensAddresses(); - const rTokenAddresses = reserveTokensAddresses.map((reserveTokensAddress) => reserveTokensAddress.rTokenAddress); - this.rTokens = await this.getTokens(rTokenAddresses); + this.reserveTokens = reserveTokens; + this.reserveMap = reserveMap; } - return this.rTokens; + + return { reserveTokens: this.reserveTokens, reserveMap: this.reserveMap }; } - private reserveTokens?: ReserveTokens[]; + async getAssets() { + const { reserveTokens } = await this.getReserveTokens(); + return reserveTokens.map(({ asset }) => asset); + } - async getReserveTokens() { - if (!this.reserveTokens) { - const reserveTokensAddresses = await this.getReserveTokensAddresses(); - const tokenAddresses = reserveTokensAddresses.reduce((accumulator, reserveTokensAddress) => { - accumulator.push(reserveTokensAddress.assetAddress); - accumulator.push(reserveTokensAddress.rTokenAddress); - accumulator.push(reserveTokensAddress.stableDebtTokenAddress); - accumulator.push(reserveTokensAddress.variableDebtTokenAddress); - return accumulator; - }, []); - const tokens = await this.getTokens(tokenAddresses); + async getATokens() { + const { reserveTokens } = await this.getReserveTokens(); + return reserveTokens.map(({ rToken }) => rToken); + } - this.reserveTokens = []; - let j = 0; - for (let i = 0; i < reserveTokensAddresses.length; i++) { - const asset = tokens[j]; - j++; - const rToken = tokens[j]; - j++; - const stableDebtToken = tokens[j]; - j++; - const variableDebtToken = tokens[j]; - j++; - this.reserveTokens.push({ asset, rToken, stableDebtToken, variableDebtToken }); - } - } + async getSupplyTokens() { + const { reserveTokens } = await this.getReserveTokens(); + return reserveTokens.filter(({ isSupplyEnabled }) => isSupplyEnabled); + } - return this.reserveTokens; + async getBorrowTokens() { + const { reserveTokens } = await this.getReserveTokens(); + return reserveTokens.filter(({ isBorrowEnabled }) => isBorrowEnabled); } async toRToken(asset: common.Token) { - const { rTokenAddress } = await this.protocolDataProvider.getReserveTokensAddresses(asset.wrapped.address); - return this.getToken(rTokenAddress); + const { reserveMap } = await this.getReserveTokens(); + + const rToken = reserveMap[asset.wrapped.address]?.rToken; + invariant(rToken?.address !== constants.AddressZero, `unsupported asset: ${asset.wrapped.address}`); + + return rToken; } async toRTokens(assets: common.Token[]) { - const calls: common.Multicall3.CallStruct[] = assets.map((asset) => ({ - target: this.protocolDataProvider.address, - callData: this.protocolDataProviderIface.encodeFunctionData('getReserveTokensAddresses', [asset.wrapped.address]), - })); - const { returnData } = await this.multicall3.callStatic.aggregate(calls); + const { reserveMap } = await this.getReserveTokens(); - const rTokenAddresses: string[] = []; - for (let i = 0; i < assets.length; i++) { - const { rTokenAddress } = this.protocolDataProviderIface.decodeFunctionResult( - 'getReserveTokensAddresses', - returnData[i] - ); - invariant(rTokenAddress !== constants.AddressZero, `unsupported asset: ${assets[i].wrapped.address}`); - rTokenAddresses.push(rTokenAddress); - } + return assets.map((asset) => { + const rToken = reserveMap[asset.wrapped.address]?.rToken; + invariant(rToken?.address !== constants.AddressZero, `unsupported asset: ${asset.wrapped.address}`); - return this.getTokens(rTokenAddresses); + return rToken; + }); } async toAsset(rToken: common.Token) { - const assetAddress = await AToken__factory.connect(rToken.address, this.provider).UNDERLYING_ASSET_ADDRESS(); - return this.getToken(assetAddress); + const { reserveMap } = await this.getReserveTokens(); + + const asset = reserveMap[rToken.address]?.asset; + invariant(asset, `unsupported aToken: ${rToken.address}`); + + return asset; } async getDebtTokenAddress(asset: common.Token, interestRateMode: InterestRateMode) { - const { stableDebtTokenAddress, variableDebtTokenAddress } = - await this.protocolDataProvider.getReserveTokensAddresses(asset.wrapped.address); + const { reserveMap } = await this.getReserveTokens(); + + const { stableDebtToken, variableDebtToken } = reserveMap[asset.wrapped.address]; + invariant(stableDebtToken || variableDebtToken, `unsupported aToken: ${asset.wrapped.address}`); - return interestRateMode === InterestRateMode.variable ? variableDebtTokenAddress : stableDebtTokenAddress; + return interestRateMode === InterestRateMode.variable ? variableDebtToken.address : stableDebtToken.address; } async getFlashLoanPremiumTotal() { diff --git a/src/logics/radiant-v2/types.ts b/src/logics/radiant-v2/types.ts index f7b9a177..85d6bb77 100644 --- a/src/logics/radiant-v2/types.ts +++ b/src/logics/radiant-v2/types.ts @@ -1,17 +1,12 @@ import * as common from '@protocolink/common'; -export interface ReserveTokensAddress { - assetAddress: string; - rTokenAddress: string; - stableDebtTokenAddress: string; - variableDebtTokenAddress: string; -} - export interface ReserveTokens { asset: common.Token; rToken: common.Token; stableDebtToken: common.Token; variableDebtToken: common.Token; + isSupplyEnabled: boolean; + isBorrowEnabled: boolean; } export enum InterestRateMode { diff --git a/src/logics/spark/configs.ts b/src/logics/spark/configs.ts index 4d568822..7571f6ce 100644 --- a/src/logics/spark/configs.ts +++ b/src/logics/spark/configs.ts @@ -1,5 +1,7 @@ import * as common from '@protocolink/common'; +export const protocolId = 'spark'; + type ContractNames = 'PoolDataProvider' | 'SparkFlashLoanCallback'; export interface Config { diff --git a/src/logics/spark/logic.borrow.ts b/src/logics/spark/logic.borrow.ts index 2469de1b..1070ee6f 100644 --- a/src/logics/spark/logic.borrow.ts +++ b/src/logics/spark/logic.borrow.ts @@ -1,53 +1,23 @@ -import { InterestRateMode } from './types'; -import { Pool__factory } from './contracts'; import { Service } from './service'; -import * as common from '@protocolink/common'; +import * as aavev3 from 'src/modules/aavev3'; import * as core from '@protocolink/core'; -import { supportedChainIds } from './configs'; +import { protocolId, supportedChainIds } from './configs'; +import { providers } from 'ethers'; -export type BorrowLogicTokenList = common.Token[]; +export type BorrowLogicTokenList = aavev3.BorrowLogicTokenList; -export type BorrowLogicFields = core.TokenOutFields<{ interestRateMode: InterestRateMode; referralCode?: number }>; +export type BorrowLogicFields = aavev3.BorrowLogicFields; -export type BorrowLogicOptions = Pick; +export type BorrowLogicOptions = aavev3.BorrowLogicOptions; -export class BorrowLogic extends core.Logic implements core.LogicTokenListInterface, core.LogicBuilderInterface { - static id = 'borrow'; - static protocolId = 'spark'; +export class BorrowLogic + extends aavev3.BorrowLogic + implements core.LogicTokenListInterface, core.LogicBuilderInterface +{ + static protocolId = protocolId; static readonly supportedChainIds = supportedChainIds; - async getTokenList() { - const service = new Service(this.chainId, this.provider); - const tokens = await service.getAssets(); - - const tokenList: BorrowLogicTokenList = []; - for (const token of tokens) { - if (token.isWrapped) { - tokenList.push(token.unwrapped); - } - tokenList.push(token); - } - - return tokenList; - } - - async build(fields: BorrowLogicFields, options: BorrowLogicOptions) { - const { output, interestRateMode, referralCode = 0 } = fields; - const { account } = options; - - const tokenOut = output.token.wrapped; - - const service = new Service(this.chainId, this.provider); - const to = await service.getPoolAddress(); - const data = Pool__factory.createInterface().encodeFunctionData('borrow', [ - tokenOut.address, - output.amountWei, - interestRateMode, - referralCode, - account, - ]); - const wrapMode = output.token.isNative ? core.WrapMode.unwrapAfter : core.WrapMode.none; - - return core.newLogic({ to, data, wrapMode }); + constructor(chainId: number, provider?: providers.Provider) { + super({ chainId, provider, service: new Service(chainId, provider) }); } } diff --git a/src/logics/spark/logic.repay.ts b/src/logics/spark/logic.repay.ts index 121e9a76..f3b67ede 100644 --- a/src/logics/spark/logic.repay.ts +++ b/src/logics/spark/logic.repay.ts @@ -1,73 +1,23 @@ -import { InterestRateMode } from './types'; -import { Pool__factory } from './contracts'; import { Service } from './service'; -import * as common from '@protocolink/common'; +import * as aavev3 from 'src/modules/aavev3'; import * as core from '@protocolink/core'; -import { supportedChainIds } from './configs'; +import { protocolId, supportedChainIds } from './configs'; +import { providers } from 'ethers'; -export type RepayLogicTokenList = common.Token[]; +export type RepayLogicTokenList = aavev3.RepayLogicTokenList; -export type RepayLogicParams = core.RepayParams<{ interestRateMode: InterestRateMode }>; +export type RepayLogicParams = aavev3.RepayLogicParams; -export type RepayLogicFields = core.RepayFields<{ interestRateMode: InterestRateMode }>; +export type RepayLogicFields = aavev3.RepayLogicFields; export class RepayLogic - extends core.Logic + extends aavev3.RepayLogic implements core.LogicTokenListInterface, core.LogicOracleInterface, core.LogicBuilderInterface { - static id = 'repay'; - static protocolId = 'spark'; + static protocolId = protocolId; static readonly supportedChainIds = supportedChainIds; - async getTokenList() { - const service = new Service(this.chainId, this.provider); - const tokens = await service.getAssets(); - - const tokenList: RepayLogicTokenList = []; - for (const token of tokens) { - if (token.isWrapped) { - tokenList.push(token.unwrapped); - } - tokenList.push(token); - } - - return tokenList; - } - - async quote(params: RepayLogicParams) { - const { borrower, tokenIn, interestRateMode } = params; - - const service = new Service(this.chainId, this.provider); - const { currentStableDebt, currentVariableDebt } = await service.poolDataProvider.getUserReserveData( - tokenIn.wrapped.address, - borrower - ); - const currentDebt = interestRateMode === InterestRateMode.variable ? currentVariableDebt : currentStableDebt; - const amountWei = common.calcSlippage(currentDebt, -1); // slightly higher than the current borrowed amount - const input = new common.TokenAmount(tokenIn).setWei(amountWei); - - return { borrower, interestRateMode, input }; - } - - async build(fields: RepayLogicFields) { - const { input, interestRateMode, borrower, balanceBps } = fields; - - const tokenIn = input.token.wrapped; - - const service = new Service(this.chainId, this.provider); - const to = await service.getPoolAddress(); - const data = Pool__factory.createInterface().encodeFunctionData('repay', [ - tokenIn.address, - input.amountWei, - interestRateMode, - borrower, - ]); - const amountOffset = balanceBps ? common.getParamOffset(1) : undefined; - const inputs = [ - core.newLogicInput({ input: new common.TokenAmount(tokenIn, input.amount), balanceBps, amountOffset }), - ]; - const wrapMode = input.token.isNative ? core.WrapMode.wrapBefore : core.WrapMode.none; - - return core.newLogic({ to, data, inputs, wrapMode }); + constructor(chainId: number, provider?: providers.Provider) { + super({ chainId, provider, service: new Service(chainId, provider) }); } } diff --git a/src/logics/spark/logic.supply.ts b/src/logics/spark/logic.supply.ts index 8a6ed1fc..86b43f32 100644 --- a/src/logics/spark/logic.supply.ts +++ b/src/logics/spark/logic.supply.ts @@ -1,68 +1,25 @@ -import { Pool__factory } from './contracts'; import { Service } from './service'; -import * as common from '@protocolink/common'; +import * as aavev3 from 'src/modules/aavev3'; import * as core from '@protocolink/core'; -import { supportedChainIds } from './configs'; +import { protocolId, supportedChainIds } from './configs'; +import { providers } from 'ethers'; -export type SupplyLogicTokenList = [common.Token, common.Token][]; +export type SupplyLogicTokenList = aavev3.SupplyLogicTokenList; -export type SupplyLogicParams = core.TokenToTokenExactInParams; +export type SupplyLogicParams = aavev3.SupplyLogicParams; -export type SupplyLogicFields = core.TokenToTokenExactInFields<{ referralCode?: number }>; +export type SupplyLogicFields = aavev3.SupplyLogicFields; -export type SupplyLogicOptions = Pick; +export type SupplyLogicOptions = aavev3.SupplyLogicOptions; export class SupplyLogic - extends core.Logic + extends aavev3.SupplyLogics implements core.LogicTokenListInterface, core.LogicOracleInterface, core.LogicBuilderInterface { - static id = 'supply'; - static protocolId = 'spark'; + static protocolId = protocolId; static readonly supportedChainIds = supportedChainIds; - async getTokenList() { - const service = new Service(this.chainId, this.provider); - const reserveTokens = await service.getReserveTokens(); - - const tokenList: SupplyLogicTokenList = []; - for (const reserveToken of reserveTokens) { - if (reserveToken.asset.isWrapped) { - tokenList.push([reserveToken.asset.unwrapped, reserveToken.aToken]); - } - tokenList.push([reserveToken.asset, reserveToken.aToken]); - } - - return tokenList; - } - - async quote(params: SupplyLogicParams) { - const { input, tokenOut } = params; - const output = new common.TokenAmount(tokenOut, input.amount); - - return { input, output }; - } - - async build(fields: SupplyLogicFields, options: SupplyLogicOptions) { - const { input, balanceBps, referralCode = 0 } = fields; - const { account } = options; - - const tokenIn = input.token.wrapped; - const agent = await this.calcAgent(account); - - const service = new Service(this.chainId, this.provider); - const to = await service.getPoolAddress(); - const data = Pool__factory.createInterface().encodeFunctionData('supply', [ - tokenIn.address, - input.amountWei, - agent, - referralCode, - ]); - const amountOffset = balanceBps ? common.getParamOffset(1) : undefined; - const inputs = [ - core.newLogicInput({ input: new common.TokenAmount(tokenIn, input.amount), balanceBps, amountOffset }), - ]; - const wrapMode = input.token.isNative ? core.WrapMode.wrapBefore : core.WrapMode.none; - - return core.newLogic({ to, data, inputs, wrapMode }); + constructor(chainId: number, provider?: providers.Provider) { + super({ chainId, provider, service: new Service(chainId, provider) }); } } diff --git a/src/logics/spark/logic.withdraw.ts b/src/logics/spark/logic.withdraw.ts index 6d9aa215..524a744b 100644 --- a/src/logics/spark/logic.withdraw.ts +++ b/src/logics/spark/logic.withdraw.ts @@ -1,65 +1,25 @@ -import { Pool__factory } from './contracts'; import { Service } from './service'; -import * as common from '@protocolink/common'; +import * as aavev3 from 'src/modules/aavev3'; import * as core from '@protocolink/core'; -import { supportedChainIds } from './configs'; +import { protocolId, supportedChainIds } from './configs'; +import { providers } from 'ethers'; -export type WithdrawLogicTokenList = [common.Token, common.Token][]; +export type WithdrawLogicTokenList = aavev3.WithdrawLogicTokenList; -export type WithdrawLogicParams = core.TokenToTokenExactInParams; +export type WithdrawLogicParams = aavev3.WithdrawLogicParams; -export type WithdrawLogicFields = core.TokenToTokenExactInFields; +export type WithdrawLogicFields = aavev3.WithdrawLogicFields; -export type WithdrawLogicOptions = Pick; +export type WithdrawLogicOptions = aavev3.WithdrawLogicOptions; export class WithdrawLogic - extends core.Logic + extends aavev3.WithdrawLogic implements core.LogicTokenListInterface, core.LogicOracleInterface, core.LogicBuilderInterface { - static id = 'withdraw'; - static protocolId = 'spark'; + static protocolId = protocolId; static readonly supportedChainIds = supportedChainIds; - async getTokenList() { - const service = new Service(this.chainId, this.provider); - const reserveTokens = await service.getReserveTokens(); - - const tokenList: WithdrawLogicTokenList = []; - for (const reserveToken of reserveTokens) { - if (reserveToken.asset.isWrapped) { - tokenList.push([reserveToken.aToken, reserveToken.asset.unwrapped]); - } - tokenList.push([reserveToken.aToken, reserveToken.asset]); - } - - return tokenList; - } - - async quote(params: WithdrawLogicParams) { - const { input, tokenOut } = params; - const output = new common.TokenAmount(tokenOut, input.amount); - - return { input, output }; - } - - async build(fields: WithdrawLogicFields, options: WithdrawLogicOptions) { - const { input, output, balanceBps } = fields; - const { account } = options; - - const tokenOut = output.token.wrapped; - const agent = await this.calcAgent(account); - - const service = new Service(this.chainId, this.provider); - const to = await service.getPoolAddress(); - const data = Pool__factory.createInterface().encodeFunctionData('withdraw', [ - tokenOut.address, - input.amountWei, - agent, - ]); - const amountOffset = balanceBps ? common.getParamOffset(1) : undefined; - const inputs = [core.newLogicInput({ input, balanceBps, amountOffset })]; - const wrapMode = output.token.isNative ? core.WrapMode.unwrapAfter : core.WrapMode.none; - - return core.newLogic({ to, data, inputs, wrapMode }); + constructor(chainId: number, provider?: providers.Provider) { + super({ chainId, provider, service: new Service(chainId, provider) }); } } diff --git a/src/logics/spark/scripts/refresh-tokens-data.ts b/src/logics/spark/scripts/refresh-tokens-data.ts deleted file mode 100644 index f21ddab0..00000000 --- a/src/logics/spark/scripts/refresh-tokens-data.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { Service } from '../service'; -import * as common from '@protocolink/common'; -import fs from 'fs-extra'; -import { resolve } from 'path'; - -export default async function () { - const chainIds = [common.ChainId.mainnet]; - - for (const chainId of chainIds) { - const service = new Service(chainId); - const reserveTokens = await service.getReserveTokens(); - - const tokenMap = reserveTokens.reduce((accumulator, reserveToken) => { - if (reserveToken.asset.isWrapped) { - const unwrapped = reserveToken.asset.unwrapped; - accumulator[unwrapped.symbol] = unwrapped; - } - accumulator[reserveToken.asset.symbol] = reserveToken.asset; - accumulator[reserveToken.aToken.symbol] = reserveToken.aToken; - return accumulator; - }, {} as Record); - - const tokenDataPath = resolve(__dirname, '..', 'tokens', 'data', `${common.toNetworkId(chainId)}.json`); - fs.outputJSONSync(tokenDataPath, tokenMap, { spaces: 2 }); - } -} diff --git a/src/logics/spark/service.test.ts b/src/logics/spark/service.test.ts index 12c77554..885335fb 100644 --- a/src/logics/spark/service.test.ts +++ b/src/logics/spark/service.test.ts @@ -7,12 +7,36 @@ import omit from 'lodash/omit'; describe('Spark Service', function () { const chainIds = [common.ChainId.mainnet]; - context('Test getReserveTokensAddresses', function () { + context('Test getReserveTokens', function () { chainIds.forEach((chainId) => { it(common.toNetworkId(chainId), async function () { const service = new Service(chainId); - const reserveTokensAddresses = await service.getReserveTokensAddresses(); - expect(reserveTokensAddresses).to.have.lengthOf.above(0); + const { reserveTokens, reserveMap } = await service.getReserveTokens(); + + expect(reserveTokens).to.have.lengthOf.above(0); + expect(Object.keys(reserveMap)).to.have.lengthOf.above(0); + }); + }); + }); + + context('Test getSupplyTokens', function () { + chainIds.forEach((chainId) => { + it(common.toNetworkId(chainId), async function () { + const service = new Service(chainId); + const supplyTokens = await service.getSupplyTokens(); + expect(supplyTokens).to.have.lengthOf.above(0); + expect(supplyTokens.every(({ isSupplyEnabled }) => isSupplyEnabled)).to.be.true; + }); + }); + }); + + context('Test getBorrowTokens', function () { + chainIds.forEach((chainId) => { + it(common.toNetworkId(chainId), async function () { + const service = new Service(chainId); + const borrowTokens = await service.getBorrowTokens(); + expect(borrowTokens).to.have.lengthOf.above(0); + expect(borrowTokens.every(({ isBorrowEnabled }) => isBorrowEnabled)).to.be.true; }); }); }); diff --git a/src/logics/spark/service.ts b/src/logics/spark/service.ts index bbea225f..fe06c3be 100644 --- a/src/logics/spark/service.ts +++ b/src/logics/spark/service.ts @@ -1,18 +1,11 @@ import { - AToken__factory, DebtTokenBase__factory, PoolAddressesProvider__factory, PoolDataProvider, PoolDataProvider__factory, Pool__factory, } from './contracts'; -import { - FlashLoanAssetInfo, - FlashLoanConfiguration, - InterestRateMode, - ReserveTokens, - ReserveTokensAddress, -} from './types'; +import { FlashLoanAssetInfo, FlashLoanConfiguration, InterestRateMode, ReserveTokens } from './types'; import { PoolDataProviderInterface } from './contracts/PoolDataProvider'; import { PoolInterface } from './contracts/Pool'; import * as common from '@protocolink/common'; @@ -62,153 +55,134 @@ export class Service extends common.Web3Toolkit { return this.poolAddress; } - private assetAddresses?: string[]; + private reserveTokens?: ReserveTokens[]; + private reserveMap?: Record; + + async getReserveTokens() { + if (!this.reserveTokens || !this.reserveMap) { + const tokenAddresses: string[] = []; + const reserveTokens: ReserveTokens[] = []; + const reserveMap: Record = {}; - async getAssetAddresses() { - if (!this.assetAddresses) { const poolAddress = await this.getPoolAddress(); const assetAddresses = await Pool__factory.connect(poolAddress, this.provider).getReservesList(); - const calls: common.Multicall3.CallStruct[] = assetAddresses.map((assetAddress) => ({ - target: this.poolDataProvider.address, - callData: this.poolDataProviderIface.encodeFunctionData('getReserveConfigurationData', [assetAddress]), - })); + const calls: common.Multicall3.CallStruct[] = assetAddresses.flatMap((assetAddress) => [ + { + target: this.poolDataProvider.address, + callData: this.poolDataProviderIface.encodeFunctionData('getReserveConfigurationData', [assetAddress]), + }, + { + target: this.poolDataProvider.address, + callData: this.poolDataProviderIface.encodeFunctionData('getReserveTokensAddresses', [assetAddress]), + }, + ]); const { returnData } = await this.multicall3.callStatic.aggregate(calls); - this.assetAddresses = []; - for (let i = 0; i < assetAddresses.length; i++) { - const assetAddress = assetAddresses[i]; - const { isActive, isFrozen } = this.poolDataProviderIface.decodeFunctionResult( + assetAddresses.forEach((assetAddress, i) => { + const { isActive, isFrozen, borrowingEnabled } = this.poolDataProviderIface.decodeFunctionResult( 'getReserveConfigurationData', - returnData[i] + returnData[i * 2] ); - if (isActive && !isFrozen) this.assetAddresses.push(assetAddress); - } - } - return this.assetAddresses; - } + const { aTokenAddress, stableDebtTokenAddress, variableDebtTokenAddress } = + this.poolDataProviderIface.decodeFunctionResult('getReserveTokensAddresses', returnData[i * 2 + 1]); - private reserveTokensAddresses?: ReserveTokensAddress[]; + reserveMap[assetAddress] = { + isSupplyEnabled: isActive && !isFrozen, + isBorrowEnabled: isActive && !isFrozen && borrowingEnabled, + }; - async getReserveTokensAddresses() { - if (!this.reserveTokensAddresses) { - const assetAddresses = await this.getAssetAddresses(); + tokenAddresses.push(assetAddress, aTokenAddress, stableDebtTokenAddress, variableDebtTokenAddress); + }); - const calls: common.Multicall3.CallStruct[] = assetAddresses.map((asset) => ({ - target: this.poolDataProvider.address, - callData: this.poolDataProviderIface.encodeFunctionData('getReserveTokensAddresses', [asset]), - })); - const { returnData } = await this.multicall3.callStatic.aggregate(calls); + const tokens = await this.getTokens(tokenAddresses); - this.reserveTokensAddresses = []; - for (let i = 0; i < assetAddresses.length; i++) { - const assetAddress = assetAddresses[i]; - const { aTokenAddress, stableDebtTokenAddress, variableDebtTokenAddress } = - this.poolDataProviderIface.decodeFunctionResult('getReserveTokensAddresses', returnData[i]); - this.reserveTokensAddresses.push({ - assetAddress, - aTokenAddress, - stableDebtTokenAddress, - variableDebtTokenAddress, - }); + for (let i = 0; i < tokens.length; i += 4) { + const asset = tokens[i]; + const aToken = tokens[i + 1]; + const stableDebtToken = tokens[i + 2]; + const variableDebtToken = tokens[i + 3]; + + const reserveToken: ReserveTokens = { + ...reserveMap[asset.address], + asset, + aToken, + stableDebtToken, + variableDebtToken, + }; + + reserveTokens.push(reserveToken); + + reserveMap[asset.address] = reserveToken; + + // Add aToken address as key for quick lookup + reserveMap[aToken.address] = reserveToken; } + + this.reserveTokens = reserveTokens; + this.reserveMap = reserveMap; } - return this.reserveTokensAddresses; + return { reserveTokens: this.reserveTokens, reserveMap: this.reserveMap }; } - private assets?: common.Token[]; - async getAssets() { - if (!this.assets) { - const assetAddresses = await this.getAssetAddresses(); - this.assets = await this.getTokens(assetAddresses); - } - return this.assets; + const { reserveTokens } = await this.getReserveTokens(); + return reserveTokens.map(({ asset }) => asset); } - private aTokens?: common.Token[]; - async getATokens() { - if (!this.aTokens) { - const reserveTokensAddresses = await this.getReserveTokensAddresses(); - const aTokenAddresses = reserveTokensAddresses.map((reserveTokensAddress) => reserveTokensAddress.aTokenAddress); - this.aTokens = await this.getTokens(aTokenAddresses); - } - return this.aTokens; + const { reserveTokens } = await this.getReserveTokens(); + return reserveTokens.map(({ aToken }) => aToken); } - private reserveTokens?: ReserveTokens[]; - - async getReserveTokens() { - if (!this.reserveTokens) { - const reserveTokensAddresses = await this.getReserveTokensAddresses(); - const tokenAddresses = reserveTokensAddresses.reduce((accumulator, reserveTokensAddress) => { - accumulator.push(reserveTokensAddress.assetAddress); - accumulator.push(reserveTokensAddress.aTokenAddress); - accumulator.push(reserveTokensAddress.stableDebtTokenAddress); - accumulator.push(reserveTokensAddress.variableDebtTokenAddress); - return accumulator; - }, []); - const tokens = await this.getTokens(tokenAddresses); - - this.reserveTokens = []; - let j = 0; - for (let i = 0; i < reserveTokensAddresses.length; i++) { - const asset = tokens[j]; - j++; - const aToken = tokens[j]; - j++; - const stableDebtToken = tokens[j]; - j++; - const variableDebtToken = tokens[j]; - j++; - this.reserveTokens.push({ asset, aToken, stableDebtToken, variableDebtToken }); - } - } + async getSupplyTokens() { + const { reserveTokens } = await this.getReserveTokens(); + return reserveTokens.filter(({ isSupplyEnabled }) => isSupplyEnabled); + } - return this.reserveTokens; + async getBorrowTokens() { + const { reserveTokens } = await this.getReserveTokens(); + return reserveTokens.filter(({ isBorrowEnabled }) => isBorrowEnabled); } async toAToken(asset: common.Token) { - const { aTokenAddress } = await this.poolDataProvider.getReserveTokensAddresses(asset.wrapped.address); - invariant(aTokenAddress !== constants.AddressZero, `unsupported asset: ${asset.wrapped.address}`); + const { reserveMap } = await this.getReserveTokens(); + + const aToken = reserveMap[asset.wrapped.address]?.aToken; + invariant(aToken?.address !== constants.AddressZero, `unsupported asset: ${asset.wrapped.address}`); - return this.getToken(aTokenAddress); + return aToken; } async toATokens(assets: common.Token[]) { - const calls: common.Multicall3.CallStruct[] = assets.map((asset) => ({ - target: this.poolDataProvider.address, - callData: this.poolDataProviderIface.encodeFunctionData('getReserveTokensAddresses', [asset.wrapped.address]), - })); - const { returnData } = await this.multicall3.callStatic.aggregate(calls); + const { reserveMap } = await this.getReserveTokens(); - const aTokenAddresses: string[] = []; - for (let i = 0; i < assets.length; i++) { - const { aTokenAddress } = this.poolDataProviderIface.decodeFunctionResult( - 'getReserveTokensAddresses', - returnData[i] - ); - invariant(aTokenAddress !== constants.AddressZero, `unsupported asset: ${assets[i].wrapped.address}`); - aTokenAddresses.push(aTokenAddress); - } + return assets.map((asset) => { + const aToken = reserveMap[asset.wrapped.address]?.aToken; + invariant(aToken?.address !== constants.AddressZero, `unsupported asset: ${asset.wrapped.address}`); - return this.getTokens(aTokenAddresses); + return aToken; + }); } async toAsset(aToken: common.Token) { - const assetAddress = await AToken__factory.connect(aToken.address, this.provider).UNDERLYING_ASSET_ADDRESS(); - return this.getToken(assetAddress); + const { reserveMap } = await this.getReserveTokens(); + + const asset = reserveMap[aToken.address]?.asset; + invariant(asset, `unsupported aToken: ${aToken.address}`); + + return asset; } async getDebtTokenAddress(asset: common.Token, interestRateMode: InterestRateMode) { - const { stableDebtTokenAddress, variableDebtTokenAddress } = await this.poolDataProvider.getReserveTokensAddresses( - asset.wrapped.address - ); + const { reserveMap } = await this.getReserveTokens(); + + const { stableDebtToken, variableDebtToken } = reserveMap[asset.wrapped.address]; + invariant(stableDebtToken || variableDebtToken, `unsupported aToken: ${asset.wrapped.address}`); - return interestRateMode === InterestRateMode.variable ? variableDebtTokenAddress : stableDebtTokenAddress; + return interestRateMode === InterestRateMode.variable ? variableDebtToken.address : stableDebtToken.address; } async getFlashLoanPremiumTotal() { diff --git a/src/logics/spark/types.ts b/src/logics/spark/types.ts index 4408ccce..04ad2fae 100644 --- a/src/logics/spark/types.ts +++ b/src/logics/spark/types.ts @@ -1,17 +1,12 @@ import * as common from '@protocolink/common'; -export interface ReserveTokensAddress { - assetAddress: string; - aTokenAddress: string; - stableDebtTokenAddress: string; - variableDebtTokenAddress: string; -} - export interface ReserveTokens { asset: common.Token; aToken: common.Token; stableDebtToken: common.Token; variableDebtToken: common.Token; + isSupplyEnabled: boolean; + isBorrowEnabled: boolean; } export enum InterestRateMode { diff --git a/src/logics/stargate/configs.ts b/src/logics/stargate/configs.ts index 5367425b..16d89bdb 100644 --- a/src/logics/stargate/configs.ts +++ b/src/logics/stargate/configs.ts @@ -274,7 +274,7 @@ export const configs: Config[] = [ pools: [ { id: PoolId.METIS, - token: metisTokens['METIS(ERC20)'], + token: metisTokens.METIS, decimals: 18, paths: [{ chainId: common.ChainId.mainnet, poolIds: [PoolId.METIS] }], }, diff --git a/src/modules/aavev2/abis/AToken.json b/src/modules/aavev2/abis/AToken.json new file mode 100644 index 00000000..f73256cc --- /dev/null +++ b/src/modules/aavev2/abis/AToken.json @@ -0,0 +1,762 @@ +[ + { + "inputs": [ + { + "internalType": "contract ILendingPool", + "name": "pool", + "type": "address" + }, + { + "internalType": "address", + "name": "underlyingAssetAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "reserveTreasuryAddress", + "type": "address" + }, + { + "internalType": "string", + "name": "tokenName", + "type": "string" + }, + { + "internalType": "string", + "name": "tokenSymbol", + "type": "string" + }, + { + "internalType": "address", + "name": "incentivesController", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "BalanceTransfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "Burn", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "Mint", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "inputs": [], + "name": "ATOKEN_REVISION", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "DOMAIN_SEPARATOR", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "EIP712_REVISION", + "outputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "PERMIT_TYPEHASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "POOL", + "outputs": [ + { + "internalType": "contract ILendingPool", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "RESERVE_TREASURY_ADDRESS", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "UINT_MAX_VALUE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "UNDERLYING_ASSET_ADDRESS", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "_nonces", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "address", + "name": "receiverOfUnderlying", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "burn", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "subtractedValue", + "type": "uint256" + } + ], + "name": "decreaseAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "getScaledUserBalanceAndSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "addedValue", + "type": "uint256" + } + ], + "name": "increaseAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "underlyingAssetDecimals", + "type": "uint8" + }, + { + "internalType": "string", + "name": "tokenName", + "type": "string" + }, + { + "internalType": "string", + "name": "tokenSymbol", + "type": "string" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "mint", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "mintToTreasury", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "permit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "scaledBalanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "scaledTotalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "transferOnLiquidation", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transferUnderlyingTo", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/src/modules/aavev2/abis/AaveV2FlashLoanCallback.json b/src/modules/aavev2/abis/AaveV2FlashLoanCallback.json new file mode 100644 index 00000000..bbb890b3 --- /dev/null +++ b/src/modules/aavev2/abis/AaveV2FlashLoanCallback.json @@ -0,0 +1,130 @@ +[ + { + "inputs": [ + { + "internalType": "address", + "name": "router_", + "type": "address" + }, + { + "internalType": "address", + "name": "aaveV2Provider_", + "type": "address" + }, + { + "internalType": "uint256", + "name": "feeRate_", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "InvalidBalance", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidCaller", + "type": "error" + }, + { + "inputs": [], + "name": "aaveV2Provider", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "assets", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "premiums", + "type": "uint256[]" + }, + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "bytes", + "name": "params", + "type": "bytes" + } + ], + "name": "executeOperation", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "feeRate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "metadata", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "router", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } +] diff --git a/src/modules/aavev2/abis/DebtTokenBase.json b/src/modules/aavev2/abis/DebtTokenBase.json new file mode 100644 index 00000000..269b9394 --- /dev/null +++ b/src/modules/aavev2/abis/DebtTokenBase.json @@ -0,0 +1,44 @@ +[ + { + "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" + } +] diff --git a/src/modules/aavev2/abis/LendingPool.json b/src/modules/aavev2/abis/LendingPool.json new file mode 100644 index 00000000..f06c46c4 --- /dev/null +++ b/src/modules/aavev2/abis/LendingPool.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/src/modules/aavev2/abis/LendingPoolAddressesProvider.json b/src/modules/aavev2/abis/LendingPoolAddressesProvider.json new file mode 100644 index 00000000..44ea7d8b --- /dev/null +++ b/src/modules/aavev2/abis/LendingPoolAddressesProvider.json @@ -0,0 +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" + } +] diff --git a/src/modules/aavev2/abis/ProtocolDataProvider.json b/src/modules/aavev2/abis/ProtocolDataProvider.json new file mode 100644 index 00000000..6da4e3f1 --- /dev/null +++ b/src/modules/aavev2/abis/ProtocolDataProvider.json @@ -0,0 +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" + } +] diff --git a/src/modules/aavev2/contracts/AToken.ts b/src/modules/aavev2/contracts/AToken.ts new file mode 100644 index 00000000..8f0a2ac3 --- /dev/null +++ b/src/modules/aavev2/contracts/AToken.ts @@ -0,0 +1,823 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + BaseContract, + BigNumber, + BigNumberish, + BytesLike, + CallOverrides, + ContractTransaction, + Overrides, + PopulatedTransaction, + Signer, + utils, +} from 'ethers'; +import type { FunctionFragment, Result, EventFragment } from '@ethersproject/abi'; +import type { Listener, Provider } from '@ethersproject/providers'; +import type { TypedEventFilter, TypedEvent, TypedListener, OnEvent } from './common'; + +export interface ATokenInterface extends utils.Interface { + functions: { + 'ATOKEN_REVISION()': FunctionFragment; + 'DOMAIN_SEPARATOR()': FunctionFragment; + 'EIP712_REVISION()': FunctionFragment; + 'PERMIT_TYPEHASH()': FunctionFragment; + 'POOL()': FunctionFragment; + 'RESERVE_TREASURY_ADDRESS()': FunctionFragment; + 'UINT_MAX_VALUE()': FunctionFragment; + 'UNDERLYING_ASSET_ADDRESS()': FunctionFragment; + '_nonces(address)': FunctionFragment; + 'allowance(address,address)': FunctionFragment; + 'approve(address,uint256)': FunctionFragment; + 'balanceOf(address)': FunctionFragment; + 'burn(address,address,uint256,uint256)': FunctionFragment; + 'decimals()': FunctionFragment; + 'decreaseAllowance(address,uint256)': FunctionFragment; + 'getScaledUserBalanceAndSupply(address)': FunctionFragment; + 'increaseAllowance(address,uint256)': FunctionFragment; + 'initialize(uint8,string,string)': FunctionFragment; + 'mint(address,uint256,uint256)': FunctionFragment; + 'mintToTreasury(uint256,uint256)': FunctionFragment; + 'name()': FunctionFragment; + 'permit(address,address,uint256,uint256,uint8,bytes32,bytes32)': FunctionFragment; + 'scaledBalanceOf(address)': FunctionFragment; + 'scaledTotalSupply()': FunctionFragment; + 'symbol()': FunctionFragment; + 'totalSupply()': FunctionFragment; + 'transfer(address,uint256)': FunctionFragment; + 'transferFrom(address,address,uint256)': FunctionFragment; + 'transferOnLiquidation(address,address,uint256)': FunctionFragment; + 'transferUnderlyingTo(address,uint256)': FunctionFragment; + }; + + getFunction( + nameOrSignatureOrTopic: + | 'ATOKEN_REVISION' + | 'DOMAIN_SEPARATOR' + | 'EIP712_REVISION' + | 'PERMIT_TYPEHASH' + | 'POOL' + | 'RESERVE_TREASURY_ADDRESS' + | 'UINT_MAX_VALUE' + | 'UNDERLYING_ASSET_ADDRESS' + | '_nonces' + | 'allowance' + | 'approve' + | 'balanceOf' + | 'burn' + | 'decimals' + | 'decreaseAllowance' + | 'getScaledUserBalanceAndSupply' + | 'increaseAllowance' + | 'initialize' + | 'mint' + | 'mintToTreasury' + | 'name' + | 'permit' + | 'scaledBalanceOf' + | 'scaledTotalSupply' + | 'symbol' + | 'totalSupply' + | 'transfer' + | 'transferFrom' + | 'transferOnLiquidation' + | 'transferUnderlyingTo' + ): FunctionFragment; + + encodeFunctionData(functionFragment: 'ATOKEN_REVISION', values?: undefined): string; + encodeFunctionData(functionFragment: 'DOMAIN_SEPARATOR', values?: undefined): string; + encodeFunctionData(functionFragment: 'EIP712_REVISION', values?: undefined): string; + encodeFunctionData(functionFragment: 'PERMIT_TYPEHASH', values?: undefined): string; + encodeFunctionData(functionFragment: 'POOL', values?: undefined): string; + encodeFunctionData(functionFragment: 'RESERVE_TREASURY_ADDRESS', values?: undefined): string; + encodeFunctionData(functionFragment: 'UINT_MAX_VALUE', values?: undefined): string; + encodeFunctionData(functionFragment: 'UNDERLYING_ASSET_ADDRESS', values?: undefined): string; + encodeFunctionData(functionFragment: '_nonces', values: [string]): string; + encodeFunctionData(functionFragment: 'allowance', values: [string, string]): string; + encodeFunctionData(functionFragment: 'approve', values: [string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'balanceOf', values: [string]): string; + encodeFunctionData(functionFragment: 'burn', values: [string, string, BigNumberish, BigNumberish]): string; + encodeFunctionData(functionFragment: 'decimals', values?: undefined): string; + encodeFunctionData(functionFragment: 'decreaseAllowance', values: [string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'getScaledUserBalanceAndSupply', values: [string]): string; + encodeFunctionData(functionFragment: 'increaseAllowance', values: [string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'initialize', values: [BigNumberish, string, string]): string; + encodeFunctionData(functionFragment: 'mint', values: [string, BigNumberish, BigNumberish]): string; + encodeFunctionData(functionFragment: 'mintToTreasury', values: [BigNumberish, BigNumberish]): string; + encodeFunctionData(functionFragment: 'name', values?: undefined): string; + encodeFunctionData( + functionFragment: 'permit', + values: [string, string, BigNumberish, BigNumberish, BigNumberish, BytesLike, BytesLike] + ): string; + encodeFunctionData(functionFragment: 'scaledBalanceOf', values: [string]): string; + encodeFunctionData(functionFragment: 'scaledTotalSupply', values?: undefined): string; + encodeFunctionData(functionFragment: 'symbol', values?: undefined): string; + encodeFunctionData(functionFragment: 'totalSupply', values?: undefined): string; + encodeFunctionData(functionFragment: 'transfer', values: [string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'transferFrom', values: [string, string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'transferOnLiquidation', values: [string, string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'transferUnderlyingTo', values: [string, BigNumberish]): string; + + decodeFunctionResult(functionFragment: 'ATOKEN_REVISION', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'DOMAIN_SEPARATOR', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'EIP712_REVISION', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'PERMIT_TYPEHASH', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'POOL', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'RESERVE_TREASURY_ADDRESS', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'UINT_MAX_VALUE', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'UNDERLYING_ASSET_ADDRESS', data: BytesLike): Result; + decodeFunctionResult(functionFragment: '_nonces', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'allowance', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'approve', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'balanceOf', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'burn', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'decimals', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'decreaseAllowance', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getScaledUserBalanceAndSupply', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'increaseAllowance', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'initialize', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'mint', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'mintToTreasury', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'name', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'permit', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'scaledBalanceOf', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'scaledTotalSupply', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'symbol', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'totalSupply', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'transfer', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'transferFrom', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'transferOnLiquidation', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'transferUnderlyingTo', data: BytesLike): Result; + + events: { + 'Approval(address,address,uint256)': EventFragment; + 'BalanceTransfer(address,address,uint256,uint256)': EventFragment; + 'Burn(address,address,uint256,uint256)': EventFragment; + 'Mint(address,uint256,uint256)': EventFragment; + 'Transfer(address,address,uint256)': EventFragment; + }; + + getEvent(nameOrSignatureOrTopic: 'Approval'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'BalanceTransfer'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'Burn'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'Mint'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'Transfer'): EventFragment; +} + +export interface ApprovalEventObject { + owner: string; + spender: string; + value: BigNumber; +} +export type ApprovalEvent = TypedEvent<[string, string, BigNumber], ApprovalEventObject>; + +export type ApprovalEventFilter = TypedEventFilter; + +export interface BalanceTransferEventObject { + from: string; + to: string; + value: BigNumber; + index: BigNumber; +} +export type BalanceTransferEvent = TypedEvent<[string, string, BigNumber, BigNumber], BalanceTransferEventObject>; + +export type BalanceTransferEventFilter = TypedEventFilter; + +export interface BurnEventObject { + from: string; + target: string; + value: BigNumber; + index: BigNumber; +} +export type BurnEvent = TypedEvent<[string, string, BigNumber, BigNumber], BurnEventObject>; + +export type BurnEventFilter = TypedEventFilter; + +export interface MintEventObject { + from: string; + value: BigNumber; + index: BigNumber; +} +export type MintEvent = TypedEvent<[string, BigNumber, BigNumber], MintEventObject>; + +export type MintEventFilter = TypedEventFilter; + +export interface TransferEventObject { + from: string; + to: string; + value: BigNumber; +} +export type TransferEvent = TypedEvent<[string, string, BigNumber], TransferEventObject>; + +export type TransferEventFilter = TypedEventFilter; + +export interface AToken extends BaseContract { + connect(signerOrProvider: Signer | Provider | string): this; + attach(addressOrName: string): this; + deployed(): Promise; + + interface: ATokenInterface; + + queryFilter( + event: TypedEventFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>; + + listeners(eventFilter?: TypedEventFilter): Array>; + listeners(eventName?: string): Array; + removeAllListeners(eventFilter: TypedEventFilter): this; + removeAllListeners(eventName?: string): this; + off: OnEvent; + on: OnEvent; + once: OnEvent; + removeListener: OnEvent; + + functions: { + ATOKEN_REVISION(overrides?: CallOverrides): Promise<[BigNumber]>; + + DOMAIN_SEPARATOR(overrides?: CallOverrides): Promise<[string]>; + + EIP712_REVISION(overrides?: CallOverrides): Promise<[string]>; + + PERMIT_TYPEHASH(overrides?: CallOverrides): Promise<[string]>; + + POOL(overrides?: CallOverrides): Promise<[string]>; + + RESERVE_TREASURY_ADDRESS(overrides?: CallOverrides): Promise<[string]>; + + UINT_MAX_VALUE(overrides?: CallOverrides): Promise<[BigNumber]>; + + UNDERLYING_ASSET_ADDRESS(overrides?: CallOverrides): Promise<[string]>; + + _nonces(arg0: string, overrides?: CallOverrides): Promise<[BigNumber]>; + + allowance(owner: string, spender: string, overrides?: CallOverrides): Promise<[BigNumber]>; + + approve( + spender: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + balanceOf(user: string, overrides?: CallOverrides): Promise<[BigNumber]>; + + burn( + user: string, + receiverOfUnderlying: string, + amount: BigNumberish, + index: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + decimals(overrides?: CallOverrides): Promise<[number]>; + + decreaseAllowance( + spender: string, + subtractedValue: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + getScaledUserBalanceAndSupply(user: string, overrides?: CallOverrides): Promise<[BigNumber, BigNumber]>; + + increaseAllowance( + spender: string, + addedValue: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + initialize( + underlyingAssetDecimals: BigNumberish, + tokenName: string, + tokenSymbol: string, + overrides?: Overrides & { from?: string } + ): Promise; + + mint( + user: string, + amount: BigNumberish, + index: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + mintToTreasury( + amount: BigNumberish, + index: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + name(overrides?: CallOverrides): Promise<[string]>; + + permit( + owner: string, + spender: string, + value: BigNumberish, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + scaledBalanceOf(user: string, overrides?: CallOverrides): Promise<[BigNumber]>; + + scaledTotalSupply(overrides?: CallOverrides): Promise<[BigNumber]>; + + symbol(overrides?: CallOverrides): Promise<[string]>; + + totalSupply(overrides?: CallOverrides): Promise<[BigNumber]>; + + transfer( + recipient: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + transferFrom( + sender: string, + recipient: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + transferOnLiquidation( + from: string, + to: string, + value: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + transferUnderlyingTo( + target: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + }; + + ATOKEN_REVISION(overrides?: CallOverrides): Promise; + + DOMAIN_SEPARATOR(overrides?: CallOverrides): Promise; + + EIP712_REVISION(overrides?: CallOverrides): Promise; + + PERMIT_TYPEHASH(overrides?: CallOverrides): Promise; + + POOL(overrides?: CallOverrides): Promise; + + RESERVE_TREASURY_ADDRESS(overrides?: CallOverrides): Promise; + + UINT_MAX_VALUE(overrides?: CallOverrides): Promise; + + UNDERLYING_ASSET_ADDRESS(overrides?: CallOverrides): Promise; + + _nonces(arg0: string, overrides?: CallOverrides): Promise; + + allowance(owner: string, spender: string, overrides?: CallOverrides): Promise; + + approve( + spender: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + balanceOf(user: string, overrides?: CallOverrides): Promise; + + burn( + user: string, + receiverOfUnderlying: string, + amount: BigNumberish, + index: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + decimals(overrides?: CallOverrides): Promise; + + decreaseAllowance( + spender: string, + subtractedValue: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + getScaledUserBalanceAndSupply(user: string, overrides?: CallOverrides): Promise<[BigNumber, BigNumber]>; + + increaseAllowance( + spender: string, + addedValue: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + initialize( + underlyingAssetDecimals: BigNumberish, + tokenName: string, + tokenSymbol: string, + overrides?: Overrides & { from?: string } + ): Promise; + + mint( + user: string, + amount: BigNumberish, + index: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + mintToTreasury( + amount: BigNumberish, + index: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + name(overrides?: CallOverrides): Promise; + + permit( + owner: string, + spender: string, + value: BigNumberish, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + scaledBalanceOf(user: string, overrides?: CallOverrides): Promise; + + scaledTotalSupply(overrides?: CallOverrides): Promise; + + symbol(overrides?: CallOverrides): Promise; + + totalSupply(overrides?: CallOverrides): Promise; + + transfer( + recipient: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + transferFrom( + sender: string, + recipient: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + transferOnLiquidation( + from: string, + to: string, + value: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + transferUnderlyingTo( + target: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + callStatic: { + ATOKEN_REVISION(overrides?: CallOverrides): Promise; + + DOMAIN_SEPARATOR(overrides?: CallOverrides): Promise; + + EIP712_REVISION(overrides?: CallOverrides): Promise; + + PERMIT_TYPEHASH(overrides?: CallOverrides): Promise; + + POOL(overrides?: CallOverrides): Promise; + + RESERVE_TREASURY_ADDRESS(overrides?: CallOverrides): Promise; + + UINT_MAX_VALUE(overrides?: CallOverrides): Promise; + + UNDERLYING_ASSET_ADDRESS(overrides?: CallOverrides): Promise; + + _nonces(arg0: string, overrides?: CallOverrides): Promise; + + allowance(owner: string, spender: string, overrides?: CallOverrides): Promise; + + approve(spender: string, amount: BigNumberish, overrides?: CallOverrides): Promise; + + balanceOf(user: string, overrides?: CallOverrides): Promise; + + burn( + user: string, + receiverOfUnderlying: string, + amount: BigNumberish, + index: BigNumberish, + overrides?: CallOverrides + ): Promise; + + decimals(overrides?: CallOverrides): Promise; + + decreaseAllowance(spender: string, subtractedValue: BigNumberish, overrides?: CallOverrides): Promise; + + getScaledUserBalanceAndSupply(user: string, overrides?: CallOverrides): Promise<[BigNumber, BigNumber]>; + + increaseAllowance(spender: string, addedValue: BigNumberish, overrides?: CallOverrides): Promise; + + initialize( + underlyingAssetDecimals: BigNumberish, + tokenName: string, + tokenSymbol: string, + overrides?: CallOverrides + ): Promise; + + mint(user: string, amount: BigNumberish, index: BigNumberish, overrides?: CallOverrides): Promise; + + mintToTreasury(amount: BigNumberish, index: BigNumberish, overrides?: CallOverrides): Promise; + + name(overrides?: CallOverrides): Promise; + + permit( + owner: string, + spender: string, + value: BigNumberish, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: CallOverrides + ): Promise; + + scaledBalanceOf(user: string, overrides?: CallOverrides): Promise; + + scaledTotalSupply(overrides?: CallOverrides): Promise; + + symbol(overrides?: CallOverrides): Promise; + + totalSupply(overrides?: CallOverrides): Promise; + + transfer(recipient: string, amount: BigNumberish, overrides?: CallOverrides): Promise; + + transferFrom(sender: string, recipient: string, amount: BigNumberish, overrides?: CallOverrides): Promise; + + transferOnLiquidation(from: string, to: string, value: BigNumberish, overrides?: CallOverrides): Promise; + + transferUnderlyingTo(target: string, amount: BigNumberish, overrides?: CallOverrides): Promise; + }; + + filters: { + 'Approval(address,address,uint256)'( + owner?: string | null, + spender?: string | null, + value?: null + ): ApprovalEventFilter; + Approval(owner?: string | null, spender?: string | null, value?: null): ApprovalEventFilter; + + 'BalanceTransfer(address,address,uint256,uint256)'( + from?: string | null, + to?: string | null, + value?: null, + index?: null + ): BalanceTransferEventFilter; + BalanceTransfer(from?: string | null, to?: string | null, value?: null, index?: null): BalanceTransferEventFilter; + + 'Burn(address,address,uint256,uint256)'( + from?: string | null, + target?: string | null, + value?: null, + index?: null + ): BurnEventFilter; + Burn(from?: string | null, target?: string | null, value?: null, index?: null): BurnEventFilter; + + 'Mint(address,uint256,uint256)'(from?: string | null, value?: null, index?: null): MintEventFilter; + Mint(from?: string | null, value?: null, index?: null): MintEventFilter; + + 'Transfer(address,address,uint256)'(from?: string | null, to?: string | null, value?: null): TransferEventFilter; + Transfer(from?: string | null, to?: string | null, value?: null): TransferEventFilter; + }; + + estimateGas: { + ATOKEN_REVISION(overrides?: CallOverrides): Promise; + + DOMAIN_SEPARATOR(overrides?: CallOverrides): Promise; + + EIP712_REVISION(overrides?: CallOverrides): Promise; + + PERMIT_TYPEHASH(overrides?: CallOverrides): Promise; + + POOL(overrides?: CallOverrides): Promise; + + RESERVE_TREASURY_ADDRESS(overrides?: CallOverrides): Promise; + + UINT_MAX_VALUE(overrides?: CallOverrides): Promise; + + UNDERLYING_ASSET_ADDRESS(overrides?: CallOverrides): Promise; + + _nonces(arg0: string, overrides?: CallOverrides): Promise; + + allowance(owner: string, spender: string, overrides?: CallOverrides): Promise; + + approve(spender: string, amount: BigNumberish, overrides?: Overrides & { from?: string }): Promise; + + balanceOf(user: string, overrides?: CallOverrides): Promise; + + burn( + user: string, + receiverOfUnderlying: string, + amount: BigNumberish, + index: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + decimals(overrides?: CallOverrides): Promise; + + decreaseAllowance( + spender: string, + subtractedValue: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + getScaledUserBalanceAndSupply(user: string, overrides?: CallOverrides): Promise; + + increaseAllowance( + spender: string, + addedValue: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + initialize( + underlyingAssetDecimals: BigNumberish, + tokenName: string, + tokenSymbol: string, + overrides?: Overrides & { from?: string } + ): Promise; + + mint( + user: string, + amount: BigNumberish, + index: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + mintToTreasury( + amount: BigNumberish, + index: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + name(overrides?: CallOverrides): Promise; + + permit( + owner: string, + spender: string, + value: BigNumberish, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + scaledBalanceOf(user: string, overrides?: CallOverrides): Promise; + + scaledTotalSupply(overrides?: CallOverrides): Promise; + + symbol(overrides?: CallOverrides): Promise; + + totalSupply(overrides?: CallOverrides): Promise; + + transfer(recipient: string, amount: BigNumberish, overrides?: Overrides & { from?: string }): Promise; + + transferFrom( + sender: string, + recipient: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + transferOnLiquidation( + from: string, + to: string, + value: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + transferUnderlyingTo( + target: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + }; + + populateTransaction: { + ATOKEN_REVISION(overrides?: CallOverrides): Promise; + + DOMAIN_SEPARATOR(overrides?: CallOverrides): Promise; + + EIP712_REVISION(overrides?: CallOverrides): Promise; + + PERMIT_TYPEHASH(overrides?: CallOverrides): Promise; + + POOL(overrides?: CallOverrides): Promise; + + RESERVE_TREASURY_ADDRESS(overrides?: CallOverrides): Promise; + + UINT_MAX_VALUE(overrides?: CallOverrides): Promise; + + UNDERLYING_ASSET_ADDRESS(overrides?: CallOverrides): Promise; + + _nonces(arg0: string, overrides?: CallOverrides): Promise; + + allowance(owner: string, spender: string, overrides?: CallOverrides): Promise; + + approve( + spender: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + balanceOf(user: string, overrides?: CallOverrides): Promise; + + burn( + user: string, + receiverOfUnderlying: string, + amount: BigNumberish, + index: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + decimals(overrides?: CallOverrides): Promise; + + decreaseAllowance( + spender: string, + subtractedValue: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + getScaledUserBalanceAndSupply(user: string, overrides?: CallOverrides): Promise; + + increaseAllowance( + spender: string, + addedValue: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + initialize( + underlyingAssetDecimals: BigNumberish, + tokenName: string, + tokenSymbol: string, + overrides?: Overrides & { from?: string } + ): Promise; + + mint( + user: string, + amount: BigNumberish, + index: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + mintToTreasury( + amount: BigNumberish, + index: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + name(overrides?: CallOverrides): Promise; + + permit( + owner: string, + spender: string, + value: BigNumberish, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + scaledBalanceOf(user: string, overrides?: CallOverrides): Promise; + + scaledTotalSupply(overrides?: CallOverrides): Promise; + + symbol(overrides?: CallOverrides): Promise; + + totalSupply(overrides?: CallOverrides): Promise; + + transfer( + recipient: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + transferFrom( + sender: string, + recipient: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + transferOnLiquidation( + from: string, + to: string, + value: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + transferUnderlyingTo( + target: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + }; +} diff --git a/src/modules/aavev2/contracts/AaveV2FlashLoanCallback.ts b/src/modules/aavev2/contracts/AaveV2FlashLoanCallback.ts new file mode 100644 index 00000000..60c68a1c --- /dev/null +++ b/src/modules/aavev2/contracts/AaveV2FlashLoanCallback.ts @@ -0,0 +1,167 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + BaseContract, + BigNumber, + BigNumberish, + BytesLike, + CallOverrides, + ContractTransaction, + Overrides, + PopulatedTransaction, + Signer, + utils, +} from 'ethers'; +import type { FunctionFragment, Result } from '@ethersproject/abi'; +import type { Listener, Provider } from '@ethersproject/providers'; +import type { TypedEventFilter, TypedEvent, TypedListener, OnEvent } from './common'; + +export interface AaveV2FlashLoanCallbackInterface extends utils.Interface { + functions: { + 'aaveV2Provider()': FunctionFragment; + 'executeOperation(address[],uint256[],uint256[],address,bytes)': FunctionFragment; + 'feeRate()': FunctionFragment; + 'metadata()': FunctionFragment; + 'router()': FunctionFragment; + }; + + getFunction( + nameOrSignatureOrTopic: 'aaveV2Provider' | 'executeOperation' | 'feeRate' | 'metadata' | 'router' + ): FunctionFragment; + + encodeFunctionData(functionFragment: 'aaveV2Provider', values?: undefined): string; + encodeFunctionData( + functionFragment: 'executeOperation', + values: [string[], BigNumberish[], BigNumberish[], string, BytesLike] + ): string; + encodeFunctionData(functionFragment: 'feeRate', values?: undefined): string; + encodeFunctionData(functionFragment: 'metadata', values?: undefined): string; + encodeFunctionData(functionFragment: 'router', values?: undefined): string; + + decodeFunctionResult(functionFragment: 'aaveV2Provider', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'executeOperation', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'feeRate', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'metadata', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'router', data: BytesLike): Result; + + events: {}; +} + +export interface AaveV2FlashLoanCallback extends BaseContract { + connect(signerOrProvider: Signer | Provider | string): this; + attach(addressOrName: string): this; + deployed(): Promise; + + interface: AaveV2FlashLoanCallbackInterface; + + queryFilter( + event: TypedEventFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>; + + listeners(eventFilter?: TypedEventFilter): Array>; + listeners(eventName?: string): Array; + removeAllListeners(eventFilter: TypedEventFilter): this; + removeAllListeners(eventName?: string): this; + off: OnEvent; + on: OnEvent; + once: OnEvent; + removeListener: OnEvent; + + functions: { + aaveV2Provider(overrides?: CallOverrides): Promise<[string]>; + + executeOperation( + assets: string[], + amounts: BigNumberish[], + premiums: BigNumberish[], + arg3: string, + params: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + feeRate(overrides?: CallOverrides): Promise<[BigNumber]>; + + metadata(overrides?: CallOverrides): Promise<[string]>; + + router(overrides?: CallOverrides): Promise<[string]>; + }; + + aaveV2Provider(overrides?: CallOverrides): Promise; + + executeOperation( + assets: string[], + amounts: BigNumberish[], + premiums: BigNumberish[], + arg3: string, + params: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + feeRate(overrides?: CallOverrides): Promise; + + metadata(overrides?: CallOverrides): Promise; + + router(overrides?: CallOverrides): Promise; + + callStatic: { + aaveV2Provider(overrides?: CallOverrides): Promise; + + executeOperation( + assets: string[], + amounts: BigNumberish[], + premiums: BigNumberish[], + arg3: string, + params: BytesLike, + overrides?: CallOverrides + ): Promise; + + feeRate(overrides?: CallOverrides): Promise; + + metadata(overrides?: CallOverrides): Promise; + + router(overrides?: CallOverrides): Promise; + }; + + filters: {}; + + estimateGas: { + aaveV2Provider(overrides?: CallOverrides): Promise; + + executeOperation( + assets: string[], + amounts: BigNumberish[], + premiums: BigNumberish[], + arg3: string, + params: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + feeRate(overrides?: CallOverrides): Promise; + + metadata(overrides?: CallOverrides): Promise; + + router(overrides?: CallOverrides): Promise; + }; + + populateTransaction: { + aaveV2Provider(overrides?: CallOverrides): Promise; + + executeOperation( + assets: string[], + amounts: BigNumberish[], + premiums: BigNumberish[], + arg3: string, + params: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + feeRate(overrides?: CallOverrides): Promise; + + metadata(overrides?: CallOverrides): Promise; + + router(overrides?: CallOverrides): Promise; + }; +} diff --git a/src/modules/aavev2/contracts/DebtTokenBase.ts b/src/modules/aavev2/contracts/DebtTokenBase.ts new file mode 100644 index 00000000..d7461f3f --- /dev/null +++ b/src/modules/aavev2/contracts/DebtTokenBase.ts @@ -0,0 +1,104 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + BaseContract, + BigNumber, + BigNumberish, + BytesLike, + CallOverrides, + ContractTransaction, + Overrides, + PopulatedTransaction, + Signer, + utils, +} from 'ethers'; +import type { FunctionFragment, Result } from '@ethersproject/abi'; +import type { Listener, Provider } from '@ethersproject/providers'; +import type { TypedEventFilter, TypedEvent, TypedListener, OnEvent } from './common'; + +export interface DebtTokenBaseInterface extends utils.Interface { + functions: { + 'approveDelegation(address,uint256)': FunctionFragment; + 'borrowAllowance(address,address)': FunctionFragment; + }; + + getFunction(nameOrSignatureOrTopic: 'approveDelegation' | 'borrowAllowance'): FunctionFragment; + + encodeFunctionData(functionFragment: 'approveDelegation', values: [string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'borrowAllowance', values: [string, string]): string; + + decodeFunctionResult(functionFragment: 'approveDelegation', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'borrowAllowance', data: BytesLike): Result; + + events: {}; +} + +export interface DebtTokenBase extends BaseContract { + connect(signerOrProvider: Signer | Provider | string): this; + attach(addressOrName: string): this; + deployed(): Promise; + + interface: DebtTokenBaseInterface; + + queryFilter( + event: TypedEventFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>; + + listeners(eventFilter?: TypedEventFilter): Array>; + listeners(eventName?: string): Array; + removeAllListeners(eventFilter: TypedEventFilter): this; + removeAllListeners(eventName?: string): this; + off: OnEvent; + on: OnEvent; + once: OnEvent; + removeListener: OnEvent; + + functions: { + approveDelegation( + delegatee: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + borrowAllowance(fromUser: string, toUser: string, overrides?: CallOverrides): Promise<[BigNumber]>; + }; + + approveDelegation( + delegatee: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + borrowAllowance(fromUser: string, toUser: string, overrides?: CallOverrides): Promise; + + callStatic: { + approveDelegation(delegatee: string, amount: BigNumberish, overrides?: CallOverrides): Promise; + + borrowAllowance(fromUser: string, toUser: string, overrides?: CallOverrides): Promise; + }; + + filters: {}; + + estimateGas: { + approveDelegation( + delegatee: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + borrowAllowance(fromUser: string, toUser: string, overrides?: CallOverrides): Promise; + }; + + populateTransaction: { + approveDelegation( + delegatee: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + borrowAllowance(fromUser: string, toUser: string, overrides?: CallOverrides): Promise; + }; +} diff --git a/src/modules/aavev2/contracts/LendingPool.ts b/src/modules/aavev2/contracts/LendingPool.ts new file mode 100644 index 00000000..deb96597 --- /dev/null +++ b/src/modules/aavev2/contracts/LendingPool.ts @@ -0,0 +1,1224 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + BaseContract, + BigNumber, + BigNumberish, + BytesLike, + CallOverrides, + ContractTransaction, + Overrides, + PopulatedTransaction, + Signer, + utils, +} from 'ethers'; +import type { FunctionFragment, Result, EventFragment } from '@ethersproject/abi'; +import type { Listener, Provider } from '@ethersproject/providers'; +import type { TypedEventFilter, TypedEvent, TypedListener, OnEvent } from './common'; + +export declare namespace DataTypes { + export type ReserveConfigurationMapStruct = { data: BigNumberish }; + + export type ReserveConfigurationMapStructOutput = [BigNumber] & { + data: BigNumber; + }; + + export type ReserveDataStruct = { + configuration: DataTypes.ReserveConfigurationMapStruct; + liquidityIndex: BigNumberish; + variableBorrowIndex: BigNumberish; + currentLiquidityRate: BigNumberish; + currentVariableBorrowRate: BigNumberish; + currentStableBorrowRate: BigNumberish; + lastUpdateTimestamp: BigNumberish; + aTokenAddress: string; + stableDebtTokenAddress: string; + variableDebtTokenAddress: string; + interestRateStrategyAddress: string; + id: BigNumberish; + }; + + export type ReserveDataStructOutput = [ + DataTypes.ReserveConfigurationMapStructOutput, + BigNumber, + BigNumber, + BigNumber, + BigNumber, + BigNumber, + number, + string, + string, + string, + string, + number + ] & { + configuration: DataTypes.ReserveConfigurationMapStructOutput; + liquidityIndex: BigNumber; + variableBorrowIndex: BigNumber; + currentLiquidityRate: BigNumber; + currentVariableBorrowRate: BigNumber; + currentStableBorrowRate: BigNumber; + lastUpdateTimestamp: number; + aTokenAddress: string; + stableDebtTokenAddress: string; + variableDebtTokenAddress: string; + interestRateStrategyAddress: string; + id: number; + }; + + export type UserConfigurationMapStruct = { data: BigNumberish }; + + export type UserConfigurationMapStructOutput = [BigNumber] & { + data: BigNumber; + }; +} + +export interface LendingPoolInterface extends utils.Interface { + functions: { + 'FLASHLOAN_PREMIUM_TOTAL()': FunctionFragment; + 'LENDINGPOOL_REVISION()': FunctionFragment; + 'MAX_NUMBER_RESERVES()': FunctionFragment; + 'MAX_STABLE_RATE_BORROW_SIZE_PERCENT()': FunctionFragment; + 'borrow(address,uint256,uint256,uint16,address)': FunctionFragment; + 'deposit(address,uint256,address,uint16)': FunctionFragment; + 'finalizeTransfer(address,address,address,uint256,uint256,uint256)': FunctionFragment; + 'flashLoan(address,address[],uint256[],uint256[],address,bytes,uint16)': FunctionFragment; + 'getAddressesProvider()': FunctionFragment; + 'getConfiguration(address)': FunctionFragment; + 'getReserveData(address)': FunctionFragment; + 'getReserveNormalizedIncome(address)': FunctionFragment; + 'getReserveNormalizedVariableDebt(address)': FunctionFragment; + 'getReservesList()': FunctionFragment; + 'getUserAccountData(address)': FunctionFragment; + 'getUserConfiguration(address)': FunctionFragment; + 'initReserve(address,address,address,address,address)': FunctionFragment; + 'initialize(address)': FunctionFragment; + 'liquidationCall(address,address,address,uint256,bool)': FunctionFragment; + 'paused()': FunctionFragment; + 'rebalanceStableBorrowRate(address,address)': FunctionFragment; + 'repay(address,uint256,uint256,address)': FunctionFragment; + 'setConfiguration(address,uint256)': FunctionFragment; + 'setPause(bool)': FunctionFragment; + 'setReserveInterestRateStrategyAddress(address,address)': FunctionFragment; + 'setUserUseReserveAsCollateral(address,bool)': FunctionFragment; + 'swapBorrowRateMode(address,uint256)': FunctionFragment; + 'withdraw(address,uint256,address)': FunctionFragment; + }; + + getFunction( + nameOrSignatureOrTopic: + | 'FLASHLOAN_PREMIUM_TOTAL' + | 'LENDINGPOOL_REVISION' + | 'MAX_NUMBER_RESERVES' + | 'MAX_STABLE_RATE_BORROW_SIZE_PERCENT' + | 'borrow' + | 'deposit' + | 'finalizeTransfer' + | 'flashLoan' + | 'getAddressesProvider' + | 'getConfiguration' + | 'getReserveData' + | 'getReserveNormalizedIncome' + | 'getReserveNormalizedVariableDebt' + | 'getReservesList' + | 'getUserAccountData' + | 'getUserConfiguration' + | 'initReserve' + | 'initialize' + | 'liquidationCall' + | 'paused' + | 'rebalanceStableBorrowRate' + | 'repay' + | 'setConfiguration' + | 'setPause' + | 'setReserveInterestRateStrategyAddress' + | 'setUserUseReserveAsCollateral' + | 'swapBorrowRateMode' + | 'withdraw' + ): FunctionFragment; + + encodeFunctionData(functionFragment: 'FLASHLOAN_PREMIUM_TOTAL', values?: undefined): string; + encodeFunctionData(functionFragment: 'LENDINGPOOL_REVISION', values?: undefined): string; + encodeFunctionData(functionFragment: 'MAX_NUMBER_RESERVES', values?: undefined): string; + encodeFunctionData(functionFragment: 'MAX_STABLE_RATE_BORROW_SIZE_PERCENT', values?: undefined): string; + encodeFunctionData( + functionFragment: 'borrow', + values: [string, BigNumberish, BigNumberish, BigNumberish, string] + ): string; + encodeFunctionData(functionFragment: 'deposit', values: [string, BigNumberish, string, BigNumberish]): string; + encodeFunctionData( + functionFragment: 'finalizeTransfer', + values: [string, string, string, BigNumberish, BigNumberish, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: 'flashLoan', + values: [string, string[], BigNumberish[], BigNumberish[], string, BytesLike, BigNumberish] + ): string; + encodeFunctionData(functionFragment: 'getAddressesProvider', values?: undefined): string; + encodeFunctionData(functionFragment: 'getConfiguration', values: [string]): string; + encodeFunctionData(functionFragment: 'getReserveData', values: [string]): string; + encodeFunctionData(functionFragment: 'getReserveNormalizedIncome', values: [string]): string; + encodeFunctionData(functionFragment: 'getReserveNormalizedVariableDebt', values: [string]): string; + encodeFunctionData(functionFragment: 'getReservesList', values?: undefined): string; + encodeFunctionData(functionFragment: 'getUserAccountData', values: [string]): string; + encodeFunctionData(functionFragment: 'getUserConfiguration', values: [string]): string; + encodeFunctionData(functionFragment: 'initReserve', values: [string, string, string, string, string]): string; + encodeFunctionData(functionFragment: 'initialize', values: [string]): string; + encodeFunctionData( + functionFragment: 'liquidationCall', + values: [string, string, string, BigNumberish, boolean] + ): string; + encodeFunctionData(functionFragment: 'paused', values?: undefined): string; + encodeFunctionData(functionFragment: 'rebalanceStableBorrowRate', values: [string, string]): string; + encodeFunctionData(functionFragment: 'repay', values: [string, BigNumberish, BigNumberish, string]): string; + encodeFunctionData(functionFragment: 'setConfiguration', values: [string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'setPause', values: [boolean]): string; + encodeFunctionData(functionFragment: 'setReserveInterestRateStrategyAddress', values: [string, string]): string; + encodeFunctionData(functionFragment: 'setUserUseReserveAsCollateral', values: [string, boolean]): string; + encodeFunctionData(functionFragment: 'swapBorrowRateMode', values: [string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'withdraw', values: [string, BigNumberish, string]): string; + + decodeFunctionResult(functionFragment: 'FLASHLOAN_PREMIUM_TOTAL', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'LENDINGPOOL_REVISION', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'MAX_NUMBER_RESERVES', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'MAX_STABLE_RATE_BORROW_SIZE_PERCENT', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'borrow', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'deposit', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'finalizeTransfer', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'flashLoan', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getAddressesProvider', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getConfiguration', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getReserveData', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getReserveNormalizedIncome', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getReserveNormalizedVariableDebt', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getReservesList', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getUserAccountData', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getUserConfiguration', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'initReserve', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'initialize', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'liquidationCall', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'paused', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'rebalanceStableBorrowRate', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'repay', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'setConfiguration', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'setPause', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'setReserveInterestRateStrategyAddress', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'setUserUseReserveAsCollateral', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'swapBorrowRateMode', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'withdraw', data: BytesLike): Result; + + events: { + 'Borrow(address,address,address,uint256,uint256,uint256,uint16)': EventFragment; + 'Deposit(address,address,address,uint256,uint16)': EventFragment; + 'FlashLoan(address,address,address,uint256,uint256,uint16)': EventFragment; + 'LiquidationCall(address,address,address,uint256,uint256,address,bool)': EventFragment; + 'Paused()': EventFragment; + 'RebalanceStableBorrowRate(address,address)': EventFragment; + 'Repay(address,address,address,uint256)': EventFragment; + 'ReserveDataUpdated(address,uint256,uint256,uint256,uint256,uint256)': EventFragment; + 'ReserveUsedAsCollateralDisabled(address,address)': EventFragment; + 'ReserveUsedAsCollateralEnabled(address,address)': EventFragment; + 'Swap(address,address,uint256)': EventFragment; + 'Unpaused()': EventFragment; + 'Withdraw(address,address,address,uint256)': EventFragment; + }; + + getEvent(nameOrSignatureOrTopic: 'Borrow'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'Deposit'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'FlashLoan'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'LiquidationCall'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'Paused'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'RebalanceStableBorrowRate'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'Repay'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'ReserveDataUpdated'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'ReserveUsedAsCollateralDisabled'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'ReserveUsedAsCollateralEnabled'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'Swap'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'Unpaused'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'Withdraw'): EventFragment; +} + +export interface BorrowEventObject { + reserve: string; + user: string; + onBehalfOf: string; + amount: BigNumber; + borrowRateMode: BigNumber; + borrowRate: BigNumber; + referral: number; +} +export type BorrowEvent = TypedEvent< + [string, string, string, BigNumber, BigNumber, BigNumber, number], + BorrowEventObject +>; + +export type BorrowEventFilter = TypedEventFilter; + +export interface DepositEventObject { + reserve: string; + user: string; + onBehalfOf: string; + amount: BigNumber; + referral: number; +} +export type DepositEvent = TypedEvent<[string, string, string, BigNumber, number], DepositEventObject>; + +export type DepositEventFilter = TypedEventFilter; + +export interface FlashLoanEventObject { + target: string; + initiator: string; + asset: string; + amount: BigNumber; + premium: BigNumber; + referralCode: number; +} +export type FlashLoanEvent = TypedEvent<[string, string, string, BigNumber, BigNumber, number], FlashLoanEventObject>; + +export type FlashLoanEventFilter = TypedEventFilter; + +export interface LiquidationCallEventObject { + collateralAsset: string; + debtAsset: string; + user: string; + debtToCover: BigNumber; + liquidatedCollateralAmount: BigNumber; + liquidator: string; + receiveAToken: boolean; +} +export type LiquidationCallEvent = TypedEvent< + [string, string, string, BigNumber, BigNumber, string, boolean], + LiquidationCallEventObject +>; + +export type LiquidationCallEventFilter = TypedEventFilter; + +export interface PausedEventObject {} +export type PausedEvent = TypedEvent<[], PausedEventObject>; + +export type PausedEventFilter = TypedEventFilter; + +export interface RebalanceStableBorrowRateEventObject { + reserve: string; + user: string; +} +export type RebalanceStableBorrowRateEvent = TypedEvent<[string, string], RebalanceStableBorrowRateEventObject>; + +export type RebalanceStableBorrowRateEventFilter = TypedEventFilter; + +export interface RepayEventObject { + reserve: string; + user: string; + repayer: string; + amount: BigNumber; +} +export type RepayEvent = TypedEvent<[string, string, string, BigNumber], RepayEventObject>; + +export type RepayEventFilter = TypedEventFilter; + +export interface ReserveDataUpdatedEventObject { + reserve: string; + liquidityRate: BigNumber; + stableBorrowRate: BigNumber; + variableBorrowRate: BigNumber; + liquidityIndex: BigNumber; + variableBorrowIndex: BigNumber; +} +export type ReserveDataUpdatedEvent = TypedEvent< + [string, BigNumber, BigNumber, BigNumber, BigNumber, BigNumber], + ReserveDataUpdatedEventObject +>; + +export type ReserveDataUpdatedEventFilter = TypedEventFilter; + +export interface ReserveUsedAsCollateralDisabledEventObject { + reserve: string; + user: string; +} +export type ReserveUsedAsCollateralDisabledEvent = TypedEvent< + [string, string], + ReserveUsedAsCollateralDisabledEventObject +>; + +export type ReserveUsedAsCollateralDisabledEventFilter = TypedEventFilter; + +export interface ReserveUsedAsCollateralEnabledEventObject { + reserve: string; + user: string; +} +export type ReserveUsedAsCollateralEnabledEvent = TypedEvent< + [string, string], + ReserveUsedAsCollateralEnabledEventObject +>; + +export type ReserveUsedAsCollateralEnabledEventFilter = TypedEventFilter; + +export interface SwapEventObject { + reserve: string; + user: string; + rateMode: BigNumber; +} +export type SwapEvent = TypedEvent<[string, string, BigNumber], SwapEventObject>; + +export type SwapEventFilter = TypedEventFilter; + +export interface UnpausedEventObject {} +export type UnpausedEvent = TypedEvent<[], UnpausedEventObject>; + +export type UnpausedEventFilter = TypedEventFilter; + +export interface WithdrawEventObject { + reserve: string; + user: string; + to: string; + amount: BigNumber; +} +export type WithdrawEvent = TypedEvent<[string, string, string, BigNumber], WithdrawEventObject>; + +export type WithdrawEventFilter = TypedEventFilter; + +export interface LendingPool extends BaseContract { + connect(signerOrProvider: Signer | Provider | string): this; + attach(addressOrName: string): this; + deployed(): Promise; + + interface: LendingPoolInterface; + + queryFilter( + event: TypedEventFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>; + + listeners(eventFilter?: TypedEventFilter): Array>; + listeners(eventName?: string): Array; + removeAllListeners(eventFilter: TypedEventFilter): this; + removeAllListeners(eventName?: string): this; + off: OnEvent; + on: OnEvent; + once: OnEvent; + removeListener: OnEvent; + + functions: { + FLASHLOAN_PREMIUM_TOTAL(overrides?: CallOverrides): Promise<[BigNumber]>; + + LENDINGPOOL_REVISION(overrides?: CallOverrides): Promise<[BigNumber]>; + + MAX_NUMBER_RESERVES(overrides?: CallOverrides): Promise<[BigNumber]>; + + MAX_STABLE_RATE_BORROW_SIZE_PERCENT(overrides?: CallOverrides): Promise<[BigNumber]>; + + borrow( + asset: string, + amount: BigNumberish, + interestRateMode: BigNumberish, + referralCode: BigNumberish, + onBehalfOf: string, + overrides?: Overrides & { from?: string } + ): Promise; + + deposit( + asset: string, + amount: BigNumberish, + onBehalfOf: string, + referralCode: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + finalizeTransfer( + asset: string, + from: string, + to: string, + amount: BigNumberish, + balanceFromBefore: BigNumberish, + balanceToBefore: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + flashLoan( + receiverAddress: string, + assets: string[], + amounts: BigNumberish[], + modes: BigNumberish[], + onBehalfOf: string, + params: BytesLike, + referralCode: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + getAddressesProvider(overrides?: CallOverrides): Promise<[string]>; + + getConfiguration( + asset: string, + overrides?: CallOverrides + ): Promise<[DataTypes.ReserveConfigurationMapStructOutput]>; + + getReserveData(asset: string, overrides?: CallOverrides): Promise<[DataTypes.ReserveDataStructOutput]>; + + getReserveNormalizedIncome(asset: string, overrides?: CallOverrides): Promise<[BigNumber]>; + + getReserveNormalizedVariableDebt(asset: string, overrides?: CallOverrides): Promise<[BigNumber]>; + + getReservesList(overrides?: CallOverrides): Promise<[string[]]>; + + getUserAccountData( + user: string, + overrides?: CallOverrides + ): Promise< + [BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, BigNumber] & { + totalCollateralETH: BigNumber; + totalDebtETH: BigNumber; + availableBorrowsETH: BigNumber; + currentLiquidationThreshold: BigNumber; + ltv: BigNumber; + healthFactor: BigNumber; + } + >; + + getUserConfiguration( + user: string, + overrides?: CallOverrides + ): Promise<[DataTypes.UserConfigurationMapStructOutput]>; + + initReserve( + asset: string, + aTokenAddress: string, + stableDebtAddress: string, + variableDebtAddress: string, + interestRateStrategyAddress: string, + overrides?: Overrides & { from?: string } + ): Promise; + + initialize(provider: string, overrides?: Overrides & { from?: string }): Promise; + + liquidationCall( + collateralAsset: string, + debtAsset: string, + user: string, + debtToCover: BigNumberish, + receiveAToken: boolean, + overrides?: Overrides & { from?: string } + ): Promise; + + paused(overrides?: CallOverrides): Promise<[boolean]>; + + rebalanceStableBorrowRate( + asset: string, + user: string, + overrides?: Overrides & { from?: string } + ): Promise; + + repay( + asset: string, + amount: BigNumberish, + rateMode: BigNumberish, + onBehalfOf: string, + overrides?: Overrides & { from?: string } + ): Promise; + + setConfiguration( + asset: string, + configuration: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + setPause(val: boolean, overrides?: Overrides & { from?: string }): Promise; + + setReserveInterestRateStrategyAddress( + asset: string, + rateStrategyAddress: string, + overrides?: Overrides & { from?: string } + ): Promise; + + setUserUseReserveAsCollateral( + asset: string, + useAsCollateral: boolean, + overrides?: Overrides & { from?: string } + ): Promise; + + swapBorrowRateMode( + asset: string, + rateMode: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + withdraw( + asset: string, + amount: BigNumberish, + to: string, + overrides?: Overrides & { from?: string } + ): Promise; + }; + + FLASHLOAN_PREMIUM_TOTAL(overrides?: CallOverrides): Promise; + + LENDINGPOOL_REVISION(overrides?: CallOverrides): Promise; + + MAX_NUMBER_RESERVES(overrides?: CallOverrides): Promise; + + MAX_STABLE_RATE_BORROW_SIZE_PERCENT(overrides?: CallOverrides): Promise; + + borrow( + asset: string, + amount: BigNumberish, + interestRateMode: BigNumberish, + referralCode: BigNumberish, + onBehalfOf: string, + overrides?: Overrides & { from?: string } + ): Promise; + + deposit( + asset: string, + amount: BigNumberish, + onBehalfOf: string, + referralCode: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + finalizeTransfer( + asset: string, + from: string, + to: string, + amount: BigNumberish, + balanceFromBefore: BigNumberish, + balanceToBefore: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + flashLoan( + receiverAddress: string, + assets: string[], + amounts: BigNumberish[], + modes: BigNumberish[], + onBehalfOf: string, + params: BytesLike, + referralCode: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + getAddressesProvider(overrides?: CallOverrides): Promise; + + getConfiguration(asset: string, overrides?: CallOverrides): Promise; + + getReserveData(asset: string, overrides?: CallOverrides): Promise; + + getReserveNormalizedIncome(asset: string, overrides?: CallOverrides): Promise; + + getReserveNormalizedVariableDebt(asset: string, overrides?: CallOverrides): Promise; + + getReservesList(overrides?: CallOverrides): Promise; + + getUserAccountData( + user: string, + overrides?: CallOverrides + ): Promise< + [BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, BigNumber] & { + totalCollateralETH: BigNumber; + totalDebtETH: BigNumber; + availableBorrowsETH: BigNumber; + currentLiquidationThreshold: BigNumber; + ltv: BigNumber; + healthFactor: BigNumber; + } + >; + + getUserConfiguration(user: string, overrides?: CallOverrides): Promise; + + initReserve( + asset: string, + aTokenAddress: string, + stableDebtAddress: string, + variableDebtAddress: string, + interestRateStrategyAddress: string, + overrides?: Overrides & { from?: string } + ): Promise; + + initialize(provider: string, overrides?: Overrides & { from?: string }): Promise; + + liquidationCall( + collateralAsset: string, + debtAsset: string, + user: string, + debtToCover: BigNumberish, + receiveAToken: boolean, + overrides?: Overrides & { from?: string } + ): Promise; + + paused(overrides?: CallOverrides): Promise; + + rebalanceStableBorrowRate( + asset: string, + user: string, + overrides?: Overrides & { from?: string } + ): Promise; + + repay( + asset: string, + amount: BigNumberish, + rateMode: BigNumberish, + onBehalfOf: string, + overrides?: Overrides & { from?: string } + ): Promise; + + setConfiguration( + asset: string, + configuration: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + setPause(val: boolean, overrides?: Overrides & { from?: string }): Promise; + + setReserveInterestRateStrategyAddress( + asset: string, + rateStrategyAddress: string, + overrides?: Overrides & { from?: string } + ): Promise; + + setUserUseReserveAsCollateral( + asset: string, + useAsCollateral: boolean, + overrides?: Overrides & { from?: string } + ): Promise; + + swapBorrowRateMode( + asset: string, + rateMode: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + withdraw( + asset: string, + amount: BigNumberish, + to: string, + overrides?: Overrides & { from?: string } + ): Promise; + + callStatic: { + FLASHLOAN_PREMIUM_TOTAL(overrides?: CallOverrides): Promise; + + LENDINGPOOL_REVISION(overrides?: CallOverrides): Promise; + + MAX_NUMBER_RESERVES(overrides?: CallOverrides): Promise; + + MAX_STABLE_RATE_BORROW_SIZE_PERCENT(overrides?: CallOverrides): Promise; + + borrow( + asset: string, + amount: BigNumberish, + interestRateMode: BigNumberish, + referralCode: BigNumberish, + onBehalfOf: string, + overrides?: CallOverrides + ): Promise; + + deposit( + asset: string, + amount: BigNumberish, + onBehalfOf: string, + referralCode: BigNumberish, + overrides?: CallOverrides + ): Promise; + + finalizeTransfer( + asset: string, + from: string, + to: string, + amount: BigNumberish, + balanceFromBefore: BigNumberish, + balanceToBefore: BigNumberish, + overrides?: CallOverrides + ): Promise; + + flashLoan( + receiverAddress: string, + assets: string[], + amounts: BigNumberish[], + modes: BigNumberish[], + onBehalfOf: string, + params: BytesLike, + referralCode: BigNumberish, + overrides?: CallOverrides + ): Promise; + + getAddressesProvider(overrides?: CallOverrides): Promise; + + getConfiguration(asset: string, overrides?: CallOverrides): Promise; + + getReserveData(asset: string, overrides?: CallOverrides): Promise; + + getReserveNormalizedIncome(asset: string, overrides?: CallOverrides): Promise; + + getReserveNormalizedVariableDebt(asset: string, overrides?: CallOverrides): Promise; + + getReservesList(overrides?: CallOverrides): Promise; + + getUserAccountData( + user: string, + overrides?: CallOverrides + ): Promise< + [BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, BigNumber] & { + totalCollateralETH: BigNumber; + totalDebtETH: BigNumber; + availableBorrowsETH: BigNumber; + currentLiquidationThreshold: BigNumber; + ltv: BigNumber; + healthFactor: BigNumber; + } + >; + + getUserConfiguration(user: string, overrides?: CallOverrides): Promise; + + initReserve( + asset: string, + aTokenAddress: string, + stableDebtAddress: string, + variableDebtAddress: string, + interestRateStrategyAddress: string, + overrides?: CallOverrides + ): Promise; + + initialize(provider: string, overrides?: CallOverrides): Promise; + + liquidationCall( + collateralAsset: string, + debtAsset: string, + user: string, + debtToCover: BigNumberish, + receiveAToken: boolean, + overrides?: CallOverrides + ): Promise; + + paused(overrides?: CallOverrides): Promise; + + rebalanceStableBorrowRate(asset: string, user: string, overrides?: CallOverrides): Promise; + + repay( + asset: string, + amount: BigNumberish, + rateMode: BigNumberish, + onBehalfOf: string, + overrides?: CallOverrides + ): Promise; + + setConfiguration(asset: string, configuration: BigNumberish, overrides?: CallOverrides): Promise; + + setPause(val: boolean, overrides?: CallOverrides): Promise; + + setReserveInterestRateStrategyAddress( + asset: string, + rateStrategyAddress: string, + overrides?: CallOverrides + ): Promise; + + setUserUseReserveAsCollateral(asset: string, useAsCollateral: boolean, overrides?: CallOverrides): Promise; + + swapBorrowRateMode(asset: string, rateMode: BigNumberish, overrides?: CallOverrides): Promise; + + withdraw(asset: string, amount: BigNumberish, to: string, overrides?: CallOverrides): Promise; + }; + + filters: { + 'Borrow(address,address,address,uint256,uint256,uint256,uint16)'( + reserve?: string | null, + user?: null, + onBehalfOf?: string | null, + amount?: null, + borrowRateMode?: null, + borrowRate?: null, + referral?: BigNumberish | null + ): BorrowEventFilter; + Borrow( + reserve?: string | null, + user?: null, + onBehalfOf?: string | null, + amount?: null, + borrowRateMode?: null, + borrowRate?: null, + referral?: BigNumberish | null + ): BorrowEventFilter; + + 'Deposit(address,address,address,uint256,uint16)'( + reserve?: string | null, + user?: null, + onBehalfOf?: string | null, + amount?: null, + referral?: BigNumberish | null + ): DepositEventFilter; + Deposit( + reserve?: string | null, + user?: null, + onBehalfOf?: string | null, + amount?: null, + referral?: BigNumberish | null + ): DepositEventFilter; + + 'FlashLoan(address,address,address,uint256,uint256,uint16)'( + target?: string | null, + initiator?: string | null, + asset?: string | null, + amount?: null, + premium?: null, + referralCode?: null + ): FlashLoanEventFilter; + FlashLoan( + target?: string | null, + initiator?: string | null, + asset?: string | null, + amount?: null, + premium?: null, + referralCode?: null + ): FlashLoanEventFilter; + + 'LiquidationCall(address,address,address,uint256,uint256,address,bool)'( + collateralAsset?: string | null, + debtAsset?: string | null, + user?: string | null, + debtToCover?: null, + liquidatedCollateralAmount?: null, + liquidator?: null, + receiveAToken?: null + ): LiquidationCallEventFilter; + LiquidationCall( + collateralAsset?: string | null, + debtAsset?: string | null, + user?: string | null, + debtToCover?: null, + liquidatedCollateralAmount?: null, + liquidator?: null, + receiveAToken?: null + ): LiquidationCallEventFilter; + + 'Paused()'(): PausedEventFilter; + Paused(): PausedEventFilter; + + 'RebalanceStableBorrowRate(address,address)'( + reserve?: string | null, + user?: string | null + ): RebalanceStableBorrowRateEventFilter; + RebalanceStableBorrowRate(reserve?: string | null, user?: string | null): RebalanceStableBorrowRateEventFilter; + + 'Repay(address,address,address,uint256)'( + reserve?: string | null, + user?: string | null, + repayer?: string | null, + amount?: null + ): RepayEventFilter; + Repay(reserve?: string | null, user?: string | null, repayer?: string | null, amount?: null): RepayEventFilter; + + 'ReserveDataUpdated(address,uint256,uint256,uint256,uint256,uint256)'( + reserve?: string | null, + liquidityRate?: null, + stableBorrowRate?: null, + variableBorrowRate?: null, + liquidityIndex?: null, + variableBorrowIndex?: null + ): ReserveDataUpdatedEventFilter; + ReserveDataUpdated( + reserve?: string | null, + liquidityRate?: null, + stableBorrowRate?: null, + variableBorrowRate?: null, + liquidityIndex?: null, + variableBorrowIndex?: null + ): ReserveDataUpdatedEventFilter; + + 'ReserveUsedAsCollateralDisabled(address,address)'( + reserve?: string | null, + user?: string | null + ): ReserveUsedAsCollateralDisabledEventFilter; + ReserveUsedAsCollateralDisabled( + reserve?: string | null, + user?: string | null + ): ReserveUsedAsCollateralDisabledEventFilter; + + 'ReserveUsedAsCollateralEnabled(address,address)'( + reserve?: string | null, + user?: string | null + ): ReserveUsedAsCollateralEnabledEventFilter; + ReserveUsedAsCollateralEnabled( + reserve?: string | null, + user?: string | null + ): ReserveUsedAsCollateralEnabledEventFilter; + + 'Swap(address,address,uint256)'(reserve?: string | null, user?: string | null, rateMode?: null): SwapEventFilter; + Swap(reserve?: string | null, user?: string | null, rateMode?: null): SwapEventFilter; + + 'Unpaused()'(): UnpausedEventFilter; + Unpaused(): UnpausedEventFilter; + + 'Withdraw(address,address,address,uint256)'( + reserve?: string | null, + user?: string | null, + to?: string | null, + amount?: null + ): WithdrawEventFilter; + Withdraw(reserve?: string | null, user?: string | null, to?: string | null, amount?: null): WithdrawEventFilter; + }; + + estimateGas: { + FLASHLOAN_PREMIUM_TOTAL(overrides?: CallOverrides): Promise; + + LENDINGPOOL_REVISION(overrides?: CallOverrides): Promise; + + MAX_NUMBER_RESERVES(overrides?: CallOverrides): Promise; + + MAX_STABLE_RATE_BORROW_SIZE_PERCENT(overrides?: CallOverrides): Promise; + + borrow( + asset: string, + amount: BigNumberish, + interestRateMode: BigNumberish, + referralCode: BigNumberish, + onBehalfOf: string, + overrides?: Overrides & { from?: string } + ): Promise; + + deposit( + asset: string, + amount: BigNumberish, + onBehalfOf: string, + referralCode: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + finalizeTransfer( + asset: string, + from: string, + to: string, + amount: BigNumberish, + balanceFromBefore: BigNumberish, + balanceToBefore: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + flashLoan( + receiverAddress: string, + assets: string[], + amounts: BigNumberish[], + modes: BigNumberish[], + onBehalfOf: string, + params: BytesLike, + referralCode: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + getAddressesProvider(overrides?: CallOverrides): Promise; + + getConfiguration(asset: string, overrides?: CallOverrides): Promise; + + getReserveData(asset: string, overrides?: CallOverrides): Promise; + + getReserveNormalizedIncome(asset: string, overrides?: CallOverrides): Promise; + + getReserveNormalizedVariableDebt(asset: string, overrides?: CallOverrides): Promise; + + getReservesList(overrides?: CallOverrides): Promise; + + getUserAccountData(user: string, overrides?: CallOverrides): Promise; + + getUserConfiguration(user: string, overrides?: CallOverrides): Promise; + + initReserve( + asset: string, + aTokenAddress: string, + stableDebtAddress: string, + variableDebtAddress: string, + interestRateStrategyAddress: string, + overrides?: Overrides & { from?: string } + ): Promise; + + initialize(provider: string, overrides?: Overrides & { from?: string }): Promise; + + liquidationCall( + collateralAsset: string, + debtAsset: string, + user: string, + debtToCover: BigNumberish, + receiveAToken: boolean, + overrides?: Overrides & { from?: string } + ): Promise; + + paused(overrides?: CallOverrides): Promise; + + rebalanceStableBorrowRate( + asset: string, + user: string, + overrides?: Overrides & { from?: string } + ): Promise; + + repay( + asset: string, + amount: BigNumberish, + rateMode: BigNumberish, + onBehalfOf: string, + overrides?: Overrides & { from?: string } + ): Promise; + + setConfiguration( + asset: string, + configuration: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + setPause(val: boolean, overrides?: Overrides & { from?: string }): Promise; + + setReserveInterestRateStrategyAddress( + asset: string, + rateStrategyAddress: string, + overrides?: Overrides & { from?: string } + ): Promise; + + setUserUseReserveAsCollateral( + asset: string, + useAsCollateral: boolean, + overrides?: Overrides & { from?: string } + ): Promise; + + swapBorrowRateMode( + asset: string, + rateMode: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + withdraw( + asset: string, + amount: BigNumberish, + to: string, + overrides?: Overrides & { from?: string } + ): Promise; + }; + + populateTransaction: { + FLASHLOAN_PREMIUM_TOTAL(overrides?: CallOverrides): Promise; + + LENDINGPOOL_REVISION(overrides?: CallOverrides): Promise; + + MAX_NUMBER_RESERVES(overrides?: CallOverrides): Promise; + + MAX_STABLE_RATE_BORROW_SIZE_PERCENT(overrides?: CallOverrides): Promise; + + borrow( + asset: string, + amount: BigNumberish, + interestRateMode: BigNumberish, + referralCode: BigNumberish, + onBehalfOf: string, + overrides?: Overrides & { from?: string } + ): Promise; + + deposit( + asset: string, + amount: BigNumberish, + onBehalfOf: string, + referralCode: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + finalizeTransfer( + asset: string, + from: string, + to: string, + amount: BigNumberish, + balanceFromBefore: BigNumberish, + balanceToBefore: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + flashLoan( + receiverAddress: string, + assets: string[], + amounts: BigNumberish[], + modes: BigNumberish[], + onBehalfOf: string, + params: BytesLike, + referralCode: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + getAddressesProvider(overrides?: CallOverrides): Promise; + + getConfiguration(asset: string, overrides?: CallOverrides): Promise; + + getReserveData(asset: string, overrides?: CallOverrides): Promise; + + getReserveNormalizedIncome(asset: string, overrides?: CallOverrides): Promise; + + getReserveNormalizedVariableDebt(asset: string, overrides?: CallOverrides): Promise; + + getReservesList(overrides?: CallOverrides): Promise; + + getUserAccountData(user: string, overrides?: CallOverrides): Promise; + + getUserConfiguration(user: string, overrides?: CallOverrides): Promise; + + initReserve( + asset: string, + aTokenAddress: string, + stableDebtAddress: string, + variableDebtAddress: string, + interestRateStrategyAddress: string, + overrides?: Overrides & { from?: string } + ): Promise; + + initialize(provider: string, overrides?: Overrides & { from?: string }): Promise; + + liquidationCall( + collateralAsset: string, + debtAsset: string, + user: string, + debtToCover: BigNumberish, + receiveAToken: boolean, + overrides?: Overrides & { from?: string } + ): Promise; + + paused(overrides?: CallOverrides): Promise; + + rebalanceStableBorrowRate( + asset: string, + user: string, + overrides?: Overrides & { from?: string } + ): Promise; + + repay( + asset: string, + amount: BigNumberish, + rateMode: BigNumberish, + onBehalfOf: string, + overrides?: Overrides & { from?: string } + ): Promise; + + setConfiguration( + asset: string, + configuration: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + setPause(val: boolean, overrides?: Overrides & { from?: string }): Promise; + + setReserveInterestRateStrategyAddress( + asset: string, + rateStrategyAddress: string, + overrides?: Overrides & { from?: string } + ): Promise; + + setUserUseReserveAsCollateral( + asset: string, + useAsCollateral: boolean, + overrides?: Overrides & { from?: string } + ): Promise; + + swapBorrowRateMode( + asset: string, + rateMode: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + withdraw( + asset: string, + amount: BigNumberish, + to: string, + overrides?: Overrides & { from?: string } + ): Promise; + }; +} diff --git a/src/modules/aavev2/contracts/LendingPoolAddressesProvider.ts b/src/modules/aavev2/contracts/LendingPoolAddressesProvider.ts new file mode 100644 index 00000000..93503f89 --- /dev/null +++ b/src/modules/aavev2/contracts/LendingPoolAddressesProvider.ts @@ -0,0 +1,572 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + BaseContract, + BigNumber, + BytesLike, + CallOverrides, + ContractTransaction, + Overrides, + PopulatedTransaction, + Signer, + utils, +} from 'ethers'; +import type { FunctionFragment, Result, EventFragment } from '@ethersproject/abi'; +import type { Listener, Provider } from '@ethersproject/providers'; +import type { TypedEventFilter, TypedEvent, TypedListener, OnEvent } from './common'; + +export interface LendingPoolAddressesProviderInterface extends utils.Interface { + functions: { + 'getAddress(bytes32)': FunctionFragment; + 'getEmergencyAdmin()': FunctionFragment; + 'getLendingPool()': FunctionFragment; + 'getLendingPoolCollateralManager()': FunctionFragment; + 'getLendingPoolConfigurator()': FunctionFragment; + 'getLendingRateOracle()': FunctionFragment; + 'getMarketId()': FunctionFragment; + 'getPoolAdmin()': FunctionFragment; + 'getPriceOracle()': FunctionFragment; + 'owner()': FunctionFragment; + 'renounceOwnership()': FunctionFragment; + 'setAddress(bytes32,address)': FunctionFragment; + 'setAddressAsProxy(bytes32,address)': FunctionFragment; + 'setEmergencyAdmin(address)': FunctionFragment; + 'setLendingPoolCollateralManager(address)': FunctionFragment; + 'setLendingPoolConfiguratorImpl(address)': FunctionFragment; + 'setLendingPoolImpl(address)': FunctionFragment; + 'setLendingRateOracle(address)': FunctionFragment; + 'setMarketId(string)': FunctionFragment; + 'setPoolAdmin(address)': FunctionFragment; + 'setPriceOracle(address)': FunctionFragment; + 'transferOwnership(address)': FunctionFragment; + }; + + getFunction( + nameOrSignatureOrTopic: + | 'getAddress' + | 'getEmergencyAdmin' + | 'getLendingPool' + | 'getLendingPoolCollateralManager' + | 'getLendingPoolConfigurator' + | 'getLendingRateOracle' + | 'getMarketId' + | 'getPoolAdmin' + | 'getPriceOracle' + | 'owner' + | 'renounceOwnership' + | 'setAddress' + | 'setAddressAsProxy' + | 'setEmergencyAdmin' + | 'setLendingPoolCollateralManager' + | 'setLendingPoolConfiguratorImpl' + | 'setLendingPoolImpl' + | 'setLendingRateOracle' + | 'setMarketId' + | 'setPoolAdmin' + | 'setPriceOracle' + | 'transferOwnership' + ): FunctionFragment; + + encodeFunctionData(functionFragment: 'getAddress', values: [BytesLike]): string; + encodeFunctionData(functionFragment: 'getEmergencyAdmin', values?: undefined): string; + encodeFunctionData(functionFragment: 'getLendingPool', values?: undefined): string; + encodeFunctionData(functionFragment: 'getLendingPoolCollateralManager', values?: undefined): string; + encodeFunctionData(functionFragment: 'getLendingPoolConfigurator', values?: undefined): string; + encodeFunctionData(functionFragment: 'getLendingRateOracle', values?: undefined): string; + encodeFunctionData(functionFragment: 'getMarketId', values?: undefined): string; + encodeFunctionData(functionFragment: 'getPoolAdmin', values?: undefined): string; + encodeFunctionData(functionFragment: 'getPriceOracle', values?: undefined): string; + encodeFunctionData(functionFragment: 'owner', values?: undefined): string; + encodeFunctionData(functionFragment: 'renounceOwnership', values?: undefined): string; + encodeFunctionData(functionFragment: 'setAddress', values: [BytesLike, string]): string; + encodeFunctionData(functionFragment: 'setAddressAsProxy', values: [BytesLike, string]): string; + encodeFunctionData(functionFragment: 'setEmergencyAdmin', values: [string]): string; + encodeFunctionData(functionFragment: 'setLendingPoolCollateralManager', values: [string]): string; + encodeFunctionData(functionFragment: 'setLendingPoolConfiguratorImpl', values: [string]): string; + encodeFunctionData(functionFragment: 'setLendingPoolImpl', values: [string]): string; + encodeFunctionData(functionFragment: 'setLendingRateOracle', values: [string]): string; + encodeFunctionData(functionFragment: 'setMarketId', values: [string]): string; + encodeFunctionData(functionFragment: 'setPoolAdmin', values: [string]): string; + encodeFunctionData(functionFragment: 'setPriceOracle', values: [string]): string; + encodeFunctionData(functionFragment: 'transferOwnership', values: [string]): string; + + decodeFunctionResult(functionFragment: 'getAddress', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getEmergencyAdmin', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getLendingPool', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getLendingPoolCollateralManager', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getLendingPoolConfigurator', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getLendingRateOracle', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getMarketId', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getPoolAdmin', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getPriceOracle', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'owner', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'renounceOwnership', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'setAddress', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'setAddressAsProxy', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'setEmergencyAdmin', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'setLendingPoolCollateralManager', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'setLendingPoolConfiguratorImpl', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'setLendingPoolImpl', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'setLendingRateOracle', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'setMarketId', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'setPoolAdmin', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'setPriceOracle', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'transferOwnership', data: BytesLike): Result; + + events: { + 'AddressSet(bytes32,address,bool)': EventFragment; + 'ConfigurationAdminUpdated(address)': EventFragment; + 'EmergencyAdminUpdated(address)': EventFragment; + 'LendingPoolCollateralManagerUpdated(address)': EventFragment; + 'LendingPoolConfiguratorUpdated(address)': EventFragment; + 'LendingPoolUpdated(address)': EventFragment; + 'LendingRateOracleUpdated(address)': EventFragment; + 'MarketIdSet(string)': EventFragment; + 'OwnershipTransferred(address,address)': EventFragment; + 'PriceOracleUpdated(address)': EventFragment; + 'ProxyCreated(bytes32,address)': EventFragment; + }; + + getEvent(nameOrSignatureOrTopic: 'AddressSet'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'ConfigurationAdminUpdated'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'EmergencyAdminUpdated'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'LendingPoolCollateralManagerUpdated'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'LendingPoolConfiguratorUpdated'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'LendingPoolUpdated'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'LendingRateOracleUpdated'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'MarketIdSet'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'OwnershipTransferred'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'PriceOracleUpdated'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'ProxyCreated'): EventFragment; +} + +export interface AddressSetEventObject { + id: string; + newAddress: string; + hasProxy: boolean; +} +export type AddressSetEvent = TypedEvent<[string, string, boolean], AddressSetEventObject>; + +export type AddressSetEventFilter = TypedEventFilter; + +export interface ConfigurationAdminUpdatedEventObject { + newAddress: string; +} +export type ConfigurationAdminUpdatedEvent = TypedEvent<[string], ConfigurationAdminUpdatedEventObject>; + +export type ConfigurationAdminUpdatedEventFilter = TypedEventFilter; + +export interface EmergencyAdminUpdatedEventObject { + newAddress: string; +} +export type EmergencyAdminUpdatedEvent = TypedEvent<[string], EmergencyAdminUpdatedEventObject>; + +export type EmergencyAdminUpdatedEventFilter = TypedEventFilter; + +export interface LendingPoolCollateralManagerUpdatedEventObject { + newAddress: string; +} +export type LendingPoolCollateralManagerUpdatedEvent = TypedEvent< + [string], + LendingPoolCollateralManagerUpdatedEventObject +>; + +export type LendingPoolCollateralManagerUpdatedEventFilter = TypedEventFilter; + +export interface LendingPoolConfiguratorUpdatedEventObject { + newAddress: string; +} +export type LendingPoolConfiguratorUpdatedEvent = TypedEvent<[string], LendingPoolConfiguratorUpdatedEventObject>; + +export type LendingPoolConfiguratorUpdatedEventFilter = TypedEventFilter; + +export interface LendingPoolUpdatedEventObject { + newAddress: string; +} +export type LendingPoolUpdatedEvent = TypedEvent<[string], LendingPoolUpdatedEventObject>; + +export type LendingPoolUpdatedEventFilter = TypedEventFilter; + +export interface LendingRateOracleUpdatedEventObject { + newAddress: string; +} +export type LendingRateOracleUpdatedEvent = TypedEvent<[string], LendingRateOracleUpdatedEventObject>; + +export type LendingRateOracleUpdatedEventFilter = TypedEventFilter; + +export interface MarketIdSetEventObject { + newMarketId: string; +} +export type MarketIdSetEvent = TypedEvent<[string], MarketIdSetEventObject>; + +export type MarketIdSetEventFilter = TypedEventFilter; + +export interface OwnershipTransferredEventObject { + previousOwner: string; + newOwner: string; +} +export type OwnershipTransferredEvent = TypedEvent<[string, string], OwnershipTransferredEventObject>; + +export type OwnershipTransferredEventFilter = TypedEventFilter; + +export interface PriceOracleUpdatedEventObject { + newAddress: string; +} +export type PriceOracleUpdatedEvent = TypedEvent<[string], PriceOracleUpdatedEventObject>; + +export type PriceOracleUpdatedEventFilter = TypedEventFilter; + +export interface ProxyCreatedEventObject { + id: string; + newAddress: string; +} +export type ProxyCreatedEvent = TypedEvent<[string, string], ProxyCreatedEventObject>; + +export type ProxyCreatedEventFilter = TypedEventFilter; + +export interface LendingPoolAddressesProvider extends BaseContract { + connect(signerOrProvider: Signer | Provider | string): this; + attach(addressOrName: string): this; + deployed(): Promise; + + interface: LendingPoolAddressesProviderInterface; + + queryFilter( + event: TypedEventFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>; + + listeners(eventFilter?: TypedEventFilter): Array>; + listeners(eventName?: string): Array; + removeAllListeners(eventFilter: TypedEventFilter): this; + removeAllListeners(eventName?: string): this; + off: OnEvent; + on: OnEvent; + once: OnEvent; + removeListener: OnEvent; + + functions: { + getAddress(id: BytesLike, overrides?: CallOverrides): Promise<[string]>; + + getEmergencyAdmin(overrides?: CallOverrides): Promise<[string]>; + + getLendingPool(overrides?: CallOverrides): Promise<[string]>; + + getLendingPoolCollateralManager(overrides?: CallOverrides): Promise<[string]>; + + getLendingPoolConfigurator(overrides?: CallOverrides): Promise<[string]>; + + getLendingRateOracle(overrides?: CallOverrides): Promise<[string]>; + + getMarketId(overrides?: CallOverrides): Promise<[string]>; + + getPoolAdmin(overrides?: CallOverrides): Promise<[string]>; + + getPriceOracle(overrides?: CallOverrides): Promise<[string]>; + + owner(overrides?: CallOverrides): Promise<[string]>; + + renounceOwnership(overrides?: Overrides & { from?: string }): Promise; + + setAddress( + id: BytesLike, + newAddress: string, + overrides?: Overrides & { from?: string } + ): Promise; + + setAddressAsProxy( + id: BytesLike, + implementationAddress: string, + overrides?: Overrides & { from?: string } + ): Promise; + + setEmergencyAdmin(emergencyAdmin: string, overrides?: Overrides & { from?: string }): Promise; + + setLendingPoolCollateralManager( + manager: string, + overrides?: Overrides & { from?: string } + ): Promise; + + setLendingPoolConfiguratorImpl( + configurator: string, + overrides?: Overrides & { from?: string } + ): Promise; + + setLendingPoolImpl(pool: string, overrides?: Overrides & { from?: string }): Promise; + + setLendingRateOracle( + lendingRateOracle: string, + overrides?: Overrides & { from?: string } + ): Promise; + + setMarketId(marketId: string, overrides?: Overrides & { from?: string }): Promise; + + setPoolAdmin(admin: string, overrides?: Overrides & { from?: string }): Promise; + + setPriceOracle(priceOracle: string, overrides?: Overrides & { from?: string }): Promise; + + transferOwnership(newOwner: string, overrides?: Overrides & { from?: string }): Promise; + }; + + getAddress(id: BytesLike, overrides?: CallOverrides): Promise; + + getEmergencyAdmin(overrides?: CallOverrides): Promise; + + getLendingPool(overrides?: CallOverrides): Promise; + + getLendingPoolCollateralManager(overrides?: CallOverrides): Promise; + + getLendingPoolConfigurator(overrides?: CallOverrides): Promise; + + getLendingRateOracle(overrides?: CallOverrides): Promise; + + getMarketId(overrides?: CallOverrides): Promise; + + getPoolAdmin(overrides?: CallOverrides): Promise; + + getPriceOracle(overrides?: CallOverrides): Promise; + + owner(overrides?: CallOverrides): Promise; + + renounceOwnership(overrides?: Overrides & { from?: string }): Promise; + + setAddress( + id: BytesLike, + newAddress: string, + overrides?: Overrides & { from?: string } + ): Promise; + + setAddressAsProxy( + id: BytesLike, + implementationAddress: string, + overrides?: Overrides & { from?: string } + ): Promise; + + setEmergencyAdmin(emergencyAdmin: string, overrides?: Overrides & { from?: string }): Promise; + + setLendingPoolCollateralManager( + manager: string, + overrides?: Overrides & { from?: string } + ): Promise; + + setLendingPoolConfiguratorImpl( + configurator: string, + overrides?: Overrides & { from?: string } + ): Promise; + + setLendingPoolImpl(pool: string, overrides?: Overrides & { from?: string }): Promise; + + setLendingRateOracle( + lendingRateOracle: string, + overrides?: Overrides & { from?: string } + ): Promise; + + setMarketId(marketId: string, overrides?: Overrides & { from?: string }): Promise; + + setPoolAdmin(admin: string, overrides?: Overrides & { from?: string }): Promise; + + setPriceOracle(priceOracle: string, overrides?: Overrides & { from?: string }): Promise; + + transferOwnership(newOwner: string, overrides?: Overrides & { from?: string }): Promise; + + callStatic: { + getAddress(id: BytesLike, overrides?: CallOverrides): Promise; + + getEmergencyAdmin(overrides?: CallOverrides): Promise; + + getLendingPool(overrides?: CallOverrides): Promise; + + getLendingPoolCollateralManager(overrides?: CallOverrides): Promise; + + getLendingPoolConfigurator(overrides?: CallOverrides): Promise; + + getLendingRateOracle(overrides?: CallOverrides): Promise; + + getMarketId(overrides?: CallOverrides): Promise; + + getPoolAdmin(overrides?: CallOverrides): Promise; + + getPriceOracle(overrides?: CallOverrides): Promise; + + owner(overrides?: CallOverrides): Promise; + + renounceOwnership(overrides?: CallOverrides): Promise; + + setAddress(id: BytesLike, newAddress: string, overrides?: CallOverrides): Promise; + + setAddressAsProxy(id: BytesLike, implementationAddress: string, overrides?: CallOverrides): Promise; + + setEmergencyAdmin(emergencyAdmin: string, overrides?: CallOverrides): Promise; + + setLendingPoolCollateralManager(manager: string, overrides?: CallOverrides): Promise; + + setLendingPoolConfiguratorImpl(configurator: string, overrides?: CallOverrides): Promise; + + setLendingPoolImpl(pool: string, overrides?: CallOverrides): Promise; + + setLendingRateOracle(lendingRateOracle: string, overrides?: CallOverrides): Promise; + + setMarketId(marketId: string, overrides?: CallOverrides): Promise; + + setPoolAdmin(admin: string, overrides?: CallOverrides): Promise; + + setPriceOracle(priceOracle: string, overrides?: CallOverrides): Promise; + + transferOwnership(newOwner: string, overrides?: CallOverrides): Promise; + }; + + filters: { + 'AddressSet(bytes32,address,bool)'(id?: null, newAddress?: string | null, hasProxy?: null): AddressSetEventFilter; + AddressSet(id?: null, newAddress?: string | null, hasProxy?: null): AddressSetEventFilter; + + 'ConfigurationAdminUpdated(address)'(newAddress?: string | null): ConfigurationAdminUpdatedEventFilter; + ConfigurationAdminUpdated(newAddress?: string | null): ConfigurationAdminUpdatedEventFilter; + + 'EmergencyAdminUpdated(address)'(newAddress?: string | null): EmergencyAdminUpdatedEventFilter; + EmergencyAdminUpdated(newAddress?: string | null): EmergencyAdminUpdatedEventFilter; + + 'LendingPoolCollateralManagerUpdated(address)'( + newAddress?: string | null + ): LendingPoolCollateralManagerUpdatedEventFilter; + LendingPoolCollateralManagerUpdated(newAddress?: string | null): LendingPoolCollateralManagerUpdatedEventFilter; + + 'LendingPoolConfiguratorUpdated(address)'(newAddress?: string | null): LendingPoolConfiguratorUpdatedEventFilter; + LendingPoolConfiguratorUpdated(newAddress?: string | null): LendingPoolConfiguratorUpdatedEventFilter; + + 'LendingPoolUpdated(address)'(newAddress?: string | null): LendingPoolUpdatedEventFilter; + LendingPoolUpdated(newAddress?: string | null): LendingPoolUpdatedEventFilter; + + 'LendingRateOracleUpdated(address)'(newAddress?: string | null): LendingRateOracleUpdatedEventFilter; + LendingRateOracleUpdated(newAddress?: string | null): LendingRateOracleUpdatedEventFilter; + + 'MarketIdSet(string)'(newMarketId?: null): MarketIdSetEventFilter; + MarketIdSet(newMarketId?: null): MarketIdSetEventFilter; + + 'OwnershipTransferred(address,address)'( + previousOwner?: string | null, + newOwner?: string | null + ): OwnershipTransferredEventFilter; + OwnershipTransferred(previousOwner?: string | null, newOwner?: string | null): OwnershipTransferredEventFilter; + + 'PriceOracleUpdated(address)'(newAddress?: string | null): PriceOracleUpdatedEventFilter; + PriceOracleUpdated(newAddress?: string | null): PriceOracleUpdatedEventFilter; + + 'ProxyCreated(bytes32,address)'(id?: null, newAddress?: string | null): ProxyCreatedEventFilter; + ProxyCreated(id?: null, newAddress?: string | null): ProxyCreatedEventFilter; + }; + + estimateGas: { + getAddress(id: BytesLike, overrides?: CallOverrides): Promise; + + getEmergencyAdmin(overrides?: CallOverrides): Promise; + + getLendingPool(overrides?: CallOverrides): Promise; + + getLendingPoolCollateralManager(overrides?: CallOverrides): Promise; + + getLendingPoolConfigurator(overrides?: CallOverrides): Promise; + + getLendingRateOracle(overrides?: CallOverrides): Promise; + + getMarketId(overrides?: CallOverrides): Promise; + + getPoolAdmin(overrides?: CallOverrides): Promise; + + getPriceOracle(overrides?: CallOverrides): Promise; + + owner(overrides?: CallOverrides): Promise; + + renounceOwnership(overrides?: Overrides & { from?: string }): Promise; + + setAddress(id: BytesLike, newAddress: string, overrides?: Overrides & { from?: string }): Promise; + + setAddressAsProxy( + id: BytesLike, + implementationAddress: string, + overrides?: Overrides & { from?: string } + ): Promise; + + setEmergencyAdmin(emergencyAdmin: string, overrides?: Overrides & { from?: string }): Promise; + + setLendingPoolCollateralManager(manager: string, overrides?: Overrides & { from?: string }): Promise; + + setLendingPoolConfiguratorImpl(configurator: string, overrides?: Overrides & { from?: string }): Promise; + + setLendingPoolImpl(pool: string, overrides?: Overrides & { from?: string }): Promise; + + setLendingRateOracle(lendingRateOracle: string, overrides?: Overrides & { from?: string }): Promise; + + setMarketId(marketId: string, overrides?: Overrides & { from?: string }): Promise; + + setPoolAdmin(admin: string, overrides?: Overrides & { from?: string }): Promise; + + setPriceOracle(priceOracle: string, overrides?: Overrides & { from?: string }): Promise; + + transferOwnership(newOwner: string, overrides?: Overrides & { from?: string }): Promise; + }; + + populateTransaction: { + getAddress(id: BytesLike, overrides?: CallOverrides): Promise; + + getEmergencyAdmin(overrides?: CallOverrides): Promise; + + getLendingPool(overrides?: CallOverrides): Promise; + + getLendingPoolCollateralManager(overrides?: CallOverrides): Promise; + + getLendingPoolConfigurator(overrides?: CallOverrides): Promise; + + getLendingRateOracle(overrides?: CallOverrides): Promise; + + getMarketId(overrides?: CallOverrides): Promise; + + getPoolAdmin(overrides?: CallOverrides): Promise; + + getPriceOracle(overrides?: CallOverrides): Promise; + + owner(overrides?: CallOverrides): Promise; + + renounceOwnership(overrides?: Overrides & { from?: string }): Promise; + + setAddress( + id: BytesLike, + newAddress: string, + overrides?: Overrides & { from?: string } + ): Promise; + + setAddressAsProxy( + id: BytesLike, + implementationAddress: string, + overrides?: Overrides & { from?: string } + ): Promise; + + setEmergencyAdmin(emergencyAdmin: string, overrides?: Overrides & { from?: string }): Promise; + + setLendingPoolCollateralManager( + manager: string, + overrides?: Overrides & { from?: string } + ): Promise; + + setLendingPoolConfiguratorImpl( + configurator: string, + overrides?: Overrides & { from?: string } + ): Promise; + + setLendingPoolImpl(pool: string, overrides?: Overrides & { from?: string }): Promise; + + setLendingRateOracle( + lendingRateOracle: string, + overrides?: Overrides & { from?: string } + ): Promise; + + setMarketId(marketId: string, overrides?: Overrides & { from?: string }): Promise; + + setPoolAdmin(admin: string, overrides?: Overrides & { from?: string }): Promise; + + setPriceOracle(priceOracle: string, overrides?: Overrides & { from?: string }): Promise; + + transferOwnership(newOwner: string, overrides?: Overrides & { from?: string }): Promise; + }; +} diff --git a/src/modules/aavev2/contracts/ProtocolDataProvider.ts b/src/modules/aavev2/contracts/ProtocolDataProvider.ts new file mode 100644 index 00000000..c30d1600 --- /dev/null +++ b/src/modules/aavev2/contracts/ProtocolDataProvider.ts @@ -0,0 +1,331 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { BaseContract, BigNumber, BytesLike, CallOverrides, PopulatedTransaction, Signer, utils } from 'ethers'; +import type { FunctionFragment, Result } from '@ethersproject/abi'; +import type { Listener, Provider } from '@ethersproject/providers'; +import type { TypedEventFilter, TypedEvent, TypedListener, OnEvent } from './common'; + +export declare namespace AaveProtocolDataProvider { + export type TokenDataStruct = { symbol: string; tokenAddress: string }; + + export type TokenDataStructOutput = [string, string] & { + symbol: string; + tokenAddress: string; + }; +} + +export interface ProtocolDataProviderInterface extends utils.Interface { + functions: { + 'ADDRESSES_PROVIDER()': FunctionFragment; + 'getAllATokens()': FunctionFragment; + 'getAllReservesTokens()': FunctionFragment; + 'getReserveConfigurationData(address)': FunctionFragment; + 'getReserveData(address)': FunctionFragment; + 'getReserveTokensAddresses(address)': FunctionFragment; + 'getUserReserveData(address,address)': FunctionFragment; + }; + + getFunction( + nameOrSignatureOrTopic: + | 'ADDRESSES_PROVIDER' + | 'getAllATokens' + | 'getAllReservesTokens' + | 'getReserveConfigurationData' + | 'getReserveData' + | 'getReserveTokensAddresses' + | 'getUserReserveData' + ): FunctionFragment; + + encodeFunctionData(functionFragment: 'ADDRESSES_PROVIDER', values?: undefined): string; + encodeFunctionData(functionFragment: 'getAllATokens', values?: undefined): string; + encodeFunctionData(functionFragment: 'getAllReservesTokens', values?: undefined): string; + encodeFunctionData(functionFragment: 'getReserveConfigurationData', values: [string]): string; + encodeFunctionData(functionFragment: 'getReserveData', values: [string]): string; + encodeFunctionData(functionFragment: 'getReserveTokensAddresses', values: [string]): string; + encodeFunctionData(functionFragment: 'getUserReserveData', values: [string, string]): string; + + decodeFunctionResult(functionFragment: 'ADDRESSES_PROVIDER', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getAllATokens', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getAllReservesTokens', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getReserveConfigurationData', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getReserveData', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getReserveTokensAddresses', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getUserReserveData', data: BytesLike): Result; + + events: {}; +} + +export interface ProtocolDataProvider extends BaseContract { + connect(signerOrProvider: Signer | Provider | string): this; + attach(addressOrName: string): this; + deployed(): Promise; + + interface: ProtocolDataProviderInterface; + + queryFilter( + event: TypedEventFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>; + + listeners(eventFilter?: TypedEventFilter): Array>; + listeners(eventName?: string): Array; + removeAllListeners(eventFilter: TypedEventFilter): this; + removeAllListeners(eventName?: string): this; + off: OnEvent; + on: OnEvent; + once: OnEvent; + removeListener: OnEvent; + + functions: { + ADDRESSES_PROVIDER(overrides?: CallOverrides): Promise<[string]>; + + getAllATokens(overrides?: CallOverrides): Promise<[AaveProtocolDataProvider.TokenDataStructOutput[]]>; + + getAllReservesTokens(overrides?: CallOverrides): Promise<[AaveProtocolDataProvider.TokenDataStructOutput[]]>; + + getReserveConfigurationData( + asset: string, + overrides?: CallOverrides + ): Promise< + [BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, boolean, boolean, boolean, boolean, boolean] & { + decimals: BigNumber; + ltv: BigNumber; + liquidationThreshold: BigNumber; + liquidationBonus: BigNumber; + reserveFactor: BigNumber; + usageAsCollateralEnabled: boolean; + borrowingEnabled: boolean; + stableBorrowRateEnabled: boolean; + isActive: boolean; + isFrozen: boolean; + } + >; + + getReserveData( + asset: string, + overrides?: CallOverrides + ): Promise< + [BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, number] & { + availableLiquidity: BigNumber; + totalStableDebt: BigNumber; + totalVariableDebt: BigNumber; + liquidityRate: BigNumber; + variableBorrowRate: BigNumber; + stableBorrowRate: BigNumber; + averageStableBorrowRate: BigNumber; + liquidityIndex: BigNumber; + variableBorrowIndex: BigNumber; + lastUpdateTimestamp: number; + } + >; + + getReserveTokensAddresses( + asset: string, + overrides?: CallOverrides + ): Promise< + [string, string, string] & { + aTokenAddress: string; + stableDebtTokenAddress: string; + variableDebtTokenAddress: string; + } + >; + + getUserReserveData( + asset: string, + user: string, + overrides?: CallOverrides + ): Promise< + [BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, number, boolean] & { + currentATokenBalance: BigNumber; + currentStableDebt: BigNumber; + currentVariableDebt: BigNumber; + principalStableDebt: BigNumber; + scaledVariableDebt: BigNumber; + stableBorrowRate: BigNumber; + liquidityRate: BigNumber; + stableRateLastUpdated: number; + usageAsCollateralEnabled: boolean; + } + >; + }; + + ADDRESSES_PROVIDER(overrides?: CallOverrides): Promise; + + getAllATokens(overrides?: CallOverrides): Promise; + + getAllReservesTokens(overrides?: CallOverrides): Promise; + + getReserveConfigurationData( + asset: string, + overrides?: CallOverrides + ): Promise< + [BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, boolean, boolean, boolean, boolean, boolean] & { + decimals: BigNumber; + ltv: BigNumber; + liquidationThreshold: BigNumber; + liquidationBonus: BigNumber; + reserveFactor: BigNumber; + usageAsCollateralEnabled: boolean; + borrowingEnabled: boolean; + stableBorrowRateEnabled: boolean; + isActive: boolean; + isFrozen: boolean; + } + >; + + getReserveData( + asset: string, + overrides?: CallOverrides + ): Promise< + [BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, number] & { + availableLiquidity: BigNumber; + totalStableDebt: BigNumber; + totalVariableDebt: BigNumber; + liquidityRate: BigNumber; + variableBorrowRate: BigNumber; + stableBorrowRate: BigNumber; + averageStableBorrowRate: BigNumber; + liquidityIndex: BigNumber; + variableBorrowIndex: BigNumber; + lastUpdateTimestamp: number; + } + >; + + getReserveTokensAddresses( + asset: string, + overrides?: CallOverrides + ): Promise< + [string, string, string] & { + aTokenAddress: string; + stableDebtTokenAddress: string; + variableDebtTokenAddress: string; + } + >; + + getUserReserveData( + asset: string, + user: string, + overrides?: CallOverrides + ): Promise< + [BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, number, boolean] & { + currentATokenBalance: BigNumber; + currentStableDebt: BigNumber; + currentVariableDebt: BigNumber; + principalStableDebt: BigNumber; + scaledVariableDebt: BigNumber; + stableBorrowRate: BigNumber; + liquidityRate: BigNumber; + stableRateLastUpdated: number; + usageAsCollateralEnabled: boolean; + } + >; + + callStatic: { + ADDRESSES_PROVIDER(overrides?: CallOverrides): Promise; + + getAllATokens(overrides?: CallOverrides): Promise; + + getAllReservesTokens(overrides?: CallOverrides): Promise; + + getReserveConfigurationData( + asset: string, + overrides?: CallOverrides + ): Promise< + [BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, boolean, boolean, boolean, boolean, boolean] & { + decimals: BigNumber; + ltv: BigNumber; + liquidationThreshold: BigNumber; + liquidationBonus: BigNumber; + reserveFactor: BigNumber; + usageAsCollateralEnabled: boolean; + borrowingEnabled: boolean; + stableBorrowRateEnabled: boolean; + isActive: boolean; + isFrozen: boolean; + } + >; + + getReserveData( + asset: string, + overrides?: CallOverrides + ): Promise< + [BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, number] & { + availableLiquidity: BigNumber; + totalStableDebt: BigNumber; + totalVariableDebt: BigNumber; + liquidityRate: BigNumber; + variableBorrowRate: BigNumber; + stableBorrowRate: BigNumber; + averageStableBorrowRate: BigNumber; + liquidityIndex: BigNumber; + variableBorrowIndex: BigNumber; + lastUpdateTimestamp: number; + } + >; + + getReserveTokensAddresses( + asset: string, + overrides?: CallOverrides + ): Promise< + [string, string, string] & { + aTokenAddress: string; + stableDebtTokenAddress: string; + variableDebtTokenAddress: string; + } + >; + + getUserReserveData( + asset: string, + user: string, + overrides?: CallOverrides + ): Promise< + [BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, number, boolean] & { + currentATokenBalance: BigNumber; + currentStableDebt: BigNumber; + currentVariableDebt: BigNumber; + principalStableDebt: BigNumber; + scaledVariableDebt: BigNumber; + stableBorrowRate: BigNumber; + liquidityRate: BigNumber; + stableRateLastUpdated: number; + usageAsCollateralEnabled: boolean; + } + >; + }; + + filters: {}; + + estimateGas: { + ADDRESSES_PROVIDER(overrides?: CallOverrides): Promise; + + getAllATokens(overrides?: CallOverrides): Promise; + + getAllReservesTokens(overrides?: CallOverrides): Promise; + + getReserveConfigurationData(asset: string, overrides?: CallOverrides): Promise; + + getReserveData(asset: string, overrides?: CallOverrides): Promise; + + getReserveTokensAddresses(asset: string, overrides?: CallOverrides): Promise; + + getUserReserveData(asset: string, user: string, overrides?: CallOverrides): Promise; + }; + + populateTransaction: { + ADDRESSES_PROVIDER(overrides?: CallOverrides): Promise; + + getAllATokens(overrides?: CallOverrides): Promise; + + getAllReservesTokens(overrides?: CallOverrides): Promise; + + getReserveConfigurationData(asset: string, overrides?: CallOverrides): Promise; + + getReserveData(asset: string, overrides?: CallOverrides): Promise; + + getReserveTokensAddresses(asset: string, overrides?: CallOverrides): Promise; + + getUserReserveData(asset: string, user: string, overrides?: CallOverrides): Promise; + }; +} diff --git a/src/modules/aavev2/contracts/common.ts b/src/modules/aavev2/contracts/common.ts new file mode 100644 index 00000000..6cfb1042 --- /dev/null +++ b/src/modules/aavev2/contracts/common.ts @@ -0,0 +1,30 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { Listener } from '@ethersproject/providers'; +import type { Event, EventFilter } from 'ethers'; + +export interface TypedEvent = any, TArgsObject = any> extends Event { + args: TArgsArray & TArgsObject; +} + +export interface TypedEventFilter<_TEvent extends TypedEvent> extends EventFilter {} + +export interface TypedListener { + (...listenerArg: [...__TypechainArgsArray, TEvent]): void; +} + +type __TypechainArgsArray = T extends TypedEvent ? U : never; + +export interface OnEvent { + (eventFilter: TypedEventFilter, listener: TypedListener): TRes; + (eventName: string, listener: Listener): TRes; +} + +export type MinEthersFactory = { + deploy(...a: ARGS[]): Promise; +}; + +export type GetContractTypeFromFactory = F extends MinEthersFactory ? C : never; + +export type GetARGsTypeFromFactory = F extends MinEthersFactory ? Parameters : never; diff --git a/src/modules/aavev2/contracts/factories/AToken__factory.ts b/src/modules/aavev2/contracts/factories/AToken__factory.ts new file mode 100644 index 00000000..ca6c89ed --- /dev/null +++ b/src/modules/aavev2/contracts/factories/AToken__factory.ts @@ -0,0 +1,780 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Signer, utils } from 'ethers'; +import type { Provider } from '@ethersproject/providers'; +import type { AToken, ATokenInterface } from '../AToken'; + +const _abi = [ + { + inputs: [ + { + internalType: 'contract ILendingPool', + name: 'pool', + type: 'address', + }, + { + internalType: 'address', + name: 'underlyingAssetAddress', + type: 'address', + }, + { + internalType: 'address', + name: 'reserveTreasuryAddress', + type: 'address', + }, + { + internalType: 'string', + name: 'tokenName', + type: 'string', + }, + { + internalType: 'string', + name: 'tokenSymbol', + type: 'string', + }, + { + internalType: 'address', + name: 'incentivesController', + type: 'address', + }, + ], + stateMutability: 'nonpayable', + type: 'constructor', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'owner', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'spender', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'value', + type: 'uint256', + }, + ], + name: 'Approval', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'from', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'to', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'value', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'index', + type: 'uint256', + }, + ], + name: 'BalanceTransfer', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'from', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'target', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'value', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'index', + type: 'uint256', + }, + ], + name: 'Burn', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'from', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'value', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'index', + type: 'uint256', + }, + ], + name: 'Mint', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'from', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'to', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'value', + type: 'uint256', + }, + ], + name: 'Transfer', + type: 'event', + }, + { + inputs: [], + name: 'ATOKEN_REVISION', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'DOMAIN_SEPARATOR', + outputs: [ + { + internalType: 'bytes32', + name: '', + type: 'bytes32', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'EIP712_REVISION', + outputs: [ + { + internalType: 'bytes', + name: '', + type: 'bytes', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'PERMIT_TYPEHASH', + outputs: [ + { + internalType: 'bytes32', + name: '', + type: 'bytes32', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'POOL', + outputs: [ + { + internalType: 'contract ILendingPool', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'RESERVE_TREASURY_ADDRESS', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'UINT_MAX_VALUE', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'UNDERLYING_ASSET_ADDRESS', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + name: '_nonces', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'owner', + type: 'address', + }, + { + internalType: 'address', + name: 'spender', + type: 'address', + }, + ], + name: 'allowance', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'spender', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'approve', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'user', + type: 'address', + }, + ], + name: 'balanceOf', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'user', + type: 'address', + }, + { + internalType: 'address', + name: 'receiverOfUnderlying', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'index', + type: 'uint256', + }, + ], + name: 'burn', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'decimals', + outputs: [ + { + internalType: 'uint8', + name: '', + type: 'uint8', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'spender', + type: 'address', + }, + { + internalType: 'uint256', + name: 'subtractedValue', + type: 'uint256', + }, + ], + name: 'decreaseAllowance', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'user', + type: 'address', + }, + ], + name: 'getScaledUserBalanceAndSupply', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'spender', + type: 'address', + }, + { + internalType: 'uint256', + name: 'addedValue', + type: 'uint256', + }, + ], + name: 'increaseAllowance', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint8', + name: 'underlyingAssetDecimals', + type: 'uint8', + }, + { + internalType: 'string', + name: 'tokenName', + type: 'string', + }, + { + internalType: 'string', + name: 'tokenSymbol', + type: 'string', + }, + ], + name: 'initialize', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'user', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'index', + type: 'uint256', + }, + ], + name: 'mint', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'index', + type: 'uint256', + }, + ], + name: 'mintToTreasury', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'name', + outputs: [ + { + internalType: 'string', + name: '', + type: 'string', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'owner', + type: 'address', + }, + { + internalType: 'address', + name: 'spender', + type: 'address', + }, + { + internalType: 'uint256', + name: 'value', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'deadline', + type: 'uint256', + }, + { + internalType: 'uint8', + name: 'v', + type: 'uint8', + }, + { + internalType: 'bytes32', + name: 'r', + type: 'bytes32', + }, + { + internalType: 'bytes32', + name: 's', + type: 'bytes32', + }, + ], + name: 'permit', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'user', + type: 'address', + }, + ], + name: 'scaledBalanceOf', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'scaledTotalSupply', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'symbol', + outputs: [ + { + internalType: 'string', + name: '', + type: 'string', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'totalSupply', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'recipient', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'transfer', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'sender', + type: 'address', + }, + { + internalType: 'address', + name: 'recipient', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'transferFrom', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'from', + type: 'address', + }, + { + internalType: 'address', + name: 'to', + type: 'address', + }, + { + internalType: 'uint256', + name: 'value', + type: 'uint256', + }, + ], + name: 'transferOnLiquidation', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'target', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'transferUnderlyingTo', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, +] as const; + +export class AToken__factory { + static readonly abi = _abi; + static createInterface(): ATokenInterface { + return new utils.Interface(_abi) as ATokenInterface; + } + static connect(address: string, signerOrProvider: Signer | Provider): AToken { + return new Contract(address, _abi, signerOrProvider) as AToken; + } +} diff --git a/src/modules/aavev2/contracts/factories/AaveV2FlashLoanCallback__factory.ts b/src/modules/aavev2/contracts/factories/AaveV2FlashLoanCallback__factory.ts new file mode 100644 index 00000000..1d1ce11f --- /dev/null +++ b/src/modules/aavev2/contracts/factories/AaveV2FlashLoanCallback__factory.ts @@ -0,0 +1,148 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Signer, utils } from 'ethers'; +import type { Provider } from '@ethersproject/providers'; +import type { AaveV2FlashLoanCallback, AaveV2FlashLoanCallbackInterface } from '../AaveV2FlashLoanCallback'; + +const _abi = [ + { + inputs: [ + { + internalType: 'address', + name: 'router_', + type: 'address', + }, + { + internalType: 'address', + name: 'aaveV2Provider_', + type: 'address', + }, + { + internalType: 'uint256', + name: 'feeRate_', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'constructor', + }, + { + inputs: [ + { + internalType: 'address', + name: 'asset', + type: 'address', + }, + ], + name: 'InvalidBalance', + type: 'error', + }, + { + inputs: [], + name: 'InvalidCaller', + type: 'error', + }, + { + inputs: [], + name: 'aaveV2Provider', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address[]', + name: 'assets', + type: 'address[]', + }, + { + internalType: 'uint256[]', + name: 'amounts', + type: 'uint256[]', + }, + { + internalType: 'uint256[]', + name: 'premiums', + type: 'uint256[]', + }, + { + internalType: 'address', + name: '', + type: 'address', + }, + { + internalType: 'bytes', + name: 'params', + type: 'bytes', + }, + ], + name: 'executeOperation', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'feeRate', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'metadata', + outputs: [ + { + internalType: 'bytes32', + name: '', + type: 'bytes32', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'router', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, +] as const; + +export class AaveV2FlashLoanCallback__factory { + static readonly abi = _abi; + static createInterface(): AaveV2FlashLoanCallbackInterface { + return new utils.Interface(_abi) as AaveV2FlashLoanCallbackInterface; + } + static connect(address: string, signerOrProvider: Signer | Provider): AaveV2FlashLoanCallback { + return new Contract(address, _abi, signerOrProvider) as AaveV2FlashLoanCallback; + } +} diff --git a/src/modules/aavev2/contracts/factories/DebtTokenBase__factory.ts b/src/modules/aavev2/contracts/factories/DebtTokenBase__factory.ts new file mode 100644 index 00000000..5b06acb9 --- /dev/null +++ b/src/modules/aavev2/contracts/factories/DebtTokenBase__factory.ts @@ -0,0 +1,62 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Signer, utils } from 'ethers'; +import type { Provider } from '@ethersproject/providers'; +import type { DebtTokenBase, DebtTokenBaseInterface } from '../DebtTokenBase'; + +const _abi = [ + { + 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', + }, +] as const; + +export class DebtTokenBase__factory { + static readonly abi = _abi; + static createInterface(): DebtTokenBaseInterface { + return new utils.Interface(_abi) as DebtTokenBaseInterface; + } + static connect(address: string, signerOrProvider: Signer | Provider): DebtTokenBase { + return new Contract(address, _abi, signerOrProvider) as DebtTokenBase; + } +} diff --git a/src/modules/aavev2/contracts/factories/LendingPoolAddressesProvider__factory.ts b/src/modules/aavev2/contracts/factories/LendingPoolAddressesProvider__factory.ts new file mode 100644 index 00000000..926a4ded --- /dev/null +++ b/src/modules/aavev2/contracts/factories/LendingPoolAddressesProvider__factory.ts @@ -0,0 +1,497 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Signer, utils } from 'ethers'; +import type { Provider } from '@ethersproject/providers'; +import type { + LendingPoolAddressesProvider, + LendingPoolAddressesProviderInterface, +} from '../LendingPoolAddressesProvider'; + +const _abi = [ + { + inputs: [ + { + internalType: 'string', + name: 'marketId', + type: 'string', + }, + ], + stateMutability: 'nonpayable', + type: 'constructor', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'bytes32', + name: 'id', + type: 'bytes32', + }, + { + indexed: true, + internalType: 'address', + name: 'newAddress', + type: 'address', + }, + { + indexed: false, + internalType: 'bool', + name: 'hasProxy', + type: 'bool', + }, + ], + name: 'AddressSet', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'newAddress', + type: 'address', + }, + ], + name: 'ConfigurationAdminUpdated', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'newAddress', + type: 'address', + }, + ], + name: 'EmergencyAdminUpdated', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'newAddress', + type: 'address', + }, + ], + name: 'LendingPoolCollateralManagerUpdated', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'newAddress', + type: 'address', + }, + ], + name: 'LendingPoolConfiguratorUpdated', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'newAddress', + type: 'address', + }, + ], + name: 'LendingPoolUpdated', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'newAddress', + type: 'address', + }, + ], + name: 'LendingRateOracleUpdated', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'string', + name: 'newMarketId', + type: 'string', + }, + ], + name: 'MarketIdSet', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'previousOwner', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'newOwner', + type: 'address', + }, + ], + name: 'OwnershipTransferred', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'newAddress', + type: 'address', + }, + ], + name: 'PriceOracleUpdated', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'bytes32', + name: 'id', + type: 'bytes32', + }, + { + indexed: true, + internalType: 'address', + name: 'newAddress', + type: 'address', + }, + ], + name: 'ProxyCreated', + type: 'event', + }, + { + inputs: [ + { + internalType: 'bytes32', + name: 'id', + type: 'bytes32', + }, + ], + name: 'getAddress', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getEmergencyAdmin', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getLendingPool', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getLendingPoolCollateralManager', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getLendingPoolConfigurator', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getLendingRateOracle', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getMarketId', + outputs: [ + { + internalType: 'string', + name: '', + type: 'string', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getPoolAdmin', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getPriceOracle', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'owner', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'renounceOwnership', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'bytes32', + name: 'id', + type: 'bytes32', + }, + { + internalType: 'address', + name: 'newAddress', + type: 'address', + }, + ], + name: 'setAddress', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'bytes32', + name: 'id', + type: 'bytes32', + }, + { + internalType: 'address', + name: 'implementationAddress', + type: 'address', + }, + ], + name: 'setAddressAsProxy', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'emergencyAdmin', + type: 'address', + }, + ], + name: 'setEmergencyAdmin', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'manager', + type: 'address', + }, + ], + name: 'setLendingPoolCollateralManager', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'configurator', + type: 'address', + }, + ], + name: 'setLendingPoolConfiguratorImpl', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'pool', + type: 'address', + }, + ], + name: 'setLendingPoolImpl', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'lendingRateOracle', + type: 'address', + }, + ], + name: 'setLendingRateOracle', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'string', + name: 'marketId', + type: 'string', + }, + ], + name: 'setMarketId', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'admin', + type: 'address', + }, + ], + name: 'setPoolAdmin', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'priceOracle', + type: 'address', + }, + ], + name: 'setPriceOracle', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'newOwner', + type: 'address', + }, + ], + name: 'transferOwnership', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, +] as const; + +export class LendingPoolAddressesProvider__factory { + static readonly abi = _abi; + static createInterface(): LendingPoolAddressesProviderInterface { + return new utils.Interface(_abi) as LendingPoolAddressesProviderInterface; + } + static connect(address: string, signerOrProvider: Signer | Provider): LendingPoolAddressesProvider { + return new Contract(address, _abi, signerOrProvider) as LendingPoolAddressesProvider; + } +} diff --git a/src/modules/aavev2/contracts/factories/LendingPool__factory.ts b/src/modules/aavev2/contracts/factories/LendingPool__factory.ts new file mode 100644 index 00000000..fe08503f --- /dev/null +++ b/src/modules/aavev2/contracts/factories/LendingPool__factory.ts @@ -0,0 +1,1097 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Signer, utils } from 'ethers'; +import type { Provider } from '@ethersproject/providers'; +import type { LendingPool, LendingPoolInterface } from '../LendingPool'; + +const _abi = [ + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'reserve', + type: 'address', + }, + { + indexed: false, + internalType: 'address', + name: 'user', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'onBehalfOf', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'borrowRateMode', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'borrowRate', + type: 'uint256', + }, + { + indexed: true, + internalType: 'uint16', + name: 'referral', + type: 'uint16', + }, + ], + name: 'Borrow', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'reserve', + type: 'address', + }, + { + indexed: false, + internalType: 'address', + name: 'user', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'onBehalfOf', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { + indexed: true, + internalType: 'uint16', + name: 'referral', + type: 'uint16', + }, + ], + name: 'Deposit', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'target', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'initiator', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'asset', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'premium', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint16', + name: 'referralCode', + type: 'uint16', + }, + ], + name: 'FlashLoan', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'collateralAsset', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'debtAsset', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'user', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'debtToCover', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'liquidatedCollateralAmount', + type: 'uint256', + }, + { + indexed: false, + internalType: 'address', + name: 'liquidator', + type: 'address', + }, + { + indexed: false, + internalType: 'bool', + name: 'receiveAToken', + type: 'bool', + }, + ], + name: 'LiquidationCall', + type: 'event', + }, + { + anonymous: false, + inputs: [], + name: 'Paused', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'reserve', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'user', + type: 'address', + }, + ], + name: 'RebalanceStableBorrowRate', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'reserve', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'user', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'repayer', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'Repay', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'reserve', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'liquidityRate', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'stableBorrowRate', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'variableBorrowRate', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'liquidityIndex', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'variableBorrowIndex', + type: 'uint256', + }, + ], + name: 'ReserveDataUpdated', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'reserve', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'user', + type: 'address', + }, + ], + name: 'ReserveUsedAsCollateralDisabled', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'reserve', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'user', + type: 'address', + }, + ], + name: 'ReserveUsedAsCollateralEnabled', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'reserve', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'user', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'rateMode', + type: 'uint256', + }, + ], + name: 'Swap', + type: 'event', + }, + { + anonymous: false, + inputs: [], + name: 'Unpaused', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'reserve', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'user', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'to', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'Withdraw', + type: 'event', + }, + { + inputs: [], + name: 'FLASHLOAN_PREMIUM_TOTAL', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'LENDINGPOOL_REVISION', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'MAX_NUMBER_RESERVES', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'MAX_STABLE_RATE_BORROW_SIZE_PERCENT', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'asset', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'interestRateMode', + type: 'uint256', + }, + { + internalType: 'uint16', + name: 'referralCode', + type: 'uint16', + }, + { + internalType: 'address', + name: 'onBehalfOf', + type: 'address', + }, + ], + name: 'borrow', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'asset', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { + internalType: 'address', + name: 'onBehalfOf', + type: 'address', + }, + { + internalType: 'uint16', + name: 'referralCode', + type: 'uint16', + }, + ], + name: 'deposit', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'asset', + type: 'address', + }, + { + internalType: 'address', + name: 'from', + type: 'address', + }, + { + internalType: 'address', + name: 'to', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'balanceFromBefore', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'balanceToBefore', + type: 'uint256', + }, + ], + name: 'finalizeTransfer', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'receiverAddress', + type: 'address', + }, + { + internalType: 'address[]', + name: 'assets', + type: 'address[]', + }, + { + internalType: 'uint256[]', + name: 'amounts', + type: 'uint256[]', + }, + { + internalType: 'uint256[]', + name: 'modes', + type: 'uint256[]', + }, + { + internalType: 'address', + name: 'onBehalfOf', + type: 'address', + }, + { + internalType: 'bytes', + name: 'params', + type: 'bytes', + }, + { + internalType: 'uint16', + name: 'referralCode', + type: 'uint16', + }, + ], + name: 'flashLoan', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'getAddressesProvider', + outputs: [ + { + internalType: 'contract ILendingPoolAddressesProvider', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'asset', + type: 'address', + }, + ], + name: 'getConfiguration', + outputs: [ + { + components: [ + { + internalType: 'uint256', + name: 'data', + type: 'uint256', + }, + ], + internalType: 'struct DataTypes.ReserveConfigurationMap', + name: '', + type: 'tuple', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'asset', + type: 'address', + }, + ], + name: 'getReserveData', + outputs: [ + { + components: [ + { + components: [ + { + internalType: 'uint256', + name: 'data', + type: 'uint256', + }, + ], + internalType: 'struct DataTypes.ReserveConfigurationMap', + name: 'configuration', + type: 'tuple', + }, + { + internalType: 'uint128', + name: 'liquidityIndex', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'variableBorrowIndex', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'currentLiquidityRate', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'currentVariableBorrowRate', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'currentStableBorrowRate', + type: 'uint128', + }, + { + internalType: 'uint40', + name: 'lastUpdateTimestamp', + type: 'uint40', + }, + { + internalType: 'address', + name: 'aTokenAddress', + type: 'address', + }, + { + internalType: 'address', + name: 'stableDebtTokenAddress', + type: 'address', + }, + { + internalType: 'address', + name: 'variableDebtTokenAddress', + type: 'address', + }, + { + internalType: 'address', + name: 'interestRateStrategyAddress', + type: 'address', + }, + { + internalType: 'uint8', + name: 'id', + type: 'uint8', + }, + ], + internalType: 'struct DataTypes.ReserveData', + name: '', + type: 'tuple', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'asset', + type: 'address', + }, + ], + name: 'getReserveNormalizedIncome', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'asset', + type: 'address', + }, + ], + name: 'getReserveNormalizedVariableDebt', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getReservesList', + outputs: [ + { + internalType: 'address[]', + name: '', + type: 'address[]', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'user', + type: 'address', + }, + ], + name: 'getUserAccountData', + outputs: [ + { + internalType: 'uint256', + name: 'totalCollateralETH', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'totalDebtETH', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'availableBorrowsETH', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'currentLiquidationThreshold', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'ltv', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'healthFactor', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'user', + type: 'address', + }, + ], + name: 'getUserConfiguration', + outputs: [ + { + components: [ + { + internalType: 'uint256', + name: 'data', + type: 'uint256', + }, + ], + internalType: 'struct DataTypes.UserConfigurationMap', + name: '', + type: 'tuple', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'asset', + type: 'address', + }, + { + internalType: 'address', + name: 'aTokenAddress', + type: 'address', + }, + { + internalType: 'address', + name: 'stableDebtAddress', + type: 'address', + }, + { + internalType: 'address', + name: 'variableDebtAddress', + type: 'address', + }, + { + internalType: 'address', + name: 'interestRateStrategyAddress', + type: 'address', + }, + ], + name: 'initReserve', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'contract ILendingPoolAddressesProvider', + name: 'provider', + type: 'address', + }, + ], + name: 'initialize', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'collateralAsset', + type: 'address', + }, + { + internalType: 'address', + name: 'debtAsset', + type: 'address', + }, + { + internalType: 'address', + name: 'user', + type: 'address', + }, + { + internalType: 'uint256', + name: 'debtToCover', + type: 'uint256', + }, + { + internalType: 'bool', + name: 'receiveAToken', + type: 'bool', + }, + ], + name: 'liquidationCall', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'paused', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'asset', + type: 'address', + }, + { + internalType: 'address', + name: 'user', + type: 'address', + }, + ], + name: 'rebalanceStableBorrowRate', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'asset', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'rateMode', + type: 'uint256', + }, + { + internalType: 'address', + name: 'onBehalfOf', + type: 'address', + }, + ], + name: 'repay', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'asset', + type: 'address', + }, + { + internalType: 'uint256', + name: 'configuration', + type: 'uint256', + }, + ], + name: 'setConfiguration', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'bool', + name: 'val', + type: 'bool', + }, + ], + name: 'setPause', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'asset', + type: 'address', + }, + { + internalType: 'address', + name: 'rateStrategyAddress', + type: 'address', + }, + ], + name: 'setReserveInterestRateStrategyAddress', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'asset', + type: 'address', + }, + { + internalType: 'bool', + name: 'useAsCollateral', + type: 'bool', + }, + ], + name: 'setUserUseReserveAsCollateral', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'asset', + type: 'address', + }, + { + internalType: 'uint256', + name: 'rateMode', + type: 'uint256', + }, + ], + name: 'swapBorrowRateMode', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'asset', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { + internalType: 'address', + name: 'to', + type: 'address', + }, + ], + name: 'withdraw', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, +] as const; + +export class LendingPool__factory { + static readonly abi = _abi; + static createInterface(): LendingPoolInterface { + return new utils.Interface(_abi) as LendingPoolInterface; + } + static connect(address: string, signerOrProvider: Signer | Provider): LendingPool { + return new Contract(address, _abi, signerOrProvider) as LendingPool; + } +} diff --git a/src/modules/aavev2/contracts/factories/ProtocolDataProvider__factory.ts b/src/modules/aavev2/contracts/factories/ProtocolDataProvider__factory.ts new file mode 100644 index 00000000..6d5596ce --- /dev/null +++ b/src/modules/aavev2/contracts/factories/ProtocolDataProvider__factory.ts @@ -0,0 +1,315 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Signer, utils } from 'ethers'; +import type { Provider } from '@ethersproject/providers'; +import type { ProtocolDataProvider, ProtocolDataProviderInterface } from '../ProtocolDataProvider'; + +const _abi = [ + { + inputs: [ + { + internalType: 'contract ILendingPoolAddressesProvider', + name: 'addressesProvider', + type: 'address', + }, + ], + stateMutability: 'nonpayable', + type: 'constructor', + }, + { + inputs: [], + name: 'ADDRESSES_PROVIDER', + outputs: [ + { + internalType: 'contract ILendingPoolAddressesProvider', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getAllATokens', + outputs: [ + { + components: [ + { + internalType: 'string', + name: 'symbol', + type: 'string', + }, + { + internalType: 'address', + name: 'tokenAddress', + type: 'address', + }, + ], + internalType: 'struct AaveProtocolDataProvider.TokenData[]', + name: '', + type: 'tuple[]', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getAllReservesTokens', + outputs: [ + { + components: [ + { + internalType: 'string', + name: 'symbol', + type: 'string', + }, + { + internalType: 'address', + name: 'tokenAddress', + type: 'address', + }, + ], + internalType: 'struct AaveProtocolDataProvider.TokenData[]', + name: '', + type: 'tuple[]', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'asset', + type: 'address', + }, + ], + name: 'getReserveConfigurationData', + outputs: [ + { + internalType: 'uint256', + name: 'decimals', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'ltv', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'liquidationThreshold', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'liquidationBonus', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'reserveFactor', + type: 'uint256', + }, + { + internalType: 'bool', + name: 'usageAsCollateralEnabled', + type: 'bool', + }, + { + internalType: 'bool', + name: 'borrowingEnabled', + type: 'bool', + }, + { + internalType: 'bool', + name: 'stableBorrowRateEnabled', + type: 'bool', + }, + { + internalType: 'bool', + name: 'isActive', + type: 'bool', + }, + { + internalType: 'bool', + name: 'isFrozen', + type: 'bool', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'asset', + type: 'address', + }, + ], + name: 'getReserveData', + outputs: [ + { + internalType: 'uint256', + name: 'availableLiquidity', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'totalStableDebt', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'totalVariableDebt', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'liquidityRate', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'variableBorrowRate', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'stableBorrowRate', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'averageStableBorrowRate', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'liquidityIndex', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'variableBorrowIndex', + type: 'uint256', + }, + { + internalType: 'uint40', + name: 'lastUpdateTimestamp', + type: 'uint40', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'asset', + type: 'address', + }, + ], + name: 'getReserveTokensAddresses', + outputs: [ + { + internalType: 'address', + name: 'aTokenAddress', + type: 'address', + }, + { + internalType: 'address', + name: 'stableDebtTokenAddress', + type: 'address', + }, + { + internalType: 'address', + name: 'variableDebtTokenAddress', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'asset', + type: 'address', + }, + { + internalType: 'address', + name: 'user', + type: 'address', + }, + ], + name: 'getUserReserveData', + outputs: [ + { + internalType: 'uint256', + name: 'currentATokenBalance', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'currentStableDebt', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'currentVariableDebt', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'principalStableDebt', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'scaledVariableDebt', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'stableBorrowRate', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'liquidityRate', + type: 'uint256', + }, + { + internalType: 'uint40', + name: 'stableRateLastUpdated', + type: 'uint40', + }, + { + internalType: 'bool', + name: 'usageAsCollateralEnabled', + type: 'bool', + }, + ], + stateMutability: 'view', + type: 'function', + }, +] as const; + +export class ProtocolDataProvider__factory { + static readonly abi = _abi; + static createInterface(): ProtocolDataProviderInterface { + return new utils.Interface(_abi) as ProtocolDataProviderInterface; + } + static connect(address: string, signerOrProvider: Signer | Provider): ProtocolDataProvider { + return new Contract(address, _abi, signerOrProvider) as ProtocolDataProvider; + } +} diff --git a/src/modules/aavev2/contracts/factories/index.ts b/src/modules/aavev2/contracts/factories/index.ts new file mode 100644 index 00000000..c6b2b1bb --- /dev/null +++ b/src/modules/aavev2/contracts/factories/index.ts @@ -0,0 +1,9 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +export { AToken__factory } from './AToken__factory'; +export { AaveV2FlashLoanCallback__factory } from './AaveV2FlashLoanCallback__factory'; +export { DebtTokenBase__factory } from './DebtTokenBase__factory'; +export { LendingPool__factory } from './LendingPool__factory'; +export { LendingPoolAddressesProvider__factory } from './LendingPoolAddressesProvider__factory'; +export { ProtocolDataProvider__factory } from './ProtocolDataProvider__factory'; diff --git a/src/modules/aavev2/contracts/index.ts b/src/modules/aavev2/contracts/index.ts new file mode 100644 index 00000000..24b49312 --- /dev/null +++ b/src/modules/aavev2/contracts/index.ts @@ -0,0 +1,16 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +export type { AToken } from './AToken'; +export type { AaveV2FlashLoanCallback } from './AaveV2FlashLoanCallback'; +export type { DebtTokenBase } from './DebtTokenBase'; +export type { LendingPool } from './LendingPool'; +export type { LendingPoolAddressesProvider } from './LendingPoolAddressesProvider'; +export type { ProtocolDataProvider } from './ProtocolDataProvider'; +export * as factories from './factories'; +export { AaveV2FlashLoanCallback__factory } from './factories/AaveV2FlashLoanCallback__factory'; +export { AToken__factory } from './factories/AToken__factory'; +export { DebtTokenBase__factory } from './factories/DebtTokenBase__factory'; +export { LendingPool__factory } from './factories/LendingPool__factory'; +export { LendingPoolAddressesProvider__factory } from './factories/LendingPoolAddressesProvider__factory'; +export { ProtocolDataProvider__factory } from './factories/ProtocolDataProvider__factory'; diff --git a/src/modules/aavev2/index.ts b/src/modules/aavev2/index.ts new file mode 100644 index 00000000..b331dc94 --- /dev/null +++ b/src/modules/aavev2/index.ts @@ -0,0 +1,6 @@ +export * from './contracts'; +export * from './logic.borrow'; +export * from './logic.deposit'; +export * from './logic.repay'; +export * from './logic.withdraw'; +export * from './utils'; diff --git a/src/modules/aavev2/logic.borrow.ts b/src/modules/aavev2/logic.borrow.ts new file mode 100644 index 00000000..3ab0f3c2 --- /dev/null +++ b/src/modules/aavev2/logic.borrow.ts @@ -0,0 +1,53 @@ +import { InterestRateMode, LogicOptions, serviceType } from './types'; +import { LendingPool__factory } from './contracts'; +import * as common from '@protocolink/common'; +import * as core from '@protocolink/core'; + +export type BorrowLogicTokenList = common.Token[]; + +export type BorrowLogicFields = core.TokenOutFields<{ interestRateMode: InterestRateMode; referralCode?: number }>; + +export type BorrowLogicOptions = Pick; + +export class BorrowLogic extends core.Logic { + static id = 'borrow'; + public readonly service: serviceType; + + constructor({ chainId, provider, service }: LogicOptions) { + super(chainId, provider); + this.service = service; + } + + async getTokenList() { + const borrowTokens = await this.service.getBorrowTokens(); + + const tokenList: BorrowLogicTokenList = []; + for (const { asset } of borrowTokens) { + if (asset.isWrapped) { + tokenList.push(asset.unwrapped); + } + tokenList.push(asset); + } + + return tokenList; + } + + async build(fields: BorrowLogicFields, options: BorrowLogicOptions) { + const { output, interestRateMode, referralCode = 0 } = fields; + const { account } = options; + + const tokenOut = output.token.wrapped; + + const to = await this.service.getLendingPoolAddress(); + const data = LendingPool__factory.createInterface().encodeFunctionData('borrow', [ + tokenOut.address, + output.amountWei, + interestRateMode, + referralCode, + account, + ]); + const wrapMode = output.token.isNative ? core.WrapMode.unwrapAfter : core.WrapMode.none; + + return core.newLogic({ to, data, wrapMode }); + } +} diff --git a/src/modules/aavev2/logic.deposit.ts b/src/modules/aavev2/logic.deposit.ts new file mode 100644 index 00000000..0b7383b4 --- /dev/null +++ b/src/modules/aavev2/logic.deposit.ts @@ -0,0 +1,52 @@ +import { LendingPool__factory } from './contracts'; +import { LogicOptions, serviceType } from './types'; +import * as common from '@protocolink/common'; +import * as core from '@protocolink/core'; + +export type DepositLogicTokenList = [common.Token, common.Token][]; + +export type DepositLogicParams = core.TokenToTokenExactInParams; + +export type DepositLogicFields = core.TokenToTokenExactInFields<{ referralCode?: number }>; + +export type DepositLogicOptions = Pick; + +export class DepositLogics extends core.Logic { + static id = 'deposit'; + public readonly service: serviceType; + + constructor({ chainId, provider, service }: LogicOptions) { + super(chainId, provider); + this.service = service; + } + + async quote(params: DepositLogicParams): Promise { + const { input, tokenOut } = params; + const output = new common.TokenAmount(tokenOut, input.amount); + + return { input, output }; + } + + async build(fields: DepositLogicFields, options: DepositLogicOptions) { + const { input, balanceBps, referralCode = 0 } = fields; + const { account } = options; + + const tokenIn = input.token.wrapped; + const agent = await this.calcAgent(account); + + const to = await this.service.getLendingPoolAddress(); + const data = LendingPool__factory.createInterface().encodeFunctionData('deposit', [ + tokenIn.address, + input.amountWei, + agent, + referralCode, + ]); + const amountOffset = balanceBps ? common.getParamOffset(1) : undefined; + const inputs = [ + core.newLogicInput({ input: new common.TokenAmount(tokenIn, input.amount), balanceBps, amountOffset }), + ]; + const wrapMode = input.token.isNative ? core.WrapMode.wrapBefore : core.WrapMode.none; + + return core.newLogic({ to, data, inputs, wrapMode }); + } +} diff --git a/src/modules/aavev2/logic.repay.ts b/src/modules/aavev2/logic.repay.ts new file mode 100644 index 00000000..8f48d9ea --- /dev/null +++ b/src/modules/aavev2/logic.repay.ts @@ -0,0 +1,69 @@ +import { InterestRateMode, LogicOptions, serviceType } from './types'; +import { LendingPool__factory } from './contracts'; +import * as common from '@protocolink/common'; +import * as core from '@protocolink/core'; + +export type RepayLogicTokenList = common.Token[]; + +export type RepayLogicParams = core.RepayParams<{ interestRateMode: InterestRateMode }>; + +export type RepayLogicFields = core.RepayFields<{ interestRateMode: InterestRateMode }>; + +export class RepayLogic extends core.Logic { + static id = 'repay'; + public readonly service: serviceType; + + constructor({ chainId, provider, service }: LogicOptions) { + super(chainId, provider); + this.service = service; + } + + async getTokenList() { + const tokens = await this.service.getAssets(); + + const tokenList: RepayLogicTokenList = []; + for (const token of tokens) { + if (token.isWrapped) { + tokenList.push(token.unwrapped); + } + tokenList.push(token); + } + + return tokenList; + } + + async quote(params: RepayLogicParams) { + const { borrower, tokenIn, interestRateMode } = params; + + const { currentStableDebt, currentVariableDebt } = await this.service.protocolDataProvider.getUserReserveData( + tokenIn.wrapped.address, + borrower + ); + const currentDebt = interestRateMode === InterestRateMode.variable ? currentVariableDebt : currentStableDebt; + const amountWei = common.calcSlippage(currentDebt, -1); // slightly higher than the current borrowed amount + const input = new common.TokenAmount(tokenIn).setWei(amountWei); + + return { borrower, interestRateMode, input }; + } + + async build(fields: RepayLogicFields) { + const { input, interestRateMode, borrower, balanceBps } = fields; + + const tokenIn = input.token.wrapped; + + const to = await this.service.getLendingPoolAddress(); + const data = LendingPool__factory.createInterface().encodeFunctionData('repay', [ + tokenIn.address, + input.amountWei, + interestRateMode, + borrower, + ]); + const amountOffset = balanceBps ? common.getParamOffset(1) : undefined; + const inputs = [ + core.newLogicInput({ input: new common.TokenAmount(tokenIn, input.amount), balanceBps, amountOffset }), + ]; + const wrapMode = input.token.isNative ? core.WrapMode.wrapBefore : core.WrapMode.none; + + return core.newLogic({ to, data, inputs, wrapMode }); + } +} diff --git a/src/modules/aavev2/logic.withdraw.ts b/src/modules/aavev2/logic.withdraw.ts new file mode 100644 index 00000000..b319b632 --- /dev/null +++ b/src/modules/aavev2/logic.withdraw.ts @@ -0,0 +1,49 @@ +import { LendingPool__factory } from './contracts'; +import { LogicOptions, serviceType } from './types'; +import * as common from '@protocolink/common'; +import * as core from '@protocolink/core'; + +export type WithdrawLogicTokenList = [common.Token, common.Token][]; + +export type WithdrawLogicParams = core.TokenToTokenExactInParams; + +export type WithdrawLogicFields = core.TokenToTokenExactInFields; + +export type WithdrawLogicOptions = Pick; + +export class WithdrawLogic extends core.Logic { + static id = 'withdraw'; + public readonly service: serviceType; + + constructor({ chainId, provider, service }: LogicOptions) { + super(chainId, provider); + this.service = service; + } + + async quote(params: WithdrawLogicParams): Promise { + const { input, tokenOut } = params; + const output = new common.TokenAmount(tokenOut, input.amount); + + return { input, output }; + } + + async build(fields: WithdrawLogicFields, options: WithdrawLogicOptions) { + const { input, output, balanceBps } = fields; + const { account } = options; + + const tokenOut = output.token.wrapped; + const agent = await this.calcAgent(account); + + const to = await this.service.getLendingPoolAddress(); + const data = LendingPool__factory.createInterface().encodeFunctionData('withdraw', [ + tokenOut.address, + input.amountWei, + agent, + ]); + const amountOffset = balanceBps ? common.getParamOffset(1) : undefined; + const inputs = [core.newLogicInput({ input, balanceBps, amountOffset })]; + const wrapMode = output.token.isNative ? core.WrapMode.unwrapAfter : core.WrapMode.none; + + return core.newLogic({ to, data, inputs, wrapMode }); + } +} diff --git a/src/modules/aavev2/types.ts b/src/modules/aavev2/types.ts new file mode 100644 index 00000000..e0229822 --- /dev/null +++ b/src/modules/aavev2/types.ts @@ -0,0 +1,17 @@ +import { Service as AaveV2Service } from 'src/logics/aave-v2'; +import { Service as RadiantV2Service } from 'src/logics/radiant-v2'; +import { providers } from 'ethers'; + +export enum InterestRateMode { + none = 0, + stable = 1, + variable = 2, +} + +export type serviceType = AaveV2Service | RadiantV2Service; + +export interface LogicOptions { + chainId: number; + provider?: providers.Provider; + service: serviceType; +} diff --git a/src/modules/aavev2/utils.ts b/src/modules/aavev2/utils.ts new file mode 100644 index 00000000..7bc50b32 --- /dev/null +++ b/src/modules/aavev2/utils.ts @@ -0,0 +1,28 @@ +import { DepositLogicTokenList } from './logic.deposit'; +import { WithdrawLogicTokenList } from './logic.withdraw'; + +export function createDepositTokenList(reserveTokens: any[], tokenKey: 'aToken' | 'rToken'): DepositLogicTokenList { + return reserveTokens.flatMap((reserveToken) => { + const tokenList: DepositLogicTokenList = []; + + if (reserveToken.asset.isWrapped) { + tokenList.push([reserveToken.asset.unwrapped, reserveToken[tokenKey]]); + } + tokenList.push([reserveToken.asset, reserveToken[tokenKey]]); + + return tokenList; + }); +} + +export function createWithdrawTokenList(reserveTokens: any[], tokenKey: 'aToken' | 'rToken'): WithdrawLogicTokenList { + return reserveTokens.flatMap((reserveToken) => { + const tokenList: WithdrawLogicTokenList = []; + + if (reserveToken.asset.isWrapped) { + tokenList.push([reserveToken[tokenKey], reserveToken.asset.unwrapped]); + } + tokenList.push([reserveToken[tokenKey], reserveToken.asset]); + + return tokenList; + }); +} diff --git a/src/modules/aavev3/abis/AToken.json b/src/modules/aavev3/abis/AToken.json new file mode 100644 index 00000000..14e51ec1 --- /dev/null +++ b/src/modules/aavev3/abis/AToken.json @@ -0,0 +1,912 @@ +[ + { + "inputs": [ + { + "internalType": "contract IPool", + "name": "pool", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "BalanceTransfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "balanceIncrease", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "Burn", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "underlyingAsset", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "treasury", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "incentivesController", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint8", + "name": "aTokenDecimals", + "type": "uint8" + }, + { + "indexed": false, + "internalType": "string", + "name": "aTokenName", + "type": "string" + }, + { + "indexed": false, + "internalType": "string", + "name": "aTokenSymbol", + "type": "string" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "params", + "type": "bytes" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "caller", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "onBehalfOf", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "balanceIncrease", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "Mint", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "inputs": [], + "name": "ATOKEN_REVISION", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "DOMAIN_SEPARATOR", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "EIP712_REVISION", + "outputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "PERMIT_TYPEHASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "POOL", + "outputs": [ + { + "internalType": "contract IPool", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "RESERVE_TREASURY_ADDRESS", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "UNDERLYING_ASSET_ADDRESS", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "receiverOfUnderlying", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "burn", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "subtractedValue", + "type": "uint256" + } + ], + "name": "decreaseAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "getIncentivesController", + "outputs": [ + { + "internalType": "contract IAaveIncentivesController", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "getPreviousIndex", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "getScaledUserBalanceAndSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "address", + "name": "onBehalfOf", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "handleRepayment", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "addedValue", + "type": "uint256" + } + ], + "name": "increaseAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IPool", + "name": "initializingPool", + "type": "address" + }, + { + "internalType": "address", + "name": "treasury", + "type": "address" + }, + { + "internalType": "address", + "name": "underlyingAsset", + "type": "address" + }, + { + "internalType": "contract IAaveIncentivesController", + "name": "incentivesController", + "type": "address" + }, + { + "internalType": "uint8", + "name": "aTokenDecimals", + "type": "uint8" + }, + { + "internalType": "string", + "name": "aTokenName", + "type": "string" + }, + { + "internalType": "string", + "name": "aTokenSymbol", + "type": "string" + }, + { + "internalType": "bytes", + "name": "params", + "type": "bytes" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "caller", + "type": "address" + }, + { + "internalType": "address", + "name": "onBehalfOf", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "mint", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "mintToTreasury", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "nonces", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "permit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "rescueTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "scaledBalanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "scaledTotalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IAaveIncentivesController", + "name": "controller", + "type": "address" + } + ], + "name": "setIncentivesController", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "transferOnLiquidation", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transferUnderlyingTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/src/modules/aavev3/abis/AaveV3FlashLoanCallback.json b/src/modules/aavev3/abis/AaveV3FlashLoanCallback.json new file mode 100644 index 00000000..079415fa --- /dev/null +++ b/src/modules/aavev3/abis/AaveV3FlashLoanCallback.json @@ -0,0 +1,130 @@ +[ + { + "inputs": [ + { + "internalType": "address", + "name": "router_", + "type": "address" + }, + { + "internalType": "address", + "name": "aaveV3Provider_", + "type": "address" + }, + { + "internalType": "uint256", + "name": "feeRate_", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "InvalidBalance", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidCaller", + "type": "error" + }, + { + "inputs": [], + "name": "aaveV3Provider", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "assets", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "premiums", + "type": "uint256[]" + }, + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "bytes", + "name": "params", + "type": "bytes" + } + ], + "name": "executeOperation", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "feeRate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "metadata", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "router", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } +] diff --git a/src/modules/aavev3/abis/DebtTokenBase.json b/src/modules/aavev3/abis/DebtTokenBase.json new file mode 100644 index 00000000..31ac8d16 --- /dev/null +++ b/src/modules/aavev3/abis/DebtTokenBase.json @@ -0,0 +1,176 @@ +[ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "fromUser", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "toUser", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "BorrowAllowanceDelegated", + "type": "event" + }, + { + "inputs": [], + "name": "DELEGATION_WITH_SIG_TYPEHASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "DOMAIN_SEPARATOR", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "EIP712_REVISION", + "outputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "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": "delegator", + "type": "address" + }, + { + "internalType": "address", + "name": "delegatee", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "delegationWithSig", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "nonces", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } +] diff --git a/src/modules/aavev3/abis/Pool.json b/src/modules/aavev3/abis/Pool.json new file mode 100644 index 00000000..f6ef167d --- /dev/null +++ b/src/modules/aavev3/abis/Pool.json @@ -0,0 +1,1721 @@ +[ + { + "inputs": [ + { + "internalType": "contract IPoolAddressesProvider", + "name": "provider", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "reserve", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "backer", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "fee", + "type": "uint256" + } + ], + "name": "BackUnbacked", + "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": false, + "internalType": "enum DataTypes.InterestRateMode", + "name": "interestRateMode", + "type": "uint8" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "borrowRate", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint16", + "name": "referralCode", + "type": "uint16" + } + ], + "name": "Borrow", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "indexed": false, + "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": "enum DataTypes.InterestRateMode", + "name": "interestRateMode", + "type": "uint8" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "premium", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint16", + "name": "referralCode", + "type": "uint16" + } + ], + "name": "FlashLoan", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "totalDebt", + "type": "uint256" + } + ], + "name": "IsolationModeTotalDebtUpdated", + "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": [ + { + "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": "referralCode", + "type": "uint16" + } + ], + "name": "MintUnbacked", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "reserve", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amountMinted", + "type": "uint256" + } + ], + "name": "MintedToTreasury", + "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" + }, + { + "indexed": false, + "internalType": "bool", + "name": "useATokens", + "type": "bool" + } + ], + "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": 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": "referralCode", + "type": "uint16" + } + ], + "name": "Supply", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "reserve", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "enum DataTypes.InterestRateMode", + "name": "interestRateMode", + "type": "uint8" + } + ], + "name": "SwapBorrowRateMode", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint8", + "name": "categoryId", + "type": "uint8" + } + ], + "name": "UserEModeSet", + "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": "ADDRESSES_PROVIDER", + "outputs": [ + { + "internalType": "contract IPoolAddressesProvider", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "BRIDGE_PROTOCOL_FEE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "FLASHLOAN_PREMIUM_TOTAL", + "outputs": [ + { + "internalType": "uint128", + "name": "", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "FLASHLOAN_PREMIUM_TO_PROTOCOL", + "outputs": [ + { + "internalType": "uint128", + "name": "", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_NUMBER_RESERVES", + "outputs": [ + { + "internalType": "uint16", + "name": "", + "type": "uint16" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_STABLE_RATE_BORROW_SIZE_PERCENT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "POOL_REVISION", + "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": "fee", + "type": "uint256" + } + ], + "name": "backUnbacked", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "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": "uint8", + "name": "id", + "type": "uint8" + }, + { + "components": [ + { + "internalType": "uint16", + "name": "ltv", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "liquidationThreshold", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "liquidationBonus", + "type": "uint16" + }, + { + "internalType": "address", + "name": "priceSource", + "type": "address" + }, + { + "internalType": "string", + "name": "label", + "type": "string" + } + ], + "internalType": "struct DataTypes.EModeCategory", + "name": "category", + "type": "tuple" + } + ], + "name": "configureEModeCategory", + "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" + } + ], + "name": "dropReserve", + "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": "interestRateModes", + "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": [ + { + "internalType": "address", + "name": "receiverAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "params", + "type": "bytes" + }, + { + "internalType": "uint16", + "name": "referralCode", + "type": "uint16" + } + ], + "name": "flashLoanSimple", + "outputs": [], + "stateMutability": "nonpayable", + "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": "uint8", + "name": "id", + "type": "uint8" + } + ], + "name": "getEModeCategoryData", + "outputs": [ + { + "components": [ + { + "internalType": "uint16", + "name": "ltv", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "liquidationThreshold", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "liquidationBonus", + "type": "uint16" + }, + { + "internalType": "address", + "name": "priceSource", + "type": "address" + }, + { + "internalType": "string", + "name": "label", + "type": "string" + } + ], + "internalType": "struct DataTypes.EModeCategory", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint16", + "name": "id", + "type": "uint16" + } + ], + "name": "getReserveAddressById", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "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": "currentLiquidityRate", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "variableBorrowIndex", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "currentVariableBorrowRate", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "currentStableBorrowRate", + "type": "uint128" + }, + { + "internalType": "uint40", + "name": "lastUpdateTimestamp", + "type": "uint40" + }, + { + "internalType": "uint16", + "name": "id", + "type": "uint16" + }, + { + "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": "uint128", + "name": "accruedToTreasury", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "unbacked", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "isolationModeTotalDebt", + "type": "uint128" + } + ], + "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": "totalCollateralBase", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalDebtBase", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "availableBorrowsBase", + "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": "user", + "type": "address" + } + ], + "name": "getUserEMode", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "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 IPoolAddressesProvider", + "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": [ + { + "internalType": "address[]", + "name": "assets", + "type": "address[]" + } + ], + "name": "mintToTreasury", + "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": "mintUnbacked", + "outputs": [], + "stateMutability": "nonpayable", + "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": "interestRateMode", + "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": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "interestRateMode", + "type": "uint256" + } + ], + "name": "repayWithATokens", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "interestRateMode", + "type": "uint256" + }, + { + "internalType": "address", + "name": "onBehalfOf", + "type": "address" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "permitV", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "permitR", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "permitS", + "type": "bytes32" + } + ], + "name": "repayWithPermit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "rescueTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "resetIsolationModeTotalDebt", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "data", + "type": "uint256" + } + ], + "internalType": "struct DataTypes.ReserveConfigurationMap", + "name": "configuration", + "type": "tuple" + } + ], + "name": "setConfiguration", + "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": "uint8", + "name": "categoryId", + "type": "uint8" + } + ], + "name": "setUserEMode", + "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": "amount", + "type": "uint256" + }, + { + "internalType": "address", + "name": "onBehalfOf", + "type": "address" + }, + { + "internalType": "uint16", + "name": "referralCode", + "type": "uint16" + } + ], + "name": "supply", + "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" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "permitV", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "permitR", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "permitS", + "type": "bytes32" + } + ], + "name": "supplyWithPermit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "interestRateMode", + "type": "uint256" + } + ], + "name": "swapBorrowRateMode", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "protocolFee", + "type": "uint256" + } + ], + "name": "updateBridgeProtocolFee", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint128", + "name": "flashLoanPremiumTotal", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "flashLoanPremiumToProtocol", + "type": "uint128" + } + ], + "name": "updateFlashloanPremiums", + "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/src/modules/aavev3/abis/PoolAddressesProvider.json b/src/modules/aavev3/abis/PoolAddressesProvider.json new file mode 100644 index 00000000..74d4db4a --- /dev/null +++ b/src/modules/aavev3/abis/PoolAddressesProvider.json @@ -0,0 +1,498 @@ +[ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oldAddress", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newAddress", + "type": "address" + } + ], + "name": "ACLAdminUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oldAddress", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newAddress", + "type": "address" + } + ], + "name": "ACLManagerUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "id", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "oldAddress", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newAddress", + "type": "address" + } + ], + "name": "AddressSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "id", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "proxyAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "oldImplementationAddress", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newImplementationAddress", + "type": "address" + } + ], + "name": "AddressSetAsProxy", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "string", + "name": "oldMarketId", + "type": "string" + }, + { + "indexed": true, + "internalType": "string", + "name": "newMarketId", + "type": "string" + } + ], + "name": "MarketIdSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oldAddress", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newAddress", + "type": "address" + } + ], + "name": "PoolConfiguratorUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oldAddress", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newAddress", + "type": "address" + } + ], + "name": "PoolDataProviderUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oldAddress", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newAddress", + "type": "address" + } + ], + "name": "PoolUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oldAddress", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newAddress", + "type": "address" + } + ], + "name": "PriceOracleSentinelUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oldAddress", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newAddress", + "type": "address" + } + ], + "name": "PriceOracleUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "id", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "proxyAddress", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "implementationAddress", + "type": "address" + } + ], + "name": "ProxyCreated", + "type": "event" + }, + { + "inputs": [], + "name": "getACLAdmin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getACLManager", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "id", + "type": "bytes32" + } + ], + "name": "getAddress", + "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": "getPool", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getPoolConfigurator", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getPoolDataProvider", + "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": "getPriceOracleSentinel", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newAclAdmin", + "type": "address" + } + ], + "name": "setACLAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newAclManager", + "type": "address" + } + ], + "name": "setACLManager", + "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": "newImplementationAddress", + "type": "address" + } + ], + "name": "setAddressAsProxy", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "newMarketId", + "type": "string" + } + ], + "name": "setMarketId", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newPoolConfiguratorImpl", + "type": "address" + } + ], + "name": "setPoolConfiguratorImpl", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newDataProvider", + "type": "address" + } + ], + "name": "setPoolDataProvider", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newPoolImpl", + "type": "address" + } + ], + "name": "setPoolImpl", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newPriceOracle", + "type": "address" + } + ], + "name": "setPriceOracle", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newPriceOracleSentinel", + "type": "address" + } + ], + "name": "setPriceOracleSentinel", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/src/modules/aavev3/abis/PoolDataProvider.json b/src/modules/aavev3/abis/PoolDataProvider.json new file mode 100644 index 00000000..8e3f63b2 --- /dev/null +++ b/src/modules/aavev3/abis/PoolDataProvider.json @@ -0,0 +1,523 @@ +[ + { + "inputs": [], + "name": "ADDRESSES_PROVIDER", + "outputs": [ + { + "internalType": "contract IPoolAddressesProvider", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "getATokenTotalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getAllATokens", + "outputs": [ + { + "components": [ + { + "internalType": "string", + "name": "symbol", + "type": "string" + }, + { + "internalType": "address", + "name": "tokenAddress", + "type": "address" + } + ], + "internalType": "struct IPoolDataProvider.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 IPoolDataProvider.TokenData[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "getDebtCeiling", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getDebtCeilingDecimals", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "getFlashLoanEnabled", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "getInterestRateStrategyAddress", + "outputs": [ + { + "internalType": "address", + "name": "irStrategyAddress", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "getLiquidationProtocolFee", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "getPaused", + "outputs": [ + { + "internalType": "bool", + "name": "isPaused", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "getReserveCaps", + "outputs": [ + { + "internalType": "uint256", + "name": "borrowCap", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supplyCap", + "type": "uint256" + } + ], + "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": "unbacked", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "accruedToTreasuryScaled", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalAToken", + "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": "getReserveEModeCategory", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "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" + } + ], + "name": "getSiloedBorrowing", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "getTotalDebt", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "getUnbackedMintCap", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "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/src/modules/aavev3/contracts/AToken.ts b/src/modules/aavev3/contracts/AToken.ts new file mode 100644 index 00000000..b2fc1a8d --- /dev/null +++ b/src/modules/aavev3/contracts/AToken.ts @@ -0,0 +1,1025 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + BaseContract, + BigNumber, + BigNumberish, + BytesLike, + CallOverrides, + ContractTransaction, + Overrides, + PopulatedTransaction, + Signer, + utils, +} from 'ethers'; +import type { FunctionFragment, Result, EventFragment } from '@ethersproject/abi'; +import type { Listener, Provider } from '@ethersproject/providers'; +import type { TypedEventFilter, TypedEvent, TypedListener, OnEvent } from './common'; + +export interface ATokenInterface extends utils.Interface { + functions: { + 'ATOKEN_REVISION()': FunctionFragment; + 'DOMAIN_SEPARATOR()': FunctionFragment; + 'EIP712_REVISION()': FunctionFragment; + 'PERMIT_TYPEHASH()': FunctionFragment; + 'POOL()': FunctionFragment; + 'RESERVE_TREASURY_ADDRESS()': FunctionFragment; + 'UNDERLYING_ASSET_ADDRESS()': FunctionFragment; + 'allowance(address,address)': FunctionFragment; + 'approve(address,uint256)': FunctionFragment; + 'balanceOf(address)': FunctionFragment; + 'burn(address,address,uint256,uint256)': FunctionFragment; + 'decimals()': FunctionFragment; + 'decreaseAllowance(address,uint256)': FunctionFragment; + 'getIncentivesController()': FunctionFragment; + 'getPreviousIndex(address)': FunctionFragment; + 'getScaledUserBalanceAndSupply(address)': FunctionFragment; + 'handleRepayment(address,address,uint256)': FunctionFragment; + 'increaseAllowance(address,uint256)': FunctionFragment; + 'initialize(address,address,address,address,uint8,string,string,bytes)': FunctionFragment; + 'mint(address,address,uint256,uint256)': FunctionFragment; + 'mintToTreasury(uint256,uint256)': FunctionFragment; + 'name()': FunctionFragment; + 'nonces(address)': FunctionFragment; + 'permit(address,address,uint256,uint256,uint8,bytes32,bytes32)': FunctionFragment; + 'rescueTokens(address,address,uint256)': FunctionFragment; + 'scaledBalanceOf(address)': FunctionFragment; + 'scaledTotalSupply()': FunctionFragment; + 'setIncentivesController(address)': FunctionFragment; + 'symbol()': FunctionFragment; + 'totalSupply()': FunctionFragment; + 'transfer(address,uint256)': FunctionFragment; + 'transferFrom(address,address,uint256)': FunctionFragment; + 'transferOnLiquidation(address,address,uint256)': FunctionFragment; + 'transferUnderlyingTo(address,uint256)': FunctionFragment; + }; + + getFunction( + nameOrSignatureOrTopic: + | 'ATOKEN_REVISION' + | 'DOMAIN_SEPARATOR' + | 'EIP712_REVISION' + | 'PERMIT_TYPEHASH' + | 'POOL' + | 'RESERVE_TREASURY_ADDRESS' + | 'UNDERLYING_ASSET_ADDRESS' + | 'allowance' + | 'approve' + | 'balanceOf' + | 'burn' + | 'decimals' + | 'decreaseAllowance' + | 'getIncentivesController' + | 'getPreviousIndex' + | 'getScaledUserBalanceAndSupply' + | 'handleRepayment' + | 'increaseAllowance' + | 'initialize' + | 'mint' + | 'mintToTreasury' + | 'name' + | 'nonces' + | 'permit' + | 'rescueTokens' + | 'scaledBalanceOf' + | 'scaledTotalSupply' + | 'setIncentivesController' + | 'symbol' + | 'totalSupply' + | 'transfer' + | 'transferFrom' + | 'transferOnLiquidation' + | 'transferUnderlyingTo' + ): FunctionFragment; + + encodeFunctionData(functionFragment: 'ATOKEN_REVISION', values?: undefined): string; + encodeFunctionData(functionFragment: 'DOMAIN_SEPARATOR', values?: undefined): string; + encodeFunctionData(functionFragment: 'EIP712_REVISION', values?: undefined): string; + encodeFunctionData(functionFragment: 'PERMIT_TYPEHASH', values?: undefined): string; + encodeFunctionData(functionFragment: 'POOL', values?: undefined): string; + encodeFunctionData(functionFragment: 'RESERVE_TREASURY_ADDRESS', values?: undefined): string; + encodeFunctionData(functionFragment: 'UNDERLYING_ASSET_ADDRESS', values?: undefined): string; + encodeFunctionData(functionFragment: 'allowance', values: [string, string]): string; + encodeFunctionData(functionFragment: 'approve', values: [string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'balanceOf', values: [string]): string; + encodeFunctionData(functionFragment: 'burn', values: [string, string, BigNumberish, BigNumberish]): string; + encodeFunctionData(functionFragment: 'decimals', values?: undefined): string; + encodeFunctionData(functionFragment: 'decreaseAllowance', values: [string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'getIncentivesController', values?: undefined): string; + encodeFunctionData(functionFragment: 'getPreviousIndex', values: [string]): string; + encodeFunctionData(functionFragment: 'getScaledUserBalanceAndSupply', values: [string]): string; + encodeFunctionData(functionFragment: 'handleRepayment', values: [string, string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'increaseAllowance', values: [string, BigNumberish]): string; + encodeFunctionData( + functionFragment: 'initialize', + values: [string, string, string, string, BigNumberish, string, string, BytesLike] + ): string; + encodeFunctionData(functionFragment: 'mint', values: [string, string, BigNumberish, BigNumberish]): string; + encodeFunctionData(functionFragment: 'mintToTreasury', values: [BigNumberish, BigNumberish]): string; + encodeFunctionData(functionFragment: 'name', values?: undefined): string; + encodeFunctionData(functionFragment: 'nonces', values: [string]): string; + encodeFunctionData( + functionFragment: 'permit', + values: [string, string, BigNumberish, BigNumberish, BigNumberish, BytesLike, BytesLike] + ): string; + encodeFunctionData(functionFragment: 'rescueTokens', values: [string, string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'scaledBalanceOf', values: [string]): string; + encodeFunctionData(functionFragment: 'scaledTotalSupply', values?: undefined): string; + encodeFunctionData(functionFragment: 'setIncentivesController', values: [string]): string; + encodeFunctionData(functionFragment: 'symbol', values?: undefined): string; + encodeFunctionData(functionFragment: 'totalSupply', values?: undefined): string; + encodeFunctionData(functionFragment: 'transfer', values: [string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'transferFrom', values: [string, string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'transferOnLiquidation', values: [string, string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'transferUnderlyingTo', values: [string, BigNumberish]): string; + + decodeFunctionResult(functionFragment: 'ATOKEN_REVISION', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'DOMAIN_SEPARATOR', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'EIP712_REVISION', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'PERMIT_TYPEHASH', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'POOL', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'RESERVE_TREASURY_ADDRESS', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'UNDERLYING_ASSET_ADDRESS', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'allowance', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'approve', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'balanceOf', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'burn', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'decimals', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'decreaseAllowance', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getIncentivesController', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getPreviousIndex', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getScaledUserBalanceAndSupply', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'handleRepayment', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'increaseAllowance', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'initialize', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'mint', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'mintToTreasury', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'name', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'nonces', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'permit', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'rescueTokens', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'scaledBalanceOf', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'scaledTotalSupply', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'setIncentivesController', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'symbol', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'totalSupply', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'transfer', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'transferFrom', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'transferOnLiquidation', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'transferUnderlyingTo', data: BytesLike): Result; + + events: { + 'Approval(address,address,uint256)': EventFragment; + 'BalanceTransfer(address,address,uint256,uint256)': EventFragment; + 'Burn(address,address,uint256,uint256,uint256)': EventFragment; + 'Initialized(address,address,address,address,uint8,string,string,bytes)': EventFragment; + 'Mint(address,address,uint256,uint256,uint256)': EventFragment; + 'Transfer(address,address,uint256)': EventFragment; + }; + + getEvent(nameOrSignatureOrTopic: 'Approval'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'BalanceTransfer'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'Burn'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'Initialized'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'Mint'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'Transfer'): EventFragment; +} + +export interface ApprovalEventObject { + owner: string; + spender: string; + value: BigNumber; +} +export type ApprovalEvent = TypedEvent<[string, string, BigNumber], ApprovalEventObject>; + +export type ApprovalEventFilter = TypedEventFilter; + +export interface BalanceTransferEventObject { + from: string; + to: string; + value: BigNumber; + index: BigNumber; +} +export type BalanceTransferEvent = TypedEvent<[string, string, BigNumber, BigNumber], BalanceTransferEventObject>; + +export type BalanceTransferEventFilter = TypedEventFilter; + +export interface BurnEventObject { + from: string; + target: string; + value: BigNumber; + balanceIncrease: BigNumber; + index: BigNumber; +} +export type BurnEvent = TypedEvent<[string, string, BigNumber, BigNumber, BigNumber], BurnEventObject>; + +export type BurnEventFilter = TypedEventFilter; + +export interface InitializedEventObject { + underlyingAsset: string; + pool: string; + treasury: string; + incentivesController: string; + aTokenDecimals: number; + aTokenName: string; + aTokenSymbol: string; + params: string; +} +export type InitializedEvent = TypedEvent< + [string, string, string, string, number, string, string, string], + InitializedEventObject +>; + +export type InitializedEventFilter = TypedEventFilter; + +export interface MintEventObject { + caller: string; + onBehalfOf: string; + value: BigNumber; + balanceIncrease: BigNumber; + index: BigNumber; +} +export type MintEvent = TypedEvent<[string, string, BigNumber, BigNumber, BigNumber], MintEventObject>; + +export type MintEventFilter = TypedEventFilter; + +export interface TransferEventObject { + from: string; + to: string; + value: BigNumber; +} +export type TransferEvent = TypedEvent<[string, string, BigNumber], TransferEventObject>; + +export type TransferEventFilter = TypedEventFilter; + +export interface AToken extends BaseContract { + connect(signerOrProvider: Signer | Provider | string): this; + attach(addressOrName: string): this; + deployed(): Promise; + + interface: ATokenInterface; + + queryFilter( + event: TypedEventFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>; + + listeners(eventFilter?: TypedEventFilter): Array>; + listeners(eventName?: string): Array; + removeAllListeners(eventFilter: TypedEventFilter): this; + removeAllListeners(eventName?: string): this; + off: OnEvent; + on: OnEvent; + once: OnEvent; + removeListener: OnEvent; + + functions: { + ATOKEN_REVISION(overrides?: CallOverrides): Promise<[BigNumber]>; + + DOMAIN_SEPARATOR(overrides?: CallOverrides): Promise<[string]>; + + EIP712_REVISION(overrides?: CallOverrides): Promise<[string]>; + + PERMIT_TYPEHASH(overrides?: CallOverrides): Promise<[string]>; + + POOL(overrides?: CallOverrides): Promise<[string]>; + + RESERVE_TREASURY_ADDRESS(overrides?: CallOverrides): Promise<[string]>; + + UNDERLYING_ASSET_ADDRESS(overrides?: CallOverrides): Promise<[string]>; + + allowance(owner: string, spender: string, overrides?: CallOverrides): Promise<[BigNumber]>; + + approve( + spender: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + balanceOf(user: string, overrides?: CallOverrides): Promise<[BigNumber]>; + + burn( + from: string, + receiverOfUnderlying: string, + amount: BigNumberish, + index: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + decimals(overrides?: CallOverrides): Promise<[number]>; + + decreaseAllowance( + spender: string, + subtractedValue: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + getIncentivesController(overrides?: CallOverrides): Promise<[string]>; + + getPreviousIndex(user: string, overrides?: CallOverrides): Promise<[BigNumber]>; + + getScaledUserBalanceAndSupply(user: string, overrides?: CallOverrides): Promise<[BigNumber, BigNumber]>; + + handleRepayment( + user: string, + onBehalfOf: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + increaseAllowance( + spender: string, + addedValue: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + initialize( + initializingPool: string, + treasury: string, + underlyingAsset: string, + incentivesController: string, + aTokenDecimals: BigNumberish, + aTokenName: string, + aTokenSymbol: string, + params: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + mint( + caller: string, + onBehalfOf: string, + amount: BigNumberish, + index: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + mintToTreasury( + amount: BigNumberish, + index: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + name(overrides?: CallOverrides): Promise<[string]>; + + nonces(owner: string, overrides?: CallOverrides): Promise<[BigNumber]>; + + permit( + owner: string, + spender: string, + value: BigNumberish, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + rescueTokens( + token: string, + to: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + scaledBalanceOf(user: string, overrides?: CallOverrides): Promise<[BigNumber]>; + + scaledTotalSupply(overrides?: CallOverrides): Promise<[BigNumber]>; + + setIncentivesController( + controller: string, + overrides?: Overrides & { from?: string } + ): Promise; + + symbol(overrides?: CallOverrides): Promise<[string]>; + + totalSupply(overrides?: CallOverrides): Promise<[BigNumber]>; + + transfer( + recipient: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + transferFrom( + sender: string, + recipient: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + transferOnLiquidation( + from: string, + to: string, + value: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + transferUnderlyingTo( + target: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + }; + + ATOKEN_REVISION(overrides?: CallOverrides): Promise; + + DOMAIN_SEPARATOR(overrides?: CallOverrides): Promise; + + EIP712_REVISION(overrides?: CallOverrides): Promise; + + PERMIT_TYPEHASH(overrides?: CallOverrides): Promise; + + POOL(overrides?: CallOverrides): Promise; + + RESERVE_TREASURY_ADDRESS(overrides?: CallOverrides): Promise; + + UNDERLYING_ASSET_ADDRESS(overrides?: CallOverrides): Promise; + + allowance(owner: string, spender: string, overrides?: CallOverrides): Promise; + + approve( + spender: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + balanceOf(user: string, overrides?: CallOverrides): Promise; + + burn( + from: string, + receiverOfUnderlying: string, + amount: BigNumberish, + index: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + decimals(overrides?: CallOverrides): Promise; + + decreaseAllowance( + spender: string, + subtractedValue: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + getIncentivesController(overrides?: CallOverrides): Promise; + + getPreviousIndex(user: string, overrides?: CallOverrides): Promise; + + getScaledUserBalanceAndSupply(user: string, overrides?: CallOverrides): Promise<[BigNumber, BigNumber]>; + + handleRepayment( + user: string, + onBehalfOf: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + increaseAllowance( + spender: string, + addedValue: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + initialize( + initializingPool: string, + treasury: string, + underlyingAsset: string, + incentivesController: string, + aTokenDecimals: BigNumberish, + aTokenName: string, + aTokenSymbol: string, + params: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + mint( + caller: string, + onBehalfOf: string, + amount: BigNumberish, + index: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + mintToTreasury( + amount: BigNumberish, + index: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + name(overrides?: CallOverrides): Promise; + + nonces(owner: string, overrides?: CallOverrides): Promise; + + permit( + owner: string, + spender: string, + value: BigNumberish, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + rescueTokens( + token: string, + to: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + scaledBalanceOf(user: string, overrides?: CallOverrides): Promise; + + scaledTotalSupply(overrides?: CallOverrides): Promise; + + setIncentivesController(controller: string, overrides?: Overrides & { from?: string }): Promise; + + symbol(overrides?: CallOverrides): Promise; + + totalSupply(overrides?: CallOverrides): Promise; + + transfer( + recipient: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + transferFrom( + sender: string, + recipient: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + transferOnLiquidation( + from: string, + to: string, + value: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + transferUnderlyingTo( + target: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + callStatic: { + ATOKEN_REVISION(overrides?: CallOverrides): Promise; + + DOMAIN_SEPARATOR(overrides?: CallOverrides): Promise; + + EIP712_REVISION(overrides?: CallOverrides): Promise; + + PERMIT_TYPEHASH(overrides?: CallOverrides): Promise; + + POOL(overrides?: CallOverrides): Promise; + + RESERVE_TREASURY_ADDRESS(overrides?: CallOverrides): Promise; + + UNDERLYING_ASSET_ADDRESS(overrides?: CallOverrides): Promise; + + allowance(owner: string, spender: string, overrides?: CallOverrides): Promise; + + approve(spender: string, amount: BigNumberish, overrides?: CallOverrides): Promise; + + balanceOf(user: string, overrides?: CallOverrides): Promise; + + burn( + from: string, + receiverOfUnderlying: string, + amount: BigNumberish, + index: BigNumberish, + overrides?: CallOverrides + ): Promise; + + decimals(overrides?: CallOverrides): Promise; + + decreaseAllowance(spender: string, subtractedValue: BigNumberish, overrides?: CallOverrides): Promise; + + getIncentivesController(overrides?: CallOverrides): Promise; + + getPreviousIndex(user: string, overrides?: CallOverrides): Promise; + + getScaledUserBalanceAndSupply(user: string, overrides?: CallOverrides): Promise<[BigNumber, BigNumber]>; + + handleRepayment(user: string, onBehalfOf: string, amount: BigNumberish, overrides?: CallOverrides): Promise; + + increaseAllowance(spender: string, addedValue: BigNumberish, overrides?: CallOverrides): Promise; + + initialize( + initializingPool: string, + treasury: string, + underlyingAsset: string, + incentivesController: string, + aTokenDecimals: BigNumberish, + aTokenName: string, + aTokenSymbol: string, + params: BytesLike, + overrides?: CallOverrides + ): Promise; + + mint( + caller: string, + onBehalfOf: string, + amount: BigNumberish, + index: BigNumberish, + overrides?: CallOverrides + ): Promise; + + mintToTreasury(amount: BigNumberish, index: BigNumberish, overrides?: CallOverrides): Promise; + + name(overrides?: CallOverrides): Promise; + + nonces(owner: string, overrides?: CallOverrides): Promise; + + permit( + owner: string, + spender: string, + value: BigNumberish, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: CallOverrides + ): Promise; + + rescueTokens(token: string, to: string, amount: BigNumberish, overrides?: CallOverrides): Promise; + + scaledBalanceOf(user: string, overrides?: CallOverrides): Promise; + + scaledTotalSupply(overrides?: CallOverrides): Promise; + + setIncentivesController(controller: string, overrides?: CallOverrides): Promise; + + symbol(overrides?: CallOverrides): Promise; + + totalSupply(overrides?: CallOverrides): Promise; + + transfer(recipient: string, amount: BigNumberish, overrides?: CallOverrides): Promise; + + transferFrom(sender: string, recipient: string, amount: BigNumberish, overrides?: CallOverrides): Promise; + + transferOnLiquidation(from: string, to: string, value: BigNumberish, overrides?: CallOverrides): Promise; + + transferUnderlyingTo(target: string, amount: BigNumberish, overrides?: CallOverrides): Promise; + }; + + filters: { + 'Approval(address,address,uint256)'( + owner?: string | null, + spender?: string | null, + value?: null + ): ApprovalEventFilter; + Approval(owner?: string | null, spender?: string | null, value?: null): ApprovalEventFilter; + + 'BalanceTransfer(address,address,uint256,uint256)'( + from?: string | null, + to?: string | null, + value?: null, + index?: null + ): BalanceTransferEventFilter; + BalanceTransfer(from?: string | null, to?: string | null, value?: null, index?: null): BalanceTransferEventFilter; + + 'Burn(address,address,uint256,uint256,uint256)'( + from?: string | null, + target?: string | null, + value?: null, + balanceIncrease?: null, + index?: null + ): BurnEventFilter; + Burn( + from?: string | null, + target?: string | null, + value?: null, + balanceIncrease?: null, + index?: null + ): BurnEventFilter; + + 'Initialized(address,address,address,address,uint8,string,string,bytes)'( + underlyingAsset?: string | null, + pool?: string | null, + treasury?: null, + incentivesController?: null, + aTokenDecimals?: null, + aTokenName?: null, + aTokenSymbol?: null, + params?: null + ): InitializedEventFilter; + Initialized( + underlyingAsset?: string | null, + pool?: string | null, + treasury?: null, + incentivesController?: null, + aTokenDecimals?: null, + aTokenName?: null, + aTokenSymbol?: null, + params?: null + ): InitializedEventFilter; + + 'Mint(address,address,uint256,uint256,uint256)'( + caller?: string | null, + onBehalfOf?: string | null, + value?: null, + balanceIncrease?: null, + index?: null + ): MintEventFilter; + Mint( + caller?: string | null, + onBehalfOf?: string | null, + value?: null, + balanceIncrease?: null, + index?: null + ): MintEventFilter; + + 'Transfer(address,address,uint256)'(from?: string | null, to?: string | null, value?: null): TransferEventFilter; + Transfer(from?: string | null, to?: string | null, value?: null): TransferEventFilter; + }; + + estimateGas: { + ATOKEN_REVISION(overrides?: CallOverrides): Promise; + + DOMAIN_SEPARATOR(overrides?: CallOverrides): Promise; + + EIP712_REVISION(overrides?: CallOverrides): Promise; + + PERMIT_TYPEHASH(overrides?: CallOverrides): Promise; + + POOL(overrides?: CallOverrides): Promise; + + RESERVE_TREASURY_ADDRESS(overrides?: CallOverrides): Promise; + + UNDERLYING_ASSET_ADDRESS(overrides?: CallOverrides): Promise; + + allowance(owner: string, spender: string, overrides?: CallOverrides): Promise; + + approve(spender: string, amount: BigNumberish, overrides?: Overrides & { from?: string }): Promise; + + balanceOf(user: string, overrides?: CallOverrides): Promise; + + burn( + from: string, + receiverOfUnderlying: string, + amount: BigNumberish, + index: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + decimals(overrides?: CallOverrides): Promise; + + decreaseAllowance( + spender: string, + subtractedValue: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + getIncentivesController(overrides?: CallOverrides): Promise; + + getPreviousIndex(user: string, overrides?: CallOverrides): Promise; + + getScaledUserBalanceAndSupply(user: string, overrides?: CallOverrides): Promise; + + handleRepayment( + user: string, + onBehalfOf: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + increaseAllowance( + spender: string, + addedValue: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + initialize( + initializingPool: string, + treasury: string, + underlyingAsset: string, + incentivesController: string, + aTokenDecimals: BigNumberish, + aTokenName: string, + aTokenSymbol: string, + params: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + mint( + caller: string, + onBehalfOf: string, + amount: BigNumberish, + index: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + mintToTreasury( + amount: BigNumberish, + index: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + name(overrides?: CallOverrides): Promise; + + nonces(owner: string, overrides?: CallOverrides): Promise; + + permit( + owner: string, + spender: string, + value: BigNumberish, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + rescueTokens( + token: string, + to: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + scaledBalanceOf(user: string, overrides?: CallOverrides): Promise; + + scaledTotalSupply(overrides?: CallOverrides): Promise; + + setIncentivesController(controller: string, overrides?: Overrides & { from?: string }): Promise; + + symbol(overrides?: CallOverrides): Promise; + + totalSupply(overrides?: CallOverrides): Promise; + + transfer(recipient: string, amount: BigNumberish, overrides?: Overrides & { from?: string }): Promise; + + transferFrom( + sender: string, + recipient: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + transferOnLiquidation( + from: string, + to: string, + value: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + transferUnderlyingTo( + target: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + }; + + populateTransaction: { + ATOKEN_REVISION(overrides?: CallOverrides): Promise; + + DOMAIN_SEPARATOR(overrides?: CallOverrides): Promise; + + EIP712_REVISION(overrides?: CallOverrides): Promise; + + PERMIT_TYPEHASH(overrides?: CallOverrides): Promise; + + POOL(overrides?: CallOverrides): Promise; + + RESERVE_TREASURY_ADDRESS(overrides?: CallOverrides): Promise; + + UNDERLYING_ASSET_ADDRESS(overrides?: CallOverrides): Promise; + + allowance(owner: string, spender: string, overrides?: CallOverrides): Promise; + + approve( + spender: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + balanceOf(user: string, overrides?: CallOverrides): Promise; + + burn( + from: string, + receiverOfUnderlying: string, + amount: BigNumberish, + index: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + decimals(overrides?: CallOverrides): Promise; + + decreaseAllowance( + spender: string, + subtractedValue: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + getIncentivesController(overrides?: CallOverrides): Promise; + + getPreviousIndex(user: string, overrides?: CallOverrides): Promise; + + getScaledUserBalanceAndSupply(user: string, overrides?: CallOverrides): Promise; + + handleRepayment( + user: string, + onBehalfOf: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + increaseAllowance( + spender: string, + addedValue: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + initialize( + initializingPool: string, + treasury: string, + underlyingAsset: string, + incentivesController: string, + aTokenDecimals: BigNumberish, + aTokenName: string, + aTokenSymbol: string, + params: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + mint( + caller: string, + onBehalfOf: string, + amount: BigNumberish, + index: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + mintToTreasury( + amount: BigNumberish, + index: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + name(overrides?: CallOverrides): Promise; + + nonces(owner: string, overrides?: CallOverrides): Promise; + + permit( + owner: string, + spender: string, + value: BigNumberish, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + rescueTokens( + token: string, + to: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + scaledBalanceOf(user: string, overrides?: CallOverrides): Promise; + + scaledTotalSupply(overrides?: CallOverrides): Promise; + + setIncentivesController( + controller: string, + overrides?: Overrides & { from?: string } + ): Promise; + + symbol(overrides?: CallOverrides): Promise; + + totalSupply(overrides?: CallOverrides): Promise; + + transfer( + recipient: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + transferFrom( + sender: string, + recipient: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + transferOnLiquidation( + from: string, + to: string, + value: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + transferUnderlyingTo( + target: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + }; +} diff --git a/src/modules/aavev3/contracts/AaveV3FlashLoanCallback.ts b/src/modules/aavev3/contracts/AaveV3FlashLoanCallback.ts new file mode 100644 index 00000000..041a37f3 --- /dev/null +++ b/src/modules/aavev3/contracts/AaveV3FlashLoanCallback.ts @@ -0,0 +1,167 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + BaseContract, + BigNumber, + BigNumberish, + BytesLike, + CallOverrides, + ContractTransaction, + Overrides, + PopulatedTransaction, + Signer, + utils, +} from 'ethers'; +import type { FunctionFragment, Result } from '@ethersproject/abi'; +import type { Listener, Provider } from '@ethersproject/providers'; +import type { TypedEventFilter, TypedEvent, TypedListener, OnEvent } from './common'; + +export interface AaveV3FlashLoanCallbackInterface extends utils.Interface { + functions: { + 'aaveV3Provider()': FunctionFragment; + 'executeOperation(address[],uint256[],uint256[],address,bytes)': FunctionFragment; + 'feeRate()': FunctionFragment; + 'metadata()': FunctionFragment; + 'router()': FunctionFragment; + }; + + getFunction( + nameOrSignatureOrTopic: 'aaveV3Provider' | 'executeOperation' | 'feeRate' | 'metadata' | 'router' + ): FunctionFragment; + + encodeFunctionData(functionFragment: 'aaveV3Provider', values?: undefined): string; + encodeFunctionData( + functionFragment: 'executeOperation', + values: [string[], BigNumberish[], BigNumberish[], string, BytesLike] + ): string; + encodeFunctionData(functionFragment: 'feeRate', values?: undefined): string; + encodeFunctionData(functionFragment: 'metadata', values?: undefined): string; + encodeFunctionData(functionFragment: 'router', values?: undefined): string; + + decodeFunctionResult(functionFragment: 'aaveV3Provider', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'executeOperation', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'feeRate', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'metadata', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'router', data: BytesLike): Result; + + events: {}; +} + +export interface AaveV3FlashLoanCallback extends BaseContract { + connect(signerOrProvider: Signer | Provider | string): this; + attach(addressOrName: string): this; + deployed(): Promise; + + interface: AaveV3FlashLoanCallbackInterface; + + queryFilter( + event: TypedEventFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>; + + listeners(eventFilter?: TypedEventFilter): Array>; + listeners(eventName?: string): Array; + removeAllListeners(eventFilter: TypedEventFilter): this; + removeAllListeners(eventName?: string): this; + off: OnEvent; + on: OnEvent; + once: OnEvent; + removeListener: OnEvent; + + functions: { + aaveV3Provider(overrides?: CallOverrides): Promise<[string]>; + + executeOperation( + assets: string[], + amounts: BigNumberish[], + premiums: BigNumberish[], + arg3: string, + params: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + feeRate(overrides?: CallOverrides): Promise<[BigNumber]>; + + metadata(overrides?: CallOverrides): Promise<[string]>; + + router(overrides?: CallOverrides): Promise<[string]>; + }; + + aaveV3Provider(overrides?: CallOverrides): Promise; + + executeOperation( + assets: string[], + amounts: BigNumberish[], + premiums: BigNumberish[], + arg3: string, + params: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + feeRate(overrides?: CallOverrides): Promise; + + metadata(overrides?: CallOverrides): Promise; + + router(overrides?: CallOverrides): Promise; + + callStatic: { + aaveV3Provider(overrides?: CallOverrides): Promise; + + executeOperation( + assets: string[], + amounts: BigNumberish[], + premiums: BigNumberish[], + arg3: string, + params: BytesLike, + overrides?: CallOverrides + ): Promise; + + feeRate(overrides?: CallOverrides): Promise; + + metadata(overrides?: CallOverrides): Promise; + + router(overrides?: CallOverrides): Promise; + }; + + filters: {}; + + estimateGas: { + aaveV3Provider(overrides?: CallOverrides): Promise; + + executeOperation( + assets: string[], + amounts: BigNumberish[], + premiums: BigNumberish[], + arg3: string, + params: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + feeRate(overrides?: CallOverrides): Promise; + + metadata(overrides?: CallOverrides): Promise; + + router(overrides?: CallOverrides): Promise; + }; + + populateTransaction: { + aaveV3Provider(overrides?: CallOverrides): Promise; + + executeOperation( + assets: string[], + amounts: BigNumberish[], + premiums: BigNumberish[], + arg3: string, + params: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + feeRate(overrides?: CallOverrides): Promise; + + metadata(overrides?: CallOverrides): Promise; + + router(overrides?: CallOverrides): Promise; + }; +} diff --git a/src/modules/aavev3/contracts/DebtTokenBase.ts b/src/modules/aavev3/contracts/DebtTokenBase.ts new file mode 100644 index 00000000..e1424331 --- /dev/null +++ b/src/modules/aavev3/contracts/DebtTokenBase.ts @@ -0,0 +1,256 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + BaseContract, + BigNumber, + BigNumberish, + BytesLike, + CallOverrides, + ContractTransaction, + Overrides, + PopulatedTransaction, + Signer, + utils, +} from 'ethers'; +import type { FunctionFragment, Result, EventFragment } from '@ethersproject/abi'; +import type { Listener, Provider } from '@ethersproject/providers'; +import type { TypedEventFilter, TypedEvent, TypedListener, OnEvent } from './common'; + +export interface DebtTokenBaseInterface extends utils.Interface { + functions: { + 'DELEGATION_WITH_SIG_TYPEHASH()': FunctionFragment; + 'DOMAIN_SEPARATOR()': FunctionFragment; + 'EIP712_REVISION()': FunctionFragment; + 'approveDelegation(address,uint256)': FunctionFragment; + 'borrowAllowance(address,address)': FunctionFragment; + 'delegationWithSig(address,address,uint256,uint256,uint8,bytes32,bytes32)': FunctionFragment; + 'nonces(address)': FunctionFragment; + }; + + getFunction( + nameOrSignatureOrTopic: + | 'DELEGATION_WITH_SIG_TYPEHASH' + | 'DOMAIN_SEPARATOR' + | 'EIP712_REVISION' + | 'approveDelegation' + | 'borrowAllowance' + | 'delegationWithSig' + | 'nonces' + ): FunctionFragment; + + encodeFunctionData(functionFragment: 'DELEGATION_WITH_SIG_TYPEHASH', values?: undefined): string; + encodeFunctionData(functionFragment: 'DOMAIN_SEPARATOR', values?: undefined): string; + encodeFunctionData(functionFragment: 'EIP712_REVISION', values?: undefined): string; + encodeFunctionData(functionFragment: 'approveDelegation', values: [string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'borrowAllowance', values: [string, string]): string; + encodeFunctionData( + functionFragment: 'delegationWithSig', + values: [string, string, BigNumberish, BigNumberish, BigNumberish, BytesLike, BytesLike] + ): string; + encodeFunctionData(functionFragment: 'nonces', values: [string]): string; + + decodeFunctionResult(functionFragment: 'DELEGATION_WITH_SIG_TYPEHASH', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'DOMAIN_SEPARATOR', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'EIP712_REVISION', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'approveDelegation', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'borrowAllowance', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'delegationWithSig', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'nonces', data: BytesLike): Result; + + events: { + 'BorrowAllowanceDelegated(address,address,address,uint256)': EventFragment; + }; + + getEvent(nameOrSignatureOrTopic: 'BorrowAllowanceDelegated'): EventFragment; +} + +export interface BorrowAllowanceDelegatedEventObject { + fromUser: string; + toUser: string; + asset: string; + amount: BigNumber; +} +export type BorrowAllowanceDelegatedEvent = TypedEvent< + [string, string, string, BigNumber], + BorrowAllowanceDelegatedEventObject +>; + +export type BorrowAllowanceDelegatedEventFilter = TypedEventFilter; + +export interface DebtTokenBase extends BaseContract { + connect(signerOrProvider: Signer | Provider | string): this; + attach(addressOrName: string): this; + deployed(): Promise; + + interface: DebtTokenBaseInterface; + + queryFilter( + event: TypedEventFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>; + + listeners(eventFilter?: TypedEventFilter): Array>; + listeners(eventName?: string): Array; + removeAllListeners(eventFilter: TypedEventFilter): this; + removeAllListeners(eventName?: string): this; + off: OnEvent; + on: OnEvent; + once: OnEvent; + removeListener: OnEvent; + + functions: { + DELEGATION_WITH_SIG_TYPEHASH(overrides?: CallOverrides): Promise<[string]>; + + DOMAIN_SEPARATOR(overrides?: CallOverrides): Promise<[string]>; + + EIP712_REVISION(overrides?: CallOverrides): Promise<[string]>; + + approveDelegation( + delegatee: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + borrowAllowance(fromUser: string, toUser: string, overrides?: CallOverrides): Promise<[BigNumber]>; + + delegationWithSig( + delegator: string, + delegatee: string, + value: BigNumberish, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + nonces(owner: string, overrides?: CallOverrides): Promise<[BigNumber]>; + }; + + DELEGATION_WITH_SIG_TYPEHASH(overrides?: CallOverrides): Promise; + + DOMAIN_SEPARATOR(overrides?: CallOverrides): Promise; + + EIP712_REVISION(overrides?: CallOverrides): Promise; + + approveDelegation( + delegatee: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + borrowAllowance(fromUser: string, toUser: string, overrides?: CallOverrides): Promise; + + delegationWithSig( + delegator: string, + delegatee: string, + value: BigNumberish, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + nonces(owner: string, overrides?: CallOverrides): Promise; + + callStatic: { + DELEGATION_WITH_SIG_TYPEHASH(overrides?: CallOverrides): Promise; + + DOMAIN_SEPARATOR(overrides?: CallOverrides): Promise; + + EIP712_REVISION(overrides?: CallOverrides): Promise; + + approveDelegation(delegatee: string, amount: BigNumberish, overrides?: CallOverrides): Promise; + + borrowAllowance(fromUser: string, toUser: string, overrides?: CallOverrides): Promise; + + delegationWithSig( + delegator: string, + delegatee: string, + value: BigNumberish, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: CallOverrides + ): Promise; + + nonces(owner: string, overrides?: CallOverrides): Promise; + }; + + filters: { + 'BorrowAllowanceDelegated(address,address,address,uint256)'( + fromUser?: string | null, + toUser?: string | null, + asset?: string | null, + amount?: null + ): BorrowAllowanceDelegatedEventFilter; + BorrowAllowanceDelegated( + fromUser?: string | null, + toUser?: string | null, + asset?: string | null, + amount?: null + ): BorrowAllowanceDelegatedEventFilter; + }; + + estimateGas: { + DELEGATION_WITH_SIG_TYPEHASH(overrides?: CallOverrides): Promise; + + DOMAIN_SEPARATOR(overrides?: CallOverrides): Promise; + + EIP712_REVISION(overrides?: CallOverrides): Promise; + + approveDelegation( + delegatee: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + borrowAllowance(fromUser: string, toUser: string, overrides?: CallOverrides): Promise; + + delegationWithSig( + delegator: string, + delegatee: string, + value: BigNumberish, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + nonces(owner: string, overrides?: CallOverrides): Promise; + }; + + populateTransaction: { + DELEGATION_WITH_SIG_TYPEHASH(overrides?: CallOverrides): Promise; + + DOMAIN_SEPARATOR(overrides?: CallOverrides): Promise; + + EIP712_REVISION(overrides?: CallOverrides): Promise; + + approveDelegation( + delegatee: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + borrowAllowance(fromUser: string, toUser: string, overrides?: CallOverrides): Promise; + + delegationWithSig( + delegator: string, + delegatee: string, + value: BigNumberish, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + nonces(owner: string, overrides?: CallOverrides): Promise; + }; +} diff --git a/src/modules/aavev3/contracts/Pool.ts b/src/modules/aavev3/contracts/Pool.ts new file mode 100644 index 00000000..cf1607d3 --- /dev/null +++ b/src/modules/aavev3/contracts/Pool.ts @@ -0,0 +1,1924 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + BaseContract, + BigNumber, + BigNumberish, + BytesLike, + CallOverrides, + ContractTransaction, + Overrides, + PopulatedTransaction, + Signer, + utils, +} from 'ethers'; +import type { FunctionFragment, Result, EventFragment } from '@ethersproject/abi'; +import type { Listener, Provider } from '@ethersproject/providers'; +import type { TypedEventFilter, TypedEvent, TypedListener, OnEvent } from './common'; + +export declare namespace DataTypes { + export type EModeCategoryStruct = { + ltv: BigNumberish; + liquidationThreshold: BigNumberish; + liquidationBonus: BigNumberish; + priceSource: string; + label: string; + }; + + export type EModeCategoryStructOutput = [number, number, number, string, string] & { + ltv: number; + liquidationThreshold: number; + liquidationBonus: number; + priceSource: string; + label: string; + }; + + export type ReserveConfigurationMapStruct = { data: BigNumberish }; + + export type ReserveConfigurationMapStructOutput = [BigNumber] & { + data: BigNumber; + }; + + export type ReserveDataStruct = { + configuration: DataTypes.ReserveConfigurationMapStruct; + liquidityIndex: BigNumberish; + currentLiquidityRate: BigNumberish; + variableBorrowIndex: BigNumberish; + currentVariableBorrowRate: BigNumberish; + currentStableBorrowRate: BigNumberish; + lastUpdateTimestamp: BigNumberish; + id: BigNumberish; + aTokenAddress: string; + stableDebtTokenAddress: string; + variableDebtTokenAddress: string; + interestRateStrategyAddress: string; + accruedToTreasury: BigNumberish; + unbacked: BigNumberish; + isolationModeTotalDebt: BigNumberish; + }; + + export type ReserveDataStructOutput = [ + DataTypes.ReserveConfigurationMapStructOutput, + BigNumber, + BigNumber, + BigNumber, + BigNumber, + BigNumber, + number, + number, + string, + string, + string, + string, + BigNumber, + BigNumber, + BigNumber + ] & { + configuration: DataTypes.ReserveConfigurationMapStructOutput; + liquidityIndex: BigNumber; + currentLiquidityRate: BigNumber; + variableBorrowIndex: BigNumber; + currentVariableBorrowRate: BigNumber; + currentStableBorrowRate: BigNumber; + lastUpdateTimestamp: number; + id: number; + aTokenAddress: string; + stableDebtTokenAddress: string; + variableDebtTokenAddress: string; + interestRateStrategyAddress: string; + accruedToTreasury: BigNumber; + unbacked: BigNumber; + isolationModeTotalDebt: BigNumber; + }; + + export type UserConfigurationMapStruct = { data: BigNumberish }; + + export type UserConfigurationMapStructOutput = [BigNumber] & { + data: BigNumber; + }; +} + +export interface PoolInterface extends utils.Interface { + functions: { + 'ADDRESSES_PROVIDER()': FunctionFragment; + 'BRIDGE_PROTOCOL_FEE()': FunctionFragment; + 'FLASHLOAN_PREMIUM_TOTAL()': FunctionFragment; + 'FLASHLOAN_PREMIUM_TO_PROTOCOL()': FunctionFragment; + 'MAX_NUMBER_RESERVES()': FunctionFragment; + 'MAX_STABLE_RATE_BORROW_SIZE_PERCENT()': FunctionFragment; + 'POOL_REVISION()': FunctionFragment; + 'backUnbacked(address,uint256,uint256)': FunctionFragment; + 'borrow(address,uint256,uint256,uint16,address)': FunctionFragment; + 'configureEModeCategory(uint8,(uint16,uint16,uint16,address,string))': FunctionFragment; + 'deposit(address,uint256,address,uint16)': FunctionFragment; + 'dropReserve(address)': FunctionFragment; + 'finalizeTransfer(address,address,address,uint256,uint256,uint256)': FunctionFragment; + 'flashLoan(address,address[],uint256[],uint256[],address,bytes,uint16)': FunctionFragment; + 'flashLoanSimple(address,address,uint256,bytes,uint16)': FunctionFragment; + 'getConfiguration(address)': FunctionFragment; + 'getEModeCategoryData(uint8)': FunctionFragment; + 'getReserveAddressById(uint16)': FunctionFragment; + 'getReserveData(address)': FunctionFragment; + 'getReserveNormalizedIncome(address)': FunctionFragment; + 'getReserveNormalizedVariableDebt(address)': FunctionFragment; + 'getReservesList()': FunctionFragment; + 'getUserAccountData(address)': FunctionFragment; + 'getUserConfiguration(address)': FunctionFragment; + 'getUserEMode(address)': FunctionFragment; + 'initReserve(address,address,address,address,address)': FunctionFragment; + 'initialize(address)': FunctionFragment; + 'liquidationCall(address,address,address,uint256,bool)': FunctionFragment; + 'mintToTreasury(address[])': FunctionFragment; + 'mintUnbacked(address,uint256,address,uint16)': FunctionFragment; + 'rebalanceStableBorrowRate(address,address)': FunctionFragment; + 'repay(address,uint256,uint256,address)': FunctionFragment; + 'repayWithATokens(address,uint256,uint256)': FunctionFragment; + 'repayWithPermit(address,uint256,uint256,address,uint256,uint8,bytes32,bytes32)': FunctionFragment; + 'rescueTokens(address,address,uint256)': FunctionFragment; + 'resetIsolationModeTotalDebt(address)': FunctionFragment; + 'setConfiguration(address,(uint256))': FunctionFragment; + 'setReserveInterestRateStrategyAddress(address,address)': FunctionFragment; + 'setUserEMode(uint8)': FunctionFragment; + 'setUserUseReserveAsCollateral(address,bool)': FunctionFragment; + 'supply(address,uint256,address,uint16)': FunctionFragment; + 'supplyWithPermit(address,uint256,address,uint16,uint256,uint8,bytes32,bytes32)': FunctionFragment; + 'swapBorrowRateMode(address,uint256)': FunctionFragment; + 'updateBridgeProtocolFee(uint256)': FunctionFragment; + 'updateFlashloanPremiums(uint128,uint128)': FunctionFragment; + 'withdraw(address,uint256,address)': FunctionFragment; + }; + + getFunction( + nameOrSignatureOrTopic: + | 'ADDRESSES_PROVIDER' + | 'BRIDGE_PROTOCOL_FEE' + | 'FLASHLOAN_PREMIUM_TOTAL' + | 'FLASHLOAN_PREMIUM_TO_PROTOCOL' + | 'MAX_NUMBER_RESERVES' + | 'MAX_STABLE_RATE_BORROW_SIZE_PERCENT' + | 'POOL_REVISION' + | 'backUnbacked' + | 'borrow' + | 'configureEModeCategory' + | 'deposit' + | 'dropReserve' + | 'finalizeTransfer' + | 'flashLoan' + | 'flashLoanSimple' + | 'getConfiguration' + | 'getEModeCategoryData' + | 'getReserveAddressById' + | 'getReserveData' + | 'getReserveNormalizedIncome' + | 'getReserveNormalizedVariableDebt' + | 'getReservesList' + | 'getUserAccountData' + | 'getUserConfiguration' + | 'getUserEMode' + | 'initReserve' + | 'initialize' + | 'liquidationCall' + | 'mintToTreasury' + | 'mintUnbacked' + | 'rebalanceStableBorrowRate' + | 'repay' + | 'repayWithATokens' + | 'repayWithPermit' + | 'rescueTokens' + | 'resetIsolationModeTotalDebt' + | 'setConfiguration' + | 'setReserveInterestRateStrategyAddress' + | 'setUserEMode' + | 'setUserUseReserveAsCollateral' + | 'supply' + | 'supplyWithPermit' + | 'swapBorrowRateMode' + | 'updateBridgeProtocolFee' + | 'updateFlashloanPremiums' + | 'withdraw' + ): FunctionFragment; + + encodeFunctionData(functionFragment: 'ADDRESSES_PROVIDER', values?: undefined): string; + encodeFunctionData(functionFragment: 'BRIDGE_PROTOCOL_FEE', values?: undefined): string; + encodeFunctionData(functionFragment: 'FLASHLOAN_PREMIUM_TOTAL', values?: undefined): string; + encodeFunctionData(functionFragment: 'FLASHLOAN_PREMIUM_TO_PROTOCOL', values?: undefined): string; + encodeFunctionData(functionFragment: 'MAX_NUMBER_RESERVES', values?: undefined): string; + encodeFunctionData(functionFragment: 'MAX_STABLE_RATE_BORROW_SIZE_PERCENT', values?: undefined): string; + encodeFunctionData(functionFragment: 'POOL_REVISION', values?: undefined): string; + encodeFunctionData(functionFragment: 'backUnbacked', values: [string, BigNumberish, BigNumberish]): string; + encodeFunctionData( + functionFragment: 'borrow', + values: [string, BigNumberish, BigNumberish, BigNumberish, string] + ): string; + encodeFunctionData( + functionFragment: 'configureEModeCategory', + values: [BigNumberish, DataTypes.EModeCategoryStruct] + ): string; + encodeFunctionData(functionFragment: 'deposit', values: [string, BigNumberish, string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'dropReserve', values: [string]): string; + encodeFunctionData( + functionFragment: 'finalizeTransfer', + values: [string, string, string, BigNumberish, BigNumberish, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: 'flashLoan', + values: [string, string[], BigNumberish[], BigNumberish[], string, BytesLike, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: 'flashLoanSimple', + values: [string, string, BigNumberish, BytesLike, BigNumberish] + ): string; + encodeFunctionData(functionFragment: 'getConfiguration', values: [string]): string; + encodeFunctionData(functionFragment: 'getEModeCategoryData', values: [BigNumberish]): string; + encodeFunctionData(functionFragment: 'getReserveAddressById', values: [BigNumberish]): string; + encodeFunctionData(functionFragment: 'getReserveData', values: [string]): string; + encodeFunctionData(functionFragment: 'getReserveNormalizedIncome', values: [string]): string; + encodeFunctionData(functionFragment: 'getReserveNormalizedVariableDebt', values: [string]): string; + encodeFunctionData(functionFragment: 'getReservesList', values?: undefined): string; + encodeFunctionData(functionFragment: 'getUserAccountData', values: [string]): string; + encodeFunctionData(functionFragment: 'getUserConfiguration', values: [string]): string; + encodeFunctionData(functionFragment: 'getUserEMode', values: [string]): string; + encodeFunctionData(functionFragment: 'initReserve', values: [string, string, string, string, string]): string; + encodeFunctionData(functionFragment: 'initialize', values: [string]): string; + encodeFunctionData( + functionFragment: 'liquidationCall', + values: [string, string, string, BigNumberish, boolean] + ): string; + encodeFunctionData(functionFragment: 'mintToTreasury', values: [string[]]): string; + encodeFunctionData(functionFragment: 'mintUnbacked', values: [string, BigNumberish, string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'rebalanceStableBorrowRate', values: [string, string]): string; + encodeFunctionData(functionFragment: 'repay', values: [string, BigNumberish, BigNumberish, string]): string; + encodeFunctionData(functionFragment: 'repayWithATokens', values: [string, BigNumberish, BigNumberish]): string; + encodeFunctionData( + functionFragment: 'repayWithPermit', + values: [string, BigNumberish, BigNumberish, string, BigNumberish, BigNumberish, BytesLike, BytesLike] + ): string; + encodeFunctionData(functionFragment: 'rescueTokens', values: [string, string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'resetIsolationModeTotalDebt', values: [string]): string; + encodeFunctionData( + functionFragment: 'setConfiguration', + values: [string, DataTypes.ReserveConfigurationMapStruct] + ): string; + encodeFunctionData(functionFragment: 'setReserveInterestRateStrategyAddress', values: [string, string]): string; + encodeFunctionData(functionFragment: 'setUserEMode', values: [BigNumberish]): string; + encodeFunctionData(functionFragment: 'setUserUseReserveAsCollateral', values: [string, boolean]): string; + encodeFunctionData(functionFragment: 'supply', values: [string, BigNumberish, string, BigNumberish]): string; + encodeFunctionData( + functionFragment: 'supplyWithPermit', + values: [string, BigNumberish, string, BigNumberish, BigNumberish, BigNumberish, BytesLike, BytesLike] + ): string; + encodeFunctionData(functionFragment: 'swapBorrowRateMode', values: [string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'updateBridgeProtocolFee', values: [BigNumberish]): string; + encodeFunctionData(functionFragment: 'updateFlashloanPremiums', values: [BigNumberish, BigNumberish]): string; + encodeFunctionData(functionFragment: 'withdraw', values: [string, BigNumberish, string]): string; + + decodeFunctionResult(functionFragment: 'ADDRESSES_PROVIDER', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'BRIDGE_PROTOCOL_FEE', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'FLASHLOAN_PREMIUM_TOTAL', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'FLASHLOAN_PREMIUM_TO_PROTOCOL', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'MAX_NUMBER_RESERVES', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'MAX_STABLE_RATE_BORROW_SIZE_PERCENT', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'POOL_REVISION', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'backUnbacked', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'borrow', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'configureEModeCategory', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'deposit', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'dropReserve', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'finalizeTransfer', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'flashLoan', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'flashLoanSimple', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getConfiguration', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getEModeCategoryData', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getReserveAddressById', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getReserveData', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getReserveNormalizedIncome', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getReserveNormalizedVariableDebt', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getReservesList', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getUserAccountData', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getUserConfiguration', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getUserEMode', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'initReserve', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'initialize', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'liquidationCall', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'mintToTreasury', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'mintUnbacked', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'rebalanceStableBorrowRate', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'repay', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'repayWithATokens', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'repayWithPermit', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'rescueTokens', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'resetIsolationModeTotalDebt', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'setConfiguration', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'setReserveInterestRateStrategyAddress', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'setUserEMode', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'setUserUseReserveAsCollateral', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'supply', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'supplyWithPermit', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'swapBorrowRateMode', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'updateBridgeProtocolFee', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'updateFlashloanPremiums', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'withdraw', data: BytesLike): Result; + + events: { + 'BackUnbacked(address,address,uint256,uint256)': EventFragment; + 'Borrow(address,address,address,uint256,uint8,uint256,uint16)': EventFragment; + 'FlashLoan(address,address,address,uint256,uint8,uint256,uint16)': EventFragment; + 'IsolationModeTotalDebtUpdated(address,uint256)': EventFragment; + 'LiquidationCall(address,address,address,uint256,uint256,address,bool)': EventFragment; + 'MintUnbacked(address,address,address,uint256,uint16)': EventFragment; + 'MintedToTreasury(address,uint256)': EventFragment; + 'RebalanceStableBorrowRate(address,address)': EventFragment; + 'Repay(address,address,address,uint256,bool)': EventFragment; + 'ReserveDataUpdated(address,uint256,uint256,uint256,uint256,uint256)': EventFragment; + 'ReserveUsedAsCollateralDisabled(address,address)': EventFragment; + 'ReserveUsedAsCollateralEnabled(address,address)': EventFragment; + 'Supply(address,address,address,uint256,uint16)': EventFragment; + 'SwapBorrowRateMode(address,address,uint8)': EventFragment; + 'UserEModeSet(address,uint8)': EventFragment; + 'Withdraw(address,address,address,uint256)': EventFragment; + }; + + getEvent(nameOrSignatureOrTopic: 'BackUnbacked'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'Borrow'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'FlashLoan'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'IsolationModeTotalDebtUpdated'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'LiquidationCall'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'MintUnbacked'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'MintedToTreasury'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'RebalanceStableBorrowRate'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'Repay'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'ReserveDataUpdated'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'ReserveUsedAsCollateralDisabled'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'ReserveUsedAsCollateralEnabled'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'Supply'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'SwapBorrowRateMode'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'UserEModeSet'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'Withdraw'): EventFragment; +} + +export interface BackUnbackedEventObject { + reserve: string; + backer: string; + amount: BigNumber; + fee: BigNumber; +} +export type BackUnbackedEvent = TypedEvent<[string, string, BigNumber, BigNumber], BackUnbackedEventObject>; + +export type BackUnbackedEventFilter = TypedEventFilter; + +export interface BorrowEventObject { + reserve: string; + user: string; + onBehalfOf: string; + amount: BigNumber; + interestRateMode: number; + borrowRate: BigNumber; + referralCode: number; +} +export type BorrowEvent = TypedEvent<[string, string, string, BigNumber, number, BigNumber, number], BorrowEventObject>; + +export type BorrowEventFilter = TypedEventFilter; + +export interface FlashLoanEventObject { + target: string; + initiator: string; + asset: string; + amount: BigNumber; + interestRateMode: number; + premium: BigNumber; + referralCode: number; +} +export type FlashLoanEvent = TypedEvent< + [string, string, string, BigNumber, number, BigNumber, number], + FlashLoanEventObject +>; + +export type FlashLoanEventFilter = TypedEventFilter; + +export interface IsolationModeTotalDebtUpdatedEventObject { + asset: string; + totalDebt: BigNumber; +} +export type IsolationModeTotalDebtUpdatedEvent = TypedEvent< + [string, BigNumber], + IsolationModeTotalDebtUpdatedEventObject +>; + +export type IsolationModeTotalDebtUpdatedEventFilter = TypedEventFilter; + +export interface LiquidationCallEventObject { + collateralAsset: string; + debtAsset: string; + user: string; + debtToCover: BigNumber; + liquidatedCollateralAmount: BigNumber; + liquidator: string; + receiveAToken: boolean; +} +export type LiquidationCallEvent = TypedEvent< + [string, string, string, BigNumber, BigNumber, string, boolean], + LiquidationCallEventObject +>; + +export type LiquidationCallEventFilter = TypedEventFilter; + +export interface MintUnbackedEventObject { + reserve: string; + user: string; + onBehalfOf: string; + amount: BigNumber; + referralCode: number; +} +export type MintUnbackedEvent = TypedEvent<[string, string, string, BigNumber, number], MintUnbackedEventObject>; + +export type MintUnbackedEventFilter = TypedEventFilter; + +export interface MintedToTreasuryEventObject { + reserve: string; + amountMinted: BigNumber; +} +export type MintedToTreasuryEvent = TypedEvent<[string, BigNumber], MintedToTreasuryEventObject>; + +export type MintedToTreasuryEventFilter = TypedEventFilter; + +export interface RebalanceStableBorrowRateEventObject { + reserve: string; + user: string; +} +export type RebalanceStableBorrowRateEvent = TypedEvent<[string, string], RebalanceStableBorrowRateEventObject>; + +export type RebalanceStableBorrowRateEventFilter = TypedEventFilter; + +export interface RepayEventObject { + reserve: string; + user: string; + repayer: string; + amount: BigNumber; + useATokens: boolean; +} +export type RepayEvent = TypedEvent<[string, string, string, BigNumber, boolean], RepayEventObject>; + +export type RepayEventFilter = TypedEventFilter; + +export interface ReserveDataUpdatedEventObject { + reserve: string; + liquidityRate: BigNumber; + stableBorrowRate: BigNumber; + variableBorrowRate: BigNumber; + liquidityIndex: BigNumber; + variableBorrowIndex: BigNumber; +} +export type ReserveDataUpdatedEvent = TypedEvent< + [string, BigNumber, BigNumber, BigNumber, BigNumber, BigNumber], + ReserveDataUpdatedEventObject +>; + +export type ReserveDataUpdatedEventFilter = TypedEventFilter; + +export interface ReserveUsedAsCollateralDisabledEventObject { + reserve: string; + user: string; +} +export type ReserveUsedAsCollateralDisabledEvent = TypedEvent< + [string, string], + ReserveUsedAsCollateralDisabledEventObject +>; + +export type ReserveUsedAsCollateralDisabledEventFilter = TypedEventFilter; + +export interface ReserveUsedAsCollateralEnabledEventObject { + reserve: string; + user: string; +} +export type ReserveUsedAsCollateralEnabledEvent = TypedEvent< + [string, string], + ReserveUsedAsCollateralEnabledEventObject +>; + +export type ReserveUsedAsCollateralEnabledEventFilter = TypedEventFilter; + +export interface SupplyEventObject { + reserve: string; + user: string; + onBehalfOf: string; + amount: BigNumber; + referralCode: number; +} +export type SupplyEvent = TypedEvent<[string, string, string, BigNumber, number], SupplyEventObject>; + +export type SupplyEventFilter = TypedEventFilter; + +export interface SwapBorrowRateModeEventObject { + reserve: string; + user: string; + interestRateMode: number; +} +export type SwapBorrowRateModeEvent = TypedEvent<[string, string, number], SwapBorrowRateModeEventObject>; + +export type SwapBorrowRateModeEventFilter = TypedEventFilter; + +export interface UserEModeSetEventObject { + user: string; + categoryId: number; +} +export type UserEModeSetEvent = TypedEvent<[string, number], UserEModeSetEventObject>; + +export type UserEModeSetEventFilter = TypedEventFilter; + +export interface WithdrawEventObject { + reserve: string; + user: string; + to: string; + amount: BigNumber; +} +export type WithdrawEvent = TypedEvent<[string, string, string, BigNumber], WithdrawEventObject>; + +export type WithdrawEventFilter = TypedEventFilter; + +export interface Pool extends BaseContract { + connect(signerOrProvider: Signer | Provider | string): this; + attach(addressOrName: string): this; + deployed(): Promise; + + interface: PoolInterface; + + queryFilter( + event: TypedEventFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>; + + listeners(eventFilter?: TypedEventFilter): Array>; + listeners(eventName?: string): Array; + removeAllListeners(eventFilter: TypedEventFilter): this; + removeAllListeners(eventName?: string): this; + off: OnEvent; + on: OnEvent; + once: OnEvent; + removeListener: OnEvent; + + functions: { + ADDRESSES_PROVIDER(overrides?: CallOverrides): Promise<[string]>; + + BRIDGE_PROTOCOL_FEE(overrides?: CallOverrides): Promise<[BigNumber]>; + + FLASHLOAN_PREMIUM_TOTAL(overrides?: CallOverrides): Promise<[BigNumber]>; + + FLASHLOAN_PREMIUM_TO_PROTOCOL(overrides?: CallOverrides): Promise<[BigNumber]>; + + MAX_NUMBER_RESERVES(overrides?: CallOverrides): Promise<[number]>; + + MAX_STABLE_RATE_BORROW_SIZE_PERCENT(overrides?: CallOverrides): Promise<[BigNumber]>; + + POOL_REVISION(overrides?: CallOverrides): Promise<[BigNumber]>; + + backUnbacked( + asset: string, + amount: BigNumberish, + fee: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + borrow( + asset: string, + amount: BigNumberish, + interestRateMode: BigNumberish, + referralCode: BigNumberish, + onBehalfOf: string, + overrides?: Overrides & { from?: string } + ): Promise; + + configureEModeCategory( + id: BigNumberish, + category: DataTypes.EModeCategoryStruct, + overrides?: Overrides & { from?: string } + ): Promise; + + deposit( + asset: string, + amount: BigNumberish, + onBehalfOf: string, + referralCode: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + dropReserve(asset: string, overrides?: Overrides & { from?: string }): Promise; + + finalizeTransfer( + asset: string, + from: string, + to: string, + amount: BigNumberish, + balanceFromBefore: BigNumberish, + balanceToBefore: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + flashLoan( + receiverAddress: string, + assets: string[], + amounts: BigNumberish[], + interestRateModes: BigNumberish[], + onBehalfOf: string, + params: BytesLike, + referralCode: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + flashLoanSimple( + receiverAddress: string, + asset: string, + amount: BigNumberish, + params: BytesLike, + referralCode: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + getConfiguration( + asset: string, + overrides?: CallOverrides + ): Promise<[DataTypes.ReserveConfigurationMapStructOutput]>; + + getEModeCategoryData(id: BigNumberish, overrides?: CallOverrides): Promise<[DataTypes.EModeCategoryStructOutput]>; + + getReserveAddressById(id: BigNumberish, overrides?: CallOverrides): Promise<[string]>; + + getReserveData(asset: string, overrides?: CallOverrides): Promise<[DataTypes.ReserveDataStructOutput]>; + + getReserveNormalizedIncome(asset: string, overrides?: CallOverrides): Promise<[BigNumber]>; + + getReserveNormalizedVariableDebt(asset: string, overrides?: CallOverrides): Promise<[BigNumber]>; + + getReservesList(overrides?: CallOverrides): Promise<[string[]]>; + + getUserAccountData( + user: string, + overrides?: CallOverrides + ): Promise< + [BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, BigNumber] & { + totalCollateralBase: BigNumber; + totalDebtBase: BigNumber; + availableBorrowsBase: BigNumber; + currentLiquidationThreshold: BigNumber; + ltv: BigNumber; + healthFactor: BigNumber; + } + >; + + getUserConfiguration( + user: string, + overrides?: CallOverrides + ): Promise<[DataTypes.UserConfigurationMapStructOutput]>; + + getUserEMode(user: string, overrides?: CallOverrides): Promise<[BigNumber]>; + + initReserve( + asset: string, + aTokenAddress: string, + stableDebtAddress: string, + variableDebtAddress: string, + interestRateStrategyAddress: string, + overrides?: Overrides & { from?: string } + ): Promise; + + initialize(provider: string, overrides?: Overrides & { from?: string }): Promise; + + liquidationCall( + collateralAsset: string, + debtAsset: string, + user: string, + debtToCover: BigNumberish, + receiveAToken: boolean, + overrides?: Overrides & { from?: string } + ): Promise; + + mintToTreasury(assets: string[], overrides?: Overrides & { from?: string }): Promise; + + mintUnbacked( + asset: string, + amount: BigNumberish, + onBehalfOf: string, + referralCode: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + rebalanceStableBorrowRate( + asset: string, + user: string, + overrides?: Overrides & { from?: string } + ): Promise; + + repay( + asset: string, + amount: BigNumberish, + interestRateMode: BigNumberish, + onBehalfOf: string, + overrides?: Overrides & { from?: string } + ): Promise; + + repayWithATokens( + asset: string, + amount: BigNumberish, + interestRateMode: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + repayWithPermit( + asset: string, + amount: BigNumberish, + interestRateMode: BigNumberish, + onBehalfOf: string, + deadline: BigNumberish, + permitV: BigNumberish, + permitR: BytesLike, + permitS: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + rescueTokens( + token: string, + to: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + resetIsolationModeTotalDebt(asset: string, overrides?: Overrides & { from?: string }): Promise; + + setConfiguration( + asset: string, + configuration: DataTypes.ReserveConfigurationMapStruct, + overrides?: Overrides & { from?: string } + ): Promise; + + setReserveInterestRateStrategyAddress( + asset: string, + rateStrategyAddress: string, + overrides?: Overrides & { from?: string } + ): Promise; + + setUserEMode(categoryId: BigNumberish, overrides?: Overrides & { from?: string }): Promise; + + setUserUseReserveAsCollateral( + asset: string, + useAsCollateral: boolean, + overrides?: Overrides & { from?: string } + ): Promise; + + supply( + asset: string, + amount: BigNumberish, + onBehalfOf: string, + referralCode: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + supplyWithPermit( + asset: string, + amount: BigNumberish, + onBehalfOf: string, + referralCode: BigNumberish, + deadline: BigNumberish, + permitV: BigNumberish, + permitR: BytesLike, + permitS: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + swapBorrowRateMode( + asset: string, + interestRateMode: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + updateBridgeProtocolFee( + protocolFee: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + updateFlashloanPremiums( + flashLoanPremiumTotal: BigNumberish, + flashLoanPremiumToProtocol: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + withdraw( + asset: string, + amount: BigNumberish, + to: string, + overrides?: Overrides & { from?: string } + ): Promise; + }; + + ADDRESSES_PROVIDER(overrides?: CallOverrides): Promise; + + BRIDGE_PROTOCOL_FEE(overrides?: CallOverrides): Promise; + + FLASHLOAN_PREMIUM_TOTAL(overrides?: CallOverrides): Promise; + + FLASHLOAN_PREMIUM_TO_PROTOCOL(overrides?: CallOverrides): Promise; + + MAX_NUMBER_RESERVES(overrides?: CallOverrides): Promise; + + MAX_STABLE_RATE_BORROW_SIZE_PERCENT(overrides?: CallOverrides): Promise; + + POOL_REVISION(overrides?: CallOverrides): Promise; + + backUnbacked( + asset: string, + amount: BigNumberish, + fee: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + borrow( + asset: string, + amount: BigNumberish, + interestRateMode: BigNumberish, + referralCode: BigNumberish, + onBehalfOf: string, + overrides?: Overrides & { from?: string } + ): Promise; + + configureEModeCategory( + id: BigNumberish, + category: DataTypes.EModeCategoryStruct, + overrides?: Overrides & { from?: string } + ): Promise; + + deposit( + asset: string, + amount: BigNumberish, + onBehalfOf: string, + referralCode: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + dropReserve(asset: string, overrides?: Overrides & { from?: string }): Promise; + + finalizeTransfer( + asset: string, + from: string, + to: string, + amount: BigNumberish, + balanceFromBefore: BigNumberish, + balanceToBefore: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + flashLoan( + receiverAddress: string, + assets: string[], + amounts: BigNumberish[], + interestRateModes: BigNumberish[], + onBehalfOf: string, + params: BytesLike, + referralCode: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + flashLoanSimple( + receiverAddress: string, + asset: string, + amount: BigNumberish, + params: BytesLike, + referralCode: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + getConfiguration(asset: string, overrides?: CallOverrides): Promise; + + getEModeCategoryData(id: BigNumberish, overrides?: CallOverrides): Promise; + + getReserveAddressById(id: BigNumberish, overrides?: CallOverrides): Promise; + + getReserveData(asset: string, overrides?: CallOverrides): Promise; + + getReserveNormalizedIncome(asset: string, overrides?: CallOverrides): Promise; + + getReserveNormalizedVariableDebt(asset: string, overrides?: CallOverrides): Promise; + + getReservesList(overrides?: CallOverrides): Promise; + + getUserAccountData( + user: string, + overrides?: CallOverrides + ): Promise< + [BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, BigNumber] & { + totalCollateralBase: BigNumber; + totalDebtBase: BigNumber; + availableBorrowsBase: BigNumber; + currentLiquidationThreshold: BigNumber; + ltv: BigNumber; + healthFactor: BigNumber; + } + >; + + getUserConfiguration(user: string, overrides?: CallOverrides): Promise; + + getUserEMode(user: string, overrides?: CallOverrides): Promise; + + initReserve( + asset: string, + aTokenAddress: string, + stableDebtAddress: string, + variableDebtAddress: string, + interestRateStrategyAddress: string, + overrides?: Overrides & { from?: string } + ): Promise; + + initialize(provider: string, overrides?: Overrides & { from?: string }): Promise; + + liquidationCall( + collateralAsset: string, + debtAsset: string, + user: string, + debtToCover: BigNumberish, + receiveAToken: boolean, + overrides?: Overrides & { from?: string } + ): Promise; + + mintToTreasury(assets: string[], overrides?: Overrides & { from?: string }): Promise; + + mintUnbacked( + asset: string, + amount: BigNumberish, + onBehalfOf: string, + referralCode: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + rebalanceStableBorrowRate( + asset: string, + user: string, + overrides?: Overrides & { from?: string } + ): Promise; + + repay( + asset: string, + amount: BigNumberish, + interestRateMode: BigNumberish, + onBehalfOf: string, + overrides?: Overrides & { from?: string } + ): Promise; + + repayWithATokens( + asset: string, + amount: BigNumberish, + interestRateMode: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + repayWithPermit( + asset: string, + amount: BigNumberish, + interestRateMode: BigNumberish, + onBehalfOf: string, + deadline: BigNumberish, + permitV: BigNumberish, + permitR: BytesLike, + permitS: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + rescueTokens( + token: string, + to: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + resetIsolationModeTotalDebt(asset: string, overrides?: Overrides & { from?: string }): Promise; + + setConfiguration( + asset: string, + configuration: DataTypes.ReserveConfigurationMapStruct, + overrides?: Overrides & { from?: string } + ): Promise; + + setReserveInterestRateStrategyAddress( + asset: string, + rateStrategyAddress: string, + overrides?: Overrides & { from?: string } + ): Promise; + + setUserEMode(categoryId: BigNumberish, overrides?: Overrides & { from?: string }): Promise; + + setUserUseReserveAsCollateral( + asset: string, + useAsCollateral: boolean, + overrides?: Overrides & { from?: string } + ): Promise; + + supply( + asset: string, + amount: BigNumberish, + onBehalfOf: string, + referralCode: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + supplyWithPermit( + asset: string, + amount: BigNumberish, + onBehalfOf: string, + referralCode: BigNumberish, + deadline: BigNumberish, + permitV: BigNumberish, + permitR: BytesLike, + permitS: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + swapBorrowRateMode( + asset: string, + interestRateMode: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + updateBridgeProtocolFee( + protocolFee: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + updateFlashloanPremiums( + flashLoanPremiumTotal: BigNumberish, + flashLoanPremiumToProtocol: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + withdraw( + asset: string, + amount: BigNumberish, + to: string, + overrides?: Overrides & { from?: string } + ): Promise; + + callStatic: { + ADDRESSES_PROVIDER(overrides?: CallOverrides): Promise; + + BRIDGE_PROTOCOL_FEE(overrides?: CallOverrides): Promise; + + FLASHLOAN_PREMIUM_TOTAL(overrides?: CallOverrides): Promise; + + FLASHLOAN_PREMIUM_TO_PROTOCOL(overrides?: CallOverrides): Promise; + + MAX_NUMBER_RESERVES(overrides?: CallOverrides): Promise; + + MAX_STABLE_RATE_BORROW_SIZE_PERCENT(overrides?: CallOverrides): Promise; + + POOL_REVISION(overrides?: CallOverrides): Promise; + + backUnbacked(asset: string, amount: BigNumberish, fee: BigNumberish, overrides?: CallOverrides): Promise; + + borrow( + asset: string, + amount: BigNumberish, + interestRateMode: BigNumberish, + referralCode: BigNumberish, + onBehalfOf: string, + overrides?: CallOverrides + ): Promise; + + configureEModeCategory( + id: BigNumberish, + category: DataTypes.EModeCategoryStruct, + overrides?: CallOverrides + ): Promise; + + deposit( + asset: string, + amount: BigNumberish, + onBehalfOf: string, + referralCode: BigNumberish, + overrides?: CallOverrides + ): Promise; + + dropReserve(asset: string, overrides?: CallOverrides): Promise; + + finalizeTransfer( + asset: string, + from: string, + to: string, + amount: BigNumberish, + balanceFromBefore: BigNumberish, + balanceToBefore: BigNumberish, + overrides?: CallOverrides + ): Promise; + + flashLoan( + receiverAddress: string, + assets: string[], + amounts: BigNumberish[], + interestRateModes: BigNumberish[], + onBehalfOf: string, + params: BytesLike, + referralCode: BigNumberish, + overrides?: CallOverrides + ): Promise; + + flashLoanSimple( + receiverAddress: string, + asset: string, + amount: BigNumberish, + params: BytesLike, + referralCode: BigNumberish, + overrides?: CallOverrides + ): Promise; + + getConfiguration(asset: string, overrides?: CallOverrides): Promise; + + getEModeCategoryData(id: BigNumberish, overrides?: CallOverrides): Promise; + + getReserveAddressById(id: BigNumberish, overrides?: CallOverrides): Promise; + + getReserveData(asset: string, overrides?: CallOverrides): Promise; + + getReserveNormalizedIncome(asset: string, overrides?: CallOverrides): Promise; + + getReserveNormalizedVariableDebt(asset: string, overrides?: CallOverrides): Promise; + + getReservesList(overrides?: CallOverrides): Promise; + + getUserAccountData( + user: string, + overrides?: CallOverrides + ): Promise< + [BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, BigNumber] & { + totalCollateralBase: BigNumber; + totalDebtBase: BigNumber; + availableBorrowsBase: BigNumber; + currentLiquidationThreshold: BigNumber; + ltv: BigNumber; + healthFactor: BigNumber; + } + >; + + getUserConfiguration(user: string, overrides?: CallOverrides): Promise; + + getUserEMode(user: string, overrides?: CallOverrides): Promise; + + initReserve( + asset: string, + aTokenAddress: string, + stableDebtAddress: string, + variableDebtAddress: string, + interestRateStrategyAddress: string, + overrides?: CallOverrides + ): Promise; + + initialize(provider: string, overrides?: CallOverrides): Promise; + + liquidationCall( + collateralAsset: string, + debtAsset: string, + user: string, + debtToCover: BigNumberish, + receiveAToken: boolean, + overrides?: CallOverrides + ): Promise; + + mintToTreasury(assets: string[], overrides?: CallOverrides): Promise; + + mintUnbacked( + asset: string, + amount: BigNumberish, + onBehalfOf: string, + referralCode: BigNumberish, + overrides?: CallOverrides + ): Promise; + + rebalanceStableBorrowRate(asset: string, user: string, overrides?: CallOverrides): Promise; + + repay( + asset: string, + amount: BigNumberish, + interestRateMode: BigNumberish, + onBehalfOf: string, + overrides?: CallOverrides + ): Promise; + + repayWithATokens( + asset: string, + amount: BigNumberish, + interestRateMode: BigNumberish, + overrides?: CallOverrides + ): Promise; + + repayWithPermit( + asset: string, + amount: BigNumberish, + interestRateMode: BigNumberish, + onBehalfOf: string, + deadline: BigNumberish, + permitV: BigNumberish, + permitR: BytesLike, + permitS: BytesLike, + overrides?: CallOverrides + ): Promise; + + rescueTokens(token: string, to: string, amount: BigNumberish, overrides?: CallOverrides): Promise; + + resetIsolationModeTotalDebt(asset: string, overrides?: CallOverrides): Promise; + + setConfiguration( + asset: string, + configuration: DataTypes.ReserveConfigurationMapStruct, + overrides?: CallOverrides + ): Promise; + + setReserveInterestRateStrategyAddress( + asset: string, + rateStrategyAddress: string, + overrides?: CallOverrides + ): Promise; + + setUserEMode(categoryId: BigNumberish, overrides?: CallOverrides): Promise; + + setUserUseReserveAsCollateral(asset: string, useAsCollateral: boolean, overrides?: CallOverrides): Promise; + + supply( + asset: string, + amount: BigNumberish, + onBehalfOf: string, + referralCode: BigNumberish, + overrides?: CallOverrides + ): Promise; + + supplyWithPermit( + asset: string, + amount: BigNumberish, + onBehalfOf: string, + referralCode: BigNumberish, + deadline: BigNumberish, + permitV: BigNumberish, + permitR: BytesLike, + permitS: BytesLike, + overrides?: CallOverrides + ): Promise; + + swapBorrowRateMode(asset: string, interestRateMode: BigNumberish, overrides?: CallOverrides): Promise; + + updateBridgeProtocolFee(protocolFee: BigNumberish, overrides?: CallOverrides): Promise; + + updateFlashloanPremiums( + flashLoanPremiumTotal: BigNumberish, + flashLoanPremiumToProtocol: BigNumberish, + overrides?: CallOverrides + ): Promise; + + withdraw(asset: string, amount: BigNumberish, to: string, overrides?: CallOverrides): Promise; + }; + + filters: { + 'BackUnbacked(address,address,uint256,uint256)'( + reserve?: string | null, + backer?: string | null, + amount?: null, + fee?: null + ): BackUnbackedEventFilter; + BackUnbacked(reserve?: string | null, backer?: string | null, amount?: null, fee?: null): BackUnbackedEventFilter; + + 'Borrow(address,address,address,uint256,uint8,uint256,uint16)'( + reserve?: string | null, + user?: null, + onBehalfOf?: string | null, + amount?: null, + interestRateMode?: null, + borrowRate?: null, + referralCode?: BigNumberish | null + ): BorrowEventFilter; + Borrow( + reserve?: string | null, + user?: null, + onBehalfOf?: string | null, + amount?: null, + interestRateMode?: null, + borrowRate?: null, + referralCode?: BigNumberish | null + ): BorrowEventFilter; + + 'FlashLoan(address,address,address,uint256,uint8,uint256,uint16)'( + target?: string | null, + initiator?: null, + asset?: string | null, + amount?: null, + interestRateMode?: null, + premium?: null, + referralCode?: BigNumberish | null + ): FlashLoanEventFilter; + FlashLoan( + target?: string | null, + initiator?: null, + asset?: string | null, + amount?: null, + interestRateMode?: null, + premium?: null, + referralCode?: BigNumberish | null + ): FlashLoanEventFilter; + + 'IsolationModeTotalDebtUpdated(address,uint256)'( + asset?: string | null, + totalDebt?: null + ): IsolationModeTotalDebtUpdatedEventFilter; + IsolationModeTotalDebtUpdated(asset?: string | null, totalDebt?: null): IsolationModeTotalDebtUpdatedEventFilter; + + 'LiquidationCall(address,address,address,uint256,uint256,address,bool)'( + collateralAsset?: string | null, + debtAsset?: string | null, + user?: string | null, + debtToCover?: null, + liquidatedCollateralAmount?: null, + liquidator?: null, + receiveAToken?: null + ): LiquidationCallEventFilter; + LiquidationCall( + collateralAsset?: string | null, + debtAsset?: string | null, + user?: string | null, + debtToCover?: null, + liquidatedCollateralAmount?: null, + liquidator?: null, + receiveAToken?: null + ): LiquidationCallEventFilter; + + 'MintUnbacked(address,address,address,uint256,uint16)'( + reserve?: string | null, + user?: null, + onBehalfOf?: string | null, + amount?: null, + referralCode?: BigNumberish | null + ): MintUnbackedEventFilter; + MintUnbacked( + reserve?: string | null, + user?: null, + onBehalfOf?: string | null, + amount?: null, + referralCode?: BigNumberish | null + ): MintUnbackedEventFilter; + + 'MintedToTreasury(address,uint256)'(reserve?: string | null, amountMinted?: null): MintedToTreasuryEventFilter; + MintedToTreasury(reserve?: string | null, amountMinted?: null): MintedToTreasuryEventFilter; + + 'RebalanceStableBorrowRate(address,address)'( + reserve?: string | null, + user?: string | null + ): RebalanceStableBorrowRateEventFilter; + RebalanceStableBorrowRate(reserve?: string | null, user?: string | null): RebalanceStableBorrowRateEventFilter; + + 'Repay(address,address,address,uint256,bool)'( + reserve?: string | null, + user?: string | null, + repayer?: string | null, + amount?: null, + useATokens?: null + ): RepayEventFilter; + Repay( + reserve?: string | null, + user?: string | null, + repayer?: string | null, + amount?: null, + useATokens?: null + ): RepayEventFilter; + + 'ReserveDataUpdated(address,uint256,uint256,uint256,uint256,uint256)'( + reserve?: string | null, + liquidityRate?: null, + stableBorrowRate?: null, + variableBorrowRate?: null, + liquidityIndex?: null, + variableBorrowIndex?: null + ): ReserveDataUpdatedEventFilter; + ReserveDataUpdated( + reserve?: string | null, + liquidityRate?: null, + stableBorrowRate?: null, + variableBorrowRate?: null, + liquidityIndex?: null, + variableBorrowIndex?: null + ): ReserveDataUpdatedEventFilter; + + 'ReserveUsedAsCollateralDisabled(address,address)'( + reserve?: string | null, + user?: string | null + ): ReserveUsedAsCollateralDisabledEventFilter; + ReserveUsedAsCollateralDisabled( + reserve?: string | null, + user?: string | null + ): ReserveUsedAsCollateralDisabledEventFilter; + + 'ReserveUsedAsCollateralEnabled(address,address)'( + reserve?: string | null, + user?: string | null + ): ReserveUsedAsCollateralEnabledEventFilter; + ReserveUsedAsCollateralEnabled( + reserve?: string | null, + user?: string | null + ): ReserveUsedAsCollateralEnabledEventFilter; + + 'Supply(address,address,address,uint256,uint16)'( + reserve?: string | null, + user?: null, + onBehalfOf?: string | null, + amount?: null, + referralCode?: BigNumberish | null + ): SupplyEventFilter; + Supply( + reserve?: string | null, + user?: null, + onBehalfOf?: string | null, + amount?: null, + referralCode?: BigNumberish | null + ): SupplyEventFilter; + + 'SwapBorrowRateMode(address,address,uint8)'( + reserve?: string | null, + user?: string | null, + interestRateMode?: null + ): SwapBorrowRateModeEventFilter; + SwapBorrowRateMode( + reserve?: string | null, + user?: string | null, + interestRateMode?: null + ): SwapBorrowRateModeEventFilter; + + 'UserEModeSet(address,uint8)'(user?: string | null, categoryId?: null): UserEModeSetEventFilter; + UserEModeSet(user?: string | null, categoryId?: null): UserEModeSetEventFilter; + + 'Withdraw(address,address,address,uint256)'( + reserve?: string | null, + user?: string | null, + to?: string | null, + amount?: null + ): WithdrawEventFilter; + Withdraw(reserve?: string | null, user?: string | null, to?: string | null, amount?: null): WithdrawEventFilter; + }; + + estimateGas: { + ADDRESSES_PROVIDER(overrides?: CallOverrides): Promise; + + BRIDGE_PROTOCOL_FEE(overrides?: CallOverrides): Promise; + + FLASHLOAN_PREMIUM_TOTAL(overrides?: CallOverrides): Promise; + + FLASHLOAN_PREMIUM_TO_PROTOCOL(overrides?: CallOverrides): Promise; + + MAX_NUMBER_RESERVES(overrides?: CallOverrides): Promise; + + MAX_STABLE_RATE_BORROW_SIZE_PERCENT(overrides?: CallOverrides): Promise; + + POOL_REVISION(overrides?: CallOverrides): Promise; + + backUnbacked( + asset: string, + amount: BigNumberish, + fee: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + borrow( + asset: string, + amount: BigNumberish, + interestRateMode: BigNumberish, + referralCode: BigNumberish, + onBehalfOf: string, + overrides?: Overrides & { from?: string } + ): Promise; + + configureEModeCategory( + id: BigNumberish, + category: DataTypes.EModeCategoryStruct, + overrides?: Overrides & { from?: string } + ): Promise; + + deposit( + asset: string, + amount: BigNumberish, + onBehalfOf: string, + referralCode: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + dropReserve(asset: string, overrides?: Overrides & { from?: string }): Promise; + + finalizeTransfer( + asset: string, + from: string, + to: string, + amount: BigNumberish, + balanceFromBefore: BigNumberish, + balanceToBefore: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + flashLoan( + receiverAddress: string, + assets: string[], + amounts: BigNumberish[], + interestRateModes: BigNumberish[], + onBehalfOf: string, + params: BytesLike, + referralCode: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + flashLoanSimple( + receiverAddress: string, + asset: string, + amount: BigNumberish, + params: BytesLike, + referralCode: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + getConfiguration(asset: string, overrides?: CallOverrides): Promise; + + getEModeCategoryData(id: BigNumberish, overrides?: CallOverrides): Promise; + + getReserveAddressById(id: BigNumberish, overrides?: CallOverrides): Promise; + + getReserveData(asset: string, overrides?: CallOverrides): Promise; + + getReserveNormalizedIncome(asset: string, overrides?: CallOverrides): Promise; + + getReserveNormalizedVariableDebt(asset: string, overrides?: CallOverrides): Promise; + + getReservesList(overrides?: CallOverrides): Promise; + + getUserAccountData(user: string, overrides?: CallOverrides): Promise; + + getUserConfiguration(user: string, overrides?: CallOverrides): Promise; + + getUserEMode(user: string, overrides?: CallOverrides): Promise; + + initReserve( + asset: string, + aTokenAddress: string, + stableDebtAddress: string, + variableDebtAddress: string, + interestRateStrategyAddress: string, + overrides?: Overrides & { from?: string } + ): Promise; + + initialize(provider: string, overrides?: Overrides & { from?: string }): Promise; + + liquidationCall( + collateralAsset: string, + debtAsset: string, + user: string, + debtToCover: BigNumberish, + receiveAToken: boolean, + overrides?: Overrides & { from?: string } + ): Promise; + + mintToTreasury(assets: string[], overrides?: Overrides & { from?: string }): Promise; + + mintUnbacked( + asset: string, + amount: BigNumberish, + onBehalfOf: string, + referralCode: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + rebalanceStableBorrowRate( + asset: string, + user: string, + overrides?: Overrides & { from?: string } + ): Promise; + + repay( + asset: string, + amount: BigNumberish, + interestRateMode: BigNumberish, + onBehalfOf: string, + overrides?: Overrides & { from?: string } + ): Promise; + + repayWithATokens( + asset: string, + amount: BigNumberish, + interestRateMode: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + repayWithPermit( + asset: string, + amount: BigNumberish, + interestRateMode: BigNumberish, + onBehalfOf: string, + deadline: BigNumberish, + permitV: BigNumberish, + permitR: BytesLike, + permitS: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + rescueTokens( + token: string, + to: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + resetIsolationModeTotalDebt(asset: string, overrides?: Overrides & { from?: string }): Promise; + + setConfiguration( + asset: string, + configuration: DataTypes.ReserveConfigurationMapStruct, + overrides?: Overrides & { from?: string } + ): Promise; + + setReserveInterestRateStrategyAddress( + asset: string, + rateStrategyAddress: string, + overrides?: Overrides & { from?: string } + ): Promise; + + setUserEMode(categoryId: BigNumberish, overrides?: Overrides & { from?: string }): Promise; + + setUserUseReserveAsCollateral( + asset: string, + useAsCollateral: boolean, + overrides?: Overrides & { from?: string } + ): Promise; + + supply( + asset: string, + amount: BigNumberish, + onBehalfOf: string, + referralCode: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + supplyWithPermit( + asset: string, + amount: BigNumberish, + onBehalfOf: string, + referralCode: BigNumberish, + deadline: BigNumberish, + permitV: BigNumberish, + permitR: BytesLike, + permitS: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + swapBorrowRateMode( + asset: string, + interestRateMode: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + updateBridgeProtocolFee(protocolFee: BigNumberish, overrides?: Overrides & { from?: string }): Promise; + + updateFlashloanPremiums( + flashLoanPremiumTotal: BigNumberish, + flashLoanPremiumToProtocol: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + withdraw( + asset: string, + amount: BigNumberish, + to: string, + overrides?: Overrides & { from?: string } + ): Promise; + }; + + populateTransaction: { + ADDRESSES_PROVIDER(overrides?: CallOverrides): Promise; + + BRIDGE_PROTOCOL_FEE(overrides?: CallOverrides): Promise; + + FLASHLOAN_PREMIUM_TOTAL(overrides?: CallOverrides): Promise; + + FLASHLOAN_PREMIUM_TO_PROTOCOL(overrides?: CallOverrides): Promise; + + MAX_NUMBER_RESERVES(overrides?: CallOverrides): Promise; + + MAX_STABLE_RATE_BORROW_SIZE_PERCENT(overrides?: CallOverrides): Promise; + + POOL_REVISION(overrides?: CallOverrides): Promise; + + backUnbacked( + asset: string, + amount: BigNumberish, + fee: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + borrow( + asset: string, + amount: BigNumberish, + interestRateMode: BigNumberish, + referralCode: BigNumberish, + onBehalfOf: string, + overrides?: Overrides & { from?: string } + ): Promise; + + configureEModeCategory( + id: BigNumberish, + category: DataTypes.EModeCategoryStruct, + overrides?: Overrides & { from?: string } + ): Promise; + + deposit( + asset: string, + amount: BigNumberish, + onBehalfOf: string, + referralCode: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + dropReserve(asset: string, overrides?: Overrides & { from?: string }): Promise; + + finalizeTransfer( + asset: string, + from: string, + to: string, + amount: BigNumberish, + balanceFromBefore: BigNumberish, + balanceToBefore: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + flashLoan( + receiverAddress: string, + assets: string[], + amounts: BigNumberish[], + interestRateModes: BigNumberish[], + onBehalfOf: string, + params: BytesLike, + referralCode: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + flashLoanSimple( + receiverAddress: string, + asset: string, + amount: BigNumberish, + params: BytesLike, + referralCode: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + getConfiguration(asset: string, overrides?: CallOverrides): Promise; + + getEModeCategoryData(id: BigNumberish, overrides?: CallOverrides): Promise; + + getReserveAddressById(id: BigNumberish, overrides?: CallOverrides): Promise; + + getReserveData(asset: string, overrides?: CallOverrides): Promise; + + getReserveNormalizedIncome(asset: string, overrides?: CallOverrides): Promise; + + getReserveNormalizedVariableDebt(asset: string, overrides?: CallOverrides): Promise; + + getReservesList(overrides?: CallOverrides): Promise; + + getUserAccountData(user: string, overrides?: CallOverrides): Promise; + + getUserConfiguration(user: string, overrides?: CallOverrides): Promise; + + getUserEMode(user: string, overrides?: CallOverrides): Promise; + + initReserve( + asset: string, + aTokenAddress: string, + stableDebtAddress: string, + variableDebtAddress: string, + interestRateStrategyAddress: string, + overrides?: Overrides & { from?: string } + ): Promise; + + initialize(provider: string, overrides?: Overrides & { from?: string }): Promise; + + liquidationCall( + collateralAsset: string, + debtAsset: string, + user: string, + debtToCover: BigNumberish, + receiveAToken: boolean, + overrides?: Overrides & { from?: string } + ): Promise; + + mintToTreasury(assets: string[], overrides?: Overrides & { from?: string }): Promise; + + mintUnbacked( + asset: string, + amount: BigNumberish, + onBehalfOf: string, + referralCode: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + rebalanceStableBorrowRate( + asset: string, + user: string, + overrides?: Overrides & { from?: string } + ): Promise; + + repay( + asset: string, + amount: BigNumberish, + interestRateMode: BigNumberish, + onBehalfOf: string, + overrides?: Overrides & { from?: string } + ): Promise; + + repayWithATokens( + asset: string, + amount: BigNumberish, + interestRateMode: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + repayWithPermit( + asset: string, + amount: BigNumberish, + interestRateMode: BigNumberish, + onBehalfOf: string, + deadline: BigNumberish, + permitV: BigNumberish, + permitR: BytesLike, + permitS: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + rescueTokens( + token: string, + to: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + resetIsolationModeTotalDebt( + asset: string, + overrides?: Overrides & { from?: string } + ): Promise; + + setConfiguration( + asset: string, + configuration: DataTypes.ReserveConfigurationMapStruct, + overrides?: Overrides & { from?: string } + ): Promise; + + setReserveInterestRateStrategyAddress( + asset: string, + rateStrategyAddress: string, + overrides?: Overrides & { from?: string } + ): Promise; + + setUserEMode(categoryId: BigNumberish, overrides?: Overrides & { from?: string }): Promise; + + setUserUseReserveAsCollateral( + asset: string, + useAsCollateral: boolean, + overrides?: Overrides & { from?: string } + ): Promise; + + supply( + asset: string, + amount: BigNumberish, + onBehalfOf: string, + referralCode: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + supplyWithPermit( + asset: string, + amount: BigNumberish, + onBehalfOf: string, + referralCode: BigNumberish, + deadline: BigNumberish, + permitV: BigNumberish, + permitR: BytesLike, + permitS: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + swapBorrowRateMode( + asset: string, + interestRateMode: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + updateBridgeProtocolFee( + protocolFee: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + updateFlashloanPremiums( + flashLoanPremiumTotal: BigNumberish, + flashLoanPremiumToProtocol: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + withdraw( + asset: string, + amount: BigNumberish, + to: string, + overrides?: Overrides & { from?: string } + ): Promise; + }; +} diff --git a/src/modules/aavev3/contracts/PoolAddressesProvider.ts b/src/modules/aavev3/contracts/PoolAddressesProvider.ts new file mode 100644 index 00000000..6a3dd2cf --- /dev/null +++ b/src/modules/aavev3/contracts/PoolAddressesProvider.ts @@ -0,0 +1,579 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + BaseContract, + BigNumber, + BytesLike, + CallOverrides, + ContractTransaction, + Overrides, + PopulatedTransaction, + Signer, + utils, +} from 'ethers'; +import type { FunctionFragment, Result, EventFragment } from '@ethersproject/abi'; +import type { Listener, Provider } from '@ethersproject/providers'; +import type { TypedEventFilter, TypedEvent, TypedListener, OnEvent } from './common'; + +export interface PoolAddressesProviderInterface extends utils.Interface { + functions: { + 'getACLAdmin()': FunctionFragment; + 'getACLManager()': FunctionFragment; + 'getAddress(bytes32)': FunctionFragment; + 'getMarketId()': FunctionFragment; + 'getPool()': FunctionFragment; + 'getPoolConfigurator()': FunctionFragment; + 'getPoolDataProvider()': FunctionFragment; + 'getPriceOracle()': FunctionFragment; + 'getPriceOracleSentinel()': FunctionFragment; + 'setACLAdmin(address)': FunctionFragment; + 'setACLManager(address)': FunctionFragment; + 'setAddress(bytes32,address)': FunctionFragment; + 'setAddressAsProxy(bytes32,address)': FunctionFragment; + 'setMarketId(string)': FunctionFragment; + 'setPoolConfiguratorImpl(address)': FunctionFragment; + 'setPoolDataProvider(address)': FunctionFragment; + 'setPoolImpl(address)': FunctionFragment; + 'setPriceOracle(address)': FunctionFragment; + 'setPriceOracleSentinel(address)': FunctionFragment; + }; + + getFunction( + nameOrSignatureOrTopic: + | 'getACLAdmin' + | 'getACLManager' + | 'getAddress' + | 'getMarketId' + | 'getPool' + | 'getPoolConfigurator' + | 'getPoolDataProvider' + | 'getPriceOracle' + | 'getPriceOracleSentinel' + | 'setACLAdmin' + | 'setACLManager' + | 'setAddress' + | 'setAddressAsProxy' + | 'setMarketId' + | 'setPoolConfiguratorImpl' + | 'setPoolDataProvider' + | 'setPoolImpl' + | 'setPriceOracle' + | 'setPriceOracleSentinel' + ): FunctionFragment; + + encodeFunctionData(functionFragment: 'getACLAdmin', values?: undefined): string; + encodeFunctionData(functionFragment: 'getACLManager', values?: undefined): string; + encodeFunctionData(functionFragment: 'getAddress', values: [BytesLike]): string; + encodeFunctionData(functionFragment: 'getMarketId', values?: undefined): string; + encodeFunctionData(functionFragment: 'getPool', values?: undefined): string; + encodeFunctionData(functionFragment: 'getPoolConfigurator', values?: undefined): string; + encodeFunctionData(functionFragment: 'getPoolDataProvider', values?: undefined): string; + encodeFunctionData(functionFragment: 'getPriceOracle', values?: undefined): string; + encodeFunctionData(functionFragment: 'getPriceOracleSentinel', values?: undefined): string; + encodeFunctionData(functionFragment: 'setACLAdmin', values: [string]): string; + encodeFunctionData(functionFragment: 'setACLManager', values: [string]): string; + encodeFunctionData(functionFragment: 'setAddress', values: [BytesLike, string]): string; + encodeFunctionData(functionFragment: 'setAddressAsProxy', values: [BytesLike, string]): string; + encodeFunctionData(functionFragment: 'setMarketId', values: [string]): string; + encodeFunctionData(functionFragment: 'setPoolConfiguratorImpl', values: [string]): string; + encodeFunctionData(functionFragment: 'setPoolDataProvider', values: [string]): string; + encodeFunctionData(functionFragment: 'setPoolImpl', values: [string]): string; + encodeFunctionData(functionFragment: 'setPriceOracle', values: [string]): string; + encodeFunctionData(functionFragment: 'setPriceOracleSentinel', values: [string]): string; + + decodeFunctionResult(functionFragment: 'getACLAdmin', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getACLManager', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getAddress', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getMarketId', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getPool', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getPoolConfigurator', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getPoolDataProvider', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getPriceOracle', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getPriceOracleSentinel', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'setACLAdmin', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'setACLManager', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'setAddress', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'setAddressAsProxy', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'setMarketId', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'setPoolConfiguratorImpl', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'setPoolDataProvider', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'setPoolImpl', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'setPriceOracle', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'setPriceOracleSentinel', data: BytesLike): Result; + + events: { + 'ACLAdminUpdated(address,address)': EventFragment; + 'ACLManagerUpdated(address,address)': EventFragment; + 'AddressSet(bytes32,address,address)': EventFragment; + 'AddressSetAsProxy(bytes32,address,address,address)': EventFragment; + 'MarketIdSet(string,string)': EventFragment; + 'PoolConfiguratorUpdated(address,address)': EventFragment; + 'PoolDataProviderUpdated(address,address)': EventFragment; + 'PoolUpdated(address,address)': EventFragment; + 'PriceOracleSentinelUpdated(address,address)': EventFragment; + 'PriceOracleUpdated(address,address)': EventFragment; + 'ProxyCreated(bytes32,address,address)': EventFragment; + }; + + getEvent(nameOrSignatureOrTopic: 'ACLAdminUpdated'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'ACLManagerUpdated'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'AddressSet'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'AddressSetAsProxy'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'MarketIdSet'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'PoolConfiguratorUpdated'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'PoolDataProviderUpdated'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'PoolUpdated'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'PriceOracleSentinelUpdated'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'PriceOracleUpdated'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'ProxyCreated'): EventFragment; +} + +export interface ACLAdminUpdatedEventObject { + oldAddress: string; + newAddress: string; +} +export type ACLAdminUpdatedEvent = TypedEvent<[string, string], ACLAdminUpdatedEventObject>; + +export type ACLAdminUpdatedEventFilter = TypedEventFilter; + +export interface ACLManagerUpdatedEventObject { + oldAddress: string; + newAddress: string; +} +export type ACLManagerUpdatedEvent = TypedEvent<[string, string], ACLManagerUpdatedEventObject>; + +export type ACLManagerUpdatedEventFilter = TypedEventFilter; + +export interface AddressSetEventObject { + id: string; + oldAddress: string; + newAddress: string; +} +export type AddressSetEvent = TypedEvent<[string, string, string], AddressSetEventObject>; + +export type AddressSetEventFilter = TypedEventFilter; + +export interface AddressSetAsProxyEventObject { + id: string; + proxyAddress: string; + oldImplementationAddress: string; + newImplementationAddress: string; +} +export type AddressSetAsProxyEvent = TypedEvent<[string, string, string, string], AddressSetAsProxyEventObject>; + +export type AddressSetAsProxyEventFilter = TypedEventFilter; + +export interface MarketIdSetEventObject { + oldMarketId: string; + newMarketId: string; +} +export type MarketIdSetEvent = TypedEvent<[string, string], MarketIdSetEventObject>; + +export type MarketIdSetEventFilter = TypedEventFilter; + +export interface PoolConfiguratorUpdatedEventObject { + oldAddress: string; + newAddress: string; +} +export type PoolConfiguratorUpdatedEvent = TypedEvent<[string, string], PoolConfiguratorUpdatedEventObject>; + +export type PoolConfiguratorUpdatedEventFilter = TypedEventFilter; + +export interface PoolDataProviderUpdatedEventObject { + oldAddress: string; + newAddress: string; +} +export type PoolDataProviderUpdatedEvent = TypedEvent<[string, string], PoolDataProviderUpdatedEventObject>; + +export type PoolDataProviderUpdatedEventFilter = TypedEventFilter; + +export interface PoolUpdatedEventObject { + oldAddress: string; + newAddress: string; +} +export type PoolUpdatedEvent = TypedEvent<[string, string], PoolUpdatedEventObject>; + +export type PoolUpdatedEventFilter = TypedEventFilter; + +export interface PriceOracleSentinelUpdatedEventObject { + oldAddress: string; + newAddress: string; +} +export type PriceOracleSentinelUpdatedEvent = TypedEvent<[string, string], PriceOracleSentinelUpdatedEventObject>; + +export type PriceOracleSentinelUpdatedEventFilter = TypedEventFilter; + +export interface PriceOracleUpdatedEventObject { + oldAddress: string; + newAddress: string; +} +export type PriceOracleUpdatedEvent = TypedEvent<[string, string], PriceOracleUpdatedEventObject>; + +export type PriceOracleUpdatedEventFilter = TypedEventFilter; + +export interface ProxyCreatedEventObject { + id: string; + proxyAddress: string; + implementationAddress: string; +} +export type ProxyCreatedEvent = TypedEvent<[string, string, string], ProxyCreatedEventObject>; + +export type ProxyCreatedEventFilter = TypedEventFilter; + +export interface PoolAddressesProvider extends BaseContract { + connect(signerOrProvider: Signer | Provider | string): this; + attach(addressOrName: string): this; + deployed(): Promise; + + interface: PoolAddressesProviderInterface; + + queryFilter( + event: TypedEventFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>; + + listeners(eventFilter?: TypedEventFilter): Array>; + listeners(eventName?: string): Array; + removeAllListeners(eventFilter: TypedEventFilter): this; + removeAllListeners(eventName?: string): this; + off: OnEvent; + on: OnEvent; + once: OnEvent; + removeListener: OnEvent; + + functions: { + getACLAdmin(overrides?: CallOverrides): Promise<[string]>; + + getACLManager(overrides?: CallOverrides): Promise<[string]>; + + getAddress(id: BytesLike, overrides?: CallOverrides): Promise<[string]>; + + getMarketId(overrides?: CallOverrides): Promise<[string]>; + + getPool(overrides?: CallOverrides): Promise<[string]>; + + getPoolConfigurator(overrides?: CallOverrides): Promise<[string]>; + + getPoolDataProvider(overrides?: CallOverrides): Promise<[string]>; + + getPriceOracle(overrides?: CallOverrides): Promise<[string]>; + + getPriceOracleSentinel(overrides?: CallOverrides): Promise<[string]>; + + setACLAdmin(newAclAdmin: string, overrides?: Overrides & { from?: string }): Promise; + + setACLManager(newAclManager: string, overrides?: Overrides & { from?: string }): Promise; + + setAddress( + id: BytesLike, + newAddress: string, + overrides?: Overrides & { from?: string } + ): Promise; + + setAddressAsProxy( + id: BytesLike, + newImplementationAddress: string, + overrides?: Overrides & { from?: string } + ): Promise; + + setMarketId(newMarketId: string, overrides?: Overrides & { from?: string }): Promise; + + setPoolConfiguratorImpl( + newPoolConfiguratorImpl: string, + overrides?: Overrides & { from?: string } + ): Promise; + + setPoolDataProvider( + newDataProvider: string, + overrides?: Overrides & { from?: string } + ): Promise; + + setPoolImpl(newPoolImpl: string, overrides?: Overrides & { from?: string }): Promise; + + setPriceOracle(newPriceOracle: string, overrides?: Overrides & { from?: string }): Promise; + + setPriceOracleSentinel( + newPriceOracleSentinel: string, + overrides?: Overrides & { from?: string } + ): Promise; + }; + + getACLAdmin(overrides?: CallOverrides): Promise; + + getACLManager(overrides?: CallOverrides): Promise; + + getAddress(id: BytesLike, overrides?: CallOverrides): Promise; + + getMarketId(overrides?: CallOverrides): Promise; + + getPool(overrides?: CallOverrides): Promise; + + getPoolConfigurator(overrides?: CallOverrides): Promise; + + getPoolDataProvider(overrides?: CallOverrides): Promise; + + getPriceOracle(overrides?: CallOverrides): Promise; + + getPriceOracleSentinel(overrides?: CallOverrides): Promise; + + setACLAdmin(newAclAdmin: string, overrides?: Overrides & { from?: string }): Promise; + + setACLManager(newAclManager: string, overrides?: Overrides & { from?: string }): Promise; + + setAddress( + id: BytesLike, + newAddress: string, + overrides?: Overrides & { from?: string } + ): Promise; + + setAddressAsProxy( + id: BytesLike, + newImplementationAddress: string, + overrides?: Overrides & { from?: string } + ): Promise; + + setMarketId(newMarketId: string, overrides?: Overrides & { from?: string }): Promise; + + setPoolConfiguratorImpl( + newPoolConfiguratorImpl: string, + overrides?: Overrides & { from?: string } + ): Promise; + + setPoolDataProvider(newDataProvider: string, overrides?: Overrides & { from?: string }): Promise; + + setPoolImpl(newPoolImpl: string, overrides?: Overrides & { from?: string }): Promise; + + setPriceOracle(newPriceOracle: string, overrides?: Overrides & { from?: string }): Promise; + + setPriceOracleSentinel( + newPriceOracleSentinel: string, + overrides?: Overrides & { from?: string } + ): Promise; + + callStatic: { + getACLAdmin(overrides?: CallOverrides): Promise; + + getACLManager(overrides?: CallOverrides): Promise; + + getAddress(id: BytesLike, overrides?: CallOverrides): Promise; + + getMarketId(overrides?: CallOverrides): Promise; + + getPool(overrides?: CallOverrides): Promise; + + getPoolConfigurator(overrides?: CallOverrides): Promise; + + getPoolDataProvider(overrides?: CallOverrides): Promise; + + getPriceOracle(overrides?: CallOverrides): Promise; + + getPriceOracleSentinel(overrides?: CallOverrides): Promise; + + setACLAdmin(newAclAdmin: string, overrides?: CallOverrides): Promise; + + setACLManager(newAclManager: string, overrides?: CallOverrides): Promise; + + setAddress(id: BytesLike, newAddress: string, overrides?: CallOverrides): Promise; + + setAddressAsProxy(id: BytesLike, newImplementationAddress: string, overrides?: CallOverrides): Promise; + + setMarketId(newMarketId: string, overrides?: CallOverrides): Promise; + + setPoolConfiguratorImpl(newPoolConfiguratorImpl: string, overrides?: CallOverrides): Promise; + + setPoolDataProvider(newDataProvider: string, overrides?: CallOverrides): Promise; + + setPoolImpl(newPoolImpl: string, overrides?: CallOverrides): Promise; + + setPriceOracle(newPriceOracle: string, overrides?: CallOverrides): Promise; + + setPriceOracleSentinel(newPriceOracleSentinel: string, overrides?: CallOverrides): Promise; + }; + + filters: { + 'ACLAdminUpdated(address,address)'( + oldAddress?: string | null, + newAddress?: string | null + ): ACLAdminUpdatedEventFilter; + ACLAdminUpdated(oldAddress?: string | null, newAddress?: string | null): ACLAdminUpdatedEventFilter; + + 'ACLManagerUpdated(address,address)'( + oldAddress?: string | null, + newAddress?: string | null + ): ACLManagerUpdatedEventFilter; + ACLManagerUpdated(oldAddress?: string | null, newAddress?: string | null): ACLManagerUpdatedEventFilter; + + 'AddressSet(bytes32,address,address)'( + id?: BytesLike | null, + oldAddress?: string | null, + newAddress?: string | null + ): AddressSetEventFilter; + AddressSet(id?: BytesLike | null, oldAddress?: string | null, newAddress?: string | null): AddressSetEventFilter; + + 'AddressSetAsProxy(bytes32,address,address,address)'( + id?: BytesLike | null, + proxyAddress?: string | null, + oldImplementationAddress?: null, + newImplementationAddress?: string | null + ): AddressSetAsProxyEventFilter; + AddressSetAsProxy( + id?: BytesLike | null, + proxyAddress?: string | null, + oldImplementationAddress?: null, + newImplementationAddress?: string | null + ): AddressSetAsProxyEventFilter; + + 'MarketIdSet(string,string)'(oldMarketId?: string | null, newMarketId?: string | null): MarketIdSetEventFilter; + MarketIdSet(oldMarketId?: string | null, newMarketId?: string | null): MarketIdSetEventFilter; + + 'PoolConfiguratorUpdated(address,address)'( + oldAddress?: string | null, + newAddress?: string | null + ): PoolConfiguratorUpdatedEventFilter; + PoolConfiguratorUpdated(oldAddress?: string | null, newAddress?: string | null): PoolConfiguratorUpdatedEventFilter; + + 'PoolDataProviderUpdated(address,address)'( + oldAddress?: string | null, + newAddress?: string | null + ): PoolDataProviderUpdatedEventFilter; + PoolDataProviderUpdated(oldAddress?: string | null, newAddress?: string | null): PoolDataProviderUpdatedEventFilter; + + 'PoolUpdated(address,address)'(oldAddress?: string | null, newAddress?: string | null): PoolUpdatedEventFilter; + PoolUpdated(oldAddress?: string | null, newAddress?: string | null): PoolUpdatedEventFilter; + + 'PriceOracleSentinelUpdated(address,address)'( + oldAddress?: string | null, + newAddress?: string | null + ): PriceOracleSentinelUpdatedEventFilter; + PriceOracleSentinelUpdated( + oldAddress?: string | null, + newAddress?: string | null + ): PriceOracleSentinelUpdatedEventFilter; + + 'PriceOracleUpdated(address,address)'( + oldAddress?: string | null, + newAddress?: string | null + ): PriceOracleUpdatedEventFilter; + PriceOracleUpdated(oldAddress?: string | null, newAddress?: string | null): PriceOracleUpdatedEventFilter; + + 'ProxyCreated(bytes32,address,address)'( + id?: BytesLike | null, + proxyAddress?: string | null, + implementationAddress?: string | null + ): ProxyCreatedEventFilter; + ProxyCreated( + id?: BytesLike | null, + proxyAddress?: string | null, + implementationAddress?: string | null + ): ProxyCreatedEventFilter; + }; + + estimateGas: { + getACLAdmin(overrides?: CallOverrides): Promise; + + getACLManager(overrides?: CallOverrides): Promise; + + getAddress(id: BytesLike, overrides?: CallOverrides): Promise; + + getMarketId(overrides?: CallOverrides): Promise; + + getPool(overrides?: CallOverrides): Promise; + + getPoolConfigurator(overrides?: CallOverrides): Promise; + + getPoolDataProvider(overrides?: CallOverrides): Promise; + + getPriceOracle(overrides?: CallOverrides): Promise; + + getPriceOracleSentinel(overrides?: CallOverrides): Promise; + + setACLAdmin(newAclAdmin: string, overrides?: Overrides & { from?: string }): Promise; + + setACLManager(newAclManager: string, overrides?: Overrides & { from?: string }): Promise; + + setAddress(id: BytesLike, newAddress: string, overrides?: Overrides & { from?: string }): Promise; + + setAddressAsProxy( + id: BytesLike, + newImplementationAddress: string, + overrides?: Overrides & { from?: string } + ): Promise; + + setMarketId(newMarketId: string, overrides?: Overrides & { from?: string }): Promise; + + setPoolConfiguratorImpl( + newPoolConfiguratorImpl: string, + overrides?: Overrides & { from?: string } + ): Promise; + + setPoolDataProvider(newDataProvider: string, overrides?: Overrides & { from?: string }): Promise; + + setPoolImpl(newPoolImpl: string, overrides?: Overrides & { from?: string }): Promise; + + setPriceOracle(newPriceOracle: string, overrides?: Overrides & { from?: string }): Promise; + + setPriceOracleSentinel( + newPriceOracleSentinel: string, + overrides?: Overrides & { from?: string } + ): Promise; + }; + + populateTransaction: { + getACLAdmin(overrides?: CallOverrides): Promise; + + getACLManager(overrides?: CallOverrides): Promise; + + getAddress(id: BytesLike, overrides?: CallOverrides): Promise; + + getMarketId(overrides?: CallOverrides): Promise; + + getPool(overrides?: CallOverrides): Promise; + + getPoolConfigurator(overrides?: CallOverrides): Promise; + + getPoolDataProvider(overrides?: CallOverrides): Promise; + + getPriceOracle(overrides?: CallOverrides): Promise; + + getPriceOracleSentinel(overrides?: CallOverrides): Promise; + + setACLAdmin(newAclAdmin: string, overrides?: Overrides & { from?: string }): Promise; + + setACLManager(newAclManager: string, overrides?: Overrides & { from?: string }): Promise; + + setAddress( + id: BytesLike, + newAddress: string, + overrides?: Overrides & { from?: string } + ): Promise; + + setAddressAsProxy( + id: BytesLike, + newImplementationAddress: string, + overrides?: Overrides & { from?: string } + ): Promise; + + setMarketId(newMarketId: string, overrides?: Overrides & { from?: string }): Promise; + + setPoolConfiguratorImpl( + newPoolConfiguratorImpl: string, + overrides?: Overrides & { from?: string } + ): Promise; + + setPoolDataProvider( + newDataProvider: string, + overrides?: Overrides & { from?: string } + ): Promise; + + setPoolImpl(newPoolImpl: string, overrides?: Overrides & { from?: string }): Promise; + + setPriceOracle(newPriceOracle: string, overrides?: Overrides & { from?: string }): Promise; + + setPriceOracleSentinel( + newPriceOracleSentinel: string, + overrides?: Overrides & { from?: string } + ): Promise; + }; +} diff --git a/src/modules/aavev3/contracts/PoolDataProvider.ts b/src/modules/aavev3/contracts/PoolDataProvider.ts new file mode 100644 index 00000000..1cd9dafa --- /dev/null +++ b/src/modules/aavev3/contracts/PoolDataProvider.ts @@ -0,0 +1,556 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { BaseContract, BigNumber, BytesLike, CallOverrides, PopulatedTransaction, Signer, utils } from 'ethers'; +import type { FunctionFragment, Result } from '@ethersproject/abi'; +import type { Listener, Provider } from '@ethersproject/providers'; +import type { TypedEventFilter, TypedEvent, TypedListener, OnEvent } from './common'; + +export declare namespace IPoolDataProvider { + export type TokenDataStruct = { symbol: string; tokenAddress: string }; + + export type TokenDataStructOutput = [string, string] & { + symbol: string; + tokenAddress: string; + }; +} + +export interface PoolDataProviderInterface extends utils.Interface { + functions: { + 'ADDRESSES_PROVIDER()': FunctionFragment; + 'getATokenTotalSupply(address)': FunctionFragment; + 'getAllATokens()': FunctionFragment; + 'getAllReservesTokens()': FunctionFragment; + 'getDebtCeiling(address)': FunctionFragment; + 'getDebtCeilingDecimals()': FunctionFragment; + 'getFlashLoanEnabled(address)': FunctionFragment; + 'getInterestRateStrategyAddress(address)': FunctionFragment; + 'getLiquidationProtocolFee(address)': FunctionFragment; + 'getPaused(address)': FunctionFragment; + 'getReserveCaps(address)': FunctionFragment; + 'getReserveConfigurationData(address)': FunctionFragment; + 'getReserveData(address)': FunctionFragment; + 'getReserveEModeCategory(address)': FunctionFragment; + 'getReserveTokensAddresses(address)': FunctionFragment; + 'getSiloedBorrowing(address)': FunctionFragment; + 'getTotalDebt(address)': FunctionFragment; + 'getUnbackedMintCap(address)': FunctionFragment; + 'getUserReserveData(address,address)': FunctionFragment; + }; + + getFunction( + nameOrSignatureOrTopic: + | 'ADDRESSES_PROVIDER' + | 'getATokenTotalSupply' + | 'getAllATokens' + | 'getAllReservesTokens' + | 'getDebtCeiling' + | 'getDebtCeilingDecimals' + | 'getFlashLoanEnabled' + | 'getInterestRateStrategyAddress' + | 'getLiquidationProtocolFee' + | 'getPaused' + | 'getReserveCaps' + | 'getReserveConfigurationData' + | 'getReserveData' + | 'getReserveEModeCategory' + | 'getReserveTokensAddresses' + | 'getSiloedBorrowing' + | 'getTotalDebt' + | 'getUnbackedMintCap' + | 'getUserReserveData' + ): FunctionFragment; + + encodeFunctionData(functionFragment: 'ADDRESSES_PROVIDER', values?: undefined): string; + encodeFunctionData(functionFragment: 'getATokenTotalSupply', values: [string]): string; + encodeFunctionData(functionFragment: 'getAllATokens', values?: undefined): string; + encodeFunctionData(functionFragment: 'getAllReservesTokens', values?: undefined): string; + encodeFunctionData(functionFragment: 'getDebtCeiling', values: [string]): string; + encodeFunctionData(functionFragment: 'getDebtCeilingDecimals', values?: undefined): string; + encodeFunctionData(functionFragment: 'getFlashLoanEnabled', values: [string]): string; + encodeFunctionData(functionFragment: 'getInterestRateStrategyAddress', values: [string]): string; + encodeFunctionData(functionFragment: 'getLiquidationProtocolFee', values: [string]): string; + encodeFunctionData(functionFragment: 'getPaused', values: [string]): string; + encodeFunctionData(functionFragment: 'getReserveCaps', values: [string]): string; + encodeFunctionData(functionFragment: 'getReserveConfigurationData', values: [string]): string; + encodeFunctionData(functionFragment: 'getReserveData', values: [string]): string; + encodeFunctionData(functionFragment: 'getReserveEModeCategory', values: [string]): string; + encodeFunctionData(functionFragment: 'getReserveTokensAddresses', values: [string]): string; + encodeFunctionData(functionFragment: 'getSiloedBorrowing', values: [string]): string; + encodeFunctionData(functionFragment: 'getTotalDebt', values: [string]): string; + encodeFunctionData(functionFragment: 'getUnbackedMintCap', values: [string]): string; + encodeFunctionData(functionFragment: 'getUserReserveData', values: [string, string]): string; + + decodeFunctionResult(functionFragment: 'ADDRESSES_PROVIDER', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getATokenTotalSupply', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getAllATokens', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getAllReservesTokens', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getDebtCeiling', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getDebtCeilingDecimals', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getFlashLoanEnabled', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getInterestRateStrategyAddress', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getLiquidationProtocolFee', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getPaused', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getReserveCaps', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getReserveConfigurationData', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getReserveData', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getReserveEModeCategory', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getReserveTokensAddresses', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getSiloedBorrowing', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getTotalDebt', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getUnbackedMintCap', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getUserReserveData', data: BytesLike): Result; + + events: {}; +} + +export interface PoolDataProvider extends BaseContract { + connect(signerOrProvider: Signer | Provider | string): this; + attach(addressOrName: string): this; + deployed(): Promise; + + interface: PoolDataProviderInterface; + + queryFilter( + event: TypedEventFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>; + + listeners(eventFilter?: TypedEventFilter): Array>; + listeners(eventName?: string): Array; + removeAllListeners(eventFilter: TypedEventFilter): this; + removeAllListeners(eventName?: string): this; + off: OnEvent; + on: OnEvent; + once: OnEvent; + removeListener: OnEvent; + + functions: { + ADDRESSES_PROVIDER(overrides?: CallOverrides): Promise<[string]>; + + getATokenTotalSupply(asset: string, overrides?: CallOverrides): Promise<[BigNumber]>; + + getAllATokens(overrides?: CallOverrides): Promise<[IPoolDataProvider.TokenDataStructOutput[]]>; + + getAllReservesTokens(overrides?: CallOverrides): Promise<[IPoolDataProvider.TokenDataStructOutput[]]>; + + getDebtCeiling(asset: string, overrides?: CallOverrides): Promise<[BigNumber]>; + + getDebtCeilingDecimals(overrides?: CallOverrides): Promise<[BigNumber]>; + + getFlashLoanEnabled(asset: string, overrides?: CallOverrides): Promise<[boolean]>; + + getInterestRateStrategyAddress( + asset: string, + overrides?: CallOverrides + ): Promise<[string] & { irStrategyAddress: string }>; + + getLiquidationProtocolFee(asset: string, overrides?: CallOverrides): Promise<[BigNumber]>; + + getPaused(asset: string, overrides?: CallOverrides): Promise<[boolean] & { isPaused: boolean }>; + + getReserveCaps( + asset: string, + overrides?: CallOverrides + ): Promise<[BigNumber, BigNumber] & { borrowCap: BigNumber; supplyCap: BigNumber }>; + + getReserveConfigurationData( + asset: string, + overrides?: CallOverrides + ): Promise< + [BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, boolean, boolean, boolean, boolean, boolean] & { + decimals: BigNumber; + ltv: BigNumber; + liquidationThreshold: BigNumber; + liquidationBonus: BigNumber; + reserveFactor: BigNumber; + usageAsCollateralEnabled: boolean; + borrowingEnabled: boolean; + stableBorrowRateEnabled: boolean; + isActive: boolean; + isFrozen: boolean; + } + >; + + getReserveData( + asset: string, + overrides?: CallOverrides + ): Promise< + [ + BigNumber, + BigNumber, + BigNumber, + BigNumber, + BigNumber, + BigNumber, + BigNumber, + BigNumber, + BigNumber, + BigNumber, + BigNumber, + number + ] & { + unbacked: BigNumber; + accruedToTreasuryScaled: BigNumber; + totalAToken: BigNumber; + totalStableDebt: BigNumber; + totalVariableDebt: BigNumber; + liquidityRate: BigNumber; + variableBorrowRate: BigNumber; + stableBorrowRate: BigNumber; + averageStableBorrowRate: BigNumber; + liquidityIndex: BigNumber; + variableBorrowIndex: BigNumber; + lastUpdateTimestamp: number; + } + >; + + getReserveEModeCategory(asset: string, overrides?: CallOverrides): Promise<[BigNumber]>; + + getReserveTokensAddresses( + asset: string, + overrides?: CallOverrides + ): Promise< + [string, string, string] & { + aTokenAddress: string; + stableDebtTokenAddress: string; + variableDebtTokenAddress: string; + } + >; + + getSiloedBorrowing(asset: string, overrides?: CallOverrides): Promise<[boolean]>; + + getTotalDebt(asset: string, overrides?: CallOverrides): Promise<[BigNumber]>; + + getUnbackedMintCap(asset: string, overrides?: CallOverrides): Promise<[BigNumber]>; + + getUserReserveData( + asset: string, + user: string, + overrides?: CallOverrides + ): Promise< + [BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, number, boolean] & { + currentATokenBalance: BigNumber; + currentStableDebt: BigNumber; + currentVariableDebt: BigNumber; + principalStableDebt: BigNumber; + scaledVariableDebt: BigNumber; + stableBorrowRate: BigNumber; + liquidityRate: BigNumber; + stableRateLastUpdated: number; + usageAsCollateralEnabled: boolean; + } + >; + }; + + ADDRESSES_PROVIDER(overrides?: CallOverrides): Promise; + + getATokenTotalSupply(asset: string, overrides?: CallOverrides): Promise; + + getAllATokens(overrides?: CallOverrides): Promise; + + getAllReservesTokens(overrides?: CallOverrides): Promise; + + getDebtCeiling(asset: string, overrides?: CallOverrides): Promise; + + getDebtCeilingDecimals(overrides?: CallOverrides): Promise; + + getFlashLoanEnabled(asset: string, overrides?: CallOverrides): Promise; + + getInterestRateStrategyAddress(asset: string, overrides?: CallOverrides): Promise; + + getLiquidationProtocolFee(asset: string, overrides?: CallOverrides): Promise; + + getPaused(asset: string, overrides?: CallOverrides): Promise; + + getReserveCaps( + asset: string, + overrides?: CallOverrides + ): Promise<[BigNumber, BigNumber] & { borrowCap: BigNumber; supplyCap: BigNumber }>; + + getReserveConfigurationData( + asset: string, + overrides?: CallOverrides + ): Promise< + [BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, boolean, boolean, boolean, boolean, boolean] & { + decimals: BigNumber; + ltv: BigNumber; + liquidationThreshold: BigNumber; + liquidationBonus: BigNumber; + reserveFactor: BigNumber; + usageAsCollateralEnabled: boolean; + borrowingEnabled: boolean; + stableBorrowRateEnabled: boolean; + isActive: boolean; + isFrozen: boolean; + } + >; + + getReserveData( + asset: string, + overrides?: CallOverrides + ): Promise< + [ + BigNumber, + BigNumber, + BigNumber, + BigNumber, + BigNumber, + BigNumber, + BigNumber, + BigNumber, + BigNumber, + BigNumber, + BigNumber, + number + ] & { + unbacked: BigNumber; + accruedToTreasuryScaled: BigNumber; + totalAToken: BigNumber; + totalStableDebt: BigNumber; + totalVariableDebt: BigNumber; + liquidityRate: BigNumber; + variableBorrowRate: BigNumber; + stableBorrowRate: BigNumber; + averageStableBorrowRate: BigNumber; + liquidityIndex: BigNumber; + variableBorrowIndex: BigNumber; + lastUpdateTimestamp: number; + } + >; + + getReserveEModeCategory(asset: string, overrides?: CallOverrides): Promise; + + getReserveTokensAddresses( + asset: string, + overrides?: CallOverrides + ): Promise< + [string, string, string] & { + aTokenAddress: string; + stableDebtTokenAddress: string; + variableDebtTokenAddress: string; + } + >; + + getSiloedBorrowing(asset: string, overrides?: CallOverrides): Promise; + + getTotalDebt(asset: string, overrides?: CallOverrides): Promise; + + getUnbackedMintCap(asset: string, overrides?: CallOverrides): Promise; + + getUserReserveData( + asset: string, + user: string, + overrides?: CallOverrides + ): Promise< + [BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, number, boolean] & { + currentATokenBalance: BigNumber; + currentStableDebt: BigNumber; + currentVariableDebt: BigNumber; + principalStableDebt: BigNumber; + scaledVariableDebt: BigNumber; + stableBorrowRate: BigNumber; + liquidityRate: BigNumber; + stableRateLastUpdated: number; + usageAsCollateralEnabled: boolean; + } + >; + + callStatic: { + ADDRESSES_PROVIDER(overrides?: CallOverrides): Promise; + + getATokenTotalSupply(asset: string, overrides?: CallOverrides): Promise; + + getAllATokens(overrides?: CallOverrides): Promise; + + getAllReservesTokens(overrides?: CallOverrides): Promise; + + getDebtCeiling(asset: string, overrides?: CallOverrides): Promise; + + getDebtCeilingDecimals(overrides?: CallOverrides): Promise; + + getFlashLoanEnabled(asset: string, overrides?: CallOverrides): Promise; + + getInterestRateStrategyAddress(asset: string, overrides?: CallOverrides): Promise; + + getLiquidationProtocolFee(asset: string, overrides?: CallOverrides): Promise; + + getPaused(asset: string, overrides?: CallOverrides): Promise; + + getReserveCaps( + asset: string, + overrides?: CallOverrides + ): Promise<[BigNumber, BigNumber] & { borrowCap: BigNumber; supplyCap: BigNumber }>; + + getReserveConfigurationData( + asset: string, + overrides?: CallOverrides + ): Promise< + [BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, boolean, boolean, boolean, boolean, boolean] & { + decimals: BigNumber; + ltv: BigNumber; + liquidationThreshold: BigNumber; + liquidationBonus: BigNumber; + reserveFactor: BigNumber; + usageAsCollateralEnabled: boolean; + borrowingEnabled: boolean; + stableBorrowRateEnabled: boolean; + isActive: boolean; + isFrozen: boolean; + } + >; + + getReserveData( + asset: string, + overrides?: CallOverrides + ): Promise< + [ + BigNumber, + BigNumber, + BigNumber, + BigNumber, + BigNumber, + BigNumber, + BigNumber, + BigNumber, + BigNumber, + BigNumber, + BigNumber, + number + ] & { + unbacked: BigNumber; + accruedToTreasuryScaled: BigNumber; + totalAToken: BigNumber; + totalStableDebt: BigNumber; + totalVariableDebt: BigNumber; + liquidityRate: BigNumber; + variableBorrowRate: BigNumber; + stableBorrowRate: BigNumber; + averageStableBorrowRate: BigNumber; + liquidityIndex: BigNumber; + variableBorrowIndex: BigNumber; + lastUpdateTimestamp: number; + } + >; + + getReserveEModeCategory(asset: string, overrides?: CallOverrides): Promise; + + getReserveTokensAddresses( + asset: string, + overrides?: CallOverrides + ): Promise< + [string, string, string] & { + aTokenAddress: string; + stableDebtTokenAddress: string; + variableDebtTokenAddress: string; + } + >; + + getSiloedBorrowing(asset: string, overrides?: CallOverrides): Promise; + + getTotalDebt(asset: string, overrides?: CallOverrides): Promise; + + getUnbackedMintCap(asset: string, overrides?: CallOverrides): Promise; + + getUserReserveData( + asset: string, + user: string, + overrides?: CallOverrides + ): Promise< + [BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, number, boolean] & { + currentATokenBalance: BigNumber; + currentStableDebt: BigNumber; + currentVariableDebt: BigNumber; + principalStableDebt: BigNumber; + scaledVariableDebt: BigNumber; + stableBorrowRate: BigNumber; + liquidityRate: BigNumber; + stableRateLastUpdated: number; + usageAsCollateralEnabled: boolean; + } + >; + }; + + filters: {}; + + estimateGas: { + ADDRESSES_PROVIDER(overrides?: CallOverrides): Promise; + + getATokenTotalSupply(asset: string, overrides?: CallOverrides): Promise; + + getAllATokens(overrides?: CallOverrides): Promise; + + getAllReservesTokens(overrides?: CallOverrides): Promise; + + getDebtCeiling(asset: string, overrides?: CallOverrides): Promise; + + getDebtCeilingDecimals(overrides?: CallOverrides): Promise; + + getFlashLoanEnabled(asset: string, overrides?: CallOverrides): Promise; + + getInterestRateStrategyAddress(asset: string, overrides?: CallOverrides): Promise; + + getLiquidationProtocolFee(asset: string, overrides?: CallOverrides): Promise; + + getPaused(asset: string, overrides?: CallOverrides): Promise; + + getReserveCaps(asset: string, overrides?: CallOverrides): Promise; + + getReserveConfigurationData(asset: string, overrides?: CallOverrides): Promise; + + getReserveData(asset: string, overrides?: CallOverrides): Promise; + + getReserveEModeCategory(asset: string, overrides?: CallOverrides): Promise; + + getReserveTokensAddresses(asset: string, overrides?: CallOverrides): Promise; + + getSiloedBorrowing(asset: string, overrides?: CallOverrides): Promise; + + getTotalDebt(asset: string, overrides?: CallOverrides): Promise; + + getUnbackedMintCap(asset: string, overrides?: CallOverrides): Promise; + + getUserReserveData(asset: string, user: string, overrides?: CallOverrides): Promise; + }; + + populateTransaction: { + ADDRESSES_PROVIDER(overrides?: CallOverrides): Promise; + + getATokenTotalSupply(asset: string, overrides?: CallOverrides): Promise; + + getAllATokens(overrides?: CallOverrides): Promise; + + getAllReservesTokens(overrides?: CallOverrides): Promise; + + getDebtCeiling(asset: string, overrides?: CallOverrides): Promise; + + getDebtCeilingDecimals(overrides?: CallOverrides): Promise; + + getFlashLoanEnabled(asset: string, overrides?: CallOverrides): Promise; + + getInterestRateStrategyAddress(asset: string, overrides?: CallOverrides): Promise; + + getLiquidationProtocolFee(asset: string, overrides?: CallOverrides): Promise; + + getPaused(asset: string, overrides?: CallOverrides): Promise; + + getReserveCaps(asset: string, overrides?: CallOverrides): Promise; + + getReserveConfigurationData(asset: string, overrides?: CallOverrides): Promise; + + getReserveData(asset: string, overrides?: CallOverrides): Promise; + + getReserveEModeCategory(asset: string, overrides?: CallOverrides): Promise; + + getReserveTokensAddresses(asset: string, overrides?: CallOverrides): Promise; + + getSiloedBorrowing(asset: string, overrides?: CallOverrides): Promise; + + getTotalDebt(asset: string, overrides?: CallOverrides): Promise; + + getUnbackedMintCap(asset: string, overrides?: CallOverrides): Promise; + + getUserReserveData(asset: string, user: string, overrides?: CallOverrides): Promise; + }; +} diff --git a/src/modules/aavev3/contracts/common.ts b/src/modules/aavev3/contracts/common.ts new file mode 100644 index 00000000..6cfb1042 --- /dev/null +++ b/src/modules/aavev3/contracts/common.ts @@ -0,0 +1,30 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { Listener } from '@ethersproject/providers'; +import type { Event, EventFilter } from 'ethers'; + +export interface TypedEvent = any, TArgsObject = any> extends Event { + args: TArgsArray & TArgsObject; +} + +export interface TypedEventFilter<_TEvent extends TypedEvent> extends EventFilter {} + +export interface TypedListener { + (...listenerArg: [...__TypechainArgsArray, TEvent]): void; +} + +type __TypechainArgsArray = T extends TypedEvent ? U : never; + +export interface OnEvent { + (eventFilter: TypedEventFilter, listener: TypedListener): TRes; + (eventName: string, listener: Listener): TRes; +} + +export type MinEthersFactory = { + deploy(...a: ARGS[]): Promise; +}; + +export type GetContractTypeFromFactory = F extends MinEthersFactory ? C : never; + +export type GetARGsTypeFromFactory = F extends MinEthersFactory ? Parameters : never; diff --git a/src/modules/aavev3/contracts/factories/AToken__factory.ts b/src/modules/aavev3/contracts/factories/AToken__factory.ts new file mode 100644 index 00000000..c2a5451e --- /dev/null +++ b/src/modules/aavev3/contracts/factories/AToken__factory.ts @@ -0,0 +1,930 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Signer, utils } from 'ethers'; +import type { Provider } from '@ethersproject/providers'; +import type { AToken, ATokenInterface } from '../AToken'; + +const _abi = [ + { + inputs: [ + { + internalType: 'contract IPool', + name: 'pool', + type: 'address', + }, + ], + stateMutability: 'nonpayable', + type: 'constructor', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'owner', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'spender', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'value', + type: 'uint256', + }, + ], + name: 'Approval', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'from', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'to', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'value', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'index', + type: 'uint256', + }, + ], + name: 'BalanceTransfer', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'from', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'target', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'value', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'balanceIncrease', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'index', + type: 'uint256', + }, + ], + name: 'Burn', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'underlyingAsset', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'pool', + type: 'address', + }, + { + indexed: false, + internalType: 'address', + name: 'treasury', + type: 'address', + }, + { + indexed: false, + internalType: 'address', + name: 'incentivesController', + type: 'address', + }, + { + indexed: false, + internalType: 'uint8', + name: 'aTokenDecimals', + type: 'uint8', + }, + { + indexed: false, + internalType: 'string', + name: 'aTokenName', + type: 'string', + }, + { + indexed: false, + internalType: 'string', + name: 'aTokenSymbol', + type: 'string', + }, + { + indexed: false, + internalType: 'bytes', + name: 'params', + type: 'bytes', + }, + ], + name: 'Initialized', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'caller', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'onBehalfOf', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'value', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'balanceIncrease', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'index', + type: 'uint256', + }, + ], + name: 'Mint', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'from', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'to', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'value', + type: 'uint256', + }, + ], + name: 'Transfer', + type: 'event', + }, + { + inputs: [], + name: 'ATOKEN_REVISION', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'DOMAIN_SEPARATOR', + outputs: [ + { + internalType: 'bytes32', + name: '', + type: 'bytes32', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'EIP712_REVISION', + outputs: [ + { + internalType: 'bytes', + name: '', + type: 'bytes', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'PERMIT_TYPEHASH', + outputs: [ + { + internalType: 'bytes32', + name: '', + type: 'bytes32', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'POOL', + outputs: [ + { + internalType: 'contract IPool', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'RESERVE_TREASURY_ADDRESS', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'UNDERLYING_ASSET_ADDRESS', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'owner', + type: 'address', + }, + { + internalType: 'address', + name: 'spender', + type: 'address', + }, + ], + name: 'allowance', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'spender', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'approve', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'user', + type: 'address', + }, + ], + name: 'balanceOf', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'from', + type: 'address', + }, + { + internalType: 'address', + name: 'receiverOfUnderlying', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'index', + type: 'uint256', + }, + ], + name: 'burn', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'decimals', + outputs: [ + { + internalType: 'uint8', + name: '', + type: 'uint8', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'spender', + type: 'address', + }, + { + internalType: 'uint256', + name: 'subtractedValue', + type: 'uint256', + }, + ], + name: 'decreaseAllowance', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'getIncentivesController', + outputs: [ + { + internalType: 'contract IAaveIncentivesController', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'user', + type: 'address', + }, + ], + name: 'getPreviousIndex', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'user', + type: 'address', + }, + ], + name: 'getScaledUserBalanceAndSupply', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'user', + type: 'address', + }, + { + internalType: 'address', + name: 'onBehalfOf', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'handleRepayment', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'spender', + type: 'address', + }, + { + internalType: 'uint256', + name: 'addedValue', + type: 'uint256', + }, + ], + name: 'increaseAllowance', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'contract IPool', + name: 'initializingPool', + type: 'address', + }, + { + internalType: 'address', + name: 'treasury', + type: 'address', + }, + { + internalType: 'address', + name: 'underlyingAsset', + type: 'address', + }, + { + internalType: 'contract IAaveIncentivesController', + name: 'incentivesController', + type: 'address', + }, + { + internalType: 'uint8', + name: 'aTokenDecimals', + type: 'uint8', + }, + { + internalType: 'string', + name: 'aTokenName', + type: 'string', + }, + { + internalType: 'string', + name: 'aTokenSymbol', + type: 'string', + }, + { + internalType: 'bytes', + name: 'params', + type: 'bytes', + }, + ], + name: 'initialize', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'caller', + type: 'address', + }, + { + internalType: 'address', + name: 'onBehalfOf', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'index', + type: 'uint256', + }, + ], + name: 'mint', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'index', + type: 'uint256', + }, + ], + name: 'mintToTreasury', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'name', + outputs: [ + { + internalType: 'string', + name: '', + type: 'string', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'owner', + type: 'address', + }, + ], + name: 'nonces', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'owner', + type: 'address', + }, + { + internalType: 'address', + name: 'spender', + type: 'address', + }, + { + internalType: 'uint256', + name: 'value', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'deadline', + type: 'uint256', + }, + { + internalType: 'uint8', + name: 'v', + type: 'uint8', + }, + { + internalType: 'bytes32', + name: 'r', + type: 'bytes32', + }, + { + internalType: 'bytes32', + name: 's', + type: 'bytes32', + }, + ], + name: 'permit', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'token', + type: 'address', + }, + { + internalType: 'address', + name: 'to', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'rescueTokens', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'user', + type: 'address', + }, + ], + name: 'scaledBalanceOf', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'scaledTotalSupply', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'contract IAaveIncentivesController', + name: 'controller', + type: 'address', + }, + ], + name: 'setIncentivesController', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'symbol', + outputs: [ + { + internalType: 'string', + name: '', + type: 'string', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'totalSupply', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'recipient', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'transfer', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'sender', + type: 'address', + }, + { + internalType: 'address', + name: 'recipient', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'transferFrom', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'from', + type: 'address', + }, + { + internalType: 'address', + name: 'to', + type: 'address', + }, + { + internalType: 'uint256', + name: 'value', + type: 'uint256', + }, + ], + name: 'transferOnLiquidation', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'target', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'transferUnderlyingTo', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, +] as const; + +export class AToken__factory { + static readonly abi = _abi; + static createInterface(): ATokenInterface { + return new utils.Interface(_abi) as ATokenInterface; + } + static connect(address: string, signerOrProvider: Signer | Provider): AToken { + return new Contract(address, _abi, signerOrProvider) as AToken; + } +} diff --git a/src/modules/aavev3/contracts/factories/AaveV3FlashLoanCallback__factory.ts b/src/modules/aavev3/contracts/factories/AaveV3FlashLoanCallback__factory.ts new file mode 100644 index 00000000..7f82b9c8 --- /dev/null +++ b/src/modules/aavev3/contracts/factories/AaveV3FlashLoanCallback__factory.ts @@ -0,0 +1,148 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Signer, utils } from 'ethers'; +import type { Provider } from '@ethersproject/providers'; +import type { AaveV3FlashLoanCallback, AaveV3FlashLoanCallbackInterface } from '../AaveV3FlashLoanCallback'; + +const _abi = [ + { + inputs: [ + { + internalType: 'address', + name: 'router_', + type: 'address', + }, + { + internalType: 'address', + name: 'aaveV3Provider_', + type: 'address', + }, + { + internalType: 'uint256', + name: 'feeRate_', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'constructor', + }, + { + inputs: [ + { + internalType: 'address', + name: 'asset', + type: 'address', + }, + ], + name: 'InvalidBalance', + type: 'error', + }, + { + inputs: [], + name: 'InvalidCaller', + type: 'error', + }, + { + inputs: [], + name: 'aaveV3Provider', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address[]', + name: 'assets', + type: 'address[]', + }, + { + internalType: 'uint256[]', + name: 'amounts', + type: 'uint256[]', + }, + { + internalType: 'uint256[]', + name: 'premiums', + type: 'uint256[]', + }, + { + internalType: 'address', + name: '', + type: 'address', + }, + { + internalType: 'bytes', + name: 'params', + type: 'bytes', + }, + ], + name: 'executeOperation', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'feeRate', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'metadata', + outputs: [ + { + internalType: 'bytes32', + name: '', + type: 'bytes32', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'router', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, +] as const; + +export class AaveV3FlashLoanCallback__factory { + static readonly abi = _abi; + static createInterface(): AaveV3FlashLoanCallbackInterface { + return new utils.Interface(_abi) as AaveV3FlashLoanCallbackInterface; + } + static connect(address: string, signerOrProvider: Signer | Provider): AaveV3FlashLoanCallback { + return new Contract(address, _abi, signerOrProvider) as AaveV3FlashLoanCallback; + } +} diff --git a/src/modules/aavev3/contracts/factories/DebtTokenBase__factory.ts b/src/modules/aavev3/contracts/factories/DebtTokenBase__factory.ts new file mode 100644 index 00000000..2b1650d4 --- /dev/null +++ b/src/modules/aavev3/contracts/factories/DebtTokenBase__factory.ts @@ -0,0 +1,194 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Signer, utils } from 'ethers'; +import type { Provider } from '@ethersproject/providers'; +import type { DebtTokenBase, DebtTokenBaseInterface } from '../DebtTokenBase'; + +const _abi = [ + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'fromUser', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'toUser', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'asset', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'BorrowAllowanceDelegated', + type: 'event', + }, + { + inputs: [], + name: 'DELEGATION_WITH_SIG_TYPEHASH', + outputs: [ + { + internalType: 'bytes32', + name: '', + type: 'bytes32', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'DOMAIN_SEPARATOR', + outputs: [ + { + internalType: 'bytes32', + name: '', + type: 'bytes32', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'EIP712_REVISION', + outputs: [ + { + internalType: 'bytes', + name: '', + type: 'bytes', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + 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: 'delegator', + type: 'address', + }, + { + internalType: 'address', + name: 'delegatee', + type: 'address', + }, + { + internalType: 'uint256', + name: 'value', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'deadline', + type: 'uint256', + }, + { + internalType: 'uint8', + name: 'v', + type: 'uint8', + }, + { + internalType: 'bytes32', + name: 'r', + type: 'bytes32', + }, + { + internalType: 'bytes32', + name: 's', + type: 'bytes32', + }, + ], + name: 'delegationWithSig', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'owner', + type: 'address', + }, + ], + name: 'nonces', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, +] as const; + +export class DebtTokenBase__factory { + static readonly abi = _abi; + static createInterface(): DebtTokenBaseInterface { + return new utils.Interface(_abi) as DebtTokenBaseInterface; + } + static connect(address: string, signerOrProvider: Signer | Provider): DebtTokenBase { + return new Contract(address, _abi, signerOrProvider) as DebtTokenBase; + } +} diff --git a/src/modules/aavev3/contracts/factories/PoolAddressesProvider__factory.ts b/src/modules/aavev3/contracts/factories/PoolAddressesProvider__factory.ts new file mode 100644 index 00000000..e027e14a --- /dev/null +++ b/src/modules/aavev3/contracts/factories/PoolAddressesProvider__factory.ts @@ -0,0 +1,516 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Signer, utils } from 'ethers'; +import type { Provider } from '@ethersproject/providers'; +import type { PoolAddressesProvider, PoolAddressesProviderInterface } from '../PoolAddressesProvider'; + +const _abi = [ + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'oldAddress', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'newAddress', + type: 'address', + }, + ], + name: 'ACLAdminUpdated', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'oldAddress', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'newAddress', + type: 'address', + }, + ], + name: 'ACLManagerUpdated', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'bytes32', + name: 'id', + type: 'bytes32', + }, + { + indexed: true, + internalType: 'address', + name: 'oldAddress', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'newAddress', + type: 'address', + }, + ], + name: 'AddressSet', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'bytes32', + name: 'id', + type: 'bytes32', + }, + { + indexed: true, + internalType: 'address', + name: 'proxyAddress', + type: 'address', + }, + { + indexed: false, + internalType: 'address', + name: 'oldImplementationAddress', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'newImplementationAddress', + type: 'address', + }, + ], + name: 'AddressSetAsProxy', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'string', + name: 'oldMarketId', + type: 'string', + }, + { + indexed: true, + internalType: 'string', + name: 'newMarketId', + type: 'string', + }, + ], + name: 'MarketIdSet', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'oldAddress', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'newAddress', + type: 'address', + }, + ], + name: 'PoolConfiguratorUpdated', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'oldAddress', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'newAddress', + type: 'address', + }, + ], + name: 'PoolDataProviderUpdated', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'oldAddress', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'newAddress', + type: 'address', + }, + ], + name: 'PoolUpdated', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'oldAddress', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'newAddress', + type: 'address', + }, + ], + name: 'PriceOracleSentinelUpdated', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'oldAddress', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'newAddress', + type: 'address', + }, + ], + name: 'PriceOracleUpdated', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'bytes32', + name: 'id', + type: 'bytes32', + }, + { + indexed: true, + internalType: 'address', + name: 'proxyAddress', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'implementationAddress', + type: 'address', + }, + ], + name: 'ProxyCreated', + type: 'event', + }, + { + inputs: [], + name: 'getACLAdmin', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getACLManager', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'bytes32', + name: 'id', + type: 'bytes32', + }, + ], + name: 'getAddress', + 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: 'getPool', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getPoolConfigurator', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getPoolDataProvider', + 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: 'getPriceOracleSentinel', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'newAclAdmin', + type: 'address', + }, + ], + name: 'setACLAdmin', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'newAclManager', + type: 'address', + }, + ], + name: 'setACLManager', + 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: 'newImplementationAddress', + type: 'address', + }, + ], + name: 'setAddressAsProxy', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'string', + name: 'newMarketId', + type: 'string', + }, + ], + name: 'setMarketId', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'newPoolConfiguratorImpl', + type: 'address', + }, + ], + name: 'setPoolConfiguratorImpl', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'newDataProvider', + type: 'address', + }, + ], + name: 'setPoolDataProvider', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'newPoolImpl', + type: 'address', + }, + ], + name: 'setPoolImpl', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'newPriceOracle', + type: 'address', + }, + ], + name: 'setPriceOracle', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'newPriceOracleSentinel', + type: 'address', + }, + ], + name: 'setPriceOracleSentinel', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, +] as const; + +export class PoolAddressesProvider__factory { + static readonly abi = _abi; + static createInterface(): PoolAddressesProviderInterface { + return new utils.Interface(_abi) as PoolAddressesProviderInterface; + } + static connect(address: string, signerOrProvider: Signer | Provider): PoolAddressesProvider { + return new Contract(address, _abi, signerOrProvider) as PoolAddressesProvider; + } +} diff --git a/src/modules/aavev3/contracts/factories/PoolDataProvider__factory.ts b/src/modules/aavev3/contracts/factories/PoolDataProvider__factory.ts new file mode 100644 index 00000000..9414479d --- /dev/null +++ b/src/modules/aavev3/contracts/factories/PoolDataProvider__factory.ts @@ -0,0 +1,541 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Signer, utils } from 'ethers'; +import type { Provider } from '@ethersproject/providers'; +import type { PoolDataProvider, PoolDataProviderInterface } from '../PoolDataProvider'; + +const _abi = [ + { + inputs: [], + name: 'ADDRESSES_PROVIDER', + outputs: [ + { + internalType: 'contract IPoolAddressesProvider', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'asset', + type: 'address', + }, + ], + name: 'getATokenTotalSupply', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getAllATokens', + outputs: [ + { + components: [ + { + internalType: 'string', + name: 'symbol', + type: 'string', + }, + { + internalType: 'address', + name: 'tokenAddress', + type: 'address', + }, + ], + internalType: 'struct IPoolDataProvider.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 IPoolDataProvider.TokenData[]', + name: '', + type: 'tuple[]', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'asset', + type: 'address', + }, + ], + name: 'getDebtCeiling', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getDebtCeilingDecimals', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'pure', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'asset', + type: 'address', + }, + ], + name: 'getFlashLoanEnabled', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'asset', + type: 'address', + }, + ], + name: 'getInterestRateStrategyAddress', + outputs: [ + { + internalType: 'address', + name: 'irStrategyAddress', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'asset', + type: 'address', + }, + ], + name: 'getLiquidationProtocolFee', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'asset', + type: 'address', + }, + ], + name: 'getPaused', + outputs: [ + { + internalType: 'bool', + name: 'isPaused', + type: 'bool', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'asset', + type: 'address', + }, + ], + name: 'getReserveCaps', + outputs: [ + { + internalType: 'uint256', + name: 'borrowCap', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'supplyCap', + type: 'uint256', + }, + ], + 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: 'unbacked', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'accruedToTreasuryScaled', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'totalAToken', + 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: 'getReserveEModeCategory', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + 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', + }, + ], + name: 'getSiloedBorrowing', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'asset', + type: 'address', + }, + ], + name: 'getTotalDebt', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'asset', + type: 'address', + }, + ], + name: 'getUnbackedMintCap', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + 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', + }, +] as const; + +export class PoolDataProvider__factory { + static readonly abi = _abi; + static createInterface(): PoolDataProviderInterface { + return new utils.Interface(_abi) as PoolDataProviderInterface; + } + static connect(address: string, signerOrProvider: Signer | Provider): PoolDataProvider { + return new Contract(address, _abi, signerOrProvider) as PoolDataProvider; + } +} diff --git a/src/modules/aavev3/contracts/factories/Pool__factory.ts b/src/modules/aavev3/contracts/factories/Pool__factory.ts new file mode 100644 index 00000000..5c852f06 --- /dev/null +++ b/src/modules/aavev3/contracts/factories/Pool__factory.ts @@ -0,0 +1,1739 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Signer, utils } from 'ethers'; +import type { Provider } from '@ethersproject/providers'; +import type { Pool, PoolInterface } from '../Pool'; + +const _abi = [ + { + inputs: [ + { + internalType: 'contract IPoolAddressesProvider', + name: 'provider', + type: 'address', + }, + ], + stateMutability: 'nonpayable', + type: 'constructor', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'reserve', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'backer', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'fee', + type: 'uint256', + }, + ], + name: 'BackUnbacked', + 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: false, + internalType: 'enum DataTypes.InterestRateMode', + name: 'interestRateMode', + type: 'uint8', + }, + { + indexed: false, + internalType: 'uint256', + name: 'borrowRate', + type: 'uint256', + }, + { + indexed: true, + internalType: 'uint16', + name: 'referralCode', + type: 'uint16', + }, + ], + name: 'Borrow', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'target', + type: 'address', + }, + { + indexed: false, + 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: 'enum DataTypes.InterestRateMode', + name: 'interestRateMode', + type: 'uint8', + }, + { + indexed: false, + internalType: 'uint256', + name: 'premium', + type: 'uint256', + }, + { + indexed: true, + internalType: 'uint16', + name: 'referralCode', + type: 'uint16', + }, + ], + name: 'FlashLoan', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'asset', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'totalDebt', + type: 'uint256', + }, + ], + name: 'IsolationModeTotalDebtUpdated', + 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: [ + { + 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: 'referralCode', + type: 'uint16', + }, + ], + name: 'MintUnbacked', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'reserve', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amountMinted', + type: 'uint256', + }, + ], + name: 'MintedToTreasury', + 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', + }, + { + indexed: false, + internalType: 'bool', + name: 'useATokens', + type: 'bool', + }, + ], + 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: 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: 'referralCode', + type: 'uint16', + }, + ], + name: 'Supply', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'reserve', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'user', + type: 'address', + }, + { + indexed: false, + internalType: 'enum DataTypes.InterestRateMode', + name: 'interestRateMode', + type: 'uint8', + }, + ], + name: 'SwapBorrowRateMode', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'user', + type: 'address', + }, + { + indexed: false, + internalType: 'uint8', + name: 'categoryId', + type: 'uint8', + }, + ], + name: 'UserEModeSet', + 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: 'ADDRESSES_PROVIDER', + outputs: [ + { + internalType: 'contract IPoolAddressesProvider', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'BRIDGE_PROTOCOL_FEE', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'FLASHLOAN_PREMIUM_TOTAL', + outputs: [ + { + internalType: 'uint128', + name: '', + type: 'uint128', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'FLASHLOAN_PREMIUM_TO_PROTOCOL', + outputs: [ + { + internalType: 'uint128', + name: '', + type: 'uint128', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'MAX_NUMBER_RESERVES', + outputs: [ + { + internalType: 'uint16', + name: '', + type: 'uint16', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'MAX_STABLE_RATE_BORROW_SIZE_PERCENT', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'POOL_REVISION', + 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: 'fee', + type: 'uint256', + }, + ], + name: 'backUnbacked', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + 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: 'uint8', + name: 'id', + type: 'uint8', + }, + { + components: [ + { + internalType: 'uint16', + name: 'ltv', + type: 'uint16', + }, + { + internalType: 'uint16', + name: 'liquidationThreshold', + type: 'uint16', + }, + { + internalType: 'uint16', + name: 'liquidationBonus', + type: 'uint16', + }, + { + internalType: 'address', + name: 'priceSource', + type: 'address', + }, + { + internalType: 'string', + name: 'label', + type: 'string', + }, + ], + internalType: 'struct DataTypes.EModeCategory', + name: 'category', + type: 'tuple', + }, + ], + name: 'configureEModeCategory', + 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', + }, + ], + name: 'dropReserve', + 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: 'interestRateModes', + 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: [ + { + internalType: 'address', + name: 'receiverAddress', + type: 'address', + }, + { + internalType: 'address', + name: 'asset', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { + internalType: 'bytes', + name: 'params', + type: 'bytes', + }, + { + internalType: 'uint16', + name: 'referralCode', + type: 'uint16', + }, + ], + name: 'flashLoanSimple', + outputs: [], + stateMutability: 'nonpayable', + 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: 'uint8', + name: 'id', + type: 'uint8', + }, + ], + name: 'getEModeCategoryData', + outputs: [ + { + components: [ + { + internalType: 'uint16', + name: 'ltv', + type: 'uint16', + }, + { + internalType: 'uint16', + name: 'liquidationThreshold', + type: 'uint16', + }, + { + internalType: 'uint16', + name: 'liquidationBonus', + type: 'uint16', + }, + { + internalType: 'address', + name: 'priceSource', + type: 'address', + }, + { + internalType: 'string', + name: 'label', + type: 'string', + }, + ], + internalType: 'struct DataTypes.EModeCategory', + name: '', + type: 'tuple', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint16', + name: 'id', + type: 'uint16', + }, + ], + name: 'getReserveAddressById', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + 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: 'currentLiquidityRate', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'variableBorrowIndex', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'currentVariableBorrowRate', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'currentStableBorrowRate', + type: 'uint128', + }, + { + internalType: 'uint40', + name: 'lastUpdateTimestamp', + type: 'uint40', + }, + { + internalType: 'uint16', + name: 'id', + type: 'uint16', + }, + { + 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: 'uint128', + name: 'accruedToTreasury', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'unbacked', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'isolationModeTotalDebt', + type: 'uint128', + }, + ], + 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: 'totalCollateralBase', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'totalDebtBase', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'availableBorrowsBase', + 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: 'user', + type: 'address', + }, + ], + name: 'getUserEMode', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + 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 IPoolAddressesProvider', + 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: [ + { + internalType: 'address[]', + name: 'assets', + type: 'address[]', + }, + ], + name: 'mintToTreasury', + 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: 'mintUnbacked', + outputs: [], + stateMutability: 'nonpayable', + 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: 'interestRateMode', + 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: 'amount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'interestRateMode', + type: 'uint256', + }, + ], + name: 'repayWithATokens', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'asset', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'interestRateMode', + type: 'uint256', + }, + { + internalType: 'address', + name: 'onBehalfOf', + type: 'address', + }, + { + internalType: 'uint256', + name: 'deadline', + type: 'uint256', + }, + { + internalType: 'uint8', + name: 'permitV', + type: 'uint8', + }, + { + internalType: 'bytes32', + name: 'permitR', + type: 'bytes32', + }, + { + internalType: 'bytes32', + name: 'permitS', + type: 'bytes32', + }, + ], + name: 'repayWithPermit', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'token', + type: 'address', + }, + { + internalType: 'address', + name: 'to', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'rescueTokens', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'asset', + type: 'address', + }, + ], + name: 'resetIsolationModeTotalDebt', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'asset', + type: 'address', + }, + { + components: [ + { + internalType: 'uint256', + name: 'data', + type: 'uint256', + }, + ], + internalType: 'struct DataTypes.ReserveConfigurationMap', + name: 'configuration', + type: 'tuple', + }, + ], + name: 'setConfiguration', + 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: 'uint8', + name: 'categoryId', + type: 'uint8', + }, + ], + name: 'setUserEMode', + 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: 'amount', + type: 'uint256', + }, + { + internalType: 'address', + name: 'onBehalfOf', + type: 'address', + }, + { + internalType: 'uint16', + name: 'referralCode', + type: 'uint16', + }, + ], + name: 'supply', + 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', + }, + { + internalType: 'uint256', + name: 'deadline', + type: 'uint256', + }, + { + internalType: 'uint8', + name: 'permitV', + type: 'uint8', + }, + { + internalType: 'bytes32', + name: 'permitR', + type: 'bytes32', + }, + { + internalType: 'bytes32', + name: 'permitS', + type: 'bytes32', + }, + ], + name: 'supplyWithPermit', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'asset', + type: 'address', + }, + { + internalType: 'uint256', + name: 'interestRateMode', + type: 'uint256', + }, + ], + name: 'swapBorrowRateMode', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'protocolFee', + type: 'uint256', + }, + ], + name: 'updateBridgeProtocolFee', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint128', + name: 'flashLoanPremiumTotal', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'flashLoanPremiumToProtocol', + type: 'uint128', + }, + ], + name: 'updateFlashloanPremiums', + 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', + }, +] as const; + +export class Pool__factory { + static readonly abi = _abi; + static createInterface(): PoolInterface { + return new utils.Interface(_abi) as PoolInterface; + } + static connect(address: string, signerOrProvider: Signer | Provider): Pool { + return new Contract(address, _abi, signerOrProvider) as Pool; + } +} diff --git a/src/modules/aavev3/contracts/factories/index.ts b/src/modules/aavev3/contracts/factories/index.ts new file mode 100644 index 00000000..7681115c --- /dev/null +++ b/src/modules/aavev3/contracts/factories/index.ts @@ -0,0 +1,9 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +export { AToken__factory } from './AToken__factory'; +export { AaveV3FlashLoanCallback__factory } from './AaveV3FlashLoanCallback__factory'; +export { DebtTokenBase__factory } from './DebtTokenBase__factory'; +export { Pool__factory } from './Pool__factory'; +export { PoolAddressesProvider__factory } from './PoolAddressesProvider__factory'; +export { PoolDataProvider__factory } from './PoolDataProvider__factory'; diff --git a/src/modules/aavev3/contracts/index.ts b/src/modules/aavev3/contracts/index.ts new file mode 100644 index 00000000..cd0e1203 --- /dev/null +++ b/src/modules/aavev3/contracts/index.ts @@ -0,0 +1,16 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +export type { AToken } from './AToken'; +export type { AaveV3FlashLoanCallback } from './AaveV3FlashLoanCallback'; +export type { DebtTokenBase } from './DebtTokenBase'; +export type { Pool } from './Pool'; +export type { PoolAddressesProvider } from './PoolAddressesProvider'; +export type { PoolDataProvider } from './PoolDataProvider'; +export * as factories from './factories'; +export { AaveV3FlashLoanCallback__factory } from './factories/AaveV3FlashLoanCallback__factory'; +export { AToken__factory } from './factories/AToken__factory'; +export { DebtTokenBase__factory } from './factories/DebtTokenBase__factory'; +export { Pool__factory } from './factories/Pool__factory'; +export { PoolAddressesProvider__factory } from './factories/PoolAddressesProvider__factory'; +export { PoolDataProvider__factory } from './factories/PoolDataProvider__factory'; diff --git a/src/modules/aavev3/index.ts b/src/modules/aavev3/index.ts new file mode 100644 index 00000000..c0e63229 --- /dev/null +++ b/src/modules/aavev3/index.ts @@ -0,0 +1,5 @@ +export * from './contracts'; +export * from './logic.borrow'; +export * from './logic.repay'; +export * from './logic.supply'; +export * from './logic.withdraw'; diff --git a/src/modules/aavev3/logic.borrow.ts b/src/modules/aavev3/logic.borrow.ts new file mode 100644 index 00000000..64aa4fe1 --- /dev/null +++ b/src/modules/aavev3/logic.borrow.ts @@ -0,0 +1,53 @@ +import { InterestRateMode, LogicOptions, serviceType } from './types'; +import { Pool__factory } from './contracts'; +import * as common from '@protocolink/common'; +import * as core from '@protocolink/core'; + +export type BorrowLogicTokenList = common.Token[]; + +export type BorrowLogicFields = core.TokenOutFields<{ interestRateMode: InterestRateMode; referralCode?: number }>; + +export type BorrowLogicOptions = Pick; + +export class BorrowLogic extends core.Logic { + static id = 'borrow'; + public readonly service: serviceType; + + constructor({ chainId, provider, service }: LogicOptions) { + super(chainId, provider); + this.service = service; + } + + async getTokenList() { + const borrowTokens = await this.service.getBorrowTokens(); + + const tokenList: BorrowLogicTokenList = []; + for (const { asset } of borrowTokens) { + if (asset.isWrapped) { + tokenList.push(asset.unwrapped); + } + tokenList.push(asset); + } + + return tokenList; + } + + async build(fields: BorrowLogicFields, options: BorrowLogicOptions) { + const { output, interestRateMode, referralCode = 0 } = fields; + const { account } = options; + + const tokenOut = output.token.wrapped; + + const to = await this.service.getPoolAddress(); + const data = Pool__factory.createInterface().encodeFunctionData('borrow', [ + tokenOut.address, + output.amountWei, + interestRateMode, + referralCode, + account, + ]); + const wrapMode = output.token.isNative ? core.WrapMode.unwrapAfter : core.WrapMode.none; + + return core.newLogic({ to, data, wrapMode }); + } +} diff --git a/src/modules/aavev3/logic.repay.ts b/src/modules/aavev3/logic.repay.ts new file mode 100644 index 00000000..e243d1dd --- /dev/null +++ b/src/modules/aavev3/logic.repay.ts @@ -0,0 +1,69 @@ +import { InterestRateMode, LogicOptions, serviceType } from './types'; +import { Pool__factory } from './contracts'; +import * as common from '@protocolink/common'; +import * as core from '@protocolink/core'; + +export type RepayLogicTokenList = common.Token[]; + +export type RepayLogicParams = core.RepayParams<{ interestRateMode: InterestRateMode }>; + +export type RepayLogicFields = core.RepayFields<{ interestRateMode: InterestRateMode }>; + +export class RepayLogic extends core.Logic { + static id = 'repay'; + public readonly service: serviceType; + + constructor({ chainId, provider, service }: LogicOptions) { + super(chainId, provider); + this.service = service; + } + + async getTokenList() { + const tokens = await this.service.getAssets(); + + const tokenList: RepayLogicTokenList = []; + for (const token of tokens) { + if (token.isWrapped) { + tokenList.push(token.unwrapped); + } + tokenList.push(token); + } + + return tokenList; + } + + async quote(params: RepayLogicParams) { + const { borrower, tokenIn, interestRateMode } = params; + + const { currentStableDebt, currentVariableDebt } = await this.service.poolDataProvider.getUserReserveData( + tokenIn.wrapped.address, + borrower + ); + const currentDebt = interestRateMode === InterestRateMode.variable ? currentVariableDebt : currentStableDebt; + const amountWei = common.calcSlippage(currentDebt, -1); // slightly higher than the current borrowed amount + const input = new common.TokenAmount(tokenIn).setWei(amountWei); + + return { borrower, interestRateMode, input }; + } + + async build(fields: RepayLogicFields) { + const { input, interestRateMode, borrower, balanceBps } = fields; + + const tokenIn = input.token.wrapped; + + const to = await this.service.getPoolAddress(); + const data = Pool__factory.createInterface().encodeFunctionData('repay', [ + tokenIn.address, + input.amountWei, + interestRateMode, + borrower, + ]); + const amountOffset = balanceBps ? common.getParamOffset(1) : undefined; + const inputs = [ + core.newLogicInput({ input: new common.TokenAmount(tokenIn, input.amount), balanceBps, amountOffset }), + ]; + const wrapMode = input.token.isNative ? core.WrapMode.wrapBefore : core.WrapMode.none; + + return core.newLogic({ to, data, inputs, wrapMode }); + } +} diff --git a/src/modules/aavev3/logic.supply.ts b/src/modules/aavev3/logic.supply.ts new file mode 100644 index 00000000..d7f216b9 --- /dev/null +++ b/src/modules/aavev3/logic.supply.ts @@ -0,0 +1,66 @@ +import { LogicOptions, serviceType } from './types'; +import { Pool__factory } from './contracts'; +import * as common from '@protocolink/common'; +import * as core from '@protocolink/core'; + +export type SupplyLogicTokenList = [common.Token, common.Token][]; + +export type SupplyLogicParams = core.TokenToTokenExactInParams; + +export type SupplyLogicFields = core.TokenToTokenExactInFields<{ referralCode?: number }>; + +export type SupplyLogicOptions = Pick; + +export class SupplyLogics extends core.Logic { + static id = 'supply'; + public readonly service: serviceType; + + constructor({ chainId, provider, service }: LogicOptions) { + super(chainId, provider); + this.service = service; + } + + async getTokenList() { + const supplyTokens = await this.service.getSupplyTokens(); + + const tokenList: SupplyLogicTokenList = []; + for (const reserveToken of supplyTokens) { + if (reserveToken.asset.isWrapped) { + tokenList.push([reserveToken.asset.unwrapped, reserveToken.aToken]); + } + tokenList.push([reserveToken.asset, reserveToken.aToken]); + } + + return tokenList; + } + + async quote(params: SupplyLogicParams): Promise { + const { input, tokenOut } = params; + const output = new common.TokenAmount(tokenOut, input.amount); + + return { input, output }; + } + + async build(fields: SupplyLogicFields, options: SupplyLogicOptions) { + const { input, balanceBps, referralCode = 0 } = fields; + const { account } = options; + + const tokenIn = input.token.wrapped; + const agent = await this.calcAgent(account); + + const to = await this.service.getPoolAddress(); + const data = Pool__factory.createInterface().encodeFunctionData('supply', [ + tokenIn.address, + input.amountWei, + agent, + referralCode, + ]); + const amountOffset = balanceBps ? common.getParamOffset(1) : undefined; + const inputs = [ + core.newLogicInput({ input: new common.TokenAmount(tokenIn, input.amount), balanceBps, amountOffset }), + ]; + const wrapMode = input.token.isNative ? core.WrapMode.wrapBefore : core.WrapMode.none; + + return core.newLogic({ to, data, inputs, wrapMode }); + } +} diff --git a/src/modules/aavev3/logic.withdraw.ts b/src/modules/aavev3/logic.withdraw.ts new file mode 100644 index 00000000..69ee5e26 --- /dev/null +++ b/src/modules/aavev3/logic.withdraw.ts @@ -0,0 +1,63 @@ +import { LogicOptions, serviceType } from './types'; +import { Pool__factory } from './contracts'; +import * as common from '@protocolink/common'; +import * as core from '@protocolink/core'; + +export type WithdrawLogicTokenList = [common.Token, common.Token][]; + +export type WithdrawLogicParams = core.TokenToTokenExactInParams; + +export type WithdrawLogicFields = core.TokenToTokenExactInFields; + +export type WithdrawLogicOptions = Pick; + +export class WithdrawLogic extends core.Logic { + static id = 'withdraw'; + public readonly service: serviceType; + + constructor({ chainId, provider, service }: LogicOptions) { + super(chainId, provider); + this.service = service; + } + + async getTokenList() { + const { reserveTokens } = await this.service.getReserveTokens(); + + const tokenList: WithdrawLogicTokenList = []; + for (const reserveToken of reserveTokens) { + if (reserveToken.asset.isWrapped) { + tokenList.push([reserveToken.aToken, reserveToken.asset.unwrapped]); + } + tokenList.push([reserveToken.aToken, reserveToken.asset]); + } + + return tokenList; + } + + async quote(params: WithdrawLogicParams): Promise { + const { input, tokenOut } = params; + const output = new common.TokenAmount(tokenOut, input.amount); + + return { input, output }; + } + + async build(fields: WithdrawLogicFields, options: WithdrawLogicOptions) { + const { input, output, balanceBps } = fields; + const { account } = options; + + const tokenOut = output.token.wrapped; + const agent = await this.calcAgent(account); + + const to = await this.service.getPoolAddress(); + const data = Pool__factory.createInterface().encodeFunctionData('withdraw', [ + tokenOut.address, + input.amountWei, + agent, + ]); + const amountOffset = balanceBps ? common.getParamOffset(1) : undefined; + const inputs = [core.newLogicInput({ input, balanceBps, amountOffset })]; + const wrapMode = output.token.isNative ? core.WrapMode.unwrapAfter : core.WrapMode.none; + + return core.newLogic({ to, data, inputs, wrapMode }); + } +} diff --git a/src/modules/aavev3/types.ts b/src/modules/aavev3/types.ts new file mode 100644 index 00000000..c715ad88 --- /dev/null +++ b/src/modules/aavev3/types.ts @@ -0,0 +1,17 @@ +import { Service as AaveV3Service } from 'src/logics/aave-v3'; +import { Service as SparkService } from 'src/logics/spark'; +import { providers } from 'ethers'; + +export enum InterestRateMode { + none = 0, + stable = 1, + variable = 2, +} + +export type serviceType = AaveV3Service | SparkService; + +export interface LogicOptions { + chainId: number; + provider?: providers.Provider; + service: serviceType; +} diff --git a/test/logics/openocean-v2/swap-token.test.ts b/test/logics/openocean-v2/swap-token.test.ts index 31378155..425b8d3b 100644 --- a/test/logics/openocean-v2/swap-token.test.ts +++ b/test/logics/openocean-v2/swap-token.test.ts @@ -17,7 +17,7 @@ describe('metis: Test OpenOceanV2 SwapToken Logic', function () { await claimToken( chainId, user.address, - common.metisTokens['METIS(ERC20)'], + common.metisTokens.METIS, '100', '0x7314Ef2CA509490f65F52CC8FC9E0675C66390b8' ); @@ -35,7 +35,7 @@ describe('metis: Test OpenOceanV2 SwapToken Logic', function () { const testCases = [ { params: { - input: new common.TokenAmount(common.metisTokens['METIS(ERC20)'], '1'), + input: new common.TokenAmount(common.metisTokens.METIS, '1'), tokenOut: common.metisTokens['m.DAI'], slippage: 100, }, @@ -43,7 +43,7 @@ describe('metis: Test OpenOceanV2 SwapToken Logic', function () { { params: { input: new common.TokenAmount(common.metisTokens['m.USDC'], '1'), - tokenOut: common.metisTokens['METIS(ERC20)'], + tokenOut: common.metisTokens.METIS, slippage: 100, }, }, diff --git a/yarn.lock b/yarn.lock index c463de51..ecf60e1d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1050,6 +1050,21 @@ type-fest "^3.12.0" zksync-web3 "^0.14.3" +"@protocolink/common@^0.4.2": + version "0.4.2" + resolved "https://registry.yarnpkg.com/@protocolink/common/-/common-0.4.2.tgz#25fb1f4991aaf957dc686e5364f4f5a47c9fe7bf" + integrity sha512-HuO3WZEfSDnbbdSrUlHYcltgWdKe0V9suJrS/FYFrrawGHI3zE4mZwG7oBvbczU+z1OwF4ANTEhKVOH11uWJIQ== + dependencies: + "@types/lodash" "^4.14.195" + axios "^1.3.6" + axios-retry "^3.5.1" + bignumber.js "^9.1.1" + ethers "^5.7.2" + lodash "^4.17.21" + tiny-invariant "^1.3.1" + type-fest "^3.12.0" + zksync-web3 "^0.14.3" + "@protocolink/core@^0.5.0": version "0.5.0" resolved "https://registry.yarnpkg.com/@protocolink/core/-/core-0.5.0.tgz#fc2ea588e4308bebc9d8d7c1d3bbaae2a0c882ab"