@scallop-io/sui-scallop-sdk 0.46.58-alpha.1 → 0.46.60
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 +23 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -25
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallopClient.d.ts +1 -1
- package/package.json +1 -1
- package/src/builders/coreBuilder.ts +23 -26
- package/src/models/scallopClient.ts +14 -11
|
@@ -298,7 +298,7 @@ export declare class ScallopClient {
|
|
|
298
298
|
* Function to migrate all market coin in user wallet into sCoin
|
|
299
299
|
* @returns Transaction response
|
|
300
300
|
*/
|
|
301
|
-
migrateAllMarketCoin<S extends boolean>(sign?: S): Promise<ScallopClientFnReturnType<S>>;
|
|
301
|
+
migrateAllMarketCoin<S extends boolean>(includeStakePool?: boolean, sign?: S): Promise<ScallopClientFnReturnType<S>>;
|
|
302
302
|
/**
|
|
303
303
|
* Claim unlocked SCA from all veSCA accounts.
|
|
304
304
|
*/
|
package/package.json
CHANGED
|
@@ -341,47 +341,44 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
|
|
|
341
341
|
try {
|
|
342
342
|
const sCoinName = builder.utils.parseSCoinName(poolCoinName);
|
|
343
343
|
if (!sCoinName) throw new Error(`No sCoin for ${poolCoinName}`);
|
|
344
|
-
const {
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
);
|
|
344
|
+
const {
|
|
345
|
+
leftCoin,
|
|
346
|
+
takeCoin: sCoins,
|
|
347
|
+
totalAmount,
|
|
348
|
+
} = await builder.selectSCoin(txBlock, sCoinName, amount, sender);
|
|
350
349
|
txBlock.transferObjects([leftCoin], sender);
|
|
351
|
-
const
|
|
352
|
-
|
|
353
|
-
const txResult = txBlock.withdraw(marketCoin, poolCoinName);
|
|
350
|
+
const marketCoins = txBlock.burnSCoin(sCoinName, sCoins);
|
|
354
351
|
|
|
355
352
|
// check amount
|
|
356
353
|
amount -= totalAmount;
|
|
357
354
|
try {
|
|
358
355
|
if (amount > 0) {
|
|
359
356
|
// sCoin is not enough, try market coin
|
|
360
|
-
const { leftCoin, takeCoin } =
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
357
|
+
const { leftCoin, takeCoin: walletMarketCoins } =
|
|
358
|
+
await builder.selectMarketCoin(
|
|
359
|
+
txBlock,
|
|
360
|
+
marketCoinName,
|
|
361
|
+
amount,
|
|
362
|
+
sender
|
|
363
|
+
);
|
|
366
364
|
txBlock.transferObjects([leftCoin], sender);
|
|
367
|
-
txBlock.mergeCoins(
|
|
368
|
-
txBlock.withdraw(takeCoin, poolCoinName),
|
|
369
|
-
]);
|
|
365
|
+
txBlock.mergeCoins(marketCoins, [walletMarketCoins]);
|
|
370
366
|
}
|
|
371
367
|
} catch (e) {
|
|
372
368
|
// ignore
|
|
373
369
|
}
|
|
374
|
-
return
|
|
370
|
+
return txBlock.withdraw(marketCoins, poolCoinName);
|
|
375
371
|
} catch (e) {
|
|
376
372
|
// no sCoin found
|
|
377
|
-
const { leftCoin, takeCoin } =
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
373
|
+
const { leftCoin, takeCoin: walletMarketCoins } =
|
|
374
|
+
await builder.selectMarketCoin(
|
|
375
|
+
txBlock,
|
|
376
|
+
marketCoinName,
|
|
377
|
+
amount,
|
|
378
|
+
sender
|
|
379
|
+
);
|
|
383
380
|
txBlock.transferObjects([leftCoin], sender);
|
|
384
|
-
return txBlock.withdraw(
|
|
381
|
+
return txBlock.withdraw(walletMarketCoins, poolCoinName);
|
|
385
382
|
}
|
|
386
383
|
},
|
|
387
384
|
borrowQuick: async (amount, poolCoinName, obligationId, obligationKey) => {
|
|
@@ -989,6 +989,7 @@ export class ScallopClient {
|
|
|
989
989
|
* @returns Transaction response
|
|
990
990
|
*/
|
|
991
991
|
public async migrateAllMarketCoin<S extends boolean>(
|
|
992
|
+
includeStakePool: boolean = true,
|
|
992
993
|
sign: S = true as S
|
|
993
994
|
): Promise<ScallopClientFnReturnType<S>> {
|
|
994
995
|
const txBlock = this.builder.createTxBlock();
|
|
@@ -1040,18 +1041,20 @@ export class ScallopClient {
|
|
|
1040
1041
|
);
|
|
1041
1042
|
sCoins.push(sCoin);
|
|
1042
1043
|
}
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1044
|
+
if (includeStakePool) {
|
|
1045
|
+
// check for staked market coin in spool
|
|
1046
|
+
if (SUPPORT_SPOOLS.includes(sCoinName as SupportStakeMarketCoins)) {
|
|
1047
|
+
try {
|
|
1048
|
+
const sCoin = await txBlock.unstakeQuick(
|
|
1049
|
+
Number.MAX_SAFE_INTEGER,
|
|
1050
|
+
sCoinName as SupportStakeMarketCoins
|
|
1051
|
+
);
|
|
1052
|
+
if (sCoin) {
|
|
1053
|
+
sCoins.push(sCoin);
|
|
1054
|
+
}
|
|
1055
|
+
} catch (e: any) {
|
|
1056
|
+
// ignore
|
|
1052
1057
|
}
|
|
1053
|
-
} catch (e: any) {
|
|
1054
|
-
// ignore
|
|
1055
1058
|
}
|
|
1056
1059
|
}
|
|
1057
1060
|
|