@scallop-io/sui-scallop-sdk 1.3.5-alpha.2 → 1.3.5-alpha.4
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/constants/enum.d.ts +0 -1
- package/dist/index.js +31 -40
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -39
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallopClient.d.ts +4 -4
- package/dist/models/scallopUtils.d.ts +2 -9
- package/dist/types/builder/borrowIncentive.d.ts +6 -6
- package/package.json +1 -1
- package/src/builders/borrowIncentiveBuilder.ts +2 -13
- package/src/constants/enum.ts +0 -13
- package/src/models/scallopClient.ts +27 -10
- package/src/models/scallopUtils.ts +9 -16
- package/src/types/builder/borrowIncentive.ts +10 -15
package/dist/index.mjs
CHANGED
|
@@ -267,18 +267,6 @@ var spoolRewardCoins = {
|
|
|
267
267
|
var suiBridgeCoins = {
|
|
268
268
|
sbeth: "sbeth"
|
|
269
269
|
};
|
|
270
|
-
var borrowIncentiveRewardCoins = {
|
|
271
|
-
usdc: ["ssui", "ssca"],
|
|
272
|
-
sui: ["ssui", "ssca"],
|
|
273
|
-
wusdc: ["ssui", "ssca"],
|
|
274
|
-
wusdt: ["ssui", "ssca"],
|
|
275
|
-
sca: ["ssui", "ssca"],
|
|
276
|
-
afsui: ["ssui"],
|
|
277
|
-
hasui: ["ssui"],
|
|
278
|
-
vsui: ["ssui"],
|
|
279
|
-
weth: ["ssui"],
|
|
280
|
-
sbeth: ["ssui"]
|
|
281
|
-
};
|
|
282
270
|
var coinIds = {
|
|
283
271
|
usdc: "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7",
|
|
284
272
|
sui: "0x0000000000000000000000000000000000000000000000000000000000000002",
|
|
@@ -4756,15 +4744,6 @@ var ScallopUtils = class {
|
|
|
4756
4744
|
this.getSpoolRewardCoinName = (stakeMarketCoinName) => {
|
|
4757
4745
|
return spoolRewardCoins[stakeMarketCoinName];
|
|
4758
4746
|
};
|
|
4759
|
-
/**
|
|
4760
|
-
* Get reward type of borrow incentive pool.
|
|
4761
|
-
*
|
|
4762
|
-
* @param borrowIncentiveCoinName - Support borrow incentive coin.
|
|
4763
|
-
* @return Borrow incentive reward coin name.
|
|
4764
|
-
*/
|
|
4765
|
-
this.getBorrowIncentiveRewardCoinName = (borrowIncentiveCoinName) => {
|
|
4766
|
-
return borrowIncentiveRewardCoins[borrowIncentiveCoinName];
|
|
4767
|
-
};
|
|
4768
4747
|
this.params = {
|
|
4769
4748
|
pythEndpoints: params.pythEndpoints ?? PYTH_ENDPOINTS["mainnet"],
|
|
4770
4749
|
...params
|
|
@@ -4834,7 +4813,10 @@ var ScallopUtils = class {
|
|
|
4834
4813
|
* @param coinName - Specific support coin name.
|
|
4835
4814
|
* @return Coin type.
|
|
4836
4815
|
*/
|
|
4837
|
-
parseCoinType(coinName) {
|
|
4816
|
+
parseCoinType(coinName, useOldMarketCoin = false) {
|
|
4817
|
+
if (sCoinIds[coinName] && !useOldMarketCoin) {
|
|
4818
|
+
return sCoinIds[coinName];
|
|
4819
|
+
}
|
|
4838
4820
|
coinName = isMarketCoin(coinName) ? this.parseCoinName(coinName) : coinName;
|
|
4839
4821
|
const coinPackageId = this.address.get(`core.coins.${coinName}.id`) || coinIds[coinName] || void 0;
|
|
4840
4822
|
if (!coinPackageId) {
|
|
@@ -4940,7 +4922,7 @@ var ScallopUtils = class {
|
|
|
4940
4922
|
*/
|
|
4941
4923
|
parseMarketCoinType(coinName) {
|
|
4942
4924
|
const protocolObjectId = this.address.get("core.object") ?? PROTOCOL_OBJECT_ID;
|
|
4943
|
-
const coinType = this.parseCoinType(coinName);
|
|
4925
|
+
const coinType = this.parseCoinType(coinName, true);
|
|
4944
4926
|
return `${protocolObjectId}::reserve::MarketCoin<${coinType}>`;
|
|
4945
4927
|
}
|
|
4946
4928
|
parseCoinNameFromType(coinType) {
|
|
@@ -6083,11 +6065,7 @@ var generateBorrowIncentiveNormalMethod = ({ builder, txBlock }) => {
|
|
|
6083
6065
|
]
|
|
6084
6066
|
);
|
|
6085
6067
|
},
|
|
6086
|
-
claimBorrowIncentive: (obligationId, obligationKey,
|
|
6087
|
-
const rewardCoinNames = builder.utils.getBorrowIncentiveRewardCoinName(coinName);
|
|
6088
|
-
if (rewardCoinNames.includes(rewardCoinName) === false) {
|
|
6089
|
-
throw new Error(`Invalid reward coin name ${rewardCoinName}`);
|
|
6090
|
-
}
|
|
6068
|
+
claimBorrowIncentive: (obligationId, obligationKey, rewardCoinName) => {
|
|
6091
6069
|
const rewardType = builder.utils.parseCoinType(rewardCoinName);
|
|
6092
6070
|
return txBlock.moveCall(
|
|
6093
6071
|
`${borrowIncentiveIds.borrowIncentivePkg}::user::redeem_rewards`,
|
|
@@ -6180,7 +6158,7 @@ var generateBorrowIncentiveQuickMethod = ({ builder, txBlock }) => {
|
|
|
6180
6158
|
txBlock.unstakeObligation(obligationArg, obligationKeyArg);
|
|
6181
6159
|
}
|
|
6182
6160
|
},
|
|
6183
|
-
claimBorrowIncentiveQuick: async (
|
|
6161
|
+
claimBorrowIncentiveQuick: async (rewardCoinName, obligation, obligationKey) => {
|
|
6184
6162
|
const { obligationId: obligationArg, obligationKey: obligationKeyArg } = await requireObligationInfo2(
|
|
6185
6163
|
builder,
|
|
6186
6164
|
txBlock,
|
|
@@ -6190,7 +6168,6 @@ var generateBorrowIncentiveQuickMethod = ({ builder, txBlock }) => {
|
|
|
6190
6168
|
return txBlock.claimBorrowIncentive(
|
|
6191
6169
|
obligationArg,
|
|
6192
6170
|
obligationKeyArg,
|
|
6193
|
-
coinName,
|
|
6194
6171
|
rewardCoinName
|
|
6195
6172
|
);
|
|
6196
6173
|
}
|
|
@@ -8235,30 +8212,46 @@ var ScallopClient = class {
|
|
|
8235
8212
|
}
|
|
8236
8213
|
}
|
|
8237
8214
|
/**
|
|
8238
|
-
*
|
|
8215
|
+
* Claim borrow incentive reward.
|
|
8239
8216
|
*
|
|
8240
|
-
* @param
|
|
8217
|
+
* @param poolName
|
|
8241
8218
|
* @param amount - The amount of coins would deposit.
|
|
8242
8219
|
* @param sign - Decide to directly sign the transaction or return the transaction block.
|
|
8243
8220
|
* @param accountId - The stake account object.
|
|
8244
8221
|
* @param walletAddress - The wallet address of the owner.
|
|
8245
8222
|
* @return Transaction block response or transaction block
|
|
8246
8223
|
*/
|
|
8247
|
-
async claimBorrowIncentive(
|
|
8224
|
+
async claimBorrowIncentive(obligationId, obligationKeyId, sign = true, walletAddress) {
|
|
8248
8225
|
const txBlock = this.builder.createTxBlock();
|
|
8249
8226
|
const sender = walletAddress ?? this.walletAddress;
|
|
8250
8227
|
txBlock.setSender(sender);
|
|
8251
|
-
const
|
|
8252
|
-
|
|
8228
|
+
const rewardCoinsCollection = {};
|
|
8229
|
+
const obligationAccount = await this.query.getObligationAccount(obligationId);
|
|
8230
|
+
const rewardCoinNames = Object.values(obligationAccount.borrowIncentives).flatMap(
|
|
8231
|
+
({ rewards }) => rewards.filter(({ availableClaimAmount }) => availableClaimAmount > 0)
|
|
8232
|
+
).flatMap(({ coinName }) => coinName);
|
|
8233
|
+
for (const rewardCoinName of rewardCoinNames) {
|
|
8253
8234
|
const rewardCoin = await txBlock.claimBorrowIncentiveQuick(
|
|
8254
|
-
coinName,
|
|
8255
8235
|
rewardCoinName,
|
|
8256
8236
|
obligationId,
|
|
8257
8237
|
obligationKeyId
|
|
8258
8238
|
);
|
|
8259
|
-
|
|
8239
|
+
if (!rewardCoinsCollection[rewardCoinName]) {
|
|
8240
|
+
rewardCoinsCollection[rewardCoinName] = [rewardCoin];
|
|
8241
|
+
} else {
|
|
8242
|
+
rewardCoinsCollection[rewardCoinName].push(rewardCoin);
|
|
8243
|
+
}
|
|
8260
8244
|
}
|
|
8261
|
-
txBlock.transferObjects(
|
|
8245
|
+
txBlock.transferObjects(
|
|
8246
|
+
Object.values(rewardCoinsCollection).map((rewardCoins) => {
|
|
8247
|
+
const mergeDest = rewardCoins[0];
|
|
8248
|
+
if (rewardCoins.length > 1) {
|
|
8249
|
+
txBlock.mergeCoins(mergeDest, rewardCoins.slice(1));
|
|
8250
|
+
}
|
|
8251
|
+
return mergeDest;
|
|
8252
|
+
}),
|
|
8253
|
+
sender
|
|
8254
|
+
);
|
|
8262
8255
|
if (sign) {
|
|
8263
8256
|
return await this.suiKit.signAndSendTxn(
|
|
8264
8257
|
txBlock
|
|
@@ -8567,7 +8560,6 @@ export {
|
|
|
8567
8560
|
UNLOCK_ROUND_DURATION,
|
|
8568
8561
|
USE_TEST_ADDRESS,
|
|
8569
8562
|
assetCoins,
|
|
8570
|
-
borrowIncentiveRewardCoins,
|
|
8571
8563
|
coinDecimals,
|
|
8572
8564
|
coinIds,
|
|
8573
8565
|
marketCoins,
|