@scallop-io/sui-scallop-sdk 0.46.43 → 0.46.45
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/builders/coreBuilder.d.ts +2 -2
- package/dist/builders/sCoinBuilder.d.ts +2 -2
- package/dist/builders/spoolBuilder.d.ts +2 -2
- package/dist/index.js +65 -33
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +65 -33
- package/dist/index.mjs.map +1 -1
- package/dist/types/builder/core.d.ts +2 -2
- package/dist/types/builder/index.d.ts +3 -3
- package/dist/types/builder/sCoin.d.ts +2 -2
- package/dist/types/builder/spool.d.ts +3 -3
- package/package.json +1 -1
- package/src/builders/coreBuilder.ts +6 -1
- package/src/builders/index.ts +3 -3
- package/src/builders/sCoinBuilder.ts +6 -1
- package/src/builders/spoolBuilder.ts +80 -12
- package/src/models/scallopClient.ts +9 -20
- package/src/types/builder/core.ts +2 -2
- package/src/types/builder/index.ts +3 -7
- package/src/types/builder/sCoin.ts +2 -2
- package/src/types/builder/spool.ts +3 -3
package/dist/index.mjs
CHANGED
|
@@ -5678,6 +5678,22 @@ var requireStakeAccounts = async (...params) => {
|
|
|
5678
5678
|
}) : stakeAccounts[stakeMarketCoinName];
|
|
5679
5679
|
return specificStakeAccounts;
|
|
5680
5680
|
};
|
|
5681
|
+
var stakeHelper = async (builder, txBlock, stakeAccount, coinType, coinName, amount, sender, isSCoin = false) => {
|
|
5682
|
+
try {
|
|
5683
|
+
const coins = await builder.utils.selectCoins(amount, coinType, sender);
|
|
5684
|
+
const [takeCoin, leftCoin] = txBlock.takeAmountFromCoins(coins, amount);
|
|
5685
|
+
if (isSCoin) {
|
|
5686
|
+
const marketCoin = txBlock.burnSCoin(coinName, takeCoin);
|
|
5687
|
+
txBlock.stake(stakeAccount, marketCoin, coinName);
|
|
5688
|
+
} else {
|
|
5689
|
+
txBlock.stake(stakeAccount, takeCoin, coinName);
|
|
5690
|
+
}
|
|
5691
|
+
txBlock.transferObjects([leftCoin], sender);
|
|
5692
|
+
return true;
|
|
5693
|
+
} catch (e) {
|
|
5694
|
+
return false;
|
|
5695
|
+
}
|
|
5696
|
+
};
|
|
5681
5697
|
var generateSpoolNormalMethod = ({
|
|
5682
5698
|
builder,
|
|
5683
5699
|
txBlock
|
|
@@ -5751,18 +5767,29 @@ var generateSpoolQuickMethod = ({
|
|
|
5751
5767
|
stakeAccountId
|
|
5752
5768
|
);
|
|
5753
5769
|
const marketCoinType = builder.utils.parseMarketCoinType(stakeMarketCoinName);
|
|
5770
|
+
const sCoinType = builder.utils.parseSCoinType(stakeMarketCoinName);
|
|
5754
5771
|
if (typeof amountOrMarketCoin === "number") {
|
|
5755
|
-
const
|
|
5756
|
-
|
|
5772
|
+
const stakeMarketCoinRes = await stakeHelper(
|
|
5773
|
+
builder,
|
|
5774
|
+
txBlock,
|
|
5775
|
+
stakeAccountIds[0],
|
|
5757
5776
|
marketCoinType,
|
|
5777
|
+
stakeMarketCoinName,
|
|
5778
|
+
amountOrMarketCoin,
|
|
5758
5779
|
sender
|
|
5759
5780
|
);
|
|
5760
|
-
|
|
5761
|
-
|
|
5762
|
-
|
|
5763
|
-
|
|
5764
|
-
|
|
5765
|
-
|
|
5781
|
+
if (!stakeMarketCoinRes) {
|
|
5782
|
+
await stakeHelper(
|
|
5783
|
+
builder,
|
|
5784
|
+
txBlock,
|
|
5785
|
+
stakeAccountIds[0],
|
|
5786
|
+
sCoinType,
|
|
5787
|
+
stakeMarketCoinName,
|
|
5788
|
+
amountOrMarketCoin,
|
|
5789
|
+
sender,
|
|
5790
|
+
true
|
|
5791
|
+
);
|
|
5792
|
+
}
|
|
5766
5793
|
} else {
|
|
5767
5794
|
txBlock.stake(
|
|
5768
5795
|
stakeAccountIds[0],
|
|
@@ -5778,7 +5805,7 @@ var generateSpoolQuickMethod = ({
|
|
|
5778
5805
|
stakeMarketCoinName,
|
|
5779
5806
|
stakeAccountId
|
|
5780
5807
|
);
|
|
5781
|
-
const
|
|
5808
|
+
const sCoins2 = [];
|
|
5782
5809
|
for (const account of stakeAccounts) {
|
|
5783
5810
|
if (account.staked === 0)
|
|
5784
5811
|
continue;
|
|
@@ -5788,12 +5815,28 @@ var generateSpoolQuickMethod = ({
|
|
|
5788
5815
|
amountToUnstake,
|
|
5789
5816
|
stakeMarketCoinName
|
|
5790
5817
|
);
|
|
5791
|
-
|
|
5818
|
+
const sCoin = txBlock.mintSCoin(stakeMarketCoinName, marketCoin);
|
|
5819
|
+
sCoins2.push(sCoin);
|
|
5792
5820
|
amount -= amountToUnstake;
|
|
5793
5821
|
if (amount === 0)
|
|
5794
5822
|
break;
|
|
5795
5823
|
}
|
|
5796
|
-
|
|
5824
|
+
const mergedSCoin = sCoins2[0];
|
|
5825
|
+
if (sCoins2.length > 1) {
|
|
5826
|
+
txBlock.mergeCoins(mergedSCoin, sCoins2.slice(1));
|
|
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);
|
|
5836
|
+
}
|
|
5837
|
+
} catch (e) {
|
|
5838
|
+
}
|
|
5839
|
+
return mergedSCoin;
|
|
5797
5840
|
},
|
|
5798
5841
|
claimQuick: async (stakeMarketCoinName, stakeAccountId) => {
|
|
5799
5842
|
const stakeAccountIds = await requireStakeAccountIds(
|
|
@@ -6674,9 +6717,9 @@ var newScallopTxBlock = (builder, initTxBlock) => {
|
|
|
6674
6717
|
loyaltyTxBlock
|
|
6675
6718
|
);
|
|
6676
6719
|
const referralTxBlock = newReferralTxBlock(builder, borrowIncentiveTxBlock);
|
|
6677
|
-
const
|
|
6678
|
-
const
|
|
6679
|
-
const coreTxBlock = newCoreTxBlock(builder,
|
|
6720
|
+
const sCoinTxBlock = newSCoinTxBlock(builder, referralTxBlock);
|
|
6721
|
+
const spoolTxBlock = newSpoolTxBlock(builder, sCoinTxBlock);
|
|
6722
|
+
const coreTxBlock = newCoreTxBlock(builder, spoolTxBlock);
|
|
6680
6723
|
return new Proxy(coreTxBlock, {
|
|
6681
6724
|
get: (target, prop) => {
|
|
6682
6725
|
if (prop in vescaTxBlock) {
|
|
@@ -7032,8 +7075,8 @@ var ScallopClient = class {
|
|
|
7032
7075
|
const txBlock = this.builder.createTxBlock();
|
|
7033
7076
|
const sender = walletAddress || this.walletAddress;
|
|
7034
7077
|
txBlock.setSender(sender);
|
|
7035
|
-
const
|
|
7036
|
-
txBlock.transferObjects([
|
|
7078
|
+
const sCoin = await txBlock.depositQuick(amount, poolCoinName);
|
|
7079
|
+
txBlock.transferObjects([sCoin], sender);
|
|
7037
7080
|
if (sign) {
|
|
7038
7081
|
return await this.suiKit.signAndSendTxn(
|
|
7039
7082
|
txBlock
|
|
@@ -7049,7 +7092,7 @@ var ScallopClient = class {
|
|
|
7049
7092
|
const stakeMarketCoinName = this.utils.parseMarketCoinName(stakeCoinName);
|
|
7050
7093
|
const stakeAccounts = await this.query.getStakeAccounts(stakeMarketCoinName);
|
|
7051
7094
|
const targetStakeAccount = stakeAccountId || stakeAccounts[0].id;
|
|
7052
|
-
const marketCoin = await txBlock.depositQuick(amount, stakeCoinName);
|
|
7095
|
+
const marketCoin = await txBlock.depositQuick(amount, stakeCoinName, false);
|
|
7053
7096
|
if (targetStakeAccount) {
|
|
7054
7097
|
await txBlock.stakeQuick(
|
|
7055
7098
|
marketCoin,
|
|
@@ -7366,25 +7409,14 @@ var ScallopClient = class {
|
|
|
7366
7409
|
}
|
|
7367
7410
|
if (SUPPORT_SPOOLS.includes(sCoinName)) {
|
|
7368
7411
|
try {
|
|
7369
|
-
const
|
|
7412
|
+
const stakedMarketCoin = await txBlock.unstakeQuick(
|
|
7370
7413
|
Number.MAX_SAFE_INTEGER,
|
|
7371
7414
|
sCoinName
|
|
7372
7415
|
);
|
|
7373
|
-
if (
|
|
7374
|
-
|
|
7375
|
-
|
|
7376
|
-
|
|
7377
|
-
mergedStakedMarketCoin,
|
|
7378
|
-
stakedMarketCoins.slice(1)
|
|
7379
|
-
);
|
|
7380
|
-
}
|
|
7381
|
-
if (toDestroyMarketCoin) {
|
|
7382
|
-
txBlock.mergeCoins(toDestroyMarketCoin, [
|
|
7383
|
-
mergedStakedMarketCoin
|
|
7384
|
-
]);
|
|
7385
|
-
} else {
|
|
7386
|
-
toDestroyMarketCoin = mergedStakedMarketCoin;
|
|
7387
|
-
}
|
|
7416
|
+
if (toDestroyMarketCoin) {
|
|
7417
|
+
txBlock.mergeCoins(toDestroyMarketCoin, [stakedMarketCoin]);
|
|
7418
|
+
} else {
|
|
7419
|
+
toDestroyMarketCoin = stakedMarketCoin;
|
|
7388
7420
|
}
|
|
7389
7421
|
} catch (e) {
|
|
7390
7422
|
const errMsg = e.toString();
|