@scallop-io/sui-scallop-sdk 1.3.0-alpha.3 → 1.3.0-alpha.5

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.
package/dist/index.mjs CHANGED
@@ -12,7 +12,7 @@ var SUPPORT_POOLS = [
12
12
  "usdc",
13
13
  // native USDC
14
14
  "sbeth",
15
- // native ETH
15
+ // sui bridge ETH
16
16
  "weth",
17
17
  "wbtc",
18
18
  "wusdc",
@@ -30,7 +30,7 @@ var SUPPORT_COLLATERALS = [
30
30
  "usdc",
31
31
  // native USDC
32
32
  "sbeth",
33
- // native ETH
33
+ // sui bridge ETH
34
34
  "weth",
35
35
  "wbtc",
36
36
  "wusdc",
@@ -283,6 +283,93 @@ var FlashLoanFeeObjectMap = {
283
283
  wsol: "0xe84bdb35b790fc7bdd1645122ac6ac0fc904531d6772c9e25904fece322c5f34"
284
284
  };
285
285
 
286
+ // src/constants/queryKeys.ts
287
+ var queryKeys = {
288
+ api: {
289
+ getAddresses: (addressesId) => [
290
+ "api",
291
+ "getAddresses",
292
+ { addressesId }
293
+ ],
294
+ getMarket: () => ["api", "getMarket"],
295
+ getSpools: () => ["api", "getSpools"],
296
+ getBorrowIncentivePool: () => ["api", "getBorrowIncentivePools"],
297
+ getTotalValueLocked: () => ["api", "getTotalValueLocked"]
298
+ },
299
+ rpc: {
300
+ getInspectTxn: (queryTarget, args, typeArgs) => [
301
+ "rpc",
302
+ "getInspectTxn",
303
+ {
304
+ queryTarget,
305
+ args: JSON.stringify(args),
306
+ typeArgs: !typeArgs ? void 0 : JSON.stringify(typeArgs)
307
+ }
308
+ ],
309
+ getObject: (objectId, walletAddress, options) => ["rpc", "getObject", { walletAddress, options, objectId }],
310
+ getObjects: (objectIds, walletAddress, options) => [
311
+ "rpc",
312
+ "getObjects",
313
+ {
314
+ walletAddress,
315
+ options,
316
+ objectIds: JSON.stringify(objectIds ?? [])
317
+ }
318
+ ],
319
+ getOwnedObjects: (input) => [
320
+ "rpc",
321
+ "getOwnedObjects",
322
+ {
323
+ walletAddress: input.owner,
324
+ cursor: input.cursor ?? void 0,
325
+ options: input.options ?? void 0,
326
+ filter: JSON.stringify(input.filter ?? void 0),
327
+ limit: input.limit ?? void 0
328
+ }
329
+ ],
330
+ getDynamicFields: (input) => [
331
+ "rpc",
332
+ "getDynamicFields",
333
+ {
334
+ parentId: input.parentId,
335
+ cursor: input.cursor ?? void 0,
336
+ limit: input.limit ?? void 0
337
+ }
338
+ ],
339
+ getDynamicFieldObject: (input) => [
340
+ "rpc",
341
+ "getDynamicFieldObject",
342
+ {
343
+ parentId: input.parentId,
344
+ name: {
345
+ type: input?.name?.type,
346
+ value: input?.name?.value
347
+ }
348
+ }
349
+ ],
350
+ getTotalVeScaTreasuryAmount: (refreshArgs, vescaAmountArgs) => [
351
+ "rpc",
352
+ "getTotalVeScaTreasuryAmount",
353
+ {
354
+ refreshArgs: JSON.stringify(refreshArgs),
355
+ vescaAmountArgs: JSON.stringify(vescaAmountArgs)
356
+ }
357
+ ],
358
+ getAllCoinBalances: (owner) => [
359
+ "rpc",
360
+ "getAllCoinBalances",
361
+ { owner }
362
+ ]
363
+ },
364
+ pyth: {
365
+ getPythLatestPriceFeed: (pythPriceId) => [
366
+ "pyth",
367
+ "getPythPriceId",
368
+ { pythPriceId }
369
+ ]
370
+ }
371
+ };
372
+
286
373
  // src/constants/vesca.ts
287
374
  var UNLOCK_ROUND_DURATION = 60 * 60 * 24;
288
375
  var MAX_LOCK_ROUNDS = 1460;
@@ -300,8 +387,7 @@ import { SuiKit } from "@scallop-io/sui-kit";
300
387
  import { QueryClient } from "@tanstack/query-core";
301
388
  import {
302
389
  SuiTxBlock,
303
- normalizeStructTag as normalizeStructTag2,
304
- normalizeSuiAddress
390
+ normalizeStructTag as normalizeStructTag2
305
391
  } from "@scallop-io/sui-kit";
306
392
 
307
393
  // src/constants/cache.ts
@@ -919,7 +1005,7 @@ var callWithRateLimit = async (tokenBucket, fn, retryDelayInMs = DEFAULT_INTERVA
919
1005
  await new Promise((resolve) => setTimeout(resolve, delay));
920
1006
  return tryRequest();
921
1007
  } else {
922
- console.error("An error occurred:", error);
1008
+ console.error("An error occurred:", error.message);
923
1009
  return null;
924
1010
  }
925
1011
  }
@@ -942,8 +1028,8 @@ async function callMethodWithIndexerFallback(method, context, ...args) {
942
1028
  if (indexer) {
943
1029
  try {
944
1030
  return await method.apply(context, args);
945
- } catch (_e) {
946
- console.warn("Indexer requests failed. Retrying without indexer..");
1031
+ } catch (e) {
1032
+ console.warn(`Indexer requests failed: ${e}. Retrying without indexer..`);
947
1033
  return await method.apply(context, [...args.slice(0, -1), false]);
948
1034
  }
949
1035
  }
@@ -957,8 +1043,8 @@ function withIndexerFallback(method) {
957
1043
 
958
1044
  // src/models/scallopCache.ts
959
1045
  var ScallopCache = class {
960
- constructor(suiKit, walletAddress, cacheOptions, tokenBucket) {
961
- this.queryClient = new QueryClient(cacheOptions ?? DEFAULT_CACHE_OPTIONS);
1046
+ constructor(suiKit, walletAddress, cacheOptions, tokenBucket, queryClient) {
1047
+ this.queryClient = queryClient ?? new QueryClient(cacheOptions ?? DEFAULT_CACHE_OPTIONS);
962
1048
  this._suiKit = suiKit;
963
1049
  this.tokenBucket = tokenBucket ?? new TokenBucket(DEFAULT_TOKENS_PER_INTERVAL, DEFAULT_INTERVAL_IN_MS);
964
1050
  this.walletAddress = walletAddress ?? suiKit.currentAddress();
@@ -986,41 +1072,6 @@ var ScallopCache = class {
986
1072
  refetchType
987
1073
  });
988
1074
  }
989
- async resolveArgs(txb, args) {
990
- return await Promise.all(
991
- args.map(async (arg) => {
992
- if (typeof arg === "string") {
993
- const objData = (await this.queryGetObject(arg, { showOwner: true }))?.data;
994
- if (!objData)
995
- return arg;
996
- const owner = objData?.owner;
997
- if (!owner)
998
- return arg;
999
- if ("Shared" in owner) {
1000
- return txb.sharedObjectRef({
1001
- objectId: objData.objectId,
1002
- initialSharedVersion: owner.Shared.initial_shared_version,
1003
- mutable: true
1004
- });
1005
- } else {
1006
- return txb.objectRef({
1007
- objectId: objData.objectId,
1008
- version: objData.version,
1009
- digest: objData.digest
1010
- });
1011
- }
1012
- } else if ("objectId" in arg && "version" in arg && "digest" in arg) {
1013
- return txb.objectRef({
1014
- objectId: arg.objectId,
1015
- version: arg.version,
1016
- digest: arg.digest
1017
- });
1018
- } else {
1019
- return arg;
1020
- }
1021
- })
1022
- );
1023
- }
1024
1075
  /**
1025
1076
  * @description Provides cache for inspectTxn of the SuiKit.
1026
1077
  * @param QueryInspectTxnParams
@@ -1033,15 +1084,9 @@ var ScallopCache = class {
1033
1084
  typeArgs
1034
1085
  }) {
1035
1086
  const txBlock = new SuiTxBlock();
1036
- const resolvedArgs = await this.resolveArgs(txBlock, args);
1037
- txBlock.moveCall(queryTarget, resolvedArgs, typeArgs);
1087
+ txBlock.moveCall(queryTarget, args, typeArgs);
1038
1088
  const query = await this.queryClient.fetchQuery({
1039
- queryKey: typeArgs ? ["inspectTxn", queryTarget, JSON.stringify(args)] : [
1040
- "inspectTxn",
1041
- queryTarget,
1042
- JSON.stringify(args),
1043
- JSON.stringify(typeArgs)
1044
- ],
1089
+ queryKey: queryKeys.rpc.getInspectTxn(queryTarget, args, typeArgs),
1045
1090
  queryFn: async () => {
1046
1091
  return await callWithRateLimit(
1047
1092
  this.tokenBucket,
@@ -1058,12 +1103,8 @@ var ScallopCache = class {
1058
1103
  * @returns Promise<SuiObjectResponse>
1059
1104
  */
1060
1105
  async queryGetObject(objectId, options) {
1061
- const queryKey = ["getObject", objectId, this.walletAddress];
1062
- if (options) {
1063
- queryKey.push(JSON.stringify(options));
1064
- }
1065
1106
  return this.queryClient.fetchQuery({
1066
- queryKey,
1107
+ queryKey: queryKeys.rpc.getObject(objectId, this.walletAddress, options),
1067
1108
  queryFn: async () => {
1068
1109
  return await callWithRateLimit(
1069
1110
  this.tokenBucket,
@@ -1085,16 +1126,12 @@ var ScallopCache = class {
1085
1126
  }) {
1086
1127
  if (objectIds.length === 0)
1087
1128
  return [];
1088
- const queryKey = [
1089
- "getObjects",
1090
- JSON.stringify(objectIds),
1091
- this.walletAddress
1092
- ];
1093
- if (options) {
1094
- queryKey.push(JSON.stringify(options));
1095
- }
1096
1129
  return this.queryClient.fetchQuery({
1097
- queryKey,
1130
+ queryKey: queryKeys.rpc.getObjects(
1131
+ objectIds,
1132
+ this.walletAddress,
1133
+ options
1134
+ ),
1098
1135
  queryFn: async () => {
1099
1136
  return await callWithRateLimit(
1100
1137
  this.tokenBucket,
@@ -1109,21 +1146,8 @@ var ScallopCache = class {
1109
1146
  * @returns Promise<PaginatedObjectsResponse>
1110
1147
  */
1111
1148
  async queryGetOwnedObjects(input) {
1112
- const queryKey = ["getOwnedObjects", input.owner];
1113
- if (input.cursor) {
1114
- queryKey.push(JSON.stringify(input.cursor));
1115
- }
1116
- if (input.options) {
1117
- queryKey.push(JSON.stringify(input.options));
1118
- }
1119
- if (input.filter) {
1120
- queryKey.push(JSON.stringify(input.filter));
1121
- }
1122
- if (input.limit) {
1123
- queryKey.push(JSON.stringify(input.limit));
1124
- }
1125
1149
  return this.queryClient.fetchQuery({
1126
- queryKey,
1150
+ queryKey: queryKeys.rpc.getOwnedObjects(input),
1127
1151
  queryFn: async () => {
1128
1152
  return await callWithRateLimit(
1129
1153
  this.tokenBucket,
@@ -1133,15 +1157,8 @@ var ScallopCache = class {
1133
1157
  });
1134
1158
  }
1135
1159
  async queryGetDynamicFields(input) {
1136
- const queryKey = ["getDynamicFields", input.parentId];
1137
- if (input.cursor) {
1138
- queryKey.push(JSON.stringify(input.cursor));
1139
- }
1140
- if (input.limit) {
1141
- queryKey.push(JSON.stringify(input.limit));
1142
- }
1143
1160
  return this.queryClient.fetchQuery({
1144
- queryKey,
1161
+ queryKey: queryKeys.rpc.getDynamicFields(input),
1145
1162
  queryFn: async () => {
1146
1163
  return await callWithRateLimit(
1147
1164
  this.tokenBucket,
@@ -1151,14 +1168,8 @@ var ScallopCache = class {
1151
1168
  });
1152
1169
  }
1153
1170
  async queryGetDynamicFieldObject(input) {
1154
- const queryKey = [
1155
- "getDynamicFieldObject",
1156
- input.parentId,
1157
- input.name.type,
1158
- input.name.value
1159
- ];
1160
1171
  return this.queryClient.fetchQuery({
1161
- queryKey,
1172
+ queryKey: queryKeys.rpc.getDynamicFieldObject(input),
1162
1173
  queryFn: async () => {
1163
1174
  return await callWithRateLimit(
1164
1175
  this.tokenBucket,
@@ -1168,9 +1179,8 @@ var ScallopCache = class {
1168
1179
  });
1169
1180
  }
1170
1181
  async queryGetAllCoinBalances(owner) {
1171
- const queryKey = ["getAllCoinBalances", owner];
1172
1182
  return this.queryClient.fetchQuery({
1173
- queryKey,
1183
+ queryKey: queryKeys.rpc.getAllCoinBalances(owner),
1174
1184
  queryFn: async () => {
1175
1185
  const allBalances = await callWithRateLimit(
1176
1186
  this.tokenBucket,
@@ -1187,17 +1197,6 @@ var ScallopCache = class {
1187
1197
  },
1188
1198
  {}
1189
1199
  );
1190
- for (const coinType in balances) {
1191
- const coinBalanceQueryKey = [
1192
- "getCoinBalance",
1193
- normalizeSuiAddress(owner),
1194
- normalizeStructTag2(coinType)
1195
- ];
1196
- this.queryClient.setQueryData(
1197
- coinBalanceQueryKey,
1198
- balances[coinType]
1199
- );
1200
- }
1201
1200
  return balances;
1202
1201
  }
1203
1202
  });
@@ -1205,19 +1204,7 @@ var ScallopCache = class {
1205
1204
  async queryGetCoinBalance(input) {
1206
1205
  if (!input.coinType)
1207
1206
  return "0";
1208
- const queryKey = [
1209
- "getCoinBalance",
1210
- normalizeSuiAddress(input.owner),
1211
- normalizeStructTag2(input.coinType)
1212
- ];
1213
- return this.queryClient.fetchQuery({
1214
- queryKey,
1215
- queryFn: async () => {
1216
- if (!input.coinType)
1217
- return "0";
1218
- return (await this.queryGetAllCoinBalances(input.owner))[normalizeStructTag2(input.coinType)] ?? "0";
1219
- }
1220
- });
1207
+ return (await this.queryGetAllCoinBalances(input.owner) || {})[normalizeStructTag2(input.coinType)] ?? "0";
1221
1208
  }
1222
1209
  };
1223
1210
 
@@ -2151,7 +2138,7 @@ var ScallopAddress = class {
2151
2138
  const addressesId = id || this._id || void 0;
2152
2139
  if (addressesId !== void 0) {
2153
2140
  const response = await this.cache.queryClient.fetchQuery({
2154
- queryKey: ["api-getAddresses", addressesId],
2141
+ queryKey: queryKeys.api.getAddresses(addressesId),
2155
2142
  queryFn: async () => {
2156
2143
  return await this._requestClient.get(`/addresses/${addressesId}`, {
2157
2144
  headers: {
@@ -2277,7 +2264,7 @@ var ScallopAddress = class {
2277
2264
  };
2278
2265
 
2279
2266
  // src/models/scallopClient.ts
2280
- import { normalizeSuiAddress as normalizeSuiAddress4 } from "@mysten/sui/utils";
2267
+ import { normalizeSuiAddress as normalizeSuiAddress3 } from "@mysten/sui/utils";
2281
2268
  import { SuiKit as SuiKit6 } from "@scallop-io/sui-kit";
2282
2269
 
2283
2270
  // src/models/scallopUtils.ts
@@ -2305,7 +2292,7 @@ var supplyLimitZod = zod.object({
2305
2292
  value: zod.string()
2306
2293
  })
2307
2294
  });
2308
- var SUPPLY_LIMIT_TYPE = "0x6e641f0dca8aedab3101d047e96439178f16301bf0b57fe8745086ff1195eb3e::market_dynamic_keys::SupplyLimitKey";
2295
+ var SUPPLY_LIMIT_KEY = "0x6e641f0dca8aedab3101d047e96439178f16301bf0b57fe8745086ff1195eb3e::market_dynamic_keys::SupplyLimitKey";
2309
2296
  var getSupplyLimit = async (utils, poolName) => {
2310
2297
  const poolCoinType = utils.parseCoinType(poolName).slice(2);
2311
2298
  const marketObject = utils.address.get("core.market");
@@ -2314,7 +2301,7 @@ var getSupplyLimit = async (utils, poolName) => {
2314
2301
  const object = await utils.cache.queryGetDynamicFieldObject({
2315
2302
  parentId: marketObject,
2316
2303
  name: {
2317
- type: SUPPLY_LIMIT_TYPE,
2304
+ type: SUPPLY_LIMIT_KEY,
2318
2305
  value: poolCoinType
2319
2306
  }
2320
2307
  });
@@ -2324,6 +2311,76 @@ var getSupplyLimit = async (utils, poolName) => {
2324
2311
  return parsedData.data.fields.value;
2325
2312
  };
2326
2313
 
2314
+ // src/queries/isolatedAsset.ts
2315
+ import { z as zod2 } from "zod";
2316
+ var isolatedAssetZod = zod2.object({
2317
+ dataType: zod2.string(),
2318
+ type: zod2.string(),
2319
+ hasPublicTransfer: zod2.boolean(),
2320
+ fields: zod2.object({
2321
+ id: zod2.object({
2322
+ id: zod2.string()
2323
+ }),
2324
+ name: zod2.object({
2325
+ type: zod2.string()
2326
+ }),
2327
+ value: zod2.boolean()
2328
+ })
2329
+ });
2330
+ var ISOLATED_ASSET_KEY = "0x6e641f0dca8aedab3101d047e96439178f16301bf0b57fe8745086ff1195eb3e::market_dynamic_keys::IsolatedAssetKey";
2331
+ var getIsolatedAssets = async (address) => {
2332
+ const marketObject = address.get("core.market");
2333
+ const isolatedAssets = [];
2334
+ if (!marketObject)
2335
+ return isolatedAssets;
2336
+ let hasNextPage = false;
2337
+ let nextCursor = null;
2338
+ const isIsolatedDynamicField = (dynamicField) => {
2339
+ return dynamicField.name.type === ISOLATED_ASSET_KEY;
2340
+ };
2341
+ do {
2342
+ const response = await address.cache.queryGetDynamicFields({
2343
+ parentId: marketObject,
2344
+ cursor: nextCursor,
2345
+ limit: 10
2346
+ });
2347
+ if (!response)
2348
+ break;
2349
+ const isolatedAssetCoinTypes = response.data.filter(isIsolatedDynamicField).map(({ name }) => `0x${name.value.type.name}`);
2350
+ isolatedAssets.push(...isolatedAssetCoinTypes);
2351
+ if (response && response.hasNextPage && response.nextCursor) {
2352
+ hasNextPage = true;
2353
+ nextCursor = response.nextCursor;
2354
+ } else {
2355
+ hasNextPage = false;
2356
+ }
2357
+ } while (hasNextPage);
2358
+ return isolatedAssets;
2359
+ };
2360
+ var isIsolatedAsset = async (utils, coinName) => {
2361
+ const marketObject = utils.address.get("core.market");
2362
+ const cachedData = utils.address.cache.queryClient.getQueryData([
2363
+ "getDynamicFields",
2364
+ marketObject
2365
+ ]);
2366
+ if (cachedData) {
2367
+ const coinType2 = utils.parseCoinType(coinName);
2368
+ return cachedData.includes(coinType2);
2369
+ }
2370
+ const coinType = utils.parseCoinType(coinName).slice(2);
2371
+ const object = await utils.cache.queryGetDynamicFieldObject({
2372
+ parentId: marketObject,
2373
+ name: {
2374
+ type: ISOLATED_ASSET_KEY,
2375
+ value: coinType
2376
+ }
2377
+ });
2378
+ const parsedData = isolatedAssetZod.safeParse(object?.data?.content);
2379
+ if (!parsedData.success)
2380
+ return false;
2381
+ return parsedData.data.fields.value;
2382
+ };
2383
+
2327
2384
  // src/queries/coreQuery.ts
2328
2385
  var queryMarket = async (query, indexer = false) => {
2329
2386
  const coinPrices = await query.utils.getCoinPrices();
@@ -2408,6 +2465,7 @@ var queryMarket = async (query, indexer = false) => {
2408
2465
  borrowFee: parsedMarketPoolData.borrowFee,
2409
2466
  marketCoinSupplyAmount: parsedMarketPoolData.marketCoinSupplyAmount,
2410
2467
  minBorrowAmount: parsedMarketPoolData.minBorrowAmount,
2468
+ isIsolated: await isIsolatedAsset(query.utils, poolCoinName),
2411
2469
  maxSupplyCoin,
2412
2470
  ...calculatedMarketPoolData
2413
2471
  };
@@ -2635,6 +2693,7 @@ var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, c
2635
2693
  marketCoinSupplyAmount: parsedMarketPoolData.marketCoinSupplyAmount,
2636
2694
  minBorrowAmount: parsedMarketPoolData.minBorrowAmount,
2637
2695
  maxSupplyCoin,
2696
+ isIsolated: await isIsolatedAsset(query.utils, poolCoinName),
2638
2697
  ...calculatedMarketPoolData
2639
2698
  };
2640
2699
  }
@@ -3694,7 +3753,8 @@ var getLending = async (query, poolCoinName, ownerAddress, indexer = false, mark
3694
3753
  availableUnstakeAmount: availableUnstakeAmount.toNumber(),
3695
3754
  availableUnstakeCoin: availableUnstakeCoin.toNumber(),
3696
3755
  availableClaimAmount: availableClaimAmount.toNumber(),
3697
- availableClaimCoin: availableClaimCoin.toNumber()
3756
+ availableClaimCoin: availableClaimCoin.toNumber(),
3757
+ isIsolated: marketPool ? marketPool.isIsolated : false
3698
3758
  };
3699
3759
  return lending;
3700
3760
  };
@@ -4052,7 +4112,7 @@ var getTotalValueLocked = async (query, indexer = false) => {
4052
4112
  import BigNumber5 from "bignumber.js";
4053
4113
  import { SUI_CLOCK_OBJECT_ID, SuiTxBlock as SuiTxBlock2 } from "@scallop-io/sui-kit";
4054
4114
  import { bcs } from "@mysten/sui/bcs";
4055
- import { z as zod2 } from "zod";
4115
+ import { z as zod3 } from "zod";
4056
4116
  import assert from "assert";
4057
4117
  var getVescaKeys = async (utils, ownerAddress) => {
4058
4118
  const owner = ownerAddress || utils.suiKit.currentAddress();
@@ -4101,10 +4161,10 @@ var getVeScas = async ({
4101
4161
  }
4102
4162
  return result;
4103
4163
  };
4104
- var SuiObjectRefZod = zod2.object({
4105
- objectId: zod2.string(),
4106
- digest: zod2.string(),
4107
- version: zod2.string()
4164
+ var SuiObjectRefZod = zod3.object({
4165
+ objectId: zod3.string(),
4166
+ digest: zod3.string(),
4167
+ version: zod3.string()
4108
4168
  });
4109
4169
  var getVeSca = async (utils, veScaKey, ownerAddress) => {
4110
4170
  const tableId = utils.address.get(`vesca.tableId`);
@@ -4179,10 +4239,10 @@ var getTotalVeScaTreasuryAmount = async (utils, veScaTreasury) => {
4179
4239
  onlyTransactionKind: true
4180
4240
  });
4181
4241
  const res = await utils.cache.queryClient.fetchQuery({
4182
- queryKey: [
4183
- "getTotalVeScaTreasuryAmount",
4184
- JSON.stringify([...refreshArgs, ...veScaAmountArgs])
4185
- ],
4242
+ queryKey: queryKeys.rpc.getTotalVeScaTreasuryAmount(
4243
+ refreshArgs,
4244
+ veScaAmountArgs
4245
+ ),
4186
4246
  queryFn: async () => {
4187
4247
  return await utils.suiKit.inspectTxn(txBytes);
4188
4248
  }
@@ -4238,16 +4298,16 @@ var queryVeScaKeyIdFromReferralBindings = async (address, refereeAddress) => {
4238
4298
 
4239
4299
  // src/queries/loyaltyProgramQuery.ts
4240
4300
  import BigNumber6 from "bignumber.js";
4241
- import { z as zod3 } from "zod";
4242
- var rewardPoolFieldsZod = zod3.object({
4243
- balance: zod3.string(),
4244
- enable_claim: zod3.boolean()
4301
+ import { z as zod4 } from "zod";
4302
+ var rewardPoolFieldsZod = zod4.object({
4303
+ balance: zod4.string(),
4304
+ enable_claim: zod4.boolean()
4245
4305
  }).transform((value) => ({
4246
4306
  totalPoolReward: BigNumber6(value.balance).shiftedBy(-9).toNumber(),
4247
4307
  isClaimEnabled: value.enable_claim
4248
4308
  }));
4249
- var userRewardFieldsZod = zod3.object({
4250
- value: zod3.string()
4309
+ var userRewardFieldsZod = zod4.object({
4310
+ value: zod4.string()
4251
4311
  }).transform((value) => BigNumber6(value.value).shiftedBy(-9).toNumber());
4252
4312
  var getLoyaltyProgramInformations = async (query, veScaKey) => {
4253
4313
  const rewardPool = query.address.get("loyaltyProgram.rewardPool");
@@ -4666,7 +4726,7 @@ var ScallopUtils = class {
4666
4726
  const pythConnection = new SuiPriceServiceConnection(endpoint);
4667
4727
  try {
4668
4728
  const feed = await this.address.cache.queryClient.fetchQuery({
4669
- queryKey: [priceId],
4729
+ queryKey: queryKeys.pyth.getPythLatestPriceFeed(priceId),
4670
4730
  queryFn: async () => {
4671
4731
  return await pythConnection.getLatestPriceFeeds([priceId]);
4672
4732
  }
@@ -4760,7 +4820,7 @@ var ScallopUtils = class {
4760
4820
  };
4761
4821
 
4762
4822
  // src/models/scallopBuilder.ts
4763
- import { normalizeSuiAddress as normalizeSuiAddress3 } from "@mysten/sui/utils";
4823
+ import { normalizeSuiAddress as normalizeSuiAddress2 } from "@mysten/sui/utils";
4764
4824
  import { SuiKit as SuiKit5 } from "@scallop-io/sui-kit";
4765
4825
 
4766
4826
  // src/builders/coreBuilder.ts
@@ -6393,7 +6453,7 @@ var ScallopIndexer = class {
6393
6453
  */
6394
6454
  async getMarket() {
6395
6455
  const response = await this.cache.queryClient.fetchQuery({
6396
- queryKey: ["market"],
6456
+ queryKey: queryKeys.api.getMarket(),
6397
6457
  queryFn: async () => {
6398
6458
  return await this._requestClient.get(`/api/market/migrate`);
6399
6459
  }
@@ -6456,7 +6516,7 @@ var ScallopIndexer = class {
6456
6516
  */
6457
6517
  async getSpools() {
6458
6518
  const response = await this.cache.queryClient.fetchQuery({
6459
- queryKey: ["spools"],
6519
+ queryKey: queryKeys.api.getSpools(),
6460
6520
  queryFn: async () => {
6461
6521
  return await this._requestClient.get(`/api/spools/migrate`);
6462
6522
  }
@@ -6485,7 +6545,7 @@ var ScallopIndexer = class {
6485
6545
  */
6486
6546
  async getBorrowIncentivePools() {
6487
6547
  const response = await this.cache.queryClient.fetchQuery({
6488
- queryKey: ["borrowIncentivePools"],
6548
+ queryKey: queryKeys.api.getBorrowIncentivePool(),
6489
6549
  queryFn: async () => {
6490
6550
  return await this._requestClient.get(`/api/borrowIncentivePools/migrate`);
6491
6551
  }
@@ -6526,7 +6586,7 @@ var ScallopIndexer = class {
6526
6586
  */
6527
6587
  async getTotalValueLocked() {
6528
6588
  const response = await this.cache.queryClient.fetchQuery({
6529
- queryKey: ["totalValueLocked"],
6589
+ queryKey: queryKeys.api.getTotalValueLocked(),
6530
6590
  queryFn: async () => {
6531
6591
  return await this._requestClient.get(`/api/market/tvl`);
6532
6592
  }
@@ -6633,12 +6693,12 @@ var getSCoinSwapRate = async (query, fromSCoin, toSCoin, underlyingCoinPrice) =>
6633
6693
  };
6634
6694
 
6635
6695
  // src/models/scallopQuery.ts
6636
- import { normalizeSuiAddress as normalizeSuiAddress2 } from "@mysten/sui/utils";
6696
+ import { normalizeSuiAddress } from "@mysten/sui/utils";
6637
6697
  var ScallopQuery = class {
6638
6698
  constructor(params, instance) {
6639
6699
  this.params = params;
6640
6700
  this.suiKit = instance?.suiKit ?? instance?.utils?.suiKit ?? new SuiKit4(params);
6641
- this.walletAddress = normalizeSuiAddress2(
6701
+ this.walletAddress = normalizeSuiAddress(
6642
6702
  params.walletAddress || this.suiKit.currentAddress()
6643
6703
  );
6644
6704
  if (instance?.utils) {
@@ -7151,6 +7211,18 @@ var ScallopQuery = class {
7151
7211
  async getPoolSupplyLimit(poolName) {
7152
7212
  return await getSupplyLimit(this.utils, poolName);
7153
7213
  }
7214
+ /**
7215
+ * Get list of isolated assets
7216
+ */
7217
+ async getIsolatedAssets() {
7218
+ return await getIsolatedAssets(this.address);
7219
+ }
7220
+ /**
7221
+ * Check if asset is an isolated asset
7222
+ */
7223
+ async isIsolatedAsset(assetCoinName) {
7224
+ return isIsolatedAsset(this.utils, assetCoinName);
7225
+ }
7154
7226
  };
7155
7227
 
7156
7228
  // src/models/scallopBuilder.ts
@@ -7159,7 +7231,7 @@ var ScallopBuilder = class {
7159
7231
  constructor(params, instance) {
7160
7232
  this.suiKit = instance?.suiKit ?? new SuiKit5(params);
7161
7233
  this.params = params;
7162
- this.walletAddress = normalizeSuiAddress3(
7234
+ this.walletAddress = normalizeSuiAddress2(
7163
7235
  params?.walletAddress || this.suiKit.currentAddress()
7164
7236
  );
7165
7237
  if (instance?.query) {
@@ -7309,7 +7381,7 @@ var ScallopClient = class {
7309
7381
  constructor(params, instance) {
7310
7382
  this.params = params;
7311
7383
  this.suiKit = instance?.suiKit ?? instance?.builder?.suiKit ?? new SuiKit6(params);
7312
- this.walletAddress = normalizeSuiAddress4(
7384
+ this.walletAddress = normalizeSuiAddress3(
7313
7385
  params?.walletAddress || this.suiKit.currentAddress()
7314
7386
  );
7315
7387
  if (instance?.builder) {
@@ -7979,14 +8051,15 @@ var ScallopClient = class {
7979
8051
 
7980
8052
  // src/models/scallop.ts
7981
8053
  var Scallop = class {
7982
- constructor(params, cacheOptions, tokenBucket) {
8054
+ constructor(params, cacheOptions, tokenBucket, queryClient) {
7983
8055
  this.params = params;
7984
8056
  this.suiKit = new SuiKit7(params);
7985
8057
  this.cache = new ScallopCache(
7986
8058
  this.suiKit,
7987
8059
  params.walletAddress,
7988
8060
  cacheOptions ?? DEFAULT_CACHE_OPTIONS,
7989
- tokenBucket ?? new TokenBucket(DEFAULT_TOKENS_PER_INTERVAL, DEFAULT_INTERVAL_IN_MS)
8061
+ tokenBucket ?? new TokenBucket(DEFAULT_TOKENS_PER_INTERVAL, DEFAULT_INTERVAL_IN_MS),
8062
+ queryClient
7990
8063
  );
7991
8064
  this.address = new ScallopAddress(
7992
8065
  {
@@ -8130,6 +8203,7 @@ export {
8130
8203
  coinDecimals,
8131
8204
  coinIds,
8132
8205
  marketCoins,
8206
+ queryKeys,
8133
8207
  sCoinIds,
8134
8208
  sCoins,
8135
8209
  spoolRewardCoins,