@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.
Files changed (42) hide show
  1. package/dist/constants/common.d.ts +3 -3
  2. package/dist/constants/enum.d.ts +2 -2
  3. package/dist/index.js +220 -150
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +219 -149
  6. package/dist/index.mjs.map +1 -1
  7. package/dist/models/scallopClient.d.ts +4 -4
  8. package/dist/models/scallopQuery.d.ts +40 -6
  9. package/dist/models/scallopUtils.d.ts +11 -11
  10. package/dist/queries/borrowIncentiveQuery.d.ts +2 -2
  11. package/dist/queries/coreQuery.d.ts +0 -2
  12. package/dist/queries/portfolioQuery.d.ts +0 -2
  13. package/dist/queries/priceQuery.d.ts +32 -2
  14. package/dist/queries/sCoinQuery.d.ts +1 -1
  15. package/dist/test.d.ts +0 -0
  16. package/dist/types/builder/borrowIncentive.d.ts +6 -6
  17. package/dist/types/constant/common.d.ts +1 -1
  18. package/dist/types/utils.d.ts +2 -6
  19. package/package.json +1 -1
  20. package/src/builders/borrowIncentiveBuilder.ts +2 -13
  21. package/src/constants/coinGecko.ts +3 -2
  22. package/src/constants/common.ts +10 -5
  23. package/src/constants/enum.ts +44 -34
  24. package/src/constants/poolAddress.ts +9 -8
  25. package/src/constants/pyth.ts +3 -2
  26. package/src/models/scallopClient.ts +27 -10
  27. package/src/models/scallopQuery.ts +18 -1
  28. package/src/models/scallopUtils.ts +23 -18
  29. package/src/queries/borrowIncentiveQuery.ts +29 -12
  30. package/src/queries/borrowLimitQuery.ts +3 -2
  31. package/src/queries/coreQuery.ts +4 -10
  32. package/src/queries/isolatedAssetQuery.ts +3 -2
  33. package/src/queries/portfolioQuery.ts +65 -62
  34. package/src/queries/priceQuery.ts +35 -2
  35. package/src/queries/sCoinQuery.ts +1 -1
  36. package/src/queries/spoolQuery.ts +2 -4
  37. package/src/queries/supplyLimitQuery.ts +3 -2
  38. package/src/test.ts +20 -0
  39. package/src/types/builder/borrowIncentive.ts +10 -15
  40. package/src/types/constant/common.ts +1 -2
  41. package/src/types/utils.ts +2 -10
  42. 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?: SuiObjectArg,
47
- obligationKey?: SuiObjectArg
42
+ obligation?: string,
43
+ obligationKey?: string
48
44
  ): Promise<void>;
49
45
  stakeObligationWithVeScaQuick(
50
- obligation?: SuiObjectArg,
51
- obligationKey?: SuiObjectArg,
52
- veScaKey?: SuiObjectArg
46
+ obligation?: string,
47
+ obligationKey?: string,
48
+ veScaKey?: string
53
49
  ): Promise<void>;
54
50
  unstakeObligationQuick(
55
- obligation?: SuiObjectArg,
56
- obligationKey?: SuiObjectArg
51
+ obligation?: string,
52
+ obligationKey?: string
57
53
  ): Promise<void>;
58
54
  claimBorrowIncentiveQuick(
59
- coinName: SupportBorrowIncentiveCoins,
60
55
  rewardType: SupportBorrowIncentiveRewardCoins,
61
- obligation?: SuiObjectArg,
62
- obligationKey?: SuiObjectArg
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 =
@@ -1,18 +1,10 @@
1
- import type { SupportAssetCoins } from './constant';
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<SupportAssetCoins, number>>;
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;
@@ -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 => {