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(mux): Add MuxLP Staking (#3006)
- Loading branch information
Showing
2 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
84 changes: 84 additions & 0 deletions
84
src/apps/mux/arbitrum/mux.mux-lp-staking.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,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]; | ||
} | ||
} |
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