@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.js
CHANGED
|
@@ -5869,14 +5869,14 @@ var generateSpoolQuickMethod = ({
|
|
|
5869
5869
|
);
|
|
5870
5870
|
}
|
|
5871
5871
|
},
|
|
5872
|
-
unstakeQuick: async (amount, stakeMarketCoinName, stakeAccountId) => {
|
|
5872
|
+
unstakeQuick: async (amount, stakeMarketCoinName, stakeAccountId, returnSCoin = true) => {
|
|
5873
5873
|
const stakeAccounts = await requireStakeAccounts(
|
|
5874
5874
|
builder,
|
|
5875
5875
|
txBlock,
|
|
5876
5876
|
stakeMarketCoinName,
|
|
5877
5877
|
stakeAccountId
|
|
5878
5878
|
);
|
|
5879
|
-
const
|
|
5879
|
+
const toTransfer = [];
|
|
5880
5880
|
for (const account of stakeAccounts) {
|
|
5881
5881
|
if (account.staked === 0)
|
|
5882
5882
|
continue;
|
|
@@ -5886,29 +5886,47 @@ var generateSpoolQuickMethod = ({
|
|
|
5886
5886
|
amountToUnstake,
|
|
5887
5887
|
stakeMarketCoinName
|
|
5888
5888
|
);
|
|
5889
|
-
|
|
5890
|
-
|
|
5889
|
+
if (returnSCoin) {
|
|
5890
|
+
const sCoin = txBlock.mintSCoin(stakeMarketCoinName, marketCoin);
|
|
5891
|
+
toTransfer.push(sCoin);
|
|
5892
|
+
} else {
|
|
5893
|
+
toTransfer.push(marketCoin);
|
|
5894
|
+
}
|
|
5891
5895
|
amount -= amountToUnstake;
|
|
5892
5896
|
if (amount === 0)
|
|
5893
5897
|
break;
|
|
5894
5898
|
}
|
|
5895
|
-
if (
|
|
5896
|
-
const
|
|
5897
|
-
if (
|
|
5898
|
-
txBlock.mergeCoins(
|
|
5899
|
+
if (toTransfer.length > 0) {
|
|
5900
|
+
const mergedCoin = toTransfer[0];
|
|
5901
|
+
if (toTransfer.length > 1) {
|
|
5902
|
+
txBlock.mergeCoins(mergedCoin, toTransfer.slice(1));
|
|
5899
5903
|
}
|
|
5900
|
-
|
|
5901
|
-
|
|
5902
|
-
|
|
5903
|
-
|
|
5904
|
-
|
|
5905
|
-
|
|
5906
|
-
|
|
5907
|
-
|
|
5904
|
+
if (returnSCoin) {
|
|
5905
|
+
try {
|
|
5906
|
+
const existingCoins = await builder.utils.selectCoins(
|
|
5907
|
+
Number.MAX_SAFE_INTEGER,
|
|
5908
|
+
builder.utils.parseSCoinType(stakeMarketCoinName),
|
|
5909
|
+
requireSender(txBlock)
|
|
5910
|
+
);
|
|
5911
|
+
if (existingCoins.length > 0) {
|
|
5912
|
+
txBlock.mergeCoins(mergedCoin, existingCoins);
|
|
5913
|
+
}
|
|
5914
|
+
} catch (e) {
|
|
5915
|
+
}
|
|
5916
|
+
} else {
|
|
5917
|
+
try {
|
|
5918
|
+
const existingCoins = await builder.utils.selectCoins(
|
|
5919
|
+
Number.MAX_SAFE_INTEGER,
|
|
5920
|
+
builder.utils.parseMarketCoinType(stakeMarketCoinName),
|
|
5921
|
+
requireSender(txBlock)
|
|
5922
|
+
);
|
|
5923
|
+
if (existingCoins.length > 0) {
|
|
5924
|
+
txBlock.mergeCoins(mergedCoin, existingCoins);
|
|
5925
|
+
}
|
|
5926
|
+
} catch (e) {
|
|
5908
5927
|
}
|
|
5909
|
-
} catch (e) {
|
|
5910
5928
|
}
|
|
5911
|
-
return
|
|
5929
|
+
return mergedCoin;
|
|
5912
5930
|
}
|
|
5913
5931
|
},
|
|
5914
5932
|
claimQuick: async (stakeMarketCoinName, stakeAccountId) => {
|