@scallop-io/sui-scallop-sdk 0.47.3 → 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 (67) 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/referralBuilder.d.ts +2 -2
  6. package/dist/builders/sCoinBuilder.d.ts +2 -2
  7. package/dist/builders/spoolBuilder.d.ts +2 -2
  8. package/dist/builders/vescaBuilder.d.ts +2 -2
  9. package/dist/constants/common.d.ts +4 -4
  10. package/dist/constants/index.d.ts +1 -1
  11. package/dist/constants/vesca.d.ts +3 -3
  12. package/dist/index.js +87 -71
  13. package/dist/index.js.map +1 -1
  14. package/dist/index.mjs +90 -77
  15. package/dist/index.mjs.map +1 -1
  16. package/dist/models/scallopBuilder.d.ts +10 -8
  17. package/dist/models/scallopCache.d.ts +5 -9
  18. package/dist/models/scallopClient.d.ts +2 -2
  19. package/dist/models/scallopQuery.d.ts +1 -1
  20. package/dist/models/scallopUtils.d.ts +2 -2
  21. package/dist/queries/coreQuery.d.ts +3 -3
  22. package/dist/queries/loyaltyProgramQuery.d.ts +1 -1
  23. package/dist/queries/priceQuery.d.ts +1 -1
  24. package/dist/queries/vescaQuery.d.ts +1 -1
  25. package/dist/test.d.ts +1 -0
  26. package/dist/types/builder/borrowIncentive.d.ts +1 -1
  27. package/dist/types/builder/core.d.ts +16 -16
  28. package/dist/types/builder/spool.d.ts +3 -3
  29. package/dist/types/builder/vesca.d.ts +5 -5
  30. package/dist/types/model.d.ts +4 -4
  31. package/dist/types/query/vesca.d.ts +1 -1
  32. package/dist/utils/query.d.ts +1 -1
  33. package/dist/utils/util.d.ts +1 -0
  34. package/package.json +13 -9
  35. package/src/builders/borrowIncentiveBuilder.ts +6 -6
  36. package/src/builders/coreBuilder.ts +15 -15
  37. package/src/builders/index.ts +2 -2
  38. package/src/builders/loyaltyProgramBuilder.ts +5 -5
  39. package/src/builders/oracle.ts +5 -4
  40. package/src/builders/referralBuilder.ts +6 -6
  41. package/src/builders/sCoinBuilder.ts +5 -8
  42. package/src/builders/spoolBuilder.ts +9 -9
  43. package/src/builders/vescaBuilder.ts +5 -5
  44. package/src/constants/common.ts +4 -4
  45. package/src/constants/index.ts +1 -1
  46. package/src/constants/vesca.ts +5 -6
  47. package/src/models/scallopBuilder.ts +14 -7
  48. package/src/models/scallopCache.ts +43 -34
  49. package/src/models/scallopClient.ts +8 -6
  50. package/src/models/scallopQuery.ts +2 -2
  51. package/src/models/scallopUtils.ts +3 -3
  52. package/src/queries/borrowIncentiveQuery.ts +1 -1
  53. package/src/queries/coreQuery.ts +4 -4
  54. package/src/queries/loyaltyProgramQuery.ts +1 -1
  55. package/src/queries/priceQuery.ts +1 -1
  56. package/src/queries/sCoinQuery.ts +2 -2
  57. package/src/queries/spoolQuery.ts +4 -5
  58. package/src/queries/vescaQuery.ts +6 -3
  59. package/src/test.ts +26 -0
  60. package/src/types/address.ts +26 -26
  61. package/src/types/builder/borrowIncentive.ts +1 -1
  62. package/src/types/builder/core.ts +26 -28
  63. package/src/types/builder/spool.ts +2 -3
  64. package/src/types/builder/vesca.ts +5 -9
  65. package/src/types/model.ts +4 -7
  66. package/src/types/query/vesca.ts +1 -1
  67. package/src/utils/query.ts +1 -1
@@ -1,7 +1,4 @@
1
- import {
2
- TransactionBlock,
3
- SuiTxBlock as SuiKitTxBlock,
4
- } from '@scallop-io/sui-kit';
1
+ import { Transaction, SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
5
2
  import { ScallopBuilder } from 'src/models';
6
3
  import {
7
4
  BaseScallopTxBlock,
@@ -83,15 +80,15 @@ export const newSCoinTxBlock = (
83
80
  initTxBlock?:
84
81
  | ScallopTxBlock
85
82
  | SuiKitTxBlock
86
- | TransactionBlock
83
+ | Transaction
87
84
  | BaseScallopTxBlock
88
85
  ) => {
89
86
  const txBlock =
90
- initTxBlock instanceof TransactionBlock
87
+ initTxBlock instanceof Transaction
91
88
  ? new SuiKitTxBlock(initTxBlock)
92
89
  : initTxBlock
93
- ? initTxBlock
94
- : new SuiKitTxBlock();
90
+ ? initTxBlock
91
+ : new SuiKitTxBlock();
95
92
 
96
93
  const normalMethod = generateSCoinNormalMethod({
97
94
  builder,
@@ -1,11 +1,11 @@
1
- import { TransactionBlock } from '@mysten/sui.js/transactions';
2
- import { SUI_CLOCK_OBJECT_ID } from '@mysten/sui.js/utils';
1
+ import { Transaction } from '@mysten/sui/transactions';
2
+ import { SUI_CLOCK_OBJECT_ID } from '@mysten/sui/utils';
3
3
  import { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
4
4
  import { spoolRewardCoins } from '../constants/enum';
5
5
  import { getStakeAccounts } from '../queries/spoolQuery';
6
6
  import { requireSender } from '../utils';
7
7
  import type { SuiAddressArg } from '@scallop-io/sui-kit';
8
- import type { TransactionResult } from '@mysten/sui.js/transactions';
8
+ import type { TransactionResult } from '@mysten/sui/transactions';
9
9
  import type { ScallopBuilder } from '../models';
10
10
  import type {
11
11
  SpoolIds,
@@ -166,10 +166,10 @@ const generateSpoolNormalMethod: GenerateSpoolNormalMethod = ({
166
166
  claim: (stakeAccount, stakeMarketCoinName) => {
167
167
  const stakePoolId = builder.address.get(
168
168
  `spool.pools.${stakeMarketCoinName}.id`
169
- );
169
+ ) as string;
170
170
  const rewardPoolId = builder.address.get(
171
171
  `spool.pools.${stakeMarketCoinName}.rewardPoolId`
172
- );
172
+ ) as string;
173
173
  const marketCoinType =
174
174
  builder.utils.parseMarketCoinType(stakeMarketCoinName);
175
175
  const rewardCoinName = spoolRewardCoins[stakeMarketCoinName];
@@ -317,15 +317,15 @@ export const newSpoolTxBlock = (
317
317
  initTxBlock?:
318
318
  | ScallopTxBlock
319
319
  | SuiKitTxBlock
320
- | TransactionBlock
320
+ | Transaction
321
321
  | SuiTxBlockWithSCoin
322
322
  ) => {
323
323
  const txBlock =
324
- initTxBlock instanceof TransactionBlock
324
+ initTxBlock instanceof Transaction
325
325
  ? new SuiKitTxBlock(initTxBlock)
326
326
  : initTxBlock
327
- ? initTxBlock
328
- : new SuiKitTxBlock();
327
+ ? initTxBlock
328
+ : new SuiKitTxBlock();
329
329
 
330
330
  const normalMethod = generateSpoolNormalMethod({
331
331
  builder,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  SUI_CLOCK_OBJECT_ID,
3
3
  SuiTxBlock,
4
- TransactionBlock,
4
+ Transaction,
5
5
  SuiTxBlock as SuiKitTxBlock,
6
6
  } from '@scallop-io/sui-kit';
7
7
  import { SCA_COIN_TYPE } from 'src/constants';
@@ -366,14 +366,14 @@ const generateQuickVeScaMethod: GenerateVeScaQuickMethod = ({
366
366
  */
367
367
  export const newVeScaTxBlock = (
368
368
  builder: ScallopBuilder,
369
- initTxBlock?: ScallopTxBlock | SuiKitTxBlock | TransactionBlock
369
+ initTxBlock?: ScallopTxBlock | SuiKitTxBlock | Transaction
370
370
  ) => {
371
371
  const txBlock =
372
- initTxBlock instanceof TransactionBlock
372
+ initTxBlock instanceof Transaction
373
373
  ? new SuiKitTxBlock(initTxBlock)
374
374
  : initTxBlock
375
- ? initTxBlock
376
- : new SuiKitTxBlock();
375
+ ? initTxBlock
376
+ : new SuiKitTxBlock();
377
377
 
378
378
  const normalMethod = generateNormalVeScaMethod({
379
379
  builder,
@@ -1,9 +1,9 @@
1
1
  // export const API_BASE_URL = 'https://sui.api.scallop.io';
2
- export const API_BASE_URL = 'https://sui.apis.scallop.io';
3
- export const SDK_API_BASE_URL = 'https://sdk.api.scallop.io';
2
+ export const API_BASE_URL = 'https://sui.apis.scallop.io' as const;
3
+ export const SDK_API_BASE_URL = 'https://sdk.api.scallop.io' as const;
4
4
 
5
- export const IS_VE_SCA_TEST = false;
6
- export const USE_TEST_ADDRESS = false;
5
+ export const IS_VE_SCA_TEST: boolean = false;
6
+ export const USE_TEST_ADDRESS: boolean = false;
7
7
 
8
8
  export const ADDRESSES_ID =
9
9
  IS_VE_SCA_TEST || USE_TEST_ADDRESS
@@ -1,4 +1,4 @@
1
1
  export * from './common';
2
2
  export * from './enum';
3
- export * from './vesca';
4
3
  export * from './flashloan';
4
+ export * from './vesca';
@@ -1,7 +1,6 @@
1
- export const UNLOCK_ROUND_DURATION = 60 * 60 * 24; // 1 days in seconds
2
- export const MAX_LOCK_ROUNDS: number = 1460; // 4 years in days (or 9 days for testing)
3
- export const MAX_LOCK_DURATION: number =
4
- MAX_LOCK_ROUNDS * UNLOCK_ROUND_DURATION; // 4 years in seconds
1
+ export const UNLOCK_ROUND_DURATION = 60 * 60 * 24; // 1 day in seconds
2
+ export const MAX_LOCK_ROUNDS = 1460 as const; // 4 years in days (or 9 days for testing)
3
+ export const MAX_LOCK_DURATION = MAX_LOCK_ROUNDS * UNLOCK_ROUND_DURATION; // 4 years in seconds
5
4
 
6
- export const MIN_INITIAL_LOCK_AMOUNT: number = 10_000_000_000 as const;
7
- export const MIN_TOP_UP_AMOUNT: number = 1_000_000_000 as const;
5
+ export const MIN_INITIAL_LOCK_AMOUNT = 10_000_000_000 as const;
6
+ export const MIN_TOP_UP_AMOUNT = 1_000_000_000 as const;
@@ -1,12 +1,12 @@
1
- import { normalizeSuiAddress } from '@mysten/sui.js/utils';
1
+ import { normalizeSuiAddress } from '@mysten/sui/utils';
2
2
  import { SuiKit } from '@scallop-io/sui-kit';
3
3
  import { ADDRESSES_ID } from '../constants';
4
4
  import { newScallopTxBlock } from '../builders';
5
5
  import { ScallopAddress } from './scallopAddress';
6
6
  import { ScallopQuery } from './scallopQuery';
7
7
  import { ScallopUtils } from './scallopUtils';
8
- import type { SuiTransactionBlockResponse } from '@mysten/sui.js/client';
9
- import type { TransactionBlock } from '@mysten/sui.js/transactions';
8
+ import type { SuiTransactionBlockResponse } from '@mysten/sui/client';
9
+ import type { Transaction } from '@mysten/sui/transactions';
10
10
  import type { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
11
11
  import type {
12
12
  ScallopBuilderParams,
@@ -19,6 +19,7 @@ import type {
19
19
  } from '../types';
20
20
  import { ScallopCache } from './scallopCache';
21
21
  import { DEFAULT_CACHE_OPTIONS } from 'src/constants/cache';
22
+ import { SuiClient as SuiClientV0 } from '@mysten/sui.js/client';
22
23
 
23
24
  /**
24
25
  * @description
@@ -42,6 +43,9 @@ export class ScallopBuilder {
42
43
  public walletAddress: string;
43
44
  public cache: ScallopCache;
44
45
 
46
+ // For compatibility with pyth sdk
47
+ public oldSuiClient: SuiClientV0;
48
+
45
49
  public constructor(
46
50
  params: ScallopBuilderParams,
47
51
  instance?: ScallopBuilderInstanceParams
@@ -88,6 +92,11 @@ export class ScallopBuilder {
88
92
  this.isTestnet = params.networkType
89
93
  ? params.networkType === 'testnet'
90
94
  : false;
95
+
96
+ // intitialize old Sui Client version
97
+ this.oldSuiClient = new SuiClientV0({
98
+ url: this.suiKit.suiInteractor.currentFullNode,
99
+ });
91
100
  }
92
101
 
93
102
  /**
@@ -112,9 +121,7 @@ export class ScallopBuilder {
112
121
  * @param txBlock - Scallop txBlock, txBlock created by SuiKit, or original transaction block.
113
122
  * @return Scallop txBlock.
114
123
  */
115
- public createTxBlock(
116
- txBlock?: ScallopTxBlock | SuiKitTxBlock | TransactionBlock
117
- ) {
124
+ public createTxBlock(txBlock?: ScallopTxBlock | SuiKitTxBlock | Transaction) {
118
125
  return newScallopTxBlock(this, txBlock);
119
126
  }
120
127
 
@@ -210,7 +217,7 @@ export class ScallopBuilder {
210
217
  * @param txBlock - Scallop txBlock, txBlock created by SuiKit, or original transaction block.
211
218
  */
212
219
  public async signAndSendTxBlock(
213
- txBlock: ScallopTxBlock | SuiKitTxBlock | TransactionBlock
220
+ txBlock: ScallopTxBlock | SuiKitTxBlock | Transaction
214
221
  ) {
215
222
  return (await this.suiKit.signAndSendTxn(
216
223
  txBlock
@@ -1,6 +1,6 @@
1
1
  import { QueryClient, QueryClientConfig } from '@tanstack/query-core';
2
2
  import {
3
- SuiTxArg,
3
+ SuiObjectArg,
4
4
  SuiTxBlock,
5
5
  normalizeStructTag,
6
6
  normalizeSuiAddress,
@@ -17,7 +17,7 @@ import type {
17
17
  GetDynamicFieldObjectParams,
18
18
  GetBalanceParams,
19
19
  SuiClient,
20
- } from '@mysten/sui.js/client';
20
+ } from '@mysten/sui/client';
21
21
  import { DEFAULT_CACHE_OPTIONS } from 'src/constants/cache';
22
22
  import { callWithRateLimit, TokenBucket } from 'src/utils';
23
23
  import {
@@ -27,7 +27,7 @@ import {
27
27
 
28
28
  type QueryInspectTxnParams = {
29
29
  queryTarget: string;
30
- args: SuiTxArg[];
30
+ args: SuiObjectArg[];
31
31
  typeArgs?: any[];
32
32
  };
33
33
 
@@ -92,20 +92,43 @@ export class ScallopCache {
92
92
  });
93
93
  }
94
94
 
95
- /**
96
- * @description Cache protocol config call for 60 seconds.
97
- * @returns Promise<ProtocolConfig>
98
- */
99
- public async getProtocolConfig() {
100
- return await this.queryClient.fetchQuery({
101
- queryKey: ['getProtocolConfig'],
102
- queryFn: async () => {
103
- return await callWithRateLimit(this.tokenBucket, () =>
104
- this.client.getProtocolConfig()
105
- );
106
- },
107
- staleTime: 30000,
108
- });
95
+ public async resolveArgs(
96
+ txb: SuiTxBlock,
97
+ args: SuiObjectArg[]
98
+ ): Promise<SuiObjectArg[]> {
99
+ return await Promise.all(
100
+ args.map(async (arg) => {
101
+ if (typeof arg === 'string') {
102
+ const objData = (await this.queryGetObject(arg, { showOwner: true }))
103
+ ?.data;
104
+ if (!objData) return arg;
105
+ const owner = objData?.owner as any;
106
+ if (!owner) return arg;
107
+
108
+ if ('Shared' in owner) {
109
+ return txb.sharedObjectRef({
110
+ objectId: objData.objectId,
111
+ initialSharedVersion: owner.Shared.initial_shared_version,
112
+ mutable: true,
113
+ });
114
+ } else {
115
+ return txb.objectRef({
116
+ objectId: objData.objectId,
117
+ version: objData.version,
118
+ digest: objData.digest,
119
+ });
120
+ }
121
+ } else if ('objectId' in arg && 'version' in arg && 'digest' in arg) {
122
+ return txb.objectRef({
123
+ objectId: arg.objectId,
124
+ version: arg.version as string,
125
+ digest: arg.digest,
126
+ });
127
+ } else {
128
+ return arg;
129
+ }
130
+ })
131
+ );
109
132
  }
110
133
 
111
134
  /**
@@ -121,23 +144,9 @@ export class ScallopCache {
121
144
  }: QueryInspectTxnParams): Promise<DevInspectResults | null> {
122
145
  const txBlock = new SuiTxBlock();
123
146
 
124
- // resolve all the object args to prevent duplicate getNormalizedMoveFunction calls
125
- const resolvedArgs = await Promise.all(
126
- args.map(async (arg) => {
127
- if (typeof arg === 'string') {
128
- return (await this.queryGetObject(arg, { showContent: true }))?.data;
129
- }
130
- return arg;
131
- })
132
- );
133
- txBlock.moveCall(queryTarget, resolvedArgs, typeArgs);
147
+ const resolvedArgs = await this.resolveArgs(txBlock, args);
134
148
 
135
- // build the txBlock to prevent duplicate getProtocolConfig calls
136
- const txBytes = await txBlock.txBlock.build({
137
- client: this.client,
138
- onlyTransactionKind: true,
139
- protocolConfig: (await this.getProtocolConfig()) ?? undefined,
140
- });
149
+ txBlock.moveCall(queryTarget, resolvedArgs, typeArgs);
141
150
 
142
151
  const query = await this.queryClient.fetchQuery({
143
152
  queryKey: typeArgs
@@ -150,7 +159,7 @@ export class ScallopCache {
150
159
  ],
151
160
  queryFn: async () => {
152
161
  return await callWithRateLimit(this.tokenBucket, () =>
153
- this.suiKit.inspectTxn(txBytes)
162
+ this.suiKit.inspectTxn(txBlock)
154
163
  );
155
164
  },
156
165
  });
@@ -1,4 +1,4 @@
1
- import { normalizeSuiAddress } from '@mysten/sui.js/utils';
1
+ import { normalizeSuiAddress } from '@mysten/sui/utils';
2
2
  import { SuiKit } from '@scallop-io/sui-kit';
3
3
  import { DEFAULT_CACHE_OPTIONS } from 'src/constants/cache';
4
4
  import {
@@ -12,13 +12,13 @@ import { ScallopAddress } from './scallopAddress';
12
12
  import { ScallopUtils } from './scallopUtils';
13
13
  import { ScallopBuilder } from './scallopBuilder';
14
14
  import { ScallopQuery } from './scallopQuery';
15
- import { ScallopCache } from './scallopCache';
16
- import { requireSender } from 'src/utils';
17
- import type { SuiTransactionBlockResponse } from '@mysten/sui.js/client';
15
+ import type { SuiTransactionBlockResponse } from '@mysten/sui/client';
18
16
  import type {
19
17
  TransactionObjectArgument,
20
18
  TransactionResult,
21
- } from '@mysten/sui.js/transactions';
19
+ } from '@mysten/sui/transactions';
20
+ import { ScallopCache } from './scallopCache';
21
+ import { requireSender } from 'src/utils';
22
22
  import type { SuiObjectArg } from '@scallop-io/sui-kit';
23
23
  import type {
24
24
  ScallopClientFnReturnType,
@@ -604,7 +604,7 @@ export class ScallopClient {
604
604
  callback: (
605
605
  txBlock: ScallopTxBlock,
606
606
  coin: TransactionObjectArgument | string
607
- ) => SuiObjectArg,
607
+ ) => SuiObjectArg | Promise<SuiObjectArg>,
608
608
  sign: S = true as S,
609
609
  walletAddress?: string
610
610
  ): Promise<ScallopClientFnReturnType<S>> {
@@ -812,6 +812,8 @@ export class ScallopClient {
812
812
  );
813
813
  const stakeCoinName =
814
814
  this.utils.parseCoinName<SupportStakeCoins>(stakeMarketCoinName);
815
+
816
+ console.log(stakeMarketCoin, stakeCoinName);
815
817
  if (stakeMarketCoin) {
816
818
  const coin = txBlock.withdraw(stakeMarketCoin, stakeCoinName);
817
819
  await this.utils.mergeSimilarCoins(
@@ -53,14 +53,14 @@ import { ScallopUtils } from './scallopUtils';
53
53
  import { ScallopIndexer } from './scallopIndexer';
54
54
  import { ScallopCache } from './scallopCache';
55
55
  import { DEFAULT_CACHE_OPTIONS } from 'src/constants/cache';
56
- import { SuiObjectData } from '@mysten/sui.js/client';
56
+ import { SuiObjectData } from '@mysten/sui/src/client';
57
57
  import {
58
58
  getSCoinAmount,
59
59
  getSCoinAmounts,
60
60
  getSCoinSwapRate,
61
61
  getSCoinTotalSupply,
62
62
  } from 'src/queries/sCoinQuery';
63
- import { normalizeSuiAddress } from '@mysten/sui.js/utils';
63
+ import { normalizeSuiAddress } from '@mysten/sui/utils';
64
64
  import { getSupplyLimit } from 'src/queries/supplyLimit';
65
65
 
66
66
  /**
@@ -1,4 +1,4 @@
1
- import { SUI_TYPE_ARG, normalizeStructTag } from '@mysten/sui.js/utils';
1
+ import { SUI_TYPE_ARG, normalizeStructTag } from '@mysten/sui/utils';
2
2
  import { SuiKit } from '@scallop-io/sui-kit';
3
3
  import { SuiPriceServiceConnection } from '@pythnetwork/pyth-sui-js';
4
4
  import { ScallopAddress } from './scallopAddress';
@@ -41,7 +41,7 @@ import type {
41
41
  SupportSCoin,
42
42
  ScallopUtilsInstanceParams,
43
43
  } from '../types';
44
- import type { SuiAddressArg, SuiTxArg, SuiTxBlock } from '@scallop-io/sui-kit';
44
+ import type { SuiObjectArg, SuiTxArg, SuiTxBlock } from '@scallop-io/sui-kit';
45
45
 
46
46
  /**
47
47
  * @description
@@ -444,7 +444,7 @@ export class ScallopUtils {
444
444
  * @param obligationId - The obligation id.
445
445
  * @return Asset coin Names.
446
446
  */
447
- public async getObligationCoinNames(obligationId: SuiAddressArg) {
447
+ public async getObligationCoinNames(obligationId: SuiObjectArg) {
448
448
  const obligation = await queryObligation(this, obligationId);
449
449
  if (!obligation) return undefined;
450
450
 
@@ -1,4 +1,4 @@
1
- import { normalizeStructTag } from '@mysten/sui.js/utils';
1
+ import { normalizeStructTag } from '@mysten/sui/utils';
2
2
  import {
3
3
  SUPPORT_BORROW_INCENTIVE_POOLS,
4
4
  SUPPORT_BORROW_INCENTIVE_REWARDS,
@@ -1,4 +1,4 @@
1
- import { normalizeStructTag } from '@mysten/sui.js/utils';
1
+ import { normalizeStructTag } from '@mysten/sui/utils';
2
2
  import {
3
3
  SUPPORT_POOLS,
4
4
  PROTOCOL_OBJECT_ID,
@@ -13,8 +13,8 @@ import {
13
13
  parseOriginMarketCollateralData,
14
14
  calculateMarketCollateralData,
15
15
  } from '../utils';
16
- import type { SuiObjectResponse, SuiObjectData } from '@mysten/sui.js/client';
17
- import type { SuiAddressArg } from '@scallop-io/sui-kit';
16
+ import type { SuiObjectResponse, SuiObjectData } from '@mysten/sui/client';
17
+ import type { SuiObjectArg } from '@scallop-io/sui-kit';
18
18
  import type { ScallopAddress, ScallopCache, ScallopQuery } from '../models';
19
19
  import {
20
20
  Market,
@@ -819,7 +819,7 @@ export const queryObligation = async (
819
819
  }: {
820
820
  address: ScallopAddress;
821
821
  },
822
- obligationId: SuiAddressArg
822
+ obligationId: SuiObjectArg
823
823
  ) => {
824
824
  const packageId = address.get('core.packages.query.id');
825
825
  const queryTarget = `${packageId}::obligation_query::obligation_data`;
@@ -1,4 +1,4 @@
1
- import { SuiObjectData } from '@mysten/sui.js/client';
1
+ import { SuiObjectData } from '@mysten/sui/src/client';
2
2
  import BigNumber from 'bignumber.js';
3
3
  import { ScallopQuery } from 'src/models';
4
4
  import { LoyaltyProgramInfo } from 'src/types';
@@ -1,4 +1,4 @@
1
- import { SuiObjectData } from '@mysten/sui.js/client';
1
+ import { SuiObjectData } from '@mysten/sui/client';
2
2
  import type { ScallopAddress } from '../models';
3
3
  import type { SupportAssetCoins } from '../types';
4
4
 
@@ -1,4 +1,4 @@
1
- import { bcs } from '@mysten/sui.js/bcs';
1
+ import { bcs } from '@mysten/sui/bcs';
2
2
  import assert from 'assert';
3
3
  import BigNumber from 'bignumber.js';
4
4
  import { SUPPORT_SCOIN } from 'src/constants';
@@ -38,7 +38,7 @@ export const getSCoinTotalSupply = async (
38
38
  const type = results[0].returnValues[0][1]; // should be u64
39
39
  assert(type === 'u64', 'Result type is not u64');
40
40
 
41
- return BigNumber(bcs.de(type, value))
41
+ return BigNumber(bcs.u64().parse(value))
42
42
  .shiftedBy(utils.getCoinDecimal(utils.parseCoinName(sCoinName)))
43
43
  .toNumber();
44
44
  }
@@ -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,