@scallop-io/sui-scallop-sdk 1.3.4-alpha.7 → 1.3.4-isolated-asset.2

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.
@@ -18,8 +18,9 @@ const isolatedAssetZod = zod.object({
18
18
  }),
19
19
  });
20
20
 
21
- const ISOLATED_ASSET_KEY =
22
- '0x6e641f0dca8aedab3101d047e96439178f16301bf0b57fe8745086ff1195eb3e::market_dynamic_keys::IsolatedAssetKey';
21
+ // const isolatedAssetKeyType = `${protocolObject}::market_dynamic_keys::IsolatedAssetKey`;
22
+ // TODO: use prod value
23
+ const isolatedAssetKeyType = `0x6c23585e940a989588432509107e98bae06dbca4e333f26d0635d401b3c7c76d::market_dynamic_keys::IsolatedAssetKey`;
23
24
 
24
25
  /**
25
26
  * Return list of isolated assets coin types
@@ -42,7 +43,7 @@ export const getIsolatedAssets = async (
42
43
  ): dynamicField is DynamicFieldInfo & {
43
44
  name: DynamicFieldName & { value: { type: { name: string } } };
44
45
  } => {
45
- return dynamicField.name.type === ISOLATED_ASSET_KEY;
46
+ return dynamicField.name.type === isolatedAssetKeyType;
46
47
  };
47
48
 
48
49
  do {
@@ -83,7 +84,6 @@ export const isIsolatedAsset = async (
83
84
  ): Promise<boolean> => {
84
85
  try {
85
86
  const marketObject = utils.address.get('core.market');
86
-
87
87
  // check if the coin type is in the list
88
88
  const cachedData = utils.address.cache.queryClient.getQueryData<string[]>([
89
89
  'getDynamicFields',
@@ -100,7 +100,7 @@ export const isIsolatedAsset = async (
100
100
  const object = await utils.cache.queryGetDynamicFieldObject({
101
101
  parentId: marketObject,
102
102
  name: {
103
- type: ISOLATED_ASSET_KEY,
103
+ type: isolatedAssetKeyType,
104
104
  value: coinType,
105
105
  },
106
106
  });
@@ -10,7 +10,6 @@ export const queryVeScaKeyIdFromReferralBindings = async (
10
10
  refereeAddress: string
11
11
  ): Promise<string | null> => {
12
12
  const referralBindingTableId = address.get('referral.bindingTableId');
13
-
14
13
  const referralBindResponse = await address.cache.queryGetDynamicFieldObject({
15
14
  parentId: referralBindingTableId,
16
15
  name: {
@@ -114,7 +114,7 @@ export const getSpool = async (
114
114
  const coinName = query.utils.parseCoinName<SupportStakeCoins>(marketCoinName);
115
115
  marketPool = marketPool || (await query.getMarketPool(coinName, indexer));
116
116
  if (!marketPool) {
117
- throw new Error(`Fail to fetch marketPool for ${coinName}`);
117
+ throw new Error(`Failed to fetch marketPool for ${marketCoinName}`);
118
118
  }
119
119
 
120
120
  const poolId = query.address.get(`spool.pools.${marketCoinName}.id`);
@@ -1,5 +1,5 @@
1
- import { ScallopUtils } from '../models';
2
- import { SupportPoolCoins } from '../types';
1
+ import { ScallopUtils } from 'src/models';
2
+ import { SupportPoolCoins } from 'src/types';
3
3
  import { z as zod } from 'zod';
4
4
 
5
5
  const supplyLimitZod = zod.object({
@@ -17,9 +17,9 @@ const supplyLimitZod = zod.object({
17
17
  }),
18
18
  });
19
19
 
20
- const SUPPLY_LIMIT_KEY =
21
- '0x6e641f0dca8aedab3101d047e96439178f16301bf0b57fe8745086ff1195eb3e::market_dynamic_keys::SupplyLimitKey';
22
-
20
+ // const supplyLimitKeyType = `0x6e641f0dca8aedab3101d047e96439178f16301bf0b57fe8745086ff1195eb3e::market_dynamic_keys::SupplyLimitKey`;
21
+ // TODO: use prod value
22
+ const supplyLimitKeyType = `0x6c23585e940a989588432509107e98bae06dbca4e333f26d0635d401b3c7c76d::market_dynamic_keys::SupplyLimitKey`;
23
23
  /**
24
24
  * Return supply limit of a pool (including the decimals)
25
25
  * @param utils
@@ -30,19 +30,24 @@ export const getSupplyLimit = async (
30
30
  utils: ScallopUtils,
31
31
  poolName: SupportPoolCoins
32
32
  ) => {
33
- const poolCoinType = utils.parseCoinType(poolName).slice(2);
34
- const marketObject = utils.address.get('core.market');
35
- if (!marketObject) return null;
33
+ try {
34
+ const poolCoinType = utils.parseCoinType(poolName).slice(2);
35
+ const marketObject = utils.address.get('core.market');
36
+ if (!marketObject) return null;
36
37
 
37
- const object = await utils.cache.queryGetDynamicFieldObject({
38
- parentId: marketObject,
39
- name: {
40
- type: SUPPLY_LIMIT_KEY,
41
- value: poolCoinType,
42
- },
43
- });
38
+ const object = await utils.cache.queryGetDynamicFieldObject({
39
+ parentId: marketObject,
40
+ name: {
41
+ type: supplyLimitKeyType,
42
+ value: poolCoinType,
43
+ },
44
+ });
44
45
 
45
- const parsedData = supplyLimitZod.safeParse(object?.data?.content);
46
- if (!parsedData.success) return null;
47
- return parsedData.data.fields.value;
46
+ const parsedData = supplyLimitZod.safeParse(object?.data?.content);
47
+ if (!parsedData.success) return null;
48
+ return parsedData.data.fields.value;
49
+ } catch (e: any) {
50
+ console.error(`Error in getSupplyLimit for ${poolName}: ${e.message}`);
51
+ return '0';
52
+ }
48
53
  };
@@ -130,6 +130,7 @@ export type MarketPool = {
130
130
  coinDecimal: number;
131
131
  coinPrice: number;
132
132
  maxSupplyCoin: number;
133
+ maxBorrowCoin: number;
133
134
  isIsolated: boolean;
134
135
  } & Required<
135
136
  Pick<
@@ -153,6 +154,7 @@ export type MarketCollateral = {
153
154
  coinWrappedType: CoinWrappedType;
154
155
  coinDecimal: number;
155
156
  coinPrice: number;
157
+ isIsolated: boolean;
156
158
  } & Required<
157
159
  Pick<
158
160
  ParsedMarketCollateralData,
@@ -20,7 +20,7 @@ export type PoolAddressInfo = {
20
20
  decimal: number;
21
21
  pythFeedId: string;
22
22
  lendingPoolAddress: string;
23
- collateralPoolAddress: string;
23
+ collateralPoolAddress?: string;
24
24
  sCoinAddress: string | undefined;
25
25
  marketCoinAddress: string;
26
26
  coinAddress: string;