@scallop-io/sui-scallop-sdk 0.46.31 → 0.46.32
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/index.js +64 -64
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +64 -64
- package/dist/index.mjs.map +1 -1
- package/dist/types/query/borrowIncentive.d.ts +3 -4
- package/dist/utils/query.d.ts +1 -1
- package/package.json +1 -1
- package/src/queries/borrowIncentiveQuery.ts +9 -2
- package/src/types/query/borrowIncentive.ts +3 -4
- package/src/utils/query.ts +1 -9
|
@@ -20,7 +20,9 @@ export type BorrowIncentivePool = {
|
|
|
20
20
|
coinType: string;
|
|
21
21
|
coinDecimal: number;
|
|
22
22
|
coinPrice: number;
|
|
23
|
-
|
|
23
|
+
stakedAmount: number;
|
|
24
|
+
stakedCoin: number;
|
|
25
|
+
stakedValue: number;
|
|
24
26
|
points: OptionalKeys<Record<SupportBorrowIncentiveRewardCoins, BorrowIncentivePoolPoints>>;
|
|
25
27
|
};
|
|
26
28
|
export type OriginBorrowIncentivePoolPointData = {
|
|
@@ -66,9 +68,6 @@ export type ParsedBorrowIncentivePoolData = {
|
|
|
66
68
|
createdAt: number;
|
|
67
69
|
};
|
|
68
70
|
export type CalculatedBorrowIncentivePoolPointData = {
|
|
69
|
-
stakedAmount: number;
|
|
70
|
-
stakedCoin: number;
|
|
71
|
-
stakedValue: number;
|
|
72
71
|
baseWeight: number;
|
|
73
72
|
weightedStakedAmount: number;
|
|
74
73
|
weightedStakedCoin: number;
|
package/dist/utils/query.d.ts
CHANGED
|
@@ -41,7 +41,7 @@ export declare const parseOriginBorrowIncentivesPoolPointData: (originBorrowInce
|
|
|
41
41
|
* @return Parsed borrow incentive pool data
|
|
42
42
|
*/
|
|
43
43
|
export declare const parseOriginBorrowIncentivePoolData: (originBorrowIncentivePoolData: OriginBorrowIncentivePoolData) => ParsedBorrowIncentivePoolData;
|
|
44
|
-
export declare const calculateBorrowIncentivePoolPointData: (
|
|
44
|
+
export declare const calculateBorrowIncentivePoolPointData: (parsedBorrowIncentivePoolData: ParsedBorrowIncentivePoolData, parsedBorrowIncentivePoolPointData: ParsedBorrowIncentivePoolPointData, rewardCoinPrice: number, rewardCoinDecimal: number, poolCoinPrice: number, poolCoinDecimal: number) => CalculatedBorrowIncentivePoolPointData;
|
|
45
45
|
export declare const parseOriginBorrowIncentiveAccountPoolPointData: (originBorrowIncentiveAccountPoolPointData: OriginBorrowIncentiveAccountPoolData) => ParsedBorrowIncentiveAccountPoolData;
|
|
46
46
|
/**
|
|
47
47
|
* Parse origin borrow incentive account data to a more readable format.
|
package/package.json
CHANGED
|
@@ -19,6 +19,7 @@ import type {
|
|
|
19
19
|
BorrowIncentivePoolPoints,
|
|
20
20
|
OptionalKeys,
|
|
21
21
|
} from '../types';
|
|
22
|
+
import BigNumber from 'bignumber.js';
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
25
|
* Query borrow incentive pools data.
|
|
@@ -76,7 +77,7 @@ export const queryBorrowIncentivePools = async (
|
|
|
76
77
|
|
|
77
78
|
for (const pool of borrowIncentivePoolsQueryData.incentive_pools) {
|
|
78
79
|
const borrowIncentivePoolPoints: OptionalKeys<
|
|
79
|
-
Record<
|
|
80
|
+
Record<SupportBorrowIncentiveRewardCoins, BorrowIncentivePoolPoints>
|
|
80
81
|
> = {};
|
|
81
82
|
const parsedBorrowIncentivePoolData =
|
|
82
83
|
parseOriginBorrowIncentivePoolData(pool);
|
|
@@ -132,14 +133,20 @@ export const queryBorrowIncentivePools = async (
|
|
|
132
133
|
};
|
|
133
134
|
}
|
|
134
135
|
|
|
136
|
+
const stakedAmount = BigNumber(parsedBorrowIncentivePoolData.staked);
|
|
137
|
+
const stakedCoin = stakedAmount.shiftedBy(-1 * poolCoinDecimal);
|
|
138
|
+
const stakedValue = stakedCoin.multipliedBy(poolCoinPrice);
|
|
139
|
+
|
|
135
140
|
borrowIncentivePools[poolCoinName] = {
|
|
136
141
|
coinName: poolCoinName,
|
|
137
142
|
symbol: query.utils.parseSymbol(poolCoinName),
|
|
138
143
|
coinType: poolCoinType,
|
|
139
144
|
coinDecimal: poolCoinDecimal,
|
|
140
145
|
coinPrice: poolCoinPrice,
|
|
146
|
+
stakedAmount: stakedAmount.toNumber(),
|
|
147
|
+
stakedCoin: stakedCoin.toNumber(),
|
|
148
|
+
stakedValue: stakedValue.toNumber(),
|
|
141
149
|
points: borrowIncentivePoolPoints,
|
|
142
|
-
staked: parsedBorrowIncentivePoolData.staked,
|
|
143
150
|
};
|
|
144
151
|
}
|
|
145
152
|
|
|
@@ -36,7 +36,9 @@ export type BorrowIncentivePool = {
|
|
|
36
36
|
coinType: string;
|
|
37
37
|
coinDecimal: number;
|
|
38
38
|
coinPrice: number;
|
|
39
|
-
|
|
39
|
+
stakedAmount: number;
|
|
40
|
+
stakedCoin: number;
|
|
41
|
+
stakedValue: number;
|
|
40
42
|
points: OptionalKeys<
|
|
41
43
|
Record<SupportBorrowIncentiveRewardCoins, BorrowIncentivePoolPoints>
|
|
42
44
|
>;
|
|
@@ -94,9 +96,6 @@ export type ParsedBorrowIncentivePoolData = {
|
|
|
94
96
|
};
|
|
95
97
|
|
|
96
98
|
export type CalculatedBorrowIncentivePoolPointData = {
|
|
97
|
-
stakedAmount: number;
|
|
98
|
-
stakedCoin: number;
|
|
99
|
-
stakedValue: number;
|
|
100
99
|
baseWeight: number;
|
|
101
100
|
weightedStakedAmount: number;
|
|
102
101
|
weightedStakedCoin: number;
|
package/src/utils/query.ts
CHANGED
|
@@ -447,7 +447,7 @@ export const parseOriginBorrowIncentivePoolData = (
|
|
|
447
447
|
};
|
|
448
448
|
|
|
449
449
|
export const calculateBorrowIncentivePoolPointData = (
|
|
450
|
-
|
|
450
|
+
parsedBorrowIncentivePoolData: ParsedBorrowIncentivePoolData,
|
|
451
451
|
parsedBorrowIncentivePoolPointData: ParsedBorrowIncentivePoolPointData,
|
|
452
452
|
rewardCoinPrice: number,
|
|
453
453
|
rewardCoinDecimal: number,
|
|
@@ -488,11 +488,6 @@ export const calculateBorrowIncentivePoolPointData = (
|
|
|
488
488
|
parsedBorrowIncentivePoolPointData.distributedPoint
|
|
489
489
|
).plus(accumulatedPoints);
|
|
490
490
|
|
|
491
|
-
// pure staked amount
|
|
492
|
-
const stakedAmount = BigNumber(pasredBorrowIncentinvePoolData.staked);
|
|
493
|
-
|
|
494
|
-
const stakedCoin = stakedAmount.shiftedBy(-1 * poolCoinDecimal);
|
|
495
|
-
const stakedValue = stakedCoin.multipliedBy(poolCoinPrice);
|
|
496
491
|
const baseWeight = BigNumber(parsedBorrowIncentivePoolPointData.baseWeight);
|
|
497
492
|
|
|
498
493
|
// staked amount applied with weight
|
|
@@ -539,9 +534,6 @@ export const calculateBorrowIncentivePoolPointData = (
|
|
|
539
534
|
accumulatedPoints: accumulatedPoints.toNumber(),
|
|
540
535
|
currentPointIndex: currentPointIndex.toNumber(),
|
|
541
536
|
currentTotalDistributedPoint: currentTotalDistributedPoint.toNumber(),
|
|
542
|
-
stakedAmount: stakedAmount.toNumber(),
|
|
543
|
-
stakedCoin: stakedCoin.toNumber(),
|
|
544
|
-
stakedValue: stakedValue.toNumber(),
|
|
545
537
|
baseWeight: baseWeight.toNumber(),
|
|
546
538
|
weightedStakedAmount: weightedStakedAmount.toNumber(),
|
|
547
539
|
weightedStakedCoin: weightedStakedCoin.toNumber(),
|