@scallop-io/sui-scallop-sdk 0.47.2 → 1.3.0-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 (70) hide show
  1. package/dist/builders/borrowIncentiveBuilder.d.ts +2 -2
  2. package/dist/builders/coreBuilder.d.ts +2 -2
  3. package/dist/builders/index.d.ts +2 -2
  4. package/dist/builders/loyaltyProgramBuilder.d.ts +2 -2
  5. package/dist/builders/oracle.d.ts +4 -1
  6. package/dist/builders/referralBuilder.d.ts +2 -2
  7. package/dist/builders/sCoinBuilder.d.ts +2 -2
  8. package/dist/builders/spoolBuilder.d.ts +2 -2
  9. package/dist/builders/vescaBuilder.d.ts +2 -2
  10. package/dist/constants/common.d.ts +4 -4
  11. package/dist/constants/index.d.ts +1 -1
  12. package/dist/constants/vesca.d.ts +3 -3
  13. package/dist/index.js +125 -96
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +128 -102
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/models/scallop.d.ts +5 -5
  18. package/dist/models/scallopBuilder.d.ts +10 -8
  19. package/dist/models/scallopCache.d.ts +5 -9
  20. package/dist/models/scallopClient.d.ts +2 -2
  21. package/dist/models/scallopQuery.d.ts +1 -1
  22. package/dist/models/scallopUtils.d.ts +2 -2
  23. package/dist/queries/coreQuery.d.ts +3 -3
  24. package/dist/queries/loyaltyProgramQuery.d.ts +1 -1
  25. package/dist/queries/priceQuery.d.ts +1 -1
  26. package/dist/queries/vescaQuery.d.ts +1 -1
  27. package/dist/test.d.ts +1 -0
  28. package/dist/types/builder/borrowIncentive.d.ts +1 -1
  29. package/dist/types/builder/core.d.ts +16 -16
  30. package/dist/types/builder/spool.d.ts +3 -3
  31. package/dist/types/builder/vesca.d.ts +5 -5
  32. package/dist/types/model.d.ts +8 -7
  33. package/dist/types/query/vesca.d.ts +1 -1
  34. package/dist/utils/query.d.ts +1 -1
  35. package/dist/utils/util.d.ts +1 -0
  36. package/package.json +13 -9
  37. package/src/builders/borrowIncentiveBuilder.ts +9 -14
  38. package/src/builders/coreBuilder.ts +15 -15
  39. package/src/builders/index.ts +2 -2
  40. package/src/builders/loyaltyProgramBuilder.ts +5 -5
  41. package/src/builders/oracle.ts +13 -6
  42. package/src/builders/referralBuilder.ts +6 -6
  43. package/src/builders/sCoinBuilder.ts +5 -8
  44. package/src/builders/spoolBuilder.ts +9 -9
  45. package/src/builders/vescaBuilder.ts +5 -5
  46. package/src/constants/common.ts +4 -4
  47. package/src/constants/index.ts +1 -1
  48. package/src/constants/vesca.ts +5 -6
  49. package/src/models/scallop.ts +39 -16
  50. package/src/models/scallopBuilder.ts +14 -7
  51. package/src/models/scallopCache.ts +43 -34
  52. package/src/models/scallopClient.ts +8 -6
  53. package/src/models/scallopQuery.ts +2 -2
  54. package/src/models/scallopUtils.ts +3 -3
  55. package/src/queries/borrowIncentiveQuery.ts +1 -1
  56. package/src/queries/coreQuery.ts +4 -4
  57. package/src/queries/loyaltyProgramQuery.ts +1 -1
  58. package/src/queries/priceQuery.ts +1 -1
  59. package/src/queries/sCoinQuery.ts +2 -2
  60. package/src/queries/spoolQuery.ts +4 -5
  61. package/src/queries/vescaQuery.ts +6 -3
  62. package/src/test.ts +26 -0
  63. package/src/types/address.ts +26 -26
  64. package/src/types/builder/borrowIncentive.ts +1 -1
  65. package/src/types/builder/core.ts +26 -28
  66. package/src/types/builder/spool.ts +2 -3
  67. package/src/types/builder/vesca.ts +5 -9
  68. package/src/types/model.ts +11 -10
  69. package/src/types/query/vesca.ts +1 -1
  70. package/src/utils/query.ts +1 -1
@@ -1,4 +1,4 @@
1
- import { normalizeStructTag } from '@mysten/sui.js/utils';
1
+ import { normalizeStructTag } from '@mysten/sui/utils';
2
2
  import { SUPPORT_SPOOLS } from '../constants';
3
3
  import {
4
4
  parseOriginSpoolData,
@@ -7,7 +7,7 @@ import {
7
7
  calculateSpoolRewardPoolData,
8
8
  isMarketCoin,
9
9
  } from '../utils';
10
- import type { SuiObjectResponse } from '@mysten/sui.js/client';
10
+ import type { SuiObjectResponse } from '@mysten/sui/client';
11
11
  import type { ScallopQuery, ScallopUtils } from '../models';
12
12
  import type {
13
13
  MarketPool,
@@ -292,9 +292,8 @@ export const getStakeAccounts = async (
292
292
  utils.parseCoinName<SupportStakeCoins>(stakeMarketCoinName);
293
293
  const marketCoinType = utils.parseMarketCoinType(stakeCoinName);
294
294
 
295
- types[
296
- stakeMarketCoinName as SupportStakeMarketCoins
297
- ] = `${spoolObjectId}::spool_account::SpoolAccount<${marketCoinType}>`;
295
+ types[stakeMarketCoinName as SupportStakeMarketCoins] =
296
+ `${spoolObjectId}::spool_account::SpoolAccount<${marketCoinType}>`;
298
297
  return types;
299
298
  },
300
299
  {} as Record<SupportStakeMarketCoins, string>
@@ -4,12 +4,13 @@ import {
4
4
  type SuiObjectResponse,
5
5
  type SuiObjectData,
6
6
  DevInspectResults,
7
- } from '@mysten/sui.js/client';
7
+ } from '@mysten/sui/client';
8
8
  import type { ScallopUtils } from '../models';
9
9
  import { MAX_LOCK_DURATION } from 'src/constants';
10
10
  import { SUI_CLOCK_OBJECT_ID, SuiTxBlock } from '@scallop-io/sui-kit';
11
- import { bcs } from '@mysten/sui.js/bcs';
11
+ import { bcs } from '@mysten/sui/bcs';
12
12
  import { z as zod } from 'zod';
13
+ import assert from 'assert';
13
14
  /**
14
15
  * Query all owned veSca key.
15
16
  *
@@ -207,6 +208,7 @@ const getTotalVeScaTreasuryAmount = async (
207
208
  );
208
209
 
209
210
  const txb = new SuiTxBlock();
211
+
210
212
  // refresh first
211
213
  txb.moveCall(refreshQueryTarget, resolvedRefreshArgs);
212
214
  txb.moveCall(veScaAmountQueryTarget, resolvedVeScaAmountArgs);
@@ -231,7 +233,8 @@ const getTotalVeScaTreasuryAmount = async (
231
233
  if (results && results[1].returnValues) {
232
234
  const value = Uint8Array.from(results[1].returnValues[0][0]);
233
235
  const type = results[1].returnValues[0][1];
234
- return bcs.de(type, value);
236
+ assert(type === 'u64', 'Result type is not u64');
237
+ return bcs.u64().parse(value);
235
238
  }
236
239
 
237
240
  return '0';
package/src/test.ts ADDED
@@ -0,0 +1,26 @@
1
+ import { ScallopQuery } from './models';
2
+
3
+ const query = new ScallopQuery({
4
+ walletAddress:
5
+ '0xe78704e7c188b1902dbb630dc4c3ef7f46740c8cf121e38b3438ac1daea09f2d',
6
+ });
7
+
8
+ const main = async () => {
9
+ try {
10
+ await query.init();
11
+ const result = await query.suiKit.client().getObject({
12
+ id: '0xaa72bd551b25715b8f9d72f226fa02526bdf2e085a86faec7184230c5209bb6e',
13
+ options: {
14
+ showContent: true,
15
+ showType: true,
16
+ },
17
+ });
18
+ console.dir(result.data, { depth: null });
19
+ } catch (e) {
20
+ console.error(e);
21
+ } finally {
22
+ process.exit(0);
23
+ }
24
+ };
25
+
26
+ main();
@@ -27,13 +27,13 @@ export interface AddressesInterface {
27
27
  [K in SupportOracleType]: K extends (typeof SUPPORT_ORACLES)[0]
28
28
  ? string
29
29
  : K extends (typeof SUPPORT_ORACLES)[1]
30
- ? string
31
- : K extends (typeof SUPPORT_ORACLES)[2]
32
- ? {
33
- feed: string;
34
- feedObject: string;
35
- }
36
- : never;
30
+ ? string
31
+ : K extends (typeof SUPPORT_ORACLES)[2]
32
+ ? {
33
+ feed: string;
34
+ feedObject: string;
35
+ }
36
+ : never;
37
37
  };
38
38
  }
39
39
  >
@@ -46,19 +46,19 @@ export interface AddressesInterface {
46
46
  holder: string;
47
47
  }
48
48
  : K extends (typeof SUPPORT_ORACLES)[1]
49
- ? {
50
- registry: string;
51
- registryCap: string;
52
- }
53
- : K extends (typeof SUPPORT_ORACLES)[2]
54
- ? {
55
- registry: string;
56
- registryCap: string;
57
- state: string;
58
- wormhole: string;
59
- wormholeState: string;
60
- }
61
- : never;
49
+ ? {
50
+ registry: string;
51
+ registryCap: string;
52
+ }
53
+ : K extends (typeof SUPPORT_ORACLES)[2]
54
+ ? {
55
+ registry: string;
56
+ registryCap: string;
57
+ state: string;
58
+ wormhole: string;
59
+ wormholeState: string;
60
+ }
61
+ : never;
62
62
  } & { xOracle: string; xOracleCap: string };
63
63
  packages: Partial<
64
64
  Record<
@@ -145,12 +145,12 @@ type AddressPathsProps<T> = T extends string
145
145
  type Join<T extends string[], D extends string> = T extends []
146
146
  ? never
147
147
  : T extends [infer F]
148
- ? F
149
- : T extends [infer F, ...infer R]
150
- ? F extends string
151
- ? `${F}${D}${Join<Extract<R, string[]>, D>}`
152
- : never
153
- : string;
148
+ ? F
149
+ : T extends [infer F, ...infer R]
150
+ ? F extends string
151
+ ? `${F}${D}${Join<Extract<R, string[]>, D>}`
152
+ : never
153
+ : string;
154
154
 
155
155
  export type AddressStringPath = Join<
156
156
  AddressPathsProps<AddressesInterface>,
@@ -2,7 +2,7 @@ import type {
2
2
  SuiTxBlock as SuiKitTxBlock,
3
3
  SuiObjectArg,
4
4
  } from '@scallop-io/sui-kit';
5
- import type { TransactionResult } from '@mysten/sui.js/transactions';
5
+ import type { TransactionResult } from '@mysten/sui/transactions';
6
6
  import type { ScallopBuilder } from '../../models';
7
7
  import type {
8
8
  SupportBorrowIncentiveCoins,
@@ -1,13 +1,11 @@
1
1
  import type {
2
2
  SuiTxBlock as SuiKitTxBlock,
3
- SuiAddressArg,
4
3
  SuiObjectArg,
5
- SuiTxArg,
6
4
  } from '@scallop-io/sui-kit';
7
5
  import type {
8
6
  TransactionArgument,
9
7
  TransactionResult,
10
- } from '@mysten/sui.js/transactions';
8
+ } from '@mysten/sui/transactions';
11
9
  import type { ScallopBuilder } from '../../models';
12
10
  import type {
13
11
  SupportCollateralCoins,
@@ -35,19 +33,19 @@ type ObligationHotPotato = NestedResult;
35
33
  export type CoreNormalMethods = {
36
34
  openObligation: () => [Obligation, ObligationKey, ObligationHotPotato];
37
35
  returnObligation: (
38
- obligation: SuiAddressArg,
36
+ obligation: SuiObjectArg,
39
37
  obligationHotPotato: SuiObjectArg
40
38
  ) => void;
41
39
  openObligationEntry: () => void;
42
40
  addCollateral: (
43
- obligation: SuiAddressArg,
41
+ obligation: SuiObjectArg,
44
42
  coin: SuiObjectArg,
45
43
  collateralCoinName: SupportCollateralCoins
46
44
  ) => void;
47
45
  takeCollateral: (
48
- obligation: SuiAddressArg,
49
- obligationKey: SuiAddressArg,
50
- amount: SuiTxArg,
46
+ obligation: SuiObjectArg,
47
+ obligationKey: SuiObjectArg,
48
+ amount: number,
51
49
  collateralCoinName: SupportCollateralCoins
52
50
  ) => TransactionResult;
53
51
  deposit: (
@@ -64,36 +62,36 @@ export type CoreNormalMethods = {
64
62
  poolCoinName: SupportPoolCoins
65
63
  ) => void;
66
64
  borrow: (
67
- obligation: SuiAddressArg,
68
- obligationKey: SuiAddressArg,
69
- amount: SuiTxArg,
65
+ obligation: SuiObjectArg,
66
+ obligationKey: SuiObjectArg,
67
+ amount: number,
70
68
  poolCoinName: SupportPoolCoins
71
69
  ) => TransactionResult;
72
70
  borrowWithReferral: (
73
- obligation: SuiAddressArg,
74
- obligationKey: SuiAddressArg,
71
+ obligation: SuiObjectArg,
72
+ obligationKey: SuiObjectArg,
75
73
  borrowReferral: SuiObjectArg,
76
- amount: SuiTxArg,
74
+ amount: number,
77
75
  poolCoinName: SupportPoolCoins
78
76
  ) => TransactionResult;
79
77
  borrowEntry: (
80
- obligation: SuiAddressArg,
81
- obligationKey: SuiAddressArg,
82
- amount: SuiTxArg,
78
+ obligation: SuiObjectArg,
79
+ obligationKey: SuiObjectArg,
80
+ amount: number,
83
81
  poolCoinName: SupportPoolCoins
84
82
  ) => void;
85
83
  repay: (
86
- obligation: SuiAddressArg,
84
+ obligation: SuiObjectArg,
87
85
  coin: SuiObjectArg,
88
86
  poolCoinName: SupportPoolCoins
89
87
  ) => void;
90
88
  borrowFlashLoan: (
91
- amount: SuiTxArg,
89
+ amount: number,
92
90
  poolCoinName: SupportPoolCoins
93
91
  ) => TransactionResult;
94
92
  repayFlashLoan: (
95
93
  coin: SuiObjectArg,
96
- loan: SuiAddressArg,
94
+ loan: SuiObjectArg,
97
95
  poolCoinName: SupportPoolCoins
98
96
  ) => void;
99
97
  };
@@ -102,26 +100,26 @@ export type CoreQuickMethods = {
102
100
  addCollateralQuick: (
103
101
  amount: number,
104
102
  collateralCoinName: SupportCollateralCoins,
105
- obligationId?: SuiAddressArg
103
+ obligationId?: SuiObjectArg
106
104
  ) => Promise<void>;
107
105
  takeCollateralQuick: (
108
106
  amount: number,
109
107
  collateralCoinName: SupportCollateralCoins,
110
- obligationId?: SuiAddressArg,
111
- obligationKey?: SuiAddressArg
108
+ obligationId?: SuiObjectArg,
109
+ obligationKey?: SuiObjectArg
112
110
  ) => Promise<TransactionResult>;
113
111
  borrowQuick: (
114
112
  amount: number,
115
113
  poolCoinName: SupportPoolCoins,
116
- obligationId?: SuiAddressArg,
117
- obligationKey?: SuiAddressArg
114
+ obligationId?: SuiObjectArg,
115
+ obligationKey?: SuiObjectArg
118
116
  ) => Promise<TransactionResult>;
119
117
  borrowWithReferralQuick: (
120
118
  amount: number,
121
119
  poolCoinName: SupportPoolCoins,
122
120
  borrowReferral: SuiObjectArg,
123
- obligationId?: SuiAddressArg,
124
- obligationKey?: SuiAddressArg
121
+ obligationId?: SuiObjectArg,
122
+ obligationKey?: SuiObjectArg
125
123
  ) => Promise<TransactionResult>;
126
124
  depositQuick: (
127
125
  amount: number,
@@ -135,7 +133,7 @@ export type CoreQuickMethods = {
135
133
  repayQuick: (
136
134
  amount: number,
137
135
  poolCoinName: SupportPoolCoins,
138
- obligationId?: SuiAddressArg
136
+ obligationId?: SuiObjectArg
139
137
  ) => Promise<void>;
140
138
  updateAssetPricesQuick: (
141
139
  assetCoinNames?: SupportAssetCoins[]
@@ -2,9 +2,8 @@ import type {
2
2
  SuiTxBlock as SuiKitTxBlock,
3
3
  SuiAddressArg,
4
4
  SuiObjectArg,
5
- SuiTxArg,
6
5
  } from '@scallop-io/sui-kit';
7
- import type { TransactionResult } from '@mysten/sui.js/transactions';
6
+ import type { TransactionResult } from '@mysten/sui/transactions';
8
7
  import type { ScallopBuilder } from '../../models';
9
8
  import type { SupportStakeMarketCoins } from '../constant';
10
9
  import { SuiTxBlockWithSCoin } from '.';
@@ -24,7 +23,7 @@ export type SpoolNormalMethods = {
24
23
  ) => void;
25
24
  unstake: (
26
25
  stakeAccount: SuiAddressArg,
27
- amount: SuiTxArg,
26
+ amount: number,
28
27
  stakeMarketCoinName: SupportStakeMarketCoins
29
28
  ) => TransactionResult;
30
29
  claim: (
@@ -1,9 +1,5 @@
1
- import {
2
- SuiTxBlock as SuiKitTxBlock,
3
- SuiObjectArg,
4
- SuiTxArg,
5
- } from '@scallop-io/sui-kit';
6
- import type { TransactionResult } from '@mysten/sui.js/transactions';
1
+ import { SuiTxBlock as SuiKitTxBlock, SuiObjectArg } from '@scallop-io/sui-kit';
2
+ import type { TransactionResult } from '@mysten/sui/transactions';
7
3
  import { ScallopBuilder } from 'src/models';
8
4
 
9
5
  export type VescaIds = {
@@ -16,17 +12,17 @@ export type VescaIds = {
16
12
  export type VeScaNormalMethods = {
17
13
  lockSca: (
18
14
  scaCoin: SuiObjectArg,
19
- unlockAtInSecondTimestamp: SuiTxArg
15
+ unlockAtInSecondTimestamp: number
20
16
  ) => TransactionResult;
21
17
  extendLockPeriod: (
22
18
  veScaKey: SuiObjectArg,
23
- newUnlockAtInSecondTimestamp: SuiTxArg
19
+ newUnlockAtInSecondTimestamp: number
24
20
  ) => void;
25
21
  extendLockAmount: (veScaKey: SuiObjectArg, scaCoin: SuiObjectArg) => void;
26
22
  renewExpiredVeSca: (
27
23
  veScaKey: SuiObjectArg,
28
24
  scaCoin: SuiObjectArg,
29
- newUnlockAtInSecondTimestamp: SuiTxArg
25
+ newUnlockAtInSecondTimestamp: number
30
26
  ) => void;
31
27
  redeemSca: (veScaKey: SuiObjectArg) => TransactionResult;
32
28
  mintEmptyVeSca: () => TransactionResult;
@@ -1,8 +1,5 @@
1
- import type { SuiTransactionBlockResponse } from '@mysten/sui.js/client';
2
- import type {
3
- TransactionBlock,
4
- TransactionResult,
5
- } from '@mysten/sui.js/transactions';
1
+ import type { SuiTransactionBlockResponse } from '@mysten/sui/client';
2
+ import type { Transaction, TransactionResult } from '@mysten/sui/transactions';
6
3
  import type { SuiKit, SuiKitParams, NetworkType } from '@scallop-io/sui-kit';
7
4
  import type {
8
5
  ScallopAddress,
@@ -15,12 +12,12 @@ import { ScallopCache } from 'src/models/scallopCache';
15
12
 
16
13
  export type ScallopClientFnReturnType<T extends boolean> = T extends true
17
14
  ? SuiTransactionBlockResponse
18
- : TransactionBlock;
15
+ : Transaction;
19
16
 
20
17
  export type ScallopClientVeScaReturnType<T extends boolean> = T extends true
21
18
  ? SuiTransactionBlockResponse
22
19
  : {
23
- tx: TransactionBlock;
20
+ tx: Transaction;
24
21
  scaCoin: TransactionResult;
25
22
  };
26
23
 
@@ -66,13 +63,17 @@ export type ScallopParams = {
66
63
  walletAddress?: string;
67
64
  } & SuiKitParams;
68
65
 
69
- export type ScallopClientParams = ScallopParams;
66
+ export type ScallopClientParams = ScallopParams &
67
+ ScallopBuilderParams &
68
+ ScallopQueryParams &
69
+ ScallopUtilsParams;
70
70
 
71
71
  export type ScallopBuilderParams = ScallopParams & {
72
72
  pythEndpoints?: string[];
73
- };
73
+ usePythPullModel?: boolean;
74
+ } & ScallopQueryParams;
74
75
 
75
- export type ScallopQueryParams = ScallopParams;
76
+ export type ScallopQueryParams = ScallopParams & ScallopUtilsParams;
76
77
 
77
78
  export type ScallopUtilsParams = ScallopParams & {
78
79
  pythEndpoints?: string[];
@@ -1,4 +1,4 @@
1
- import type { SuiObjectRef } from '@mysten/sui.js/client';
1
+ import type { SuiObjectRef } from '@mysten/sui/client';
2
2
 
3
3
  export type Vesca = {
4
4
  id: string;
@@ -1,5 +1,5 @@
1
1
  import BigNumber from 'bignumber.js';
2
- import { normalizeStructTag, parseStructTag } from '@mysten/sui.js/utils';
2
+ import { normalizeStructTag, parseStructTag } from '@mysten/sui/utils';
3
3
  import type { ScallopUtils } from '../models';
4
4
  import type {
5
5
  OriginMarketPoolData,