This repository has been archived by the owner on Jan 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 381
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(notional-finance-v3): Add claimables on Arbitrum (#3146)
- Loading branch information
Showing
2 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
...s/notional-finance-v3/arbitrum/notional-finance-v3.claimable.contract-position-fetcher.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters