@scallop-io/sui-scallop-sdk 0.46.47 → 0.46.48

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.
@@ -14,7 +14,7 @@ export type SpoolNormalMethods = {
14
14
  };
15
15
  export type SpoolQuickMethods = {
16
16
  stakeQuick(amountOrMarketCoin: SuiObjectArg | number, stakeMarketCoinName: SupportStakeMarketCoins, stakeAccountId?: SuiAddressArg): Promise<void>;
17
- unstakeQuick(amount: number, stakeMarketCoinName: SupportStakeMarketCoins, stakeAccountId?: SuiAddressArg): Promise<TransactionResult | undefined>;
17
+ unstakeQuick(amount: number, stakeMarketCoinName: SupportStakeMarketCoins, stakeAccountId?: SuiAddressArg, returnSCoin?: boolean): Promise<TransactionResult | undefined>;
18
18
  claimQuick(stakeMarketCoinName: SupportStakeMarketCoins, stakeAccountId?: SuiAddressArg): Promise<TransactionResult[]>;
19
19
  };
20
20
  export type SuiTxBlockWithSpoolNormalMethods = SuiKitTxBlock & SuiTxBlockWithSCoin & SpoolNormalMethods;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scallop-io/sui-scallop-sdk",
3
- "version": "0.46.47",
3
+ "version": "0.46.48",
4
4
  "description": "Typescript sdk for interacting with Scallop contract on SUI",
5
5
  "keywords": [
6
6
  "sui",
@@ -249,14 +249,19 @@ const generateSpoolQuickMethod: GenerateSpoolQuickMethod = ({
249
249
  );
250
250
  }
251
251
  },
252
- unstakeQuick: async (amount, stakeMarketCoinName, stakeAccountId) => {
252
+ unstakeQuick: async (
253
+ amount,
254
+ stakeMarketCoinName,
255
+ stakeAccountId,
256
+ returnSCoin = true
257
+ ) => {
253
258
  const stakeAccounts = await requireStakeAccounts(
254
259
  builder,
255
260
  txBlock,
256
261
  stakeMarketCoinName,
257
262
  stakeAccountId
258
263
  );
259
- const sCoins: TransactionResult[] = [];
264
+ const toTransfer: TransactionResult[] = [];
260
265
  for (const account of stakeAccounts) {
261
266
  if (account.staked === 0) continue;
262
267
  const amountToUnstake = Math.min(amount, account.staked);
@@ -267,33 +272,56 @@ const generateSpoolQuickMethod: GenerateSpoolQuickMethod = ({
267
272
  );
268
273
 
269
274
  // convert to new sCoin
270
- const sCoin = txBlock.mintSCoin(stakeMarketCoinName, marketCoin);
271
- sCoins.push(sCoin);
275
+ if (returnSCoin) {
276
+ const sCoin = txBlock.mintSCoin(stakeMarketCoinName, marketCoin);
277
+ toTransfer.push(sCoin);
278
+ } else {
279
+ toTransfer.push(marketCoin);
280
+ }
281
+
272
282
  amount -= amountToUnstake;
273
283
  if (amount === 0) break;
274
284
  }
275
285
 
276
- if (sCoins.length > 0) {
277
- const mergedSCoin = sCoins[0];
286
+ if (toTransfer.length > 0) {
287
+ const mergedCoin = toTransfer[0];
278
288
 
279
- if (sCoins.length > 1) {
280
- txBlock.mergeCoins(mergedSCoin, sCoins.slice(1));
289
+ if (toTransfer.length > 1) {
290
+ txBlock.mergeCoins(mergedCoin, toTransfer.slice(1));
281
291
  }
282
- // check for existing sCoins
283
- try {
284
- const existingCoins = await builder.utils.selectCoins(
285
- Number.MAX_SAFE_INTEGER,
286
- builder.utils.parseSCoinType(stakeMarketCoinName),
287
- requireSender(txBlock)
288
- );
289
292
 
290
- if (existingCoins.length > 0) {
291
- txBlock.mergeCoins(mergedSCoin, existingCoins);
293
+ if (returnSCoin) {
294
+ // check for existing sCoins
295
+ try {
296
+ const existingCoins = await builder.utils.selectCoins(
297
+ Number.MAX_SAFE_INTEGER,
298
+ builder.utils.parseSCoinType(stakeMarketCoinName),
299
+ requireSender(txBlock)
300
+ );
301
+
302
+ if (existingCoins.length > 0) {
303
+ txBlock.mergeCoins(mergedCoin, existingCoins);
304
+ }
305
+ } catch (e) {
306
+ // ignore
307
+ }
308
+ } else {
309
+ // check for existing market coins
310
+ try {
311
+ const existingCoins = await builder.utils.selectCoins(
312
+ Number.MAX_SAFE_INTEGER,
313
+ builder.utils.parseMarketCoinType(stakeMarketCoinName),
314
+ requireSender(txBlock)
315
+ );
316
+
317
+ if (existingCoins.length > 0) {
318
+ txBlock.mergeCoins(mergedCoin, existingCoins);
319
+ }
320
+ } catch (e) {
321
+ // ignore
292
322
  }
293
- } catch (e) {
294
- // ignore
295
323
  }
296
- return mergedSCoin;
324
+ return mergedCoin;
297
325
  }
298
326
  },
299
327
  claimQuick: async (stakeMarketCoinName, stakeAccountId) => {
@@ -42,7 +42,8 @@ export type SpoolQuickMethods = {
42
42
  unstakeQuick(
43
43
  amount: number,
44
44
  stakeMarketCoinName: SupportStakeMarketCoins,
45
- stakeAccountId?: SuiAddressArg
45
+ stakeAccountId?: SuiAddressArg,
46
+ returnSCoin?: boolean
46
47
  ): Promise<TransactionResult | undefined>;
47
48
  claimQuick(
48
49
  stakeMarketCoinName: SupportStakeMarketCoins,