From b42cf522e40d9f683b927356e4c26fc2ecfeaa76 Mon Sep 17 00:00:00 2001 From: William Poulin Date: Tue, 31 Oct 2023 16:47:38 -0400 Subject: [PATCH] feat(mux): Add MuxLP Staking (#3006) --- ...ux-lp-staking.contract-position-fetcher.ts | 84 +++++++++++++++++++ src/apps/mux/mux.module.ts | 2 + 2 files changed, 86 insertions(+) create mode 100644 src/apps/mux/arbitrum/mux.mux-lp-staking.contract-position-fetcher.ts diff --git a/src/apps/mux/arbitrum/mux.mux-lp-staking.contract-position-fetcher.ts b/src/apps/mux/arbitrum/mux.mux-lp-staking.contract-position-fetcher.ts new file mode 100644 index 000000000..a7690f273 --- /dev/null +++ b/src/apps/mux/arbitrum/mux.mux-lp-staking.contract-position-fetcher.ts @@ -0,0 +1,84 @@ +import { Inject } from '@nestjs/common'; +import { BigNumberish } from 'ethers'; + +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, + GetTokenDefinitionsParams, +} from '~position/template/contract-position.template.types'; + +import { MuxContractFactory, MuxRewardRouter } from '../contracts'; + +@PositionTemplate() +export class ArbitrumMuxMuxLpStakingContractPositionFetcher extends ContractPositionTemplatePositionFetcher { + groupLabel = 'MUXLP Staked'; + + constructor( + @Inject(APP_TOOLKIT) protected readonly appToolkit: IAppToolkit, + @Inject(MuxContractFactory) protected readonly contractFactory: MuxContractFactory, + ) { + super(appToolkit); + } + + getContract(address: string): MuxRewardRouter { + return this.contractFactory.muxRewardRouter({ address, network: this.network }); + } + + async getDefinitions(): Promise { + return [{ address: '0xaf9c4f6a0ceb02d4217ff73f3c95bbc8c7320cee' }]; + } + + async getTokenDefinitions({ contract }: GetTokenDefinitionsParams) { + return [ + { + metaType: MetaType.SUPPLIED, + address: await contract.mlp(), + network: this.network, + }, + { + metaType: MetaType.CLAIMABLE, + address: await contract.mux(), + network: this.network, + }, + { + metaType: MetaType.CLAIMABLE, + address: await contract.weth(), + network: this.network, + }, + ]; + } + + async getLabel({ contractPosition }: GetDisplayPropsParams) { + return getLabelFromToken(contractPosition.tokens[0]); + } + + async getTokenBalancesPerPosition({ + address, + contract, + multicall, + }: GetTokenBalancesParams): Promise { + const mlpRewardTracker = this.contractFactory.muxRewardTracker({ + address: '0x290450cdea757c68e4fe6032ff3886d204292914', + network: this.network, + }); + + const muxRewardTracker = this.contractFactory.muxRewardTracker({ + address: '0x0a9bbf8299fed2441009a7bb44874ee453de8e5d', + network: this.network, + }); + + const [staked, mlpRewards, muxRewards] = await Promise.all([ + contract.stakedMlpAmount(address), + multicall.wrap(mlpRewardTracker).callStatic.claimable(address), + multicall.wrap(muxRewardTracker).callStatic.claimable(address), + ]); + + return [staked, mlpRewards, muxRewards]; + } +} diff --git a/src/apps/mux/mux.module.ts b/src/apps/mux/mux.module.ts index bc77d5a09..93ec52071 100644 --- a/src/apps/mux/mux.module.ts +++ b/src/apps/mux/mux.module.ts @@ -6,6 +6,7 @@ import { OptimismMuxPerpContractPositionFetcher } from '~apps/mux/optimism/mux.p import { ArbitrumMuxFarmContractPositionFetcher } from './arbitrum/mux.farm.contract-position-fetcher'; import { ArbitrumMuxMlpTokenFetcher } from './arbitrum/mux.mlp.token-fetcher'; +import { ArbitrumMuxMuxLpStakingContractPositionFetcher } from './arbitrum/mux.mux-lp-staking.contract-position-fetcher'; import { ArbitrumMuxMuxTokenFetcher } from './arbitrum/mux.mux.token-fetcher'; import { ArbitrumMuxPerpContractPositionFetcher } from './arbitrum/mux.perp.contract-position-fetcher'; import { AvalancheMuxMlpTokenFetcher } from './avalanche/mux.mlp.token-fetcher'; @@ -24,6 +25,7 @@ import { FantomMuxPerpContractPositionFetcher } from './fantom/mux.perp.contract ArbitrumMuxPerpContractPositionFetcher, ArbitrumMuxMlpTokenFetcher, ArbitrumMuxMuxTokenFetcher, + ArbitrumMuxMuxLpStakingContractPositionFetcher, // Avalanche AvalancheMuxPerpContractPositionFetcher, AvalancheMuxMlpTokenFetcher,