@scallop-io/sui-scallop-sdk 1.3.4 → 1.3.5-alpha.2

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.
Files changed (37) hide show
  1. package/dist/constants/common.d.ts +3 -3
  2. package/dist/constants/enum.d.ts +2 -1
  3. package/dist/constants/tokenBucket.d.ts +1 -1
  4. package/dist/index.js +200 -121
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +199 -121
  7. package/dist/index.mjs.map +1 -1
  8. package/dist/models/scallopQuery.d.ts +41 -7
  9. package/dist/models/scallopUtils.d.ts +10 -3
  10. package/dist/queries/borrowIncentiveQuery.d.ts +2 -2
  11. package/dist/queries/coreQuery.d.ts +0 -2
  12. package/dist/queries/portfolioQuery.d.ts +0 -2
  13. package/dist/queries/priceQuery.d.ts +32 -2
  14. package/dist/queries/sCoinQuery.d.ts +1 -1
  15. package/dist/types/constant/common.d.ts +1 -1
  16. package/dist/types/utils.d.ts +2 -6
  17. package/package.json +1 -1
  18. package/src/constants/coinGecko.ts +3 -2
  19. package/src/constants/common.ts +10 -5
  20. package/src/constants/enum.ts +54 -31
  21. package/src/constants/poolAddress.ts +10 -7
  22. package/src/constants/pyth.ts +3 -2
  23. package/src/constants/tokenBucket.ts +1 -1
  24. package/src/models/scallopQuery.ts +14 -1
  25. package/src/models/scallopUtils.ts +14 -2
  26. package/src/queries/borrowIncentiveQuery.ts +29 -12
  27. package/src/queries/borrowLimitQuery.ts +3 -2
  28. package/src/queries/coreQuery.ts +4 -9
  29. package/src/queries/isolatedAssetQuery.ts +3 -2
  30. package/src/queries/portfolioQuery.ts +65 -62
  31. package/src/queries/priceQuery.ts +36 -2
  32. package/src/queries/sCoinQuery.ts +1 -1
  33. package/src/queries/spoolQuery.ts +2 -4
  34. package/src/queries/supplyLimitQuery.ts +3 -2
  35. package/src/types/constant/common.ts +1 -2
  36. package/src/types/utils.ts +2 -10
  37. package/src/utils/query.ts +0 -87
@@ -1,5 +1,9 @@
1
1
  import { normalizeStructTag } from '@mysten/sui/utils';
2
- import { SUPPORT_BORROW_INCENTIVE_POOLS } from '../constants';
2
+ import {
3
+ sCoinRawNameToName,
4
+ SUPPORT_BORROW_INCENTIVE_POOLS,
5
+ SUPPORT_BORROW_INCENTIVE_REWARDS,
6
+ } from '../constants';
3
7
  import {
4
8
  parseOriginBorrowIncentivePoolData,
5
9
  parseOriginBorrowIncentiveAccountData,
@@ -17,6 +21,7 @@ import type {
17
21
  OptionalKeys,
18
22
  BorrowIncentivePool,
19
23
  CoinPrices,
24
+ MarketPools,
20
25
  } from '../types';
21
26
  import BigNumber from 'bignumber.js';
22
27
 
@@ -55,11 +60,14 @@ export const getBorrowIncentivePools = async (
55
60
  ...SUPPORT_BORROW_INCENTIVE_POOLS,
56
61
  ],
57
62
  indexer: boolean = false,
63
+ marketPools?: MarketPools,
58
64
  coinPrices?: CoinPrices
59
65
  ) => {
60
66
  const borrowIncentivePools: BorrowIncentivePools = {};
61
-
62
- coinPrices = coinPrices ?? (await query.utils.getCoinPrices()) ?? {};
67
+ marketPools =
68
+ marketPools ??
69
+ (await query.getMarketPools(undefined, false, { coinPrices }));
70
+ coinPrices = coinPrices ?? (await query.getAllCoinPrices({ marketPools }));
63
71
 
64
72
  if (indexer) {
65
73
  const borrowIncentivePoolsIndexer =
@@ -67,7 +75,13 @@ export const getBorrowIncentivePools = async (
67
75
 
68
76
  const updateBorrowIncentivePool = (pool: BorrowIncentivePool) => {
69
77
  if (!borrowIncentiveCoinNames.includes(pool.coinName)) return;
70
- pool.coinPrice = coinPrices[pool.coinName] ?? pool.coinPrice;
78
+ pool.coinPrice = coinPrices[pool.coinName] || pool.coinPrice;
79
+ for (const sCoinName of SUPPORT_BORROW_INCENTIVE_REWARDS) {
80
+ if (pool.points[sCoinName]) {
81
+ pool.points[sCoinName].coinPrice =
82
+ coinPrices[sCoinName] ?? pool.points[sCoinName].coinPrice;
83
+ }
84
+ }
71
85
  borrowIncentivePools[pool.coinName] = pool;
72
86
  };
73
87
 
@@ -94,7 +108,6 @@ export const getBorrowIncentivePools = async (
94
108
  query.utils.parseCoinNameFromType<SupportBorrowIncentiveCoins>(
95
109
  poolCoinType
96
110
  );
97
-
98
111
  const poolCoinPrice = coinPrices?.[poolCoinName] ?? 0;
99
112
  const poolCoinDecimal = query.utils.getCoinDecimal(poolCoinName);
100
113
 
@@ -102,17 +115,21 @@ export const getBorrowIncentivePools = async (
102
115
  if (!borrowIncentiveCoinNames.includes(poolCoinName)) {
103
116
  continue;
104
117
  }
105
- // pool points for borrow incentive reward ('sui' and 'sca')
118
+
119
+ // pool points for borrow incentive reward
106
120
  for (const [coinName, poolPoint] of Object.entries(
107
121
  parsedBorrowIncentivePoolData.poolPoints
108
122
  )) {
109
- const rewardCoinType = normalizeStructTag(poolPoint.pointType);
110
- const rewardCoinName =
111
- query.utils.parseCoinNameFromType<SupportBorrowIncentiveRewardCoins>(
112
- rewardCoinType
113
- );
114
- const rewardCoinPrice = coinPrices?.[rewardCoinName] ?? 0;
123
+ const rewardCoinType = poolPoint.pointType;
124
+ let rewardCoinName = query.utils.parseCoinNameFromType(
125
+ rewardCoinType
126
+ ) as SupportBorrowIncentiveRewardCoins;
127
+ // handle for scoin name
128
+ if (sCoinRawNameToName[rewardCoinName]) {
129
+ rewardCoinName = sCoinRawNameToName[rewardCoinName];
130
+ }
115
131
  const rewardCoinDecimal = query.utils.getCoinDecimal(rewardCoinName);
132
+ const rewardCoinPrice = coinPrices?.[rewardCoinName] ?? 0;
116
133
 
117
134
  const symbol = query.utils.parseSymbol(rewardCoinName);
118
135
  const coinDecimal = query.utils.getCoinDecimal(rewardCoinName);
@@ -17,8 +17,9 @@ const borrowLimitZod = zod.object({
17
17
  }),
18
18
  });
19
19
 
20
- const borrowLimitKeyType = `0xe7dbb371a9595631f7964b7ece42255ad0e738cc85fe6da26c7221b220f01af6::market_dynamic_keys::BorrowLimitKey`; // prod
21
- // const borrowLimitKeyType = `0xb784ea287d944e478a3ceaa071f8885072cce6b7224cf245914dc2f9963f460e::market_dynamic_keys::BorrowLimitKey`;
20
+ // TODO: enable for production
21
+ // const borrowLimitKeyType = `0xe7dbb371a9595631f7964b7ece42255ad0e738cc85fe6da26c7221b220f01af6::market_dynamic_keys::BorrowLimitKey`; // prod
22
+ const borrowLimitKeyType = `0xb784ea287d944e478a3ceaa071f8885072cce6b7224cf245914dc2f9963f460e::market_dynamic_keys::BorrowLimitKey`;
22
23
  /**
23
24
  * Return supply limit of a pool (including the decimals)
24
25
  * @param utils
@@ -247,7 +247,7 @@ export const getMarketPools = async (
247
247
  const marketObjectResponse = await query.cache.queryGetObject(marketId, {
248
248
  showContent: true,
249
249
  });
250
- coinPrices = (await query.utils.getCoinPrices(poolCoinNames)) ?? {};
250
+ coinPrices = coinPrices ?? (await query.utils.getCoinPrices());
251
251
 
252
252
  const marketPools: MarketPools = {};
253
253
 
@@ -307,8 +307,7 @@ export const getMarketPool = async (
307
307
  ): Promise<MarketPool | undefined> => {
308
308
  try {
309
309
  coinPrice =
310
- coinPrice ||
311
- (await query.utils.getCoinPrices([poolCoinName]))?.[poolCoinName];
310
+ coinPrice ?? (await query.utils.getCoinPrices())?.[poolCoinName];
312
311
 
313
312
  if (indexer) {
314
313
  const marketPoolIndexer = await query.indexer.getMarketPool(poolCoinName);
@@ -541,8 +540,7 @@ export const getMarketCollaterals = async (
541
540
  indexer: boolean = false
542
541
  ) => {
543
542
  const marketId = query.address.get('core.market');
544
- const coinPrices =
545
- (await query.utils.getCoinPrices(collateralCoinNames)) ?? {};
543
+ const coinPrices = (await query.utils.getCoinPrices()) ?? {};
546
544
  const marketCollaterals: MarketCollaterals = {};
547
545
 
548
546
  if (indexer) {
@@ -600,10 +598,7 @@ export const getMarketCollateral = async (
600
598
  coinPrice?: number
601
599
  ): Promise<MarketCollateral | undefined> => {
602
600
  coinPrice =
603
- coinPrice ||
604
- (await query.utils.getCoinPrices([collateralCoinName]))?.[
605
- collateralCoinName
606
- ];
601
+ coinPrice ?? (await query.utils.getCoinPrices())?.[collateralCoinName];
607
602
 
608
603
  if (indexer) {
609
604
  const marketCollateralIndexer =
@@ -18,8 +18,9 @@ const isolatedAssetZod = zod.object({
18
18
  }),
19
19
  });
20
20
 
21
- const isolatedAssetKeyType = `0xe7dbb371a9595631f7964b7ece42255ad0e738cc85fe6da26c7221b220f01af6::market_dynamic_keys::IsolatedAssetKey`; // prod
22
- // const isolatedAssetKeyType = `0x6c23585e940a989588432509107e98bae06dbca4e333f26d0635d401b3c7c76d::market_dynamic_keys::IsolatedAssetKey`;
21
+ // TODO: enable for production
22
+ // const isolatedAssetKeyType = `0xe7dbb371a9595631f7964b7ece42255ad0e738cc85fe6da26c7221b220f01af6::market_dynamic_keys::IsolatedAssetKey`; // prod
23
+ const isolatedAssetKeyType = `0x6c23585e940a989588432509107e98bae06dbca4e333f26d0635d401b3c7c76d::market_dynamic_keys::IsolatedAssetKey`;
23
24
 
24
25
  /**
25
26
  * Return list of isolated assets coin types
@@ -1,6 +1,5 @@
1
1
  import BigNumber from 'bignumber.js';
2
2
  import {
3
- SUPPORT_BORROW_INCENTIVE_REWARDS,
4
3
  SUPPORT_COLLATERALS,
5
4
  SUPPORT_POOLS,
6
5
  SUPPORT_SPOOLS,
@@ -50,7 +49,7 @@ export const getLendings = async (
50
49
  (SUPPORT_SPOOLS as readonly SupportMarketCoins[]).includes(marketCoinName)
51
50
  ) as SupportStakeMarketCoins[];
52
51
 
53
- const coinPrices = await query.utils.getCoinPrices(poolCoinNames);
52
+ const coinPrices = await query.utils.getCoinPrices();
54
53
  const marketPools = await query.getMarketPools(poolCoinNames, indexer, {
55
54
  coinPrices,
56
55
  });
@@ -122,9 +121,7 @@ export const getLending = async (
122
121
  ) => {
123
122
  const marketCoinName = query.utils.parseMarketCoinName(poolCoinName);
124
123
  coinPrice =
125
- coinPrice ??
126
- (await query.utils.getCoinPrices([poolCoinName]))?.[poolCoinName] ??
127
- 0;
124
+ coinPrice ?? (await query.utils.getCoinPrices())?.[poolCoinName] ?? 0;
128
125
 
129
126
  marketPool =
130
127
  marketPool ??
@@ -355,9 +352,9 @@ export const getObligationAccount = async (
355
352
  const collateralAssetCoinNames: SupportCollateralCoins[] = [
356
353
  ...SUPPORT_COLLATERALS,
357
354
  ];
355
+ market = market ?? (await query.queryMarket(indexer));
358
356
  coinPrices =
359
- coinPrices ?? (await query.utils.getCoinPrices(collateralAssetCoinNames));
360
- market = market ?? (await query.queryMarket(indexer, { coinPrices }));
357
+ coinPrices ?? (await query.getAllCoinPrices({ marketPools: market.pools }));
361
358
  coinAmounts =
362
359
  coinAmounts ||
363
360
  (await query.getCoinAmounts(collateralAssetCoinNames, ownerAddress));
@@ -525,64 +522,70 @@ export const getObligationAccount = async (
525
522
  const borrowIncentivePool = borrowIncentivePools[coinName];
526
523
  if (borrowIncentivePool) {
527
524
  const rewards: ObligationBorrowIcentiveReward[] = [];
528
- for (const rewardCoinName of SUPPORT_BORROW_INCENTIVE_REWARDS) {
529
- const accountPoint = borrowIncentiveAccount.pointList[rewardCoinName];
530
- const poolPoint = borrowIncentivePool.points[rewardCoinName];
531
-
532
- if (accountPoint && poolPoint) {
533
- let availableClaimAmount = BigNumber(0);
534
- let availableClaimCoin = BigNumber(0);
535
- const accountBorrowedAmount = BigNumber(accountPoint.weightedAmount);
536
- const baseIndexRate = 1_000_000_000;
537
- const increasedPointRate = poolPoint.currentPointIndex
538
- ? Math.max(
539
- BigNumber(poolPoint.currentPointIndex - accountPoint.index)
540
- .dividedBy(baseIndexRate)
541
- .toNumber(),
542
- 0
543
- )
544
- : 1;
545
- availableClaimAmount = availableClaimAmount.plus(
546
- accountBorrowedAmount
547
- .multipliedBy(increasedPointRate)
548
- .plus(accountPoint.points)
549
- );
550
- availableClaimCoin = availableClaimAmount.shiftedBy(
551
- -1 * poolPoint.coinDecimal
552
- );
553
-
554
- // for veSCA
555
- const weightScale = BigNumber(1_000_000_000_000);
556
- const boostValue = BigNumber(accountPoint.weightedAmount)
557
- .div(
558
- BigNumber(borrowIncentiveAccount.debtAmount)
559
- .multipliedBy(poolPoint.baseWeight)
560
- .dividedBy(weightScale)
561
- )
562
- .isFinite()
563
- ? BigNumber(accountPoint.weightedAmount)
564
- .div(
565
- BigNumber(borrowIncentiveAccount.debtAmount)
566
- .multipliedBy(poolPoint.baseWeight)
567
- .dividedBy(weightScale)
525
+ Object.entries(borrowIncentiveAccount.pointList).forEach(
526
+ ([key, accountPoint]) => {
527
+ const poolPoint =
528
+ borrowIncentivePool.points[
529
+ key as SupportBorrowIncentiveRewardCoins
530
+ ];
531
+
532
+ if (accountPoint && poolPoint) {
533
+ let availableClaimAmount = BigNumber(0);
534
+ let availableClaimCoin = BigNumber(0);
535
+ const accountBorrowedAmount = BigNumber(
536
+ accountPoint.weightedAmount
537
+ );
538
+ const baseIndexRate = 1_000_000_000;
539
+ const increasedPointRate = poolPoint.currentPointIndex
540
+ ? Math.max(
541
+ BigNumber(poolPoint.currentPointIndex - accountPoint.index)
542
+ .dividedBy(baseIndexRate)
543
+ .toNumber(),
544
+ 0
568
545
  )
569
- .toNumber()
570
- : 1;
571
-
572
- if (availableClaimAmount.isGreaterThanOrEqualTo(0)) {
573
- rewards.push({
574
- coinName: poolPoint.coinName,
575
- coinType: poolPoint.coinType,
576
- symbol: poolPoint.symbol,
577
- coinDecimal: poolPoint.coinDecimal,
578
- coinPrice: poolPoint.coinPrice,
579
- availableClaimAmount: availableClaimAmount.toNumber(),
580
- availableClaimCoin: availableClaimCoin.toNumber(),
581
- boostValue,
582
- });
546
+ : 1;
547
+ availableClaimAmount = availableClaimAmount.plus(
548
+ accountBorrowedAmount
549
+ .multipliedBy(increasedPointRate)
550
+ .plus(accountPoint.points)
551
+ );
552
+ availableClaimCoin = availableClaimAmount.shiftedBy(
553
+ -1 * poolPoint.coinDecimal
554
+ );
555
+
556
+ // for veSCA
557
+ const weightScale = BigNumber(1_000_000_000_000);
558
+ const boostValue = BigNumber(accountPoint.weightedAmount)
559
+ .div(
560
+ BigNumber(borrowIncentiveAccount.debtAmount)
561
+ .multipliedBy(poolPoint.baseWeight)
562
+ .dividedBy(weightScale)
563
+ )
564
+ .isFinite()
565
+ ? BigNumber(accountPoint.weightedAmount)
566
+ .div(
567
+ BigNumber(borrowIncentiveAccount.debtAmount)
568
+ .multipliedBy(poolPoint.baseWeight)
569
+ .dividedBy(weightScale)
570
+ )
571
+ .toNumber()
572
+ : 1;
573
+
574
+ if (availableClaimAmount.isGreaterThanOrEqualTo(0)) {
575
+ rewards.push({
576
+ coinName: poolPoint.coinName,
577
+ coinType: poolPoint.coinType,
578
+ symbol: poolPoint.symbol,
579
+ coinDecimal: poolPoint.coinDecimal,
580
+ coinPrice: poolPoint.coinPrice,
581
+ availableClaimAmount: availableClaimAmount.toNumber(),
582
+ availableClaimCoin: availableClaimCoin.toNumber(),
583
+ boostValue,
584
+ });
585
+ }
583
586
  }
584
587
  }
585
- }
588
+ );
586
589
 
587
590
  if (
588
591
  Object.keys(borrowIncentivePool.points).some((coinName: any) => {
@@ -1,6 +1,14 @@
1
1
  import { SuiObjectData } from '@mysten/sui/client';
2
- import type { ScallopAddress } from '../models';
3
- import type { SupportAssetCoins } from '../types';
2
+ import type { ScallopAddress, ScallopQuery } from '../models';
3
+ import type {
4
+ CoinPrices,
5
+ MarketPools,
6
+ OptionalKeys,
7
+ SupportAssetCoins,
8
+ SupportSCoin,
9
+ } from '../types';
10
+ import { SUPPORT_SCOIN } from 'src/constants/common';
11
+ import BigNumber from 'bignumber.js';
4
12
 
5
13
  /**
6
14
  * Get price from pyth fee object.
@@ -126,3 +134,29 @@ export const getPythPrices = async (
126
134
  {} as Record<SupportAssetCoins, number>
127
135
  );
128
136
  };
137
+
138
+ export const getAllCoinPrices = async (
139
+ query: ScallopQuery,
140
+ marketPools?: MarketPools,
141
+ coinPrices?: CoinPrices
142
+ ) => {
143
+ coinPrices = coinPrices ?? (await query.utils.getCoinPrices());
144
+ marketPools =
145
+ marketPools ??
146
+ (await query.getMarketPools(undefined, undefined, { coinPrices }));
147
+ if (!marketPools) {
148
+ throw new Error(`Failed to fetch market pool for getAllCoinPrices`);
149
+ }
150
+ const sCoinPrices: OptionalKeys<Record<SupportSCoin, number>> = {};
151
+ SUPPORT_SCOIN.forEach((sCoinName) => {
152
+ const coinName = query.utils.parseCoinName(sCoinName);
153
+ sCoinPrices[sCoinName] = BigNumber(coinPrices[coinName] ?? 0)
154
+ .multipliedBy(marketPools[coinName]?.conversionRate ?? 1)
155
+ .toNumber();
156
+ });
157
+
158
+ return {
159
+ ...coinPrices,
160
+ ...sCoinPrices,
161
+ };
162
+ };
@@ -153,7 +153,7 @@ export const getSCoinSwapRate = async (
153
153
  const BtoSCoinBRate = 1 / marketPools[1]!.conversionRate;
154
154
 
155
155
  const calcAtoBRate = async () => {
156
- const prices = await query.utils.getCoinPrices([fromCoinName, toCoinName]);
156
+ const prices = await query.utils.getCoinPrices();
157
157
  if (!prices[fromCoinName] || !prices[toCoinName]) {
158
158
  throw new Error('Failed to fetch the coin prices');
159
159
  }
@@ -71,7 +71,6 @@ export const getSpools = async (
71
71
  };
72
72
  Object.values(spoolsIndexer).forEach(updateSpools);
73
73
 
74
- // console.log(spools);
75
74
  return spools;
76
75
  }
77
76
 
@@ -122,7 +121,7 @@ export const getSpool = async (
122
121
  `spool.pools.${marketCoinName}.rewardPoolId`
123
122
  );
124
123
  let spool: Spool | undefined = undefined;
125
- coinPrices = coinPrices || (await query.utils.getCoinPrices([coinName]));
124
+ coinPrices = coinPrices || (await query.utils.getCoinPrices());
126
125
 
127
126
  if (indexer) {
128
127
  const spoolIndexer = await query.indexer.getSpool(marketCoinName);
@@ -152,8 +151,7 @@ export const getSpool = async (
152
151
  }
153
152
 
154
153
  const rewardCoinName = query.utils.getSpoolRewardCoinName(marketCoinName);
155
- coinPrices =
156
- coinPrices || (await query.utils.getCoinPrices([coinName, rewardCoinName]));
154
+ coinPrices = coinPrices || (await query.utils.getCoinPrices());
157
155
 
158
156
  const spoolObject = spoolObjectResponse[0];
159
157
  const rewardPoolObject = spoolObjectResponse[1];
@@ -17,8 +17,9 @@ const supplyLimitZod = zod.object({
17
17
  }),
18
18
  });
19
19
 
20
- const supplyLimitKeyType = `0x6e641f0dca8aedab3101d047e96439178f16301bf0b57fe8745086ff1195eb3e::market_dynamic_keys::SupplyLimitKey`; // prod
21
- // const supplyLimitKeyType = `0x6c23585e940a989588432509107e98bae06dbca4e333f26d0635d401b3c7c76d::market_dynamic_keys::SupplyLimitKey`;
20
+ // TODO: enable for production
21
+ // const supplyLimitKeyType = `0x6e641f0dca8aedab3101d047e96439178f16301bf0b57fe8745086ff1195eb3e::market_dynamic_keys::SupplyLimitKey`; // prod
22
+ const supplyLimitKeyType = `0x6c23585e940a989588432509107e98bae06dbca4e333f26d0635d401b3c7c76d::market_dynamic_keys::SupplyLimitKey`;
22
23
  /**
23
24
  * Return supply limit of a pool (including the decimals)
24
25
  * @param utils
@@ -23,8 +23,7 @@ export type SupportCoins =
23
23
  export type SupportAssetCoins =
24
24
  | SupportPoolCoins
25
25
  | SupportCollateralCoins
26
- | SupportStakeRewardCoins
27
- | SupportBorrowIncentiveRewardCoins;
26
+ | SupportStakeRewardCoins;
28
27
  export type SupportPoolCoins = (typeof SUPPORT_POOLS)[number];
29
28
  export type SupportCollateralCoins = (typeof SUPPORT_COLLATERALS)[number];
30
29
  export type SupportMarketCoins =
@@ -1,18 +1,10 @@
1
- import type { SupportAssetCoins } from './constant';
1
+ import type { SupportCoins } from './constant';
2
2
 
3
3
  export type OptionalKeys<T> = {
4
4
  [K in keyof T]?: T[K];
5
5
  };
6
6
 
7
- export type CoinPrices = OptionalKeys<Record<SupportAssetCoins, number>>;
8
-
9
- export type PriceMap = Map<
10
- SupportAssetCoins,
11
- {
12
- price: number;
13
- publishTime: number;
14
- }
15
- >;
7
+ export type CoinPrices = OptionalKeys<Record<SupportCoins, number>>;
16
8
 
17
9
  export type PoolAddressInfo = {
18
10
  name: string;
@@ -546,93 +546,6 @@ export const calculateBorrowIncentivePoolPointData = (
546
546
  };
547
547
  };
548
548
 
549
- // /**
550
- // * Parse origin borrow incentive reward pool data to a more readable format.
551
- // *
552
- // * @param originBorrowIncentiveRewardPoolData - Origin borrow incentive reward pool data
553
- // * @return Parsed borrow incentive reward pool data
554
- // */
555
- // export const parseOriginBorrowIncentiveRewardPoolData = (
556
- // originBorrowIncentiveRewardPoolData: OriginBorrowIncentiveRewardPoolData
557
- // ): ParsedBorrowIncentiveRewardPoolData => {
558
- // return {
559
- // rewardType: normalizeStructTag(
560
- // originBorrowIncentiveRewardPoolData.reward_type.name
561
- // ),
562
- // claimedRewards: Number(originBorrowIncentiveRewardPoolData.claimed_rewards),
563
- // exchangeRateNumerator: Number(
564
- // originBorrowIncentiveRewardPoolData.exchange_rate_numerator
565
- // ),
566
- // exchangeRateDenominator: Number(
567
- // originBorrowIncentiveRewardPoolData.exchange_rate_denominator
568
- // ),
569
- // remainingRewards: Number(
570
- // originBorrowIncentiveRewardPoolData.remaining_reward
571
- // ),
572
- // };
573
- // };
574
-
575
- // export const calculateBorrowIncentiveRewardPoolData = (
576
- // parsedBorrowIncentivePoolData: ParsedBorrowIncentivePoolData,
577
- // parsedBorrowIncentiveRewardPoolData: ParsedBorrowIncentiveRewardPoolData,
578
- // calculatedBorrowIncentivePoolData: CalculatedBorrowIncentivePoolData,
579
- // rewardCoinPrice: number,
580
- // rewardCoinDecimal: number
581
- // ): CalculatedBorrowIncentiveRewardPoolData => {
582
- // const rateYearFactor = 365 * 24 * 60 * 60;
583
-
584
- // const rewardPerSec = BigNumber(
585
- // calculatedBorrowIncentivePoolData.distributedPointPerSec
586
- // )
587
- // .multipliedBy(parsedBorrowIncentiveRewardPoolData.exchangeRateNumerator)
588
- // .dividedBy(parsedBorrowIncentiveRewardPoolData.exchangeRateDenominator);
589
- // const totalRewardAmount = BigNumber(parsedBorrowIncentivePoolData.maxPoint)
590
- // .multipliedBy(parsedBorrowIncentiveRewardPoolData.exchangeRateNumerator)
591
- // .dividedBy(parsedBorrowIncentiveRewardPoolData.exchangeRateDenominator);
592
- // const totalRewardCoin = totalRewardAmount.shiftedBy(-1 * rewardCoinDecimal);
593
- // const totalRewardValue = totalRewardCoin.multipliedBy(rewardCoinPrice);
594
- // const remaindRewardAmount = BigNumber(
595
- // parsedBorrowIncentiveRewardPoolData.remainingRewards
596
- // );
597
- // const remaindRewardCoin = remaindRewardAmount.shiftedBy(
598
- // -1 * rewardCoinDecimal
599
- // );
600
- // const remaindRewardValue = remaindRewardCoin.multipliedBy(rewardCoinPrice);
601
- // const claimedRewardAmount = BigNumber(
602
- // parsedBorrowIncentiveRewardPoolData.claimedRewards
603
- // );
604
- // const claimedRewardCoin = claimedRewardAmount.shiftedBy(
605
- // -1 * rewardCoinDecimal
606
- // );
607
- // const claimedRewardValue = claimedRewardCoin.multipliedBy(rewardCoinPrice);
608
-
609
- // const rewardValueForYear = BigNumber(rewardPerSec)
610
- // .shiftedBy(-1 * rewardCoinDecimal)
611
- // .multipliedBy(rateYearFactor)
612
- // .multipliedBy(rewardCoinPrice);
613
- // const rewardRate = rewardValueForYear
614
- // .dividedBy(calculatedBorrowIncentivePoolData.stakedValue)
615
- // .isFinite()
616
- // ? rewardValueForYear
617
- // .dividedBy(calculatedBorrowIncentivePoolData.stakedValue)
618
- // .toNumber()
619
- // : Infinity;
620
-
621
- // return {
622
- // rewardApr: rewardRate,
623
- // totalRewardAmount: totalRewardAmount.toNumber(),
624
- // totalRewardCoin: totalRewardCoin.toNumber(),
625
- // totalRewardValue: totalRewardValue.toNumber(),
626
- // remaindRewardAmount: remaindRewardAmount.toNumber(),
627
- // remaindRewardCoin: remaindRewardCoin.toNumber(),
628
- // remaindRewardValue: remaindRewardValue.toNumber(),
629
- // claimedRewardAmount: claimedRewardAmount.toNumber(),
630
- // claimedRewardCoin: claimedRewardCoin.toNumber(),
631
- // claimedRewardValue: claimedRewardValue.toNumber(),
632
- // rewardPerSec: rewardPerSec.toNumber(),
633
- // };
634
- // };
635
-
636
549
  export const parseOriginBorrowIncentiveAccountPoolPointData = (
637
550
  originBorrowIncentiveAccountPoolPointData: OriginBorrowIncentiveAccountPoolData
638
551
  ): ParsedBorrowIncentiveAccountPoolData => {