diff --git a/packages/contract-helpers/src/V3-uiStakeDataProvider-contract-copy/index.ts b/packages/contract-helpers/src/V3-uiStakeDataProvider-contract-copy/index.ts deleted file mode 100644 index 89246162..00000000 --- a/packages/contract-helpers/src/V3-uiStakeDataProvider-contract-copy/index.ts +++ /dev/null @@ -1,255 +0,0 @@ -import { providers } from 'ethers'; -// import { StakeUiDataProviderValidator } from '../commons/validators/methodValidators'; -// import { isEthAddress } from '../commons/validators/paramValidators'; -import { - Abi as IStakedTokenDataProvider, - Abi__factory as StakedTokenDataProvider__factory, -} from './typechain'; -import { - StakedTokenData, - HumanizedStakeResponse, - // GeneralStakeUIData, - // GeneralStakeUIDataHumanized, - // GetUserStakeUIData, - // GetUserStakeUIDataHumanized, -} from './types'; - -type EthAddress = string; - -export interface UiStakeDataProviderInterface { - // getUserStakeUIData: (params: { user: string }) => Promise; - getGeneralStakeUIData: ( - stakedAssets: EthAddress[], - priceFeeds: EthAddress[], - ) => Promise; - // getUserStakeUIDataHumanized: (params: { - // user: string; - // }) => Promise; - // getGeneralStakeUIDataHumanized: () => Promise; -} - -export type UiStakeDataProviderContext = { - uiStakeDataProvider: string; - provider: providers.Provider; -}; - -export class UiStakeDataProviderV3 implements UiStakeDataProviderInterface { - private readonly _contract: IStakedTokenDataProvider; - - public constructor(context: UiStakeDataProviderContext) { - this._contract = StakedTokenDataProvider__factory.connect( - context.uiStakeDataProvider, - context.provider, - ); - } - - // @StakeUiDataProviderValidator - // public async getUserStakeUIData( - // stakedTokens: EthAddress[], - // oracleAddresses: EthAddress[], - // @isEthAddress('user') { user }: { user: string }, - // ): Promise { - // const { - // stkAaveData, - // stkAaveUserData, - // stkBptData, - // stkBptUserData, - // ethPrice, - // } = await this._contract.getStakedUserDataBatch( - // stakedTokens, - // oracleAddresses, - // user, - // ); - // // TODO do we need the ETH price? add to contract if necessary - - // return { - // stkAaveData: { - // ...stkAaveData, - // stakedTokenUserBalance: stkAaveUserData.stakedTokenUserBalance, - // underlyingTokenUserBalance: stkAaveUserData.underlyingTokenUserBalance, - // stakedTokenRedeemableAmount: - // stkAaveUserData.stakedTokenRedeemableAmount, - // userCooldownAmount: stkAaveUserData.userCooldownAmount, - // userCooldownTimestamp: stkAaveUserData.userCooldownTimestamp, - // rewardsToClaim: stkAaveUserData.rewardsToClaim, - // }, - // stkBptData: { - // ...stkBptData, - // stakedTokenUserBalance: stkBptUserData.stakedTokenUserBalance, - // underlyingTokenUserBalance: stkBptUserData.underlyingTokenUserBalance, - // stakedTokenRedeemableAmount: stkBptUserData.stakedTokenRedeemableAmount, - // userCooldownAmount: stkBptUserData.userCooldownAmount, - // userCooldownTimestamp: stkBptUserData.userCooldownTimestamp, - // rewardsToClaim: stkBptUserData.rewardsToClaim, - // }, - // stkGho: { - // ...stkAaveData, - // stakedTokenUserBalance: stkAaveUserData.stakedTokenUserBalance, - // underlyingTokenUserBalance: stkAaveUserData.underlyingTokenUserBalance, - // stakedTokenRedeemableAmount: - // stkAaveUserData.stakedTokenRedeemableAmount, - // userCooldownAmount: stkAaveUserData.userCooldownAmount, - // userCooldownTimestamp: stkAaveUserData.userCooldownTimestamp, - // rewardsToClaim: stkAaveUserData.rewardsToClaim, - // }, - // ethPrice, - // }; - // } - - // @StakeUiDataProviderValidator - // public async getUserStakeUIDataHumanized( - // @isEthAddress('user') { user }: { user: string }, - // ): Promise { - // const contractResult = await this.getUserStakeUIData({ user }); - - // return { - // aave: { - // stakeTokenUserBalance: - // contractResult.stkAaveData.stakedTokenUserBalance.toString(), - // underlyingTokenUserBalance: - // contractResult.stkAaveData.underlyingTokenUserBalance.toString(), - // stakeTokenRedeemableAmount: - // contractResult.stkAaveData.stakedTokenRedeemableAmount.toString(), - // userCooldownAmount: - // contractResult.stkAaveData.userCooldownAmount.toString(), - // userCooldownTimestamp: contractResult.stkAaveData.userCooldownTimestamp, - // userIncentivesToClaim: - // contractResult.stkAaveData.rewardsToClaim.toString(), - // }, - // bpt: { - // stakeTokenUserBalance: - // contractResult.stkBptData.stakedTokenUserBalance.toString(), - // underlyingTokenUserBalance: - // contractResult.stkBptData.underlyingTokenUserBalance.toString(), - // stakeTokenRedeemableAmount: - // contractResult.stkBptData.stakedTokenRedeemableAmount.toString(), - // userCooldownAmount: - // contractResult.stkBptData.userCooldownAmount.toString(), - // userCooldownTimestamp: contractResult.stkBptData.userCooldownTimestamp, - // userIncentivesToClaim: - // contractResult.stkBptData.rewardsToClaim.toString(), - // }, - // gho: { - // stakeTokenUserBalance: - // contractResult.stkAaveData.stakedTokenUserBalance.toString(), - // underlyingTokenUserBalance: - // contractResult.stkAaveData.underlyingTokenUserBalance.toString(), - // stakeTokenRedeemableAmount: - // contractResult.stkAaveData.stakedTokenRedeemableAmount.toString(), - // userCooldownAmount: - // contractResult.stkAaveData.userCooldownAmount.toString(), - // userCooldownTimestamp: contractResult.stkAaveData.userCooldownTimestamp, - // userIncentivesToClaim: - // contractResult.stkAaveData.rewardsToClaim.toString(), - // }, - // ethPriceUsd: contractResult.ethPrice.toString(), - // }; - // } - - public async getGeneralStakeUIData( - stakedAssets: EthAddress[], - priceFeeds: EthAddress[], - ): Promise { - const [stakedData, ,] = - // add ethPrice back in - await this._contract.getStakedAssetDataBatch(stakedAssets, priceFeeds); - - const parsedStakedData = handleParsedStakedData(stakedData); - - return { - // @ts-expect-error for now need to fix type - parsedStakedData, - parsedPrices: [], - ethPriceUsd: '123', // ethPrice.toString(), - }; - } - - // public async getGeneralStakeUIDataHumanized( - // stakedAssets: EthAddress[], - // priceFeeds: EthAddress[], - // ): Promise { - // const stakedData = await this.getGeneralStakeUIData( - // stakedAssets, - // priceFeeds, - // ); - - // const parsedStakedData = handleParsedStakedData(stakedData); - - // return parsedStakedData; - - // // return { - // // aave: { - // // stakeTokenTotalSupply: - // // contractResult.stkAaveData.stakedTokenTotalSupply.toString(), - // // stakeTokenTotalRedeemableAmount: - // // contractResult.stkAaveData.stakedTokenTotalRedeemableAmount.toString(), - // // stakeCooldownSeconds: - // // contractResult.stkAaveData.stakeCooldownSeconds.toNumber(), - // // stakeUnstakeWindow: - // // contractResult.stkAaveData.stakeUnstakeWindow.toNumber(), - // // stakeTokenPriceEth: - // // contractResult.stkAaveData.stakedTokenPriceEth.toString(), - // // rewardTokenPriceEth: - // // contractResult.stkAaveData.rewardTokenPriceEth.toString(), - // // stakeApy: contractResult.stkAaveData.stakeApy.toString(), - // // distributionPerSecond: - // // contractResult.stkAaveData.distributionPerSecond.toString(), - // // distributionEnd: contractResult.stkAaveData.distributionEnd.toString(), - // // }, - // // bpt: { - // // stakeTokenTotalSupply: - // // contractResult.stkBptData.stakedTokenTotalSupply.toString(), - // // stakeTokenTotalRedeemableAmount: - // // contractResult.stkAaveData.stakedTokenTotalRedeemableAmount.toString(), - // // stakeCooldownSeconds: - // // contractResult.stkBptData.stakeCooldownSeconds.toNumber(), - // // stakeUnstakeWindow: - // // contractResult.stkBptData.stakeUnstakeWindow.toNumber(), - // // stakeTokenPriceEth: - // // contractResult.stkBptData.stakedTokenPriceEth.toString(), - // // rewardTokenPriceEth: - // // contractResult.stkBptData.rewardTokenPriceEth.toString(), - // // stakeApy: contractResult.stkBptData.stakeApy.toString(), - // // distributionPerSecond: - // // contractResult.stkBptData.distributionPerSecond.toString(), - // // distributionEnd: contractResult.stkBptData.distributionEnd.toString(), - // // }, - // // gho: { - // // stakeTokenTotalSupply: - // // contractResult.stkGho.stakedTokenTotalSupply.toString(), - // // stakeTokenTotalRedeemableAmount: - // // contractResult.stkGho.stakedTokenTotalRedeemableAmount.toString(), - // // stakeCooldownSeconds: - // // contractResult.stkGho.stakeCooldownSeconds.toNumber(), - // // stakeUnstakeWindow: contractResult.stkGho.stakeUnstakeWindow.toNumber(), - // // stakeTokenPriceEth: - // // contractResult.stkGho.stakedTokenPriceEth.toString(), - // // rewardTokenPriceEth: - // // contractResult.stkGho.rewardTokenPriceEth.toString(), - // // stakeApy: contractResult.stkGho.stakeApy.toString(), - // // distributionPerSecond: - // // contractResult.stkGho.distributionPerSecond.toString(), - // // distributionEnd: contractResult.stkGho.distributionEnd.toString(), - // // }, - // // ethPriceUsd: contractResult.ethPrice.toString(), - // // }; - // } -} -function handleParsedStakedData(stakedData: StakedTokenData[]) { - return stakedData.map((data: StakedTokenData) => { - return { - // foo: 'bar', - inPostSlashingPeriod: data.inPostSlashingPeriod, - stakedTokenTotalSupply: data.stakedTokenTotalSupply.toString(), - stakedTokenTotalRedeemableAmount: - data.stakedTokenTotalRedeemableAmount.toString(), - stakeCooldownSeconds: data.stakeCooldownSeconds.toNumber(), - stakeUnstakeWindow: data.stakeUnstakeWindow.toNumber(), - stakedTokenPriceEth: data.stakedTokenPriceEth.toString(), - rewardTokenPriceEth: data.rewardTokenPriceEth.toString(), - stakeApy: data.stakeApy.toString(), - distributionPerSecond: data.distributionPerSecond.toString(), - distributionEnd: data.distributionEnd.toString(), - }; - }); -} diff --git a/packages/contract-helpers/src/V3-uiStakeDataProvider-contract-copy/typechain/factories/IUistakeDataProviderV3__factory.ts b/packages/contract-helpers/src/V3-uiStakeDataProvider-contract-copy/typechain/factories/IUistakeDataProviderV3__factory.ts deleted file mode 100644 index 03d1b8d9..00000000 --- a/packages/contract-helpers/src/V3-uiStakeDataProvider-contract-copy/typechain/factories/IUistakeDataProviderV3__factory.ts +++ /dev/null @@ -1,472 +0,0 @@ -/* Autogenerated file. Do not edit manually. */ -/* eslint-disable */ - -import { Contract, Signer, utils } from 'ethers'; -import type { Provider } from '@ethersproject/providers'; -import type { Abi, AbiInterface } from './IUistakeDataProviderV3'; - -const _abi = [ - { - type: 'constructor', - inputs: [ - { - name: 'stkAave', - type: 'address', - internalType: 'address', - }, - { - name: 'ethUsdPriceFeed', - type: 'address', - internalType: 'address', - }, - { - name: 'aavePriceFeed', - type: 'address', - internalType: 'address', - }, - ], - stateMutability: 'nonpayable', - }, - { - type: 'function', - name: 'AAVE_PRICE_FEED', - inputs: [], - outputs: [ - { - name: '', - type: 'address', - internalType: 'address', - }, - ], - stateMutability: 'view', - }, - { - type: 'function', - name: 'ETH_USD_PRICE_FEED', - inputs: [], - outputs: [ - { - name: '', - type: 'address', - internalType: 'address', - }, - ], - stateMutability: 'view', - }, - { - type: 'function', - name: 'STAKED_AAVE', - inputs: [], - outputs: [ - { - name: '', - type: 'address', - internalType: 'address', - }, - ], - stateMutability: 'view', - }, - { - type: 'function', - name: 'getStakedAssetData', - inputs: [ - { - name: 'stakedAsset', - type: 'address', - internalType: 'address', - }, - { - name: 'oracleAddress', - type: 'address', - internalType: 'address', - }, - ], - outputs: [ - { - name: '', - type: 'tuple', - internalType: 'struct IStakedTokenDataProvider.StakedTokenData', - components: [ - { - name: 'stakedTokenTotalSupply', - type: 'uint256', - internalType: 'uint256', - }, - { - name: 'stakedTokenTotalRedeemableAmount', - type: 'uint256', - internalType: 'uint256', - }, - { - name: 'stakeCooldownSeconds', - type: 'uint256', - internalType: 'uint256', - }, - { - name: 'stakeUnstakeWindow', - type: 'uint256', - internalType: 'uint256', - }, - { - name: 'stakedTokenPriceEth', - type: 'uint256', - internalType: 'uint256', - }, - { - name: 'rewardTokenPriceEth', - type: 'uint256', - internalType: 'uint256', - }, - { - name: 'stakeApy', - type: 'uint256', - internalType: 'uint256', - }, - { - name: 'distributionPerSecond', - type: 'uint128', - internalType: 'uint128', - }, - { - name: 'inPostSlashingPeriod', - type: 'bool', - internalType: 'bool', - }, - { - name: 'distributionEnd', - type: 'uint256', - internalType: 'uint256', - }, - ], - }, - ], - stateMutability: 'view', - }, - { - type: 'function', - name: 'getStakedAssetDataBatch', - inputs: [ - { - name: 'stakedTokens', - type: 'address[]', - internalType: 'address[]', - }, - { - name: 'oracleAddresses', - type: 'address[]', - internalType: 'address[]', - }, - ], - outputs: [ - { - name: '', - type: 'tuple[]', - internalType: 'struct IStakedTokenDataProvider.StakedTokenData[]', - components: [ - { - name: 'stakedTokenTotalSupply', - type: 'uint256', - internalType: 'uint256', - }, - { - name: 'stakedTokenTotalRedeemableAmount', - type: 'uint256', - internalType: 'uint256', - }, - { - name: 'stakeCooldownSeconds', - type: 'uint256', - internalType: 'uint256', - }, - { - name: 'stakeUnstakeWindow', - type: 'uint256', - internalType: 'uint256', - }, - { - name: 'stakedTokenPriceEth', - type: 'uint256', - internalType: 'uint256', - }, - { - name: 'rewardTokenPriceEth', - type: 'uint256', - internalType: 'uint256', - }, - { - name: 'stakeApy', - type: 'uint256', - internalType: 'uint256', - }, - { - name: 'distributionPerSecond', - type: 'uint128', - internalType: 'uint128', - }, - { - name: 'inPostSlashingPeriod', - type: 'bool', - internalType: 'bool', - }, - { - name: 'distributionEnd', - type: 'uint256', - internalType: 'uint256', - }, - ], - }, - { - name: '', - type: 'uint256', - internalType: 'uint256', - }, - ], - stateMutability: 'view', - }, - { - type: 'function', - name: 'getStakedUserData', - inputs: [ - { - name: 'stakedAsset', - type: 'address', - internalType: 'address', - }, - { - name: 'oracleAddress', - type: 'address', - internalType: 'address', - }, - { - name: 'user', - type: 'address', - internalType: 'address', - }, - ], - outputs: [ - { - name: '', - type: 'tuple', - internalType: 'struct IStakedTokenDataProvider.StakedTokenData', - components: [ - { - name: 'stakedTokenTotalSupply', - type: 'uint256', - internalType: 'uint256', - }, - { - name: 'stakedTokenTotalRedeemableAmount', - type: 'uint256', - internalType: 'uint256', - }, - { - name: 'stakeCooldownSeconds', - type: 'uint256', - internalType: 'uint256', - }, - { - name: 'stakeUnstakeWindow', - type: 'uint256', - internalType: 'uint256', - }, - { - name: 'stakedTokenPriceEth', - type: 'uint256', - internalType: 'uint256', - }, - { - name: 'rewardTokenPriceEth', - type: 'uint256', - internalType: 'uint256', - }, - { - name: 'stakeApy', - type: 'uint256', - internalType: 'uint256', - }, - { - name: 'distributionPerSecond', - type: 'uint128', - internalType: 'uint128', - }, - { - name: 'inPostSlashingPeriod', - type: 'bool', - internalType: 'bool', - }, - { - name: 'distributionEnd', - type: 'uint256', - internalType: 'uint256', - }, - ], - }, - { - name: '', - type: 'tuple', - internalType: 'struct IStakedTokenDataProvider.StakedTokenUserData', - components: [ - { - name: 'stakedTokenUserBalance', - type: 'uint256', - internalType: 'uint256', - }, - { - name: 'stakedTokenRedeemableAmount', - type: 'uint256', - internalType: 'uint256', - }, - { - name: 'underlyingTokenUserBalance', - type: 'uint256', - internalType: 'uint256', - }, - { - name: 'rewardsToClaim', - type: 'uint256', - internalType: 'uint256', - }, - { - name: 'userCooldownTimestamp', - type: 'uint40', - internalType: 'uint40', - }, - { - name: 'userCooldownAmount', - type: 'uint216', - internalType: 'uint216', - }, - ], - }, - ], - stateMutability: 'view', - }, - { - type: 'function', - name: 'getStakedUserDataBatch', - inputs: [ - { - name: 'stakedTokens', - type: 'address[]', - internalType: 'address[]', - }, - { - name: 'oracleAddresses', - type: 'address[]', - internalType: 'address[]', - }, - { - name: 'userAddress', - type: 'address', - internalType: 'address', - }, - ], - outputs: [ - { - name: '', - type: 'tuple[]', - internalType: 'struct IStakedTokenDataProvider.StakedTokenData[]', - components: [ - { - name: 'stakedTokenTotalSupply', - type: 'uint256', - internalType: 'uint256', - }, - { - name: 'stakedTokenTotalRedeemableAmount', - type: 'uint256', - internalType: 'uint256', - }, - { - name: 'stakeCooldownSeconds', - type: 'uint256', - internalType: 'uint256', - }, - { - name: 'stakeUnstakeWindow', - type: 'uint256', - internalType: 'uint256', - }, - { - name: 'stakedTokenPriceEth', - type: 'uint256', - internalType: 'uint256', - }, - { - name: 'rewardTokenPriceEth', - type: 'uint256', - internalType: 'uint256', - }, - { - name: 'stakeApy', - type: 'uint256', - internalType: 'uint256', - }, - { - name: 'distributionPerSecond', - type: 'uint128', - internalType: 'uint128', - }, - { - name: 'inPostSlashingPeriod', - type: 'bool', - internalType: 'bool', - }, - { - name: 'distributionEnd', - type: 'uint256', - internalType: 'uint256', - }, - ], - }, - { - name: '', - type: 'tuple[]', - internalType: 'struct IStakedTokenDataProvider.StakedTokenUserData[]', - components: [ - { - name: 'stakedTokenUserBalance', - type: 'uint256', - internalType: 'uint256', - }, - { - name: 'stakedTokenRedeemableAmount', - type: 'uint256', - internalType: 'uint256', - }, - { - name: 'underlyingTokenUserBalance', - type: 'uint256', - internalType: 'uint256', - }, - { - name: 'rewardsToClaim', - type: 'uint256', - internalType: 'uint256', - }, - { - name: 'userCooldownTimestamp', - type: 'uint40', - internalType: 'uint40', - }, - { - name: 'userCooldownAmount', - type: 'uint216', - internalType: 'uint216', - }, - ], - }, - ], - stateMutability: 'view', - }, -] as const; - -export class Abi__factory { - static readonly abi = _abi; - static createInterface(): AbiInterface { - return new utils.Interface(_abi) as AbiInterface; - } - static connect(address: string, signerOrProvider: Signer | Provider): Abi { - return new Contract(address, _abi, signerOrProvider) as Abi; - } -} diff --git a/packages/contract-helpers/src/V3-uiStakeDataProvider-contract-copy/typechain/factories/index.ts b/packages/contract-helpers/src/V3-uiStakeDataProvider-contract-copy/typechain/factories/index.ts deleted file mode 100644 index 84281930..00000000 --- a/packages/contract-helpers/src/V3-uiStakeDataProvider-contract-copy/typechain/factories/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -/* Autogenerated file. Do not edit manually. */ - -export { Abi__factory } from './IUistakeDataProviderV3__factory'; diff --git a/packages/contract-helpers/src/V3-uiStakeDataProvider-contract-copy/typechain/index.ts b/packages/contract-helpers/src/V3-uiStakeDataProvider-contract-copy/typechain/index.ts deleted file mode 100644 index 8ecc87bd..00000000 --- a/packages/contract-helpers/src/V3-uiStakeDataProvider-contract-copy/typechain/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -/* Autogenerated file. Do not edit manually. */ - -export type { Abi } from './factories/IUistakeDataProviderV3'; -export * as factories from './factories'; -export { Abi__factory } from './factories/IUistakeDataProviderV3__factory'; diff --git a/packages/contract-helpers/src/V3-uiStakeDataProvider-contract-copy/types.ts b/packages/contract-helpers/src/V3-uiStakeDataProvider-contract-copy/types.ts deleted file mode 100644 index 8d249234..00000000 --- a/packages/contract-helpers/src/V3-uiStakeDataProvider-contract-copy/types.ts +++ /dev/null @@ -1,152 +0,0 @@ -import { BigNumber } from 'ethers'; - -export type StakedTokenData = { - stakedTokenTotalSupply: BigNumber; - stakedTokenTotalRedeemableAmount: BigNumber; - stakeCooldownSeconds: BigNumber; - stakeUnstakeWindow: BigNumber; - rewardTokenPriceEth: BigNumber; - distributionEnd: BigNumber; - distributionPerSecond: BigNumber; - stakedTokenPriceEth: BigNumber; - stakeApy: BigNumber; - inPostSlashingPeriod: boolean; -}; - -export type HumanizedStakeResponse = { - parsedStakedData: StakedTokenData[]; - parsedPrices: string[]; - ethPriceUsd: string; -}; - -export type GeneralStakeUIData = { - stkAaveData: { - stakedTokenTotalSupply: BigNumber; - stakedTokenTotalRedeemableAmount: BigNumber; - stakeCooldownSeconds: BigNumber; - stakeUnstakeWindow: BigNumber; - rewardTokenPriceEth: BigNumber; - distributionEnd: BigNumber; - distributionPerSecond: BigNumber; - stakedTokenPriceEth: BigNumber; - stakeApy: BigNumber; - }; - stkBptData: { - stakedTokenTotalSupply: BigNumber; - stakedTokenTotalRedeemableAmount: BigNumber; - stakeCooldownSeconds: BigNumber; - stakeUnstakeWindow: BigNumber; - rewardTokenPriceEth: BigNumber; - distributionEnd: BigNumber; - distributionPerSecond: BigNumber; - stakedTokenPriceEth: BigNumber; - stakeApy: BigNumber; - }; - stkGho: { - stakedTokenTotalSupply: BigNumber; - stakedTokenTotalRedeemableAmount: BigNumber; - stakeCooldownSeconds: BigNumber; - stakeUnstakeWindow: BigNumber; - rewardTokenPriceEth: BigNumber; - distributionEnd: BigNumber; - distributionPerSecond: BigNumber; - stakedTokenPriceEth: BigNumber; - stakeApy: BigNumber; - }; - ethPrice: BigNumber; -}; - -export type GetUserStakeUIData = { - stkAaveData: { - stakedTokenUserBalance: BigNumber; - underlyingTokenUserBalance: BigNumber; - stakedTokenRedeemableAmount: BigNumber; - userCooldownAmount: BigNumber; - userCooldownTimestamp: number; - rewardsToClaim: BigNumber; - }; - stkBptData: { - stakedTokenUserBalance: BigNumber; - underlyingTokenUserBalance: BigNumber; - stakedTokenRedeemableAmount: BigNumber; - userCooldownAmount: BigNumber; - userCooldownTimestamp: number; - rewardsToClaim: BigNumber; - }; - stkGho: { - stakedTokenUserBalance: BigNumber; - underlyingTokenUserBalance: BigNumber; - stakedTokenRedeemableAmount: BigNumber; - userCooldownAmount: BigNumber; - userCooldownTimestamp: number; - rewardsToClaim: BigNumber; - }; - ethPrice: BigNumber; -}; - -export type GeneralStakeUIDataHumanized = { - aave: { - stakeTokenTotalSupply: string; - stakeTokenTotalRedeemableAmount: string; - stakeCooldownSeconds: number; - stakeUnstakeWindow: number; - stakeTokenPriceEth: string; - rewardTokenPriceEth: string; - stakeApy: string; - distributionPerSecond: string; - distributionEnd: string; - }; - bpt: { - stakeTokenTotalSupply: string; - stakeTokenTotalRedeemableAmount: string; - stakeCooldownSeconds: number; - stakeUnstakeWindow: number; - stakeTokenPriceEth: string; - rewardTokenPriceEth: string; - stakeApy: string; - distributionPerSecond: string; - distributionEnd: string; - }; - - gho: { - stakeTokenTotalSupply: string; - stakeTokenTotalRedeemableAmount: string; - stakeCooldownSeconds: number; - stakeUnstakeWindow: number; - stakeTokenPriceEth: string; - rewardTokenPriceEth: string; - stakeApy: string; - distributionPerSecond: string; - distributionEnd: string; - }; - - ethPriceUsd: string; -}; - -export type GetUserStakeUIDataHumanized = { - aave: { - stakeTokenUserBalance: string; - underlyingTokenUserBalance: string; - stakeTokenRedeemableAmount: string; - userCooldownAmount: string; - userCooldownTimestamp: number; - userIncentivesToClaim: string; - }; - bpt: { - stakeTokenUserBalance: string; - underlyingTokenUserBalance: string; - stakeTokenRedeemableAmount: string; - userCooldownAmount: string; - userCooldownTimestamp: number; - userIncentivesToClaim: string; - }; - gho: { - stakeTokenUserBalance: string; - underlyingTokenUserBalance: string; - stakeTokenRedeemableAmount: string; - userCooldownAmount: string; - userCooldownTimestamp: number; - userIncentivesToClaim: string; - }; - ethPriceUsd: string; -}; diff --git a/packages/contract-helpers/src/V3-uiStakeDataProvider-contract-copy/_mocks.ts b/packages/contract-helpers/src/V3-uiStakeDataProvider-contract/_mocks.ts similarity index 100% rename from packages/contract-helpers/src/V3-uiStakeDataProvider-contract-copy/_mocks.ts rename to packages/contract-helpers/src/V3-uiStakeDataProvider-contract/_mocks.ts diff --git a/packages/contract-helpers/src/V3-uiStakeDataProvider-contract/abis/abi.json b/packages/contract-helpers/src/V3-uiStakeDataProvider-contract/abis/abi.json new file mode 100644 index 00000000..70fda363 --- /dev/null +++ b/packages/contract-helpers/src/V3-uiStakeDataProvider-contract/abis/abi.json @@ -0,0 +1,407 @@ +{ + "abi": [ + { + "inputs": [ + { "internalType": "address", "name": "stkAave", "type": "address" }, + { "internalType": "address", "name": "stkGho", "type": "address" }, + { + "internalType": "address", + "name": "ethUsdPriceFeed", + "type": "address" + }, + { + "internalType": "address", + "name": "aavePriceFeed", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "AAVE_PRICE_FEED", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ETH_USD_PRICE_FEED", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "STAKED_AAVE", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "STAKED_GHO", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "stakedAsset", "type": "address" }, + { "internalType": "address", "name": "oracle", "type": "address" } + ], + "name": "getStakedAssetData", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "stakedTokenTotalSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "stakedTokenTotalRedeemableAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "stakeCooldownSeconds", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "stakeUnstakeWindow", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "stakedTokenPriceEth", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rewardTokenPriceEth", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "stakeApy", + "type": "uint256" + }, + { + "internalType": "uint128", + "name": "distributionPerSecond", + "type": "uint128" + }, + { + "internalType": "bool", + "name": "inPostSlashingPeriod", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "distributionEnd", + "type": "uint256" + } + ], + "internalType": "struct IStakedTokenDataProvider.StakedTokenData", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "stakedAssets", + "type": "address[]" + }, + { "internalType": "address[]", "name": "oracles", "type": "address[]" } + ], + "name": "getStakedAssetDataBatch", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "stakedTokenTotalSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "stakedTokenTotalRedeemableAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "stakeCooldownSeconds", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "stakeUnstakeWindow", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "stakedTokenPriceEth", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rewardTokenPriceEth", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "stakeApy", + "type": "uint256" + }, + { + "internalType": "uint128", + "name": "distributionPerSecond", + "type": "uint128" + }, + { + "internalType": "bool", + "name": "inPostSlashingPeriod", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "distributionEnd", + "type": "uint256" + } + ], + "internalType": "struct IStakedTokenDataProvider.StakedTokenData[]", + "name": "", + "type": "tuple[]" + }, + { "internalType": "uint256", "name": "", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "stakedAsset", "type": "address" }, + { "internalType": "address", "name": "oracle", "type": "address" }, + { "internalType": "address", "name": "user", "type": "address" } + ], + "name": "getStakedUserData", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "stakedTokenTotalSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "stakedTokenTotalRedeemableAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "stakeCooldownSeconds", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "stakeUnstakeWindow", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "stakedTokenPriceEth", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rewardTokenPriceEth", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "stakeApy", + "type": "uint256" + }, + { + "internalType": "uint128", + "name": "distributionPerSecond", + "type": "uint128" + }, + { + "internalType": "bool", + "name": "inPostSlashingPeriod", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "distributionEnd", + "type": "uint256" + } + ], + "internalType": "struct IStakedTokenDataProvider.StakedTokenData", + "name": "", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "stakedTokenUserBalance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "stakedTokenRedeemableAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "underlyingTokenUserBalance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rewardsToClaim", + "type": "uint256" + }, + { + "internalType": "uint40", + "name": "userCooldownTimestamp", + "type": "uint40" + }, + { + "internalType": "uint216", + "name": "userCooldownAmount", + "type": "uint216" + } + ], + "internalType": "struct IStakedTokenDataProvider.StakedTokenUserData", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "stakedAssets", + "type": "address[]" + }, + { "internalType": "address[]", "name": "oracles", "type": "address[]" }, + { "internalType": "address", "name": "user", "type": "address" } + ], + "name": "getStakedUserDataBatch", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "stakedTokenTotalSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "stakedTokenTotalRedeemableAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "stakeCooldownSeconds", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "stakeUnstakeWindow", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "stakedTokenPriceEth", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rewardTokenPriceEth", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "stakeApy", + "type": "uint256" + }, + { + "internalType": "uint128", + "name": "distributionPerSecond", + "type": "uint128" + }, + { + "internalType": "bool", + "name": "inPostSlashingPeriod", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "distributionEnd", + "type": "uint256" + } + ], + "internalType": "struct IStakedTokenDataProvider.StakedTokenData[]", + "name": "", + "type": "tuple[]" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "stakedTokenUserBalance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "stakedTokenRedeemableAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "underlyingTokenUserBalance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rewardsToClaim", + "type": "uint256" + }, + { + "internalType": "uint40", + "name": "userCooldownTimestamp", + "type": "uint40" + }, + { + "internalType": "uint216", + "name": "userCooldownAmount", + "type": "uint216" + } + ], + "internalType": "struct IStakedTokenDataProvider.StakedTokenUserData[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + } + ] +} diff --git a/packages/contract-helpers/src/V3-uiStakeDataProvider-contract/index.ts b/packages/contract-helpers/src/V3-uiStakeDataProvider-contract/index.ts new file mode 100644 index 00000000..b2ffeea8 --- /dev/null +++ b/packages/contract-helpers/src/V3-uiStakeDataProvider-contract/index.ts @@ -0,0 +1,113 @@ +import { providers } from 'ethers'; + +import { Abi as IStakedTokenDataProvider, Abi__factory } from './typechain'; + +import { + StakedTokenData, + GeneralStakeUIDataHumanized, + StakedContractUserData, + GetUserStakeUIDataHumanized, +} from './types'; + +type EthAddress = string; + +export interface UiStakeDataProviderInterface { + getStakedAssetDataBatch: ( + stakedAssets: EthAddress[], + oracles: EthAddress[], + ) => Promise; + getUserStakeUIDataHumanized: (params: { + user: string; + stakedAssets: EthAddress[]; + oracles: EthAddress[]; + }) => Promise; +} + +export type UiStakeDataProviderContext = { + uiStakeDataProvider: string; + provider: providers.Provider; +}; + +export class UiStakeDataProviderV3 implements UiStakeDataProviderInterface { + private readonly _contract: IStakedTokenDataProvider; + + public constructor(context: UiStakeDataProviderContext) { + this._contract = Abi__factory.connect( + context.uiStakeDataProvider, + context.provider, + ); + } + + public async getUserStakeUIDataHumanized({ + user, + stakedAssets, + oracles, + }: { + user: string; + stakedAssets: EthAddress[]; + oracles: EthAddress[]; + }): Promise { + const [, stakedUserData] = await this._contract.getStakedUserDataBatch( + stakedAssets, + oracles, + user, + ); + + // // NOTE only fetching eth price here, should we call oracle directly? + const [, ethPrice] = await this._contract.getStakedAssetDataBatch( + stakedAssets, + oracles, + ); + const parsedUserStakedData = await handleUserStakedData(stakedUserData); + + return { + stakeUserData: parsedUserStakedData, + ethPriceUsd: ethPrice.toString(), // ethPrice.toString(), + }; + } + + public async getStakedAssetDataBatch( + stakedAssets: EthAddress[], + oracles: EthAddress[], + ): Promise { + const [stakedData, ethPrice] = await this._contract.getStakedAssetDataBatch( + stakedAssets, + oracles, + ); + + const parsedStakedData = await handleParsedStakedData(stakedData); + + return { stakeData: parsedStakedData, ethPriceUsd: ethPrice.toString() }; + } +} + +function handleUserStakedData(stakeUserData: StakedContractUserData[]) { + return stakeUserData.map((data: StakedContractUserData) => { + return { + stakeTokenUserBalance: data.stakedTokenUserBalance.toString(), + underlyingTokenUserBalance: data.underlyingTokenUserBalance.toString(), + stakeTokenRedeemableAmount: data.stakedTokenRedeemableAmount.toString(), + userCooldownAmount: data.userCooldownAmount.toString(), + userCooldownTimestamp: data.userCooldownTimestamp, + userIncentivesToClaim: data.rewardsToClaim.toString(), + }; + }); +} + +function handleParsedStakedData(stakedData: StakedTokenData[]) { + return stakedData.map((data: StakedTokenData) => { + return { + inPostSlashingPeriod: data.inPostSlashingPeriod, + stakeTokenTotalSupply: data.stakedTokenTotalSupply.toString(), + stakeTokenTotalRedeemableAmount: + data.stakedTokenTotalRedeemableAmount.toString(), + stakeCooldownSeconds: data.stakeCooldownSeconds.toNumber(), + stakeUnstakeWindow: data.stakeUnstakeWindow.toNumber(), + stakeTokenPriceEth: data.stakedTokenPriceEth.toString(), + rewardTokenPriceEth: data.rewardTokenPriceEth.toString(), + stakeApy: data.stakeApy.toString(), + distributionPerSecond: data.distributionPerSecond.toString(), + distributionEnd: data.distributionEnd.toString(), + }; + }); +} diff --git a/packages/contract-helpers/src/V3-uiStakeDataProvider-contract-copy/typechain/factories/IUistakeDataProviderV3.d.ts b/packages/contract-helpers/src/V3-uiStakeDataProvider-contract/typechain/Abi.ts similarity index 63% rename from packages/contract-helpers/src/V3-uiStakeDataProvider-contract-copy/typechain/factories/IUistakeDataProviderV3.d.ts rename to packages/contract-helpers/src/V3-uiStakeDataProvider-contract/typechain/Abi.ts index d5c42b9a..8d134556 100644 --- a/packages/contract-helpers/src/V3-uiStakeDataProvider-contract-copy/typechain/factories/IUistakeDataProviderV3.d.ts +++ b/packages/contract-helpers/src/V3-uiStakeDataProvider-contract/typechain/Abi.ts @@ -1,4 +1,5 @@ /* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ /* eslint-disable */ import type { BaseContract, @@ -9,15 +10,15 @@ import type { PopulatedTransaction, Signer, utils, -} from 'ethers'; -import type { FunctionFragment, Result } from '@ethersproject/abi'; -import type { Listener, Provider } from '@ethersproject/providers'; +} from "ethers"; +import type { FunctionFragment, Result } from "@ethersproject/abi"; +import type { Listener, Provider } from "@ethersproject/providers"; import type { TypedEventFilter, TypedEvent, TypedListener, OnEvent, -} from '../common'; +} from "./common"; export declare namespace IStakedTokenDataProvider { export type StakedTokenDataStruct = { @@ -43,7 +44,7 @@ export declare namespace IStakedTokenDataProvider { BigNumber, BigNumber, boolean, - BigNumber, + BigNumber ] & { stakedTokenTotalSupply: BigNumber; stakedTokenTotalRedeemableAmount: BigNumber; @@ -72,7 +73,7 @@ export declare namespace IStakedTokenDataProvider { BigNumber, BigNumber, number, - BigNumber, + BigNumber ] & { stakedTokenUserBalance: BigNumber; stakedTokenRedeemableAmount: BigNumber; @@ -85,82 +86,89 @@ export declare namespace IStakedTokenDataProvider { export interface AbiInterface extends utils.Interface { functions: { - 'AAVE_PRICE_FEED()': FunctionFragment; - 'ETH_USD_PRICE_FEED()': FunctionFragment; - 'STAKED_AAVE()': FunctionFragment; - 'getStakedAssetData(address,address)': FunctionFragment; - 'getStakedAssetDataBatch(address[],address[])': FunctionFragment; - 'getStakedUserData(address,address,address)': FunctionFragment; - 'getStakedUserDataBatch(address[],address[],address)': FunctionFragment; + "AAVE_PRICE_FEED()": FunctionFragment; + "ETH_USD_PRICE_FEED()": FunctionFragment; + "STAKED_AAVE()": FunctionFragment; + "STAKED_GHO()": FunctionFragment; + "getStakedAssetData(address,address)": FunctionFragment; + "getStakedAssetDataBatch(address[],address[])": FunctionFragment; + "getStakedUserData(address,address,address)": FunctionFragment; + "getStakedUserDataBatch(address[],address[],address)": FunctionFragment; }; getFunction( nameOrSignatureOrTopic: - | 'AAVE_PRICE_FEED' - | 'ETH_USD_PRICE_FEED' - | 'STAKED_AAVE' - | 'getStakedAssetData' - | 'getStakedAssetDataBatch' - | 'getStakedUserData' - | 'getStakedUserDataBatch', + | "AAVE_PRICE_FEED" + | "ETH_USD_PRICE_FEED" + | "STAKED_AAVE" + | "STAKED_GHO" + | "getStakedAssetData" + | "getStakedAssetDataBatch" + | "getStakedUserData" + | "getStakedUserDataBatch" ): FunctionFragment; encodeFunctionData( - functionFragment: 'AAVE_PRICE_FEED', - values?: undefined, + functionFragment: "AAVE_PRICE_FEED", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "ETH_USD_PRICE_FEED", + values?: undefined ): string; encodeFunctionData( - functionFragment: 'ETH_USD_PRICE_FEED', - values?: undefined, + functionFragment: "STAKED_AAVE", + values?: undefined ): string; encodeFunctionData( - functionFragment: 'STAKED_AAVE', - values?: undefined, + functionFragment: "STAKED_GHO", + values?: undefined ): string; encodeFunctionData( - functionFragment: 'getStakedAssetData', - values: [string, string], + functionFragment: "getStakedAssetData", + values: [string, string] ): string; encodeFunctionData( - functionFragment: 'getStakedAssetDataBatch', - values: [string[], string[]], + functionFragment: "getStakedAssetDataBatch", + values: [string[], string[]] ): string; encodeFunctionData( - functionFragment: 'getStakedUserData', - values: [string, string, string], + functionFragment: "getStakedUserData", + values: [string, string, string] ): string; encodeFunctionData( - functionFragment: 'getStakedUserDataBatch', - values: [string[], string[], string], + functionFragment: "getStakedUserDataBatch", + values: [string[], string[], string] ): string; decodeFunctionResult( - functionFragment: 'AAVE_PRICE_FEED', - data: BytesLike, + functionFragment: "AAVE_PRICE_FEED", + data: BytesLike ): Result; decodeFunctionResult( - functionFragment: 'ETH_USD_PRICE_FEED', - data: BytesLike, + functionFragment: "ETH_USD_PRICE_FEED", + data: BytesLike ): Result; decodeFunctionResult( - functionFragment: 'STAKED_AAVE', - data: BytesLike, + functionFragment: "STAKED_AAVE", + data: BytesLike ): Result; + decodeFunctionResult(functionFragment: "STAKED_GHO", data: BytesLike): Result; decodeFunctionResult( - functionFragment: 'getStakedAssetData', - data: BytesLike, + functionFragment: "getStakedAssetData", + data: BytesLike ): Result; decodeFunctionResult( - functionFragment: 'getStakedAssetDataBatch', - data: BytesLike, + functionFragment: "getStakedAssetDataBatch", + data: BytesLike ): Result; decodeFunctionResult( - functionFragment: 'getStakedUserData', - data: BytesLike, + functionFragment: "getStakedUserData", + data: BytesLike ): Result; decodeFunctionResult( - functionFragment: 'getStakedUserDataBatch', - data: BytesLike, + functionFragment: "getStakedUserDataBatch", + data: BytesLike ): Result; events: {}; @@ -176,15 +184,15 @@ export interface Abi extends BaseContract { queryFilter( event: TypedEventFilter, fromBlockOrBlockhash?: string | number | undefined, - toBlock?: string | number | undefined, + toBlock?: string | number | undefined ): Promise>; listeners( - eventFilter?: TypedEventFilter, + eventFilter?: TypedEventFilter ): Array>; listeners(eventName?: string): Array; removeAllListeners( - eventFilter: TypedEventFilter, + eventFilter: TypedEventFilter ): this; removeAllListeners(eventName?: string): this; off: OnEvent; @@ -199,41 +207,43 @@ export interface Abi extends BaseContract { STAKED_AAVE(overrides?: CallOverrides): Promise<[string]>; + STAKED_GHO(overrides?: CallOverrides): Promise<[string]>; + getStakedAssetData( stakedAsset: string, - oracleAddress: string, - overrides?: CallOverrides, + oracle: string, + overrides?: CallOverrides ): Promise<[IStakedTokenDataProvider.StakedTokenDataStructOutput]>; getStakedAssetDataBatch( - stakedTokens: string[], - oracleAddresses: string[], - overrides?: CallOverrides, + stakedAssets: string[], + oracles: string[], + overrides?: CallOverrides ): Promise< [IStakedTokenDataProvider.StakedTokenDataStructOutput[], BigNumber] >; getStakedUserData( stakedAsset: string, - oracleAddress: string, + oracle: string, user: string, - overrides?: CallOverrides, + overrides?: CallOverrides ): Promise< [ IStakedTokenDataProvider.StakedTokenDataStructOutput, - IStakedTokenDataProvider.StakedTokenUserDataStructOutput, + IStakedTokenDataProvider.StakedTokenUserDataStructOutput ] >; getStakedUserDataBatch( - stakedTokens: string[], - oracleAddresses: string[], - userAddress: string, - overrides?: CallOverrides, + stakedAssets: string[], + oracles: string[], + user: string, + overrides?: CallOverrides ): Promise< [ IStakedTokenDataProvider.StakedTokenDataStructOutput[], - IStakedTokenDataProvider.StakedTokenUserDataStructOutput[], + IStakedTokenDataProvider.StakedTokenUserDataStructOutput[] ] >; }; @@ -244,41 +254,43 @@ export interface Abi extends BaseContract { STAKED_AAVE(overrides?: CallOverrides): Promise; + STAKED_GHO(overrides?: CallOverrides): Promise; + getStakedAssetData( stakedAsset: string, - oracleAddress: string, - overrides?: CallOverrides, + oracle: string, + overrides?: CallOverrides ): Promise; getStakedAssetDataBatch( - stakedTokens: string[], - oracleAddresses: string[], - overrides?: CallOverrides, + stakedAssets: string[], + oracles: string[], + overrides?: CallOverrides ): Promise< [IStakedTokenDataProvider.StakedTokenDataStructOutput[], BigNumber] >; getStakedUserData( stakedAsset: string, - oracleAddress: string, + oracle: string, user: string, - overrides?: CallOverrides, + overrides?: CallOverrides ): Promise< [ IStakedTokenDataProvider.StakedTokenDataStructOutput, - IStakedTokenDataProvider.StakedTokenUserDataStructOutput, + IStakedTokenDataProvider.StakedTokenUserDataStructOutput ] >; getStakedUserDataBatch( - stakedTokens: string[], - oracleAddresses: string[], - userAddress: string, - overrides?: CallOverrides, + stakedAssets: string[], + oracles: string[], + user: string, + overrides?: CallOverrides ): Promise< [ IStakedTokenDataProvider.StakedTokenDataStructOutput[], - IStakedTokenDataProvider.StakedTokenUserDataStructOutput[], + IStakedTokenDataProvider.StakedTokenUserDataStructOutput[] ] >; @@ -289,41 +301,43 @@ export interface Abi extends BaseContract { STAKED_AAVE(overrides?: CallOverrides): Promise; + STAKED_GHO(overrides?: CallOverrides): Promise; + getStakedAssetData( stakedAsset: string, - oracleAddress: string, - overrides?: CallOverrides, + oracle: string, + overrides?: CallOverrides ): Promise; getStakedAssetDataBatch( - stakedTokens: string[], - oracleAddresses: string[], - overrides?: CallOverrides, + stakedAssets: string[], + oracles: string[], + overrides?: CallOverrides ): Promise< [IStakedTokenDataProvider.StakedTokenDataStructOutput[], BigNumber] >; getStakedUserData( stakedAsset: string, - oracleAddress: string, + oracle: string, user: string, - overrides?: CallOverrides, + overrides?: CallOverrides ): Promise< [ IStakedTokenDataProvider.StakedTokenDataStructOutput, - IStakedTokenDataProvider.StakedTokenUserDataStructOutput, + IStakedTokenDataProvider.StakedTokenUserDataStructOutput ] >; getStakedUserDataBatch( - stakedTokens: string[], - oracleAddresses: string[], - userAddress: string, - overrides?: CallOverrides, + stakedAssets: string[], + oracles: string[], + user: string, + overrides?: CallOverrides ): Promise< [ IStakedTokenDataProvider.StakedTokenDataStructOutput[], - IStakedTokenDataProvider.StakedTokenUserDataStructOutput[], + IStakedTokenDataProvider.StakedTokenUserDataStructOutput[] ] >; }; @@ -337,30 +351,32 @@ export interface Abi extends BaseContract { STAKED_AAVE(overrides?: CallOverrides): Promise; + STAKED_GHO(overrides?: CallOverrides): Promise; + getStakedAssetData( stakedAsset: string, - oracleAddress: string, - overrides?: CallOverrides, + oracle: string, + overrides?: CallOverrides ): Promise; getStakedAssetDataBatch( - stakedTokens: string[], - oracleAddresses: string[], - overrides?: CallOverrides, + stakedAssets: string[], + oracles: string[], + overrides?: CallOverrides ): Promise; getStakedUserData( stakedAsset: string, - oracleAddress: string, + oracle: string, user: string, - overrides?: CallOverrides, + overrides?: CallOverrides ): Promise; getStakedUserDataBatch( - stakedTokens: string[], - oracleAddresses: string[], - userAddress: string, - overrides?: CallOverrides, + stakedAssets: string[], + oracles: string[], + user: string, + overrides?: CallOverrides ): Promise; }; @@ -368,35 +384,37 @@ export interface Abi extends BaseContract { AAVE_PRICE_FEED(overrides?: CallOverrides): Promise; ETH_USD_PRICE_FEED( - overrides?: CallOverrides, + overrides?: CallOverrides ): Promise; STAKED_AAVE(overrides?: CallOverrides): Promise; + STAKED_GHO(overrides?: CallOverrides): Promise; + getStakedAssetData( stakedAsset: string, - oracleAddress: string, - overrides?: CallOverrides, + oracle: string, + overrides?: CallOverrides ): Promise; getStakedAssetDataBatch( - stakedTokens: string[], - oracleAddresses: string[], - overrides?: CallOverrides, + stakedAssets: string[], + oracles: string[], + overrides?: CallOverrides ): Promise; getStakedUserData( stakedAsset: string, - oracleAddress: string, + oracle: string, user: string, - overrides?: CallOverrides, + overrides?: CallOverrides ): Promise; getStakedUserDataBatch( - stakedTokens: string[], - oracleAddresses: string[], - userAddress: string, - overrides?: CallOverrides, + stakedAssets: string[], + oracles: string[], + user: string, + overrides?: CallOverrides ): Promise; }; } diff --git a/packages/contract-helpers/src/V3-uiStakeDataProvider-contract-copy/typechain/common.ts b/packages/contract-helpers/src/V3-uiStakeDataProvider-contract/typechain/common.ts similarity index 81% rename from packages/contract-helpers/src/V3-uiStakeDataProvider-contract-copy/typechain/common.ts rename to packages/contract-helpers/src/V3-uiStakeDataProvider-contract/typechain/common.ts index 0fb82cd3..2fc40c7f 100644 --- a/packages/contract-helpers/src/V3-uiStakeDataProvider-contract-copy/typechain/common.ts +++ b/packages/contract-helpers/src/V3-uiStakeDataProvider-contract/typechain/common.ts @@ -1,11 +1,12 @@ /* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ /* eslint-disable */ -import type { Listener } from '@ethersproject/providers'; -import type { Event, EventFilter } from 'ethers'; +import type { Listener } from "@ethersproject/providers"; +import type { Event, EventFilter } from "ethers"; export interface TypedEvent< TArgsArray extends Array = any, - TArgsObject = any, + TArgsObject = any > extends Event { args: TArgsArray & TArgsObject; } @@ -22,7 +23,7 @@ type __TypechainArgsArray = T extends TypedEvent ? U : never; export interface OnEvent { ( eventFilter: TypedEventFilter, - listener: TypedListener, + listener: TypedListener ): TRes; (eventName: string, listener: Listener): TRes; } @@ -39,5 +40,5 @@ export type GetContractTypeFromFactory = F extends MinEthersFactory< : never; export type GetARGsTypeFromFactory = F extends MinEthersFactory - ? Parameters + ? Parameters : never; diff --git a/packages/contract-helpers/src/V3-uiStakeDataProvider-contract/typechain/factories/Abi__factory.ts b/packages/contract-helpers/src/V3-uiStakeDataProvider-contract/typechain/factories/Abi__factory.ts new file mode 100644 index 00000000..7cffa216 --- /dev/null +++ b/packages/contract-helpers/src/V3-uiStakeDataProvider-contract/typechain/factories/Abi__factory.ts @@ -0,0 +1,491 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Signer, utils } from "ethers"; +import type { Provider } from "@ethersproject/providers"; +import type { Abi, AbiInterface } from "../Abi"; + +const _abi = [ + { + inputs: [ + { + internalType: "address", + name: "stkAave", + type: "address", + }, + { + internalType: "address", + name: "stkGho", + type: "address", + }, + { + internalType: "address", + name: "ethUsdPriceFeed", + type: "address", + }, + { + internalType: "address", + name: "aavePriceFeed", + type: "address", + }, + ], + stateMutability: "nonpayable", + type: "constructor", + }, + { + inputs: [], + name: "AAVE_PRICE_FEED", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "ETH_USD_PRICE_FEED", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "STAKED_AAVE", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "STAKED_GHO", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "stakedAsset", + type: "address", + }, + { + internalType: "address", + name: "oracle", + type: "address", + }, + ], + name: "getStakedAssetData", + outputs: [ + { + components: [ + { + internalType: "uint256", + name: "stakedTokenTotalSupply", + type: "uint256", + }, + { + internalType: "uint256", + name: "stakedTokenTotalRedeemableAmount", + type: "uint256", + }, + { + internalType: "uint256", + name: "stakeCooldownSeconds", + type: "uint256", + }, + { + internalType: "uint256", + name: "stakeUnstakeWindow", + type: "uint256", + }, + { + internalType: "uint256", + name: "stakedTokenPriceEth", + type: "uint256", + }, + { + internalType: "uint256", + name: "rewardTokenPriceEth", + type: "uint256", + }, + { + internalType: "uint256", + name: "stakeApy", + type: "uint256", + }, + { + internalType: "uint128", + name: "distributionPerSecond", + type: "uint128", + }, + { + internalType: "bool", + name: "inPostSlashingPeriod", + type: "bool", + }, + { + internalType: "uint256", + name: "distributionEnd", + type: "uint256", + }, + ], + internalType: "struct IStakedTokenDataProvider.StakedTokenData", + name: "", + type: "tuple", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address[]", + name: "stakedAssets", + type: "address[]", + }, + { + internalType: "address[]", + name: "oracles", + type: "address[]", + }, + ], + name: "getStakedAssetDataBatch", + outputs: [ + { + components: [ + { + internalType: "uint256", + name: "stakedTokenTotalSupply", + type: "uint256", + }, + { + internalType: "uint256", + name: "stakedTokenTotalRedeemableAmount", + type: "uint256", + }, + { + internalType: "uint256", + name: "stakeCooldownSeconds", + type: "uint256", + }, + { + internalType: "uint256", + name: "stakeUnstakeWindow", + type: "uint256", + }, + { + internalType: "uint256", + name: "stakedTokenPriceEth", + type: "uint256", + }, + { + internalType: "uint256", + name: "rewardTokenPriceEth", + type: "uint256", + }, + { + internalType: "uint256", + name: "stakeApy", + type: "uint256", + }, + { + internalType: "uint128", + name: "distributionPerSecond", + type: "uint128", + }, + { + internalType: "bool", + name: "inPostSlashingPeriod", + type: "bool", + }, + { + internalType: "uint256", + name: "distributionEnd", + type: "uint256", + }, + ], + internalType: "struct IStakedTokenDataProvider.StakedTokenData[]", + name: "", + type: "tuple[]", + }, + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "stakedAsset", + type: "address", + }, + { + internalType: "address", + name: "oracle", + type: "address", + }, + { + internalType: "address", + name: "user", + type: "address", + }, + ], + name: "getStakedUserData", + outputs: [ + { + components: [ + { + internalType: "uint256", + name: "stakedTokenTotalSupply", + type: "uint256", + }, + { + internalType: "uint256", + name: "stakedTokenTotalRedeemableAmount", + type: "uint256", + }, + { + internalType: "uint256", + name: "stakeCooldownSeconds", + type: "uint256", + }, + { + internalType: "uint256", + name: "stakeUnstakeWindow", + type: "uint256", + }, + { + internalType: "uint256", + name: "stakedTokenPriceEth", + type: "uint256", + }, + { + internalType: "uint256", + name: "rewardTokenPriceEth", + type: "uint256", + }, + { + internalType: "uint256", + name: "stakeApy", + type: "uint256", + }, + { + internalType: "uint128", + name: "distributionPerSecond", + type: "uint128", + }, + { + internalType: "bool", + name: "inPostSlashingPeriod", + type: "bool", + }, + { + internalType: "uint256", + name: "distributionEnd", + type: "uint256", + }, + ], + internalType: "struct IStakedTokenDataProvider.StakedTokenData", + name: "", + type: "tuple", + }, + { + components: [ + { + internalType: "uint256", + name: "stakedTokenUserBalance", + type: "uint256", + }, + { + internalType: "uint256", + name: "stakedTokenRedeemableAmount", + type: "uint256", + }, + { + internalType: "uint256", + name: "underlyingTokenUserBalance", + type: "uint256", + }, + { + internalType: "uint256", + name: "rewardsToClaim", + type: "uint256", + }, + { + internalType: "uint40", + name: "userCooldownTimestamp", + type: "uint40", + }, + { + internalType: "uint216", + name: "userCooldownAmount", + type: "uint216", + }, + ], + internalType: "struct IStakedTokenDataProvider.StakedTokenUserData", + name: "", + type: "tuple", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address[]", + name: "stakedAssets", + type: "address[]", + }, + { + internalType: "address[]", + name: "oracles", + type: "address[]", + }, + { + internalType: "address", + name: "user", + type: "address", + }, + ], + name: "getStakedUserDataBatch", + outputs: [ + { + components: [ + { + internalType: "uint256", + name: "stakedTokenTotalSupply", + type: "uint256", + }, + { + internalType: "uint256", + name: "stakedTokenTotalRedeemableAmount", + type: "uint256", + }, + { + internalType: "uint256", + name: "stakeCooldownSeconds", + type: "uint256", + }, + { + internalType: "uint256", + name: "stakeUnstakeWindow", + type: "uint256", + }, + { + internalType: "uint256", + name: "stakedTokenPriceEth", + type: "uint256", + }, + { + internalType: "uint256", + name: "rewardTokenPriceEth", + type: "uint256", + }, + { + internalType: "uint256", + name: "stakeApy", + type: "uint256", + }, + { + internalType: "uint128", + name: "distributionPerSecond", + type: "uint128", + }, + { + internalType: "bool", + name: "inPostSlashingPeriod", + type: "bool", + }, + { + internalType: "uint256", + name: "distributionEnd", + type: "uint256", + }, + ], + internalType: "struct IStakedTokenDataProvider.StakedTokenData[]", + name: "", + type: "tuple[]", + }, + { + components: [ + { + internalType: "uint256", + name: "stakedTokenUserBalance", + type: "uint256", + }, + { + internalType: "uint256", + name: "stakedTokenRedeemableAmount", + type: "uint256", + }, + { + internalType: "uint256", + name: "underlyingTokenUserBalance", + type: "uint256", + }, + { + internalType: "uint256", + name: "rewardsToClaim", + type: "uint256", + }, + { + internalType: "uint40", + name: "userCooldownTimestamp", + type: "uint40", + }, + { + internalType: "uint216", + name: "userCooldownAmount", + type: "uint216", + }, + ], + internalType: "struct IStakedTokenDataProvider.StakedTokenUserData[]", + name: "", + type: "tuple[]", + }, + ], + stateMutability: "view", + type: "function", + }, +] as const; + +export class Abi__factory { + static readonly abi = _abi; + static createInterface(): AbiInterface { + return new utils.Interface(_abi) as AbiInterface; + } + static connect(address: string, signerOrProvider: Signer | Provider): Abi { + return new Contract(address, _abi, signerOrProvider) as Abi; + } +} diff --git a/packages/contract-helpers/src/V3-uiStakeDataProvider-contract/typechain/factories/index.ts b/packages/contract-helpers/src/V3-uiStakeDataProvider-contract/typechain/factories/index.ts new file mode 100644 index 00000000..f1d4cddb --- /dev/null +++ b/packages/contract-helpers/src/V3-uiStakeDataProvider-contract/typechain/factories/index.ts @@ -0,0 +1,4 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +export { Abi__factory } from "./Abi__factory"; diff --git a/packages/contract-helpers/src/V3-uiStakeDataProvider-contract/typechain/index.ts b/packages/contract-helpers/src/V3-uiStakeDataProvider-contract/typechain/index.ts new file mode 100644 index 00000000..c937049e --- /dev/null +++ b/packages/contract-helpers/src/V3-uiStakeDataProvider-contract/typechain/index.ts @@ -0,0 +1,6 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +export type { Abi } from "./Abi"; +export * as factories from "./factories"; +export { Abi__factory } from "./factories/Abi__factory"; diff --git a/packages/contract-helpers/src/V3-uiStakeDataProvider-contract/types.ts b/packages/contract-helpers/src/V3-uiStakeDataProvider-contract/types.ts new file mode 100644 index 00000000..a1efadc1 --- /dev/null +++ b/packages/contract-helpers/src/V3-uiStakeDataProvider-contract/types.ts @@ -0,0 +1,60 @@ +import { BigNumber } from 'ethers'; + +export type StakedTokenData = { + stakedTokenTotalSupply: BigNumber; + stakedTokenTotalRedeemableAmount: BigNumber; + stakeCooldownSeconds: BigNumber; + stakeUnstakeWindow: BigNumber; + rewardTokenPriceEth: BigNumber; + distributionEnd: BigNumber; + distributionPerSecond: BigNumber; + stakedTokenPriceEth: BigNumber; + stakeApy: BigNumber; + inPostSlashingPeriod: boolean; +}; + +export type StakedContractUserData = { + stakedTokenUserBalance: BigNumber; + underlyingTokenUserBalance: BigNumber; + stakedTokenRedeemableAmount: BigNumber; + userCooldownAmount: BigNumber; + userCooldownTimestamp: number; + rewardsToClaim: BigNumber; +}; + +export type StakeUIUserData = { + stakeTokenUserBalance: string; + underlyingTokenUserBalance: string; + stakeTokenRedeemableAmount: string; + userCooldownAmount: string; + userCooldownTimestamp: number; + userIncentivesToClaim: string; +}; + +export type GeneralStakeUIDataHumanized = { + stakeData: Array<{ + inPostSlashingPeriod: boolean; + stakeTokenTotalSupply: string; + stakeTokenTotalRedeemableAmount: string; + stakeCooldownSeconds: number; + stakeUnstakeWindow: number; + stakeTokenPriceEth: string; + rewardTokenPriceEth: string; + stakeApy: string; + distributionPerSecond: string; + distributionEnd: string; + }>; + ethPriceUsd: string; +}; + +export type GetUserStakeUIDataHumanized = { + stakeUserData: Array<{ + stakeTokenUserBalance: string; + underlyingTokenUserBalance: string; + stakeTokenRedeemableAmount: string; + userCooldownAmount: string; + userCooldownTimestamp: number; + userIncentivesToClaim: string; + }>; + ethPriceUsd: string; +}; diff --git a/packages/contract-helpers/src/V3-uiStakeDataProvider-contract-copy/uiStakeDataProvider.test.ts b/packages/contract-helpers/src/V3-uiStakeDataProvider-contract/uiStakeDataProvider.test.ts similarity index 100% rename from packages/contract-helpers/src/V3-uiStakeDataProvider-contract-copy/uiStakeDataProvider.test.ts rename to packages/contract-helpers/src/V3-uiStakeDataProvider-contract/uiStakeDataProvider.test.ts diff --git a/packages/contract-helpers/src/commons/types.ts b/packages/contract-helpers/src/commons/types.ts index 0c12eff7..d6583d50 100644 --- a/packages/contract-helpers/src/commons/types.ts +++ b/packages/contract-helpers/src/commons/types.ts @@ -154,6 +154,7 @@ export enum GovernanceVote { export enum Stake { aave = 'aave', bpt = 'bpt', + gho = 'gho', } export type GasRecommendationType = Record< diff --git a/packages/contract-helpers/src/index.ts b/packages/contract-helpers/src/index.ts index 8c594b7f..47a07ff0 100644 --- a/packages/contract-helpers/src/index.ts +++ b/packages/contract-helpers/src/index.ts @@ -8,7 +8,7 @@ export * from './v3-UiPoolDataProvider-contract'; export * from './wallet-balance-provider'; export * from './cl-feed-registry'; // export * from './uiStakeDataProvider-contract'; -export * from './V3-uiStakeDataProvider-contract-copy'; +export * from './V3-uiStakeDataProvider-contract'; // services export * from './incentive-controller';