@scallop-io/sui-scallop-sdk 0.42.7 → 0.44.0
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/enum.d.ts +3 -1
- package/dist/index.js +125 -57
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +95 -29
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallopBuilder.d.ts +4 -60
- package/dist/models/scallopClient.d.ts +10 -10
- package/dist/models/scallopUtils.d.ts +3 -1
- package/dist/queries/coreQuery.d.ts +2 -1
- package/dist/types/builder/core.d.ts +18 -18
- package/dist/types/builder/index.d.ts +0 -2
- package/dist/types/builder/spool.d.ts +8 -9
- package/dist/types/constant/enum.d.ts +8 -0
- package/dist/types/query/core.d.ts +1 -1
- package/dist/types/query/portfolio.d.ts +44 -28
- package/dist/types/query/spool.d.ts +1 -1
- package/dist/utils/query.d.ts +3 -0
- package/package.json +24 -18
- package/src/builders/coreBuilder.ts +7 -7
- package/src/builders/spoolBuilder.ts +4 -4
- package/src/constants/enum.ts +22 -0
- package/src/models/scallopClient.ts +20 -20
- package/src/models/scallopUtils.ts +38 -15
- package/src/queries/coreQuery.ts +6 -1
- package/src/queries/portfolioQuery.ts +55 -14
- package/src/types/builder/core.ts +34 -29
- package/src/types/builder/index.ts +0 -2
- package/src/types/builder/spool.ts +15 -17
- package/src/types/constant/enum.ts +13 -0
- package/src/types/query/core.ts +2 -0
- package/src/types/query/portfolio.ts +46 -36
- package/src/types/query/spool.ts +1 -1
- package/src/utils/query.ts +18 -2
|
@@ -32,11 +32,21 @@ export type Lending = Required<
|
|
|
32
32
|
stakedAmount: number;
|
|
33
33
|
stakedCoin: number;
|
|
34
34
|
stakedValue: number;
|
|
35
|
+
unstakedMarketAmount: number;
|
|
36
|
+
unstakedMarketCoin: number;
|
|
37
|
+
unstakedAmount: number;
|
|
38
|
+
unstakedCoin: number;
|
|
39
|
+
unstakedValue: number;
|
|
35
40
|
availableSupplyAmount: number;
|
|
41
|
+
availableSupplyCoin: number;
|
|
36
42
|
availableWithdrawAmount: number;
|
|
43
|
+
availableWithdrawCoin: number;
|
|
37
44
|
availableStakeAmount: number;
|
|
45
|
+
availableStakeCoin: number;
|
|
38
46
|
availableUnstakeAmount: number;
|
|
47
|
+
availableUnstakeCoin: number;
|
|
39
48
|
availableClaimAmount: number;
|
|
49
|
+
availableClaimCoin: number;
|
|
40
50
|
};
|
|
41
51
|
|
|
42
52
|
export type ObligationAccount = {
|
|
@@ -53,43 +63,43 @@ export type ObligationAccount = {
|
|
|
53
63
|
totalDepositedPools: number;
|
|
54
64
|
totalBorrowedPools: number;
|
|
55
65
|
collaterals: OptionalKeys<
|
|
56
|
-
Record<
|
|
57
|
-
SupportCollateralCoins,
|
|
58
|
-
{
|
|
59
|
-
coinName: SupportCollateralCoins;
|
|
60
|
-
coinType: string;
|
|
61
|
-
symbol: string;
|
|
62
|
-
depositedAmount: number;
|
|
63
|
-
depositedCoin: number;
|
|
64
|
-
depositedValue: number;
|
|
65
|
-
borrowCapacityValue: number;
|
|
66
|
-
requiredCollateralValue: number;
|
|
67
|
-
availableDepositAmount: number;
|
|
68
|
-
availableDepositCoin: number;
|
|
69
|
-
availableWithdrawAmount: number;
|
|
70
|
-
availableWithdrawCoin: number;
|
|
71
|
-
}
|
|
72
|
-
>
|
|
73
|
-
>;
|
|
74
|
-
debts: OptionalKeys<
|
|
75
|
-
Record<
|
|
76
|
-
SupportPoolCoins,
|
|
77
|
-
{
|
|
78
|
-
coinName: SupportPoolCoins;
|
|
79
|
-
coinType: string;
|
|
80
|
-
symbol: string;
|
|
81
|
-
borrowedAmount: number;
|
|
82
|
-
borrowedCoin: number;
|
|
83
|
-
borrowedValue: number;
|
|
84
|
-
borrowedValueWithWeight: number;
|
|
85
|
-
borrowIndex: number;
|
|
86
|
-
availableBorrowAmount: number;
|
|
87
|
-
availableBorrowCoin: number;
|
|
88
|
-
availableRepayAmount: number;
|
|
89
|
-
availableRepayCoin: number;
|
|
90
|
-
}
|
|
91
|
-
>
|
|
66
|
+
Record<SupportCollateralCoins, ObligationCollateral>
|
|
92
67
|
>;
|
|
68
|
+
debts: OptionalKeys<Record<SupportPoolCoins, ObligationDebt>>;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export type ObligationCollateral = {
|
|
72
|
+
coinName: SupportCollateralCoins;
|
|
73
|
+
coinType: string;
|
|
74
|
+
symbol: string;
|
|
75
|
+
coinDecimal: number;
|
|
76
|
+
coinPrice: number;
|
|
77
|
+
depositedAmount: number;
|
|
78
|
+
depositedCoin: number;
|
|
79
|
+
depositedValue: number;
|
|
80
|
+
borrowCapacityValue: number;
|
|
81
|
+
requiredCollateralValue: number;
|
|
82
|
+
availableDepositAmount: number;
|
|
83
|
+
availableDepositCoin: number;
|
|
84
|
+
availableWithdrawAmount: number;
|
|
85
|
+
availableWithdrawCoin: number;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export type ObligationDebt = {
|
|
89
|
+
coinName: SupportPoolCoins;
|
|
90
|
+
coinType: string;
|
|
91
|
+
symbol: string;
|
|
92
|
+
coinDecimal: number;
|
|
93
|
+
coinPrice: number;
|
|
94
|
+
borrowedAmount: number;
|
|
95
|
+
borrowedCoin: number;
|
|
96
|
+
borrowedValue: number;
|
|
97
|
+
borrowedValueWithWeight: number;
|
|
98
|
+
borrowIndex: number;
|
|
99
|
+
availableBorrowAmount: number;
|
|
100
|
+
availableBorrowCoin: number;
|
|
101
|
+
availableRepayAmount: number;
|
|
102
|
+
availableRepayCoin: number;
|
|
93
103
|
};
|
|
94
104
|
|
|
95
105
|
export type TotalValueLocked = {
|
package/src/types/query/spool.ts
CHANGED
package/src/utils/query.ts
CHANGED
|
@@ -346,7 +346,7 @@ export const calculateRewardPoolData = (
|
|
|
346
346
|
.shiftedBy(-1 * rewardCoinDecimal)
|
|
347
347
|
.multipliedBy(rateYearFactor)
|
|
348
348
|
.multipliedBy(rewardCoinPrice);
|
|
349
|
-
const
|
|
349
|
+
const rewardRate = rewardValueForYear
|
|
350
350
|
.dividedBy(calculatedStakePoolData.stakedValue)
|
|
351
351
|
.isFinite()
|
|
352
352
|
? rewardValueForYear
|
|
@@ -355,7 +355,7 @@ export const calculateRewardPoolData = (
|
|
|
355
355
|
: Infinity;
|
|
356
356
|
|
|
357
357
|
return {
|
|
358
|
-
|
|
358
|
+
rewardApr: rewardRate,
|
|
359
359
|
totalRewardAmount: totalRewardAmount.toNumber(),
|
|
360
360
|
totalRewardCoin: totalRewardCoin.toNumber(),
|
|
361
361
|
totalRewardValue: totalRewardValue.toNumber(),
|
|
@@ -370,3 +370,19 @@ export const calculateRewardPoolData = (
|
|
|
370
370
|
exchangeRateDenominator: parsedRewardPoolData.exchangeRateDenominator,
|
|
371
371
|
};
|
|
372
372
|
};
|
|
373
|
+
|
|
374
|
+
export const minBigNumber = (...args: BigNumber.Value[]) => {
|
|
375
|
+
return BigNumber(
|
|
376
|
+
args.reduce((min, current) =>
|
|
377
|
+
new BigNumber(current).lt(min) ? current : min
|
|
378
|
+
)
|
|
379
|
+
);
|
|
380
|
+
};
|
|
381
|
+
|
|
382
|
+
export const maxBigNumber = (...args: BigNumber.Value[]) => {
|
|
383
|
+
return BigNumber(
|
|
384
|
+
args.reduce((max, current) =>
|
|
385
|
+
new BigNumber(current).gt(max) ? current : max
|
|
386
|
+
)
|
|
387
|
+
);
|
|
388
|
+
};
|