@scallop-io/sui-scallop-sdk 2.1.4 → 2.1.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scallop-io/sui-scallop-sdk",
3
- "version": "2.1.4",
3
+ "version": "2.1.6",
4
4
  "description": "Typescript sdk for interacting with Scallop contract on SUI",
5
5
  "keywords": [
6
6
  "sui",
@@ -89,7 +89,11 @@ export const isInSubsTable = async (
89
89
  value: veScaKey,
90
90
  },
91
91
  });
92
- return !!resp?.data;
92
+
93
+ if (!resp?.data) return false;
94
+
95
+ const contents = (resp.data.content as any).fields.value.fields.contents;
96
+ return Array.isArray(contents) && contents.length > 0;
93
97
  } catch (e) {
94
98
  console.error(e);
95
99
  return false;
@@ -463,17 +467,10 @@ const generateQuickVeScaMethod: GenerateVeScaQuickMethod = ({
463
467
  },
464
468
  mergeVeScaQuick: async (targetKey: string, sourceKey: string) => {
465
469
  // check targetKey and sourceKey
470
+ const table = builder.address.get('vesca.subsTableId');
466
471
  const [isTargetInSubTable, isSourceInSubTable] = await Promise.all([
467
- isInSubsTable(
468
- builder,
469
- targetKey,
470
- builder.address.get('vesca.subsTableId')
471
- ),
472
- isInSubsTable(
473
- builder,
474
- sourceKey,
475
- builder.address.get('vesca.subsTableId')
476
- ),
472
+ isInSubsTable(builder, targetKey, table),
473
+ isInSubsTable(builder, sourceKey, table),
477
474
  ]);
478
475
 
479
476
  const unstakeObligationBeforeStake =
@@ -776,8 +776,8 @@ class ScallopQuery implements ScallopQueryInterface {
776
776
  /**
777
777
  * Get list of isolated assets
778
778
  */
779
- async getIsolatedAssets() {
780
- return await getIsolatedAssets(this);
779
+ async getIsolatedAssets(useOnChainQuery: boolean = false) {
780
+ return await getIsolatedAssets(this, useOnChainQuery);
781
781
  }
782
782
 
783
783
  /**
@@ -247,6 +247,7 @@ const queryRequiredMarketObjects = async (
247
247
  borrowFeeKey?: string;
248
248
  supplyLimitKey?: string;
249
249
  borrowLimitKey?: string;
250
+ isolatedAssetKey?: string;
250
251
  };
251
252
 
252
253
  const keyCollections: Record<keyof KeyType, string[]> = {
@@ -258,6 +259,7 @@ const queryRequiredMarketObjects = async (
258
259
  borrowFeeKey: [],
259
260
  supplyLimitKey: [],
260
261
  borrowLimitKey: [],
262
+ isolatedAssetKey: [],
261
263
  };
262
264
 
263
265
  const taskMap = new Map<string, KeyType>();
@@ -274,6 +276,7 @@ const queryRequiredMarketObjects = async (
274
276
  borrowFeeKey: poolData?.borrowFeeKey,
275
277
  supplyLimitKey: poolData?.supplyLimitKey,
276
278
  borrowLimitKey: poolData?.borrowLimitKey,
279
+ isolatedAssetKey: poolData?.isolatedAssetKey,
277
280
  };
278
281
 
279
282
  // Add to key collections
@@ -311,6 +314,7 @@ const queryRequiredMarketObjects = async (
311
314
  borrowFeeKey: new Map<string, SuiObjectData>(),
312
315
  supplyLimitKey: new Map<string, SuiObjectData>(),
313
316
  borrowLimitKey: new Map<string, SuiObjectData>(),
317
+ isolatedAssetKey: new Map<string, SuiObjectData>(),
314
318
  isIsolated: new Map<string, boolean>(),
315
319
  } as Record<keyof KeyType, Map<string, SuiObjectData>>;
316
320
 
@@ -349,7 +353,10 @@ const queryRequiredMarketObjects = async (
349
353
  borrowLimitKey: task.borrowLimitKey
350
354
  ? resultMaps.borrowLimitKey.get(task.borrowLimitKey)
351
355
  : undefined,
352
- isolatedAssetKey: utils.constants.poolAddresses[poolCoinName]?.isIsolated,
356
+ isolatedAssetKey: task.isolatedAssetKey
357
+ ? resultMaps.isolatedAssetKey.get(task.isolatedAssetKey)
358
+ : undefined,
359
+ isIsolated: utils.constants.poolAddresses[poolCoinName]?.isIsolated,
353
360
  };
354
361
  }
355
362
 
@@ -553,6 +560,7 @@ export const getMarketPool = async (
553
560
  borrowFeeKey: SuiObjectData;
554
561
  supplyLimitKey: SuiObjectData;
555
562
  borrowLimitKey: SuiObjectData;
563
+ isolatedAssetKey?: SuiObjectData;
556
564
  isIsolated: boolean;
557
565
  }
558
566
  ): Promise<