From a1fbfe22ed97eda2047fb06a9dae0e1b86fe6170 Mon Sep 17 00:00:00 2001 From: Claudiu Lataretu Date: Mon, 16 Sep 2024 18:32:46 +0300 Subject: [PATCH] SERVICES-2416: use maximum boosted APR for pair dual farm APR Signed-off-by: Claudiu Lataretu --- src/modules/pair/pair.resolver.ts | 2 +- .../services/staking.compute.service.ts | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/modules/pair/pair.resolver.ts b/src/modules/pair/pair.resolver.ts index c3500a80a..efd4f7db7 100644 --- a/src/modules/pair/pair.resolver.ts +++ b/src/modules/pair/pair.resolver.ts @@ -162,7 +162,7 @@ export class PairCompoundedAPRResolver extends GenericResolver { return '0'; } - return await this.stakingCompute.boostedAPR(stakingAddress); + return await this.stakingCompute.maxBoostedAPR(stakingAddress); } } diff --git a/src/modules/staking/services/staking.compute.service.ts b/src/modules/staking/services/staking.compute.service.ts index 785a0f949..32101dc92 100644 --- a/src/modules/staking/services/staking.compute.service.ts +++ b/src/modules/staking/services/staking.compute.service.ts @@ -289,6 +289,31 @@ export class StakingComputeService { return boostedAPR.toFixed(); } + @ErrorLoggerAsync({ + logArgs: true, + }) + async maxBoostedAPR(stakeAddress: string): Promise { + return await this.computeMaxBoostedApr(stakeAddress); + } + + async computeMaxBoostedApr(stakeAddress: string): Promise { + const [baseAPR, boostedYieldsFactors, boostedYieldsRewardsPercentage] = + await Promise.all([ + this.stakeFarmBaseAPR(stakeAddress), + this.stakingAbi.boostedYieldsFactors(stakeAddress), + this.stakingAbi.boostedYieldsRewardsPercenatage(stakeAddress), + ]); + + const bnRawMaxBoostedApr = new BigNumber(baseAPR) + .multipliedBy(boostedYieldsFactors.maxRewardsFactor) + .multipliedBy(boostedYieldsRewardsPercentage) + .dividedBy( + constantsConfig.MAX_PERCENT - boostedYieldsRewardsPercentage, + ); + + return bnRawMaxBoostedApr.toFixed(); + } + async computeRewardsRemainingDays(stakeAddress: string): Promise { const [perBlockRewardAmount, accumulatedRewards, rewardsCapacity] = await Promise.all([