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 383
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(plutus): Add plsGLP, plvGLP, and plvGLP farm (#1307)
- Loading branch information
1 parent
5ccef3c
commit 6ea68eb
Showing
24 changed files
with
4,112 additions
and
30 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
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
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
61 changes: 61 additions & 0 deletions
61
src/apps/plutus/arbitrum/plutus.farm-plv-glp.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,61 @@ | ||
import { Inject } from '@nestjs/common'; | ||
|
||
import { APP_TOOLKIT, IAppToolkit } from '~app-toolkit/app-toolkit.interface'; | ||
import { Register } from '~app-toolkit/decorators'; | ||
import { GetDataPropsParams, GetTokenBalancesParams } from '~position/template/contract-position.template.types'; | ||
import { | ||
SingleStakingFarmDataProps, | ||
SingleStakingFarmDefinition, | ||
SingleStakingFarmTemplateContractPositionFetcher, | ||
} from '~position/template/single-staking.template.contract-position-fetcher'; | ||
import { Network } from '~types/network.interface'; | ||
|
||
import { PlutusContractFactory, PlutusFarmPls } from '../contracts'; | ||
import PLUTUS_DEFINITION from '../plutus.definition'; | ||
|
||
const appId = PLUTUS_DEFINITION.id; | ||
const groupId = PLUTUS_DEFINITION.groups.farmPlvGlp.id; | ||
const network = Network.ARBITRUM_MAINNET; | ||
|
||
@Register.ContractPositionFetcher({ appId, groupId, network }) | ||
export class ArbitrumPlutusFarmPlvGlpContractPositionFetcher extends SingleStakingFarmTemplateContractPositionFetcher<PlutusFarmPls> { | ||
appId = appId; | ||
groupId = groupId; | ||
network = network; | ||
groupLabel = 'plvGLP Farm'; | ||
|
||
constructor( | ||
@Inject(APP_TOOLKIT) protected readonly appToolkit: IAppToolkit, | ||
@Inject(PlutusContractFactory) protected readonly contractFactory: PlutusContractFactory, | ||
) { | ||
super(appToolkit); | ||
} | ||
|
||
getContract(address: string): PlutusFarmPls { | ||
return this.contractFactory.plutusFarmPls({ address, network: this.network }); | ||
} | ||
|
||
async getFarmDefinitions(): Promise<SingleStakingFarmDefinition[]> { | ||
return [ | ||
{ | ||
address: '0x4e5cf54fde5e1237e80e87fcba555d829e1307ce', | ||
stakedTokenAddress: '0x5326e71ff593ecc2cf7acae5fe57582d6e74cff1', | ||
rewardTokenAddresses: [ | ||
'0x51318b7d00db7acc4026c88c3952b66278b6a67f', // PLS | ||
], | ||
}, | ||
]; | ||
} | ||
|
||
async getRewardRates({ contract }: GetDataPropsParams<PlutusFarmPls, SingleStakingFarmDataProps>) { | ||
return contract.plsPerSecond(); | ||
} | ||
|
||
async getStakedTokenBalance({ contract, address }: GetTokenBalancesParams<PlutusFarmPls>) { | ||
return contract.userInfo(0, address).then(v => v.amount); | ||
} | ||
|
||
async getRewardTokenBalances({ contract, address }: GetTokenBalancesParams<PlutusFarmPls>) { | ||
return contract.pendingPls(0, address); | ||
} | ||
} |
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
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,41 @@ | ||
import { Inject } from '@nestjs/common'; | ||
|
||
import { APP_TOOLKIT, IAppToolkit } from '~app-toolkit/app-toolkit.interface'; | ||
import { Register } from '~app-toolkit/decorators'; | ||
import { Erc20 } from '~contract/contracts'; | ||
import { AppTokenTemplatePositionFetcher } from '~position/template/app-token.template.position-fetcher'; | ||
import { Network } from '~types/network.interface'; | ||
|
||
import { PlutusContractFactory } from '../contracts'; | ||
import PLUTUS_DEFINITION from '../plutus.definition'; | ||
|
||
const appId = PLUTUS_DEFINITION.id; | ||
const groupId = PLUTUS_DEFINITION.groups.plsGlp.id; | ||
const network = Network.ARBITRUM_MAINNET; | ||
|
||
@Register.TokenPositionFetcher({ appId, groupId, network }) | ||
export class ArbitrumPlutusPlsGlpTokenFetcher extends AppTokenTemplatePositionFetcher<Erc20> { | ||
appId = appId; | ||
groupId = groupId; | ||
network = network; | ||
groupLabel = 'plsGLP'; | ||
|
||
constructor( | ||
@Inject(APP_TOOLKIT) protected readonly appToolkit: IAppToolkit, | ||
@Inject(PlutusContractFactory) protected readonly contractFactory: PlutusContractFactory, | ||
) { | ||
super(appToolkit); | ||
} | ||
|
||
getContract(address: string) { | ||
return this.contractFactory.erc20({ address, network: this.network }); | ||
} | ||
|
||
async getAddresses() { | ||
return ['0x530f1cbb2ebd71bec58d351dcd3768148986a467']; | ||
} | ||
|
||
async getUnderlyingTokenAddresses() { | ||
return ['0x4277f8f2c384827b5273592ff7cebd9f2c1ac258']; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
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 { AppTokenTemplatePositionFetcher } from '~position/template/app-token.template.position-fetcher'; | ||
import { | ||
GetDataPropsParams, | ||
GetPricePerShareParams, | ||
GetUnderlyingTokensParams, | ||
} from '~position/template/app-token.template.types'; | ||
import { Network } from '~types/network.interface'; | ||
|
||
import { PlutusContractFactory } from '../contracts'; | ||
import { PlutusPlvGlp } from '../contracts/ethers/PlutusPlvGlp'; | ||
import { PLUTUS_DEFINITION } from '../plutus.definition'; | ||
|
||
const appId = PLUTUS_DEFINITION.id; | ||
const groupId = PLUTUS_DEFINITION.groups.plvGlp.id; | ||
const network = Network.ARBITRUM_MAINNET; | ||
|
||
type PlutusPlvGlpTokenDataProps = { | ||
reserve: number; | ||
liquidity: number; | ||
}; | ||
|
||
@Register.TokenPositionFetcher({ appId, groupId, network }) | ||
export class ArbitrumPlutusPlvGlpTokenFetcher extends AppTokenTemplatePositionFetcher< | ||
PlutusPlvGlp, | ||
PlutusPlvGlpTokenDataProps | ||
> { | ||
appId = appId; | ||
groupId = groupId; | ||
network = network; | ||
groupLabel = 'plvGLP'; | ||
|
||
constructor( | ||
@Inject(APP_TOOLKIT) protected readonly appToolkit: IAppToolkit, | ||
@Inject(PlutusContractFactory) protected readonly contractFactory: PlutusContractFactory, | ||
) { | ||
super(appToolkit); | ||
} | ||
|
||
getContract(address: string): PlutusPlvGlp { | ||
return this.contractFactory.plutusPlvGlp({ address, network: this.network }); | ||
} | ||
|
||
getAddresses() { | ||
return ['0x5326e71ff593ecc2cf7acae5fe57582d6e74cff1']; | ||
} | ||
|
||
async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams<PlutusPlvGlp>) { | ||
return contract.asset(); | ||
} | ||
|
||
async getPricePerShare({ contract }: GetPricePerShareParams<PlutusPlvGlp>) { | ||
const pricePerShareRaw = await contract.convertToAssets(BigNumber.from(10).pow(18).toString()); | ||
return Number(pricePerShareRaw) / 10 ** 18; | ||
} | ||
|
||
async getDataProps({ appToken, contract }: GetDataPropsParams<PlutusPlvGlp>) { | ||
const reserveRaw = await contract.totalAssets(); | ||
const reserve = Number(reserveRaw) / 10 ** appToken.tokens[0].decimals; | ||
const liquidity = reserve * appToken.tokens[0].price; | ||
return { reserve, liquidity }; | ||
} | ||
} |
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
Oops, something went wrong.