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

feat(gains-networks): Add staking positions (6.4.1) #3154

Merged
merged 2 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading