@scallop-io/sui-scallop-sdk 1.5.0 → 1.5.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scallop-io/sui-scallop-sdk",
3
- "version": "1.5.0",
3
+ "version": "1.5.2",
4
4
  "description": "Typescript sdk for interacting with Scallop contract on SUI",
5
5
  "keywords": [
6
6
  "sui",
@@ -297,7 +297,7 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
297
297
 
298
298
  if (collateralCoinName === 'sui') {
299
299
  const [suiCoin] = txBlock.splitSUIFromGas([amount]);
300
- await txBlock.addCollateral(obligationArg, suiCoin, collateralCoinName);
300
+ txBlock.addCollateral(obligationArg, suiCoin, collateralCoinName);
301
301
  } else {
302
302
  const { leftCoin, takeCoin } = await builder.selectCoin(
303
303
  txBlock,
@@ -305,11 +305,7 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
305
305
  amount,
306
306
  sender
307
307
  );
308
- await txBlock.addCollateral(
309
- obligationArg,
310
- takeCoin,
311
- collateralCoinName
312
- );
308
+ txBlock.addCollateral(obligationArg, takeCoin, collateralCoinName);
313
309
  txBlock.transferObjects([leftCoin], sender);
314
310
  }
315
311
  },
@@ -329,7 +325,7 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
329
325
  obligationInfo.obligationId
330
326
  );
331
327
  await updateOracles(builder, txBlock, updateCoinNames);
332
- return await txBlock.takeCollateral(
328
+ return txBlock.takeCollateral(
333
329
  obligationInfo.obligationId,
334
330
  obligationInfo.obligationKey as SuiObjectArg,
335
331
  amount,
@@ -341,7 +337,7 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
341
337
  let marketCoinDeposit: TransactionResult | undefined;
342
338
  if (poolCoinName === 'sui') {
343
339
  const [suiCoin] = txBlock.splitSUIFromGas([amount]);
344
- marketCoinDeposit = await txBlock.deposit(suiCoin, poolCoinName);
340
+ marketCoinDeposit = txBlock.deposit(suiCoin, poolCoinName);
345
341
  } else {
346
342
  const { leftCoin, takeCoin } = await builder.selectCoin(
347
343
  txBlock,
@@ -350,12 +346,12 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
350
346
  sender
351
347
  );
352
348
  txBlock.transferObjects([leftCoin], sender);
353
- marketCoinDeposit = await txBlock.deposit(takeCoin, poolCoinName);
349
+ marketCoinDeposit = txBlock.deposit(takeCoin, poolCoinName);
354
350
  }
355
351
 
356
352
  // convert to sCoin
357
353
  return returnSCoin
358
- ? await txBlock.mintSCoin(
354
+ ? txBlock.mintSCoin(
359
355
  builder.utils.parseMarketCoinName(poolCoinName),
360
356
  marketCoinDeposit
361
357
  )
@@ -375,7 +371,7 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
375
371
  totalAmount,
376
372
  } = await builder.selectSCoin(txBlock, sCoinName, amount, sender);
377
373
  txBlock.transferObjects([leftCoin], sender);
378
- const marketCoins = await txBlock.burnSCoin(sCoinName, sCoins);
374
+ const marketCoins = txBlock.burnSCoin(sCoinName, sCoins);
379
375
 
380
376
  // check amount
381
377
  amount -= totalAmount;
@@ -406,7 +402,7 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
406
402
  sender
407
403
  );
408
404
  txBlock.transferObjects([leftCoin], sender);
409
- return await txBlock.withdraw(walletMarketCoins, poolCoinName);
405
+ return txBlock.withdraw(walletMarketCoins, poolCoinName);
410
406
  }
411
407
  },
412
408
  borrowQuick: async (amount, poolCoinName, obligationId, obligationKey) => {
@@ -466,7 +462,7 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
466
462
 
467
463
  if (poolCoinName === 'sui') {
468
464
  const [suiCoin] = txBlock.splitSUIFromGas([amount]);
469
- return await txBlock.repay(
465
+ return txBlock.repay(
470
466
  obligationInfo.obligationId,
471
467
  suiCoin,
472
468
  poolCoinName
@@ -479,7 +475,7 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
479
475
  sender
480
476
  );
481
477
  txBlock.transferObjects([leftCoin], sender);
482
- return await txBlock.repay(
478
+ return txBlock.repay(
483
479
  obligationInfo.obligationId,
484
480
  takeCoin,
485
481
  poolCoinName
@@ -14,7 +14,7 @@ import type {
14
14
  xOracleRuleType,
15
15
  } from '../types';
16
16
  import { PYTH_ENDPOINTS } from 'src/constants/pyth';
17
- import { xOracleList } from 'src/constants';
17
+ import { xOracleList as X_ORACLE_LIST } from 'src/constants';
18
18
 
19
19
  /**
20
20
  * Update the price of the oracle for multiple coin.
@@ -32,10 +32,18 @@ export const updateOracles = async (
32
32
  ],
33
33
  options: {
34
34
  usePythPullModel: boolean;
35
- } = { usePythPullModel: true }
35
+ useOnChainXOracleList: boolean;
36
+ } = { usePythPullModel: true, useOnChainXOracleList: true }
36
37
  ) => {
37
38
  const usePythPullModel =
38
39
  builder.params.usePythPullModel ?? options.usePythPullModel;
40
+ const useOnChainXOracleList =
41
+ builder.params.useOnChainXOracleList ?? options.useOnChainXOracleList;
42
+
43
+ const xOracleList = useOnChainXOracleList
44
+ ? await builder.query.getAssetOracles()
45
+ : X_ORACLE_LIST;
46
+
39
47
  // const rules: SupportOracleType[] = builder.isTestnet ? ['pyth'] : ['pyth'];
40
48
  const flattenedRules: SupportOracleType[] = [
41
49
  ...new Set(
@@ -203,12 +203,9 @@ export const voloCoinIds: types.VoloCoinIds = {
203
203
  vsui: '0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55',
204
204
  };
205
205
 
206
- // PROD VERSION
207
206
  export const sCoinIds: types.SCoinIds = {
208
- // ssui: '0xaafc4f740de0dd0dde642a31148fb94517087052f19afb0f7bed1dc41a50c77b::scallop_sui::SCALLOP_SUI', // @TODO: restore on prod
209
- ssui: '0x88618204de2dfdc2597681a8441ee726b0dc13494c41e319c3264eb7b35fea90::scallop_sui::SCALLOP_SUI',
210
- // ssca: '0x5ca17430c1d046fae9edeaa8fd76c7b4193a00d764a0ecfa9418d733ad27bc1e::scallop_sca::SCALLOP_SCA', // @TODO: restore on prod
211
- ssca: '0x9f64a180373a6b66595025ae16a4ab701f0af1dd5c7ce1ac91dc112e52c2a3f8::scallop_sca::SCALLOP_SCA',
207
+ ssui: '0xaafc4f740de0dd0dde642a31148fb94517087052f19afb0f7bed1dc41a50c77b::scallop_sui::SCALLOP_SUI',
208
+ ssca: '0x5ca17430c1d046fae9edeaa8fd76c7b4193a00d764a0ecfa9418d733ad27bc1e::scallop_sca::SCALLOP_SCA',
212
209
  scetus:
213
210
  '0xea346ce428f91ab007210443efcea5f5cdbbb3aae7e9affc0ca93f9203c31f0c::scallop_cetus::SCALLOP_CETUS',
214
211
  smusd:
@@ -230,8 +227,7 @@ export const sCoinIds: types.SCoinIds = {
230
227
  '0xe1a1cc6bcf0001a015eab84bcc6713393ce20535f55b8b6f35c142e057a25fbe::scallop_v_sui::SCALLOP_V_SUI',
231
228
  // stable coins
232
229
  susdc:
233
- // '0x854950aa624b1df59fe64e630b2ba7c550642e9342267a33061d59fb31582da5::scallop_usdc::SCALLOP_USDC', // @TODO: restore on prod
234
- '0x55ed015f9f006c0c96ad36ebe3b3570d088e8498f52defea48e5634c110e485c::scallop_usdc::SCALLOP_USDC',
230
+ '0x854950aa624b1df59fe64e630b2ba7c550642e9342267a33061d59fb31582da5::scallop_usdc::SCALLOP_USDC',
235
231
  swusdc:
236
232
  '0xad4d71551d31092230db1fd482008ea42867dbf27b286e9c70a79d2a6191d58d::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC',
237
233
  swusdt:
@@ -242,10 +238,8 @@ export const sCoinIds: types.SCoinIds = {
242
238
  '0xd285cbbf54c87fd93cd15227547467bb3e405da8bbf2ab99f83f323f88ac9a65::scallop_usdy::SCALLOP_USDY',
243
239
  // isolated assets
244
240
  sdeep:
245
- // '0xeb7a05a3224837c5e5503575aed0be73c091d1ce5e43aa3c3e716e0ae614608f::scallop_deep::SCALLOP_DEEP', // @TODO: restore on prod
246
- '0x34f0a2e793e1f79ceac72cfe3bb95f65541da449418289ccd12922d16140c882::scallop_deep::SCALLOP_DEEP',
247
- // sfud: '0xe56d5167f427cbe597da9e8150ef5c337839aaf46891d62468dcf80bdd8e10d1::scallop_fud::SCALLOP_FUD', // @TODO: restore on prod
248
- sfud: '0x3b23c05f917052255a0b16a534dbd4446911aa4a30bd3497cdf5b736551e7ef8::scallop_fud::SCALLOP_FUD',
241
+ '0xeb7a05a3224837c5e5503575aed0be73c091d1ce5e43aa3c3e716e0ae614608f::scallop_deep::SCALLOP_DEEP',
242
+ sfud: '0xe56d5167f427cbe597da9e8150ef5c337839aaf46891d62468dcf80bdd8e10d1::scallop_fud::SCALLOP_FUD',
249
243
  sblub:
250
244
  '0xe72f65446eabfad2103037af2d49d24599106fb44bf4c046c1e7e9acf6844dd0::scallop_blub::SCALLOP_BLUB',
251
245
  // Sui bridge assets
@@ -272,49 +266,3 @@ export const sCoinRawNameToName = Object.entries(sCoinIds).reduce(
272
266
  },
273
267
  {} as Record<string, types.SupportSCoin>
274
268
  );
275
-
276
- // TEST VERSION
277
- // export const sCoinIds: types.SCoinIds = {
278
- // ssui: '0xf569919046f19a0c40b519ecfbb6ca0319698cd5908716c29b62ef56541f298b::scallop_sui::SCALLOP_SUI',
279
- // swusdt: '0xac781d9f73058ff5e69f9bf8dde32f2e8c71c66d7fe8497fc83b2d9182254b22::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT',
280
- // swusdc: '0xf5447c4305a486d8c8557559887c2c39449ddb5e748f15d33946d02a1663c158::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC',
281
- // ssca: '0x958428555e778e55918a59eb1c92c77f32b5c554fa3a5e56cd0815086b5072e7::scallop_sca::SCALLOP_SCA',
282
- // } as const;
283
-
284
- // export const sCoinTreasuryCaps: types.SCoinTreasuryCaps = {
285
- // ssui: '0xd2c65de0495a060114c6ecc45f5573b8a4519e9538b93075aa2116e94209db55',
286
- // scetus: '0x24ba523450908240698628d554d910ed9aba6ff6c73ad735ee571cebd833fc4c',
287
- // ssca: '0xda98f336dd1d5827bfaee0fda75c9618d4c730df79623baca7b13037b514643d',
288
- // swusdc: '0xd74d585df52333ac463746225b2ae1a48d7f6b037ee97dd43f746e0f6b6a4723',
289
- // swusdt: '0x7bc99da1e37d838c49b018ed061f115d26c364a6b1a25059aebb372dfadba753',
290
- // sweth: '0xc2a793057fffb91be6cb026cd35e1fc51d5fdd9fae73d2c1cde19ddde0463c2d',
291
- // safsui: '0x20df47fa386c9948e255072df3f4e79e32921846770a0d2e01eb4336b5581aa9',
292
- // shasui: '0x5bb658edbd3f905494862e4b69101922fb3bea9ac5b035c32e66ec3ee1f4e685',
293
- // svsui: '0x3718f9350999e8be4c20064eaf874f470de4f36e3a7ca580fcd94d640a128936',
294
- // };
295
-
296
- // PROD VERSION
297
- // export const sCoinConverterTreasury: types.SCoinConverterTreasury = {
298
- // ssui: '0x5fe57239383098ef93f75912b145e5937a1b3fc78451c78bb1964bc8c4189d5c',
299
- // scetus: '0x065ab504806e2a013308de3d60940d9550d39ef83c8a3882f5cbc9019388eeee',
300
- // ssca: '0xa9aa774956ec3ee0cafef4084e16e37aacd15564f6e6eb646a63bd96cb959b27',
301
- // swusdc: '0x2081a7fe4847aef473729bd6755686a7f232db46a2ff1be187fca961a6767363',
302
- // swusdt: '0xc19b204eee6306c794d4d8c1b02b6f58862a52d2cdfc2f580131abd967292450',
303
- // sweth: '0x0517d6380ff1687faf0385ccf758c815f114399e408d8b761fbcac4a3bf32495',
304
- // safsui: '0x088d0c107a29f250ead75e561a0f5039397da69fffd09392b33939ddc191cd31',
305
- // shasui: '0xa883cc4c09d51d3c3713124efce616a343a1158d3430cb42147488321db22fcf',
306
- // svsui: '0x8bd37d8aee69f17c5bb54c77d0d40ff6020b7b4a2c295ed455a79f72fb1c07e7',
307
- // };
308
-
309
- // TEST VERSION
310
- // export const sCoinConverterTreasury: types.SCoinConverterTreasury = {
311
- // ssui: '0x9cb4551b36c17d37e19d700147fa819ea1c487ff8bcf18374de2cceb2e9d4845',
312
- // scetus: '0xd786f4b2d26278cc7911a3445b1b085eab60f269ef9dbb6b87e803d52f155003',
313
- // ssca: '0xe818636d1d6c46d6ea1a2dce9d94696d7cbc18ce27451b603eeaa47aba8d75e0',
314
- // swusdc: '0xfc6971648f867f7fd6928d1b873af71577e2eaf2c7543ef8bc82c431d833ae78',
315
- // swusdt: '0xb9593e2c3a0ba796ee815012b75ae46468ea78cda0188b9ac6816efe65503521',
316
- // sweth: '0x032b4c8fac94c038dbe986f7587e9b1e4ef580b5ee06d2ef249d85459b7ef05d',
317
- // safsui: '0x21450ef0570ef3d224ffa3b873ab802e439ece7b93cc7efad10ae0c1e3b3fcfe',
318
- // shasui: '0xf822fc1402207e47d2e3ba8ff6e1e594bf1de777dc5ebd2744619cd2726e3b0d',
319
- // svsui: '0x327114f0bf3559d7e2de10282147ed76a236c7c6775029165c4db09a6062ead6',
320
- // };