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

Commit

Permalink
feat(mux): Add MuxLP Staking (#3006)
Browse files Browse the repository at this point in the history
  • Loading branch information
wpoulin authored Oct 31, 2023
1 parent e01f271 commit b42cf52
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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<MuxRewardRouter> {
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<DefaultContractPositionDefinition[]> {
return [{ address: '0xaf9c4f6a0ceb02d4217ff73f3c95bbc8c7320cee' }];
}

async getTokenDefinitions({ contract }: GetTokenDefinitionsParams<MuxRewardRouter>) {
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<MuxRewardRouter>) {
return getLabelFromToken(contractPosition.tokens[0]);
}

async getTokenBalancesPerPosition({
address,
contract,
multicall,
}: GetTokenBalancesParams<MuxRewardRouter>): Promise<BigNumberish[]> {
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];
}
}
2 changes: 2 additions & 0 deletions src/apps/mux/mux.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -24,6 +25,7 @@ import { FantomMuxPerpContractPositionFetcher } from './fantom/mux.perp.contract
ArbitrumMuxPerpContractPositionFetcher,
ArbitrumMuxMlpTokenFetcher,
ArbitrumMuxMuxTokenFetcher,
ArbitrumMuxMuxLpStakingContractPositionFetcher,
// Avalanche
AvalancheMuxPerpContractPositionFetcher,
AvalancheMuxMlpTokenFetcher,
Expand Down

0 comments on commit b42cf52

Please sign in to comment.