Skip to content

Commit

Permalink
adjust booster logic
Browse files Browse the repository at this point in the history
  • Loading branch information
xieqian committed Mar 20, 2024
1 parent ff0ea66 commit 7dc0603
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
25 changes: 12 additions & 13 deletions redux/selectors/getAccountRewards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand All @@ -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(
Expand All @@ -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));
Expand All @@ -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 };
};
Expand Down Expand Up @@ -220,7 +219,7 @@ export const getAccountRewards = createSelector(
assets.netTvlFarm,
farmData,
app.config.booster_decimals,
netLiquidity,
xBRRR,
app.config.boost_suppress_factor,
);

Expand Down
6 changes: 2 additions & 4 deletions redux/selectors/getStaking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
);
Expand All @@ -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;
Expand Down

0 comments on commit 7dc0603

Please sign in to comment.