@pushchain/core 6.0.6 → 6.0.7
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/package.json
CHANGED
|
@@ -146,7 +146,9 @@ function buildHopDescriptor(ctx, params, route, ueaAddress) {
|
|
|
146
146
|
case route_detector_1.TransactionRoute.UOA_TO_PUSH: {
|
|
147
147
|
// Route 1: Build Push Chain multicalls
|
|
148
148
|
const seedAmount = (_d = params.value) !== null && _d !== void 0 ? _d : BigInt(0);
|
|
149
|
-
if (isValueOnlyNativeSeedToOwnUea(params, ueaAddress
|
|
149
|
+
if (isValueOnlyNativeSeedToOwnUea(params, ueaAddress, {
|
|
150
|
+
allowFunds: true,
|
|
151
|
+
})) {
|
|
150
152
|
return Object.assign(Object.assign({}, baseDescriptor), { pushMulticalls: [], nativeSeedOnly: true, nativeSeedAmount: seedAmount });
|
|
151
153
|
}
|
|
152
154
|
const executeParams = (0, helpers_1.toExecuteParams)(params);
|
|
@@ -643,14 +645,44 @@ function getSegmentType(route) {
|
|
|
643
645
|
function sumMulticallNativeValue(multicalls) {
|
|
644
646
|
return (multicalls !== null && multicalls !== void 0 ? multicalls : []).reduce((sum, mc) => { var _a; return sum + ((_a = mc.value) !== null && _a !== void 0 ? _a : BigInt(0)); }, BigInt(0));
|
|
645
647
|
}
|
|
646
|
-
function isValueOnlyNativeSeedToOwnUea(params, ueaAddress) {
|
|
648
|
+
function isValueOnlyNativeSeedToOwnUea(params, ueaAddress, options) {
|
|
647
649
|
var _a, _b;
|
|
648
650
|
return (((_a = params.value) !== null && _a !== void 0 ? _a : BigInt(0)) > BigInt(0) &&
|
|
649
|
-
!((_b = params.funds) === null || _b === void 0 ? void 0 : _b.amount) &&
|
|
651
|
+
((options === null || options === void 0 ? void 0 : options.allowFunds) === true || !((_b = params.funds) === null || _b === void 0 ? void 0 : _b.amount)) &&
|
|
650
652
|
(0, data_utils_1.isEmptyPayloadData)(params.data) &&
|
|
651
653
|
typeof params.to === 'string' &&
|
|
652
654
|
params.to.toLowerCase() === ueaAddress.toLowerCase());
|
|
653
655
|
}
|
|
656
|
+
function getRootFundsDeposit(hops) {
|
|
657
|
+
let rootFunds;
|
|
658
|
+
for (const hop of hops) {
|
|
659
|
+
// Only the leading Push execution segment is submitted through the root
|
|
660
|
+
// source-chain gateway tx. Later UOA_TO_PUSH hops may be nested inside a
|
|
661
|
+
// Route 3 child inbound and must not attach origin-chain funds to root.
|
|
662
|
+
if (hop.route !== 'UOA_TO_PUSH')
|
|
663
|
+
break;
|
|
664
|
+
const funds = hop.params.funds;
|
|
665
|
+
if (!(funds === null || funds === void 0 ? void 0 : funds.amount) || funds.amount <= BigInt(0))
|
|
666
|
+
continue;
|
|
667
|
+
if (!rootFunds) {
|
|
668
|
+
rootFunds = Object.assign({}, funds);
|
|
669
|
+
continue;
|
|
670
|
+
}
|
|
671
|
+
const currentToken = rootFunds.token;
|
|
672
|
+
const nextToken = funds.token;
|
|
673
|
+
const sameToken = currentToken === nextToken ||
|
|
674
|
+
(!!currentToken &&
|
|
675
|
+
!!nextToken &&
|
|
676
|
+
currentToken.address.toLowerCase() === nextToken.address.toLowerCase() &&
|
|
677
|
+
currentToken.symbol === nextToken.symbol &&
|
|
678
|
+
currentToken.mechanism === nextToken.mechanism);
|
|
679
|
+
if (!sameToken) {
|
|
680
|
+
throw new Error('Cascade can only bridge one origin token in root Push execution hops. Split mixed-token deposits into separate transactions.');
|
|
681
|
+
}
|
|
682
|
+
rootFunds = Object.assign(Object.assign({}, rootFunds), { amount: rootFunds.amount + funds.amount });
|
|
683
|
+
}
|
|
684
|
+
return rootFunds;
|
|
685
|
+
}
|
|
654
686
|
function isNativeSeedOnlyHop(hop) {
|
|
655
687
|
return (hop === null || hop === void 0 ? void 0 : hop.nativeSeedOnly) === true;
|
|
656
688
|
}
|
|
@@ -1411,6 +1443,10 @@ function createCascadedBuilder(ctx, preparedTxs, callbacks, defaultEventHook) {
|
|
|
1411
1443
|
value: cascadeRequiredNativeValue,
|
|
1412
1444
|
data: composedMulticalls,
|
|
1413
1445
|
};
|
|
1446
|
+
const rootFundsDeposit = getRootFundsDeposit(hops);
|
|
1447
|
+
if (rootFundsDeposit) {
|
|
1448
|
+
executeParams.funds = rootFundsDeposit;
|
|
1449
|
+
}
|
|
1414
1450
|
const response = yield withMultihopRootProgressMapping(ctx, () => callbacks.executeFn(executeParams));
|
|
1415
1451
|
// Build hop info for tracking
|
|
1416
1452
|
const hopInfos = hops.map((hop, index) => ({
|
|
@@ -33,6 +33,7 @@ const svm_bridge_1 = require("./svm-bridge");
|
|
|
33
33
|
const signing_1 = require("./signing");
|
|
34
34
|
const quote_1 = require("./quote");
|
|
35
35
|
const formatters_1 = require("../../formatters");
|
|
36
|
+
const helpers_1 = require("./helpers");
|
|
36
37
|
function executeFundsWithPayload(ctx, execute, eventBuffer, getResponseCallbacks) {
|
|
37
38
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
38
39
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
@@ -111,6 +112,25 @@ function executeFundsWithPayload(ctx, execute, eventBuffer, getResponseCallbacks
|
|
|
111
112
|
// Apply sizer floor: Case A pads to $1, Cases B/C pass-through.
|
|
112
113
|
if (depositUsd < r1Sizing.paddedDepositUsd)
|
|
113
114
|
depositUsd = r1Sizing.paddedDepositUsd;
|
|
115
|
+
// Match funds-only and standard fee-lock sizing: fixed PC→USD conversion can
|
|
116
|
+
// underfund large PC deposits when the live pETH/WPC pool has meaningful
|
|
117
|
+
// slippage. Quote the native amount required for the target WPC output and
|
|
118
|
+
// raise the USD deposit before converting back to source-chain native value.
|
|
119
|
+
if (chain_1.CHAIN_INFO[chain].vm === enums_1.VM.EVM && requiredFunds > ueaBalance) {
|
|
120
|
+
const deficit = requiredFunds - ueaBalance;
|
|
121
|
+
const targetWpc = (deficit * BigInt(12)) / BigInt(10);
|
|
122
|
+
const originPrc20 = (0, helpers_1.getNativePRC20ForChain)(chain, ctx.pushNetwork);
|
|
123
|
+
const poolNativeAmount = yield (0, gas_calculator_1.estimateNativeForDesiredDeposit)(ctx, targetWpc, originPrc20);
|
|
124
|
+
if (poolNativeAmount > BigInt(0)) {
|
|
125
|
+
const poolBasedUsd = (poolNativeAmount * nativeTokenUsdPrice) / oneNativeUnit;
|
|
126
|
+
if (poolBasedUsd > depositUsd) {
|
|
127
|
+
(0, context_1.printLog)(ctx, `sendFundsWithPayload — pool-based deposit sizing overrides fixed-rate estimate: ` +
|
|
128
|
+
`fixedUsd=${depositUsd.toString()}, poolBasedUsd=${poolBasedUsd.toString()}, ` +
|
|
129
|
+
`requiredFunds=${requiredFunds.toString()}, ueaBalance=${ueaBalance.toString()}`);
|
|
130
|
+
depositUsd = poolBasedUsd;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
114
134
|
// If SVM, clamp depositUsd to on-chain Config caps
|
|
115
135
|
if (chain_1.CHAIN_INFO[chain].vm === enums_1.VM.SVM) {
|
|
116
136
|
const svmClient = new svm_client_1.SvmClient({
|