@pushchain/core 5.1.4-alpha.10 → 5.1.4-alpha.11
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
|
@@ -757,9 +757,43 @@ function executeCeaToPush(ctx, params, executeFn) {
|
|
|
757
757
|
const currentBalance = ueaBalance;
|
|
758
758
|
// Cosmos-EVM tx overhead costs ~1 PC per operation; 3 PC covers approve(s) + buffer.
|
|
759
759
|
const OUTBOUND_GAS_RESERVE_R3 = BigInt(3e18);
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
760
|
+
const ROUTE3_MINIMUM_DEPOSIT_USD = utils_1.Utils.helpers.parseUnits('10', 8); // $10
|
|
761
|
+
// For fresh wallets: predict post-fee-locking UPC balance using the same
|
|
762
|
+
// Uniswap V3 quoter the chain uses (pETH → WPC swap), matching Route 2 logic.
|
|
763
|
+
let effectiveBalance = currentBalance;
|
|
764
|
+
if (!isUEADeployed && effectiveBalance <= OUTBOUND_GAS_RESERVE_R3) {
|
|
765
|
+
const signerChain = ctx.universalSigner.account.chain;
|
|
766
|
+
const ethPrice = yield new price_fetch_1.PriceFetch(ctx.rpcUrls).getPrice(signerChain);
|
|
767
|
+
const nativeAmountETH = ethPrice > BigInt(0)
|
|
768
|
+
? (ROUTE3_MINIMUM_DEPOSIT_USD * BigInt(1e18) + (ethPrice - BigInt(1))) / ethPrice + BigInt(1)
|
|
769
|
+
: BigInt(0);
|
|
770
|
+
if (nativeAmountETH > BigInt(0)) {
|
|
771
|
+
const originPrc20 = (0, helpers_1.getNativePRC20ForChain)(signerChain, ctx.pushNetwork);
|
|
772
|
+
const predictedUPC = yield (0, gas_calculator_1.estimateDepositFromLockedNative)(ctx, nativeAmountETH, originPrc20);
|
|
773
|
+
if (predictedUPC > BigInt(0)) {
|
|
774
|
+
effectiveBalance = (predictedUPC * BigInt(90)) / BigInt(100);
|
|
775
|
+
(0, context_1.printLog)(ctx, `executeCeaToPush — fresh wallet: Uniswap quote predicts ${predictedUPC.toString()} UPC ` +
|
|
776
|
+
`from ${nativeAmountETH.toString()} wei pETH, using ${effectiveBalance.toString()} (90%)`);
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
// Balance-aware adjustment matching Route 2 logic:
|
|
781
|
+
// - If balance exceeds target + reserve: use target (200 UPC)
|
|
782
|
+
// - If balance exceeds reserve: use balance - reserve (maximize within budget)
|
|
783
|
+
// - Otherwise: keep original nativeValueForGas (fallback)
|
|
784
|
+
const EVM_NATIVE_VALUE_TARGET_R3 = BigInt(200e18); // 200 UPC
|
|
785
|
+
let adjustedValue;
|
|
786
|
+
if (effectiveBalance > EVM_NATIVE_VALUE_TARGET_R3 + OUTBOUND_GAS_RESERVE_R3) {
|
|
787
|
+
adjustedValue = EVM_NATIVE_VALUE_TARGET_R3;
|
|
788
|
+
}
|
|
789
|
+
else if (effectiveBalance > OUTBOUND_GAS_RESERVE_R3) {
|
|
790
|
+
adjustedValue = effectiveBalance - OUTBOUND_GAS_RESERVE_R3;
|
|
791
|
+
}
|
|
792
|
+
else {
|
|
793
|
+
adjustedValue = nativeValueForGas;
|
|
794
|
+
}
|
|
795
|
+
if (adjustedValue !== nativeValueForGas) {
|
|
796
|
+
(0, context_1.printLog)(ctx, `executeCeaToPush — adjusting nativeValueForGas from ${nativeValueForGas.toString()} to ${adjustedValue.toString()} (effective balance: ${effectiveBalance.toString()})`);
|
|
763
797
|
nativeValueForGas = adjustedValue;
|
|
764
798
|
}
|
|
765
799
|
// 12. Build Push Chain multicalls (approvals + sendUniversalTxOutbound)
|
|
@@ -776,17 +810,11 @@ function executeCeaToPush(ctx, params, executeFn) {
|
|
|
776
810
|
// Sum native values from multicall entries for proper fee calculation
|
|
777
811
|
const multicallNativeValue = pushChainMulticalls.reduce((sum, mc) => { var _a; return sum + ((_a = mc.value) !== null && _a !== void 0 ? _a : BigInt(0)); }, BigInt(0));
|
|
778
812
|
// 13. Execute through the normal execute() flow
|
|
779
|
-
const executeParams = {
|
|
780
|
-
to: ueaAddress,
|
|
781
|
-
value: multicallNativeValue, // ensures correct requiredFunds calculation
|
|
782
|
-
data: pushChainMulticalls,
|
|
783
|
-
_ueaStatus: {
|
|
813
|
+
const executeParams = Object.assign({ to: ueaAddress, value: multicallNativeValue, data: pushChainMulticalls, _ueaStatus: {
|
|
784
814
|
isDeployed: isUEADeployed,
|
|
785
815
|
nonce: ueaNonce,
|
|
786
816
|
balance: ueaBalance,
|
|
787
|
-
},
|
|
788
|
-
_skipFeeLocking: true, // outbound executes on Push Chain, no external fee locking
|
|
789
|
-
};
|
|
817
|
+
}, _skipFeeLocking: isUEADeployed }, (!isUEADeployed ? { _minimumDepositUsd: ROUTE3_MINIMUM_DEPOSIT_USD } : {}));
|
|
790
818
|
const response = yield executeFn(executeParams);
|
|
791
819
|
// Add Route 3 context to response
|
|
792
820
|
response.chain = sourceChain;
|
|
@@ -920,17 +948,11 @@ function executeCeaToPushSvm(ctx, params, sourceChain, executeFn) {
|
|
|
920
948
|
// Sum native values from multicall entries for proper fee calculation
|
|
921
949
|
const multicallNativeValue = pushChainMulticalls.reduce((sum, mc) => { var _a; return sum + ((_a = mc.value) !== null && _a !== void 0 ? _a : BigInt(0)); }, BigInt(0));
|
|
922
950
|
// Execute through the normal execute() flow
|
|
923
|
-
const executeParams = {
|
|
924
|
-
to: ueaAddress,
|
|
925
|
-
value: multicallNativeValue, // ensures correct requiredFunds calculation
|
|
926
|
-
data: pushChainMulticalls,
|
|
927
|
-
_ueaStatus: {
|
|
951
|
+
const executeParams = Object.assign({ to: ueaAddress, value: multicallNativeValue, data: pushChainMulticalls, _ueaStatus: {
|
|
928
952
|
isDeployed: isUEADeployed,
|
|
929
953
|
nonce: ueaNonce,
|
|
930
954
|
balance: ueaBalance,
|
|
931
|
-
},
|
|
932
|
-
_skipFeeLocking: true, // outbound executes on Push Chain, no external fee locking
|
|
933
|
-
};
|
|
955
|
+
}, _skipFeeLocking: isUEADeployed }, (!isUEADeployed ? { _minimumDepositUsd: utils_1.Utils.helpers.parseUnits('10', 8) } : {}));
|
|
934
956
|
const response = yield executeFn(executeParams);
|
|
935
957
|
// Add Route 3 SVM context to response
|
|
936
958
|
response.chain = sourceChain;
|