diff --git a/src/apps/kwenta/kwenta.module.ts b/src/apps/kwenta/kwenta.module.ts index 56e4b8c97..67da1bcc8 100644 --- a/src/apps/kwenta/kwenta.module.ts +++ b/src/apps/kwenta/kwenta.module.ts @@ -5,11 +5,12 @@ import { AbstractApp } from '~app/app.dynamic-module'; import { SynthetixContractFactory } from '../synthetix/contracts'; import { KwentaContractFactory } from './contracts'; +import { OptimismKwentaEscrowV2ContractPositionFetcher } from './optimism/kwenta.escrow-v2.contract-position-fetcher'; import { OptimismKwentaEscrowContractPositionFetcher } from './optimism/kwenta.escrow.contract-position-fetcher'; import { OptimismKwentaPerpV1CrossMarginContractPositionFetcher } from './optimism/kwenta.perp-v1-cross-margin.contract-position-fetcher'; import { OptimismKwentaPerpV2SmartMarginContractPositionFetcher } from './optimism/kwenta.perp-v2-smart-margin.contract-position-fetcher'; -import { OptimismKwentaStakingContractPositionFetcher } from './optimism/kwenta.staking.contract-position-fetcher'; import { OptimismKwentaStakingV2ContractPositionFetcher } from './optimism/kwenta.staking-v2.contract-position-fetcher'; +import { OptimismKwentaStakingContractPositionFetcher } from './optimism/kwenta.staking.contract-position-fetcher'; @Module({ providers: [ @@ -20,6 +21,7 @@ import { OptimismKwentaStakingV2ContractPositionFetcher } from './optimism/kwent OptimismKwentaStakingContractPositionFetcher, OptimismKwentaEscrowContractPositionFetcher, OptimismKwentaStakingV2ContractPositionFetcher, + OptimismKwentaEscrowV2ContractPositionFetcher, ], }) export class KwentaAppModule extends AbstractApp() { } diff --git a/src/apps/kwenta/optimism/kwenta.escrow-v2.contract-position-fetcher.ts b/src/apps/kwenta/optimism/kwenta.escrow-v2.contract-position-fetcher.ts new file mode 100644 index 000000000..f6db68935 --- /dev/null +++ b/src/apps/kwenta/optimism/kwenta.escrow-v2.contract-position-fetcher.ts @@ -0,0 +1,33 @@ +import { Inject } from '@nestjs/common'; + +import { APP_TOOLKIT, IAppToolkit } from '~app-toolkit/app-toolkit.interface'; +import { PositionTemplate } from '~app-toolkit/decorators/position-template.decorator'; +import { GetTokenDefinitionsParams, GetTokenBalancesParams } from '~position/template/contract-position.template.types'; +import { VotingEscrowTemplateContractPositionFetcher } from '~position/template/voting-escrow.template.contract-position-fetcher'; + +import { KwentaContractFactory, KwentaStakingV2 } from '../contracts'; + +@PositionTemplate() +export class OptimismKwentaEscrowV2ContractPositionFetcher extends VotingEscrowTemplateContractPositionFetcher { + groupLabel = 'Escrow V2'; + veTokenAddress = '0x61294940ce7cd1bda10e349adc5b538b722ceb88'; + + constructor( + @Inject(APP_TOOLKIT) protected readonly appToolkit: IAppToolkit, + @Inject(KwentaContractFactory) protected readonly contractFactory: KwentaContractFactory, + ) { + super(appToolkit); + } + + getEscrowContract(address: string): KwentaStakingV2 { + return this.contractFactory.kwentaStakingV2({ address, network: this.network }); + } + + getEscrowedTokenAddress({ contract }: GetTokenDefinitionsParams) { + return contract.kwenta(); + } + + async getEscrowedTokenBalance({ contract, address }: GetTokenBalancesParams) { + return await contract.unstakedEscrowedBalanceOf(address); + } +}