@scallop-io/sui-scallop-sdk 0.46.42 → 0.46.44
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 +63 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +63 -18
- 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 +3 -3
- package/src/queries/portfolioQuery.ts +3 -1
- 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
|
@@ -3391,7 +3391,9 @@ var getLending = async (query, poolCoinName, ownerAddress, indexer = false, mark
|
|
|
3391
3391
|
const marketCoinPrice = BigNumber4(coinPrice ?? 0).multipliedBy(
|
|
3392
3392
|
marketPool?.conversionRate ?? 1
|
|
3393
3393
|
);
|
|
3394
|
-
const unstakedMarketAmount = BigNumber4(marketCoinAmount)
|
|
3394
|
+
const unstakedMarketAmount = BigNumber4(marketCoinAmount).plus(
|
|
3395
|
+
BigNumber4(sCoinAmount)
|
|
3396
|
+
);
|
|
3395
3397
|
const unstakedMarketCoin = unstakedMarketAmount.shiftedBy(-1 * coinDecimal);
|
|
3396
3398
|
const availableSupplyAmount = BigNumber4(coinAmount);
|
|
3397
3399
|
const availableSupplyCoin = availableSupplyAmount.shiftedBy(-1 * coinDecimal);
|
|
@@ -5676,6 +5678,22 @@ var requireStakeAccounts = async (...params) => {
|
|
|
5676
5678
|
}) : stakeAccounts[stakeMarketCoinName];
|
|
5677
5679
|
return specificStakeAccounts;
|
|
5678
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
|
+
};
|
|
5679
5697
|
var generateSpoolNormalMethod = ({
|
|
5680
5698
|
builder,
|
|
5681
5699
|
txBlock
|
|
@@ -5749,18 +5767,29 @@ var generateSpoolQuickMethod = ({
|
|
|
5749
5767
|
stakeAccountId
|
|
5750
5768
|
);
|
|
5751
5769
|
const marketCoinType = builder.utils.parseMarketCoinType(stakeMarketCoinName);
|
|
5770
|
+
const sCoinType = builder.utils.parseSCoinType(stakeMarketCoinName);
|
|
5752
5771
|
if (typeof amountOrMarketCoin === "number") {
|
|
5753
|
-
const
|
|
5754
|
-
|
|
5772
|
+
const stakeMarketCoinRes = await stakeHelper(
|
|
5773
|
+
builder,
|
|
5774
|
+
txBlock,
|
|
5775
|
+
stakeAccountIds[0],
|
|
5755
5776
|
marketCoinType,
|
|
5777
|
+
stakeMarketCoinName,
|
|
5778
|
+
amountOrMarketCoin,
|
|
5756
5779
|
sender
|
|
5757
5780
|
);
|
|
5758
|
-
|
|
5759
|
-
|
|
5760
|
-
|
|
5761
|
-
|
|
5762
|
-
|
|
5763
|
-
|
|
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
|
+
}
|
|
5764
5793
|
} else {
|
|
5765
5794
|
txBlock.stake(
|
|
5766
5795
|
stakeAccountIds[0],
|
|
@@ -5776,7 +5805,7 @@ var generateSpoolQuickMethod = ({
|
|
|
5776
5805
|
stakeMarketCoinName,
|
|
5777
5806
|
stakeAccountId
|
|
5778
5807
|
);
|
|
5779
|
-
const
|
|
5808
|
+
const sCoins2 = [];
|
|
5780
5809
|
for (const account of stakeAccounts) {
|
|
5781
5810
|
if (account.staked === 0)
|
|
5782
5811
|
continue;
|
|
@@ -5786,12 +5815,28 @@ var generateSpoolQuickMethod = ({
|
|
|
5786
5815
|
amountToUnstake,
|
|
5787
5816
|
stakeMarketCoinName
|
|
5788
5817
|
);
|
|
5789
|
-
|
|
5818
|
+
const sCoin = txBlock.mintSCoin(stakeMarketCoinName, marketCoin);
|
|
5819
|
+
sCoins2.push(sCoin);
|
|
5790
5820
|
amount -= amountToUnstake;
|
|
5791
5821
|
if (amount === 0)
|
|
5792
5822
|
break;
|
|
5793
5823
|
}
|
|
5794
|
-
|
|
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;
|
|
5795
5840
|
},
|
|
5796
5841
|
claimQuick: async (stakeMarketCoinName, stakeAccountId) => {
|
|
5797
5842
|
const stakeAccountIds = await requireStakeAccountIds(
|
|
@@ -6672,9 +6717,9 @@ var newScallopTxBlock = (builder, initTxBlock) => {
|
|
|
6672
6717
|
loyaltyTxBlock
|
|
6673
6718
|
);
|
|
6674
6719
|
const referralTxBlock = newReferralTxBlock(builder, borrowIncentiveTxBlock);
|
|
6675
|
-
const
|
|
6676
|
-
const
|
|
6677
|
-
const coreTxBlock = newCoreTxBlock(builder,
|
|
6720
|
+
const sCoinTxBlock = newSCoinTxBlock(builder, referralTxBlock);
|
|
6721
|
+
const spoolTxBlock = newSpoolTxBlock(builder, sCoinTxBlock);
|
|
6722
|
+
const coreTxBlock = newCoreTxBlock(builder, spoolTxBlock);
|
|
6678
6723
|
return new Proxy(coreTxBlock, {
|
|
6679
6724
|
get: (target, prop) => {
|
|
6680
6725
|
if (prop in vescaTxBlock) {
|
|
@@ -7030,8 +7075,8 @@ var ScallopClient = class {
|
|
|
7030
7075
|
const txBlock = this.builder.createTxBlock();
|
|
7031
7076
|
const sender = walletAddress || this.walletAddress;
|
|
7032
7077
|
txBlock.setSender(sender);
|
|
7033
|
-
const
|
|
7034
|
-
txBlock.transferObjects([
|
|
7078
|
+
const sCoin = await txBlock.depositQuick(amount, poolCoinName);
|
|
7079
|
+
txBlock.transferObjects([sCoin], sender);
|
|
7035
7080
|
if (sign) {
|
|
7036
7081
|
return await this.suiKit.signAndSendTxn(
|
|
7037
7082
|
txBlock
|
|
@@ -7047,7 +7092,7 @@ var ScallopClient = class {
|
|
|
7047
7092
|
const stakeMarketCoinName = this.utils.parseMarketCoinName(stakeCoinName);
|
|
7048
7093
|
const stakeAccounts = await this.query.getStakeAccounts(stakeMarketCoinName);
|
|
7049
7094
|
const targetStakeAccount = stakeAccountId || stakeAccounts[0].id;
|
|
7050
|
-
const marketCoin = await txBlock.depositQuick(amount, stakeCoinName);
|
|
7095
|
+
const marketCoin = await txBlock.depositQuick(amount, stakeCoinName, false);
|
|
7051
7096
|
if (targetStakeAccount) {
|
|
7052
7097
|
await txBlock.stakeQuick(
|
|
7053
7098
|
marketCoin,
|