@scallop-io/sui-scallop-sdk 0.44.19 → 0.44.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,6 +20,7 @@ export type BorrowIncentivePool = {
20
20
  coinType: string;
21
21
  coinDecimal: number;
22
22
  coinPrice: number;
23
+ staked: number;
23
24
  points: OptionalKeys<Record<SupportBorrowIncentiveRewardCoins, BorrowIncentivePoolPoints>>;
24
25
  };
25
26
  export type OriginBorrowIncentivePoolPointData = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scallop-io/sui-scallop-sdk",
3
- "version": "0.44.19",
3
+ "version": "0.44.21",
4
4
  "description": "Typescript sdk for interacting with Scallop contract on SUI",
5
5
  "keywords": [
6
6
  "sui",
@@ -1,5 +1,7 @@
1
+ import { IS_VE_SCA_TEST } from './common';
2
+
1
3
  export const UNLOCK_ROUND_DURATION = 60 * 60 * 24; // 1 days in seconds
2
- export const MAX_LOCK_ROUNDS: number = 1460; // 4 years in days
4
+ export const MAX_LOCK_ROUNDS: number = IS_VE_SCA_TEST ? 9 : 1460; // 4 years in days (or 9 days for testing)
3
5
  export const MAX_LOCK_DURATION: number =
4
6
  MAX_LOCK_ROUNDS * UNLOCK_ROUND_DURATION; // 4 years in seconds
5
7
 
@@ -142,6 +142,7 @@ export const queryBorrowIncentivePools = async (
142
142
  coinDecimal: poolCoinDecimal,
143
143
  coinPrice: poolCoinPrice,
144
144
  points: borrowIncentivePoolPoints,
145
+ staked: parsedBorrowIncentivePoolData.staked,
145
146
  };
146
147
  }
147
148
 
@@ -511,20 +511,22 @@ export const getObligationAccount = async (
511
511
  );
512
512
 
513
513
  // for veSCA
514
- // console.log('poolPoint.weightedAmount', poolPoint.weightedAmount);
515
- // console.log(
516
- // 'borrowIncentiveAccount.amount',
517
- // borrowIncentiveAccount.debtAmount
518
- // );
519
- const weightScale = BigNumber('1000000000000');
520
-
514
+ const weightScale = BigNumber(1_000_000_000_000);
521
515
  const boostValue = BigNumber(accountPoint.weightedAmount)
522
516
  .div(
523
517
  BigNumber(borrowIncentiveAccount.debtAmount)
524
518
  .multipliedBy(poolPoint.baseWeight)
525
519
  .dividedBy(weightScale)
526
520
  )
527
- .toNumber();
521
+ .isFinite()
522
+ ? BigNumber(accountPoint.weightedAmount)
523
+ .div(
524
+ BigNumber(borrowIncentiveAccount.debtAmount)
525
+ .multipliedBy(poolPoint.baseWeight)
526
+ .dividedBy(weightScale)
527
+ )
528
+ .toNumber()
529
+ : 1;
528
530
 
529
531
  if (availableClaimAmount.isGreaterThan(0)) {
530
532
  rewards.push({
@@ -54,6 +54,7 @@ export type BorrowIncentivePool = {
54
54
  coinType: string;
55
55
  coinDecimal: number;
56
56
  coinPrice: number;
57
+ staked: number;
57
58
  points: OptionalKeys<
58
59
  Record<SupportBorrowIncentiveRewardCoins, BorrowIncentivePoolPoints>
59
60
  >;
@@ -502,25 +502,30 @@ export const calculateBorrowIncentivePoolPointData = (
502
502
 
503
503
  // Calculate the reward rate
504
504
  const rateYearFactor = 365 * 24 * 60 * 60;
505
- const rewardPerSec = BigNumber(distributedPointPerSec).dividedBy(
506
- parsedBorrowIncentivePoolPointData.period
505
+ const rewardPerSec = BigNumber(distributedPointPerSec).shiftedBy(
506
+ -1 * rewardCoinDecimal
507
507
  );
508
508
 
509
509
  const rewardValueForYear = BigNumber(rewardPerSec)
510
- .shiftedBy(-1 * rewardCoinDecimal)
511
510
  .multipliedBy(rateYearFactor)
512
511
  .multipliedBy(rewardCoinPrice);
513
512
 
514
- const weightScale = BigNumber('1000000000000');
513
+ const weightScale = BigNumber(1_000_000_000_000);
515
514
  const rewardRate = rewardValueForYear
515
+ .multipliedBy(
516
+ BigNumber(parsedBorrowIncentivePoolPointData.baseWeight).dividedBy(
517
+ weightScale
518
+ )
519
+ )
516
520
  .dividedBy(weightedStakedValue)
517
- .multipliedBy(parsedBorrowIncentivePoolPointData.baseWeight)
518
- .dividedBy(weightScale)
519
521
  .isFinite()
520
522
  ? rewardValueForYear
523
+ .multipliedBy(
524
+ BigNumber(parsedBorrowIncentivePoolPointData.baseWeight).dividedBy(
525
+ weightScale
526
+ )
527
+ )
521
528
  .dividedBy(weightedStakedValue)
522
- .multipliedBy(parsedBorrowIncentivePoolPointData.baseWeight)
523
- .dividedBy(weightScale)
524
529
  .toNumber()
525
530
  : Infinity;
526
531
 
package/src/utils/util.ts CHANGED
@@ -55,7 +55,12 @@ export const parseDataFromPythPriceFeed = (
55
55
  address: ScallopAddress
56
56
  ) => {
57
57
  const assetCoinNames = [
58
- ...new Set([...SUPPORT_POOLS, ...SUPPORT_COLLATERALS]),
58
+ ...new Set([
59
+ ...SUPPORT_POOLS,
60
+ ...SUPPORT_COLLATERALS,
61
+ ...SUPPORT_SPOOLS_REWARDS,
62
+ ...SUPPORT_BORROW_INCENTIVE_REWARDS,
63
+ ]),
59
64
  ] as SupportAssetCoins[];
60
65
  const assetCoinName = assetCoinNames.find((assetCoinName) => {
61
66
  return (