@scallop-io/sui-scallop-sdk 1.3.4 → 1.3.5-alpha.1
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.
- package/dist/constants/common.d.ts +3 -3
- package/dist/constants/enum.d.ts +2 -1
- package/dist/constants/tokenBucket.d.ts +1 -1
- package/dist/index.js +161 -84
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +160 -84
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallopQuery.d.ts +41 -7
- package/dist/models/scallopUtils.d.ts +10 -3
- package/dist/queries/borrowIncentiveQuery.d.ts +2 -2
- package/dist/queries/coreQuery.d.ts +0 -2
- package/dist/queries/portfolioQuery.d.ts +0 -2
- package/dist/queries/priceQuery.d.ts +32 -2
- package/dist/queries/sCoinQuery.d.ts +1 -1
- package/dist/types/constant/common.d.ts +1 -1
- package/dist/types/utils.d.ts +2 -6
- package/package.json +1 -1
- package/src/constants/coinGecko.ts +3 -2
- package/src/constants/common.ts +10 -5
- package/src/constants/enum.ts +54 -31
- package/src/constants/poolAddress.ts +10 -7
- package/src/constants/pyth.ts +3 -2
- package/src/constants/tokenBucket.ts +1 -1
- package/src/models/scallopQuery.ts +14 -1
- package/src/models/scallopUtils.ts +14 -2
- package/src/queries/borrowIncentiveQuery.ts +30 -12
- package/src/queries/borrowLimitQuery.ts +3 -2
- package/src/queries/coreQuery.ts +4 -9
- package/src/queries/isolatedAssetQuery.ts +3 -2
- package/src/queries/portfolioQuery.ts +3 -6
- package/src/queries/priceQuery.ts +36 -2
- package/src/queries/sCoinQuery.ts +1 -1
- package/src/queries/spoolQuery.ts +2 -4
- package/src/queries/supplyLimitQuery.ts +3 -2
- package/src/types/constant/common.ts +1 -2
- package/src/types/utils.ts +2 -10
- package/src/utils/query.ts +0 -87
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { normalizeStructTag } from '@mysten/sui/utils';
|
|
2
|
-
import {
|
|
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,19 +60,29 @@ 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 = {};
|
|
67
|
+
marketPools =
|
|
68
|
+
marketPools ??
|
|
69
|
+
(await query.getMarketPools(undefined, false, { coinPrices }));
|
|
70
|
+
coinPrices = coinPrices ?? (await query.getAllCoinPrices({ marketPools }));
|
|
61
71
|
|
|
62
|
-
|
|
63
|
-
|
|
72
|
+
console.log({ coinPrices });
|
|
64
73
|
if (indexer) {
|
|
65
74
|
const borrowIncentivePoolsIndexer =
|
|
66
75
|
await query.indexer.getBorrowIncentivePools();
|
|
67
76
|
|
|
68
77
|
const updateBorrowIncentivePool = (pool: BorrowIncentivePool) => {
|
|
69
78
|
if (!borrowIncentiveCoinNames.includes(pool.coinName)) return;
|
|
70
|
-
pool.coinPrice = coinPrices[pool.coinName]
|
|
79
|
+
pool.coinPrice = coinPrices[pool.coinName] || pool.coinPrice;
|
|
80
|
+
for (const sCoinName of SUPPORT_BORROW_INCENTIVE_REWARDS) {
|
|
81
|
+
if (pool.points[sCoinName]) {
|
|
82
|
+
pool.points[sCoinName].coinPrice =
|
|
83
|
+
coinPrices[sCoinName] ?? pool.points[sCoinName].coinPrice;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
71
86
|
borrowIncentivePools[pool.coinName] = pool;
|
|
72
87
|
};
|
|
73
88
|
|
|
@@ -94,7 +109,6 @@ export const getBorrowIncentivePools = async (
|
|
|
94
109
|
query.utils.parseCoinNameFromType<SupportBorrowIncentiveCoins>(
|
|
95
110
|
poolCoinType
|
|
96
111
|
);
|
|
97
|
-
|
|
98
112
|
const poolCoinPrice = coinPrices?.[poolCoinName] ?? 0;
|
|
99
113
|
const poolCoinDecimal = query.utils.getCoinDecimal(poolCoinName);
|
|
100
114
|
|
|
@@ -102,17 +116,21 @@ export const getBorrowIncentivePools = async (
|
|
|
102
116
|
if (!borrowIncentiveCoinNames.includes(poolCoinName)) {
|
|
103
117
|
continue;
|
|
104
118
|
}
|
|
105
|
-
|
|
119
|
+
|
|
120
|
+
// pool points for borrow incentive reward
|
|
106
121
|
for (const [coinName, poolPoint] of Object.entries(
|
|
107
122
|
parsedBorrowIncentivePoolData.poolPoints
|
|
108
123
|
)) {
|
|
109
|
-
const rewardCoinType =
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
124
|
+
const rewardCoinType = poolPoint.pointType;
|
|
125
|
+
let rewardCoinName = query.utils.parseCoinNameFromType(
|
|
126
|
+
rewardCoinType
|
|
127
|
+
) as SupportBorrowIncentiveRewardCoins;
|
|
128
|
+
// handle for scoin name
|
|
129
|
+
if (sCoinRawNameToName[rewardCoinName]) {
|
|
130
|
+
rewardCoinName = sCoinRawNameToName[rewardCoinName];
|
|
131
|
+
}
|
|
115
132
|
const rewardCoinDecimal = query.utils.getCoinDecimal(rewardCoinName);
|
|
133
|
+
const rewardCoinPrice = coinPrices?.[rewardCoinName] ?? 0;
|
|
116
134
|
|
|
117
135
|
const symbol = query.utils.parseSymbol(rewardCoinName);
|
|
118
136
|
const coinDecimal = query.utils.getCoinDecimal(rewardCoinName);
|
|
@@ -17,8 +17,9 @@ const borrowLimitZod = zod.object({
|
|
|
17
17
|
}),
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
// const borrowLimitKeyType = `
|
|
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
|
package/src/queries/coreQuery.ts
CHANGED
|
@@ -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(
|
|
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
|
-
|
|
22
|
-
// const isolatedAssetKeyType = `
|
|
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
|
|
@@ -50,7 +50,7 @@ export const getLendings = async (
|
|
|
50
50
|
(SUPPORT_SPOOLS as readonly SupportMarketCoins[]).includes(marketCoinName)
|
|
51
51
|
) as SupportStakeMarketCoins[];
|
|
52
52
|
|
|
53
|
-
const coinPrices = await query.utils.getCoinPrices(
|
|
53
|
+
const coinPrices = await query.utils.getCoinPrices();
|
|
54
54
|
const marketPools = await query.getMarketPools(poolCoinNames, indexer, {
|
|
55
55
|
coinPrices,
|
|
56
56
|
});
|
|
@@ -122,9 +122,7 @@ export const getLending = async (
|
|
|
122
122
|
) => {
|
|
123
123
|
const marketCoinName = query.utils.parseMarketCoinName(poolCoinName);
|
|
124
124
|
coinPrice =
|
|
125
|
-
coinPrice ??
|
|
126
|
-
(await query.utils.getCoinPrices([poolCoinName]))?.[poolCoinName] ??
|
|
127
|
-
0;
|
|
125
|
+
coinPrice ?? (await query.utils.getCoinPrices())?.[poolCoinName] ?? 0;
|
|
128
126
|
|
|
129
127
|
marketPool =
|
|
130
128
|
marketPool ??
|
|
@@ -355,8 +353,7 @@ export const getObligationAccount = async (
|
|
|
355
353
|
const collateralAssetCoinNames: SupportCollateralCoins[] = [
|
|
356
354
|
...SUPPORT_COLLATERALS,
|
|
357
355
|
];
|
|
358
|
-
coinPrices =
|
|
359
|
-
coinPrices ?? (await query.utils.getCoinPrices(collateralAssetCoinNames));
|
|
356
|
+
coinPrices = coinPrices ?? (await query.utils.getCoinPrices());
|
|
360
357
|
market = market ?? (await query.queryMarket(indexer, { coinPrices }));
|
|
361
358
|
coinAmounts =
|
|
362
359
|
coinAmounts ||
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { SuiObjectData } from '@mysten/sui/client';
|
|
2
|
-
import type { ScallopAddress } from '../models';
|
|
3
|
-
import type {
|
|
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(
|
|
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(
|
|
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
|
-
|
|
21
|
-
// const supplyLimitKeyType = `
|
|
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 =
|
package/src/types/utils.ts
CHANGED
|
@@ -1,18 +1,10 @@
|
|
|
1
|
-
import type {
|
|
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<
|
|
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;
|
package/src/utils/query.ts
CHANGED
|
@@ -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 => {
|