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(gains-networks): Add staking positions (6.4.1) (#3154)
- Loading branch information
Showing
8 changed files
with
1,479 additions
and
0 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
src/apps/gains-network/arbitrum/gains-network.staking-v2.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,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'; | ||
} |
61 changes: 61 additions & 0 deletions
61
src/apps/gains-network/common/gains-network.staking-v2.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,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]; | ||
} | ||
} |
Oops, something went wrong.