@scallop-io/sui-scallop-sdk 0.46.31 → 0.46.33
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 +68 -67
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +68 -67
- 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/constants/common.ts +2 -2
- package/src/queries/borrowIncentiveQuery.ts +9 -2
- package/src/queries/portfolioQuery.ts +7 -5
- 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
package/src/constants/common.ts
CHANGED
|
@@ -18,8 +18,8 @@ export const PROTOCOL_OBJECT_ID = IS_VE_SCA_TEST
|
|
|
18
18
|
// '0x87ddec2984645dbbe2403a509cc6edf393a43acdba9b77d45da2bcbefcf733c1' as const;
|
|
19
19
|
|
|
20
20
|
export const BORROW_FEE_PROTOCOL_ID = IS_VE_SCA_TEST
|
|
21
|
-
? ('0xc9f859f98ca352a11b97a038c4b4162bee437b8df8caa047990fe9cb03d4f778' as const)
|
|
22
|
-
: ('0xc38f849e81cfe46d4e4320f508ea7dda42934a329d5a6571bb4c3cb6ea63f5da' as const);
|
|
21
|
+
? ('0xc9f859f98ca352a11b97a038c4b4162bee437b8df8caa047990fe9cb03d4f778' as const) // test environment
|
|
22
|
+
: ('0xc38f849e81cfe46d4e4320f508ea7dda42934a329d5a6571bb4c3cb6ea63f5da' as const);
|
|
23
23
|
// export const BORROW_FEE_PROTOCOL_ID =
|
|
24
24
|
// '0x87ddec2984645dbbe2403a509cc6edf393a43acdba9b77d45da2bcbefcf733c1' as const;
|
|
25
25
|
|
|
@@ -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
|
|
|
@@ -486,7 +486,6 @@ export const getObligationAccount = async (
|
|
|
486
486
|
)) {
|
|
487
487
|
const coinName = poolCoinName as SupportBorrowIncentiveCoins;
|
|
488
488
|
const borrowIncentivePool = borrowIncentivePools[coinName];
|
|
489
|
-
|
|
490
489
|
if (borrowIncentivePool) {
|
|
491
490
|
const rewards: ObligationBorrowIcentiveReward[] = [];
|
|
492
491
|
for (const rewardCoinName of SUPPORT_BORROW_INCENTIVE_REWARDS) {
|
|
@@ -499,9 +498,12 @@ export const getObligationAccount = async (
|
|
|
499
498
|
const accountBorrowedAmount = BigNumber(accountPoint.weightedAmount);
|
|
500
499
|
const baseIndexRate = 1_000_000_000;
|
|
501
500
|
const increasedPointRate = poolPoint.currentPointIndex
|
|
502
|
-
?
|
|
503
|
-
poolPoint.currentPointIndex - accountPoint.index
|
|
504
|
-
|
|
501
|
+
? Math.max(
|
|
502
|
+
BigNumber(poolPoint.currentPointIndex - accountPoint.index)
|
|
503
|
+
.dividedBy(baseIndexRate)
|
|
504
|
+
.toNumber(),
|
|
505
|
+
0
|
|
506
|
+
)
|
|
505
507
|
: 1;
|
|
506
508
|
availableClaimAmount = availableClaimAmount.plus(
|
|
507
509
|
accountBorrowedAmount
|
|
@@ -530,7 +532,7 @@ export const getObligationAccount = async (
|
|
|
530
532
|
.toNumber()
|
|
531
533
|
: 1;
|
|
532
534
|
|
|
533
|
-
if (availableClaimAmount.
|
|
535
|
+
if (availableClaimAmount.isGreaterThanOrEqualTo(0)) {
|
|
534
536
|
rewards.push({
|
|
535
537
|
coinName: poolPoint.coinName,
|
|
536
538
|
coinType: poolPoint.coinType,
|
|
@@ -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(),
|