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 380
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(jones-dao): Add staking V2, get staking V1 dynamically (#489)
- Loading branch information
1 parent
5ee1f9a
commit 8c47c93
Showing
17 changed files
with
4,813 additions
and
59 deletions.
There are no files selected for viewing
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
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
51 changes: 51 additions & 0 deletions
51
src/apps/jones-dao/arbitrum/jones-dao.milliner-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,51 @@ | ||
import { Inject } from '@nestjs/common'; | ||
|
||
import { APP_TOOLKIT, IAppToolkit } from '~app-toolkit/app-toolkit.interface'; | ||
import { Register } from '~app-toolkit/decorators'; | ||
import { RewardRateUnit } from '~app-toolkit/helpers/master-chef/master-chef.contract-position-helper'; | ||
import { PositionFetcher } from '~position/position-fetcher.interface'; | ||
import { ContractPosition } from '~position/position.interface'; | ||
import { Network } from '~types/network.interface'; | ||
|
||
import { JonesDaoContractFactory, JonesMillinerV2 } from '../contracts'; | ||
import { JONES_DAO_DEFINITION } from '../jones-dao.definition'; | ||
|
||
const appId = JONES_DAO_DEFINITION.id; | ||
const groupId = JONES_DAO_DEFINITION.groups.millinerV2.id; | ||
const network = Network.ARBITRUM_MAINNET; | ||
|
||
@Register.ContractPositionFetcher({ appId, groupId, network }) | ||
export class ArbitrumJonesDaoMillinerV2ContractPositionFetcher implements PositionFetcher<ContractPosition> { | ||
constructor( | ||
@Inject(APP_TOOLKIT) private readonly appToolkit: IAppToolkit, | ||
@Inject(JonesDaoContractFactory) private readonly contractFactory: JonesDaoContractFactory, | ||
) {} | ||
|
||
async getPositions() { | ||
return this.appToolkit.helpers.masterChefContractPositionHelper.getContractPositions<JonesMillinerV2>({ | ||
address: '0xb94d1959084081c5a11c460012ab522f5a0fd756', | ||
appId: JONES_DAO_DEFINITION.id, | ||
groupId: JONES_DAO_DEFINITION.groups.millinerV2.id, | ||
network: Network.ARBITRUM_MAINNET, | ||
dependencies: [{ appId: 'sushiswap', groupIds: ['pool'], network }], | ||
resolveContract: ({ address, network }) => this.contractFactory.jonesMillinerV2({ address, network }), | ||
resolvePoolLength: ({ multicall, contract }) => multicall.wrap(contract).poolLength(), | ||
resolveDepositTokenAddress: ({ poolIndex, contract, multicall }) => | ||
multicall | ||
.wrap(contract) | ||
.poolInfo(poolIndex) | ||
.then(v => v.lpToken), | ||
resolveRewardTokenAddresses: ({ multicall, contract }) => multicall.wrap(contract).jones(), | ||
rewardRateUnit: RewardRateUnit.SECOND, | ||
resolveRewardRate: this.appToolkit.helpers.masterChefDefaultRewardsPerBlockStrategy.build({ | ||
resolvePoolAllocPoints: async ({ poolIndex, contract, multicall }) => | ||
multicall | ||
.wrap(contract) | ||
.poolInfo(poolIndex) | ||
.then(v => v.allocPoint), | ||
resolveTotalAllocPoints: ({ multicall, contract }) => multicall.wrap(contract).totalAllocPoint(), | ||
resolveTotalRewardRate: ({ multicall, contract }) => multicall.wrap(contract).jonesPerSecond(), | ||
}), | ||
}); | ||
} | ||
} |
Oops, something went wrong.