@1llet.xyz/erc4337-gasless-sdk 0.4.57 → 0.4.59
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/index.d.mts +19 -1
- package/dist/index.d.ts +19 -1
- package/dist/index.js +89 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +89 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { monad, unichain, arbitrum, polygon, bsc, avalanche, optimism, gnosis, b
|
|
|
2
2
|
import * as StellarSdk from 'stellar-sdk';
|
|
3
3
|
import { Networks } from 'stellar-sdk';
|
|
4
4
|
import axios from 'axios';
|
|
5
|
-
import { createPublicClient, http, createWalletClient, decodeErrorResult,
|
|
5
|
+
import { parseAbi, createPublicClient, http, encodeFunctionData, createWalletClient, decodeErrorResult, encodeAbiParameters, keccak256, maxUint256, padHex } from 'viem';
|
|
6
6
|
import { privateKeyToAccount } from 'viem/accounts';
|
|
7
7
|
import { OpenAPI, OneClickService, QuoteRequest } from '@defuse-protocol/one-click-sdk-typescript';
|
|
8
8
|
|
|
@@ -1650,15 +1650,15 @@ var init_near = __esm({
|
|
|
1650
1650
|
return { success: false, errorReason: `Stellar Verification Failed: ${e.message}` };
|
|
1651
1651
|
}
|
|
1652
1652
|
}
|
|
1653
|
-
const { createPublicClient:
|
|
1653
|
+
const { createPublicClient: createPublicClient4, http: http4 } = await import('viem');
|
|
1654
1654
|
const { FACILITATOR_NETWORKS: FACILITATOR_NETWORKS2 } = await Promise.resolve().then(() => (init_facilitator(), facilitator_exports));
|
|
1655
1655
|
const networkConfig = FACILITATOR_NETWORKS2[sourceChain];
|
|
1656
1656
|
if (!networkConfig) {
|
|
1657
1657
|
return { success: false, errorReason: `Unsupported source chain for verification: ${sourceChain}` };
|
|
1658
1658
|
}
|
|
1659
|
-
const publicClient =
|
|
1659
|
+
const publicClient = createPublicClient4({
|
|
1660
1660
|
chain: networkConfig.chain,
|
|
1661
|
-
transport:
|
|
1661
|
+
transport: http4(networkConfig.rpcUrl)
|
|
1662
1662
|
});
|
|
1663
1663
|
try {
|
|
1664
1664
|
console.log(`[NearStrategy] Waiting for receipt...`);
|
|
@@ -2827,7 +2827,91 @@ init_TransferManager();
|
|
|
2827
2827
|
init_near();
|
|
2828
2828
|
init_cctp2();
|
|
2829
2829
|
init_stargate();
|
|
2830
|
+
var UNISWAP_V3_ROUTER = "0x2626664c2603336E57B271c5C0b26F421741e481";
|
|
2831
|
+
var UNISWAP_V3_QUOTER = "0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a";
|
|
2832
|
+
var USDC_ADDRESS = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
2833
|
+
var WETH_ADDRESS = "0x4200000000000000000000000000000000000006";
|
|
2834
|
+
var QUOTER_ABI = parseAbi([
|
|
2835
|
+
"function quoteExactOutputSingle(tuple(address tokenIn, address tokenOut, uint256 amount, uint24 fee, uint160 sqrtPriceLimitX96) params) external returns (uint256 amountIn, uint160 sqrtPriceX96After, uint32 initializedTicksCrossed, uint256 gasEstimate)"
|
|
2836
|
+
]);
|
|
2837
|
+
var ROUTER_ABI = parseAbi([
|
|
2838
|
+
"function exactOutputSingle(tuple(address tokenIn, address tokenOut, uint24 fee, address recipient, uint256 amountOut, uint256 amountInMaximum, uint160 sqrtPriceLimitX96) params) external payable returns (uint256 amountIn)"
|
|
2839
|
+
]);
|
|
2840
|
+
var UniswapService = class {
|
|
2841
|
+
constructor() {
|
|
2842
|
+
this.publicClient = createPublicClient({
|
|
2843
|
+
chain: base,
|
|
2844
|
+
transport: http("https://mainnet.base.org")
|
|
2845
|
+
// Default public RPC
|
|
2846
|
+
});
|
|
2847
|
+
}
|
|
2848
|
+
/**
|
|
2849
|
+
* Get amount of USDC needed to buy exact amount of ETH
|
|
2850
|
+
* @param amountETHWei Amount of ETH (Wei) needed
|
|
2851
|
+
*/
|
|
2852
|
+
async quoteUSDCForETH(amountETHWei) {
|
|
2853
|
+
try {
|
|
2854
|
+
const params = {
|
|
2855
|
+
tokenIn: USDC_ADDRESS,
|
|
2856
|
+
tokenOut: WETH_ADDRESS,
|
|
2857
|
+
amount: amountETHWei,
|
|
2858
|
+
fee: 500,
|
|
2859
|
+
sqrtPriceLimitX96: 0n
|
|
2860
|
+
};
|
|
2861
|
+
const result = await this.publicClient.readContract({
|
|
2862
|
+
address: UNISWAP_V3_QUOTER,
|
|
2863
|
+
abi: QUOTER_ABI,
|
|
2864
|
+
functionName: "quoteExactOutputSingle",
|
|
2865
|
+
args: [params]
|
|
2866
|
+
});
|
|
2867
|
+
const amountIn = result[0];
|
|
2868
|
+
return amountIn * 101n / 100n;
|
|
2869
|
+
} catch (e) {
|
|
2870
|
+
console.error("Quote failed", e);
|
|
2871
|
+
throw new Error("Failed to quote USDC for ETH swap");
|
|
2872
|
+
}
|
|
2873
|
+
}
|
|
2874
|
+
/**
|
|
2875
|
+
* Build tx data for swapping USDC -> ETH
|
|
2876
|
+
* Uses SwapRouter02.exactOutputSingle + unwrapWETH9
|
|
2877
|
+
*/
|
|
2878
|
+
buildSwapData(recipient, amountOutETH, maxAmountInUSDC) {
|
|
2879
|
+
const swapParams = {
|
|
2880
|
+
tokenIn: USDC_ADDRESS,
|
|
2881
|
+
tokenOut: WETH_ADDRESS,
|
|
2882
|
+
fee: 500,
|
|
2883
|
+
recipient: "0x0000000000000000000000000000000000000000",
|
|
2884
|
+
// Router address constant for internal unwrap? usually encoded as address(0) or router itself
|
|
2885
|
+
amountOut: amountOutETH,
|
|
2886
|
+
amountInMaximum: maxAmountInUSDC,
|
|
2887
|
+
sqrtPriceLimitX96: 0n
|
|
2888
|
+
};
|
|
2889
|
+
const swapCalldata = encodeFunctionData({
|
|
2890
|
+
abi: ROUTER_ABI,
|
|
2891
|
+
functionName: "exactOutputSingle",
|
|
2892
|
+
args: [swapParams]
|
|
2893
|
+
});
|
|
2894
|
+
const unwrapCalldata = encodeFunctionData({
|
|
2895
|
+
abi: parseAbi(["function unwrapWETH9(uint256 amountMinimum, address recipient) payable"]),
|
|
2896
|
+
functionName: "unwrapWETH9",
|
|
2897
|
+
args: [amountOutETH, recipient]
|
|
2898
|
+
});
|
|
2899
|
+
const multicallCalldata = encodeFunctionData({
|
|
2900
|
+
abi: parseAbi(["function multicall(bytes[] data) payable returns (bytes[])"]),
|
|
2901
|
+
functionName: "multicall",
|
|
2902
|
+
args: [[swapCalldata, unwrapCalldata]]
|
|
2903
|
+
});
|
|
2904
|
+
return multicallCalldata;
|
|
2905
|
+
}
|
|
2906
|
+
getRouterAddress() {
|
|
2907
|
+
return UNISWAP_V3_ROUTER;
|
|
2908
|
+
}
|
|
2909
|
+
getUSDCAddress() {
|
|
2910
|
+
return USDC_ADDRESS;
|
|
2911
|
+
}
|
|
2912
|
+
};
|
|
2913
|
+
var uniswapService = new UniswapService();
|
|
2830
2914
|
|
|
2831
|
-
export { AccountAbstraction, BASE_MAINNET, BASE_SEPOLIA2 as BASE_SEPOLIA, BundlerClient, CCTPStrategy, CHAIN_CONFIGS, CHAIN_ID_TO_KEY, GNOSIS_MAINNET, NearStrategy, OPTIMISM_MAINNET, STELLAR, STELLAR_MAINNET, StargateStrategy, StellarService, TransferManager, entryPointAbi, erc20Abi, getNearSimulation, getStargateSimulation, smartAccountAbi };
|
|
2915
|
+
export { AccountAbstraction, BASE_MAINNET, BASE_SEPOLIA2 as BASE_SEPOLIA, BundlerClient, CCTPStrategy, CHAIN_CONFIGS, CHAIN_ID_TO_KEY, GNOSIS_MAINNET, NearStrategy, OPTIMISM_MAINNET, STELLAR, STELLAR_MAINNET, StargateStrategy, StellarService, TransferManager, UniswapService, entryPointAbi, erc20Abi, getNearSimulation, getStargateSimulation, smartAccountAbi, uniswapService };
|
|
2832
2916
|
//# sourceMappingURL=index.mjs.map
|
|
2833
2917
|
//# sourceMappingURL=index.mjs.map
|