@scallop-io/sui-scallop-sdk 0.46.46 → 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.
- package/dist/index.js +66 -38
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +66 -38
- package/dist/index.mjs.map +1 -1
- package/dist/types/builder/spool.d.ts +1 -1
- package/package.json +1 -1
- package/src/builders/spoolBuilder.ts +50 -20
- package/src/models/scallopClient.ts +32 -24
- package/src/types/builder/spool.ts +3 -2
package/dist/index.mjs
CHANGED
|
@@ -5798,14 +5798,14 @@ var generateSpoolQuickMethod = ({
|
|
|
5798
5798
|
);
|
|
5799
5799
|
}
|
|
5800
5800
|
},
|
|
5801
|
-
unstakeQuick: async (amount, stakeMarketCoinName, stakeAccountId) => {
|
|
5801
|
+
unstakeQuick: async (amount, stakeMarketCoinName, stakeAccountId, returnSCoin = true) => {
|
|
5802
5802
|
const stakeAccounts = await requireStakeAccounts(
|
|
5803
5803
|
builder,
|
|
5804
5804
|
txBlock,
|
|
5805
5805
|
stakeMarketCoinName,
|
|
5806
5806
|
stakeAccountId
|
|
5807
5807
|
);
|
|
5808
|
-
const
|
|
5808
|
+
const toTransfer = [];
|
|
5809
5809
|
for (const account of stakeAccounts) {
|
|
5810
5810
|
if (account.staked === 0)
|
|
5811
5811
|
continue;
|
|
@@ -5815,28 +5815,48 @@ var generateSpoolQuickMethod = ({
|
|
|
5815
5815
|
amountToUnstake,
|
|
5816
5816
|
stakeMarketCoinName
|
|
5817
5817
|
);
|
|
5818
|
-
|
|
5819
|
-
|
|
5818
|
+
if (returnSCoin) {
|
|
5819
|
+
const sCoin = txBlock.mintSCoin(stakeMarketCoinName, marketCoin);
|
|
5820
|
+
toTransfer.push(sCoin);
|
|
5821
|
+
} else {
|
|
5822
|
+
toTransfer.push(marketCoin);
|
|
5823
|
+
}
|
|
5820
5824
|
amount -= amountToUnstake;
|
|
5821
5825
|
if (amount === 0)
|
|
5822
5826
|
break;
|
|
5823
5827
|
}
|
|
5824
|
-
|
|
5825
|
-
|
|
5826
|
-
|
|
5827
|
-
|
|
5828
|
-
try {
|
|
5829
|
-
const existingCoins = await builder.utils.selectCoins(
|
|
5830
|
-
Number.MAX_SAFE_INTEGER,
|
|
5831
|
-
builder.utils.parseSCoinType(stakeMarketCoinName),
|
|
5832
|
-
requireSender(txBlock)
|
|
5833
|
-
);
|
|
5834
|
-
if (existingCoins.length > 0) {
|
|
5835
|
-
txBlock.mergeCoins(mergedSCoin, existingCoins);
|
|
5828
|
+
if (toTransfer.length > 0) {
|
|
5829
|
+
const mergedCoin = toTransfer[0];
|
|
5830
|
+
if (toTransfer.length > 1) {
|
|
5831
|
+
txBlock.mergeCoins(mergedCoin, toTransfer.slice(1));
|
|
5836
5832
|
}
|
|
5837
|
-
|
|
5833
|
+
if (returnSCoin) {
|
|
5834
|
+
try {
|
|
5835
|
+
const existingCoins = await builder.utils.selectCoins(
|
|
5836
|
+
Number.MAX_SAFE_INTEGER,
|
|
5837
|
+
builder.utils.parseSCoinType(stakeMarketCoinName),
|
|
5838
|
+
requireSender(txBlock)
|
|
5839
|
+
);
|
|
5840
|
+
if (existingCoins.length > 0) {
|
|
5841
|
+
txBlock.mergeCoins(mergedCoin, existingCoins);
|
|
5842
|
+
}
|
|
5843
|
+
} catch (e) {
|
|
5844
|
+
}
|
|
5845
|
+
} else {
|
|
5846
|
+
try {
|
|
5847
|
+
const existingCoins = await builder.utils.selectCoins(
|
|
5848
|
+
Number.MAX_SAFE_INTEGER,
|
|
5849
|
+
builder.utils.parseMarketCoinType(stakeMarketCoinName),
|
|
5850
|
+
requireSender(txBlock)
|
|
5851
|
+
);
|
|
5852
|
+
if (existingCoins.length > 0) {
|
|
5853
|
+
txBlock.mergeCoins(mergedCoin, existingCoins);
|
|
5854
|
+
}
|
|
5855
|
+
} catch (e) {
|
|
5856
|
+
}
|
|
5857
|
+
}
|
|
5858
|
+
return mergedCoin;
|
|
5838
5859
|
}
|
|
5839
|
-
return mergedSCoin;
|
|
5840
5860
|
},
|
|
5841
5861
|
claimQuick: async (stakeMarketCoinName, stakeAccountId) => {
|
|
5842
5862
|
const stakeAccountIds = await requireStakeAccountIds(
|
|
@@ -7270,8 +7290,10 @@ var ScallopClient = class {
|
|
|
7270
7290
|
stakeAccountId
|
|
7271
7291
|
);
|
|
7272
7292
|
const stakeCoinName = this.utils.parseCoinName(stakeMarketCoinName);
|
|
7273
|
-
|
|
7274
|
-
|
|
7293
|
+
if (stakeMarketCoin) {
|
|
7294
|
+
const coin = txBlock.withdraw(stakeMarketCoin, stakeCoinName);
|
|
7295
|
+
txBlock.transferObjects([coin], sender);
|
|
7296
|
+
}
|
|
7275
7297
|
if (sign) {
|
|
7276
7298
|
return await this.suiKit.signAndSendTxn(
|
|
7277
7299
|
txBlock
|
|
@@ -7386,6 +7408,7 @@ var ScallopClient = class {
|
|
|
7386
7408
|
const toTransfer = [];
|
|
7387
7409
|
await Promise.all(
|
|
7388
7410
|
SUPPORT_SCOIN.map(async (sCoinName) => {
|
|
7411
|
+
const sCoins2 = [];
|
|
7389
7412
|
let toDestroyMarketCoin;
|
|
7390
7413
|
try {
|
|
7391
7414
|
const marketCoins2 = await this.utils.selectCoins(
|
|
@@ -7403,23 +7426,6 @@ var ScallopClient = class {
|
|
|
7403
7426
|
if (!errMsg.includes("No valid coins found for the transaction"))
|
|
7404
7427
|
throw e;
|
|
7405
7428
|
}
|
|
7406
|
-
if (SUPPORT_SPOOLS.includes(sCoinName)) {
|
|
7407
|
-
try {
|
|
7408
|
-
const stakedMarketCoin = await txBlock.unstakeQuick(
|
|
7409
|
-
Number.MAX_SAFE_INTEGER,
|
|
7410
|
-
sCoinName
|
|
7411
|
-
);
|
|
7412
|
-
if (toDestroyMarketCoin) {
|
|
7413
|
-
txBlock.mergeCoins(toDestroyMarketCoin, [stakedMarketCoin]);
|
|
7414
|
-
} else {
|
|
7415
|
-
toDestroyMarketCoin = stakedMarketCoin;
|
|
7416
|
-
}
|
|
7417
|
-
} catch (e) {
|
|
7418
|
-
const errMsg = e.toString();
|
|
7419
|
-
if (!errMsg.includes("No stake account found"))
|
|
7420
|
-
throw e;
|
|
7421
|
-
}
|
|
7422
|
-
}
|
|
7423
7429
|
if (toDestroyMarketCoin) {
|
|
7424
7430
|
const sCoin = txBlock.mintSCoin(
|
|
7425
7431
|
sCoinName,
|
|
@@ -7441,7 +7447,29 @@ var ScallopClient = class {
|
|
|
7441
7447
|
if (!errMsg.includes("No valid coins found for the transaction"))
|
|
7442
7448
|
throw e;
|
|
7443
7449
|
}
|
|
7444
|
-
|
|
7450
|
+
sCoins2.push(sCoin);
|
|
7451
|
+
}
|
|
7452
|
+
if (SUPPORT_SPOOLS.includes(sCoinName)) {
|
|
7453
|
+
try {
|
|
7454
|
+
const sCoin = await txBlock.unstakeQuick(
|
|
7455
|
+
Number.MAX_SAFE_INTEGER,
|
|
7456
|
+
sCoinName
|
|
7457
|
+
);
|
|
7458
|
+
if (sCoin) {
|
|
7459
|
+
sCoins2.push(sCoin);
|
|
7460
|
+
}
|
|
7461
|
+
} catch (e) {
|
|
7462
|
+
const errMsg = e.toString();
|
|
7463
|
+
if (!errMsg.includes("No stake account found"))
|
|
7464
|
+
throw e;
|
|
7465
|
+
}
|
|
7466
|
+
}
|
|
7467
|
+
if (sCoins2.length > 0) {
|
|
7468
|
+
const mergedSCoin = sCoins2[0];
|
|
7469
|
+
if (sCoins2.length > 1) {
|
|
7470
|
+
txBlock.mergeCoins(mergedSCoin, sCoins2.slice(1));
|
|
7471
|
+
}
|
|
7472
|
+
toTransfer.push(mergedSCoin);
|
|
7445
7473
|
}
|
|
7446
7474
|
})
|
|
7447
7475
|
);
|