diff --git a/packages/contract-helpers/src/UiIncentiveDataProviderV3-contract/_mocks.ts b/packages/contract-helpers/src/UiIncentiveDataProviderV3-contract/_mocks.ts new file mode 100644 index 00000000..a572a814 --- /dev/null +++ b/packages/contract-helpers/src/UiIncentiveDataProviderV3-contract/_mocks.ts @@ -0,0 +1,132 @@ +import { BigNumber } from 'ethers'; +import { ReservesIncentiveData, UserReservesIncentivesData } from './types'; + +export const getReservesIncentivesDataMock: ReservesIncentiveData[] = [ + { + underlyingAsset: '0xb04Aaa2A73ff3D88950BdF19Eb4AC029630a2367', + aIncentiveData: { + tokenAddress: '0x6d0eeb7b37BF26E182EB9a8631DCF79e4EF43DDd', + incentiveControllerAddress: '0x5465485D7b15CaBc9196E73A0b1cc457262079e3', + rewardsTokenInformation: [ + { + rewardTokenSymbol: 'REW', + rewardTokenAddress: '0x1f689325CBdF44B24DBE2ecC2b1fFD4130861b4E', + rewardOracleAddress: '0xca8e9B5F9e36EbF74096223fc48810861b4FA642', + emissionPerSecond: BigNumber.from({ + _hex: '0x04464ecbc45ffe', + _isBigNumber: true, + }), + incentivesLastUpdateTimestamp: BigNumber.from({ + _hex: '0x61a5167a', + _isBigNumber: true, + }), + tokenIncentivesIndex: BigNumber.from({ + _hex: '0x00', + _isBigNumber: true, + }), + emissionEndTimestamp: BigNumber.from({ + _hex: '0x638649fa', + _isBigNumber: true, + }), + rewardPriceFeed: BigNumber.from({ + _hex: '0x05f5e100', + _isBigNumber: true, + }), + rewardTokenDecimals: 18, + precision: 18, + priceFeedDecimals: 0, + }, + ], + }, + vIncentiveData: { + tokenAddress: '0xaD99ef885623E8520f631625b2675d6dAd3aaDC1', + incentiveControllerAddress: '0x5465485D7b15CaBc9196E73A0b1cc457262079e3', + rewardsTokenInformation: [ + { + rewardTokenSymbol: 'REW', + rewardTokenAddress: '0x1f689325CBdF44B24DBE2ecC2b1fFD4130861b4E', + rewardOracleAddress: '0xca8e9B5F9e36EbF74096223fc48810861b4FA642', + emissionPerSecond: BigNumber.from({ + _hex: '0x04464ecbc45ffe', + _isBigNumber: true, + }), + incentivesLastUpdateTimestamp: BigNumber.from({ + _hex: '0x61a5167a', + _isBigNumber: true, + }), + tokenIncentivesIndex: BigNumber.from({ + _hex: '0x00', + _isBigNumber: true, + }), + emissionEndTimestamp: BigNumber.from({ + _hex: '0x638649fa', + _isBigNumber: true, + }), + rewardPriceFeed: BigNumber.from({ + _hex: '0x05f5e100', + _isBigNumber: true, + }), + rewardTokenDecimals: 18, + precision: 18, + priceFeedDecimals: 0, + }, + ], + }, + }, +]; + +export const getUserIncentivesDataMock: UserReservesIncentivesData[] = [ + { + underlyingAsset: '0xb04Aaa2A73ff3D88950BdF19Eb4AC029630a2367', + aTokenIncentivesUserData: { + tokenAddress: '0x6d0eeb7b37BF26E182EB9a8631DCF79e4EF43DDd', + incentiveControllerAddress: '0x5465485D7b15CaBc9196E73A0b1cc457262079e3', + userRewardsInformation: [ + { + rewardTokenSymbol: 'REW', + rewardOracleAddress: '0xca8e9B5F9e36EbF74096223fc48810861b4FA642', + rewardTokenAddress: '0x1f689325CBdF44B24DBE2ecC2b1fFD4130861b4E', + userUnclaimedRewards: BigNumber.from({ + _hex: '0x00', + _isBigNumber: true, + }), + tokenIncentivesUserIndex: BigNumber.from({ + _hex: '0x00', + _isBigNumber: true, + }), + rewardPriceFeed: BigNumber.from({ + _hex: '0x05f5e100', + _isBigNumber: true, + }), + priceFeedDecimals: 0, + rewardTokenDecimals: 18, + }, + ], + }, + vTokenIncentivesUserData: { + tokenAddress: '0xaD99ef885623E8520f631625b2675d6dAd3aaDC1', + incentiveControllerAddress: '0x5465485D7b15CaBc9196E73A0b1cc457262079e3', + userRewardsInformation: [ + { + rewardTokenSymbol: 'REW', + rewardOracleAddress: '0xca8e9B5F9e36EbF74096223fc48810861b4FA642', + rewardTokenAddress: '0x1f689325CBdF44B24DBE2ecC2b1fFD4130861b4E', + userUnclaimedRewards: BigNumber.from({ + _hex: '0x00', + _isBigNumber: true, + }), + tokenIncentivesUserIndex: BigNumber.from({ + _hex: '0x00', + _isBigNumber: true, + }), + rewardPriceFeed: BigNumber.from({ + _hex: '0x05f5e100', + _isBigNumber: true, + }), + priceFeedDecimals: 0, + rewardTokenDecimals: 18, + }, + ], + }, + }, +]; diff --git a/packages/contract-helpers/src/UiIncentiveDataProviderV3-contract/index.ts b/packages/contract-helpers/src/UiIncentiveDataProviderV3-contract/index.ts new file mode 100644 index 00000000..e9942568 --- /dev/null +++ b/packages/contract-helpers/src/UiIncentiveDataProviderV3-contract/index.ts @@ -0,0 +1,217 @@ +import { providers } from 'ethers'; +import BaseService from '../commons/BaseService'; +import { UiIncentiveDataProviderValidator } from '../commons/validators/methodValidators'; +import { isEthAddress } from '../commons/validators/paramValidators'; +import { ReservesHelperInput, UserReservesHelperInput } from '../index'; +import { UiIncentiveDataProviderV3 } from './typechain/UiIncentiveDataProviderV3'; +import { UiIncentiveDataProviderV3__factory } from './typechain/UiIncentiveDataProviderV3__factory'; +import { + FullReservesIncentiveDataResponse, + IncentiveData, + IncentiveDataHumanized, + ReservesIncentiveData, + ReservesIncentiveDataHumanized, + RewardInfo, + UserIncentiveData, + UserIncentiveDataHumanized, + UserReservesIncentivesData, + UserReservesIncentivesDataHumanized, + UserRewardInfo, +} from './types'; +export * from './types'; + +export interface UiIncentiveDataProviderInterface { + getFullReservesIncentiveData: ( + args: UserReservesHelperInput, + ) => Promise; + getReservesIncentivesData: ( + args: ReservesHelperInput, + ) => Promise; + getUserReservesIncentivesData: ( + args: UserReservesHelperInput, + ) => Promise; + getReservesIncentivesDataHumanized: ( + args: ReservesHelperInput, + ) => Promise; + getUserReservesIncentivesDataHumanized: ( + args: UserReservesHelperInput, + ) => Promise; +} +export interface FeedResultSuccessful { + rewardTokenAddress: string; + answer: string; + updatedAt: number; + decimals: number; +} + +export interface UiIncentiveDataProviderContext { + uiIncentiveDataProviderAddress: string; + provider: providers.Provider; + chainId: number; +} + +export class UiIncentiveDataProvider + extends BaseService + implements UiIncentiveDataProviderInterface +{ + readonly uiIncentiveDataProviderAddress: string; + + readonly chainId: number; + + /** + * Constructor + * @param context The ui incentive data provider context + */ + public constructor({ + provider, + uiIncentiveDataProviderAddress, + chainId, + }: UiIncentiveDataProviderContext) { + super(provider, UiIncentiveDataProviderV3__factory); + this.uiIncentiveDataProviderAddress = uiIncentiveDataProviderAddress; + this.chainId = chainId; + } + + /** + * Get the full reserve incentive data for the lending pool and the user + * @param user The user address + */ + @UiIncentiveDataProviderValidator + public async getFullReservesIncentiveData( + @isEthAddress('user') + @isEthAddress('lendingPoolAddressProvider') + { user, lendingPoolAddressProvider }: UserReservesHelperInput, + ): Promise { + const uiIncentiveContract = this.getContractInstance( + this.uiIncentiveDataProviderAddress, + ); + + return uiIncentiveContract.getFullReservesIncentiveData( + lendingPoolAddressProvider, + user, + ); + } + + /** + * Get the reserve incentive data for the lending pool + */ + @UiIncentiveDataProviderValidator + public async getReservesIncentivesData( + @isEthAddress('lendingPoolAddressProvider') + { lendingPoolAddressProvider }: ReservesHelperInput, + ): Promise { + const uiIncentiveContract = this.getContractInstance( + this.uiIncentiveDataProviderAddress, + ); + + return uiIncentiveContract.getReservesIncentivesData( + lendingPoolAddressProvider, + ); + } + + /** + * Get the reserve incentive data for the user + * @param user The user address + */ + @UiIncentiveDataProviderValidator + public async getUserReservesIncentivesData( + @isEthAddress('user') + @isEthAddress('lendingPoolAddressProvider') + { user, lendingPoolAddressProvider }: UserReservesHelperInput, + ): Promise { + const uiIncentiveContract = this.getContractInstance( + this.uiIncentiveDataProviderAddress, + ); + + return uiIncentiveContract.getUserReservesIncentivesData( + lendingPoolAddressProvider, + user, + ); + } + + @UiIncentiveDataProviderValidator + public async getReservesIncentivesDataHumanized( + @isEthAddress('lendingPoolAddressProvider') + { lendingPoolAddressProvider }: ReservesHelperInput, + ): Promise { + const response: ReservesIncentiveData[] = + await this.getReservesIncentivesData({ lendingPoolAddressProvider }); + + return response.map(r => ({ + id: `${this.chainId}-${r.underlyingAsset}-${lendingPoolAddressProvider}`.toLowerCase(), + underlyingAsset: r.underlyingAsset.toLowerCase(), + aIncentiveData: this._formatIncentiveData(r.aIncentiveData), + vIncentiveData: this._formatIncentiveData(r.vIncentiveData), + })); + } + + @UiIncentiveDataProviderValidator + public async getUserReservesIncentivesDataHumanized( + @isEthAddress('user') + @isEthAddress('lendingPoolAddressProvider') + { user, lendingPoolAddressProvider }: UserReservesHelperInput, + ): Promise { + const response: UserReservesIncentivesData[] = + await this.getUserReservesIncentivesData({ + user, + lendingPoolAddressProvider, + }); + + return response.map(r => ({ + id: `${this.chainId}-${user}-${r.underlyingAsset}-${lendingPoolAddressProvider}`.toLowerCase(), + underlyingAsset: r.underlyingAsset.toLowerCase(), + aTokenIncentivesUserData: this._formatUserIncentiveData( + r.aTokenIncentivesUserData, + ), + vTokenIncentivesUserData: this._formatUserIncentiveData( + r.vTokenIncentivesUserData, + ), + })); + } + + private _formatIncentiveData(data: IncentiveData): IncentiveDataHumanized { + return { + tokenAddress: data.tokenAddress, + incentiveControllerAddress: data.incentiveControllerAddress, + rewardsTokenInformation: data.rewardsTokenInformation.map( + (rawRewardInfo: RewardInfo) => ({ + precision: rawRewardInfo.precision, + rewardTokenAddress: rawRewardInfo.rewardTokenAddress, + rewardTokenDecimals: rawRewardInfo.rewardTokenDecimals, + emissionPerSecond: rawRewardInfo.emissionPerSecond.toString(), + incentivesLastUpdateTimestamp: + rawRewardInfo.incentivesLastUpdateTimestamp.toNumber(), + tokenIncentivesIndex: rawRewardInfo.tokenIncentivesIndex.toString(), + emissionEndTimestamp: rawRewardInfo.emissionEndTimestamp.toNumber(), + rewardTokenSymbol: rawRewardInfo.rewardTokenSymbol, + rewardOracleAddress: rawRewardInfo.rewardOracleAddress, + rewardPriceFeed: rawRewardInfo.rewardPriceFeed.toString(), + priceFeedDecimals: rawRewardInfo.priceFeedDecimals, + }), + ), + }; + } + + private _formatUserIncentiveData( + data: UserIncentiveData, + ): UserIncentiveDataHumanized { + return { + tokenAddress: data.tokenAddress, + incentiveControllerAddress: data.incentiveControllerAddress, + userRewardsInformation: data.userRewardsInformation.map( + (userRewardInformation: UserRewardInfo) => ({ + rewardTokenAddress: userRewardInformation.rewardTokenAddress, + rewardTokenDecimals: userRewardInformation.rewardTokenDecimals, + tokenIncentivesUserIndex: + userRewardInformation.tokenIncentivesUserIndex.toString(), + userUnclaimedRewards: + userRewardInformation.userUnclaimedRewards.toString(), + rewardTokenSymbol: userRewardInformation.rewardTokenSymbol, + rewardOracleAddress: userRewardInformation.rewardOracleAddress, + rewardPriceFeed: userRewardInformation.rewardPriceFeed.toString(), + priceFeedDecimals: userRewardInformation.priceFeedDecimals, + }), + ), + }; + } +} diff --git a/packages/contract-helpers/src/UiIncentiveDataProviderV3-contract/typechain/UiIncentiveDataProviderV3.ts b/packages/contract-helpers/src/UiIncentiveDataProviderV3-contract/typechain/UiIncentiveDataProviderV3.ts new file mode 100644 index 00000000..ce572d7e --- /dev/null +++ b/packages/contract-helpers/src/UiIncentiveDataProviderV3-contract/typechain/UiIncentiveDataProviderV3.ts @@ -0,0 +1,347 @@ +/* Autogenerated file. Do not edit manually. */ +/* eslint-disable */ +import type { + BaseContract, + BigNumber, + BigNumberish, + 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 IUiIncentiveDataProviderV3 { + export type RewardInfoStruct = { + rewardTokenSymbol: string; + rewardTokenAddress: string; + rewardOracleAddress: string; + emissionPerSecond: BigNumberish; + incentivesLastUpdateTimestamp: BigNumberish; + tokenIncentivesIndex: BigNumberish; + emissionEndTimestamp: BigNumberish; + rewardPriceFeed: BigNumberish; + rewardTokenDecimals: BigNumberish; + precision: BigNumberish; + priceFeedDecimals: BigNumberish; + }; + + export type RewardInfoStructOutput = [ + string, + string, + string, + BigNumber, + BigNumber, + BigNumber, + BigNumber, + BigNumber, + number, + number, + number, + ] & { + rewardTokenSymbol: string; + rewardTokenAddress: string; + rewardOracleAddress: string; + emissionPerSecond: BigNumber; + incentivesLastUpdateTimestamp: BigNumber; + tokenIncentivesIndex: BigNumber; + emissionEndTimestamp: BigNumber; + rewardPriceFeed: BigNumber; + rewardTokenDecimals: number; + precision: number; + priceFeedDecimals: number; + }; + + export type IncentiveDataStruct = { + tokenAddress: string; + incentiveControllerAddress: string; + rewardsTokenInformation: IUiIncentiveDataProviderV3.RewardInfoStruct[]; + }; + + export type IncentiveDataStructOutput = [ + string, + string, + IUiIncentiveDataProviderV3.RewardInfoStructOutput[], + ] & { + tokenAddress: string; + incentiveControllerAddress: string; + rewardsTokenInformation: IUiIncentiveDataProviderV3.RewardInfoStructOutput[]; + }; + + export type AggregatedReserveIncentiveDataStruct = { + underlyingAsset: string; + aIncentiveData: IUiIncentiveDataProviderV3.IncentiveDataStruct; + vIncentiveData: IUiIncentiveDataProviderV3.IncentiveDataStruct; + }; + + export type AggregatedReserveIncentiveDataStructOutput = [ + string, + IUiIncentiveDataProviderV3.IncentiveDataStructOutput, + IUiIncentiveDataProviderV3.IncentiveDataStructOutput, + ] & { + underlyingAsset: string; + aIncentiveData: IUiIncentiveDataProviderV3.IncentiveDataStructOutput; + vIncentiveData: IUiIncentiveDataProviderV3.IncentiveDataStructOutput; + }; + + export type UserRewardInfoStruct = { + rewardTokenSymbol: string; + rewardOracleAddress: string; + rewardTokenAddress: string; + userUnclaimedRewards: BigNumberish; + tokenIncentivesUserIndex: BigNumberish; + rewardPriceFeed: BigNumberish; + priceFeedDecimals: BigNumberish; + rewardTokenDecimals: BigNumberish; + }; + + export type UserRewardInfoStructOutput = [ + string, + string, + string, + BigNumber, + BigNumber, + BigNumber, + number, + number, + ] & { + rewardTokenSymbol: string; + rewardOracleAddress: string; + rewardTokenAddress: string; + userUnclaimedRewards: BigNumber; + tokenIncentivesUserIndex: BigNumber; + rewardPriceFeed: BigNumber; + priceFeedDecimals: number; + rewardTokenDecimals: number; + }; + + export type UserIncentiveDataStruct = { + tokenAddress: string; + incentiveControllerAddress: string; + userRewardsInformation: IUiIncentiveDataProviderV3.UserRewardInfoStruct[]; + }; + + export type UserIncentiveDataStructOutput = [ + string, + string, + IUiIncentiveDataProviderV3.UserRewardInfoStructOutput[], + ] & { + tokenAddress: string; + incentiveControllerAddress: string; + userRewardsInformation: IUiIncentiveDataProviderV3.UserRewardInfoStructOutput[]; + }; + + export type UserReserveIncentiveDataStruct = { + underlyingAsset: string; + aTokenIncentivesUserData: IUiIncentiveDataProviderV3.UserIncentiveDataStruct; + vTokenIncentivesUserData: IUiIncentiveDataProviderV3.UserIncentiveDataStruct; + }; + + export type UserReserveIncentiveDataStructOutput = [ + string, + IUiIncentiveDataProviderV3.UserIncentiveDataStructOutput, + IUiIncentiveDataProviderV3.UserIncentiveDataStructOutput, + ] & { + underlyingAsset: string; + aTokenIncentivesUserData: IUiIncentiveDataProviderV3.UserIncentiveDataStructOutput; + vTokenIncentivesUserData: IUiIncentiveDataProviderV3.UserIncentiveDataStructOutput; + }; +} + +export interface UiIncentiveDataProviderV3Interface extends utils.Interface { + functions: { + 'getFullReservesIncentiveData(address,address)': FunctionFragment; + 'getReservesIncentivesData(address)': FunctionFragment; + 'getUserReservesIncentivesData(address,address)': FunctionFragment; + }; + + getFunction( + nameOrSignatureOrTopic: + | 'getFullReservesIncentiveData' + | 'getReservesIncentivesData' + | 'getUserReservesIncentivesData', + ): FunctionFragment; + + encodeFunctionData( + functionFragment: 'getFullReservesIncentiveData', + values: [string, string], + ): string; + encodeFunctionData( + functionFragment: 'getReservesIncentivesData', + values: [string], + ): string; + encodeFunctionData( + functionFragment: 'getUserReservesIncentivesData', + values: [string, string], + ): string; + + decodeFunctionResult( + functionFragment: 'getFullReservesIncentiveData', + data: BytesLike, + ): Result; + decodeFunctionResult( + functionFragment: 'getReservesIncentivesData', + data: BytesLike, + ): Result; + decodeFunctionResult( + functionFragment: 'getUserReservesIncentivesData', + data: BytesLike, + ): Result; + + events: {}; +} + +export interface UiIncentiveDataProviderV3 extends BaseContract { + connect(signerOrProvider: Signer | Provider | string): this; + attach(addressOrName: string): this; + deployed(): Promise; + + interface: UiIncentiveDataProviderV3Interface; + + 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: { + getFullReservesIncentiveData( + provider: string, + user: string, + overrides?: CallOverrides, + ): Promise< + [ + IUiIncentiveDataProviderV3.AggregatedReserveIncentiveDataStructOutput[], + IUiIncentiveDataProviderV3.UserReserveIncentiveDataStructOutput[], + ] + >; + + getReservesIncentivesData( + provider: string, + overrides?: CallOverrides, + ): Promise< + [IUiIncentiveDataProviderV3.AggregatedReserveIncentiveDataStructOutput[]] + >; + + getUserReservesIncentivesData( + provider: string, + user: string, + overrides?: CallOverrides, + ): Promise< + [IUiIncentiveDataProviderV3.UserReserveIncentiveDataStructOutput[]] + >; + }; + + getFullReservesIncentiveData( + provider: string, + user: string, + overrides?: CallOverrides, + ): Promise< + [ + IUiIncentiveDataProviderV3.AggregatedReserveIncentiveDataStructOutput[], + IUiIncentiveDataProviderV3.UserReserveIncentiveDataStructOutput[], + ] + >; + + getReservesIncentivesData( + provider: string, + overrides?: CallOverrides, + ): Promise< + IUiIncentiveDataProviderV3.AggregatedReserveIncentiveDataStructOutput[] + >; + + getUserReservesIncentivesData( + provider: string, + user: string, + overrides?: CallOverrides, + ): Promise; + + callStatic: { + getFullReservesIncentiveData( + provider: string, + user: string, + overrides?: CallOverrides, + ): Promise< + [ + IUiIncentiveDataProviderV3.AggregatedReserveIncentiveDataStructOutput[], + IUiIncentiveDataProviderV3.UserReserveIncentiveDataStructOutput[], + ] + >; + + getReservesIncentivesData( + provider: string, + overrides?: CallOverrides, + ): Promise< + IUiIncentiveDataProviderV3.AggregatedReserveIncentiveDataStructOutput[] + >; + + getUserReservesIncentivesData( + provider: string, + user: string, + overrides?: CallOverrides, + ): Promise< + IUiIncentiveDataProviderV3.UserReserveIncentiveDataStructOutput[] + >; + }; + + filters: {}; + + estimateGas: { + getFullReservesIncentiveData( + provider: string, + user: string, + overrides?: CallOverrides, + ): Promise; + + getReservesIncentivesData( + provider: string, + overrides?: CallOverrides, + ): Promise; + + getUserReservesIncentivesData( + provider: string, + user: string, + overrides?: CallOverrides, + ): Promise; + }; + + populateTransaction: { + getFullReservesIncentiveData( + provider: string, + user: string, + overrides?: CallOverrides, + ): Promise; + + getReservesIncentivesData( + provider: string, + overrides?: CallOverrides, + ): Promise; + + getUserReservesIncentivesData( + provider: string, + user: string, + overrides?: CallOverrides, + ): Promise; + }; +} diff --git a/packages/contract-helpers/src/UiIncentiveDataProviderV3-contract/typechain/UiIncentiveDataProviderV3__factory.ts b/packages/contract-helpers/src/UiIncentiveDataProviderV3-contract/typechain/UiIncentiveDataProviderV3__factory.ts new file mode 100644 index 00000000..89adfc5f --- /dev/null +++ b/packages/contract-helpers/src/UiIncentiveDataProviderV3-contract/typechain/UiIncentiveDataProviderV3__factory.ts @@ -0,0 +1,709 @@ +/* Autogenerated file. Do not edit manually. */ +/* eslint-disable */ + +import { Contract, Signer, utils } from 'ethers'; +import type { Provider } from '@ethersproject/providers'; +import type { + UiIncentiveDataProviderV3, + UiIncentiveDataProviderV3Interface, +} from '../UiIncentiveDataProviderV3'; + +const _abi = [ + { + inputs: [ + { + internalType: 'contract IPoolAddressesProvider', + name: 'provider', + type: 'address', + }, + { + internalType: 'address', + name: 'user', + type: 'address', + }, + ], + name: 'getFullReservesIncentiveData', + outputs: [ + { + components: [ + { + internalType: 'address', + name: 'underlyingAsset', + type: 'address', + }, + { + components: [ + { + internalType: 'address', + name: 'tokenAddress', + type: 'address', + }, + { + internalType: 'address', + name: 'incentiveControllerAddress', + type: 'address', + }, + { + components: [ + { + internalType: 'string', + name: 'rewardTokenSymbol', + type: 'string', + }, + { + internalType: 'address', + name: 'rewardTokenAddress', + type: 'address', + }, + { + internalType: 'address', + name: 'rewardOracleAddress', + type: 'address', + }, + { + internalType: 'uint256', + name: 'emissionPerSecond', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'incentivesLastUpdateTimestamp', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'tokenIncentivesIndex', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'emissionEndTimestamp', + type: 'uint256', + }, + { + internalType: 'int256', + name: 'rewardPriceFeed', + type: 'int256', + }, + { + internalType: 'uint8', + name: 'rewardTokenDecimals', + type: 'uint8', + }, + { + internalType: 'uint8', + name: 'precision', + type: 'uint8', + }, + { + internalType: 'uint8', + name: 'priceFeedDecimals', + type: 'uint8', + }, + ], + internalType: 'struct IUiIncentiveDataProviderV3.RewardInfo[]', + name: 'rewardsTokenInformation', + type: 'tuple[]', + }, + ], + internalType: 'struct IUiIncentiveDataProviderV3.IncentiveData', + name: 'aIncentiveData', + type: 'tuple', + }, + { + components: [ + { + internalType: 'address', + name: 'tokenAddress', + type: 'address', + }, + { + internalType: 'address', + name: 'incentiveControllerAddress', + type: 'address', + }, + { + components: [ + { + internalType: 'string', + name: 'rewardTokenSymbol', + type: 'string', + }, + { + internalType: 'address', + name: 'rewardTokenAddress', + type: 'address', + }, + { + internalType: 'address', + name: 'rewardOracleAddress', + type: 'address', + }, + { + internalType: 'uint256', + name: 'emissionPerSecond', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'incentivesLastUpdateTimestamp', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'tokenIncentivesIndex', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'emissionEndTimestamp', + type: 'uint256', + }, + { + internalType: 'int256', + name: 'rewardPriceFeed', + type: 'int256', + }, + { + internalType: 'uint8', + name: 'rewardTokenDecimals', + type: 'uint8', + }, + { + internalType: 'uint8', + name: 'precision', + type: 'uint8', + }, + { + internalType: 'uint8', + name: 'priceFeedDecimals', + type: 'uint8', + }, + ], + internalType: 'struct IUiIncentiveDataProviderV3.RewardInfo[]', + name: 'rewardsTokenInformation', + type: 'tuple[]', + }, + ], + internalType: 'struct IUiIncentiveDataProviderV3.IncentiveData', + name: 'vIncentiveData', + type: 'tuple', + }, + ], + internalType: + 'struct IUiIncentiveDataProviderV3.AggregatedReserveIncentiveData[]', + name: '', + type: 'tuple[]', + }, + { + components: [ + { + internalType: 'address', + name: 'underlyingAsset', + type: 'address', + }, + { + components: [ + { + internalType: 'address', + name: 'tokenAddress', + type: 'address', + }, + { + internalType: 'address', + name: 'incentiveControllerAddress', + type: 'address', + }, + { + components: [ + { + internalType: 'string', + name: 'rewardTokenSymbol', + type: 'string', + }, + { + internalType: 'address', + name: 'rewardOracleAddress', + type: 'address', + }, + { + internalType: 'address', + name: 'rewardTokenAddress', + type: 'address', + }, + { + internalType: 'uint256', + name: 'userUnclaimedRewards', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'tokenIncentivesUserIndex', + type: 'uint256', + }, + { + internalType: 'int256', + name: 'rewardPriceFeed', + type: 'int256', + }, + { + internalType: 'uint8', + name: 'priceFeedDecimals', + type: 'uint8', + }, + { + internalType: 'uint8', + name: 'rewardTokenDecimals', + type: 'uint8', + }, + ], + internalType: + 'struct IUiIncentiveDataProviderV3.UserRewardInfo[]', + name: 'userRewardsInformation', + type: 'tuple[]', + }, + ], + internalType: 'struct IUiIncentiveDataProviderV3.UserIncentiveData', + name: 'aTokenIncentivesUserData', + type: 'tuple', + }, + { + components: [ + { + internalType: 'address', + name: 'tokenAddress', + type: 'address', + }, + { + internalType: 'address', + name: 'incentiveControllerAddress', + type: 'address', + }, + { + components: [ + { + internalType: 'string', + name: 'rewardTokenSymbol', + type: 'string', + }, + { + internalType: 'address', + name: 'rewardOracleAddress', + type: 'address', + }, + { + internalType: 'address', + name: 'rewardTokenAddress', + type: 'address', + }, + { + internalType: 'uint256', + name: 'userUnclaimedRewards', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'tokenIncentivesUserIndex', + type: 'uint256', + }, + { + internalType: 'int256', + name: 'rewardPriceFeed', + type: 'int256', + }, + { + internalType: 'uint8', + name: 'priceFeedDecimals', + type: 'uint8', + }, + { + internalType: 'uint8', + name: 'rewardTokenDecimals', + type: 'uint8', + }, + ], + internalType: + 'struct IUiIncentiveDataProviderV3.UserRewardInfo[]', + name: 'userRewardsInformation', + type: 'tuple[]', + }, + ], + internalType: 'struct IUiIncentiveDataProviderV3.UserIncentiveData', + name: 'vTokenIncentivesUserData', + type: 'tuple', + }, + ], + internalType: + 'struct IUiIncentiveDataProviderV3.UserReserveIncentiveData[]', + name: '', + type: 'tuple[]', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'contract IPoolAddressesProvider', + name: 'provider', + type: 'address', + }, + ], + name: 'getReservesIncentivesData', + outputs: [ + { + components: [ + { + internalType: 'address', + name: 'underlyingAsset', + type: 'address', + }, + { + components: [ + { + internalType: 'address', + name: 'tokenAddress', + type: 'address', + }, + { + internalType: 'address', + name: 'incentiveControllerAddress', + type: 'address', + }, + { + components: [ + { + internalType: 'string', + name: 'rewardTokenSymbol', + type: 'string', + }, + { + internalType: 'address', + name: 'rewardTokenAddress', + type: 'address', + }, + { + internalType: 'address', + name: 'rewardOracleAddress', + type: 'address', + }, + { + internalType: 'uint256', + name: 'emissionPerSecond', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'incentivesLastUpdateTimestamp', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'tokenIncentivesIndex', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'emissionEndTimestamp', + type: 'uint256', + }, + { + internalType: 'int256', + name: 'rewardPriceFeed', + type: 'int256', + }, + { + internalType: 'uint8', + name: 'rewardTokenDecimals', + type: 'uint8', + }, + { + internalType: 'uint8', + name: 'precision', + type: 'uint8', + }, + { + internalType: 'uint8', + name: 'priceFeedDecimals', + type: 'uint8', + }, + ], + internalType: 'struct IUiIncentiveDataProviderV3.RewardInfo[]', + name: 'rewardsTokenInformation', + type: 'tuple[]', + }, + ], + internalType: 'struct IUiIncentiveDataProviderV3.IncentiveData', + name: 'aIncentiveData', + type: 'tuple', + }, + { + components: [ + { + internalType: 'address', + name: 'tokenAddress', + type: 'address', + }, + { + internalType: 'address', + name: 'incentiveControllerAddress', + type: 'address', + }, + { + components: [ + { + internalType: 'string', + name: 'rewardTokenSymbol', + type: 'string', + }, + { + internalType: 'address', + name: 'rewardTokenAddress', + type: 'address', + }, + { + internalType: 'address', + name: 'rewardOracleAddress', + type: 'address', + }, + { + internalType: 'uint256', + name: 'emissionPerSecond', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'incentivesLastUpdateTimestamp', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'tokenIncentivesIndex', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'emissionEndTimestamp', + type: 'uint256', + }, + { + internalType: 'int256', + name: 'rewardPriceFeed', + type: 'int256', + }, + { + internalType: 'uint8', + name: 'rewardTokenDecimals', + type: 'uint8', + }, + { + internalType: 'uint8', + name: 'precision', + type: 'uint8', + }, + { + internalType: 'uint8', + name: 'priceFeedDecimals', + type: 'uint8', + }, + ], + internalType: 'struct IUiIncentiveDataProviderV3.RewardInfo[]', + name: 'rewardsTokenInformation', + type: 'tuple[]', + }, + ], + internalType: 'struct IUiIncentiveDataProviderV3.IncentiveData', + name: 'vIncentiveData', + type: 'tuple', + }, + ], + internalType: + 'struct IUiIncentiveDataProviderV3.AggregatedReserveIncentiveData[]', + name: '', + type: 'tuple[]', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'contract IPoolAddressesProvider', + name: 'provider', + type: 'address', + }, + { + internalType: 'address', + name: 'user', + type: 'address', + }, + ], + name: 'getUserReservesIncentivesData', + outputs: [ + { + components: [ + { + internalType: 'address', + name: 'underlyingAsset', + type: 'address', + }, + { + components: [ + { + internalType: 'address', + name: 'tokenAddress', + type: 'address', + }, + { + internalType: 'address', + name: 'incentiveControllerAddress', + type: 'address', + }, + { + components: [ + { + internalType: 'string', + name: 'rewardTokenSymbol', + type: 'string', + }, + { + internalType: 'address', + name: 'rewardOracleAddress', + type: 'address', + }, + { + internalType: 'address', + name: 'rewardTokenAddress', + type: 'address', + }, + { + internalType: 'uint256', + name: 'userUnclaimedRewards', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'tokenIncentivesUserIndex', + type: 'uint256', + }, + { + internalType: 'int256', + name: 'rewardPriceFeed', + type: 'int256', + }, + { + internalType: 'uint8', + name: 'priceFeedDecimals', + type: 'uint8', + }, + { + internalType: 'uint8', + name: 'rewardTokenDecimals', + type: 'uint8', + }, + ], + internalType: + 'struct IUiIncentiveDataProviderV3.UserRewardInfo[]', + name: 'userRewardsInformation', + type: 'tuple[]', + }, + ], + internalType: 'struct IUiIncentiveDataProviderV3.UserIncentiveData', + name: 'aTokenIncentivesUserData', + type: 'tuple', + }, + { + components: [ + { + internalType: 'address', + name: 'tokenAddress', + type: 'address', + }, + { + internalType: 'address', + name: 'incentiveControllerAddress', + type: 'address', + }, + { + components: [ + { + internalType: 'string', + name: 'rewardTokenSymbol', + type: 'string', + }, + { + internalType: 'address', + name: 'rewardOracleAddress', + type: 'address', + }, + { + internalType: 'address', + name: 'rewardTokenAddress', + type: 'address', + }, + { + internalType: 'uint256', + name: 'userUnclaimedRewards', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'tokenIncentivesUserIndex', + type: 'uint256', + }, + { + internalType: 'int256', + name: 'rewardPriceFeed', + type: 'int256', + }, + { + internalType: 'uint8', + name: 'priceFeedDecimals', + type: 'uint8', + }, + { + internalType: 'uint8', + name: 'rewardTokenDecimals', + type: 'uint8', + }, + ], + internalType: + 'struct IUiIncentiveDataProviderV3.UserRewardInfo[]', + name: 'userRewardsInformation', + type: 'tuple[]', + }, + ], + internalType: 'struct IUiIncentiveDataProviderV3.UserIncentiveData', + name: 'vTokenIncentivesUserData', + type: 'tuple', + }, + ], + internalType: + 'struct IUiIncentiveDataProviderV3.UserReserveIncentiveData[]', + name: '', + type: 'tuple[]', + }, + ], + stateMutability: 'view', + type: 'function', + }, +] as const; + +export class UiIncentiveDataProviderV3__factory { + static readonly abi = _abi; + static createInterface(): UiIncentiveDataProviderV3Interface { + return new utils.Interface(_abi) as UiIncentiveDataProviderV3Interface; + } + static connect( + address: string, + signerOrProvider: Signer | Provider, + ): UiIncentiveDataProviderV3 { + return new Contract( + address, + _abi, + signerOrProvider, + ) as UiIncentiveDataProviderV3; + } +} diff --git a/packages/contract-helpers/src/UiIncentiveDataProviderV3-contract/typechain/common.ts b/packages/contract-helpers/src/UiIncentiveDataProviderV3-contract/typechain/common.ts new file mode 100644 index 00000000..0fb82cd3 --- /dev/null +++ b/packages/contract-helpers/src/UiIncentiveDataProviderV3-contract/typechain/common.ts @@ -0,0 +1,43 @@ +/* Autogenerated file. Do not edit manually. */ +/* eslint-disable */ +import type { Listener } from '@ethersproject/providers'; +import type { Event, EventFilter } from 'ethers'; + +export interface TypedEvent< + TArgsArray extends Array = 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< + infer C, + any +> + ? C + : never; + +export type GetARGsTypeFromFactory = F extends MinEthersFactory + ? Parameters + : never; diff --git a/packages/contract-helpers/src/UiIncentiveDataProviderV3-contract/types.ts b/packages/contract-helpers/src/UiIncentiveDataProviderV3-contract/types.ts new file mode 100644 index 00000000..6bdd50cc --- /dev/null +++ b/packages/contract-helpers/src/UiIncentiveDataProviderV3-contract/types.ts @@ -0,0 +1,108 @@ +import { BigNumber } from 'ethers'; + +// SmartContract response types + +export type RewardInfo = { + rewardTokenSymbol: string; + rewardTokenAddress: string; + rewardOracleAddress: string; + emissionPerSecond: BigNumber; + incentivesLastUpdateTimestamp: BigNumber; + tokenIncentivesIndex: BigNumber; + emissionEndTimestamp: BigNumber; + rewardPriceFeed: BigNumber; + rewardTokenDecimals: number; + precision: number; + priceFeedDecimals: number; +}; + +export interface IncentiveData { + tokenAddress: string; + incentiveControllerAddress: string; + rewardsTokenInformation: RewardInfo[]; +} + +export interface ReservesIncentiveData { + underlyingAsset: string; + aIncentiveData: IncentiveData; + vIncentiveData: IncentiveData; +} + +export interface UserRewardInfo { + rewardTokenSymbol: string; + rewardOracleAddress: string; + rewardTokenAddress: string; + userUnclaimedRewards: BigNumber; + tokenIncentivesUserIndex: BigNumber; + rewardPriceFeed: BigNumber; + priceFeedDecimals: number; + rewardTokenDecimals: number; +} +export interface UserIncentiveData { + tokenAddress: string; + incentiveControllerAddress: string; + userRewardsInformation: UserRewardInfo[]; +} +export interface UserReservesIncentivesData { + underlyingAsset: string; + aTokenIncentivesUserData: UserIncentiveData; + vTokenIncentivesUserData: UserIncentiveData; +} + +export interface FullReservesIncentiveDataResponse { + 0: ReservesIncentiveData[]; + 1: UserReservesIncentivesData[]; +} + +// Humanized response types + +export interface RewardInfoHumanized { + rewardTokenSymbol: string; + rewardTokenAddress: string; + rewardOracleAddress: string; + emissionPerSecond: string; + incentivesLastUpdateTimestamp: number; + tokenIncentivesIndex: string; + emissionEndTimestamp: number; + rewardPriceFeed: string; + rewardTokenDecimals: number; + precision: number; + priceFeedDecimals: number; +} + +export interface IncentiveDataHumanized { + tokenAddress: string; + incentiveControllerAddress: string; + rewardsTokenInformation: RewardInfoHumanized[]; +} + +export interface ReservesIncentiveDataHumanized { + id: string; + underlyingAsset: string; + aIncentiveData: IncentiveDataHumanized; + vIncentiveData: IncentiveDataHumanized; +} + +export interface UserRewardInfoHumanized { + rewardTokenSymbol: string; + rewardOracleAddress: string; + rewardTokenAddress: string; + userUnclaimedRewards: string; + tokenIncentivesUserIndex: string; + rewardPriceFeed: string; + priceFeedDecimals: number; + rewardTokenDecimals: number; +} + +export interface UserIncentiveDataHumanized { + tokenAddress: string; + incentiveControllerAddress: string; + userRewardsInformation: UserRewardInfoHumanized[]; +} + +export interface UserReservesIncentivesDataHumanized { + id: string; + underlyingAsset: string; + aTokenIncentivesUserData: UserIncentiveDataHumanized; + vTokenIncentivesUserData: UserIncentiveDataHumanized; +} diff --git a/packages/contract-helpers/src/UiIncentiveDataProviderV3-contract/uiIncentiveDataProviderV3.test.ts b/packages/contract-helpers/src/UiIncentiveDataProviderV3-contract/uiIncentiveDataProviderV3.test.ts new file mode 100644 index 00000000..3d8c30ee --- /dev/null +++ b/packages/contract-helpers/src/UiIncentiveDataProviderV3-contract/uiIncentiveDataProviderV3.test.ts @@ -0,0 +1,481 @@ +import { BigNumber, providers } from 'ethers'; +import { + getReservesIncentivesDataMock, + getUserIncentivesDataMock, +} from './_mocks'; +import { UiIncentiveDataProviderV3 } from './typechain/UiIncentiveDataProviderV3'; +import { UiIncentiveDataProviderV3__factory } from './typechain/UiIncentiveDataProviderV3__factory'; +import { UiIncentiveDataProvider } from './index'; + +jest.mock('../cl-feed-registry/index', () => { + const clInstance = { getPriceFeed: jest.fn() }; + const cl = jest.fn(() => clInstance); + return { ChainlinkFeedsRegistry: cl }; +}); + +describe('UiIncentiveDataProvider', () => { + const provider: providers.Provider = new providers.JsonRpcProvider(); + const user = '0x0000000000000000000000000000000000000001'; + const lendingPoolAddressProvider = + '0x0000000000000000000000000000000000000002'; + const uiIncentiveDataProviderAddress = + '0x0000000000000000000000000000000000000003'; + + describe('creating', () => { + it('Expects to initialize', () => { + const instance = new UiIncentiveDataProvider({ + uiIncentiveDataProviderAddress, + provider: new providers.JsonRpcProvider(), + chainId: 137, + }); + expect(instance instanceof UiIncentiveDataProvider).toEqual(true); + }); + }); + afterEach(() => { + jest.clearAllMocks(); + }); + describe('getFullReservesIncentiveData', () => { + const instance = new UiIncentiveDataProvider({ + uiIncentiveDataProviderAddress, + provider, + chainId: 137, + }); + it('should throw if uiIncentiveDataProvider is not a valid ethereum address', async () => { + const instance = new UiIncentiveDataProvider({ + uiIncentiveDataProviderAddress: 'asdf', + provider, + chainId: 137, + }); + await expect(async () => + instance.getFullReservesIncentiveData({ + user, + lendingPoolAddressProvider, + }), + ).rejects.toThrowError( + 'UiIncentiveDataProviderAddress must be an eth valid address', + ); + }); + it('should throw if user is not a valid ethereum address', async () => { + const user = 'asdf'; + await expect(async () => + instance.getFullReservesIncentiveData({ + user, + lendingPoolAddressProvider, + }), + ).rejects.toThrowError( + `Address: ${user} is not a valid ethereum Address`, + ); + }); + it('should throw if lending pool address is not a valid ethereum address', async () => { + const lendingPoolAddressProvider = 'asdf'; + await expect(async () => + instance.getFullReservesIncentiveData({ + user, + lendingPoolAddressProvider, + }), + ).rejects.toThrowError( + `Address: ${lendingPoolAddressProvider} is not a valid ethereum Address`, + ); + }); + it('should not throw if user and lending pool address provider is a valid ethereum address', async () => { + const spy = jest + .spyOn(UiIncentiveDataProviderV3__factory, 'connect') + .mockReturnValue({ + getFullReservesIncentiveData: async () => Promise.resolve({}), + } as unknown as UiIncentiveDataProviderV3); + await instance.getFullReservesIncentiveData({ + user, + lendingPoolAddressProvider, + }); + + expect(spy).toHaveBeenCalled(); + }); + }); + + describe('getReservesIncentivesData', () => { + const instance = new UiIncentiveDataProvider({ + uiIncentiveDataProviderAddress, + provider, + chainId: 137, + }); + afterEach(() => { + jest.clearAllMocks(); + }); + it('should throw if uiIncentiveDataProvider is not a valid ethereum address', async () => { + const instance = new UiIncentiveDataProvider({ + uiIncentiveDataProviderAddress: 'asdf', + provider, + chainId: 137, + }); + await expect(async () => + instance.getReservesIncentivesData({ lendingPoolAddressProvider }), + ).rejects.toThrowError( + 'UiIncentiveDataProviderAddress must be an eth valid address', + ); + }); + it('should throw if lending pool address is not a valid ethereum address', async () => { + const lendingPoolAddressProvider = 'asdf'; + await expect(async () => + instance.getReservesIncentivesData({ lendingPoolAddressProvider }), + ).rejects.toThrow( + `Address: ${lendingPoolAddressProvider} is not a valid ethereum Address`, + ); + }); + it('should not throw', async () => { + const spy = jest + .spyOn(UiIncentiveDataProviderV3__factory, 'connect') + .mockReturnValue({ + getReservesIncentivesData: async () => + Promise.resolve(getReservesIncentivesDataMock), + } as unknown as UiIncentiveDataProviderV3); + await instance.getReservesIncentivesData({ lendingPoolAddressProvider }); + expect(spy).toHaveBeenCalled(); + }); + }); + + describe('getUserReserves', () => { + const instance = new UiIncentiveDataProvider({ + uiIncentiveDataProviderAddress, + provider, + chainId: 137, + }); + afterEach(() => { + jest.clearAllMocks(); + }); + it('should throw if uiIncentiveDataProvider is not a valid ethereum address', async () => { + const instance = new UiIncentiveDataProvider({ + uiIncentiveDataProviderAddress: 'asdf', + provider, + chainId: 137, + }); + await expect(async () => + instance.getUserReservesIncentivesData({ + lendingPoolAddressProvider, + user, + }), + ).rejects.toThrowError( + 'UiIncentiveDataProviderAddress must be an eth valid address', + ); + }); + it('should throw if lending pool address provider is not a valid ethereum address', async () => { + const lendingPoolAddressProvider = 'asdf'; + await expect(async () => + instance.getUserReservesIncentivesData({ + lendingPoolAddressProvider, + user, + }), + ).rejects.toThrow( + `Address: ${lendingPoolAddressProvider} is not a valid ethereum Address`, + ); + }); + it('should throw if user is not a valid ethereum address', async () => { + const user = 'asdf'; + await expect(async () => + instance.getUserReservesIncentivesData({ + lendingPoolAddressProvider, + user, + }), + ).rejects.toThrow(`Address: ${user} is not a valid ethereum Address`); + }); + it('should not throw if user is a valid ethereum address', async () => { + const spy = jest + .spyOn(UiIncentiveDataProviderV3__factory, 'connect') + .mockReturnValue({ + getUserReservesIncentivesData: async () => + Promise.resolve(getUserIncentivesDataMock), + } as unknown as UiIncentiveDataProviderV3); + await instance.getUserReservesIncentivesData({ + lendingPoolAddressProvider, + user, + }); + expect(spy).toHaveBeenCalled(); + }); + }); + + describe('getReservesIncentivesDataHumanized', () => { + const instance = new UiIncentiveDataProvider({ + uiIncentiveDataProviderAddress, + provider, + chainId: 137, + }); + afterEach(() => { + jest.clearAllMocks(); + }); + it('should throw if uiIncentiveDataProvider is not a valid ethereum address', async () => { + const instance = new UiIncentiveDataProvider({ + uiIncentiveDataProviderAddress: 'asdf', + provider, + chainId: 137, + }); + await expect(async () => + instance.getReservesIncentivesDataHumanized({ + lendingPoolAddressProvider, + }), + ).rejects.toThrowError( + 'UiIncentiveDataProviderAddress must be an eth valid address', + ); + }); + it('Expects to fail if lendingPoolAddressProvider not an eth address', async () => { + const lendingPoolAddressProvider = 'asdf'; + await expect(async () => + instance.getReservesIncentivesDataHumanized({ + lendingPoolAddressProvider, + }), + ).rejects.toThrow( + `Address: ${lendingPoolAddressProvider} is not a valid ethereum Address`, + ); + }); + it('Expects to parse the incentives response to a human readable object', async () => { + const spy = jest + .spyOn(UiIncentiveDataProviderV3__factory, 'connect') + .mockReturnValue({ + getReservesIncentivesData: async () => + Promise.resolve(getReservesIncentivesDataMock), + } as unknown as UiIncentiveDataProviderV3); + const data = await instance.getReservesIncentivesDataHumanized({ + lendingPoolAddressProvider, + }); + expect(spy).toHaveBeenCalled(); + expect(data).toEqual([ + { + id: '137-0xb04aaa2a73ff3d88950bdf19eb4ac029630a2367-0x0000000000000000000000000000000000000002', + underlyingAsset: + '0xb04Aaa2A73ff3D88950BdF19Eb4AC029630a2367'.toLowerCase(), + aIncentiveData: { + tokenAddress: '0x6d0eeb7b37BF26E182EB9a8631DCF79e4EF43DDd', + incentiveControllerAddress: + '0x5465485D7b15CaBc9196E73A0b1cc457262079e3', + rewardsTokenInformation: [ + { + rewardTokenSymbol: 'REW', + rewardTokenAddress: + '0x1f689325CBdF44B24DBE2ecC2b1fFD4130861b4E', + rewardOracleAddress: + '0xca8e9B5F9e36EbF74096223fc48810861b4FA642', + emissionPerSecond: BigNumber.from({ + _hex: '0x04464ecbc45ffe', + _isBigNumber: true, + }).toString(), + incentivesLastUpdateTimestamp: BigNumber.from({ + _hex: '0x61a5167a', + _isBigNumber: true, + }).toNumber(), + tokenIncentivesIndex: BigNumber.from({ + _hex: '0x00', + _isBigNumber: true, + }).toString(), + emissionEndTimestamp: BigNumber.from({ + _hex: '0x638649fa', + _isBigNumber: true, + }).toNumber(), + rewardPriceFeed: BigNumber.from({ + _hex: '0x05f5e100', + _isBigNumber: true, + }).toString(), + rewardTokenDecimals: 18, + precision: 18, + priceFeedDecimals: 0, + }, + ], + }, + vIncentiveData: { + tokenAddress: '0xaD99ef885623E8520f631625b2675d6dAd3aaDC1', + incentiveControllerAddress: + '0x5465485D7b15CaBc9196E73A0b1cc457262079e3', + rewardsTokenInformation: [ + { + rewardTokenSymbol: 'REW', + rewardTokenAddress: + '0x1f689325CBdF44B24DBE2ecC2b1fFD4130861b4E', + rewardOracleAddress: + '0xca8e9B5F9e36EbF74096223fc48810861b4FA642', + emissionPerSecond: BigNumber.from({ + _hex: '0x04464ecbc45ffe', + _isBigNumber: true, + }).toString(), + incentivesLastUpdateTimestamp: BigNumber.from({ + _hex: '0x61a5167a', + _isBigNumber: true, + }).toNumber(), + tokenIncentivesIndex: BigNumber.from({ + _hex: '0x00', + _isBigNumber: true, + }).toString(), + emissionEndTimestamp: BigNumber.from({ + _hex: '0x638649fa', + _isBigNumber: true, + }).toNumber(), + rewardPriceFeed: BigNumber.from({ + _hex: '0x05f5e100', + _isBigNumber: true, + }).toString(), + rewardTokenDecimals: 18, + precision: 18, + priceFeedDecimals: 0, + }, + ], + }, + sIncentiveData: { + tokenAddress: '0xb2007801F8c9dB4241E12C81E9d83741d14d7227', + incentiveControllerAddress: + '0x5465485D7b15CaBc9196E73A0b1cc457262079e3', + rewardsTokenInformation: [ + { + rewardTokenSymbol: 'REW', + rewardTokenAddress: + '0x1f689325CBdF44B24DBE2ecC2b1fFD4130861b4E', + rewardOracleAddress: + '0xca8e9B5F9e36EbF74096223fc48810861b4FA642', + emissionPerSecond: BigNumber.from({ + _hex: '0x04464ecbc45ffe', + _isBigNumber: true, + }).toString(), + incentivesLastUpdateTimestamp: BigNumber.from({ + _hex: '0x61a5167a', + _isBigNumber: true, + }).toNumber(), + tokenIncentivesIndex: BigNumber.from({ + _hex: '0x00', + _isBigNumber: true, + }).toString(), + emissionEndTimestamp: BigNumber.from({ + _hex: '0x638649fa', + _isBigNumber: true, + }).toNumber(), + rewardPriceFeed: BigNumber.from({ + _hex: '0x05f5e100', + _isBigNumber: true, + }).toString(), + rewardTokenDecimals: 18, + precision: 18, + priceFeedDecimals: 0, + }, + ], + }, + }, + ]); + }); + }); + + describe('getUserReservesIncentivesDataHumanized', () => { + const instance = new UiIncentiveDataProvider({ + uiIncentiveDataProviderAddress, + provider, + chainId: 137, + }); + afterEach(() => { + jest.clearAllMocks(); + }); + it('should throw if uiIncentiveDataProvider is not a valid ethereum address', async () => { + const instance = new UiIncentiveDataProvider({ + uiIncentiveDataProviderAddress: 'asdf', + provider, + chainId: 137, + }); + await expect(async () => + instance.getUserReservesIncentivesDataHumanized({ + lendingPoolAddressProvider, + user, + }), + ).rejects.toThrowError( + 'UiIncentiveDataProviderAddress must be an eth valid address', + ); + }); + it('Expects to fail if lendingPoolAddressProvider not an eth address', async () => { + const lendingPoolAddressProvider = 'asdf'; + await expect(async () => + instance.getUserReservesIncentivesDataHumanized({ + lendingPoolAddressProvider, + user, + }), + ).rejects.toThrow( + `Address: ${lendingPoolAddressProvider} is not a valid ethereum Address`, + ); + }); + it('Expects to fail if user not an eth address', async () => { + const user = 'asdf'; + await expect(async () => + instance.getUserReservesIncentivesDataHumanized({ + lendingPoolAddressProvider, + user, + }), + ).rejects.toThrow(`Address: ${user} is not a valid ethereum Address`); + }); + it('should work with finding only', async () => { + const spy = jest + .spyOn(UiIncentiveDataProviderV3__factory, 'connect') + .mockReturnValue({ + getUserReservesIncentivesData: async () => + Promise.resolve(getUserIncentivesDataMock), + } as unknown as UiIncentiveDataProviderV3); + const response = await instance.getUserReservesIncentivesDataHumanized({ + lendingPoolAddressProvider, + user, + }); + expect(spy).toHaveBeenCalled(); + expect(response).toEqual([ + { + id: '137-0x0000000000000000000000000000000000000001-0xb04aaa2a73ff3d88950bdf19eb4ac029630a2367-0x0000000000000000000000000000000000000002', + underlyingAsset: + '0xb04Aaa2A73ff3D88950BdF19Eb4AC029630a2367'.toLowerCase(), + aTokenIncentivesUserData: { + tokenAddress: '0x6d0eeb7b37BF26E182EB9a8631DCF79e4EF43DDd', + incentiveControllerAddress: + '0x5465485D7b15CaBc9196E73A0b1cc457262079e3', + userRewardsInformation: [ + { + rewardTokenSymbol: 'REW', + rewardOracleAddress: + '0xca8e9B5F9e36EbF74096223fc48810861b4FA642', + rewardTokenAddress: + '0x1f689325CBdF44B24DBE2ecC2b1fFD4130861b4E', + userUnclaimedRewards: BigNumber.from({ + _hex: '0x00', + _isBigNumber: true, + }).toString(), + tokenIncentivesUserIndex: BigNumber.from({ + _hex: '0x00', + _isBigNumber: true, + }).toString(), + rewardPriceFeed: BigNumber.from({ + _hex: '0x05f5e100', + _isBigNumber: true, + }).toString(), + priceFeedDecimals: 0, + rewardTokenDecimals: 18, + }, + ], + }, + vTokenIncentivesUserData: { + tokenAddress: '0xaD99ef885623E8520f631625b2675d6dAd3aaDC1', + incentiveControllerAddress: + '0x5465485D7b15CaBc9196E73A0b1cc457262079e3', + userRewardsInformation: [ + { + rewardTokenSymbol: 'REW', + rewardOracleAddress: + '0xca8e9B5F9e36EbF74096223fc48810861b4FA642', + rewardTokenAddress: + '0x1f689325CBdF44B24DBE2ecC2b1fFD4130861b4E', + userUnclaimedRewards: BigNumber.from({ + _hex: '0x00', + _isBigNumber: true, + }).toString(), + tokenIncentivesUserIndex: BigNumber.from({ + _hex: '0x00', + _isBigNumber: true, + }).toString(), + rewardPriceFeed: BigNumber.from({ + _hex: '0x05f5e100', + _isBigNumber: true, + }).toString(), + priceFeedDecimals: 0, + rewardTokenDecimals: 18, + }, + ], + }, + }, + ]); + }); + }); +}); diff --git a/packages/contract-types/src/abis/UiIncentiveDataProviderV3.json b/packages/contract-types/src/abis/UiIncentiveDataProviderV3.json new file mode 100644 index 00000000..fd544e8c --- /dev/null +++ b/packages/contract-types/src/abis/UiIncentiveDataProviderV3.json @@ -0,0 +1,666 @@ +[ + { + "inputs": [ + { + "internalType": "contract IPoolAddressesProvider", + "name": "provider", + "type": "address" + }, + { "internalType": "address", "name": "user", "type": "address" } + ], + "name": "getFullReservesIncentiveData", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "underlyingAsset", + "type": "address" + }, + { + "components": [ + { + "internalType": "address", + "name": "tokenAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "incentiveControllerAddress", + "type": "address" + }, + { + "components": [ + { + "internalType": "string", + "name": "rewardTokenSymbol", + "type": "string" + }, + { + "internalType": "address", + "name": "rewardTokenAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "rewardOracleAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "emissionPerSecond", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "incentivesLastUpdateTimestamp", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenIncentivesIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "emissionEndTimestamp", + "type": "uint256" + }, + { + "internalType": "int256", + "name": "rewardPriceFeed", + "type": "int256" + }, + { + "internalType": "uint8", + "name": "rewardTokenDecimals", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "precision", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "priceFeedDecimals", + "type": "uint8" + } + ], + "internalType": "struct IUiIncentiveDataProviderV3.RewardInfo[]", + "name": "rewardsTokenInformation", + "type": "tuple[]" + } + ], + "internalType": "struct IUiIncentiveDataProviderV3.IncentiveData", + "name": "aIncentiveData", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "address", + "name": "tokenAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "incentiveControllerAddress", + "type": "address" + }, + { + "components": [ + { + "internalType": "string", + "name": "rewardTokenSymbol", + "type": "string" + }, + { + "internalType": "address", + "name": "rewardTokenAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "rewardOracleAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "emissionPerSecond", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "incentivesLastUpdateTimestamp", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenIncentivesIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "emissionEndTimestamp", + "type": "uint256" + }, + { + "internalType": "int256", + "name": "rewardPriceFeed", + "type": "int256" + }, + { + "internalType": "uint8", + "name": "rewardTokenDecimals", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "precision", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "priceFeedDecimals", + "type": "uint8" + } + ], + "internalType": "struct IUiIncentiveDataProviderV3.RewardInfo[]", + "name": "rewardsTokenInformation", + "type": "tuple[]" + } + ], + "internalType": "struct IUiIncentiveDataProviderV3.IncentiveData", + "name": "vIncentiveData", + "type": "tuple" + } + ], + "internalType": "struct IUiIncentiveDataProviderV3.AggregatedReserveIncentiveData[]", + "name": "", + "type": "tuple[]" + }, + { + "components": [ + { + "internalType": "address", + "name": "underlyingAsset", + "type": "address" + }, + { + "components": [ + { + "internalType": "address", + "name": "tokenAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "incentiveControllerAddress", + "type": "address" + }, + { + "components": [ + { + "internalType": "string", + "name": "rewardTokenSymbol", + "type": "string" + }, + { + "internalType": "address", + "name": "rewardOracleAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "rewardTokenAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "userUnclaimedRewards", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenIncentivesUserIndex", + "type": "uint256" + }, + { + "internalType": "int256", + "name": "rewardPriceFeed", + "type": "int256" + }, + { + "internalType": "uint8", + "name": "priceFeedDecimals", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "rewardTokenDecimals", + "type": "uint8" + } + ], + "internalType": "struct IUiIncentiveDataProviderV3.UserRewardInfo[]", + "name": "userRewardsInformation", + "type": "tuple[]" + } + ], + "internalType": "struct IUiIncentiveDataProviderV3.UserIncentiveData", + "name": "aTokenIncentivesUserData", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "address", + "name": "tokenAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "incentiveControllerAddress", + "type": "address" + }, + { + "components": [ + { + "internalType": "string", + "name": "rewardTokenSymbol", + "type": "string" + }, + { + "internalType": "address", + "name": "rewardOracleAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "rewardTokenAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "userUnclaimedRewards", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenIncentivesUserIndex", + "type": "uint256" + }, + { + "internalType": "int256", + "name": "rewardPriceFeed", + "type": "int256" + }, + { + "internalType": "uint8", + "name": "priceFeedDecimals", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "rewardTokenDecimals", + "type": "uint8" + } + ], + "internalType": "struct IUiIncentiveDataProviderV3.UserRewardInfo[]", + "name": "userRewardsInformation", + "type": "tuple[]" + } + ], + "internalType": "struct IUiIncentiveDataProviderV3.UserIncentiveData", + "name": "vTokenIncentivesUserData", + "type": "tuple" + } + ], + "internalType": "struct IUiIncentiveDataProviderV3.UserReserveIncentiveData[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IPoolAddressesProvider", + "name": "provider", + "type": "address" + } + ], + "name": "getReservesIncentivesData", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "underlyingAsset", + "type": "address" + }, + { + "components": [ + { + "internalType": "address", + "name": "tokenAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "incentiveControllerAddress", + "type": "address" + }, + { + "components": [ + { + "internalType": "string", + "name": "rewardTokenSymbol", + "type": "string" + }, + { + "internalType": "address", + "name": "rewardTokenAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "rewardOracleAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "emissionPerSecond", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "incentivesLastUpdateTimestamp", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenIncentivesIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "emissionEndTimestamp", + "type": "uint256" + }, + { + "internalType": "int256", + "name": "rewardPriceFeed", + "type": "int256" + }, + { + "internalType": "uint8", + "name": "rewardTokenDecimals", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "precision", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "priceFeedDecimals", + "type": "uint8" + } + ], + "internalType": "struct IUiIncentiveDataProviderV3.RewardInfo[]", + "name": "rewardsTokenInformation", + "type": "tuple[]" + } + ], + "internalType": "struct IUiIncentiveDataProviderV3.IncentiveData", + "name": "aIncentiveData", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "address", + "name": "tokenAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "incentiveControllerAddress", + "type": "address" + }, + { + "components": [ + { + "internalType": "string", + "name": "rewardTokenSymbol", + "type": "string" + }, + { + "internalType": "address", + "name": "rewardTokenAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "rewardOracleAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "emissionPerSecond", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "incentivesLastUpdateTimestamp", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenIncentivesIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "emissionEndTimestamp", + "type": "uint256" + }, + { + "internalType": "int256", + "name": "rewardPriceFeed", + "type": "int256" + }, + { + "internalType": "uint8", + "name": "rewardTokenDecimals", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "precision", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "priceFeedDecimals", + "type": "uint8" + } + ], + "internalType": "struct IUiIncentiveDataProviderV3.RewardInfo[]", + "name": "rewardsTokenInformation", + "type": "tuple[]" + } + ], + "internalType": "struct IUiIncentiveDataProviderV3.IncentiveData", + "name": "vIncentiveData", + "type": "tuple" + } + ], + "internalType": "struct IUiIncentiveDataProviderV3.AggregatedReserveIncentiveData[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IPoolAddressesProvider", + "name": "provider", + "type": "address" + }, + { "internalType": "address", "name": "user", "type": "address" } + ], + "name": "getUserReservesIncentivesData", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "underlyingAsset", + "type": "address" + }, + { + "components": [ + { + "internalType": "address", + "name": "tokenAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "incentiveControllerAddress", + "type": "address" + }, + { + "components": [ + { + "internalType": "string", + "name": "rewardTokenSymbol", + "type": "string" + }, + { + "internalType": "address", + "name": "rewardOracleAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "rewardTokenAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "userUnclaimedRewards", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenIncentivesUserIndex", + "type": "uint256" + }, + { + "internalType": "int256", + "name": "rewardPriceFeed", + "type": "int256" + }, + { + "internalType": "uint8", + "name": "priceFeedDecimals", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "rewardTokenDecimals", + "type": "uint8" + } + ], + "internalType": "struct IUiIncentiveDataProviderV3.UserRewardInfo[]", + "name": "userRewardsInformation", + "type": "tuple[]" + } + ], + "internalType": "struct IUiIncentiveDataProviderV3.UserIncentiveData", + "name": "aTokenIncentivesUserData", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "address", + "name": "tokenAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "incentiveControllerAddress", + "type": "address" + }, + { + "components": [ + { + "internalType": "string", + "name": "rewardTokenSymbol", + "type": "string" + }, + { + "internalType": "address", + "name": "rewardOracleAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "rewardTokenAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "userUnclaimedRewards", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenIncentivesUserIndex", + "type": "uint256" + }, + { + "internalType": "int256", + "name": "rewardPriceFeed", + "type": "int256" + }, + { + "internalType": "uint8", + "name": "priceFeedDecimals", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "rewardTokenDecimals", + "type": "uint8" + } + ], + "internalType": "struct IUiIncentiveDataProviderV3.UserRewardInfo[]", + "name": "userRewardsInformation", + "type": "tuple[]" + } + ], + "internalType": "struct IUiIncentiveDataProviderV3.UserIncentiveData", + "name": "vTokenIncentivesUserData", + "type": "tuple" + } + ], + "internalType": "struct IUiIncentiveDataProviderV3.UserReserveIncentiveData[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + } +] diff --git a/packages/contract-types/src/types/UiIncentiveDataProviderV3.ts b/packages/contract-types/src/types/UiIncentiveDataProviderV3.ts new file mode 100644 index 00000000..ce572d7e --- /dev/null +++ b/packages/contract-types/src/types/UiIncentiveDataProviderV3.ts @@ -0,0 +1,347 @@ +/* Autogenerated file. Do not edit manually. */ +/* eslint-disable */ +import type { + BaseContract, + BigNumber, + BigNumberish, + 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 IUiIncentiveDataProviderV3 { + export type RewardInfoStruct = { + rewardTokenSymbol: string; + rewardTokenAddress: string; + rewardOracleAddress: string; + emissionPerSecond: BigNumberish; + incentivesLastUpdateTimestamp: BigNumberish; + tokenIncentivesIndex: BigNumberish; + emissionEndTimestamp: BigNumberish; + rewardPriceFeed: BigNumberish; + rewardTokenDecimals: BigNumberish; + precision: BigNumberish; + priceFeedDecimals: BigNumberish; + }; + + export type RewardInfoStructOutput = [ + string, + string, + string, + BigNumber, + BigNumber, + BigNumber, + BigNumber, + BigNumber, + number, + number, + number, + ] & { + rewardTokenSymbol: string; + rewardTokenAddress: string; + rewardOracleAddress: string; + emissionPerSecond: BigNumber; + incentivesLastUpdateTimestamp: BigNumber; + tokenIncentivesIndex: BigNumber; + emissionEndTimestamp: BigNumber; + rewardPriceFeed: BigNumber; + rewardTokenDecimals: number; + precision: number; + priceFeedDecimals: number; + }; + + export type IncentiveDataStruct = { + tokenAddress: string; + incentiveControllerAddress: string; + rewardsTokenInformation: IUiIncentiveDataProviderV3.RewardInfoStruct[]; + }; + + export type IncentiveDataStructOutput = [ + string, + string, + IUiIncentiveDataProviderV3.RewardInfoStructOutput[], + ] & { + tokenAddress: string; + incentiveControllerAddress: string; + rewardsTokenInformation: IUiIncentiveDataProviderV3.RewardInfoStructOutput[]; + }; + + export type AggregatedReserveIncentiveDataStruct = { + underlyingAsset: string; + aIncentiveData: IUiIncentiveDataProviderV3.IncentiveDataStruct; + vIncentiveData: IUiIncentiveDataProviderV3.IncentiveDataStruct; + }; + + export type AggregatedReserveIncentiveDataStructOutput = [ + string, + IUiIncentiveDataProviderV3.IncentiveDataStructOutput, + IUiIncentiveDataProviderV3.IncentiveDataStructOutput, + ] & { + underlyingAsset: string; + aIncentiveData: IUiIncentiveDataProviderV3.IncentiveDataStructOutput; + vIncentiveData: IUiIncentiveDataProviderV3.IncentiveDataStructOutput; + }; + + export type UserRewardInfoStruct = { + rewardTokenSymbol: string; + rewardOracleAddress: string; + rewardTokenAddress: string; + userUnclaimedRewards: BigNumberish; + tokenIncentivesUserIndex: BigNumberish; + rewardPriceFeed: BigNumberish; + priceFeedDecimals: BigNumberish; + rewardTokenDecimals: BigNumberish; + }; + + export type UserRewardInfoStructOutput = [ + string, + string, + string, + BigNumber, + BigNumber, + BigNumber, + number, + number, + ] & { + rewardTokenSymbol: string; + rewardOracleAddress: string; + rewardTokenAddress: string; + userUnclaimedRewards: BigNumber; + tokenIncentivesUserIndex: BigNumber; + rewardPriceFeed: BigNumber; + priceFeedDecimals: number; + rewardTokenDecimals: number; + }; + + export type UserIncentiveDataStruct = { + tokenAddress: string; + incentiveControllerAddress: string; + userRewardsInformation: IUiIncentiveDataProviderV3.UserRewardInfoStruct[]; + }; + + export type UserIncentiveDataStructOutput = [ + string, + string, + IUiIncentiveDataProviderV3.UserRewardInfoStructOutput[], + ] & { + tokenAddress: string; + incentiveControllerAddress: string; + userRewardsInformation: IUiIncentiveDataProviderV3.UserRewardInfoStructOutput[]; + }; + + export type UserReserveIncentiveDataStruct = { + underlyingAsset: string; + aTokenIncentivesUserData: IUiIncentiveDataProviderV3.UserIncentiveDataStruct; + vTokenIncentivesUserData: IUiIncentiveDataProviderV3.UserIncentiveDataStruct; + }; + + export type UserReserveIncentiveDataStructOutput = [ + string, + IUiIncentiveDataProviderV3.UserIncentiveDataStructOutput, + IUiIncentiveDataProviderV3.UserIncentiveDataStructOutput, + ] & { + underlyingAsset: string; + aTokenIncentivesUserData: IUiIncentiveDataProviderV3.UserIncentiveDataStructOutput; + vTokenIncentivesUserData: IUiIncentiveDataProviderV3.UserIncentiveDataStructOutput; + }; +} + +export interface UiIncentiveDataProviderV3Interface extends utils.Interface { + functions: { + 'getFullReservesIncentiveData(address,address)': FunctionFragment; + 'getReservesIncentivesData(address)': FunctionFragment; + 'getUserReservesIncentivesData(address,address)': FunctionFragment; + }; + + getFunction( + nameOrSignatureOrTopic: + | 'getFullReservesIncentiveData' + | 'getReservesIncentivesData' + | 'getUserReservesIncentivesData', + ): FunctionFragment; + + encodeFunctionData( + functionFragment: 'getFullReservesIncentiveData', + values: [string, string], + ): string; + encodeFunctionData( + functionFragment: 'getReservesIncentivesData', + values: [string], + ): string; + encodeFunctionData( + functionFragment: 'getUserReservesIncentivesData', + values: [string, string], + ): string; + + decodeFunctionResult( + functionFragment: 'getFullReservesIncentiveData', + data: BytesLike, + ): Result; + decodeFunctionResult( + functionFragment: 'getReservesIncentivesData', + data: BytesLike, + ): Result; + decodeFunctionResult( + functionFragment: 'getUserReservesIncentivesData', + data: BytesLike, + ): Result; + + events: {}; +} + +export interface UiIncentiveDataProviderV3 extends BaseContract { + connect(signerOrProvider: Signer | Provider | string): this; + attach(addressOrName: string): this; + deployed(): Promise; + + interface: UiIncentiveDataProviderV3Interface; + + 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: { + getFullReservesIncentiveData( + provider: string, + user: string, + overrides?: CallOverrides, + ): Promise< + [ + IUiIncentiveDataProviderV3.AggregatedReserveIncentiveDataStructOutput[], + IUiIncentiveDataProviderV3.UserReserveIncentiveDataStructOutput[], + ] + >; + + getReservesIncentivesData( + provider: string, + overrides?: CallOverrides, + ): Promise< + [IUiIncentiveDataProviderV3.AggregatedReserveIncentiveDataStructOutput[]] + >; + + getUserReservesIncentivesData( + provider: string, + user: string, + overrides?: CallOverrides, + ): Promise< + [IUiIncentiveDataProviderV3.UserReserveIncentiveDataStructOutput[]] + >; + }; + + getFullReservesIncentiveData( + provider: string, + user: string, + overrides?: CallOverrides, + ): Promise< + [ + IUiIncentiveDataProviderV3.AggregatedReserveIncentiveDataStructOutput[], + IUiIncentiveDataProviderV3.UserReserveIncentiveDataStructOutput[], + ] + >; + + getReservesIncentivesData( + provider: string, + overrides?: CallOverrides, + ): Promise< + IUiIncentiveDataProviderV3.AggregatedReserveIncentiveDataStructOutput[] + >; + + getUserReservesIncentivesData( + provider: string, + user: string, + overrides?: CallOverrides, + ): Promise; + + callStatic: { + getFullReservesIncentiveData( + provider: string, + user: string, + overrides?: CallOverrides, + ): Promise< + [ + IUiIncentiveDataProviderV3.AggregatedReserveIncentiveDataStructOutput[], + IUiIncentiveDataProviderV3.UserReserveIncentiveDataStructOutput[], + ] + >; + + getReservesIncentivesData( + provider: string, + overrides?: CallOverrides, + ): Promise< + IUiIncentiveDataProviderV3.AggregatedReserveIncentiveDataStructOutput[] + >; + + getUserReservesIncentivesData( + provider: string, + user: string, + overrides?: CallOverrides, + ): Promise< + IUiIncentiveDataProviderV3.UserReserveIncentiveDataStructOutput[] + >; + }; + + filters: {}; + + estimateGas: { + getFullReservesIncentiveData( + provider: string, + user: string, + overrides?: CallOverrides, + ): Promise; + + getReservesIncentivesData( + provider: string, + overrides?: CallOverrides, + ): Promise; + + getUserReservesIncentivesData( + provider: string, + user: string, + overrides?: CallOverrides, + ): Promise; + }; + + populateTransaction: { + getFullReservesIncentiveData( + provider: string, + user: string, + overrides?: CallOverrides, + ): Promise; + + getReservesIncentivesData( + provider: string, + overrides?: CallOverrides, + ): Promise; + + getUserReservesIncentivesData( + provider: string, + user: string, + overrides?: CallOverrides, + ): Promise; + }; +} diff --git a/packages/contract-types/src/types/factories/UiIncentiveDataProviderV3__factory.ts b/packages/contract-types/src/types/factories/UiIncentiveDataProviderV3__factory.ts new file mode 100644 index 00000000..89adfc5f --- /dev/null +++ b/packages/contract-types/src/types/factories/UiIncentiveDataProviderV3__factory.ts @@ -0,0 +1,709 @@ +/* Autogenerated file. Do not edit manually. */ +/* eslint-disable */ + +import { Contract, Signer, utils } from 'ethers'; +import type { Provider } from '@ethersproject/providers'; +import type { + UiIncentiveDataProviderV3, + UiIncentiveDataProviderV3Interface, +} from '../UiIncentiveDataProviderV3'; + +const _abi = [ + { + inputs: [ + { + internalType: 'contract IPoolAddressesProvider', + name: 'provider', + type: 'address', + }, + { + internalType: 'address', + name: 'user', + type: 'address', + }, + ], + name: 'getFullReservesIncentiveData', + outputs: [ + { + components: [ + { + internalType: 'address', + name: 'underlyingAsset', + type: 'address', + }, + { + components: [ + { + internalType: 'address', + name: 'tokenAddress', + type: 'address', + }, + { + internalType: 'address', + name: 'incentiveControllerAddress', + type: 'address', + }, + { + components: [ + { + internalType: 'string', + name: 'rewardTokenSymbol', + type: 'string', + }, + { + internalType: 'address', + name: 'rewardTokenAddress', + type: 'address', + }, + { + internalType: 'address', + name: 'rewardOracleAddress', + type: 'address', + }, + { + internalType: 'uint256', + name: 'emissionPerSecond', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'incentivesLastUpdateTimestamp', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'tokenIncentivesIndex', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'emissionEndTimestamp', + type: 'uint256', + }, + { + internalType: 'int256', + name: 'rewardPriceFeed', + type: 'int256', + }, + { + internalType: 'uint8', + name: 'rewardTokenDecimals', + type: 'uint8', + }, + { + internalType: 'uint8', + name: 'precision', + type: 'uint8', + }, + { + internalType: 'uint8', + name: 'priceFeedDecimals', + type: 'uint8', + }, + ], + internalType: 'struct IUiIncentiveDataProviderV3.RewardInfo[]', + name: 'rewardsTokenInformation', + type: 'tuple[]', + }, + ], + internalType: 'struct IUiIncentiveDataProviderV3.IncentiveData', + name: 'aIncentiveData', + type: 'tuple', + }, + { + components: [ + { + internalType: 'address', + name: 'tokenAddress', + type: 'address', + }, + { + internalType: 'address', + name: 'incentiveControllerAddress', + type: 'address', + }, + { + components: [ + { + internalType: 'string', + name: 'rewardTokenSymbol', + type: 'string', + }, + { + internalType: 'address', + name: 'rewardTokenAddress', + type: 'address', + }, + { + internalType: 'address', + name: 'rewardOracleAddress', + type: 'address', + }, + { + internalType: 'uint256', + name: 'emissionPerSecond', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'incentivesLastUpdateTimestamp', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'tokenIncentivesIndex', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'emissionEndTimestamp', + type: 'uint256', + }, + { + internalType: 'int256', + name: 'rewardPriceFeed', + type: 'int256', + }, + { + internalType: 'uint8', + name: 'rewardTokenDecimals', + type: 'uint8', + }, + { + internalType: 'uint8', + name: 'precision', + type: 'uint8', + }, + { + internalType: 'uint8', + name: 'priceFeedDecimals', + type: 'uint8', + }, + ], + internalType: 'struct IUiIncentiveDataProviderV3.RewardInfo[]', + name: 'rewardsTokenInformation', + type: 'tuple[]', + }, + ], + internalType: 'struct IUiIncentiveDataProviderV3.IncentiveData', + name: 'vIncentiveData', + type: 'tuple', + }, + ], + internalType: + 'struct IUiIncentiveDataProviderV3.AggregatedReserveIncentiveData[]', + name: '', + type: 'tuple[]', + }, + { + components: [ + { + internalType: 'address', + name: 'underlyingAsset', + type: 'address', + }, + { + components: [ + { + internalType: 'address', + name: 'tokenAddress', + type: 'address', + }, + { + internalType: 'address', + name: 'incentiveControllerAddress', + type: 'address', + }, + { + components: [ + { + internalType: 'string', + name: 'rewardTokenSymbol', + type: 'string', + }, + { + internalType: 'address', + name: 'rewardOracleAddress', + type: 'address', + }, + { + internalType: 'address', + name: 'rewardTokenAddress', + type: 'address', + }, + { + internalType: 'uint256', + name: 'userUnclaimedRewards', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'tokenIncentivesUserIndex', + type: 'uint256', + }, + { + internalType: 'int256', + name: 'rewardPriceFeed', + type: 'int256', + }, + { + internalType: 'uint8', + name: 'priceFeedDecimals', + type: 'uint8', + }, + { + internalType: 'uint8', + name: 'rewardTokenDecimals', + type: 'uint8', + }, + ], + internalType: + 'struct IUiIncentiveDataProviderV3.UserRewardInfo[]', + name: 'userRewardsInformation', + type: 'tuple[]', + }, + ], + internalType: 'struct IUiIncentiveDataProviderV3.UserIncentiveData', + name: 'aTokenIncentivesUserData', + type: 'tuple', + }, + { + components: [ + { + internalType: 'address', + name: 'tokenAddress', + type: 'address', + }, + { + internalType: 'address', + name: 'incentiveControllerAddress', + type: 'address', + }, + { + components: [ + { + internalType: 'string', + name: 'rewardTokenSymbol', + type: 'string', + }, + { + internalType: 'address', + name: 'rewardOracleAddress', + type: 'address', + }, + { + internalType: 'address', + name: 'rewardTokenAddress', + type: 'address', + }, + { + internalType: 'uint256', + name: 'userUnclaimedRewards', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'tokenIncentivesUserIndex', + type: 'uint256', + }, + { + internalType: 'int256', + name: 'rewardPriceFeed', + type: 'int256', + }, + { + internalType: 'uint8', + name: 'priceFeedDecimals', + type: 'uint8', + }, + { + internalType: 'uint8', + name: 'rewardTokenDecimals', + type: 'uint8', + }, + ], + internalType: + 'struct IUiIncentiveDataProviderV3.UserRewardInfo[]', + name: 'userRewardsInformation', + type: 'tuple[]', + }, + ], + internalType: 'struct IUiIncentiveDataProviderV3.UserIncentiveData', + name: 'vTokenIncentivesUserData', + type: 'tuple', + }, + ], + internalType: + 'struct IUiIncentiveDataProviderV3.UserReserveIncentiveData[]', + name: '', + type: 'tuple[]', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'contract IPoolAddressesProvider', + name: 'provider', + type: 'address', + }, + ], + name: 'getReservesIncentivesData', + outputs: [ + { + components: [ + { + internalType: 'address', + name: 'underlyingAsset', + type: 'address', + }, + { + components: [ + { + internalType: 'address', + name: 'tokenAddress', + type: 'address', + }, + { + internalType: 'address', + name: 'incentiveControllerAddress', + type: 'address', + }, + { + components: [ + { + internalType: 'string', + name: 'rewardTokenSymbol', + type: 'string', + }, + { + internalType: 'address', + name: 'rewardTokenAddress', + type: 'address', + }, + { + internalType: 'address', + name: 'rewardOracleAddress', + type: 'address', + }, + { + internalType: 'uint256', + name: 'emissionPerSecond', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'incentivesLastUpdateTimestamp', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'tokenIncentivesIndex', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'emissionEndTimestamp', + type: 'uint256', + }, + { + internalType: 'int256', + name: 'rewardPriceFeed', + type: 'int256', + }, + { + internalType: 'uint8', + name: 'rewardTokenDecimals', + type: 'uint8', + }, + { + internalType: 'uint8', + name: 'precision', + type: 'uint8', + }, + { + internalType: 'uint8', + name: 'priceFeedDecimals', + type: 'uint8', + }, + ], + internalType: 'struct IUiIncentiveDataProviderV3.RewardInfo[]', + name: 'rewardsTokenInformation', + type: 'tuple[]', + }, + ], + internalType: 'struct IUiIncentiveDataProviderV3.IncentiveData', + name: 'aIncentiveData', + type: 'tuple', + }, + { + components: [ + { + internalType: 'address', + name: 'tokenAddress', + type: 'address', + }, + { + internalType: 'address', + name: 'incentiveControllerAddress', + type: 'address', + }, + { + components: [ + { + internalType: 'string', + name: 'rewardTokenSymbol', + type: 'string', + }, + { + internalType: 'address', + name: 'rewardTokenAddress', + type: 'address', + }, + { + internalType: 'address', + name: 'rewardOracleAddress', + type: 'address', + }, + { + internalType: 'uint256', + name: 'emissionPerSecond', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'incentivesLastUpdateTimestamp', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'tokenIncentivesIndex', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'emissionEndTimestamp', + type: 'uint256', + }, + { + internalType: 'int256', + name: 'rewardPriceFeed', + type: 'int256', + }, + { + internalType: 'uint8', + name: 'rewardTokenDecimals', + type: 'uint8', + }, + { + internalType: 'uint8', + name: 'precision', + type: 'uint8', + }, + { + internalType: 'uint8', + name: 'priceFeedDecimals', + type: 'uint8', + }, + ], + internalType: 'struct IUiIncentiveDataProviderV3.RewardInfo[]', + name: 'rewardsTokenInformation', + type: 'tuple[]', + }, + ], + internalType: 'struct IUiIncentiveDataProviderV3.IncentiveData', + name: 'vIncentiveData', + type: 'tuple', + }, + ], + internalType: + 'struct IUiIncentiveDataProviderV3.AggregatedReserveIncentiveData[]', + name: '', + type: 'tuple[]', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'contract IPoolAddressesProvider', + name: 'provider', + type: 'address', + }, + { + internalType: 'address', + name: 'user', + type: 'address', + }, + ], + name: 'getUserReservesIncentivesData', + outputs: [ + { + components: [ + { + internalType: 'address', + name: 'underlyingAsset', + type: 'address', + }, + { + components: [ + { + internalType: 'address', + name: 'tokenAddress', + type: 'address', + }, + { + internalType: 'address', + name: 'incentiveControllerAddress', + type: 'address', + }, + { + components: [ + { + internalType: 'string', + name: 'rewardTokenSymbol', + type: 'string', + }, + { + internalType: 'address', + name: 'rewardOracleAddress', + type: 'address', + }, + { + internalType: 'address', + name: 'rewardTokenAddress', + type: 'address', + }, + { + internalType: 'uint256', + name: 'userUnclaimedRewards', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'tokenIncentivesUserIndex', + type: 'uint256', + }, + { + internalType: 'int256', + name: 'rewardPriceFeed', + type: 'int256', + }, + { + internalType: 'uint8', + name: 'priceFeedDecimals', + type: 'uint8', + }, + { + internalType: 'uint8', + name: 'rewardTokenDecimals', + type: 'uint8', + }, + ], + internalType: + 'struct IUiIncentiveDataProviderV3.UserRewardInfo[]', + name: 'userRewardsInformation', + type: 'tuple[]', + }, + ], + internalType: 'struct IUiIncentiveDataProviderV3.UserIncentiveData', + name: 'aTokenIncentivesUserData', + type: 'tuple', + }, + { + components: [ + { + internalType: 'address', + name: 'tokenAddress', + type: 'address', + }, + { + internalType: 'address', + name: 'incentiveControllerAddress', + type: 'address', + }, + { + components: [ + { + internalType: 'string', + name: 'rewardTokenSymbol', + type: 'string', + }, + { + internalType: 'address', + name: 'rewardOracleAddress', + type: 'address', + }, + { + internalType: 'address', + name: 'rewardTokenAddress', + type: 'address', + }, + { + internalType: 'uint256', + name: 'userUnclaimedRewards', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'tokenIncentivesUserIndex', + type: 'uint256', + }, + { + internalType: 'int256', + name: 'rewardPriceFeed', + type: 'int256', + }, + { + internalType: 'uint8', + name: 'priceFeedDecimals', + type: 'uint8', + }, + { + internalType: 'uint8', + name: 'rewardTokenDecimals', + type: 'uint8', + }, + ], + internalType: + 'struct IUiIncentiveDataProviderV3.UserRewardInfo[]', + name: 'userRewardsInformation', + type: 'tuple[]', + }, + ], + internalType: 'struct IUiIncentiveDataProviderV3.UserIncentiveData', + name: 'vTokenIncentivesUserData', + type: 'tuple', + }, + ], + internalType: + 'struct IUiIncentiveDataProviderV3.UserReserveIncentiveData[]', + name: '', + type: 'tuple[]', + }, + ], + stateMutability: 'view', + type: 'function', + }, +] as const; + +export class UiIncentiveDataProviderV3__factory { + static readonly abi = _abi; + static createInterface(): UiIncentiveDataProviderV3Interface { + return new utils.Interface(_abi) as UiIncentiveDataProviderV3Interface; + } + static connect( + address: string, + signerOrProvider: Signer | Provider, + ): UiIncentiveDataProviderV3 { + return new Contract( + address, + _abi, + signerOrProvider, + ) as UiIncentiveDataProviderV3; + } +} diff --git a/packages/contract-types/src/types/factories/index.ts b/packages/contract-types/src/types/factories/index.ts index 30d22e2c..8d7e132e 100644 --- a/packages/contract-types/src/types/factories/index.ts +++ b/packages/contract-types/src/types/factories/index.ts @@ -1,3 +1,4 @@ /* Autogenerated file. Do not edit manually. */ /* eslint-disable */ +export { UiIncentiveDataProviderV3__factory } from './UiIncentiveDataProviderV3__factory'; export { UiPoolDataProviderV3__factory } from './UiPoolDataProviderV3__factory'; diff --git a/packages/contract-types/src/types/index.ts b/packages/contract-types/src/types/index.ts index 9a0f55b8..31da3c47 100644 --- a/packages/contract-types/src/types/index.ts +++ b/packages/contract-types/src/types/index.ts @@ -1,5 +1,7 @@ /* Autogenerated file. Do not edit manually. */ /* eslint-disable */ +export type { UiIncentiveDataProviderV3 } from './UiIncentiveDataProviderV3'; export type { UiPoolDataProviderV3 } from './UiPoolDataProviderV3'; export * as factories from './factories'; +export { UiIncentiveDataProviderV3__factory } from './factories/UiIncentiveDataProviderV3__factory'; export { UiPoolDataProviderV3__factory } from './factories/UiPoolDataProviderV3__factory';