@t2000/cli 0.25.10 → 0.25.12
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-CEYH4WJI.js → chunk-XNKVJ4IY.js} +40 -9
- package/dist/{chunk-CEYH4WJI.js.map → chunk-XNKVJ4IY.js.map} +1 -1
- package/dist/{dist-RWDYR67F.js → dist-RQA6LP4F.js} +2 -2
- package/dist/{dist-KPKCZ4IO.js → dist-SYASOXYT.js} +2 -2
- package/dist/index.js +3 -3
- package/package.json +3 -3
- /package/dist/{dist-RWDYR67F.js.map → dist-RQA6LP4F.js.map} +0 -0
- /package/dist/{dist-KPKCZ4IO.js.map → dist-SYASOXYT.js.map} +0 -0
|
@@ -66034,21 +66034,52 @@ var T2000 = class _T2000 extends import_index.default {
|
|
|
66034
66034
|
const toDecimals = toEntry ? toEntry[1].decimals : toType === "0x2::sui::SUI" ? 9 : 6;
|
|
66035
66035
|
const fromAmount = Number(route.amountIn) / 10 ** fromDecimals;
|
|
66036
66036
|
let toAmount = Number(route.amountOut) / 10 ** toDecimals;
|
|
66037
|
+
const toTypeSuffix = toType.split("::").slice(1).join("::");
|
|
66037
66038
|
try {
|
|
66038
|
-
const
|
|
66039
|
+
const fullTx = await this.client.waitForTransaction({
|
|
66039
66040
|
digest: gasResult.digest,
|
|
66040
|
-
options: { showBalanceChanges: true }
|
|
66041
|
+
options: { showBalanceChanges: true },
|
|
66042
|
+
timeout: 8e3,
|
|
66043
|
+
pollInterval: 400
|
|
66044
|
+
});
|
|
66045
|
+
const changes = fullTx.balanceChanges ?? [];
|
|
66046
|
+
console.error(`[swap] balanceChanges count=${changes.length}, toType=${toType}`);
|
|
66047
|
+
for (const c of changes) {
|
|
66048
|
+
console.error(`[swap] coinType=${c.coinType} amount=${c.amount} owner=${JSON.stringify(c.owner)}`);
|
|
66049
|
+
}
|
|
66050
|
+
const received = changes.find((c) => {
|
|
66051
|
+
if (BigInt(c.amount) <= 0n) return false;
|
|
66052
|
+
const ownerAddr = c.owner?.AddressOwner;
|
|
66053
|
+
if (!ownerAddr || ownerAddr.toLowerCase() !== this._address.toLowerCase()) return false;
|
|
66054
|
+
if (c.coinType === toType) return true;
|
|
66055
|
+
return c.coinType.endsWith(toTypeSuffix);
|
|
66041
66056
|
});
|
|
66042
|
-
const changes = txBlock.balanceChanges ?? [];
|
|
66043
|
-
const received = changes.find(
|
|
66044
|
-
(c) => c.coinType === toType && BigInt(c.amount) > 0n && c.owner.AddressOwner === this._address
|
|
66045
|
-
);
|
|
66046
66057
|
if (received) {
|
|
66047
66058
|
const actual = Number(BigInt(received.amount)) / 10 ** toDecimals;
|
|
66048
66059
|
if (actual > 0) toAmount = actual;
|
|
66060
|
+
console.error(`[swap] Approach 1 success: toAmount=${toAmount}`);
|
|
66061
|
+
} else {
|
|
66062
|
+
console.error(`[swap] Approach 1: no matching balance change found`);
|
|
66063
|
+
}
|
|
66064
|
+
} catch (err) {
|
|
66065
|
+
console.error(`[swap] Approach 1 failed:`, err);
|
|
66066
|
+
}
|
|
66067
|
+
const cetusEstimate = Number(route.amountOut) / 10 ** toDecimals;
|
|
66068
|
+
if (Math.abs(toAmount - cetusEstimate) < 1e-3) {
|
|
66069
|
+
console.error(`[swap] toAmount still equals Cetus estimate (${cetusEstimate}), trying balance diff`);
|
|
66070
|
+
try {
|
|
66071
|
+
await new Promise((r) => setTimeout(r, 2e3));
|
|
66072
|
+
const postBal = await this.client.getBalance({ owner: this._address, coinType: toType });
|
|
66073
|
+
const postRaw = BigInt(postBal.totalBalance);
|
|
66074
|
+
const human = Number(postRaw) / 10 ** toDecimals;
|
|
66075
|
+
console.error(`[swap] Approach 2: postBalance raw=${postRaw} human=${human}`);
|
|
66076
|
+
if (human > toAmount * 10) {
|
|
66077
|
+
toAmount = human;
|
|
66078
|
+
console.error(`[swap] Approach 2: using total balance as estimate: ${toAmount}`);
|
|
66079
|
+
}
|
|
66080
|
+
} catch (err) {
|
|
66081
|
+
console.error(`[swap] Approach 2 failed:`, err);
|
|
66049
66082
|
}
|
|
66050
|
-
} catch {
|
|
66051
|
-
console.warn("[swap] Could not read balance changes, using route estimate");
|
|
66052
66083
|
}
|
|
66053
66084
|
const fromName = fromEntry ? fromEntry[0] : this._resolveTokenName(fromType, params.from);
|
|
66054
66085
|
const toName = toEntry ? toEntry[0] : this._resolveTokenName(toType, params.to);
|
|
@@ -67073,4 +67104,4 @@ axios/dist/node/axios.cjs:
|
|
|
67073
67104
|
@scure/bip39/index.js:
|
|
67074
67105
|
(*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) *)
|
|
67075
67106
|
*/
|
|
67076
|
-
//# sourceMappingURL=chunk-
|
|
67107
|
+
//# sourceMappingURL=chunk-XNKVJ4IY.js.map
|