@t2000/cli 0.25.7 → 0.25.9
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/{chunk-YZ6UELLB.js → chunk-JHT7EXQL.js} +32 -21
- package/dist/{chunk-YZ6UELLB.js.map → chunk-JHT7EXQL.js.map} +1 -1
- package/dist/{dist-7CZMGNTP.js → dist-MULWIXK5.js} +2 -2
- package/dist/{dist-SPZX35RD.js → dist-ZKLEFNJE.js} +2 -2
- package/dist/index.js +3 -3
- package/package.json +3 -3
- /package/dist/{dist-7CZMGNTP.js.map → dist-MULWIXK5.js.map} +0 -0
- /package/dist/{dist-SPZX35RD.js.map → dist-ZKLEFNJE.js.map} +0 -0
|
@@ -65369,13 +65369,14 @@ async function trySelfFunded(client, signer, tx) {
|
|
|
65369
65369
|
const result = await client.executeTransactionBlock({
|
|
65370
65370
|
transactionBlock: toBase642(builtBytes),
|
|
65371
65371
|
signature: [signature],
|
|
65372
|
-
options: { showEffects: true }
|
|
65372
|
+
options: { showEffects: true, showBalanceChanges: true }
|
|
65373
65373
|
});
|
|
65374
65374
|
await client.waitForTransaction({ digest: result.digest });
|
|
65375
65375
|
await assertTxSuccess(result.effects, result.digest);
|
|
65376
65376
|
return {
|
|
65377
65377
|
digest: result.digest,
|
|
65378
65378
|
effects: result.effects,
|
|
65379
|
+
balanceChanges: result.balanceChanges,
|
|
65379
65380
|
gasMethod: "self-funded",
|
|
65380
65381
|
gasCostSui: extractGasCost(result.effects),
|
|
65381
65382
|
preTxSuiMist: suiBalance
|
|
@@ -65394,13 +65395,14 @@ async function tryAutoTopUpThenSelfFund(client, signer, buildTx) {
|
|
|
65394
65395
|
const result = await client.executeTransactionBlock({
|
|
65395
65396
|
transactionBlock: toBase642(builtBytes),
|
|
65396
65397
|
signature: [signature],
|
|
65397
|
-
options: { showEffects: true }
|
|
65398
|
+
options: { showEffects: true, showBalanceChanges: true }
|
|
65398
65399
|
});
|
|
65399
65400
|
await client.waitForTransaction({ digest: result.digest });
|
|
65400
65401
|
await assertTxSuccess(result.effects, result.digest);
|
|
65401
65402
|
return {
|
|
65402
65403
|
digest: result.digest,
|
|
65403
65404
|
effects: result.effects,
|
|
65405
|
+
balanceChanges: result.balanceChanges,
|
|
65404
65406
|
gasMethod: "auto-topup",
|
|
65405
65407
|
gasCostSui: extractGasCost(result.effects),
|
|
65406
65408
|
preTxSuiMist: suiAfterTopUp
|
|
@@ -65424,7 +65426,7 @@ async function trySponsored(client, signer, tx) {
|
|
|
65424
65426
|
const result = await client.executeTransactionBlock({
|
|
65425
65427
|
transactionBlock: sponsoredResult.txBytes,
|
|
65426
65428
|
signature: [agentSig, sponsoredResult.sponsorSignature],
|
|
65427
|
-
options: { showEffects: true }
|
|
65429
|
+
options: { showEffects: true, showBalanceChanges: true }
|
|
65428
65430
|
});
|
|
65429
65431
|
await client.waitForTransaction({ digest: result.digest });
|
|
65430
65432
|
await assertTxSuccess(result.effects, result.digest);
|
|
@@ -65433,6 +65435,7 @@ async function trySponsored(client, signer, tx) {
|
|
|
65433
65435
|
return {
|
|
65434
65436
|
digest: result.digest,
|
|
65435
65437
|
effects: result.effects,
|
|
65438
|
+
balanceChanges: result.balanceChanges,
|
|
65436
65439
|
gasMethod: "sponsored",
|
|
65437
65440
|
gasCostSui: gasCost,
|
|
65438
65441
|
preTxSuiMist: suiBalance
|
|
@@ -66005,6 +66008,14 @@ var T2000 = class _T2000 extends import_index.default {
|
|
|
66005
66008
|
if (route.priceImpact > 0.05) {
|
|
66006
66009
|
console.warn(`[swap] High price impact: ${(route.priceImpact * 100).toFixed(2)}%`);
|
|
66007
66010
|
}
|
|
66011
|
+
const toEntry = Object.entries(SUPPORTED_ASSETS).find(([, v]) => v.type === toType);
|
|
66012
|
+
const toDecimals = toEntry ? toEntry[1].decimals : toType === "0x2::sui::SUI" ? 9 : 6;
|
|
66013
|
+
let preBalance = 0n;
|
|
66014
|
+
try {
|
|
66015
|
+
const bal = await this.client.getBalance({ owner: this._address, coinType: toType });
|
|
66016
|
+
preBalance = BigInt(bal.totalBalance);
|
|
66017
|
+
} catch {
|
|
66018
|
+
}
|
|
66008
66019
|
const gasResult = await executeWithGas(this.client, this._signer, async () => {
|
|
66009
66020
|
const tx = new Transaction();
|
|
66010
66021
|
tx.setSender(this._address);
|
|
@@ -66027,32 +66038,26 @@ var T2000 = class _T2000 extends import_index.default {
|
|
|
66027
66038
|
tx.transferObjects([outputCoin], this._address);
|
|
66028
66039
|
return tx;
|
|
66029
66040
|
});
|
|
66030
|
-
const toEntry = Object.entries(SUPPORTED_ASSETS).find(([, v]) => v.type === toType);
|
|
66031
|
-
const toDecimals = toEntry ? toEntry[1].decimals : toType === "0x2::sui::SUI" ? 9 : 6;
|
|
66032
66041
|
const fromAmount = Number(route.amountIn) / 10 ** fromDecimals;
|
|
66033
66042
|
let toAmount = Number(route.amountOut) / 10 ** toDecimals;
|
|
66034
66043
|
try {
|
|
66035
|
-
const
|
|
66036
|
-
|
|
66037
|
-
|
|
66038
|
-
|
|
66039
|
-
|
|
66040
|
-
const received = changes.find(
|
|
66041
|
-
(c) => c.coinType === toType && BigInt(c.amount) > 0n && c.owner.AddressOwner === this._address
|
|
66042
|
-
);
|
|
66043
|
-
if (received) {
|
|
66044
|
-
const actual = Number(BigInt(received.amount)) / 10 ** toDecimals;
|
|
66045
|
-
if (actual > 0) toAmount = actual;
|
|
66044
|
+
const postBal = await this.client.getBalance({ owner: this._address, coinType: toType });
|
|
66045
|
+
const postBalance = BigInt(postBal.totalBalance);
|
|
66046
|
+
const diff = postBalance - preBalance;
|
|
66047
|
+
if (diff > 0n) {
|
|
66048
|
+
toAmount = Number(diff) / 10 ** toDecimals;
|
|
66046
66049
|
}
|
|
66047
|
-
} catch
|
|
66048
|
-
console.warn("[swap] Could not
|
|
66050
|
+
} catch {
|
|
66051
|
+
console.warn("[swap] Could not read post-swap balance, using route estimate");
|
|
66049
66052
|
}
|
|
66053
|
+
const fromName = fromEntry ? fromEntry[0] : this._resolveTokenName(fromType, params.from);
|
|
66054
|
+
const toName = toEntry ? toEntry[0] : this._resolveTokenName(toType, params.to);
|
|
66050
66055
|
const routeDesc = route.routerData.paths?.map((p) => p.provider).filter(Boolean).slice(0, 3).join(" + ") ?? "Cetus Aggregator";
|
|
66051
66056
|
return {
|
|
66052
66057
|
success: true,
|
|
66053
66058
|
tx: gasResult.digest,
|
|
66054
|
-
fromToken:
|
|
66055
|
-
toToken:
|
|
66059
|
+
fromToken: fromName,
|
|
66060
|
+
toToken: toName,
|
|
66056
66061
|
fromAmount,
|
|
66057
66062
|
toAmount,
|
|
66058
66063
|
priceImpact: route.priceImpact,
|
|
@@ -66457,6 +66462,12 @@ var T2000 = class _T2000 extends import_index.default {
|
|
|
66457
66462
|
}
|
|
66458
66463
|
return all3;
|
|
66459
66464
|
}
|
|
66465
|
+
_resolveTokenName(coinType, fallback) {
|
|
66466
|
+
const entry = Object.entries(SUPPORTED_ASSETS).find(([, v]) => v.type === coinType);
|
|
66467
|
+
if (entry) return entry[0];
|
|
66468
|
+
const suffix = coinType.split("::").pop();
|
|
66469
|
+
return suffix && suffix !== coinType ? suffix : fallback;
|
|
66470
|
+
}
|
|
66460
66471
|
_mergeCoinsInTx(tx, coins) {
|
|
66461
66472
|
if (coins.length === 0) throw new T2000Error("INSUFFICIENT_BALANCE", "No coins to merge");
|
|
66462
66473
|
const primary = tx.object(coins[0].coinObjectId);
|
|
@@ -67062,4 +67073,4 @@ axios/dist/node/axios.cjs:
|
|
|
67062
67073
|
@scure/bip39/index.js:
|
|
67063
67074
|
(*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) *)
|
|
67064
67075
|
*/
|
|
67065
|
-
//# sourceMappingURL=chunk-
|
|
67076
|
+
//# sourceMappingURL=chunk-JHT7EXQL.js.map
|