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

Commit

Permalink
feat(gains-networks): Add staking positions (6.4.1) (#3154)
Browse files Browse the repository at this point in the history
  • Loading branch information
wpoulin authored Dec 14, 2023
1 parent 5651d01 commit bd6dc48
Show file tree
Hide file tree
Showing 8 changed files with 1,479 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { PositionTemplate } from '~app-toolkit/decorators/position-template.decorator';

import { GainsNetworkStakingV2ContractPositionFetcher } from '../common/gains-network.staking-v2.contract-position-fetcher';

@PositionTemplate()
export class ArbitrumGainsNetworkStakingV2ContractPositionFetcher extends GainsNetworkStakingV2ContractPositionFetcher {
groupLabel = 'Staking';

stakingContractAddress = '0x7edde7e5900633f698eab0dbc97de640fc5dc015';
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { Inject } from '@nestjs/common';

import { IAppToolkit, APP_TOOLKIT } from '~app-toolkit/app-toolkit.interface';
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 {
GetDisplayPropsParams,
GetTokenBalancesParams,
GetTokenDefinitionsParams,
} from '~position/template/contract-position.template.types';

import { GainsNetworkViemContractFactory } from '../contracts';
import { GainsNetworkStakingV2 } from '../contracts/viem';

export abstract class GainsNetworkStakingV2ContractPositionFetcher extends ContractPositionTemplatePositionFetcher<GainsNetworkStakingV2> {
abstract stakingContractAddress: string;

constructor(
@Inject(APP_TOOLKIT) protected readonly appToolkit: IAppToolkit,
@Inject(GainsNetworkViemContractFactory) protected readonly contractFactory: GainsNetworkViemContractFactory,
) {
super(appToolkit);
}

getContract(address: string) {
return this.contractFactory.gainsNetworkStakingV2({ address, network: this.network });
}

async getDefinitions() {
return [{ address: this.stakingContractAddress }];
}

async getTokenDefinitions({ contract }: GetTokenDefinitionsParams<GainsNetworkStakingV2>) {
return [
{
metaType: MetaType.SUPPLIED,
address: await contract.read.gns(),
network: this.network,
},
{
metaType: MetaType.CLAIMABLE,
address: await contract.read.dai(),
network: this.network,
},
];
}

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

async getTokenBalancesPerPosition({ address, contract }: GetTokenBalancesParams<GainsNetworkStakingV2>) {
const [suppliedBalance, claimable] = await Promise.all([
contract.read.stakers([address]),
contract.read.pendingRewardDai([address]),
]);

return [suppliedBalance[0], claimable];
}
}
Loading

0 comments on commit bd6dc48

Please sign in to comment.