@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.
- package/dist/index.js +36 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +36 -18
- 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 +48 -20
- package/src/types/builder/spool.ts +2 -1
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,29 +5815,47 @@ 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
|
-
if (
|
|
5825
|
-
const
|
|
5826
|
-
if (
|
|
5827
|
-
txBlock.mergeCoins(
|
|
5828
|
+
if (toTransfer.length > 0) {
|
|
5829
|
+
const mergedCoin = toTransfer[0];
|
|
5830
|
+
if (toTransfer.length > 1) {
|
|
5831
|
+
txBlock.mergeCoins(mergedCoin, toTransfer.slice(1));
|
|
5828
5832
|
}
|
|
5829
|
-
|
|
5830
|
-
|
|
5831
|
-
|
|
5832
|
-
|
|
5833
|
-
|
|
5834
|
-
|
|
5835
|
-
|
|
5836
|
-
|
|
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) {
|
|
5837
5856
|
}
|
|
5838
|
-
} catch (e) {
|
|
5839
5857
|
}
|
|
5840
|
-
return
|
|
5858
|
+
return mergedCoin;
|
|
5841
5859
|
}
|
|
5842
5860
|
},
|
|
5843
5861
|
claimQuick: async (stakeMarketCoinName, stakeAccountId) => {
|