@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.d.mts
CHANGED
|
@@ -508,4 +508,22 @@ declare function getStargateSimulation(sourceChain: string, destChain: string, a
|
|
|
508
508
|
minAmount?: undefined;
|
|
509
509
|
}>;
|
|
510
510
|
|
|
511
|
-
|
|
511
|
+
declare class UniswapService {
|
|
512
|
+
private publicClient;
|
|
513
|
+
constructor();
|
|
514
|
+
/**
|
|
515
|
+
* Get amount of USDC needed to buy exact amount of ETH
|
|
516
|
+
* @param amountETHWei Amount of ETH (Wei) needed
|
|
517
|
+
*/
|
|
518
|
+
quoteUSDCForETH(amountETHWei: bigint): Promise<bigint>;
|
|
519
|
+
/**
|
|
520
|
+
* Build tx data for swapping USDC -> ETH
|
|
521
|
+
* Uses SwapRouter02.exactOutputSingle + unwrapWETH9
|
|
522
|
+
*/
|
|
523
|
+
buildSwapData(recipient: Address, amountOutETH: bigint, maxAmountInUSDC: bigint): Hex;
|
|
524
|
+
getRouterAddress(): Address;
|
|
525
|
+
getUSDCAddress(): Address;
|
|
526
|
+
}
|
|
527
|
+
declare const uniswapService: UniswapService;
|
|
528
|
+
|
|
529
|
+
export { AccountAbstraction, type ApprovalSupportResult, BASE_MAINNET, BASE_SEPOLIA, BundlerClient, CCTPStrategy, CHAIN_CONFIGS, CHAIN_ID_TO_KEY, type ChainConfig$1 as ChainConfig, GNOSIS_MAINNET, type GasEstimate, NearStrategy, OPTIMISM_MAINNET, STELLAR, STELLAR_MAINNET, StargateStrategy, StellarService, type Token, TransferManager, UniswapService, type UserOpReceipt, type UserOperation, entryPointAbi, erc20Abi, getNearSimulation, getStargateSimulation, smartAccountAbi, uniswapService };
|
package/dist/index.d.ts
CHANGED
|
@@ -508,4 +508,22 @@ declare function getStargateSimulation(sourceChain: string, destChain: string, a
|
|
|
508
508
|
minAmount?: undefined;
|
|
509
509
|
}>;
|
|
510
510
|
|
|
511
|
-
|
|
511
|
+
declare class UniswapService {
|
|
512
|
+
private publicClient;
|
|
513
|
+
constructor();
|
|
514
|
+
/**
|
|
515
|
+
* Get amount of USDC needed to buy exact amount of ETH
|
|
516
|
+
* @param amountETHWei Amount of ETH (Wei) needed
|
|
517
|
+
*/
|
|
518
|
+
quoteUSDCForETH(amountETHWei: bigint): Promise<bigint>;
|
|
519
|
+
/**
|
|
520
|
+
* Build tx data for swapping USDC -> ETH
|
|
521
|
+
* Uses SwapRouter02.exactOutputSingle + unwrapWETH9
|
|
522
|
+
*/
|
|
523
|
+
buildSwapData(recipient: Address, amountOutETH: bigint, maxAmountInUSDC: bigint): Hex;
|
|
524
|
+
getRouterAddress(): Address;
|
|
525
|
+
getUSDCAddress(): Address;
|
|
526
|
+
}
|
|
527
|
+
declare const uniswapService: UniswapService;
|
|
528
|
+
|
|
529
|
+
export { AccountAbstraction, type ApprovalSupportResult, BASE_MAINNET, BASE_SEPOLIA, BundlerClient, CCTPStrategy, CHAIN_CONFIGS, CHAIN_ID_TO_KEY, type ChainConfig$1 as ChainConfig, GNOSIS_MAINNET, type GasEstimate, NearStrategy, OPTIMISM_MAINNET, STELLAR, STELLAR_MAINNET, StargateStrategy, StellarService, type Token, TransferManager, UniswapService, type UserOpReceipt, type UserOperation, entryPointAbi, erc20Abi, getNearSimulation, getStargateSimulation, smartAccountAbi, uniswapService };
|
package/dist/index.js
CHANGED
|
@@ -1674,15 +1674,15 @@ var init_near = __esm({
|
|
|
1674
1674
|
return { success: false, errorReason: `Stellar Verification Failed: ${e.message}` };
|
|
1675
1675
|
}
|
|
1676
1676
|
}
|
|
1677
|
-
const { createPublicClient:
|
|
1677
|
+
const { createPublicClient: createPublicClient4, http: http4 } = await import('viem');
|
|
1678
1678
|
const { FACILITATOR_NETWORKS: FACILITATOR_NETWORKS2 } = await Promise.resolve().then(() => (init_facilitator(), facilitator_exports));
|
|
1679
1679
|
const networkConfig = FACILITATOR_NETWORKS2[sourceChain];
|
|
1680
1680
|
if (!networkConfig) {
|
|
1681
1681
|
return { success: false, errorReason: `Unsupported source chain for verification: ${sourceChain}` };
|
|
1682
1682
|
}
|
|
1683
|
-
const publicClient =
|
|
1683
|
+
const publicClient = createPublicClient4({
|
|
1684
1684
|
chain: networkConfig.chain,
|
|
1685
|
-
transport:
|
|
1685
|
+
transport: http4(networkConfig.rpcUrl)
|
|
1686
1686
|
});
|
|
1687
1687
|
try {
|
|
1688
1688
|
console.log(`[NearStrategy] Waiting for receipt...`);
|
|
@@ -2851,6 +2851,90 @@ init_TransferManager();
|
|
|
2851
2851
|
init_near();
|
|
2852
2852
|
init_cctp2();
|
|
2853
2853
|
init_stargate();
|
|
2854
|
+
var UNISWAP_V3_ROUTER = "0x2626664c2603336E57B271c5C0b26F421741e481";
|
|
2855
|
+
var UNISWAP_V3_QUOTER = "0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a";
|
|
2856
|
+
var USDC_ADDRESS = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
2857
|
+
var WETH_ADDRESS = "0x4200000000000000000000000000000000000006";
|
|
2858
|
+
var QUOTER_ABI = viem.parseAbi([
|
|
2859
|
+
"function quoteExactOutputSingle(tuple(address tokenIn, address tokenOut, uint256 amount, uint24 fee, uint160 sqrtPriceLimitX96) params) external returns (uint256 amountIn, uint160 sqrtPriceX96After, uint32 initializedTicksCrossed, uint256 gasEstimate)"
|
|
2860
|
+
]);
|
|
2861
|
+
var ROUTER_ABI = viem.parseAbi([
|
|
2862
|
+
"function exactOutputSingle(tuple(address tokenIn, address tokenOut, uint24 fee, address recipient, uint256 amountOut, uint256 amountInMaximum, uint160 sqrtPriceLimitX96) params) external payable returns (uint256 amountIn)"
|
|
2863
|
+
]);
|
|
2864
|
+
var UniswapService = class {
|
|
2865
|
+
constructor() {
|
|
2866
|
+
this.publicClient = viem.createPublicClient({
|
|
2867
|
+
chain: chains.base,
|
|
2868
|
+
transport: viem.http("https://mainnet.base.org")
|
|
2869
|
+
// Default public RPC
|
|
2870
|
+
});
|
|
2871
|
+
}
|
|
2872
|
+
/**
|
|
2873
|
+
* Get amount of USDC needed to buy exact amount of ETH
|
|
2874
|
+
* @param amountETHWei Amount of ETH (Wei) needed
|
|
2875
|
+
*/
|
|
2876
|
+
async quoteUSDCForETH(amountETHWei) {
|
|
2877
|
+
try {
|
|
2878
|
+
const params = {
|
|
2879
|
+
tokenIn: USDC_ADDRESS,
|
|
2880
|
+
tokenOut: WETH_ADDRESS,
|
|
2881
|
+
amount: amountETHWei,
|
|
2882
|
+
fee: 500,
|
|
2883
|
+
sqrtPriceLimitX96: 0n
|
|
2884
|
+
};
|
|
2885
|
+
const result = await this.publicClient.readContract({
|
|
2886
|
+
address: UNISWAP_V3_QUOTER,
|
|
2887
|
+
abi: QUOTER_ABI,
|
|
2888
|
+
functionName: "quoteExactOutputSingle",
|
|
2889
|
+
args: [params]
|
|
2890
|
+
});
|
|
2891
|
+
const amountIn = result[0];
|
|
2892
|
+
return amountIn * 101n / 100n;
|
|
2893
|
+
} catch (e) {
|
|
2894
|
+
console.error("Quote failed", e);
|
|
2895
|
+
throw new Error("Failed to quote USDC for ETH swap");
|
|
2896
|
+
}
|
|
2897
|
+
}
|
|
2898
|
+
/**
|
|
2899
|
+
* Build tx data for swapping USDC -> ETH
|
|
2900
|
+
* Uses SwapRouter02.exactOutputSingle + unwrapWETH9
|
|
2901
|
+
*/
|
|
2902
|
+
buildSwapData(recipient, amountOutETH, maxAmountInUSDC) {
|
|
2903
|
+
const swapParams = {
|
|
2904
|
+
tokenIn: USDC_ADDRESS,
|
|
2905
|
+
tokenOut: WETH_ADDRESS,
|
|
2906
|
+
fee: 500,
|
|
2907
|
+
recipient: "0x0000000000000000000000000000000000000000",
|
|
2908
|
+
// Router address constant for internal unwrap? usually encoded as address(0) or router itself
|
|
2909
|
+
amountOut: amountOutETH,
|
|
2910
|
+
amountInMaximum: maxAmountInUSDC,
|
|
2911
|
+
sqrtPriceLimitX96: 0n
|
|
2912
|
+
};
|
|
2913
|
+
const swapCalldata = viem.encodeFunctionData({
|
|
2914
|
+
abi: ROUTER_ABI,
|
|
2915
|
+
functionName: "exactOutputSingle",
|
|
2916
|
+
args: [swapParams]
|
|
2917
|
+
});
|
|
2918
|
+
const unwrapCalldata = viem.encodeFunctionData({
|
|
2919
|
+
abi: viem.parseAbi(["function unwrapWETH9(uint256 amountMinimum, address recipient) payable"]),
|
|
2920
|
+
functionName: "unwrapWETH9",
|
|
2921
|
+
args: [amountOutETH, recipient]
|
|
2922
|
+
});
|
|
2923
|
+
const multicallCalldata = viem.encodeFunctionData({
|
|
2924
|
+
abi: viem.parseAbi(["function multicall(bytes[] data) payable returns (bytes[])"]),
|
|
2925
|
+
functionName: "multicall",
|
|
2926
|
+
args: [[swapCalldata, unwrapCalldata]]
|
|
2927
|
+
});
|
|
2928
|
+
return multicallCalldata;
|
|
2929
|
+
}
|
|
2930
|
+
getRouterAddress() {
|
|
2931
|
+
return UNISWAP_V3_ROUTER;
|
|
2932
|
+
}
|
|
2933
|
+
getUSDCAddress() {
|
|
2934
|
+
return USDC_ADDRESS;
|
|
2935
|
+
}
|
|
2936
|
+
};
|
|
2937
|
+
var uniswapService = new UniswapService();
|
|
2854
2938
|
|
|
2855
2939
|
exports.AccountAbstraction = AccountAbstraction;
|
|
2856
2940
|
exports.BASE_MAINNET = BASE_MAINNET;
|
|
@@ -2861,10 +2945,12 @@ exports.CHAIN_ID_TO_KEY = CHAIN_ID_TO_KEY;
|
|
|
2861
2945
|
exports.GNOSIS_MAINNET = GNOSIS_MAINNET;
|
|
2862
2946
|
exports.OPTIMISM_MAINNET = OPTIMISM_MAINNET;
|
|
2863
2947
|
exports.STELLAR_MAINNET = STELLAR_MAINNET;
|
|
2948
|
+
exports.UniswapService = UniswapService;
|
|
2864
2949
|
exports.entryPointAbi = entryPointAbi;
|
|
2865
2950
|
exports.erc20Abi = erc20Abi;
|
|
2866
2951
|
exports.getNearSimulation = getNearSimulation;
|
|
2867
2952
|
exports.getStargateSimulation = getStargateSimulation;
|
|
2868
2953
|
exports.smartAccountAbi = smartAccountAbi;
|
|
2954
|
+
exports.uniswapService = uniswapService;
|
|
2869
2955
|
//# sourceMappingURL=index.js.map
|
|
2870
2956
|
//# sourceMappingURL=index.js.map
|