@scallop-io/sui-scallop-sdk 0.46.58 → 0.46.60

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": "0.46.58",
3
+ "version": "0.46.60",
4
4
  "description": "Typescript sdk for interacting with Scallop contract on SUI",
5
5
  "keywords": [
6
6
  "sui",
@@ -341,47 +341,44 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
341
341
  try {
342
342
  const sCoinName = builder.utils.parseSCoinName(poolCoinName);
343
343
  if (!sCoinName) throw new Error(`No sCoin for ${poolCoinName}`);
344
- const { leftCoin, takeCoin, totalAmount } = await builder.selectSCoin(
345
- txBlock,
346
- sCoinName,
347
- amount,
348
- sender
349
- );
344
+ const {
345
+ leftCoin,
346
+ takeCoin: sCoins,
347
+ totalAmount,
348
+ } = await builder.selectSCoin(txBlock, sCoinName, amount, sender);
350
349
  txBlock.transferObjects([leftCoin], sender);
351
- const marketCoin = txBlock.burnSCoin(sCoinName, takeCoin);
352
-
353
- const txResult = txBlock.withdraw(marketCoin, poolCoinName);
350
+ const marketCoins = txBlock.burnSCoin(sCoinName, sCoins);
354
351
 
355
352
  // check amount
356
353
  amount -= totalAmount;
357
354
  try {
358
355
  if (amount > 0) {
359
356
  // sCoin is not enough, try market coin
360
- const { leftCoin, takeCoin } = await builder.selectMarketCoin(
361
- txBlock,
362
- marketCoinName,
363
- amount,
364
- sender
365
- );
357
+ const { leftCoin, takeCoin: walletMarketCoins } =
358
+ await builder.selectMarketCoin(
359
+ txBlock,
360
+ marketCoinName,
361
+ amount,
362
+ sender
363
+ );
366
364
  txBlock.transferObjects([leftCoin], sender);
367
- txBlock.mergeCoins(txResult, [
368
- txBlock.withdraw(takeCoin, poolCoinName),
369
- ]);
365
+ txBlock.mergeCoins(marketCoins, [walletMarketCoins]);
370
366
  }
371
367
  } catch (e) {
372
368
  // ignore
373
369
  }
374
- return txResult;
370
+ return txBlock.withdraw(marketCoins, poolCoinName);
375
371
  } catch (e) {
376
372
  // no sCoin found
377
- const { leftCoin, takeCoin } = await builder.selectMarketCoin(
378
- txBlock,
379
- marketCoinName,
380
- amount,
381
- sender
382
- );
373
+ const { leftCoin, takeCoin: walletMarketCoins } =
374
+ await builder.selectMarketCoin(
375
+ txBlock,
376
+ marketCoinName,
377
+ amount,
378
+ sender
379
+ );
383
380
  txBlock.transferObjects([leftCoin], sender);
384
- return txBlock.withdraw(takeCoin, poolCoinName);
381
+ return txBlock.withdraw(walletMarketCoins, poolCoinName);
385
382
  }
386
383
  },
387
384
  borrowQuick: async (amount, poolCoinName, obligationId, obligationKey) => {