@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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TransactionBlock } from '@mysten/sui.js/transactions';
|
|
2
2
|
import { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
|
|
3
3
|
import type { ScallopBuilder } from '../models';
|
|
4
|
-
import type { CoreTxBlock, ScallopTxBlock } from '../types';
|
|
4
|
+
import type { CoreTxBlock, ScallopTxBlock, SuiTxBlockWithSpool } from '../types';
|
|
5
5
|
/**
|
|
6
6
|
* Create an enhanced transaction block instance for interaction with core modules of the Scallop contract.
|
|
7
7
|
*
|
|
@@ -9,4 +9,4 @@ import type { CoreTxBlock, ScallopTxBlock } from '../types';
|
|
|
9
9
|
* @param initTxBlock - Scallop txBlock, txBlock created by SuiKit, or original transaction block.
|
|
10
10
|
* @return Scallop core txBlock.
|
|
11
11
|
*/
|
|
12
|
-
export declare const newCoreTxBlock: (builder: ScallopBuilder, initTxBlock?: ScallopTxBlock | SuiKitTxBlock | TransactionBlock) => CoreTxBlock;
|
|
12
|
+
export declare const newCoreTxBlock: (builder: ScallopBuilder, initTxBlock?: ScallopTxBlock | SuiKitTxBlock | TransactionBlock | SuiTxBlockWithSpool) => CoreTxBlock;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { TransactionBlock, SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
|
|
2
2
|
import { ScallopBuilder } from 'src/models';
|
|
3
|
-
import { SCoinTxBlock, ScallopTxBlock } from 'src/types';
|
|
4
|
-
export declare const newSCoinTxBlock: (builder: ScallopBuilder, initTxBlock?: ScallopTxBlock | SuiKitTxBlock | TransactionBlock) => SCoinTxBlock;
|
|
3
|
+
import { BaseScallopTxBlock, SCoinTxBlock, ScallopTxBlock } from 'src/types';
|
|
4
|
+
export declare const newSCoinTxBlock: (builder: ScallopBuilder, initTxBlock?: ScallopTxBlock | SuiKitTxBlock | TransactionBlock | BaseScallopTxBlock) => SCoinTxBlock;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TransactionBlock } from '@mysten/sui.js/transactions';
|
|
2
2
|
import { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
|
|
3
3
|
import type { ScallopBuilder } from '../models';
|
|
4
|
-
import type { SpoolTxBlock, ScallopTxBlock } from '../types';
|
|
4
|
+
import type { SpoolTxBlock, ScallopTxBlock, SuiTxBlockWithSCoin } from '../types';
|
|
5
5
|
/**
|
|
6
6
|
* Create an enhanced transaction block instance for interaction with spool modules of the Scallop contract.
|
|
7
7
|
*
|
|
@@ -9,4 +9,4 @@ import type { SpoolTxBlock, ScallopTxBlock } from '../types';
|
|
|
9
9
|
* @param initTxBlock - Scallop txBlock, txBlock created by SuiKit, or original transaction block.
|
|
10
10
|
* @return Scallop spool txBlock.
|
|
11
11
|
*/
|
|
12
|
-
export declare const newSpoolTxBlock: (builder: ScallopBuilder, initTxBlock?: ScallopTxBlock | SuiKitTxBlock | TransactionBlock) => SpoolTxBlock;
|
|
12
|
+
export declare const newSpoolTxBlock: (builder: ScallopBuilder, initTxBlock?: ScallopTxBlock | SuiKitTxBlock | TransactionBlock | SuiTxBlockWithSCoin) => SpoolTxBlock;
|
package/dist/index.js
CHANGED
|
@@ -3465,7 +3465,9 @@ var getLending = async (query, poolCoinName, ownerAddress, indexer = false, mark
|
|
|
3465
3465
|
const marketCoinPrice = (0, import_bignumber4.default)(coinPrice ?? 0).multipliedBy(
|
|
3466
3466
|
marketPool?.conversionRate ?? 1
|
|
3467
3467
|
);
|
|
3468
|
-
const unstakedMarketAmount = (0, import_bignumber4.default)(marketCoinAmount)
|
|
3468
|
+
const unstakedMarketAmount = (0, import_bignumber4.default)(marketCoinAmount).plus(
|
|
3469
|
+
(0, import_bignumber4.default)(sCoinAmount)
|
|
3470
|
+
);
|
|
3469
3471
|
const unstakedMarketCoin = unstakedMarketAmount.shiftedBy(-1 * coinDecimal);
|
|
3470
3472
|
const availableSupplyAmount = (0, import_bignumber4.default)(coinAmount);
|
|
3471
3473
|
const availableSupplyCoin = availableSupplyAmount.shiftedBy(-1 * coinDecimal);
|
|
@@ -5747,6 +5749,22 @@ var requireStakeAccounts = async (...params) => {
|
|
|
5747
5749
|
}) : stakeAccounts[stakeMarketCoinName];
|
|
5748
5750
|
return specificStakeAccounts;
|
|
5749
5751
|
};
|
|
5752
|
+
var stakeHelper = async (builder, txBlock, stakeAccount, coinType, coinName, amount, sender, isSCoin = false) => {
|
|
5753
|
+
try {
|
|
5754
|
+
const coins = await builder.utils.selectCoins(amount, coinType, sender);
|
|
5755
|
+
const [takeCoin, leftCoin] = txBlock.takeAmountFromCoins(coins, amount);
|
|
5756
|
+
if (isSCoin) {
|
|
5757
|
+
const marketCoin = txBlock.burnSCoin(coinName, takeCoin);
|
|
5758
|
+
txBlock.stake(stakeAccount, marketCoin, coinName);
|
|
5759
|
+
} else {
|
|
5760
|
+
txBlock.stake(stakeAccount, takeCoin, coinName);
|
|
5761
|
+
}
|
|
5762
|
+
txBlock.transferObjects([leftCoin], sender);
|
|
5763
|
+
return true;
|
|
5764
|
+
} catch (e) {
|
|
5765
|
+
return false;
|
|
5766
|
+
}
|
|
5767
|
+
};
|
|
5750
5768
|
var generateSpoolNormalMethod = ({
|
|
5751
5769
|
builder,
|
|
5752
5770
|
txBlock
|
|
@@ -5820,18 +5838,29 @@ var generateSpoolQuickMethod = ({
|
|
|
5820
5838
|
stakeAccountId
|
|
5821
5839
|
);
|
|
5822
5840
|
const marketCoinType = builder.utils.parseMarketCoinType(stakeMarketCoinName);
|
|
5841
|
+
const sCoinType = builder.utils.parseSCoinType(stakeMarketCoinName);
|
|
5823
5842
|
if (typeof amountOrMarketCoin === "number") {
|
|
5824
|
-
const
|
|
5825
|
-
|
|
5843
|
+
const stakeMarketCoinRes = await stakeHelper(
|
|
5844
|
+
builder,
|
|
5845
|
+
txBlock,
|
|
5846
|
+
stakeAccountIds[0],
|
|
5826
5847
|
marketCoinType,
|
|
5848
|
+
stakeMarketCoinName,
|
|
5849
|
+
amountOrMarketCoin,
|
|
5827
5850
|
sender
|
|
5828
5851
|
);
|
|
5829
|
-
|
|
5830
|
-
|
|
5831
|
-
|
|
5832
|
-
|
|
5833
|
-
|
|
5834
|
-
|
|
5852
|
+
if (!stakeMarketCoinRes) {
|
|
5853
|
+
await stakeHelper(
|
|
5854
|
+
builder,
|
|
5855
|
+
txBlock,
|
|
5856
|
+
stakeAccountIds[0],
|
|
5857
|
+
sCoinType,
|
|
5858
|
+
stakeMarketCoinName,
|
|
5859
|
+
amountOrMarketCoin,
|
|
5860
|
+
sender,
|
|
5861
|
+
true
|
|
5862
|
+
);
|
|
5863
|
+
}
|
|
5835
5864
|
} else {
|
|
5836
5865
|
txBlock.stake(
|
|
5837
5866
|
stakeAccountIds[0],
|
|
@@ -5847,7 +5876,7 @@ var generateSpoolQuickMethod = ({
|
|
|
5847
5876
|
stakeMarketCoinName,
|
|
5848
5877
|
stakeAccountId
|
|
5849
5878
|
);
|
|
5850
|
-
const
|
|
5879
|
+
const sCoins2 = [];
|
|
5851
5880
|
for (const account of stakeAccounts) {
|
|
5852
5881
|
if (account.staked === 0)
|
|
5853
5882
|
continue;
|
|
@@ -5857,12 +5886,28 @@ var generateSpoolQuickMethod = ({
|
|
|
5857
5886
|
amountToUnstake,
|
|
5858
5887
|
stakeMarketCoinName
|
|
5859
5888
|
);
|
|
5860
|
-
|
|
5889
|
+
const sCoin = txBlock.mintSCoin(stakeMarketCoinName, marketCoin);
|
|
5890
|
+
sCoins2.push(sCoin);
|
|
5861
5891
|
amount -= amountToUnstake;
|
|
5862
5892
|
if (amount === 0)
|
|
5863
5893
|
break;
|
|
5864
5894
|
}
|
|
5865
|
-
|
|
5895
|
+
const mergedSCoin = sCoins2[0];
|
|
5896
|
+
if (sCoins2.length > 1) {
|
|
5897
|
+
txBlock.mergeCoins(mergedSCoin, sCoins2.slice(1));
|
|
5898
|
+
}
|
|
5899
|
+
try {
|
|
5900
|
+
const existingCoins = await builder.utils.selectCoins(
|
|
5901
|
+
Number.MAX_SAFE_INTEGER,
|
|
5902
|
+
builder.utils.parseSCoinType(stakeMarketCoinName),
|
|
5903
|
+
requireSender(txBlock)
|
|
5904
|
+
);
|
|
5905
|
+
if (existingCoins.length > 0) {
|
|
5906
|
+
txBlock.mergeCoins(mergedSCoin, existingCoins);
|
|
5907
|
+
}
|
|
5908
|
+
} catch (e) {
|
|
5909
|
+
}
|
|
5910
|
+
return mergedSCoin;
|
|
5866
5911
|
},
|
|
5867
5912
|
claimQuick: async (stakeMarketCoinName, stakeAccountId) => {
|
|
5868
5913
|
const stakeAccountIds = await requireStakeAccountIds(
|
|
@@ -6732,9 +6777,9 @@ var newScallopTxBlock = (builder, initTxBlock) => {
|
|
|
6732
6777
|
loyaltyTxBlock
|
|
6733
6778
|
);
|
|
6734
6779
|
const referralTxBlock = newReferralTxBlock(builder, borrowIncentiveTxBlock);
|
|
6735
|
-
const
|
|
6736
|
-
const
|
|
6737
|
-
const coreTxBlock = newCoreTxBlock(builder,
|
|
6780
|
+
const sCoinTxBlock = newSCoinTxBlock(builder, referralTxBlock);
|
|
6781
|
+
const spoolTxBlock = newSpoolTxBlock(builder, sCoinTxBlock);
|
|
6782
|
+
const coreTxBlock = newCoreTxBlock(builder, spoolTxBlock);
|
|
6738
6783
|
return new Proxy(coreTxBlock, {
|
|
6739
6784
|
get: (target, prop) => {
|
|
6740
6785
|
if (prop in vescaTxBlock) {
|
|
@@ -7090,8 +7135,8 @@ var ScallopClient = class {
|
|
|
7090
7135
|
const txBlock = this.builder.createTxBlock();
|
|
7091
7136
|
const sender = walletAddress || this.walletAddress;
|
|
7092
7137
|
txBlock.setSender(sender);
|
|
7093
|
-
const
|
|
7094
|
-
txBlock.transferObjects([
|
|
7138
|
+
const sCoin = await txBlock.depositQuick(amount, poolCoinName);
|
|
7139
|
+
txBlock.transferObjects([sCoin], sender);
|
|
7095
7140
|
if (sign) {
|
|
7096
7141
|
return await this.suiKit.signAndSendTxn(
|
|
7097
7142
|
txBlock
|
|
@@ -7107,7 +7152,7 @@ var ScallopClient = class {
|
|
|
7107
7152
|
const stakeMarketCoinName = this.utils.parseMarketCoinName(stakeCoinName);
|
|
7108
7153
|
const stakeAccounts = await this.query.getStakeAccounts(stakeMarketCoinName);
|
|
7109
7154
|
const targetStakeAccount = stakeAccountId || stakeAccounts[0].id;
|
|
7110
|
-
const marketCoin = await txBlock.depositQuick(amount, stakeCoinName);
|
|
7155
|
+
const marketCoin = await txBlock.depositQuick(amount, stakeCoinName, false);
|
|
7111
7156
|
if (targetStakeAccount) {
|
|
7112
7157
|
await txBlock.stakeQuick(
|
|
7113
7158
|
marketCoin,
|