@scallop-io/sui-scallop-sdk 2.0.0-alpha.1 → 2.0.0-alpha.10

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.
@@ -351,8 +351,8 @@ export class ScallopCache {
351
351
  retryDelay: 1000,
352
352
  queryKey: queryKeys.rpc.getOwnedObjects(input),
353
353
  queryFn: async () => {
354
- const results = await this.callWithRateLimit(
355
- async () => await this.client.getOwnedObjects(input)
354
+ const results = await this.callWithRateLimit(() =>
355
+ this.client.getOwnedObjects(input)
356
356
  );
357
357
  if (results && results.data.length > 0) {
358
358
  results.data
@@ -59,6 +59,7 @@ export class ScallopClient {
59
59
 
60
60
  this.cache =
61
61
  instance?.builder?.cache ??
62
+ instance?.cache ??
62
63
  new ScallopCache(this.params, {
63
64
  suiKit: this.suiKit,
64
65
  });
@@ -100,13 +101,13 @@ export class ScallopClient {
100
101
  * @param force - Whether to force initialization.
101
102
  */
102
103
  public async init(force: boolean = false) {
103
- if (force || !this.address.getAddresses()) {
104
- await this.address.read();
104
+ if (force || !this.constants.isInitialized) {
105
+ await this.constants.init();
105
106
  }
106
107
 
107
- await this.builder.init(force, this.address);
108
- await this.query.init(force, this.address);
109
- await this.utils.init(force, this.address);
108
+ await this.builder.init(force);
109
+ await this.query.init(force);
110
+ await this.utils.init(force);
110
111
  }
111
112
 
112
113
  /* ==================== Query Method ==================== */
@@ -492,9 +493,7 @@ export class ScallopClient {
492
493
  const sender = walletAddress ?? this.walletAddress;
493
494
  txBlock.setSender(sender);
494
495
 
495
- const availableStake = (
496
- [...this.constants.whitelist.lending] as readonly string[]
497
- ).includes(poolCoinName);
496
+ const availableStake = this.constants.whitelist.lending.has(poolCoinName);
498
497
  if (sign && availableStake) {
499
498
  await txBlock.unstakeObligationQuick(obligationId, obligationKey);
500
499
  }
@@ -540,9 +539,7 @@ export class ScallopClient {
540
539
  const sender = walletAddress ?? this.walletAddress;
541
540
  txBlock.setSender(sender);
542
541
 
543
- const availableStake = (
544
- [...this.constants.whitelist.lending] as readonly string[]
545
- ).includes(poolCoinName);
542
+ const availableStake = this.constants.whitelist.lending.has(poolCoinName);
546
543
  if (sign && availableStake) {
547
544
  await txBlock.unstakeObligationQuick(obligationId, obligationKey);
548
545
  }
@@ -36,6 +36,7 @@ export class ScallopConstants {
36
36
  scoin: new Set(),
37
37
  spool: new Set(),
38
38
  borrowIncentiveRewards: new Set(),
39
+ rewardsAsPoint: new Set(),
39
40
  suiBridge: new Set(),
40
41
  wormhole: new Set(),
41
42
  oracles: new Set(),
@@ -44,7 +45,6 @@ export class ScallopConstants {
44
45
  };
45
46
 
46
47
  private _coinDecimals: Record<string, number | undefined> = {};
47
- private _coinNameToCoinTypeMap: Record<string, string | undefined> = {};
48
48
  private _coinNameToOldMarketCoinTypeMap: Record<string, string | undefined> =
49
49
  {};
50
50
  private _scoinRawNameToSCoinNameMap: Record<string, string | undefined> = {};
@@ -57,6 +57,7 @@ export class ScallopConstants {
57
57
  private _coinTypes: Record<string, string | undefined> = {};
58
58
  private _sCoinTypes: Record<string, string | undefined> = {};
59
59
  private _coinTypeToCoinNameMap: Record<string, string | undefined> = {};
60
+ private _supportedBorrowIncentiveRewards: Set<string> = new Set();
60
61
 
61
62
  constructor(
62
63
  public readonly params: ScallopConstantsParams,
@@ -73,6 +74,7 @@ export class ScallopConstants {
73
74
 
74
75
  this.cache =
75
76
  instance?.address?.cache ??
77
+ instance?.cache ??
76
78
  new ScallopCache(this.params, {
77
79
  suiKit: newSuiKit(this.params),
78
80
  });
@@ -98,7 +100,9 @@ export class ScallopConstants {
98
100
 
99
101
  get isInitialized() {
100
102
  return (
101
- !!this._poolAddresses && !!this._whitelist && this.isAddressInitialized
103
+ !this.isEmptyObject(this._poolAddresses) &&
104
+ Object.values(this._whitelist).every((t) => t.size > 0) &&
105
+ this.isAddressInitialized
102
106
  );
103
107
  }
104
108
 
@@ -125,6 +129,10 @@ export class ScallopConstants {
125
129
  );
126
130
  }
127
131
 
132
+ /**
133
+ * @description
134
+ * Return maps of coin names to coin decimals.
135
+ */
128
136
  get coinDecimals() {
129
137
  if (this.isEmptyObject(this._coinDecimals)) {
130
138
  this._coinDecimals = Object.fromEntries([
@@ -139,6 +147,10 @@ export class ScallopConstants {
139
147
  return this._coinDecimals;
140
148
  }
141
149
 
150
+ /**
151
+ * @description
152
+ * Return maps of coin names to coin types.
153
+ */
142
154
  get coinTypes() {
143
155
  if (this.isEmptyObject(this._coinTypes))
144
156
  this._coinTypes = Object.fromEntries([
@@ -152,6 +164,22 @@ export class ScallopConstants {
152
164
  return this._coinTypes;
153
165
  }
154
166
 
167
+ /**
168
+ * @description
169
+ * Return maps of coin types to its coin name
170
+ */
171
+ get coinTypeToCoinNameMap() {
172
+ if (this.isEmptyObject(this._coinTypeToCoinNameMap))
173
+ this._coinTypeToCoinNameMap = Object.fromEntries(
174
+ Object.entries(this.coinTypes).map(([key, val]) => [val, key])
175
+ );
176
+ return this._coinTypeToCoinNameMap;
177
+ }
178
+
179
+ /**
180
+ * @description
181
+ * Return maps of wormhole coin types to its coin name.
182
+ */
155
183
  get wormholeCoinTypeToCoinName() {
156
184
  if (this.isEmptyObject(this._wormholeCoinTypeToCoinNameMap))
157
185
  this._wormholeCoinTypeToCoinNameMap = Object.fromEntries(
@@ -162,27 +190,10 @@ export class ScallopConstants {
162
190
  return this._wormholeCoinTypeToCoinNameMap;
163
191
  }
164
192
 
165
- get coinNameToCoinTypeMap() {
166
- if (this.isEmptyObject(this._coinNameToCoinTypeMap))
167
- this._coinNameToCoinTypeMap = Object.fromEntries(
168
- Object.entries(this.poolAddresses)
169
- .filter(([_, value]) => !!value)
170
- .map(([_, value]) => [value!.coinName, value!.coinType])
171
- );
172
- return this._coinNameToCoinTypeMap;
173
- }
174
-
175
- get coinTypeToCoinNameMap() {
176
- if (this.isEmptyObject(this._coinTypeToCoinNameMap))
177
- this._coinTypeToCoinNameMap = Object.fromEntries(
178
- Object.entries(this.coinNameToCoinTypeMap).map(([key, val]) => [
179
- val,
180
- key,
181
- ])
182
- );
183
- return this._coinTypeToCoinNameMap;
184
- }
185
-
193
+ /**
194
+ * @description
195
+ * Return maps of coin name to its old market coin type (...::reserve::MarketCoin<coinType>)
196
+ */
186
197
  get coinNameToOldMarketCoinTypeMap() {
187
198
  if (this.isEmptyObject(this._coinNameToOldMarketCoinTypeMap))
188
199
  this._coinNameToOldMarketCoinTypeMap = Object.fromEntries(
@@ -196,6 +207,10 @@ export class ScallopConstants {
196
207
  return this._coinNameToOldMarketCoinTypeMap;
197
208
  }
198
209
 
210
+ /**
211
+ * @description
212
+ * Return maps of sCoin raw name from its type to its sCoin name. (e.g. 'scallop_sui' -> 'ssui')
213
+ */
199
214
  get sCoinRawNameToScoinNameMap() {
200
215
  if (this.isEmptyObject(this._scoinRawNameToSCoinNameMap))
201
216
  this._scoinRawNameToSCoinNameMap = Object.fromEntries(
@@ -210,6 +225,10 @@ export class ScallopConstants {
210
225
  return this._scoinRawNameToSCoinNameMap;
211
226
  }
212
227
 
228
+ /**
229
+ * @description
230
+ * Return maps of scoin type to its sCoin name
231
+ */
213
232
  get sCoinTypeToSCoinNameMap() {
214
233
  if (this.isEmptyObject(this._scoinTypeToSCoinNameMap))
215
234
  this._scoinTypeToSCoinNameMap = Object.fromEntries(
@@ -221,6 +240,10 @@ export class ScallopConstants {
221
240
  return this._scoinTypeToSCoinNameMap;
222
241
  }
223
242
 
243
+ /**
244
+ * @description
245
+ * Return maps of volo coin type to its coin name
246
+ */
224
247
  get voloCoinTypeToCoinNameMap() {
225
248
  if (this.isEmptyObject(this._voloCoinTypeToCoinNameMap))
226
249
  this._voloCoinTypeToCoinNameMap = {
@@ -229,6 +252,10 @@ export class ScallopConstants {
229
252
  return this._voloCoinTypeToCoinNameMap;
230
253
  }
231
254
 
255
+ /**
256
+ * @description
257
+ * Return maps of sui bridge coin type to its coin name
258
+ */
232
259
  get suiBridgeCoinTypeToCoinNameMap() {
233
260
  if (this.isEmptyObject(this._suiBridgeCoinTypeToCoinNameMap))
234
261
  this._suiBridgeCoinTypeToCoinNameMap = Object.fromEntries(
@@ -242,6 +269,10 @@ export class ScallopConstants {
242
269
  return this._suiBridgeCoinTypeToCoinNameMap;
243
270
  }
244
271
 
272
+ /**
273
+ * @description
274
+ * Return maps of sCoin coin name to its coin type
275
+ */
245
276
  get sCoinTypes() {
246
277
  if (this.isEmptyObject(this._sCoinTypes))
247
278
  this._sCoinTypes = Object.fromEntries(
@@ -253,12 +284,20 @@ export class ScallopConstants {
253
284
  return this._sCoinTypes;
254
285
  }
255
286
 
287
+ /**
288
+ * @description
289
+ * Return set of supported coin types for borrow incentive rewards
290
+ * (all supported pools + sCoins + custom coins from `whitelist.borrowIncentiveRewards`)
291
+ */
256
292
  get supportedBorrowIncentiveRewards() {
257
- return new Set([
258
- ...Object.values(this.poolAddresses)
259
- .filter((t) => !!t)
260
- .map((t) => t?.coinName),
261
- ]);
293
+ if (!this._supportedBorrowIncentiveRewards.size)
294
+ this._supportedBorrowIncentiveRewards = new Set([
295
+ ...Object.values(this.poolAddresses)
296
+ .filter((t) => !!t)
297
+ .map((t) => (t.sCoinName ? [t.coinName, t.sCoinName] : [t.coinName]))
298
+ .flat(),
299
+ ]);
300
+ return this._supportedBorrowIncentiveRewards;
262
301
  }
263
302
 
264
303
  private isEmptyObject(obj: Record<string, unknown>) {
@@ -291,12 +330,15 @@ export class ScallopConstants {
291
330
  async readWhiteList() {
292
331
  const response = await this.readApi<Record<keyof Whitelist, string[]>>({
293
332
  url:
294
- this.params.whitelistApiUrl ?? 'https://sui.apis.scallop.io/whitelist',
333
+ this.params.whitelistApiUrl ??
334
+ `https://sui.apis.scallop.io/pool/whitelist`,
295
335
  queryKey: queryKeys.api.getWhiteList(),
296
336
  });
297
337
 
298
338
  return Object.fromEntries(
299
- Object.entries(response).map(([key, value]) => [key, new Set(value)])
339
+ Object.entries(response)
340
+ .filter(([_, value]) => Array.isArray(value))
341
+ .map(([key, value]) => [key, new Set(value)])
300
342
  ) as Whitelist;
301
343
  }
302
344
 
@@ -304,7 +346,7 @@ export class ScallopConstants {
304
346
  return await this.readApi<Record<string, PoolAddress>>({
305
347
  url:
306
348
  this.params.poolAddressesApiUrl ??
307
- `https://sui.apis.scallop.io/poolAddresses`,
349
+ `https://sui.apis.scallop.io/pool/addresses`,
308
350
  queryKey: queryKeys.api.getPoolAddresses(),
309
351
  });
310
352
  }
@@ -328,14 +370,30 @@ export class ScallopConstants {
328
370
  this.readWhiteList(),
329
371
  this.readPoolAddresses(),
330
372
  ]);
373
+
331
374
  if (!this.params.forceWhitelistInterface) {
332
- this._whitelist = whitelistResponse;
375
+ this._whitelist = Object.fromEntries(
376
+ Object.entries(whitelistResponse)
377
+ .filter(([_, value]) => Array.isArray(value) || value instanceof Set)
378
+ .map(([key, value]) => [
379
+ key as keyof Whitelist,
380
+ value instanceof Set ? value : new Set(value),
381
+ ])
382
+ ) as Whitelist;
333
383
  }
334
- if (!this.params.forcePoolAddressInterface)
384
+ if (!this.params.forcePoolAddressInterface) {
335
385
  this._poolAddresses = Object.fromEntries(
336
- Object.entries(poolAddressesResponse).filter(([key]) =>
337
- Object.values(this.whitelist).some((set) => set.has(key))
338
- )
386
+ Object.entries(poolAddressesResponse)
387
+ .filter(([key]) =>
388
+ Object.values(this.whitelist).some((set) => set.has(key))
389
+ )
390
+ .map(([key, value]) => {
391
+ const parsedValue = Object.fromEntries(
392
+ Object.entries(value).map(([k, v]) => [k, v || undefined])
393
+ );
394
+ return [key, parsedValue as PoolAddress];
395
+ })
339
396
  );
397
+ }
340
398
  }
341
399
  }
@@ -43,15 +43,9 @@ import {
43
43
  getUserPortfolio,
44
44
  getPriceUpdatePolicies,
45
45
  getAssetOracles,
46
+ getOnDemandAggObjectIds,
46
47
  } from '../queries';
47
48
  import {
48
- // string,
49
- // string,
50
- // string,
51
- // string,
52
- // string,
53
- // string,
54
- // string,
55
49
  ScallopQueryParams,
56
50
  StakePools,
57
51
  StakeRewardPools,
@@ -61,6 +55,7 @@ import {
61
55
  MarketPools,
62
56
  MarketCollaterals,
63
57
  xOracleRules,
58
+ SupportOracleType,
64
59
  } from '../types';
65
60
  import { ScallopAddress } from './scallopAddress';
66
61
  import { ScallopUtils } from './scallopUtils';
@@ -109,6 +104,7 @@ export class ScallopQuery {
109
104
 
110
105
  this.cache =
111
106
  instance?.utils?.cache ??
107
+ instance?.cache ??
112
108
  new ScallopCache(this.params, {
113
109
  suiKit: this.suiKit,
114
110
  });
@@ -173,15 +169,12 @@ export class ScallopQuery {
173
169
  * @param force - Whether to force initialization.
174
170
  * @param address - ScallopAddress instance.
175
171
  */
176
- public async init(force: boolean = false, address?: ScallopAddress) {
177
- if (address && !this.address) {
178
- this.address = address;
179
- }
180
- if (force || !this.address.getAddresses()) {
181
- await this.address.read();
172
+ public async init(force: boolean = false) {
173
+ if (force || !this.constants.isInitialized) {
174
+ await this.constants.init();
182
175
  }
183
176
 
184
- await this.utils.init(force, this.address);
177
+ await this.utils.init(force);
185
178
  }
186
179
 
187
180
  /* ==================== Core Query Methods ==================== */
@@ -913,12 +906,21 @@ export class ScallopQuery {
913
906
  return [...this.constants.whitelist.lending].reduce(
914
907
  (acc, pool) => {
915
908
  acc[pool] = {
916
- primary: primary?.[pool] ?? [],
917
- secondary: secondary?.[pool] ?? [],
909
+ primary: (primary?.[pool] ?? []) as SupportOracleType[],
910
+ secondary: (secondary?.[pool] ?? []) as SupportOracleType[],
918
911
  };
919
912
  return acc;
920
913
  },
921
914
  {} as Record<string, xOracleRules>
922
915
  );
923
916
  }
917
+
918
+ /**
919
+ * Get switchboard on-demand aggregator object id based on coinType
920
+ * @param coinType
921
+ * @returns
922
+ */
923
+ public async getSwitchboardOnDemandAggregatorObjectIds(coinName: string[]) {
924
+ return await getOnDemandAggObjectIds(this, coinName);
925
+ }
924
926
  }
@@ -67,6 +67,7 @@ export class ScallopUtils {
67
67
 
68
68
  this.cache =
69
69
  instance?.constants?.cache ??
70
+ instance?.cache ??
70
71
  new ScallopCache(this.params, {
71
72
  suiKit: this.suiKit,
72
73
  });
@@ -111,10 +112,9 @@ export class ScallopUtils {
111
112
  * @param force - Whether to force initialization.
112
113
  * @param address - ScallopAddress instance.
113
114
  */
114
- public async init(force: boolean = false, address?: ScallopAddress) {
115
- if (address && !this.address) this.address = address;
116
- if (force || !this.address.getAddresses()) {
117
- await this.address.read();
115
+ public async init(force: boolean = false) {
116
+ if (force || !this.constants.isInitialized) {
117
+ await this.constants.init();
118
118
  }
119
119
  }
120
120
 
@@ -125,7 +125,10 @@ export class ScallopUtils {
125
125
  * @return Symbol string.
126
126
  */
127
127
  public parseSymbol(coinName: string) {
128
- return this.constants.poolAddresses[coinName]?.symbol ?? '';
128
+ return this.isMarketCoin(coinName)
129
+ ? (this.constants.poolAddresses[this.parseCoinName(coinName)]
130
+ ?.sCoinSymbol ?? '')
131
+ : (this.constants.poolAddresses[coinName]?.symbol ?? '');
129
132
  }
130
133
 
131
134
  /**
@@ -143,7 +146,7 @@ export class ScallopUtils {
143
146
  if (useOldMarketCoin) {
144
147
  return this.constants.coinNameToOldMarketCoinTypeMap[coinName] ?? '';
145
148
  }
146
- return this.constants.coinNameToCoinTypeMap[coinName] ?? '';
149
+ return this.constants.coinTypes[coinName] ?? '';
147
150
  }
148
151
 
149
152
  /**
@@ -248,7 +251,10 @@ export class ScallopUtils {
248
251
 
249
252
  if (isMarketCoinType) {
250
253
  return this.parseMarketCoinName(
251
- parseStructTag(typeParams as any).name.toLowerCase()
254
+ (typeof typeParams[0] === 'string'
255
+ ? parseStructTag(typeParams[0])
256
+ : typeParams[0]
257
+ ).name.toLowerCase()
252
258
  );
253
259
  }
254
260
  const assetCoinName =
@@ -436,9 +442,9 @@ export class ScallopUtils {
436
442
  },
437
443
  [] as [string, string][]
438
444
  );
445
+ if (priceIdPairs.length === 0) break;
439
446
 
440
447
  const priceIds = priceIdPairs.map(([_, priceId]) => priceId);
441
-
442
448
  const pythConnection = new SuiPriceServiceConnection(endpoint, {
443
449
  timeout: 4000,
444
450
  });
@@ -174,8 +174,10 @@ export const queryBorrowIncentiveAccounts = async (
174
174
  const borrowIncentiveAccounts: BorrowIncentiveAccounts = Object.values(
175
175
  borrowIncentiveAccountsQueryData?.pool_records ?? []
176
176
  ).reduce((accounts, accountData) => {
177
- const parsedBorrowIncentiveAccount =
178
- parseOriginBorrowIncentiveAccountData(accountData);
177
+ const parsedBorrowIncentiveAccount = parseOriginBorrowIncentiveAccountData(
178
+ utils,
179
+ accountData
180
+ );
179
181
  const poolType = parsedBorrowIncentiveAccount.poolType;
180
182
  const coinName = utils.parseCoinNameFromType(poolType);
181
183
 
@@ -496,7 +496,7 @@ const parseMarketPoolObjects = ({
496
496
  collateralStat?: SuiObjectData;
497
497
  interestModel: SuiObjectData;
498
498
  riskModel?: SuiObjectData;
499
- borrowFeeKey: SuiObjectData;
499
+ borrowFeeKey?: SuiObjectData;
500
500
  supplyLimitKey?: SuiObjectData;
501
501
  borrowLimitKey?: SuiObjectData;
502
502
  isolatedAssetKey: SuiObjectData;
@@ -506,7 +506,9 @@ const parseMarketPoolObjects = ({
506
506
  const _balanceSheet = parseObjectAs<BalanceSheet>(balanceSheet);
507
507
  const _interestModel = parseObjectAs<InterestModel>(interestModel);
508
508
  const _borrowDynamic = parseObjectAs<BorrowDynamic>(borrowDynamic);
509
- const _borrowFee = parseObjectAs<BorrowFee>(borrowFeeKey);
509
+ const _borrowFee = borrowFeeKey
510
+ ? parseObjectAs<BorrowFee>(borrowFeeKey)
511
+ : { value: '0' };
510
512
  const _supplyLimit = supplyLimitKey
511
513
  ? parseObjectAs<string>(supplyLimitKey)
512
514
  : '0';
@@ -12,4 +12,5 @@ export * from './vescaQuery';
12
12
  export * from './borrowLimitQuery';
13
13
  export * from './poolAddressesQuery';
14
14
  export * from './objectsQuery';
15
+ export * from './switchboardQuery';
15
16
  export * from './xOracleQuery';
@@ -188,7 +188,10 @@ export const getPoolAddresses = async (
188
188
  const { symbol, metaData: coinMetadataId } =
189
189
  addressApiResponse.core.coins[coinName];
190
190
 
191
- let spoolData = undefined;
191
+ let spoolData = {
192
+ spool: '',
193
+ spoolReward: '',
194
+ };
192
195
  const _spoolData = addressApiResponse.spool.pools[`s${coinName}`];
193
196
  // @ts-ignore
194
197
  if (_spoolData) {
@@ -197,11 +200,15 @@ export const getPoolAddresses = async (
197
200
  spoolData = {
198
201
  spool,
199
202
  spoolReward,
200
- coinMetadataId,
201
203
  };
202
204
  }
203
205
 
204
- let sCoinData = undefined;
206
+ let sCoinData = {
207
+ sCoinType: '',
208
+ sCoinTreasury: '',
209
+ sCoinMetadataId: '',
210
+ sCoinSymbol: '',
211
+ };
205
212
  const sCoinName = `s${coinName}`;
206
213
  const _sCoinData = addressApiResponse.scoin.coins[sCoinName];
207
214
  if (_sCoinData) {
@@ -219,7 +226,21 @@ export const getPoolAddresses = async (
219
226
  };
220
227
  }
221
228
 
222
- const { feed: pythFeed, feedObject: pythFeedObjectId } =
229
+ let pythData = {
230
+ pythFeed: '',
231
+ pythFeedObjectId: '',
232
+ };
233
+
234
+ if (addressApiResponse.core.coins[coinName]?.oracle.pyth) {
235
+ const { feed: pythFeed, feedObject: pythFeedObjectId } =
236
+ //@ts-ignore
237
+ addressApiResponse.core.coins[coinName].oracle.pyth;
238
+ pythData = {
239
+ pythFeed,
240
+ pythFeedObjectId,
241
+ };
242
+ }
243
+ const { feed: _pythFeed, feedObject: _pythFeedObjectId } =
223
244
  //@ts-ignore
224
245
  addressApiResponse.core.coins[coinName].oracle.pyth;
225
246
 
@@ -233,7 +254,6 @@ export const getPoolAddresses = async (
233
254
  )?.decimals ?? 0;
234
255
  const spoolName = spoolData ? `s${coinName}` : undefined;
235
256
 
236
- // @TODO: add query for flashloanFeeObject
237
257
  results[coinName] = {
238
258
  coinName,
239
259
  symbol,
@@ -243,18 +263,17 @@ export const getPoolAddresses = async (
243
263
  interestModel: addresses[3] ?? '',
244
264
  riskModel: addresses[4],
245
265
  borrowFeeKey: addresses[5] ?? '',
246
- supplyLimitKey: addresses[6],
247
- borrowLimitKey: addresses[7],
248
- isolatedAssetKey: addresses[8],
249
- ...(spoolData ?? {}),
250
- ...(sCoinData ?? {}),
266
+ supplyLimitKey: addresses[6] ?? '',
267
+ borrowLimitKey: addresses[7] ?? '',
268
+ isolatedAssetKey: addresses[8] ?? '',
269
+ ...spoolData,
270
+ ...sCoinData,
251
271
  sCoinName,
252
272
  coinMetadataId,
253
273
  coinType,
254
274
  spoolName,
255
275
  decimals,
256
- pythFeed,
257
- pythFeedObjectId,
276
+ ...pythData,
258
277
  flashloanFeeObject: flashloanFeeObjectIds[coinType] ?? '',
259
278
  };
260
279
 
@@ -42,9 +42,7 @@ export const getLendings = async (
42
42
  query.utils.parseMarketCoinName(poolCoinName)
43
43
  );
44
44
  const stakeMarketCoinNames = marketCoinNames.filter((marketCoinName) =>
45
- ([...query.constants.whitelist.spool] as readonly string[]).includes(
46
- marketCoinName
47
- )
45
+ query.constants.whitelist.spool.has(marketCoinName)
48
46
  ) as string[];
49
47
 
50
48
  coinPrices = coinPrices ?? (await query.utils.getCoinPrices());
@@ -139,10 +137,7 @@ export const getLending = async (
139
137
  throw new Error(`Failed to fetch marketPool for ${poolCoinName}`);
140
138
 
141
139
  spool =
142
- (spool ??
143
- ([...query.constants.whitelist.spool] as readonly string[]).includes(
144
- marketCoinName
145
- ))
140
+ (spool ?? query.constants.whitelist.spool.has(marketCoinName))
146
141
  ? await query.getSpool(marketCoinName as string, {
147
142
  indexer,
148
143
  marketPool,
@@ -155,10 +150,7 @@ export const getLending = async (
155
150
  // if (!spool) throw new Error(`Failed to fetch spool for ${poolCoinName}`);
156
151
 
157
152
  stakeAccounts =
158
- stakeAccounts ||
159
- ([...query.constants.whitelist.spool] as readonly string[]).includes(
160
- marketCoinName
161
- )
153
+ stakeAccounts || query.constants.whitelist.spool.has(marketCoinName)
162
154
  ? await query.getStakeAccounts(marketCoinName as string, ownerAddress)
163
155
  : [];
164
156
  coinAmount =
@@ -549,7 +541,6 @@ export const getObligationAccount = async (
549
541
  borrowIncentivePool.points[
550
542
  query.utils.parseSCoinTypeNameToMarketCoinName(key)
551
543
  ];
552
-
553
544
  if (accountPoint && poolPoint) {
554
545
  let availableClaimAmount = BigNumber(0);
555
546
  let availableClaimCoin = BigNumber(0);
@@ -599,6 +590,7 @@ export const getObligationAccount = async (
599
590
  symbol: poolPoint.symbol,
600
591
  coinDecimal: poolPoint.coinDecimal,
601
592
  coinPrice: poolPoint.coinPrice,
593
+ weightedBorrowAmount: accountBorrowedAmount.toNumber(),
602
594
  availableClaimAmount: availableClaimAmount.toNumber(),
603
595
  availableClaimCoin: availableClaimCoin.toNumber(),
604
596
  boostValue,