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 382
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pancakeswap): Add new CAKE syrup pool and new Pancakeswap LP far…
…ms (#398)
- Loading branch information
1 parent
33f9ac0
commit fed00bf
Showing
16 changed files
with
7,181 additions
and
10 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
56 changes: 56 additions & 0 deletions
56
src/apps/pancakeswap/binance/pancakeswap.farm-v2.cotract-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,56 @@ | ||
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 { PancakeswapChefV2, PancakeswapContractFactory } from '../contracts'; | ||
import { PANCAKESWAP_DEFINITION } from '../pancakeswap.definition'; | ||
|
||
const appId = PANCAKESWAP_DEFINITION.id; | ||
const groupId = PANCAKESWAP_DEFINITION.groups.farmV2.id; | ||
const network = Network.BINANCE_SMART_CHAIN_MAINNET; | ||
|
||
@Register.ContractPositionFetcher({ appId, groupId, network }) | ||
export class BinanceSmartChainPancakeswapFarmV2ContractPositionFetcher implements PositionFetcher<ContractPosition> { | ||
constructor( | ||
@Inject(APP_TOOLKIT) private readonly appToolkit: IAppToolkit, | ||
@Inject(PancakeswapContractFactory) private readonly contractFactory: PancakeswapContractFactory, | ||
) {} | ||
|
||
getPositions() { | ||
return this.appToolkit.helpers.masterChefContractPositionHelper.getContractPositions<PancakeswapChefV2>({ | ||
network, | ||
groupId, | ||
appId, | ||
minimumTvl: 10000, | ||
address: '0xa5f8c5dbd5f286960b9d90548680ae5ebff07652', | ||
dependencies: [{ appId, groupIds: [PANCAKESWAP_DEFINITION.groups.pool.id], network }], | ||
resolveContract: opts => this.contractFactory.pancakeswapChefV2(opts), | ||
resolvePoolLength: async ({ multicall, contract }) => multicall.wrap(contract).poolLength(), | ||
resolveDepositTokenAddress: ({ multicall, contract, poolIndex }) => multicall.wrap(contract).lpToken(poolIndex), | ||
resolveRewardTokenAddresses: ({ multicall, contract }) => multicall.wrap(contract).CAKE(), | ||
rewardRateUnit: RewardRateUnit.BLOCK, | ||
resolveRewardRate: this.appToolkit.helpers.masterChefDefaultRewardsPerBlockStrategy.build({ | ||
resolvePoolAllocPoints: ({ multicall, contract, poolIndex }) => | ||
multicall | ||
.wrap(contract) | ||
.poolInfo(poolIndex) | ||
.then(i => i.allocPoint), | ||
resolveTotalAllocPoints: async ({ multicall, contract, poolIndex }) => { | ||
const poolInfo = await multicall.wrap(contract).poolInfo(poolIndex); | ||
return poolInfo.isRegular | ||
? multicall.wrap(contract).totalRegularAllocPoint() | ||
: multicall.wrap(contract).totalSpecialAllocPoint(); | ||
}, | ||
resolveTotalRewardRate: async ({ multicall, contract, poolIndex }) => { | ||
const poolInfo = await multicall.wrap(contract).poolInfo(poolIndex); | ||
return multicall.wrap(contract).cakePerBlock(poolInfo.isRegular); | ||
}, | ||
}), | ||
}); | ||
} | ||
} |
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
57 changes: 57 additions & 0 deletions
57
src/apps/pancakeswap/binance/pancakeswap.syrup-cake.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,57 @@ | ||
// 0xa5f8c5dbd5f286960b9d90548680ae5ebff07652 => LP Staking | ||
|
||
import { Inject } from '@nestjs/common'; | ||
import { BigNumber } from 'ethers'; | ||
|
||
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 { PancakeswapContractFactory, PancakeswapSyrupCake } from '../contracts'; | ||
import { PANCAKESWAP_DEFINITION } from '../pancakeswap.definition'; | ||
|
||
const appId = PANCAKESWAP_DEFINITION.id; | ||
const groupId = PANCAKESWAP_DEFINITION.groups.syrupCake.id; | ||
const network = Network.BINANCE_SMART_CHAIN_MAINNET; | ||
|
||
@Register.ContractPositionFetcher({ appId, groupId, network }) | ||
export class BinanceSmartChainPancakeswapSyrupCakeContractPositionFetcher implements PositionFetcher<ContractPosition> { | ||
constructor( | ||
@Inject(APP_TOOLKIT) private readonly appToolkit: IAppToolkit, | ||
@Inject(PancakeswapContractFactory) | ||
private readonly contractFactory: PancakeswapContractFactory, | ||
) {} | ||
|
||
getPositions() { | ||
return this.appToolkit.helpers.masterChefContractPositionHelper.getContractPositions<PancakeswapSyrupCake>({ | ||
network, | ||
groupId, | ||
appId, | ||
address: '0x45c54210128a065de780c4b0df3d16664f7f859e', | ||
rewardRateUnit: RewardRateUnit.BLOCK, | ||
resolveContract: opts => this.contractFactory.pancakeswapSyrupCake(opts), | ||
resolvePoolLength: async () => BigNumber.from(1), | ||
resolveDepositTokenAddress: ({ multicall, contract }) => multicall.wrap(contract).token(), | ||
resolveRewardTokenAddresses: ({ multicall, contract }) => multicall.wrap(contract).token(), | ||
resolveTotalValueLocked: ({ multicall, contract }) => multicall.wrap(contract).available(), | ||
resolveRewardRate: async ({ multicall, network }) => { | ||
// The auto-compounding CAKE rewards are harvested from the main MasterChef V2 contract on PID 0 | ||
const masterChefV2Address = '0xa5f8c5dbd5f286960b9d90548680ae5ebff07652'; | ||
const masterChefV2Contract = this.contractFactory.pancakeswapChefV2({ address: masterChefV2Address, network }); | ||
const poolInfo = await multicall.wrap(masterChefV2Contract).poolInfo(0); | ||
const cakePerBlock = await multicall.wrap(masterChefV2Contract).cakePerBlock(poolInfo.isRegular); | ||
const poolAllocPoints = poolInfo.allocPoint; | ||
const totalAllocPoints = poolInfo.isRegular | ||
? masterChefV2Contract.totalRegularAllocPoint() | ||
: masterChefV2Contract.totalSpecialAllocPoint(); | ||
|
||
const poolShare = Number(poolAllocPoints) / Number(totalAllocPoints); | ||
const rewardPerBlock = poolShare * Number(cakePerBlock); | ||
return rewardPerBlock; | ||
}, | ||
}); | ||
} | ||
} |
Oops, something went wrong.