Skip to content

Commit

Permalink
fix: add finite check to boostValue
Browse files Browse the repository at this point in the history
  • Loading branch information
fum-is-chum committed Mar 28, 2024
1 parent 259dcd5 commit 97640b5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/queries/borrowIncentiveQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ export const queryBorrowIncentivePools = async (
coinDecimal: poolCoinDecimal,
coinPrice: poolCoinPrice,
points: borrowIncentivePoolPoints,
staked: parsedBorrowIncentivePoolData.staked,
};
}

Expand Down
18 changes: 10 additions & 8 deletions src/queries/portfolioQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -511,20 +511,22 @@ export const getObligationAccount = async (
);

// for veSCA
// console.log('poolPoint.weightedAmount', poolPoint.weightedAmount);
// console.log(
// 'borrowIncentiveAccount.amount',
// borrowIncentiveAccount.debtAmount
// );
const weightScale = BigNumber('1000000000000');

const weightScale = BigNumber(1_000_000_000_000);
const boostValue = BigNumber(accountPoint.weightedAmount)
.div(
BigNumber(borrowIncentiveAccount.debtAmount)
.multipliedBy(poolPoint.baseWeight)
.dividedBy(weightScale)
)
.toNumber();
.isFinite()
? BigNumber(accountPoint.weightedAmount)
.div(
BigNumber(borrowIncentiveAccount.debtAmount)
.multipliedBy(poolPoint.baseWeight)
.dividedBy(weightScale)
)
.toNumber()
: 1;

if (availableClaimAmount.isGreaterThan(0)) {
rewards.push({
Expand Down
1 change: 1 addition & 0 deletions src/types/query/borrowIncentive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export type BorrowIncentivePool = {
coinType: string;
coinDecimal: number;
coinPrice: number;
staked: number;
points: OptionalKeys<
Record<SupportBorrowIncentiveRewardCoins, BorrowIncentivePoolPoints>
>;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ export const calculateBorrowIncentivePoolPointData = (
.multipliedBy(rateYearFactor)
.multipliedBy(rewardCoinPrice);

const weightScale = BigNumber('1000000000000');
const weightScale = BigNumber(1_000_000_000_000);
const rewardRate = rewardValueForYear
.multipliedBy(
BigNumber(parsedBorrowIncentivePoolPointData.baseWeight).dividedBy(
Expand Down

0 comments on commit 97640b5

Please sign in to comment.