@scallop-io/sui-scallop-sdk 2.0.13-merge-split-ve-sca-alpha.5 → 2.1.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 (55) hide show
  1. package/dist/index.d.mts +622 -697
  2. package/dist/index.d.ts +622 -697
  3. package/dist/index.js +32 -33
  4. package/dist/index.mjs +10 -10
  5. package/package.json +8 -18
  6. package/src/builders/borrowIncentiveBuilder.ts +9 -21
  7. package/src/builders/coreBuilder.ts +2 -2
  8. package/src/builders/index.ts +2 -2
  9. package/src/builders/oracles/index.ts +2 -3
  10. package/src/builders/oracles/pyth.ts +2 -2
  11. package/src/builders/spoolBuilder.ts +2 -2
  12. package/src/builders/vescaBuilder.ts +14 -132
  13. package/src/constants/queryKeys.ts +29 -54
  14. package/src/constants/testAddress.ts +6 -12
  15. package/src/index.ts +11 -1
  16. package/src/models/index.ts +11 -9
  17. package/src/models/interface.ts +36 -0
  18. package/src/models/scallop.ts +38 -133
  19. package/src/models/scallopAddress.ts +127 -142
  20. package/src/models/scallopAxios.ts +185 -0
  21. package/src/models/scallopBuilder.ts +45 -75
  22. package/src/models/scallopClient.ts +124 -154
  23. package/src/models/scallopConstants.ts +248 -323
  24. package/src/models/scallopIndexer.ts +54 -98
  25. package/src/models/scallopQuery.ts +145 -190
  26. package/src/models/scallopQueryClient.ts +29 -0
  27. package/src/models/scallopSuiKit.ts +432 -0
  28. package/src/models/scallopUtils.ts +260 -164
  29. package/src/queries/borrowIncentiveQuery.ts +28 -16
  30. package/src/queries/borrowLimitQuery.ts +1 -1
  31. package/src/queries/coreQuery.ts +148 -107
  32. package/src/queries/flashloanFeeQuery.ts +12 -6
  33. package/src/queries/index.ts +0 -1
  34. package/src/queries/isolatedAssetQuery.ts +3 -3
  35. package/src/queries/loyaltyProgramQuery.ts +10 -8
  36. package/src/queries/ownerQuery.ts +32 -0
  37. package/src/queries/portfolioQuery.ts +4 -5
  38. package/src/queries/priceQuery.ts +14 -8
  39. package/src/queries/referralQuery.ts +9 -3
  40. package/src/queries/sCoinQuery.ts +4 -4
  41. package/src/queries/spoolQuery.ts +11 -11
  42. package/src/queries/supplyLimitQuery.ts +1 -1
  43. package/src/queries/switchboardQuery.ts +1 -1
  44. package/src/queries/vescaQuery.ts +31 -27
  45. package/src/queries/xOracleQuery.ts +13 -8
  46. package/src/types/address.ts +0 -3
  47. package/src/types/builder/core.ts +1 -1
  48. package/src/types/builder/vesca.ts +10 -20
  49. package/src/types/constant/queryKeys.ts +48 -0
  50. package/src/types/index.ts +0 -1
  51. package/src/utils/builder.ts +1 -1
  52. package/src/utils/util.ts +1 -33
  53. package/src/models/scallopCache.ts +0 -428
  54. package/src/queries/objectsQuery.ts +0 -18
  55. package/src/types/model.ts +0 -117
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scallop-io/sui-scallop-sdk",
3
- "version": "2.0.13-merge-split-ve-sca-alpha.5",
3
+ "version": "2.1.0-alpha.1",
4
4
  "description": "Typescript sdk for interacting with Scallop contract on SUI",
5
5
  "keywords": [
6
6
  "sui",
@@ -38,29 +38,20 @@
38
38
  "src"
39
39
  ],
40
40
  "dependencies": {
41
- "@graphql-typed-document-node/core": "3.2.0",
42
- "@mysten/sui": "1.3.1",
43
- "@noble/curves": "^1.2.0",
44
- "@noble/hashes": "^1.3.2",
45
- "@pythnetwork/price-service-client": "^1.8.2",
41
+ "@mysten/sui": "1.28.2",
46
42
  "@pythnetwork/pyth-sui-js": "2.1.0",
47
- "@scallop-io/sui-kit": "1.3.5",
48
- "@scure/bip39": "^1.2.1",
43
+ "@scallop-io/sui-kit": "1.4.0-alpha.3",
49
44
  "@tanstack/query-core": "5.51.15",
50
- "axios": "^1.6.0",
51
- "bech32": "^2.0.0",
45
+ "axios": "^1.9.0",
52
46
  "bignumber.js": "^9.1.2",
53
- "gql.tada": "^1.8.10",
54
- "graphql": "^16.9.0",
55
- "superstruct": "^1.0.3",
56
- "tweetnacl": "^1.0.3",
57
- "valibot": "^0.36.0",
58
47
  "zod": "^3.23.8"
59
48
  },
60
49
  "devDependencies": {
61
50
  "@commitlint/cli": "^18.2.0",
62
51
  "@commitlint/config-conventional": "^18.1.0",
63
52
  "@commitlint/prompt-cli": "^18.2.0",
53
+ "@pythnetwork/price-service-client": "^1.9.0",
54
+ "@pythnetwork/price-service-sdk": "^1.8.0",
64
55
  "@types/node": "^20.4.2",
65
56
  "@typescript-eslint/eslint-plugin": "^8.11.0",
66
57
  "@typescript-eslint/parser": "8.10.0",
@@ -83,9 +74,8 @@
83
74
  "vitest": "^3.1.1"
84
75
  },
85
76
  "peerDependencies": {
86
- "@mysten/bcs": "^1.2.0",
87
- "@mysten/sui": "1.3.1",
88
- "@scallop-io/sui-kit": "1.3.5",
77
+ "@mysten/sui": "1.28.2",
78
+ "@scallop-io/sui-kit": "1.4.0-alpha.3",
89
79
  "bn.js": "^5.2.1"
90
80
  },
91
81
  "lint-staged": {
@@ -3,8 +3,8 @@ import {
3
3
  SuiTxBlock as SuiKitTxBlock,
4
4
  SUI_CLOCK_OBJECT_ID,
5
5
  } from '@scallop-io/sui-kit';
6
- import { getObligations, getObligationLocked } from 'src/queries';
7
- import { requireSender } from 'src/utils';
6
+ import { getObligations, getObligationLocked } from '../queries';
7
+ import { requireSender } from '../utils';
8
8
  import type { SuiObjectArg } from '@scallop-io/sui-kit';
9
9
  import type { ScallopBuilder } from 'src/models';
10
10
  import type {
@@ -14,7 +14,8 @@ import type {
14
14
  SuiTxBlockWithBorrowIncentiveNormalMethods,
15
15
  BorrowIncentiveTxBlock,
16
16
  ScallopTxBlock,
17
- } from 'src/types';
17
+ VescaIds,
18
+ } from '../types';
18
19
  import { OLD_BORROW_INCENTIVE_PROTOCOL_ID } from 'src/constants';
19
20
 
20
21
  /**
@@ -46,10 +47,7 @@ const requireObligationInfo = async (
46
47
  obligationKey &&
47
48
  typeof obligationId === 'string'
48
49
  ) {
49
- const obligationLocked = await getObligationLocked(
50
- builder.cache,
51
- obligationId
52
- );
50
+ const obligationLocked = await getObligationLocked(builder, obligationId);
53
51
  return { obligationId, obligationKey, obligationLocked };
54
52
  }
55
53
  const sender = requireSender(txBlock);
@@ -91,7 +89,7 @@ const generateBorrowIncentiveNormalMethod: GenerateBorrowIncentiveNormalMethod =
91
89
  obligationAccessStore: builder.address.get('core.obligationAccessStore'),
92
90
  };
93
91
 
94
- const veScaIds = {
92
+ const veScaIds: Omit<VescaIds, 'pkgId'> = {
95
93
  table: builder.address.get('vesca.table'),
96
94
  treasury: builder.address.get('vesca.treasury'),
97
95
  config: builder.address.get('vesca.config'),
@@ -122,7 +120,7 @@ const generateBorrowIncentiveNormalMethod: GenerateBorrowIncentiveNormalMethod =
122
120
  stakeObligationWithVesca: (obligationId, obligationKey, veScaKey) => {
123
121
  builder.moveCall(
124
122
  txBlock,
125
- `${borrowIncentiveIds.borrowIncentivePkg}::user::stake_with_ve_sca_v2`,
123
+ `${borrowIncentiveIds.borrowIncentivePkg}::user::stake_with_ve_sca`,
126
124
  [
127
125
  borrowIncentiveIds.config,
128
126
  borrowIncentiveIds.incentivePools,
@@ -134,8 +132,6 @@ const generateBorrowIncentiveNormalMethod: GenerateBorrowIncentiveNormalMethod =
134
132
  veScaIds.treasury,
135
133
  veScaIds.table,
136
134
  veScaKey,
137
- builder.address.get('vesca.subsTable'),
138
- builder.address.get('vesca.subsWhitelist'),
139
135
  clockObjectRef,
140
136
  ],
141
137
  []
@@ -144,15 +140,13 @@ const generateBorrowIncentiveNormalMethod: GenerateBorrowIncentiveNormalMethod =
144
140
  unstakeObligation: (obligationId, obligationKey) => {
145
141
  builder.moveCall(
146
142
  txBlock,
147
- `${borrowIncentiveIds.borrowIncentivePkg}::user::unstake_v2`,
143
+ `${borrowIncentiveIds.borrowIncentivePkg}::user::unstake`,
148
144
  [
149
145
  borrowIncentiveIds.config,
150
146
  borrowIncentiveIds.incentivePools,
151
147
  borrowIncentiveIds.incentiveAccounts,
152
148
  obligationKey,
153
149
  obligationId,
154
- builder.address.get('vesca.subsTable'),
155
- builder.address.get('vesca.subsWhitelist'),
156
150
  clockObjectRef,
157
151
  ]
158
152
  );
@@ -176,15 +170,13 @@ const generateBorrowIncentiveNormalMethod: GenerateBorrowIncentiveNormalMethod =
176
170
  deactivateBoost: (obligation, veScaKey) => {
177
171
  builder.moveCall(
178
172
  txBlock,
179
- `${borrowIncentiveIds.borrowIncentivePkg}::user::deactivate_boost_v2`,
173
+ `${borrowIncentiveIds.borrowIncentivePkg}::user::deactivate_boost`,
180
174
  [
181
175
  borrowIncentiveIds.config,
182
176
  borrowIncentiveIds.incentivePools,
183
177
  borrowIncentiveIds.incentiveAccounts,
184
178
  obligation,
185
179
  veScaKey,
186
- builder.address.get('vesca.subsTable'),
187
- builder.address.get('vesca.subsWhitelist'),
188
180
  clockObjectRef,
189
181
  ]
190
182
  );
@@ -225,8 +217,6 @@ const generateBorrowIncentiveQuickMethod: GenerateBorrowIncentiveQuickMethod =
225
217
  txn.kind === 'MoveCall' &&
226
218
  (txn.target ===
227
219
  `${OLD_BORROW_INCENTIVE_PROTOCOL_ID}::user::unstake` ||
228
- txn.target ===
229
- `${builder.address.get('borrowIncentive.id')}::user::unstake_v2` ||
230
220
  txn.target ===
231
221
  `${builder.address.get('borrowIncentive.id')}::user::unstake`)
232
222
  );
@@ -257,8 +247,6 @@ const generateBorrowIncentiveQuickMethod: GenerateBorrowIncentiveQuickMethod =
257
247
  txn.kind === 'MoveCall' &&
258
248
  (txn.target ===
259
249
  `${OLD_BORROW_INCENTIVE_PROTOCOL_ID}::user::unstake` ||
260
- txn.target ===
261
- `${builder.address.get('borrowIncentive.id')}::user::unstake_v2` ||
262
250
  txn.target ===
263
251
  `${builder.address.get('borrowIncentive.id')}::user::unstake`)
264
252
  );
@@ -5,7 +5,7 @@ import { getObligations } from '../queries';
5
5
  import { updateOracles } from './oracles';
6
6
  import { requireSender } from '../utils';
7
7
  import type { SuiObjectArg, TransactionResult } from '@scallop-io/sui-kit';
8
- import type { ScallopBuilder } from 'src/models';
8
+ import type { ScallopBuilder } from '../models';
9
9
  import type {
10
10
  CoreIds,
11
11
  GenerateCoreNormalMethod,
@@ -15,7 +15,7 @@ import type {
15
15
  ScallopTxBlock,
16
16
  NestedResult,
17
17
  SuiTxBlockWithSpool,
18
- } from 'src/types';
18
+ } from '../types';
19
19
 
20
20
  /**
21
21
  * Check and get Obligation information from transaction block.
@@ -4,8 +4,8 @@ import { newCoreTxBlock } from './coreBuilder';
4
4
  import { newSpoolTxBlock } from './spoolBuilder';
5
5
  import { newBorrowIncentiveTxBlock } from './borrowIncentiveBuilder';
6
6
  import { newVeScaTxBlock } from './vescaBuilder';
7
- import type { ScallopBuilder } from 'src/models';
8
- import type { ScallopTxBlock } from 'src/types';
7
+ import type { ScallopBuilder } from '../models';
8
+ import type { ScallopTxBlock } from '../types';
9
9
  import { newReferralTxBlock } from './referralBuilder';
10
10
  import { newLoyaltyProgramTxBlock } from './loyaltyProgramBuilder';
11
11
  import { newSCoinTxBlock } from './sCoinBuilder';
@@ -27,10 +27,9 @@ export const updateOracles = async (
27
27
  useOnChainXOracleList: boolean;
28
28
  } = { usePythPullModel: true, useOnChainXOracleList: true }
29
29
  ) => {
30
- const usePythPullModel =
31
- builder.params.usePythPullModel ?? options.usePythPullModel;
30
+ const usePythPullModel = builder.usePythPullModel ?? options.usePythPullModel;
32
31
  const useOnChainXOracleList =
33
- builder.params.useOnChainXOracleList ?? options.useOnChainXOracleList;
32
+ builder.useOnChainXOracleList ?? options.useOnChainXOracleList;
34
33
 
35
34
  const xOracleList = useOnChainXOracleList
36
35
  ? await builder.query.getAssetOracles()
@@ -11,7 +11,7 @@ export const updatePythPriceFeeds = async (
11
11
  txBlock: SuiKitTxBlock
12
12
  ) => {
13
13
  const pythClient = new SuiPythClient(
14
- builder.suiKit.client(),
14
+ builder.suiKit.client,
15
15
  builder.address.get('core.oracles.pyth.state'),
16
16
  builder.address.get('core.oracles.pyth.wormholeState')
17
17
  );
@@ -20,7 +20,7 @@ export const updatePythPriceFeeds = async (
20
20
  );
21
21
 
22
22
  // iterate through the endpoints
23
- const endpoints = builder.params.pythEndpoints ?? [
23
+ const endpoints = builder.utils.pythEndpoints ?? [
24
24
  ...builder.constants.whitelist.pythEndpoints,
25
25
  ];
26
26
  for (const endpoint of endpoints) {
@@ -5,7 +5,7 @@ import { getStakeAccounts } from '../queries/spoolQuery';
5
5
  import { requireSender } from '../utils';
6
6
  import type { SuiAddressArg } from '@scallop-io/sui-kit';
7
7
  import type { TransactionResult } from '@mysten/sui/transactions';
8
- import type { ScallopBuilder } from 'src/models';
8
+ import type { ScallopBuilder } from '../models';
9
9
  import type {
10
10
  SpoolIds,
11
11
  GenerateSpoolNormalMethod,
@@ -14,7 +14,7 @@ import type {
14
14
  SpoolTxBlock,
15
15
  ScallopTxBlock,
16
16
  SuiTxBlockWithSCoin,
17
- } from 'src/types';
17
+ } from '../types';
18
18
 
19
19
  /**
20
20
  * Check and get stake account id from transaction block.
@@ -5,8 +5,8 @@ import {
5
5
  SuiTxBlock as SuiKitTxBlock,
6
6
  } from '@scallop-io/sui-kit';
7
7
  import { SCA_COIN_TYPE } from 'src/constants';
8
- import { ScallopBuilder } from 'src/models';
9
- import { getVeSca, getVeScas } from 'src/queries';
8
+ import { ScallopBuilder } from '../models';
9
+ import { getVeSca, getVeScas } from '../queries';
10
10
  import {
11
11
  requireSender,
12
12
  checkLockSca,
@@ -14,19 +14,19 @@ import {
14
14
  checkExtendLockAmount,
15
15
  checkRenewExpiredVeSca,
16
16
  checkVesca,
17
- } from 'src/utils';
17
+ } from '../utils';
18
18
  import type {
19
19
  TransactionObjectArgument,
20
20
  SuiObjectArg,
21
21
  } from '@scallop-io/sui-kit';
22
22
  import type {
23
- AddressesInterface,
24
23
  GenerateVeScaNormalMethod,
25
24
  GenerateVeScaQuickMethod,
26
- QuickMethodReturnType,
25
+ RedeemScaQuickReturnType,
27
26
  ScallopTxBlock,
28
27
  SuiTxBlockWithVeScaNormalMethods,
29
28
  VeScaTxBlock,
29
+ VescaIds,
30
30
  } from 'src/types';
31
31
 
32
32
  /**
@@ -70,27 +70,6 @@ export const requireVeSca = async (
70
70
  return veScaKey ? veScas.find(({ keyId }) => veScaKey === keyId) : veScas[0];
71
71
  };
72
72
 
73
- export const isInSubsTable = async (
74
- ...params: [builder: ScallopBuilder, veScaKey: string, tableId: string]
75
- ) => {
76
- const [builder, veScaKey, tableId] = params;
77
- try {
78
- const resp = await builder.cache.queryGetDynamicFieldObject({
79
- parentId: tableId,
80
- name: {
81
- type: '0x2::object::ID',
82
- value: veScaKey,
83
- },
84
- });
85
- return !!resp?.data;
86
- } catch (e) {
87
- console.error(e);
88
- return false;
89
- }
90
- };
91
-
92
- type VeScaProps = 'id' | 'table' | 'treasury' | 'config' | 'subsTable';
93
-
94
73
  /**
95
74
  * Generate veSCA normal methods.
96
75
  *
@@ -102,14 +81,12 @@ const generateNormalVeScaMethod: GenerateVeScaNormalMethod = ({
102
81
  builder,
103
82
  txBlock,
104
83
  }) => {
105
- const veScaIds: Pick<AddressesInterface['vesca'], VeScaProps> = {
106
- id: builder.address.get('vesca.id'),
84
+ const veScaIds: VescaIds = {
85
+ pkgId: builder.address.get('vesca.id'),
107
86
  table: builder.address.get('vesca.table'),
108
87
  treasury: builder.address.get('vesca.treasury'),
109
88
  config: builder.address.get('vesca.config'),
110
- subsTable: builder.address.get('vesca.subsTable'),
111
89
  };
112
-
113
90
  const clockObjectRef = txBlock.sharedObjectRef({
114
91
  objectId: SUI_CLOCK_OBJECT_ID,
115
92
  mutable: false,
@@ -120,7 +97,7 @@ const generateNormalVeScaMethod: GenerateVeScaNormalMethod = ({
120
97
  lockSca: (scaCoin, unlockAtInSecondTimestamp) => {
121
98
  return builder.moveCall(
122
99
  txBlock,
123
- `${veScaIds.id}::ve_sca::mint_ve_sca_key`,
100
+ `${veScaIds.pkgId}::ve_sca::mint_ve_sca_key`,
124
101
  [
125
102
  veScaIds.config,
126
103
  veScaIds.table,
@@ -135,7 +112,7 @@ const generateNormalVeScaMethod: GenerateVeScaNormalMethod = ({
135
112
  extendLockPeriod: (veScaKey, newUnlockAtInSecondTimestamp) => {
136
113
  builder.moveCall(
137
114
  txBlock,
138
- `${veScaIds.id}::ve_sca::extend_lock_period`,
115
+ `${veScaIds.pkgId}::ve_sca::extend_lock_period`,
139
116
  [
140
117
  veScaIds.config,
141
118
  veScaKey,
@@ -150,7 +127,7 @@ const generateNormalVeScaMethod: GenerateVeScaNormalMethod = ({
150
127
  extendLockAmount: (veScaKey, scaCoin) => {
151
128
  builder.moveCall(
152
129
  txBlock,
153
- `${veScaIds.id}::ve_sca::lock_more_sca`,
130
+ `${veScaIds.pkgId}::ve_sca::lock_more_sca`,
154
131
  [
155
132
  veScaIds.config,
156
133
  veScaKey,
@@ -165,7 +142,7 @@ const generateNormalVeScaMethod: GenerateVeScaNormalMethod = ({
165
142
  renewExpiredVeSca: (veScaKey, scaCoin, newUnlockAtInSecondTimestamp) => {
166
143
  builder.moveCall(
167
144
  txBlock,
168
- `${veScaIds.id}::ve_sca::renew_expired_ve_sca`,
145
+ `${veScaIds.pkgId}::ve_sca::renew_expired_ve_sca`,
169
146
  [
170
147
  veScaIds.config,
171
148
  veScaKey,
@@ -181,7 +158,7 @@ const generateNormalVeScaMethod: GenerateVeScaNormalMethod = ({
181
158
  redeemSca: (veScaKey) => {
182
159
  return builder.moveCall(
183
160
  txBlock,
184
- `${veScaIds.id}::ve_sca::redeem`,
161
+ `${veScaIds.pkgId}::ve_sca::redeem`,
185
162
  [
186
163
  veScaIds.config,
187
164
  veScaKey,
@@ -195,39 +172,11 @@ const generateNormalVeScaMethod: GenerateVeScaNormalMethod = ({
195
172
  mintEmptyVeSca: () => {
196
173
  return builder.moveCall(
197
174
  txBlock,
198
- `${veScaIds.id}::ve_sca::mint_ve_sca_placeholder_key`,
175
+ `${veScaIds.pkgId}::ve_sca::mint_ve_sca_placeholder_key`,
199
176
  [veScaIds.config, veScaIds.table],
200
177
  []
201
178
  );
202
179
  },
203
- splitVeSca: (veScaKey, splitAmount) => {
204
- return builder.moveCall(txBlock, `${veScaIds.id}::ve_sca::split`, [
205
- veScaIds.config,
206
- veScaKey,
207
- veScaIds.table,
208
- veScaIds.subsTable,
209
- txBlock.pure.u64(splitAmount),
210
- ]);
211
- },
212
- mergeVeSca: (targetKey, sourceKey) => {
213
- return builder.moveCall(
214
- txBlock,
215
- `${veScaIds.id}::ve_sca::merge`,
216
- [
217
- veScaIds.config,
218
- targetKey,
219
- sourceKey,
220
- veScaIds.table,
221
- veScaIds.subsTable,
222
- txBlock.sharedObjectRef({
223
- objectId: SUI_CLOCK_OBJECT_ID,
224
- mutable: false,
225
- initialSharedVersion: '1',
226
- }),
227
- ],
228
- []
229
- );
230
- },
231
180
  };
232
181
  };
233
182
 
@@ -413,75 +362,8 @@ const generateQuickVeScaMethod: GenerateVeScaQuickMethod = ({
413
362
  txBlock.transferObjects([sca], sender);
414
363
  return;
415
364
  }
416
- return sca as QuickMethodReturnType<S>;
417
- }
418
- },
419
- splitVeScaQuick: async <S extends boolean>(
420
- splitAmount: string,
421
- veScaKey: string,
422
- transferVeScaKey: S = true as S
423
- ) => {
424
- const isKeyInSubTable = await isInSubsTable(
425
- builder,
426
- veScaKey,
427
- builder.address.get('vesca.subsTable')
428
- );
429
-
430
- const unstakeObligationBeforeStake =
431
- !!txBlock.txBlock.blockData.transactions.find(
432
- (txn) =>
433
- txn.kind === 'MoveCall' &&
434
- txn.target ===
435
- `${builder.address.get('borrowIncentive.id')}::user::unstake_v2`
436
- );
437
-
438
- if (isKeyInSubTable && !unstakeObligationBeforeStake) {
439
- throw new Error(
440
- 'Key cannot be in the subs table, please call unsubscribe vesca or unstake obligation first'
441
- );
365
+ return sca as RedeemScaQuickReturnType<S>;
442
366
  }
443
-
444
- const newVeScaKey = txBlock.splitVeSca(veScaKey, splitAmount);
445
- if (transferVeScaKey) {
446
- txBlock.transferObjects([newVeScaKey], requireSender(txBlock));
447
- return;
448
- } else {
449
- return newVeScaKey as QuickMethodReturnType<S>;
450
- }
451
- },
452
- mergeVeScaQuick: async (targetKey: string, sourceKey: string) => {
453
- // check targetKey and sourceKey
454
- const [isTargetInSubTable, isSourceInSubTable] = await Promise.all([
455
- isInSubsTable(
456
- builder,
457
- targetKey,
458
- builder.address.get('vesca.subsTableId')
459
- ),
460
- isInSubsTable(
461
- builder,
462
- sourceKey,
463
- builder.address.get('vesca.subsTableId')
464
- ),
465
- ]);
466
-
467
- const unstakeObligationBeforeStake =
468
- !!txBlock.txBlock.blockData.transactions.find(
469
- (txn) =>
470
- txn.kind === 'MoveCall' &&
471
- txn.target ===
472
- `${builder.address.get('borrowIncentive.id')}::user::unstake_v2`
473
- );
474
-
475
- if (
476
- (isTargetInSubTable || isSourceInSubTable) &&
477
- !unstakeObligationBeforeStake
478
- ) {
479
- throw new Error(
480
- 'Both target and source cannot be in the subs table. Please call unsubscribe vesca or unstake obligation first'
481
- );
482
- }
483
-
484
- return txBlock.mergeVeSca(targetKey, sourceKey);
485
367
  },
486
368
  };
487
369
  };
@@ -1,18 +1,11 @@
1
- import type {
2
- GetDynamicFieldObjectParams,
3
- GetDynamicFieldsParams,
4
- GetOwnedObjectsParams,
5
- SuiObjectData,
6
- SuiObjectDataOptions,
7
- } from '@mysten/sui/client';
8
- import type { SuiObjectArg, SuiTxArg } from '@scallop-io/sui-kit';
1
+ import { QueryKeys } from 'src/types/constant/queryKeys';
9
2
 
10
3
  export const queryKeys = {
11
4
  api: {
12
- getAddresses: (addressId?: string) => [
5
+ getAddresses: (props?: QueryKeys.API.GetAddresses) => [
13
6
  'api',
14
7
  'getAddresses',
15
- { addressId },
8
+ props,
16
9
  ],
17
10
  getWhiteList: () => ['api', 'getWhiteList'],
18
11
  getPoolAddresses: () => ['api', 'getPoolAddresses'],
@@ -23,79 +16,61 @@ export const queryKeys = {
23
16
  },
24
17
 
25
18
  rpc: {
26
- getInspectTxn: (
27
- queryTarget?: string,
28
- args?: SuiObjectArg[],
29
- typeArgs?: any[]
30
- ) => [
19
+ getInspectTxn: (props?: QueryKeys.RPC.GetInspectTxn) => [
31
20
  'rpc',
32
21
  'getInspectTxn',
33
- {
34
- queryTarget,
35
- args: JSON.stringify(args),
36
- typeArgs: !typeArgs ? undefined : JSON.stringify(typeArgs),
37
- },
22
+ props,
38
23
  ],
39
- getObject: (objectId?: string, options?: SuiObjectDataOptions) => [
40
- 'rpc',
41
- 'getObject',
42
- { objectId, options },
43
- ],
44
- getObjects: (objectIds?: string[]) => [
24
+ getObject: (props?: QueryKeys.RPC.GetObject) => ['rpc', 'getObject', props],
25
+ getObjects: (props?: QueryKeys.RPC.GetObjects) => [
45
26
  'rpc',
46
27
  'getObjects',
47
- {
48
- objectIds: JSON.stringify(objectIds ?? undefined),
49
- },
28
+ props,
50
29
  ],
51
- getOwnedObjects: (input?: Partial<GetOwnedObjectsParams>) => [
30
+ getOwnedObjects: (props?: QueryKeys.RPC.GetOwnedObjects) => [
52
31
  'rpc',
53
32
  'getOwnedObjects',
54
33
  {
55
- walletAddress: input?.owner,
56
- cursor: input?.cursor ?? undefined,
57
- options: input?.options ?? undefined,
58
- filter: JSON.stringify(input?.filter ?? undefined),
59
- limit: input?.limit ?? undefined,
34
+ ...props,
35
+ filter: JSON.stringify(props?.filter ?? undefined),
60
36
  },
61
37
  ],
62
- getDynamicFields: (input?: Partial<GetDynamicFieldsParams>) => [
38
+ getDynamicFields: (props?: QueryKeys.RPC.GetDynamicFields) => [
63
39
  'rpc',
64
40
  'getDynamicFields',
65
- {
66
- parentId: input?.parentId,
67
- cursor: input?.cursor ?? undefined,
68
- limit: input?.limit ?? undefined,
69
- },
41
+ props,
70
42
  ],
71
- getDynamicFieldObject: (input?: Partial<GetDynamicFieldObjectParams>) => [
43
+ getDynamicFieldObject: (props?: QueryKeys.RPC.GetDynamicFieldObject) => [
72
44
  'rpc',
73
45
  'getDynamicFieldObject',
74
- {
75
- parentId: input?.parentId,
76
- name: JSON.stringify(input?.name ?? undefined),
77
- },
46
+ props,
78
47
  ],
79
48
  getTotalVeScaTreasuryAmount: (
80
- refreshArgs?: any[],
81
- vescaAmountArgs?: (string | SuiObjectData | SuiTxArg)[]
49
+ props?: QueryKeys.RPC.getTotalVeScaTreasuryAmount
82
50
  ) => [
83
51
  'rpc',
84
52
  'getTotalVeScaTreasuryAmount',
85
53
  {
86
- refreshArgs: JSON.stringify(refreshArgs),
87
- vescaAmountArgs: JSON.stringify(vescaAmountArgs),
54
+ ...props,
55
+ refreshArgs: props?.refreshArgs
56
+ ? JSON.stringify(props?.refreshArgs)
57
+ : undefined,
58
+ vescaAmountArgs: props?.vescaAmountArgs
59
+ ? JSON.stringify(props?.vescaAmountArgs)
60
+ : undefined,
88
61
  },
89
62
  ],
90
63
 
91
- getAllCoinBalances: (owner?: string) => [
64
+ getAllCoinBalances: (props?: QueryKeys.RPC.GetAllCoinBalances) => [
92
65
  'rpc',
93
66
  'getAllCoinBalances',
94
- { owner },
67
+ props,
95
68
  ],
96
69
 
97
- getNormalizedMoveFunction: (target?: string) => {
98
- return ['rpc', 'getNormalizedMoveCall', target];
70
+ getNormalizedMoveFunction: (
71
+ props?: QueryKeys.RPC.GetNormalizedMoveFunction
72
+ ) => {
73
+ return ['rpc', 'getNormalizedMoveCall', props];
99
74
  },
100
75
  },
101
76
  oracle: {
@@ -256,24 +256,18 @@ export const TEST_ADDRESSES: AddressesInterface = {
256
256
  '0x9636e7b947b806b9fe438d037f02bb24026c5b2691d2f6bad349c2e117f77cc3',
257
257
  },
258
258
  vesca: {
259
- id: '0x0c7f5568dbd69488437ee95f2d9a028724e1de12432965ff8acca7c67310ba46',
259
+ id: '0x1158813b32962c2d22888fae257d5f2365b03631f0cd5d5b912ccdf51ff4e2f2',
260
260
  object:
261
- '0x0c7f5568dbd69488437ee95f2d9a028724e1de12432965ff8acca7c67310ba46',
261
+ '0xcfe2d87aa5712b67cad2732edb6a2201bfdf592377e5c0968b7cb02099bd8e21',
262
262
  adminCap:
263
263
  '0x4d105b16467acca81d18c132cdd1a3cee159920a86c1ef4bdbf2e8d7878500c5',
264
264
  tableId:
265
- '0x06f763060ea5da3d639fb56df70674490a8354511cfe61584062aafd83b1940d',
266
- table: '0x06f763060ea5da3d639fb56df70674490a8354511cfe61584062aafd83b1940d',
265
+ '0x0a0b7f749baeb61e3dfee2b42245e32d0e6b484063f0a536b33e771d573d7246',
266
+ table: '0xd3a4632b1080f7d96e1c2487d4dabf2c1196916937c505a69954ac9f393be8d0',
267
267
  treasury:
268
- '0x934919cc31fa89b67578039bb10d5518fa23c50bc8f78500f1d1a718407a0a71',
268
+ '0xafa4b6231e49c15a22d641ce33fda761baaf650fa21899dfa2eb1716146e7306',
269
269
  config:
270
- '0x38d3f7a1fa5071226535d4d8bfca8ccab3d24871402df1be669d7d5e9e3e9cb4',
271
- subsTable:
272
- '0x4756b716670ff62760b22bebed73c6eb2c2cb118674a2eea3a56ebea9e27ae76',
273
- subsTableId:
274
- '0x924b56d383b45445984a80002185b670aa2e72cd7df496d345f45f9407a12c07',
275
- subsWhitelist:
276
- '0xfc72adae643da4f2fe080adc1e2cca981eadcb518facb02324eeaab169752ffb',
270
+ '0x7cbcb0a342179577a117dfdff974cf1ab765d3b571067bf22ddf5f9e3a667922',
277
271
  },
278
272
  referral: {
279
273
  id: '0x1bf5a8ce77050d8052549d743e16b469f15aa6b81b752b78b6ebb65179665f5a',
package/src/index.ts CHANGED
@@ -1,3 +1,13 @@
1
1
  export * from './constants';
2
- export * from './models';
2
+ export {
3
+ Scallop,
4
+ ScallopConstants,
5
+ ScallopAddress,
6
+ ScallopBuilder,
7
+ ScallopQuery,
8
+ ScallopSuiKit,
9
+ ScallopClient,
10
+ ScallopIndexer,
11
+ ScallopUtils,
12
+ } from './models';
3
13
  export type * from './types';