@1llet.xyz/erc4337-gasless-sdk 0.4.66 → 0.4.70

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 CHANGED
@@ -510,20 +510,15 @@ declare function getStargateSimulation(sourceChain: string, destChain: string, a
510
510
 
511
511
  declare class UniswapService {
512
512
  private publicClient;
513
- constructor();
514
- /**
515
- * Get PoolKey for USDC/WETH on Base V4
516
- * Assuming standard fee tier 0.05% (500) and tickSpacing 10
517
- */
518
- private getPoolKey;
513
+ constructor(rpcUrl: string);
519
514
  /**
520
- * Quote USDC needed for exact ETH output using Uniswap V4
515
+ * Quote USDC needed for exact ETH output using Uniswap V3
521
516
  */
522
517
  quoteUSDCForETH(amountOutETH: bigint): Promise<bigint>;
523
518
  /**
524
- * Build tx data for swapping USDC -> ETH using Universal Router (V4)
519
+ * Build tx data for swapping USDC -> ETH using Uniswap V3 SwapRouter02
525
520
  */
526
- buildSwapData(recipient: Address, amountOutETH: bigint, maxAmountInUSDC: bigint): Hex;
521
+ buildSwapData(recipient: Address, amountInMax: bigint, amountOutETH: bigint): Hex;
527
522
  getRouterAddress(): Address;
528
523
  getUSDCAddress(): Address;
529
524
  }
package/dist/index.d.ts CHANGED
@@ -510,20 +510,15 @@ declare function getStargateSimulation(sourceChain: string, destChain: string, a
510
510
 
511
511
  declare class UniswapService {
512
512
  private publicClient;
513
- constructor();
514
- /**
515
- * Get PoolKey for USDC/WETH on Base V4
516
- * Assuming standard fee tier 0.05% (500) and tickSpacing 10
517
- */
518
- private getPoolKey;
513
+ constructor(rpcUrl: string);
519
514
  /**
520
- * Quote USDC needed for exact ETH output using Uniswap V4
515
+ * Quote USDC needed for exact ETH output using Uniswap V3
521
516
  */
522
517
  quoteUSDCForETH(amountOutETH: bigint): Promise<bigint>;
523
518
  /**
524
- * Build tx data for swapping USDC -> ETH using Universal Router (V4)
519
+ * Build tx data for swapping USDC -> ETH using Uniswap V3 SwapRouter02
525
520
  */
526
- buildSwapData(recipient: Address, amountOutETH: bigint, maxAmountInUSDC: bigint): Hex;
521
+ buildSwapData(recipient: Address, amountInMax: bigint, amountOutETH: bigint): Hex;
527
522
  getRouterAddress(): Address;
528
523
  getUSDCAddress(): Address;
529
524
  }
package/dist/index.js CHANGED
@@ -2851,117 +2851,74 @@ init_TransferManager();
2851
2851
  init_near();
2852
2852
  init_cctp2();
2853
2853
  init_stargate();
2854
- var UNIVERSAL_ROUTER = "0x95273d871c8156636e114b63797d78D7E1720d81";
2855
- var QUOTER_V4 = "0x52F0E24D1c21C8A0cB1e5a5dD6198556BD9E1203";
2854
+ var SWAP_ROUTER_02 = "0x2626664c2603336E57B271c5C0b26F421741e481";
2855
+ var QUOTER_V2 = "0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a";
2856
2856
  var USDC_ADDRESS = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
2857
2857
  var WETH_ADDRESS = "0x4200000000000000000000000000000000000006";
2858
- var V4_SWAP_COMMAND = "0x10";
2859
- var UNWRAP_WETH_COMMAND = "0x0c";
2860
- var QUOTER_V4_ABI = viem.parseAbi([
2861
- "function quoteExactOutputSingle((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, (bool zeroForOne, int128 amount, uint160 sqrtPriceLimitX96) params, bytes hookData) external returns (uint256 amountIn, uint256 gasEstimate)"
2858
+ var QUOTER_ABI = viem.parseAbi([
2859
+ "function quoteExactOutputSingle((address tokenIn, address tokenOut, uint256 amount, uint24 fee, uint160 sqrtPriceLimitX96) params) external returns (uint256 amountIn, uint160 sqrtPriceX96After, uint32 initializedTicksCrossed, uint256 gasEstimate)"
2862
2860
  ]);
2863
- var UNIVERSAL_ROUTER_ABI = viem.parseAbi([
2864
- "function execute(bytes calldata commands, bytes[] calldata inputs, uint256 deadline) external payable"
2861
+ var ROUTER_ABI = viem.parseAbi([
2862
+ "function exactOutputSingle((address tokenIn, address tokenOut, uint24 fee, address recipient, uint256 amountOut, uint256 amountInMaximum, uint160 sqrtPriceLimitX96) params) external payable returns (uint256 amountIn)"
2865
2863
  ]);
2866
2864
  var UniswapService = class {
2867
- constructor() {
2865
+ constructor(rpcUrl) {
2868
2866
  this.publicClient = viem.createPublicClient({
2869
- chain: chains.base,
2870
- transport: viem.http("https://mainnet.base.org")
2871
- // Default public RPC
2867
+ transport: viem.http(rpcUrl)
2872
2868
  });
2873
2869
  }
2874
2870
  /**
2875
- * Get PoolKey for USDC/WETH on Base V4
2876
- * Assuming standard fee tier 0.05% (500) and tickSpacing 10
2877
- */
2878
- getPoolKey() {
2879
- const isUSDC0 = USDC_ADDRESS.toLowerCase() < WETH_ADDRESS.toLowerCase();
2880
- const currency0 = isUSDC0 ? USDC_ADDRESS : WETH_ADDRESS;
2881
- const currency1 = isUSDC0 ? WETH_ADDRESS : USDC_ADDRESS;
2882
- return {
2883
- currency0,
2884
- currency1,
2885
- fee: 500,
2886
- // 0.05%
2887
- tickSpacing: 10,
2888
- hooks: "0x0000000000000000000000000000000000000000"
2889
- };
2890
- }
2891
- /**
2892
- * Quote USDC needed for exact ETH output using Uniswap V4
2871
+ * Quote USDC needed for exact ETH output using Uniswap V3
2893
2872
  */
2894
2873
  async quoteUSDCForETH(amountOutETH) {
2895
2874
  try {
2896
- const key = this.getPoolKey();
2897
- const isUSDC0 = USDC_ADDRESS.toLowerCase() < WETH_ADDRESS.toLowerCase();
2898
- const zeroForOne = isUSDC0;
2899
- const amountParam = -amountOutETH;
2900
2875
  const result = await this.publicClient.readContract({
2901
- address: QUOTER_V4,
2902
- abi: QUOTER_V4_ABI,
2876
+ address: QUOTER_V2,
2877
+ abi: QUOTER_ABI,
2903
2878
  functionName: "quoteExactOutputSingle",
2904
- args: [
2905
- key,
2906
- {
2907
- zeroForOne,
2908
- amount: amountParam,
2909
- // Negative for Exact Output
2910
- sqrtPriceLimitX96: 0n
2911
- },
2912
- "0x"
2913
- // No hook data
2914
- ]
2879
+ args: [{
2880
+ tokenIn: USDC_ADDRESS,
2881
+ tokenOut: WETH_ADDRESS,
2882
+ amount: amountOutETH,
2883
+ fee: 500,
2884
+ // 0.05%
2885
+ sqrtPriceLimitX96: 0n
2886
+ }]
2915
2887
  });
2916
2888
  const amountIn = result[0];
2917
2889
  return amountIn * 105n / 100n;
2918
- } catch (e) {
2919
- console.error("V4 Quote failed", e);
2920
- throw new Error("Failed to quote USDC for ETH swap on Uniswap V4");
2890
+ } catch (error) {
2891
+ console.error("Failed to quote USDC for ETH swap on Uniswap V3", error);
2892
+ throw new Error(`Failed to quote USDC for ETH swap on Uniswap V3`);
2921
2893
  }
2922
2894
  }
2923
2895
  /**
2924
- * Build tx data for swapping USDC -> ETH using Universal Router (V4)
2896
+ * Build tx data for swapping USDC -> ETH using Uniswap V3 SwapRouter02
2925
2897
  */
2926
- buildSwapData(recipient, amountOutETH, maxAmountInUSDC) {
2927
- const key = this.getPoolKey();
2928
- const isUSDC0 = USDC_ADDRESS.toLowerCase() < WETH_ADDRESS.toLowerCase();
2929
- const zeroForOne = isUSDC0;
2930
- const swapInput = viem.encodeAbiParameters(
2931
- viem.parseAbiParameters("((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, bool zeroForOne, int128 amountSpecified, uint160 sqrtPriceLimitX96, bytes hookData)"),
2932
- [
2933
- key,
2934
- zeroForOne,
2935
- -amountOutETH,
2936
- // exact output
2937
- 0n,
2938
- // no price limit
2939
- "0x"
2940
- // no hook data
2941
- ]
2942
- );
2943
- const unwrapInput = viem.encodeAbiParameters(
2944
- viem.parseAbiParameters("address, uint256"),
2945
- [recipient, amountOutETH]
2946
- // Unwrap at least the output amount.
2947
- );
2948
- const commands = V4_SWAP_COMMAND + UNWRAP_WETH_COMMAND.substring(2);
2949
- const inputs = [swapInput, unwrapInput];
2950
- const deadline = BigInt(Math.floor(Date.now() / 1e3) + 300);
2898
+ buildSwapData(recipient, amountInMax, amountOutETH) {
2951
2899
  return viem.encodeFunctionData({
2952
- abi: UNIVERSAL_ROUTER_ABI,
2953
- functionName: "execute",
2954
- args: [commands, inputs, deadline]
2900
+ abi: ROUTER_ABI,
2901
+ functionName: "exactOutputSingle",
2902
+ args: [{
2903
+ tokenIn: USDC_ADDRESS,
2904
+ tokenOut: WETH_ADDRESS,
2905
+ fee: 500,
2906
+ // 0.05%
2907
+ recipient,
2908
+ amountOut: amountOutETH,
2909
+ amountInMaximum: amountInMax,
2910
+ sqrtPriceLimitX96: 0n
2911
+ }]
2955
2912
  });
2956
2913
  }
2957
2914
  getRouterAddress() {
2958
- return UNIVERSAL_ROUTER;
2915
+ return SWAP_ROUTER_02;
2959
2916
  }
2960
2917
  getUSDCAddress() {
2961
2918
  return USDC_ADDRESS;
2962
2919
  }
2963
2920
  };
2964
- var uniswapService = new UniswapService();
2921
+ var uniswapService = new UniswapService("https://mainnet.base.org");
2965
2922
 
2966
2923
  exports.AccountAbstraction = AccountAbstraction;
2967
2924
  exports.BASE_MAINNET = BASE_MAINNET;