From 7dc0603a7658ebe98df27e13bf29067973fd5e6e Mon Sep 17 00:00:00 2001 From: xieqian Date: Thu, 21 Mar 2024 00:28:39 +0800 Subject: [PATCH] adjust booster logic --- redux/selectors/getAccountRewards.ts | 25 ++++++++++++------------- redux/selectors/getStaking.ts | 6 ++---- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/redux/selectors/getAccountRewards.ts b/redux/selectors/getAccountRewards.ts index 80c5b3da..d492818e 100644 --- a/redux/selectors/getAccountRewards.ts +++ b/redux/selectors/getAccountRewards.ts @@ -78,7 +78,6 @@ export const computePoolsDailyAmount = ( const assetDecimals = asset.metadata.decimals + asset.config.extra_decimals; const rewardAssetDecimals = rewardAsset.metadata.decimals + rewardAsset.config.extra_decimals; - const log = Math.log(xBRRRAmount / boost_suppress_factor) / Math.log(boosterLogBase); const multiplier = log >= 0 ? 1 + log : 1; @@ -104,9 +103,8 @@ export const computePoolsDailyAmount = ( shrinkToken(portfolio.borrowed[asset.token_id]?.shares || 0, assetDecimals), ); const shares = type === "supplied" ? suppliedShares + collateralShares : borrowedShares; - const newBoostedShares = log > 0 ? shares * multiplier : boostedShares; - const newTotalBoostedShares = - log > 0 ? totalBoostedShares + newBoostedShares - boostedShares : totalBoostedShares; + const newBoostedShares = shares * multiplier; + const newTotalBoostedShares = totalBoostedShares + newBoostedShares - boostedShares; const newDailyAmount = newTotalBoostedShares > 0 ? (newBoostedShares / newTotalBoostedShares) * totalRewardsPerDay : 0; @@ -115,11 +113,11 @@ export const computePoolsDailyAmount = ( export const computeNetLiquidityDailyAmount = ( asset: Asset, - xBRRRAmount: number, + totalxBRRRAmount: number, netTvlFarm: INetTvlFarmRewards, farmData: FarmData, boosterDecimals: number, - netLiquidity: number, + xBRRR: number, boost_suppress_factor: number, ) => { const boosterLogBase = Number( @@ -128,7 +126,7 @@ export const computeNetLiquidityDailyAmount = ( const assetDecimals = asset.metadata.decimals + asset.config.extra_decimals; - const log = Math.log(xBRRRAmount / boost_suppress_factor) / Math.log(boosterLogBase); + const log = Math.log(totalxBRRRAmount / boost_suppress_factor) / Math.log(boosterLogBase); const multiplier = log >= 0 ? 1 + log : 1; const boostedShares = Number(shrinkToken(farmData.boosted_shares, assetDecimals)); @@ -141,12 +139,13 @@ export const computeNetLiquidityDailyAmount = ( ); const dailyAmount = (boostedShares / totalBoostedShares) * totalRewardsPerDay; - const shares = - Number(shrinkToken(new Decimal(netLiquidity).mul(10 ** 18).toFixed(), assetDecimals)) || 0; + const logStaked = Math.log(xBRRR / boost_suppress_factor) / Math.log(boosterLogBase); + const multiplierStaked = logStaked >= 0 ? 1 + logStaked : 1; + + const shares = boostedShares / multiplierStaked; - const newBoostedShares = log > 0 ? shares * multiplier : boostedShares; - const newTotalBoostedShares = - log > 0 ? totalBoostedShares + newBoostedShares - boostedShares : totalBoostedShares; + const newBoostedShares = shares * multiplier; + const newTotalBoostedShares = totalBoostedShares + newBoostedShares - boostedShares; const newDailyAmount = (newBoostedShares / newTotalBoostedShares) * totalRewardsPerDay; return { dailyAmount, newDailyAmount, multiplier, totalBoostedShares, shares }; }; @@ -220,7 +219,7 @@ export const getAccountRewards = createSelector( assets.netTvlFarm, farmData, app.config.booster_decimals, - netLiquidity, + xBRRR, app.config.boost_suppress_factor, ); diff --git a/redux/selectors/getStaking.ts b/redux/selectors/getStaking.ts index b1e97071..af7993cd 100644 --- a/redux/selectors/getStaking.ts +++ b/redux/selectors/getStaking.ts @@ -8,7 +8,6 @@ export const getStaking = createSelector( (account, app) => { const { config } = app; const { amount, months } = app.staking; - const BRRR = Number( shrinkToken(account.portfolio.staking["staked_booster_amount"], app.config.booster_decimals), ); @@ -23,10 +22,9 @@ export const getStaking = createSelector( ((months * config.minimum_staking_duration_sec - config.minimum_staking_duration_sec) / (config.maximum_staking_duration_sec - config.minimum_staking_duration_sec)) * (config.x_booster_multiplier_at_maximum_staking_duration / 10000 - 1); - const totalXBRRR = Math.max( - xBRRR + amount * xBRRRMultiplier, - (BRRR + amount) * xBRRRMultiplier, + xBRRR + Number(amount) * xBRRRMultiplier, + (BRRR + Number(amount)) * xBRRRMultiplier, ); const extraXBRRRAmount = totalXBRRR - xBRRR;