@scallop-io/sui-scallop-sdk 1.4.0 → 1.4.1-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 -2
- package/dist/index.js +220 -150
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +219 -149
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallopClient.d.ts +4 -4
- package/dist/models/scallopQuery.d.ts +40 -6
- package/dist/models/scallopUtils.d.ts +11 -11
- 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/test.d.ts +0 -0
- package/dist/types/builder/borrowIncentive.d.ts +6 -6
- package/dist/types/constant/common.d.ts +1 -1
- package/dist/types/utils.d.ts +2 -6
- package/package.json +1 -1
- package/src/builders/borrowIncentiveBuilder.ts +2 -13
- package/src/constants/coinGecko.ts +3 -2
- package/src/constants/common.ts +10 -5
- package/src/constants/enum.ts +44 -34
- package/src/constants/poolAddress.ts +9 -8
- package/src/constants/pyth.ts +3 -2
- package/src/models/scallopClient.ts +27 -10
- package/src/models/scallopQuery.ts +18 -1
- package/src/models/scallopUtils.ts +23 -18
- package/src/queries/borrowIncentiveQuery.ts +29 -12
- package/src/queries/borrowLimitQuery.ts +3 -2
- package/src/queries/coreQuery.ts +4 -10
- package/src/queries/isolatedAssetQuery.ts +3 -2
- package/src/queries/portfolioQuery.ts +65 -62
- package/src/queries/priceQuery.ts +35 -2
- package/src/queries/sCoinQuery.ts +1 -1
- package/src/queries/spoolQuery.ts +2 -4
- package/src/queries/supplyLimitQuery.ts +3 -2
- package/src/test.ts +20 -0
- package/src/types/builder/borrowIncentive.ts +10 -15
- package/src/types/constant/common.ts +1 -2
- package/src/types/utils.ts +2 -10
- package/src/utils/query.ts +0 -87
|
@@ -4,10 +4,7 @@ import type {
|
|
|
4
4
|
} from '@scallop-io/sui-kit';
|
|
5
5
|
import type { TransactionResult } from '@mysten/sui/transactions';
|
|
6
6
|
import type { ScallopBuilder } from '../../models';
|
|
7
|
-
import type {
|
|
8
|
-
SupportBorrowIncentiveCoins,
|
|
9
|
-
SupportBorrowIncentiveRewardCoins,
|
|
10
|
-
} from '../constant';
|
|
7
|
+
import type { SupportBorrowIncentiveRewardCoins } from '../constant';
|
|
11
8
|
|
|
12
9
|
export type BorrowIncentiveIds = {
|
|
13
10
|
borrowIncentivePkg: string;
|
|
@@ -35,7 +32,6 @@ export type BorrowIncentiveNormalMethods = {
|
|
|
35
32
|
claimBorrowIncentive: (
|
|
36
33
|
obligation: SuiObjectArg,
|
|
37
34
|
obligationKey: SuiObjectArg,
|
|
38
|
-
coinName: SupportBorrowIncentiveCoins,
|
|
39
35
|
rewardType: SupportBorrowIncentiveRewardCoins
|
|
40
36
|
) => TransactionResult;
|
|
41
37
|
deactivateBoost: (obligation: SuiObjectArg, veScaKey: SuiObjectArg) => void;
|
|
@@ -43,23 +39,22 @@ export type BorrowIncentiveNormalMethods = {
|
|
|
43
39
|
|
|
44
40
|
export type BorrowIncentiveQuickMethods = {
|
|
45
41
|
stakeObligationQuick(
|
|
46
|
-
obligation?:
|
|
47
|
-
obligationKey?:
|
|
42
|
+
obligation?: string,
|
|
43
|
+
obligationKey?: string
|
|
48
44
|
): Promise<void>;
|
|
49
45
|
stakeObligationWithVeScaQuick(
|
|
50
|
-
obligation?:
|
|
51
|
-
obligationKey?:
|
|
52
|
-
veScaKey?:
|
|
46
|
+
obligation?: string,
|
|
47
|
+
obligationKey?: string,
|
|
48
|
+
veScaKey?: string
|
|
53
49
|
): Promise<void>;
|
|
54
50
|
unstakeObligationQuick(
|
|
55
|
-
obligation?:
|
|
56
|
-
obligationKey?:
|
|
51
|
+
obligation?: string,
|
|
52
|
+
obligationKey?: string
|
|
57
53
|
): Promise<void>;
|
|
58
54
|
claimBorrowIncentiveQuick(
|
|
59
|
-
coinName: SupportBorrowIncentiveCoins,
|
|
60
55
|
rewardType: SupportBorrowIncentiveRewardCoins,
|
|
61
|
-
obligation?:
|
|
62
|
-
obligationKey?:
|
|
56
|
+
obligation?: string,
|
|
57
|
+
obligationKey?: string
|
|
63
58
|
): Promise<TransactionResult>;
|
|
64
59
|
};
|
|
65
60
|
|
|
@@ -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 => {
|