diff --git a/src/apps/notional-finance-v3/arbitrum/notional-finance-v3.claimable.contract-position-fetcher.ts b/src/apps/notional-finance-v3/arbitrum/notional-finance-v3.claimable.contract-position-fetcher.ts new file mode 100644 index 000000000..d4c5b8406 --- /dev/null +++ b/src/apps/notional-finance-v3/arbitrum/notional-finance-v3.claimable.contract-position-fetcher.ts @@ -0,0 +1,57 @@ +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 { getLabelFromToken } from '~app-toolkit/helpers/presentation/image.present'; +import { MetaType } from '~position/position.interface'; +import { ContractPositionTemplatePositionFetcher } from '~position/template/contract-position.template.position-fetcher'; +import { + DefaultContractPositionDefinition, + GetDisplayPropsParams, + GetTokenBalancesParams, +} from '~position/template/contract-position.template.types'; + +import { NotionalFinanceV3ViemContractFactory } from '../contracts'; +import { NotionalView } from '../contracts/viem'; + +@PositionTemplate() +export class ArbitrumNotionalFinanceV3ClaimableContractPositionFetcher extends ContractPositionTemplatePositionFetcher { + groupLabel = 'Claimable'; + + notionalViewContractAddress = '0x1344a36a1b56144c3bc62e7757377d288fde0369'; + + constructor( + @Inject(APP_TOOLKIT) protected readonly appToolkit: IAppToolkit, + @Inject(NotionalFinanceV3ViemContractFactory) + protected readonly contractFactory: NotionalFinanceV3ViemContractFactory, + ) { + super(appToolkit); + } + + getContract(address: string) { + return this.contractFactory.notionalView({ address, network: this.network }); + } + + async getDefinitions(): Promise { + return [{ address: this.notionalViewContractAddress }]; + } + + async getTokenDefinitions() { + return [ + { metaType: MetaType.CLAIMABLE, address: '0x019be259bc299f3f653688c7655c87f998bc7bc1', network: this.network }, + ]; + } + + async getLabel({ contractPosition }: GetDisplayPropsParams): Promise { + return getLabelFromToken(contractPosition.tokens[0]); + } + + async getTokenBalancesPerPosition({ address, contract }: GetTokenBalancesParams) { + const provider = this.appToolkit.getNetworkProvider(this.network); + const block = await provider.getBlockNumber(); + + const claimable = await contract.read.nTokenGetClaimableIncentives([address, BigInt(block)]); + + return [claimable]; + } +} diff --git a/src/apps/notional-finance-v3/notional-finance-v3.module.ts b/src/apps/notional-finance-v3/notional-finance-v3.module.ts index 9993b1279..8fd2ac145 100644 --- a/src/apps/notional-finance-v3/notional-finance-v3.module.ts +++ b/src/apps/notional-finance-v3/notional-finance-v3.module.ts @@ -3,6 +3,7 @@ import { Module } from '@nestjs/common'; import { AbstractApp } from '~app/app.dynamic-module'; import { ArbitrumNotionalFinanceV3BorrowContractPositionFetcher } from './arbitrum/notional-finance-v3.borrow.contract-position-fetcher'; +import { ArbitrumNotionalFinanceV3ClaimableContractPositionFetcher } from './arbitrum/notional-finance-v3.claimable.contract-position-fetcher'; import { ArbitrumNotionalFinanceV3NTokenTokenFetcher } from './arbitrum/notional-finance-v3.n-token.token-fetcher'; import { ArbitrumNotionalFinanceV3PCashTokenFetcher } from './arbitrum/notional-finance-v3.p-cash.token-fetcher'; import { ArbitrumNotionalFinanceV3PDebtTokenFetcher } from './arbitrum/notional-finance-v3.p-debt.token-fetcher'; @@ -18,6 +19,7 @@ import { NotionalFinanceV3ViemContractFactory } from './contracts'; ArbitrumNotionalFinanceV3NTokenTokenFetcher, ArbitrumNotionalFinanceV3SupplyContractPositionFetcher, ArbitrumNotionalFinanceV3BorrowContractPositionFetcher, + ArbitrumNotionalFinanceV3ClaimableContractPositionFetcher, ], }) export class NotionalFinanceV3AppModule extends AbstractApp() {}