Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Commit

Permalink
feat(notional-finance-v3): Add claimables on Arbitrum (#3146)
Browse files Browse the repository at this point in the history
  • Loading branch information
wpoulin authored Dec 13, 2023
1 parent 72be905 commit ab59537
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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<NotionalView> {
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<DefaultContractPositionDefinition[]> {
return [{ address: this.notionalViewContractAddress }];
}

async getTokenDefinitions() {
return [
{ metaType: MetaType.CLAIMABLE, address: '0x019be259bc299f3f653688c7655c87f998bc7bc1', network: this.network },
];
}

async getLabel({ contractPosition }: GetDisplayPropsParams<NotionalView>): Promise<string> {
return getLabelFromToken(contractPosition.tokens[0]);
}

async getTokenBalancesPerPosition({ address, contract }: GetTokenBalancesParams<NotionalView>) {
const provider = this.appToolkit.getNetworkProvider(this.network);
const block = await provider.getBlockNumber();

const claimable = await contract.read.nTokenGetClaimableIncentives([address, BigInt(block)]);

return [claimable];
}
}
2 changes: 2 additions & 0 deletions src/apps/notional-finance-v3/notional-finance-v3.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -18,6 +19,7 @@ import { NotionalFinanceV3ViemContractFactory } from './contracts';
ArbitrumNotionalFinanceV3NTokenTokenFetcher,
ArbitrumNotionalFinanceV3SupplyContractPositionFetcher,
ArbitrumNotionalFinanceV3BorrowContractPositionFetcher,
ArbitrumNotionalFinanceV3ClaimableContractPositionFetcher,
],
})
export class NotionalFinanceV3AppModule extends AbstractApp() {}

0 comments on commit ab59537

Please sign in to comment.