@scallop-io/sui-scallop-sdk 2.0.13-merge-split-ve-sca-alpha.4 → 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 +8 -18
  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
@@ -36,7 +36,7 @@ export const getLoyaltyProgramInformations = async (
36
36
  const rewardPool = query.address.get('loyaltyProgram.rewardPool');
37
37
 
38
38
  // get fields from rewardPool object
39
- const rewardPoolObject = await query.cache.queryGetObject(rewardPool);
39
+ const rewardPoolObject = await query.scallopSuiKit.queryGetObject(rewardPool);
40
40
 
41
41
  if (rewardPoolObject?.data?.content?.dataType !== 'moveObject') return null;
42
42
  const rewardPoolFields = rewardPoolObject.data.content.fields;
@@ -58,13 +58,15 @@ export const getLoyaltyProgramInformations = async (
58
58
  'loyaltyProgram.userRewardTableId'
59
59
  );
60
60
 
61
- const userRewardObject = await query.cache.queryGetDynamicFieldObject({
62
- parentId: userRewardTableId,
63
- name: {
64
- type: '0x2::object::ID',
65
- value: typeof veScaKey === 'string' ? veScaKey : veScaKey.objectId,
66
- },
67
- });
61
+ const userRewardObject = await query.scallopSuiKit.queryGetDynamicFieldObject(
62
+ {
63
+ parentId: userRewardTableId,
64
+ name: {
65
+ type: '0x2::object::ID',
66
+ value: typeof veScaKey === 'string' ? veScaKey : veScaKey.objectId,
67
+ },
68
+ }
69
+ );
68
70
 
69
71
  if (userRewardObject?.data?.content?.dataType !== 'moveObject') return result;
70
72
  const userRewardFields = userRewardObject.data.content.fields;
@@ -0,0 +1,32 @@
1
+ // import { ObjectOwner, SuiObjectData } from '@mysten/sui/client';
2
+
3
+ // const parseOwnerAddress = (owner: ObjectOwner | null | undefined): string => {
4
+ // const notSupportedOwner =
5
+ // !owner ||
6
+ // typeof owner === 'string' ||
7
+ // (typeof owner === 'object' &&
8
+ // ('Shared' in owner || 'ConsensusV2' in owner));
9
+ // if (notSupportedOwner)
10
+ // throw new Error('Owner not supported (ConsensusV2 or Shared or Immutable)');
11
+
12
+ // if ('AddressOwner' in owner) {
13
+ // return owner.AddressOwner;
14
+ // } else {
15
+ // return owner.ObjectOwner;
16
+ // }
17
+ // };
18
+
19
+ // export const getObjectOwner = async (
20
+ // cache: ScallopCache,
21
+ // object: string | SuiObjectData
22
+ // ) => {
23
+ // if (typeof object === 'object') {
24
+ // return parseOwnerAddress(object.owner);
25
+ // }
26
+
27
+ // const objResponse = await cache.queryGetObject(object, {
28
+ // showOwner: true,
29
+ // });
30
+
31
+ // return parseOwnerAddress(objResponse.data?.owner);
32
+ // };
@@ -1,6 +1,6 @@
1
1
  import BigNumber from 'bignumber.js';
2
2
  import { minBigNumber, estimatedFactor } from 'src/utils';
3
- import type { ScallopQuery } from 'src/models';
3
+ import type { ScallopQuery } from '../models';
4
4
  import type {
5
5
  Market,
6
6
  MarketPool,
@@ -16,9 +16,8 @@ import type {
16
16
  ObligationBorrowIncentiveReward,
17
17
  MarketPools,
18
18
  MarketCollaterals,
19
- } from 'src/types';
19
+ } from '../types';
20
20
  import { SuiObjectRef } from '@mysten/sui/client';
21
- import { queryMultipleObjects } from './objectsQuery';
22
21
  import { normalizeStructTag, SUI_TYPE_ARG } from '@scallop-io/sui-kit';
23
22
 
24
23
  /**
@@ -67,6 +66,7 @@ export const getLendings = async (
67
66
  ]);
68
67
 
69
68
  const lendings: Lendings = {};
69
+
70
70
  await Promise.allSettled(
71
71
  poolCoinNames.map(async (poolCoinName) => {
72
72
  const stakeMarketCoinName = stakeMarketCoinNames.find(
@@ -317,8 +317,7 @@ export const getObligationAccounts = async (
317
317
  query.getObligations(ownerAddress),
318
318
  ]);
319
319
 
320
- const obligationObjects = await queryMultipleObjects(
321
- query.cache,
320
+ const obligationObjects = await query.scallopSuiKit.queryGetObjects(
322
321
  obligations.map((obligation) => obligation.id)
323
322
  );
324
323
  const obligationAccounts: ObligationAccounts = {};
@@ -1,8 +1,7 @@
1
1
  import { SuiObjectData } from '@mysten/sui/client';
2
- import type { ScallopAddress, ScallopQuery } from '../models';
2
+ import type { ScallopAddress, ScallopQuery, ScallopSuiKit } from 'src/models';
3
3
  import type { CoinPrices, MarketPools, OptionalKeys } from '../types';
4
4
  import BigNumber from 'bignumber.js';
5
- import { ScallopConstants } from 'src/models/scallopConstants';
6
5
 
7
6
  /**
8
7
  * Get price from pyth fee object.
@@ -14,8 +13,10 @@ import { ScallopConstants } from 'src/models/scallopConstants';
14
13
  export const getPythPrice = async (
15
14
  {
16
15
  address,
16
+ scallopSuiKit,
17
17
  }: {
18
18
  address: ScallopAddress;
19
+ scallopSuiKit: ScallopSuiKit;
19
20
  },
20
21
  assetCoinName: string,
21
22
  priceFeedObject?: SuiObjectData | null
@@ -25,7 +26,7 @@ export const getPythPrice = async (
25
26
  );
26
27
  priceFeedObject =
27
28
  priceFeedObject ||
28
- (await address.cache.queryGetObject(pythFeedObjectId))?.data;
29
+ (await scallopSuiKit.queryGetObject(pythFeedObjectId))?.data;
29
30
 
30
31
  if (priceFeedObject) {
31
32
  const priceFeedPoolObject = priceFeedObject;
@@ -64,15 +65,17 @@ export const getPythPrice = async (
64
65
 
65
66
  export const getPythPrices = async (
66
67
  {
67
- constants,
68
+ address,
69
+ scallopSuiKit,
68
70
  }: {
69
- constants: ScallopConstants;
71
+ address: ScallopAddress;
72
+ scallopSuiKit: ScallopSuiKit;
70
73
  },
71
74
  assetCoinNames: string[]
72
75
  ) => {
73
76
  const pythPriceFeedIds = assetCoinNames.reduce(
74
77
  (prev, assetCoinName) => {
75
- const pythPriceFeed = constants.address.get(
78
+ const pythPriceFeed = address.get(
76
79
  `core.coins.${assetCoinName}.oracle.pyth.feedObject`
77
80
  );
78
81
  if (pythPriceFeed) {
@@ -88,7 +91,7 @@ export const getPythPrices = async (
88
91
  );
89
92
 
90
93
  // Fetch multiple objects at once to save rpc calls
91
- const priceFeedObjects = await constants.address.cache.queryGetObjects(
94
+ const priceFeedObjects = await scallopSuiKit.queryGetObjects(
92
95
  Object.keys(pythPriceFeedIds)
93
96
  );
94
97
 
@@ -108,7 +111,10 @@ export const getPythPrices = async (
108
111
  async ([assetCoinName, priceFeedObject]) => ({
109
112
  coinName: assetCoinName,
110
113
  price: await getPythPrice(
111
- constants,
114
+ {
115
+ address,
116
+ scallopSuiKit,
117
+ },
112
118
  assetCoinName as string,
113
119
  priceFeedObject
114
120
  ),
@@ -1,4 +1,4 @@
1
- import { ScallopAddress } from 'src/models';
1
+ import type { ScallopAddress, ScallopSuiKit } from 'src/models';
2
2
 
3
3
  /**
4
4
  * Query the veScaKeyId from the referral bindings table using the borrower address
@@ -6,11 +6,17 @@ import { ScallopAddress } from 'src/models';
6
6
  * @returns
7
7
  */
8
8
  export const queryVeScaKeyIdFromReferralBindings = async (
9
- address: ScallopAddress,
9
+ {
10
+ address,
11
+ scallopSuiKit,
12
+ }: {
13
+ address: ScallopAddress;
14
+ scallopSuiKit: ScallopSuiKit;
15
+ },
10
16
  refereeAddress: string
11
17
  ): Promise<string | null> => {
12
18
  const referralBindingTableId = address.get('referral.bindingTableId');
13
- const referralBindResponse = await address.cache.queryGetDynamicFieldObject({
19
+ const referralBindResponse = await scallopSuiKit.queryGetDynamicFieldObject({
14
20
  parentId: referralBindingTableId,
15
21
  name: {
16
22
  type: 'address',
@@ -26,7 +26,7 @@ export const getSCoinTotalSupply = async (
26
26
  utils.parseUnderlyingSCoinType(sCoinName),
27
27
  ];
28
28
  const queryTarget = `${sCoinPkgId}::s_coin_converter::total_supply`;
29
- const queryResults = await utils.cache.queryInspectTxn({
29
+ const queryResults = await utils.scallopSuiKit.queryInspectTxn({
30
30
  queryTarget,
31
31
  args,
32
32
  typeArgs,
@@ -62,7 +62,7 @@ export const getSCoinAmounts = async (
62
62
  sCoinNames: string[] = [...utils.constants.whitelist.scoin],
63
63
  ownerAddress?: string
64
64
  ) => {
65
- const owner = ownerAddress || utils.suiKit.currentAddress();
65
+ const owner = ownerAddress || utils.suiKit.currentAddress;
66
66
  const sCoins = {} as OptionalKeys<Record<string, number>>;
67
67
 
68
68
  await Promise.allSettled(
@@ -92,9 +92,9 @@ export const getSCoinAmount = async (
92
92
  sCoinName: string,
93
93
  ownerAddress?: string
94
94
  ) => {
95
- const owner = ownerAddress || utils.suiKit.currentAddress();
95
+ const owner = ownerAddress || utils.suiKit.currentAddress;
96
96
  const sCoinType = utils.parseSCoinType(sCoinName);
97
- const coinBalance = await utils.cache.queryGetCoinBalance({
97
+ const coinBalance = await utils.scallopSuiKit.queryGetCoinBalance({
98
98
  owner,
99
99
  coinType: sCoinType,
100
100
  });
@@ -5,9 +5,9 @@ import {
5
5
  parseOriginSpoolRewardPoolData,
6
6
  calculateSpoolRewardPoolData,
7
7
  parseObjectAs,
8
- } from 'src/utils';
8
+ } from '../utils';
9
9
  import type { SuiObjectData, SuiObjectResponse } from '@mysten/sui/client';
10
- import type { ScallopQuery, ScallopUtils } from 'src/models';
10
+ import type { ScallopQuery, ScallopUtils } from '../models';
11
11
  import type {
12
12
  Spools,
13
13
  Spool,
@@ -19,8 +19,7 @@ import type {
19
19
  OriginSpoolRewardPoolData,
20
20
  SpoolData,
21
21
  OriginSpoolData,
22
- } from 'src/types';
23
- import { queryMultipleObjects } from './objectsQuery';
22
+ } from '../types';
24
23
 
25
24
  const queryRequiredSpoolObjects = async (
26
25
  query: ScallopQuery,
@@ -63,9 +62,9 @@ const queryRequiredSpoolObjects = async (
63
62
  // Phase 2: Parallel queries with pre-collected keys
64
63
  const [spoolObjects, spoolRewardObjects, sCoinTreasuryObjects] =
65
64
  await Promise.all([
66
- queryMultipleObjects(query.cache, keyCollections.spool),
67
- queryMultipleObjects(query.cache, keyCollections.spoolReward),
68
- queryMultipleObjects(query.cache, keyCollections.sCoinTreasury),
65
+ query.scallopSuiKit.queryGetObjects(keyCollections.spool),
66
+ query.scallopSuiKit.queryGetObjects(keyCollections.spoolReward),
67
+ query.scallopSuiKit.queryGetObjects(keyCollections.sCoinTreasury),
69
68
  ]);
70
69
 
71
70
  // Phase 3: Create lookup maps
@@ -315,7 +314,7 @@ export const getStakeAccounts = async (
315
314
  },
316
315
  ownerAddress?: string
317
316
  ) => {
318
- const owner = ownerAddress || utils.suiKit.currentAddress();
317
+ const owner = ownerAddress || utils.suiKit.currentAddress;
319
318
  const spoolObjectId = utils.address.get('spool.object');
320
319
  const stakeAccountType = `${spoolObjectId}::spool_account::SpoolAccount`;
321
320
  const stakeObjectsResponse: SuiObjectResponse[] = [];
@@ -323,7 +322,7 @@ export const getStakeAccounts = async (
323
322
  let nextCursor: string | null | undefined = null;
324
323
  do {
325
324
  const paginatedStakeObjectsResponse =
326
- await utils.cache.queryGetOwnedObjects({
325
+ await utils.scallopSuiKit.queryGetOwnedObjects({
327
326
  owner,
328
327
  filter: { StructType: stakeAccountType },
329
328
  options: {
@@ -445,7 +444,8 @@ export const getStakePool = async (
445
444
  ) => {
446
445
  const poolId = utils.address.get(`spool.pools.${marketCoinName}.id`);
447
446
  let stakePool: StakePool | undefined = undefined;
448
- const stakePoolObjectResponse = await utils.cache.queryGetObject(poolId);
447
+ const stakePoolObjectResponse =
448
+ await utils.scallopSuiKit.queryGetObject(poolId);
449
449
  if (stakePoolObjectResponse?.data) {
450
450
  const stakePoolObject = stakePoolObjectResponse.data;
451
451
  const id = stakePoolObject.objectId;
@@ -505,7 +505,7 @@ export const getStakeRewardPool = async (
505
505
  );
506
506
  let stakeRewardPool: StakeRewardPool | undefined = undefined;
507
507
  const stakeRewardPoolObjectResponse =
508
- await utils.cache.queryGetObject(poolId);
508
+ await utils.scallopSuiKit.queryGetObject(poolId);
509
509
 
510
510
  if (stakeRewardPoolObjectResponse?.data) {
511
511
  const stakeRewardPoolObject = stakeRewardPoolObjectResponse.data;
@@ -30,7 +30,7 @@ export const getSupplyLimit = async (utils: ScallopUtils, poolName: string) => {
30
30
  const marketObject = utils.address.get('core.market');
31
31
  if (!marketObject) return null;
32
32
 
33
- const object = await utils.cache.queryGetDynamicFieldObject({
33
+ const object = await utils.scallopSuiKit.queryGetDynamicFieldObject({
34
34
  parentId: marketObject,
35
35
  name: {
36
36
  type: supplyLimitKeyType,
@@ -47,7 +47,7 @@ export const getOnDemandAggObjectIds = async (
47
47
  },
48
48
  };
49
49
 
50
- const resp = await query.cache.queryGetDynamicFieldObject({
50
+ const resp = await query.scallopSuiKit.queryGetDynamicFieldObject({
51
51
  parentId: switchboardRegistryTableId,
52
52
  name: dfName,
53
53
  });
@@ -1,11 +1,11 @@
1
1
  import BigNumber from 'bignumber.js';
2
- import { VeScaTreasuryFields, VeScaTreasuryInfo, Vesca } from 'src/types';
2
+ import { VeScaTreasuryFields, VeScaTreasuryInfo, Vesca } from '../types';
3
3
  import {
4
4
  type SuiObjectResponse,
5
5
  type SuiObjectData,
6
6
  DevInspectResults,
7
7
  } from '@mysten/sui/client';
8
- import type { ScallopUtils } from 'src/models';
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
11
  import { bcs } from '@mysten/sui/bcs';
@@ -23,21 +23,22 @@ export const getVescaKeys = async (
23
23
  utils: ScallopUtils,
24
24
  ownerAddress?: string
25
25
  ) => {
26
- const owner = ownerAddress || utils.suiKit.currentAddress();
26
+ const owner = ownerAddress || utils.suiKit.currentAddress;
27
27
  const veScaObjId = utils.address.get('vesca.object');
28
28
  const veScaKeyType = `${veScaObjId}::ve_sca::VeScaKey`;
29
29
  const keyObjectsResponse: SuiObjectResponse[] = [];
30
30
  let hasNextPage = false;
31
31
  let nextCursor: string | null | undefined = null;
32
32
  do {
33
- const paginatedKeyObjectsResponse = await utils.cache.queryGetOwnedObjects({
34
- owner,
35
- filter: {
36
- StructType: veScaKeyType,
37
- },
38
- cursor: nextCursor,
39
- limit: 10,
40
- });
33
+ const paginatedKeyObjectsResponse =
34
+ await utils.scallopSuiKit.queryGetOwnedObjects({
35
+ owner,
36
+ filter: {
37
+ StructType: veScaKeyType,
38
+ },
39
+ cursor: nextCursor,
40
+ limit: 10,
41
+ });
41
42
  if (!paginatedKeyObjectsResponse) continue;
42
43
 
43
44
  keyObjectsResponse.push(...paginatedKeyObjectsResponse.data);
@@ -125,7 +126,7 @@ export const getVeSca = async (
125
126
  let vesca: Vesca | undefined = undefined;
126
127
 
127
128
  const veScaDynamicFieldObjectResponse =
128
- await utils.cache.queryGetDynamicFieldObject({
129
+ await utils.scallopSuiKit.queryGetDynamicFieldObject({
129
130
  parentId: tableId,
130
131
  name: {
131
132
  type: '0x2::object::ID',
@@ -196,22 +197,22 @@ const getTotalVeScaTreasuryAmount = async (
196
197
 
197
198
  // query total veSca amount
198
199
  const veScaAmountQueryTarget = `${veScaPkgId}::treasury::total_ve_sca_amount`;
199
- const veScaAmountArgs = [veScaTreasury, clockObjectRef];
200
+ const vescaAmountArgs = [veScaTreasury, clockObjectRef];
200
201
 
201
202
  // resolve each args
202
203
  const resolvedRefreshArgs = await Promise.all(
203
204
  refreshArgs.map(async (arg) => {
204
205
  if (typeof arg === 'string') {
205
- return (await utils.cache.queryGetObject(arg))?.data;
206
+ return (await utils.scallopSuiKit.queryGetObject(arg))?.data;
206
207
  }
207
208
  return arg;
208
209
  })
209
210
  );
210
211
 
211
212
  const resolvedVeScaAmountArgs = await Promise.all(
212
- veScaAmountArgs.map(async (arg) => {
213
+ vescaAmountArgs.map(async (arg) => {
213
214
  if (typeof arg === 'string') {
214
- return (await utils.cache.queryGetObject(arg))?.data;
215
+ return (await utils.scallopSuiKit.queryGetObject(arg))?.data;
215
216
  }
216
217
  return arg;
217
218
  })
@@ -222,20 +223,22 @@ const getTotalVeScaTreasuryAmount = async (
222
223
  txb.moveCall(veScaAmountQueryTarget, resolvedVeScaAmountArgs);
223
224
 
224
225
  const txBytes = await txb.txBlock.build({
225
- client: utils.suiKit.client(),
226
+ client: utils.suiKit.client,
226
227
  onlyTransactionKind: true,
227
228
  });
228
229
 
229
230
  // return result
230
- const res = await utils.cache.queryClient.fetchQuery<DevInspectResults>({
231
- queryKey: queryKeys.rpc.getTotalVeScaTreasuryAmount(
232
- refreshArgs,
233
- veScaAmountArgs
234
- ),
235
- queryFn: async () => {
236
- return await utils.suiKit.inspectTxn(txBytes);
237
- },
238
- });
231
+ const res =
232
+ await utils.scallopSuiKit.queryClient.fetchQuery<DevInspectResults>({
233
+ queryKey: queryKeys.rpc.getTotalVeScaTreasuryAmount({
234
+ refreshArgs,
235
+ vescaAmountArgs,
236
+ node: utils.scallopSuiKit.currentFullNode,
237
+ }),
238
+ queryFn: async () => {
239
+ return await utils.suiKit.inspectTxn(txBytes);
240
+ },
241
+ });
239
242
 
240
243
  const results = res.results;
241
244
  if (results && results[1]?.returnValues) {
@@ -257,7 +260,8 @@ export const getVeScaTreasuryInfo = async (
257
260
  utils: ScallopUtils
258
261
  ): Promise<VeScaTreasuryInfo | null> => {
259
262
  const veScaTreasuryId = utils.address.get('vesca.treasury');
260
- const veScaTreasury = await utils.cache.queryGetObject(veScaTreasuryId);
263
+ const veScaTreasury =
264
+ await utils.scallopSuiKit.queryGetObject(veScaTreasuryId);
261
265
 
262
266
  if (!veScaTreasury || veScaTreasury.data?.content?.dataType !== 'moveObject')
263
267
  return null;
@@ -1,5 +1,5 @@
1
1
  import { SuiObjectResponse } from '@mysten/sui/client';
2
- import { ScallopAddress, ScallopUtils } from 'src/models';
2
+ import { ScallopAddress, ScallopSuiKit, ScallopUtils } from 'src/models';
3
3
  import { SupportOracleType, xOracleRuleType } from 'src/types';
4
4
 
5
5
  /**
@@ -7,23 +7,27 @@ import { SupportOracleType, xOracleRuleType } from 'src/types';
7
7
  * @param query
8
8
  * @returns Primary and Secondary price update policy table object
9
9
  */
10
- export const getPriceUpdatePolicies = async (
11
- address: ScallopAddress
12
- ): Promise<{
10
+ export const getPriceUpdatePolicies = async ({
11
+ address,
12
+ scallopSuiKit,
13
+ }: {
14
+ address: ScallopAddress;
15
+ scallopSuiKit: ScallopSuiKit;
16
+ }): Promise<{
13
17
  primary: SuiObjectResponse | null;
14
18
  secondary: SuiObjectResponse | null;
15
19
  }> => {
16
20
  const priceUpdatePolicyRulesKeyType = `${address.get('core.packages.xOracle.object')}::price_update_policy::PriceUpdatePolicyRulesKey`;
17
21
  const [primaryPriceUpdatePolicyTable, secondaryPriceUpdatePolicyTable] =
18
22
  await Promise.all([
19
- address.cache.queryGetDynamicFieldObject({
23
+ scallopSuiKit.queryGetDynamicFieldObject({
20
24
  parentId: address.get('core.oracles.primaryPriceUpdatePolicyObject'),
21
25
  name: {
22
26
  type: priceUpdatePolicyRulesKeyType,
23
27
  value: { dummy_field: false },
24
28
  },
25
29
  }),
26
- address.cache.queryGetDynamicFieldObject({
30
+ scallopSuiKit.queryGetDynamicFieldObject({
27
31
  parentId: address.get('core.oracles.secondaryPriceUpdatePolicyObject'),
28
32
  name: {
29
33
  type: priceUpdatePolicyRulesKeyType,
@@ -67,7 +71,7 @@ export const getAssetOracles = async (
67
71
  const assetOracles = {} as Record<string, SupportOracleType[]>;
68
72
  let cursor = null;
69
73
  do {
70
- const response = await utils.cache.queryGetDynamicFields({
74
+ const response = await utils.scallopSuiKit.queryGetDynamicFields({
71
75
  parentId:
72
76
  ruleType === 'primary'
73
77
  ? utils.address.get('core.oracles.primaryPriceUpdatePolicyVecsetId')
@@ -85,7 +89,8 @@ export const getAssetOracles = async (
85
89
  const objectIds = data.map((dynamicField) => dynamicField.objectId);
86
90
 
87
91
  // batch fetch object responses
88
- const objectResponses = await utils.cache.queryGetObjects(objectIds);
92
+ const objectResponses =
93
+ await utils.scallopSuiKit.queryGetObjects(objectIds);
89
94
  objectResponses.forEach((object) => {
90
95
  if (!object.content || object.content.dataType !== 'moveObject') return;
91
96
  const fields = object.content.fields as any;
@@ -108,9 +108,6 @@ export interface AddressesInterface {
108
108
  table: string;
109
109
  treasury: string;
110
110
  config: string;
111
- subsTable: string;
112
- subsTableId: string;
113
- subsWhitelist: string;
114
111
  };
115
112
  referral: {
116
113
  id: string;
@@ -4,8 +4,8 @@ import type {
4
4
  SuiTxArg,
5
5
  } from '@scallop-io/sui-kit';
6
6
  import type { Argument, TransactionResult } from '@mysten/sui/transactions';
7
- import type { ScallopBuilder } from '../../models';
8
7
  import { SuiTxBlockWithSpool } from '.';
8
+ import { ScallopBuilder } from 'src/models';
9
9
 
10
10
  export type CoreIds = {
11
11
  protocolPkg: string;
@@ -2,6 +2,13 @@ import { SuiTxBlock as SuiKitTxBlock, SuiObjectArg } from '@scallop-io/sui-kit';
2
2
  import type { TransactionResult } from '@mysten/sui/transactions';
3
3
  import { ScallopBuilder } from 'src/models';
4
4
 
5
+ export type VescaIds = {
6
+ pkgId: string;
7
+ table: string;
8
+ treasury: string;
9
+ config: string;
10
+ };
11
+
5
12
  export type VeScaNormalMethods = {
6
13
  lockSca: (
7
14
  scaCoin: SuiObjectArg,
@@ -19,17 +26,9 @@ export type VeScaNormalMethods = {
19
26
  ) => void;
20
27
  redeemSca: (veScaKey: SuiObjectArg) => TransactionResult;
21
28
  mintEmptyVeSca: () => TransactionResult;
22
- splitVeSca: (
23
- veScaKey: SuiObjectArg,
24
- splitAmount: string
25
- ) => TransactionResult;
26
- mergeVeSca: (
27
- targetVeScaKey: SuiObjectArg,
28
- sourceVeScaKey: SuiObjectArg
29
- ) => void;
30
29
  };
31
30
 
32
- export type QuickMethodReturnType<T extends boolean> = T extends true
31
+ export type RedeemScaQuickReturnType<T extends boolean> = T extends true
33
32
  ? void
34
33
  : TransactionResult | undefined;
35
34
 
@@ -72,18 +71,9 @@ export type VeScaQuickMethods = {
72
71
  autoCheck?: boolean
73
72
  ) => Promise<void>;
74
73
  redeemScaQuick: <T extends boolean>(
75
- veScaKey?: SuiObjectArg,
74
+ veSCaKey?: SuiObjectArg,
76
75
  transferSca?: T
77
- ) => Promise<QuickMethodReturnType<T>>;
78
- splitVeScaQuick: <T extends boolean>(
79
- splitAmount: string,
80
- veScaKey: string,
81
- transferVeScaKey?: T
82
- ) => Promise<QuickMethodReturnType<T>>;
83
- mergeVeScaQuick: (
84
- targetVeScaKey: string,
85
- sourceVeScaKey: string
86
- ) => Promise<void>;
76
+ ) => Promise<RedeemScaQuickReturnType<T>>;
87
77
  };
88
78
 
89
79
  export type SuiTxBlockWithVeScaNormalMethods = SuiKitTxBlock &
@@ -0,0 +1,48 @@
1
+ import type {
2
+ GetDynamicFieldObjectParams,
3
+ GetDynamicFieldsParams,
4
+ GetOwnedObjectsParams,
5
+ SuiObjectData,
6
+ SuiObjectDataOptions,
7
+ } from '@mysten/sui/dist/cjs/client';
8
+ import type { SuiObjectArg, SuiTxArg } from '@scallop-io/sui-kit';
9
+
10
+ export namespace QueryKeys {
11
+ export namespace API {
12
+ export type GetAddresses = {
13
+ addressId?: string;
14
+ };
15
+ }
16
+ export namespace RPC {
17
+ type BaseType = {
18
+ node?: string;
19
+ };
20
+
21
+ export type GetInspectTxn = BaseType & {
22
+ queryTarget?: string;
23
+ args?: SuiObjectArg[];
24
+ typeArgs?: any[];
25
+ };
26
+ export type GetObject = BaseType & {
27
+ objectId?: string;
28
+ options?: SuiObjectDataOptions;
29
+ };
30
+ export type GetObjects = BaseType & {
31
+ objectIds?: string[];
32
+ };
33
+ export type GetOwnedObjects = BaseType & Partial<GetOwnedObjectsParams>;
34
+ export type GetDynamicFields = BaseType & Partial<GetDynamicFieldsParams>;
35
+ export type GetDynamicFieldObject = BaseType &
36
+ Partial<GetDynamicFieldObjectParams>;
37
+ export type getTotalVeScaTreasuryAmount = BaseType & {
38
+ refreshArgs?: any[];
39
+ vescaAmountArgs?: (string | SuiObjectData | SuiTxArg)[];
40
+ };
41
+ export type GetAllCoinBalances = BaseType & {
42
+ activeAddress?: string;
43
+ };
44
+ export type GetNormalizedMoveFunction = BaseType & {
45
+ target?: string;
46
+ };
47
+ }
48
+ }
@@ -2,5 +2,4 @@ export type * from './builder';
2
2
  export type * from './constant';
3
3
  export type * from './query';
4
4
  export type * from './address';
5
- export type * from './model';
6
5
  export type * from './utils';
@@ -5,7 +5,7 @@ import {
5
5
  MAX_LOCK_ROUNDS,
6
6
  MIN_INITIAL_LOCK_AMOUNT,
7
7
  MIN_TOP_UP_AMOUNT,
8
- } from 'src/constants';
8
+ } from '../constants';
9
9
  import type { SuiObjectArg } from '@scallop-io/sui-kit';
10
10
 
11
11
  /**