@t2000/cli 0.25.11 → 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-CDQ2RJBX.js → chunk-XNKVJ4IY.js} +43 -22
- package/dist/{chunk-CDQ2RJBX.js.map → chunk-XNKVJ4IY.js.map} +1 -1
- package/dist/{dist-OSTBPTHG.js → dist-RQA6LP4F.js} +2 -2
- package/dist/{dist-MGJ75RIY.js → dist-SYASOXYT.js} +2 -2
- package/dist/index.js +3 -3
- package/package.json +3 -3
- /package/dist/{dist-OSTBPTHG.js.map → dist-RQA6LP4F.js.map} +0 -0
- /package/dist/{dist-MGJ75RIY.js.map → dist-SYASOXYT.js.map} +0 -0
|
@@ -66035,30 +66035,51 @@ var T2000 = class _T2000 extends import_index.default {
|
|
|
66035
66035
|
const fromAmount = Number(route.amountIn) / 10 ** fromDecimals;
|
|
66036
66036
|
let toAmount = Number(route.amountOut) / 10 ** toDecimals;
|
|
66037
66037
|
const toTypeSuffix = toType.split("::").slice(1).join("::");
|
|
66038
|
-
|
|
66038
|
+
try {
|
|
66039
|
+
const fullTx = await this.client.waitForTransaction({
|
|
66040
|
+
digest: gasResult.digest,
|
|
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);
|
|
66056
|
+
});
|
|
66057
|
+
if (received) {
|
|
66058
|
+
const actual = Number(BigInt(received.amount)) / 10 ** toDecimals;
|
|
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`);
|
|
66039
66070
|
try {
|
|
66040
|
-
|
|
66041
|
-
|
|
66042
|
-
|
|
66043
|
-
|
|
66044
|
-
|
|
66045
|
-
|
|
66046
|
-
|
|
66047
|
-
|
|
66048
|
-
if (!ownerAddr || ownerAddr.toLowerCase() !== this._address.toLowerCase()) return false;
|
|
66049
|
-
if (c.coinType === toType) return true;
|
|
66050
|
-
return c.coinType.endsWith(toTypeSuffix);
|
|
66051
|
-
});
|
|
66052
|
-
if (received) {
|
|
66053
|
-
const actual = Number(BigInt(received.amount)) / 10 ** toDecimals;
|
|
66054
|
-
if (actual > 0) {
|
|
66055
|
-
toAmount = actual;
|
|
66056
|
-
break;
|
|
66057
|
-
}
|
|
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}`);
|
|
66058
66079
|
}
|
|
66059
|
-
} catch {
|
|
66080
|
+
} catch (err) {
|
|
66081
|
+
console.error(`[swap] Approach 2 failed:`, err);
|
|
66060
66082
|
}
|
|
66061
|
-
if (attempt < 3) await new Promise((r) => setTimeout(r, 600));
|
|
66062
66083
|
}
|
|
66063
66084
|
const fromName = fromEntry ? fromEntry[0] : this._resolveTokenName(fromType, params.from);
|
|
66064
66085
|
const toName = toEntry ? toEntry[0] : this._resolveTokenName(toType, params.to);
|
|
@@ -67083,4 +67104,4 @@ axios/dist/node/axios.cjs:
|
|
|
67083
67104
|
@scure/bip39/index.js:
|
|
67084
67105
|
(*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) *)
|
|
67085
67106
|
*/
|
|
67086
|
-
//# sourceMappingURL=chunk-
|
|
67107
|
+
//# sourceMappingURL=chunk-XNKVJ4IY.js.map
|