From d6cdba76cebacaa190dc8d509d99c8ba23a5b033 Mon Sep 17 00:00:00 2001 From: Emily Williams Date: Tue, 8 Oct 2024 16:59:50 -0400 Subject: [PATCH 01/23] universal-router-sdk handles ETH output fee --- .../src/entities/actions/uniswap.ts | 10 +++- .../test/forge/SwapERC20CallParameters.t.sol | 57 ++++++++----------- .../test/forge/interop.json | 6 +- .../test/uniswapTrades.test.ts | 4 +- 4 files changed, 36 insertions(+), 41 deletions(-) diff --git a/sdks/universal-router-sdk/src/entities/actions/uniswap.ts b/sdks/universal-router-sdk/src/entities/actions/uniswap.ts index 62e60a427..bc4c2e3e0 100644 --- a/sdks/universal-router-sdk/src/entities/actions/uniswap.ts +++ b/sdks/universal-router-sdk/src/entities/actions/uniswap.ts @@ -142,12 +142,16 @@ export class UniswapTrade implements Command { // The router custodies for 3 reasons: to unwrap, to take a fee, and/or to do a slippage check if (routerMustCustody) { + const pools = this.trade.swaps[0].route.pools + const outputCurrency = getPathCurrency(this.trade.outputAmount.currency, pools[pools.length - 1]) + const outputCurrencyAddress = outputCurrency.isNative ? ETH_ADDRESS : outputCurrency.address + // If there is a fee, that percentage is sent to the fee recipient // In the case where ETH is the output currency, the fee is taken in WETH (for gas reasons) if (!!this.options.fee) { const feeBips = encodeFeeBips(this.options.fee.fee) planner.addCommand(CommandType.PAY_PORTION, [ - this.trade.outputAmount.currency.wrapped.address, + outputCurrencyAddress, this.options.fee.recipient, feeBips, ]) @@ -166,7 +170,7 @@ export class UniswapTrade implements Command { if (minimumAmountOut.lt(feeAmount)) throw new Error('Flat fee amount greater than minimumAmountOut') planner.addCommand(CommandType.TRANSFER, [ - this.trade.outputAmount.currency.wrapped.address, + outputCurrencyAddress, this.options.flatFee.recipient, feeAmount, ]) @@ -184,7 +188,7 @@ export class UniswapTrade implements Command { planner.addCommand(CommandType.UNWRAP_WETH, [this.options.recipient, minimumAmountOut]) } else { planner.addCommand(CommandType.SWEEP, [ - this.trade.outputAmount.currency.wrapped.address, + outputCurrencyAddress, this.options.recipient, minimumAmountOut, ]) diff --git a/sdks/universal-router-sdk/test/forge/SwapERC20CallParameters.t.sol b/sdks/universal-router-sdk/test/forge/SwapERC20CallParameters.t.sol index 33f85bcfe..1277d6c34 100644 --- a/sdks/universal-router-sdk/test/forge/SwapERC20CallParameters.t.sol +++ b/sdks/universal-router-sdk/test/forge/SwapERC20CallParameters.t.sol @@ -559,39 +559,30 @@ contract SwapERC20CallParametersTest is Test, Interop, DeployRouter { assertGt(USDC.balanceOf(RECIPIENT), 2000 * ONE_USDC); } - // TODO: Logic for giving WETH fee with an ETH output - // function testV4ExactInputDAIForETHwithWEthFee() public { - // MethodParameters memory params = readFixture(json, "._UNISWAP_V4_USDC_FOR_1_ETH_2_HOP_WITH_WETH_FEE"); - // deal(address(USDC), from, BALANCE); - // USDC.approve(address(permit2), BALANCE); - // permit2.approve(address(USDC), address(router), uint160(BALANCE), uint48(block.timestamp + 1000)); - // - // assertEq(USDC.balanceOf(from), BALANCE); - // uint256 startingRecipientBalance = RECIPIENT.balance; - // uint256 startingFeeRecipientBalance = FEE_RECIPIENT.balance; - // assertEq(WETH.balanceOf(FEE_RECIPIENT), 0); - // - // (bool success,) = address(router).call{value: params.value}(params.data); - // require(success, "call failed"); - // assertLe(USDC.balanceOf(from), BALANCE - 1000 ether); - // - // uint256 recipientOutETH = RECIPIENT.balance - startingRecipientBalance; - // uint256 feeRecipientOutETH = FEE_RECIPIENT.balance - startingFeeRecipientBalance; - // uint256 feeRecipientOutWETH = WETH.balanceOf(FEE_RECIPIENT); - // - // uint256 totalOut = recipientOutETH + feeRecipientOutWETH; - // uint256 expectedFee = totalOut * 500 / 10000; - // - // // Recipient should get ETH, and fee recipient should get WETH (and no ETH) - // assertEq(feeRecipientOutWETH, expectedFee); - // assertEq(feeRecipientOutETH, 0); - // assertEq(recipientOutETH, totalOut - expectedFee); - // assertGt(totalOut, 0.1 ether); - // - // // Nothing left in the router! - // assertEq(WETH.balanceOf(address(router)), 0); - // assertEq(address(router).balance, 0); - // } + function testV4ExactInputDAIForETHwithETHFee() public { + MethodParameters memory params = readFixture(json, "._UNISWAP_V4_USDC_FOR_1_ETH_2_HOP_WITH_ETH_FEE"); + deal(address(USDC), from, BALANCE); + USDC.approve(address(permit2), BALANCE); + permit2.approve(address(USDC), address(router), uint160(BALANCE), uint48(block.timestamp + 1000)); + + assertEq(USDC.balanceOf(from), BALANCE); + uint256 startingRecipientBalance = RECIPIENT.balance; + uint256 startingFeeRecipientBalance = FEE_RECIPIENT.balance; + assertEq(WETH.balanceOf(FEE_RECIPIENT), 0); + + (bool success,) = address(router).call{value: params.value}(params.data); + require(success, "call failed"); + + uint256 recipientOutETH = RECIPIENT.balance - startingRecipientBalance; + uint256 feeRecipientOutETH = FEE_RECIPIENT.balance - startingFeeRecipientBalance; + uint256 totalOut = recipientOutETH + feeRecipientOutETH; + uint256 expectedFee = totalOut * 500 / 10000; + + assertLe(USDC.balanceOf(from), BALANCE); + assertEq(feeRecipientOutETH, expectedFee); + assertEq(recipientOutETH, totalOut - expectedFee); + assertEq(address(router).balance, 0); + } function testV4ExactInWithFee() public { MethodParameters memory params = readFixture(json, "._UNISWAP_V4_1_ETH_FOR_USDC_WITH_FEE"); diff --git a/sdks/universal-router-sdk/test/forge/interop.json b/sdks/universal-router-sdk/test/forge/interop.json index 6ea484d31..aec38c94a 100644 --- a/sdks/universal-router-sdk/test/forge/interop.json +++ b/sdks/universal-router-sdk/test/forge/interop.json @@ -191,8 +191,8 @@ "calldata": "0x24856bc300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000003c0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000003050912000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000d2d62035241defd00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000000000000000000", "value": "1000000000000000000" }, - "_UNISWAP_V4_USDC_FOR_1_ETH_2_HOP_WITH_WETH_FEE": { - "calldata": "0x24856bc3000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000003100604000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000052000000000000000000000000000000000000000000000000000000000000005a000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000030709120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000e9bb2d80e8435e5000000000000000000000000000000000000000000000000102a78813767ff57000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000100000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb00000000000000000000000000000000000000000000000000000000000001f40000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000de0b6b3a7640000", + "_UNISWAP_V4_USDC_FOR_1_ETH_2_HOP_WITH_ETH_FEE": { + "calldata": "0x24856bc3000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000003100604000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000052000000000000000000000000000000000000000000000000000000000000005a000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000030709120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000e9bb2d80e8435e5000000000000000000000000000000000000000000000000102a78813767ff57000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000100000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb00000000000000000000000000000000000000000000000000000000000001f400000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000de0b6b3a7640000", "value": "0" } -} +} \ No newline at end of file diff --git a/sdks/universal-router-sdk/test/uniswapTrades.test.ts b/sdks/universal-router-sdk/test/uniswapTrades.test.ts index 5a928d257..e8778068e 100644 --- a/sdks/universal-router-sdk/test/uniswapTrades.test.ts +++ b/sdks/universal-router-sdk/test/uniswapTrades.test.ts @@ -647,7 +647,7 @@ describe('Uniswap', () => { expect(hexToDecimalString(methodParameters.value)).to.equal('0') }) - it('encodes an exactOutput DAI->USDC->ETH swap, with WETH fee', async () => { + it('encodes an exactOutput DAI->USDC->ETH swap, with ETH fee', async () => { const outputEther = utils.parseEther('1') const adjustedOutputEther = outputEther .mul(10000) @@ -662,7 +662,7 @@ describe('Uniswap', () => { const opts = swapOptions({ fee: feeOptions }) buildTrade([trade]) const methodParameters = SwapRouter.swapCallParameters(buildTrade([trade]), opts) - registerFixture('_UNISWAP_V4_USDC_FOR_1_ETH_2_HOP_WITH_WETH_FEE', methodParameters) + registerFixture('_UNISWAP_V4_USDC_FOR_1_ETH_2_HOP_WITH_ETH_FEE', methodParameters) expect(hexToDecimalString(methodParameters.value)).to.equal('0') }) }) From f2b0019f9d623aaecba9b9484a344ed3717096f9 Mon Sep 17 00:00:00 2001 From: Emily Williams Date: Thu, 10 Oct 2024 10:55:20 -0400 Subject: [PATCH 02/23] tests to wrap ETH output to WETH for recipient, fails need v4-sdk bug fix --- .../src/entities/actions/uniswap.ts | 41 +++++++++++-------- .../test/forge/SwapERC20CallParameters.t.sol | 17 ++++++-- .../test/forge/interop.json | 6 ++- .../test/uniswapTrades.test.ts | 15 +++++++ 4 files changed, 58 insertions(+), 21 deletions(-) diff --git a/sdks/universal-router-sdk/src/entities/actions/uniswap.ts b/sdks/universal-router-sdk/src/entities/actions/uniswap.ts index bc4c2e3e0..c81f7f3fe 100644 --- a/sdks/universal-router-sdk/src/entities/actions/uniswap.ts +++ b/sdks/universal-router-sdk/src/entities/actions/uniswap.ts @@ -97,6 +97,17 @@ export class UniswapTrade implements Command { } } + get outputRequiresWrap(): boolean { + if (this.isAllV4) { + return !this.trade.outputAmount.currency.isNative && this.trade.swaps[0].route.output.isNative + } + return false + } + + get outputRequiresTransition(): boolean { + this.outputRequiresWrap || this.outputRequiresUnwrap + } + encode(planner: RoutePlanner, _config: TradeConfig): void { // If the input currency is the native currency, we need to wrap it with the router as the recipient if (this.inputRequiresWrap) { @@ -115,7 +126,8 @@ export class UniswapTrade implements Command { // in that the reversion probability is lower const performAggregatedSlippageCheck = this.trade.tradeType === TradeType.EXACT_INPUT && this.trade.routes.length > 2 - const routerMustCustody = performAggregatedSlippageCheck || this.outputRequiresUnwrap || hasFeeOption(this.options) + const routerMustCustody = + performAggregatedSlippageCheck || this.outputRequiresTransition || hasFeeOption(this.options) for (const swap of this.trade.swaps) { switch (swap.route.protocol) { @@ -150,11 +162,7 @@ export class UniswapTrade implements Command { // In the case where ETH is the output currency, the fee is taken in WETH (for gas reasons) if (!!this.options.fee) { const feeBips = encodeFeeBips(this.options.fee.fee) - planner.addCommand(CommandType.PAY_PORTION, [ - outputCurrencyAddress, - this.options.fee.recipient, - feeBips, - ]) + planner.addCommand(CommandType.PAY_PORTION, [outputCurrencyAddress, this.options.fee.recipient, feeBips]) // If the trade is exact output, and a fee was taken, we must adjust the amount out to be the amount after the fee // Otherwise we continue as expected with the trade's normal expected output @@ -169,11 +177,7 @@ export class UniswapTrade implements Command { const feeAmount = this.options.flatFee.amount if (minimumAmountOut.lt(feeAmount)) throw new Error('Flat fee amount greater than minimumAmountOut') - planner.addCommand(CommandType.TRANSFER, [ - outputCurrencyAddress, - this.options.flatFee.recipient, - feeAmount, - ]) + planner.addCommand(CommandType.TRANSFER, [outputCurrencyAddress, this.options.flatFee.recipient, feeAmount]) // If the trade is exact output, and a fee was taken, we must adjust the amount out to be the amount after the fee // Otherwise we continue as expected with the trade's normal expected output @@ -187,14 +191,14 @@ export class UniswapTrade implements Command { if (this.outputRequiresUnwrap) { planner.addCommand(CommandType.UNWRAP_WETH, [this.options.recipient, minimumAmountOut]) } else { - planner.addCommand(CommandType.SWEEP, [ - outputCurrencyAddress, - this.options.recipient, - minimumAmountOut, - ]) + planner.addCommand(CommandType.SWEEP, [outputCurrencyAddress, this.options.recipient, minimumAmountOut]) } } + if (this.outputRequiresWrap) { + planner.addCommand(CommandType.WRAP_ETH, [this.options.recipient, 0]) + } + if (this.inputRequiresWrap && (this.trade.tradeType === TradeType.EXACT_OUTPUT || riskOfPartialFill(this.trade))) { // for exactOutput swaps that take native currency as input // we need to send back the change to the user @@ -291,6 +295,10 @@ function addV4Swap( outputAmount, tradeType, }) + + console.log(trade.route.pools) + console.log(inputAmount) + console.log(outputAmount) const slippageToleranceOnSwap = routerMustCustody && tradeType == TradeType.EXACT_INPUT ? undefined : options.slippageTolerance @@ -299,6 +307,7 @@ function addV4Swap( const v4Planner = new V4Planner() v4Planner.addTrade(trade, slippageToleranceOnSwap) + console.log(v4Planner) v4Planner.addSettle(inputWethFromRouter ? inputAmount.currency.wrapped : inputAmount.currency, payerIsUser) options.recipient = options.recipient ?? SENDER_AS_RECIPIENT diff --git a/sdks/universal-router-sdk/test/forge/SwapERC20CallParameters.t.sol b/sdks/universal-router-sdk/test/forge/SwapERC20CallParameters.t.sol index 1277d6c34..4200560ae 100644 --- a/sdks/universal-router-sdk/test/forge/SwapERC20CallParameters.t.sol +++ b/sdks/universal-router-sdk/test/forge/SwapERC20CallParameters.t.sol @@ -639,10 +639,19 @@ contract SwapERC20CallParametersTest is Test, Interop, DeployRouter { assertGe(from.balance, startingRecipientBalance); } - // v4-sdk 1.6.3 allows this - // function testV4ExactInNativeOutputWithUnwrap() public { - // MethodParameters memory params = readFixture(json, "._UNISWAP_V4_1000_USDC_FOR_ETH_WITH_UNWRAP"); - // } + function testV4ExactInNativeOutputWithUnwrap() public { + MethodParameters memory params = readFixture(json, "._UNISWAP_V4_1000_USDC_FOR_ETH_WITH_UNWRAP"); + + deal(address(USDC), from, BALANCE); + USDC.approve(address(permit2), BALANCE); + assertEq(USDC.balanceOf(from), BALANCE); + uint256 startingRecipientBalance = RECIPIENT.balance; + + (bool success,) = address(router).call{value: params.value}(params.data); + require(success, "call failed"); + + assertEq(WETH.balanceOf(RECIPIENT), 1 ether); + } function testV4ExactInMultiHop() public { MethodParameters memory params = readFixture(json, "._UNISWAP_V4_ETH_FOR_DAI"); diff --git a/sdks/universal-router-sdk/test/forge/interop.json b/sdks/universal-router-sdk/test/forge/interop.json index aec38c94a..961d298bb 100644 --- a/sdks/universal-router-sdk/test/forge/interop.json +++ b/sdks/universal-router-sdk/test/forge/interop.json @@ -194,5 +194,9 @@ "_UNISWAP_V4_USDC_FOR_1_ETH_2_HOP_WITH_ETH_FEE": { "calldata": "0x24856bc3000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000003100604000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000052000000000000000000000000000000000000000000000000000000000000005a000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000030709120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000e9bb2d80e8435e5000000000000000000000000000000000000000000000000102a78813767ff57000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000100000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb00000000000000000000000000000000000000000000000000000000000001f400000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000de0b6b3a7640000", "value": "0" + }, + "_UNISWAP_V4_1000_USDC_FOR_ETH_WITH_UNWRAP": { + "calldata": "0x24856bc300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000030709120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000020000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000ea8d710c6670fe50000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001000000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000000000000000000", + "value": "0" } -} \ No newline at end of file +} diff --git a/sdks/universal-router-sdk/test/uniswapTrades.test.ts b/sdks/universal-router-sdk/test/uniswapTrades.test.ts index e8778068e..86e3f4e74 100644 --- a/sdks/universal-router-sdk/test/uniswapTrades.test.ts +++ b/sdks/universal-router-sdk/test/uniswapTrades.test.ts @@ -665,6 +665,21 @@ describe('Uniswap', () => { registerFixture('_UNISWAP_V4_USDC_FOR_1_ETH_2_HOP_WITH_ETH_FEE', methodParameters) expect(hexToDecimalString(methodParameters.value)).to.equal('0') }) + + it('encodes a DAI->USDC->ETH swap with a wrap to recieve WETH', async () => { + const outputEther = utils.parseEther('1') + const trade = await V4Trade.fromRoute( + new V4Route([USDC_DAI_V4, ETH_DAI_V4], USDC, WETH), + CurrencyAmount.fromRawAmount(WETH, outputEther), + TradeType.EXACT_OUTPUT + ) + + const opts = swapOptions({}) + buildTrade([trade]) + const methodParameters = SwapRouter.swapCallParameters(buildTrade([trade]), opts) + registerFixture('_UNISWAP_V4_1000_USDC_FOR_ETH_WITH_UNWRAP', methodParameters) + expect(hexToDecimalString(methodParameters.value)).to.equal('0') + }) }) describe('mixed (interleaved)', async () => { From 1de63654e8607064cd7c9a2d2bfc06edcfeae19e Mon Sep 17 00:00:00 2001 From: Emily Williams Date: Thu, 10 Oct 2024 10:59:53 -0400 Subject: [PATCH 03/23] fix encodeToPath --- .../src/utils/encodeRouteToPath.test.ts | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/sdks/v4-sdk/src/utils/encodeRouteToPath.test.ts b/sdks/v4-sdk/src/utils/encodeRouteToPath.test.ts index 7dc086010..5f0298679 100644 --- a/sdks/v4-sdk/src/utils/encodeRouteToPath.test.ts +++ b/sdks/v4-sdk/src/utils/encodeRouteToPath.test.ts @@ -1,4 +1,4 @@ -import { Ether, Token } from '@uniswap/sdk-core' +import { Ether, Token, WETH9 } from '@uniswap/sdk-core' import { encodeSqrtRatioX96 } from '@uniswap/v3-sdk' import { Route } from '../entities/route' import { Pool } from '../entities/pool' @@ -6,6 +6,7 @@ import { encodeRouteToPath } from './encodeRouteToPath' import { ADDRESS_ZERO, FEE_AMOUNT_MEDIUM, TICK_SPACING_TEN } from '../internalConstants' const eth = Ether.onChain(1) +const weth = WETH9[1] const currency1 = new Token(1, '0x0000000000000000000000000000000000000001', 18, 't1') const currency2 = new Token(1, '0x0000000000000000000000000000000000000002', 18, 't2') const currency3 = new Token(1, '0x0000000000000000000000000000000000000003', 18, 't3') @@ -22,6 +23,18 @@ const pool_eth_1 = new Pool( [] ) +const pool_weth_1 = new Pool( + weth, + currency1, + FEE_AMOUNT_MEDIUM, + TICK_SPACING_TEN, + ADDRESS_ZERO, + encodeSqrtRatioX96(1, 1), + 0, + 0, + [] +) + const pool_1_2 = new Pool( currency1, currency2, @@ -105,4 +118,27 @@ describe('RouterPlanner', () => { expect(encodeRouteToPath(route, exactOutput)).toEqual(expected) }) + + it.only('encodes the correct route with native pool token but wrapped output', async () => { + const newRoute = new Route([pool_1_2, pool_eth_1], currency2, weth) + const exactOutput = false + const expected = [ + { + intermediateCurrency: '0x0000000000000000000000000000000000000001', + fee: 3000, + tickSpacing: 10, + hooks: '0x0000000000000000000000000000000000000000', + hookData: '0x', + }, + { + intermediateCurrency: '0x0000000000000000000000000000000000000000', + fee: 3000, + tickSpacing: 10, + hooks: '0x0000000000000000000000000000000000000000', + hookData: '0x', + } + ] + + expect(encodeRouteToPath(newRoute, exactOutput)).toEqual(expected) + }) }) From ae9d28d86a26a45cefaba061a11792bfe8e9a1b3 Mon Sep 17 00:00:00 2001 From: Emily Williams Date: Thu, 10 Oct 2024 16:18:29 -0400 Subject: [PATCH 04/23] add test cases (so I can see clean diff) and small var rename --- .../src/entities/actions/uniswap.ts | 10 ++-- .../test/forge/interop.json | 24 ++++----- .../test/uniswapTrades.test.ts | 51 ++++++++++++++++++- 3 files changed, 66 insertions(+), 19 deletions(-) diff --git a/sdks/universal-router-sdk/src/entities/actions/uniswap.ts b/sdks/universal-router-sdk/src/entities/actions/uniswap.ts index c81f7f3fe..1b10c9e35 100644 --- a/sdks/universal-router-sdk/src/entities/actions/uniswap.ts +++ b/sdks/universal-router-sdk/src/entities/actions/uniswap.ts @@ -155,14 +155,14 @@ export class UniswapTrade implements Command { // The router custodies for 3 reasons: to unwrap, to take a fee, and/or to do a slippage check if (routerMustCustody) { const pools = this.trade.swaps[0].route.pools - const outputCurrency = getPathCurrency(this.trade.outputAmount.currency, pools[pools.length - 1]) - const outputCurrencyAddress = outputCurrency.isNative ? ETH_ADDRESS : outputCurrency.address + const pathOutputCurrency = getPathCurrency(this.trade.outputAmount.currency, pools[pools.length - 1]) + const pathOutputCurrencyAddress = pathOutputCurrency.isNative ? ETH_ADDRESS : pathOutputCurrency.address // If there is a fee, that percentage is sent to the fee recipient // In the case where ETH is the output currency, the fee is taken in WETH (for gas reasons) if (!!this.options.fee) { const feeBips = encodeFeeBips(this.options.fee.fee) - planner.addCommand(CommandType.PAY_PORTION, [outputCurrencyAddress, this.options.fee.recipient, feeBips]) + planner.addCommand(CommandType.PAY_PORTION, [pathOutputCurrencyAddress, this.options.fee.recipient, feeBips]) // If the trade is exact output, and a fee was taken, we must adjust the amount out to be the amount after the fee // Otherwise we continue as expected with the trade's normal expected output @@ -177,7 +177,7 @@ export class UniswapTrade implements Command { const feeAmount = this.options.flatFee.amount if (minimumAmountOut.lt(feeAmount)) throw new Error('Flat fee amount greater than minimumAmountOut') - planner.addCommand(CommandType.TRANSFER, [outputCurrencyAddress, this.options.flatFee.recipient, feeAmount]) + planner.addCommand(CommandType.TRANSFER, [pathOutputCurrencyAddress, this.options.flatFee.recipient, feeAmount]) // If the trade is exact output, and a fee was taken, we must adjust the amount out to be the amount after the fee // Otherwise we continue as expected with the trade's normal expected output @@ -191,7 +191,7 @@ export class UniswapTrade implements Command { if (this.outputRequiresUnwrap) { planner.addCommand(CommandType.UNWRAP_WETH, [this.options.recipient, minimumAmountOut]) } else { - planner.addCommand(CommandType.SWEEP, [outputCurrencyAddress, this.options.recipient, minimumAmountOut]) + planner.addCommand(CommandType.SWEEP, [pathOutputCurrencyAddress, this.options.recipient, minimumAmountOut]) } } diff --git a/sdks/universal-router-sdk/test/forge/interop.json b/sdks/universal-router-sdk/test/forge/interop.json index 961d298bb..b131d95c0 100644 --- a/sdks/universal-router-sdk/test/forge/interop.json +++ b/sdks/universal-router-sdk/test/forge/interop.json @@ -16,7 +16,7 @@ "value": "1000000000000000000" }, "_UNISWAP_V2_1000_USDC_FOR_ETH": { - "calldata": "0x24856bc3000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000002080c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000003b9aca00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000040000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000ad3290bba9e3f61", + "calldata": "0x24856bc30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000100000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa000000000000000000000000000000000000000000000000000000003b9aca000000000000000000000000000000000000000000000000000ad3290bba9e3f6100000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "value": "0" }, "_UNISWAP_V2_1000_USDC_FOR_ETH_WITH_WETH_FEE": { @@ -24,19 +24,19 @@ "value": "0" }, "_UNISWAP_V2_1000_USDC_FOR_ETH_PERMIT": { - "calldata": "0x24856bc30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000030a080c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000160000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000003b9aca00000000000000000000000000000000000000000000000000000002ba7def30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e808c1cfeebb6cb36b537b82fa7c9eef31415a05000000000000000000000000000000000000000000000000000002ba7def300000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000004164e5751a7231f6f26fb08faf68a060e16db971c6425fb7a3b6bb7d88cec73f1b31c8522be432d1eac3d755bf7aa83de5147578f6e7f22c06fd038130d680d5061c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000003b9aca00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000040000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000ad3290bba9e3f61", + "calldata": "0x24856bc30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000020a080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001c00000000000000000000000000000000000000000000000000000000000000160000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000003b9aca00000000000000000000000000000000000000000000000000000002ba7def30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e808c1cfeebb6cb36b537b82fa7c9eef31415a05000000000000000000000000000000000000000000000000000002ba7def300000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000004164e5751a7231f6f26fb08faf68a060e16db971c6425fb7a3b6bb7d88cec73f1b31c8522be432d1eac3d755bf7aa83de5147578f6e7f22c06fd038130d680d5061c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa000000000000000000000000000000000000000000000000000000003b9aca000000000000000000000000000000000000000000000000000ad3290bba9e3f6100000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "value": "0" }, "_UNISWAP_V2_1000_USDC_FOR_ETH_2098_PERMIT": { - "calldata": "0x24856bc30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000030a080c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000160000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000003b9aca00000000000000000000000000000000000000000000000000000002ba7def30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e808c1cfeebb6cb36b537b82fa7c9eef31415a05000000000000000000000000000000000000000000000000000002ba7def300000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000004164e5751a7231f6f26fb08faf68a060e16db971c6425fb7a3b6bb7d88cec73f1b31c8522be432d1eac3d755bf7aa83de5147578f6e7f22c06fd038130d680d5061c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000003b9aca00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000040000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000ad3290bba9e3f61", + "calldata": "0x24856bc30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000020a080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001c00000000000000000000000000000000000000000000000000000000000000160000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000003b9aca00000000000000000000000000000000000000000000000000000002ba7def30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e808c1cfeebb6cb36b537b82fa7c9eef31415a05000000000000000000000000000000000000000000000000000002ba7def300000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000004164e5751a7231f6f26fb08faf68a060e16db971c6425fb7a3b6bb7d88cec73f1b31c8522be432d1eac3d755bf7aa83de5147578f6e7f22c06fd038130d680d5061c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa000000000000000000000000000000000000000000000000000000003b9aca000000000000000000000000000000000000000000000000000ad3290bba9e3f6100000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "value": "0" }, "_UNISWAP_V2_1000_USDC_FOR_ETH_PERMIT_V_RECOVERY_PARAM": { - "calldata": "0x24856bc30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000030a080c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000160000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000003b9aca00000000000000000000000000000000000000000000000000000002ba7def30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e808c1cfeebb6cb36b537b82fa7c9eef31415a05000000000000000000000000000000000000000000000000000002ba7def300000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000004164e5751a7231f6f26fb08faf68a060e16db971c6425fb7a3b6bb7d88cec73f1b31c8522be432d1eac3d755bf7aa83de5147578f6e7f22c06fd038130d680d5061c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000003b9aca00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000040000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000ad3290bba9e3f61", + "calldata": "0x24856bc30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000020a080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001c00000000000000000000000000000000000000000000000000000000000000160000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000003b9aca00000000000000000000000000000000000000000000000000000002ba7def30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e808c1cfeebb6cb36b537b82fa7c9eef31415a05000000000000000000000000000000000000000000000000000002ba7def300000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000004164e5751a7231f6f26fb08faf68a060e16db971c6425fb7a3b6bb7d88cec73f1b31c8522be432d1eac3d755bf7aa83de5147578f6e7f22c06fd038130d680d5061c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa000000000000000000000000000000000000000000000000000000003b9aca000000000000000000000000000000000000000000000000000ad3290bba9e3f6100000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "value": "0" }, "_UNISWAP_V2_10_DAI_FOR_ETH_2_HOP": { - "calldata": "0x24856bc3000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000002080c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000180000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000008ac7230489e80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000030000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000040000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa000000000000000000000000000000000000000000000000001bac9d330942bf", + "calldata": "0x24856bc30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000120000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000008ac7230489e80000000000000000000000000000000000000000000000000000001bac9d330942bf00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000030000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "value": "0" }, "_UNISWAP_V2_ETH_FOR_1000_USDC": { @@ -56,7 +56,7 @@ "value": "0" }, "_UNISWAP_V2_USDC_FOR_1_ETH": { - "calldata": "0x24856bc3000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000002090c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000004c6a57e800000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000040000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000de0b6b3a7640000", + "calldata": "0x24856bc30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000100000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000004c6a57e800000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "value": "0" }, "_UNISWAP_V3_1_ETH_FOR_USDC": { @@ -72,7 +72,7 @@ "value": "1000000000000000000" }, "_UNISWAP_V3_1000_USDC_FOR_ETH": { - "calldata": "0x24856bc3000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000002000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000003b9aca00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002ba0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000bb8c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000ad03bb7d9487c3b", + "calldata": "0x24856bc30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000100000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa000000000000000000000000000000000000000000000000000000003b9aca000000000000000000000000000000000000000000000000000ad03bb7d9487c3b00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002ba0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000bb8c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000", "value": "0" }, "_UNISWAP_V3_1000_USDC_FOR_ETH_WITH_WETH_FEE": { @@ -80,7 +80,7 @@ "value": "0" }, "_UNISWAP_V3_1000_USDC_FOR_ETH_PERMIT": { - "calldata": "0x24856bc30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000030a000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000160000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000003b9aca00000000000000000000000000000000000000000000000000000002ba7def30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e808c1cfeebb6cb36b537b82fa7c9eef31415a05000000000000000000000000000000000000000000000000000002ba7def300000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000004164e5751a7231f6f26fb08faf68a060e16db971c6425fb7a3b6bb7d88cec73f1b31c8522be432d1eac3d755bf7aa83de5147578f6e7f22c06fd038130d680d5061c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000003b9aca00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002ba0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000bb8c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000ad03bb7d9487c3b", + "calldata": "0x24856bc30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000020a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001c00000000000000000000000000000000000000000000000000000000000000160000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000003b9aca00000000000000000000000000000000000000000000000000000002ba7def30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e808c1cfeebb6cb36b537b82fa7c9eef31415a05000000000000000000000000000000000000000000000000000002ba7def300000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000004164e5751a7231f6f26fb08faf68a060e16db971c6425fb7a3b6bb7d88cec73f1b31c8522be432d1eac3d755bf7aa83de5147578f6e7f22c06fd038130d680d5061c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa000000000000000000000000000000000000000000000000000000003b9aca000000000000000000000000000000000000000000000000000ad03bb7d9487c3b00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002ba0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000bb8c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000", "value": "0" }, "_UNISWAP_V3_1_ETH_FOR_DAI_2_HOP": { @@ -96,7 +96,7 @@ "value": "864236051489390501" }, "_UNISWAP_V3_USDC_FOR_1_ETH": { - "calldata": "0x24856bc3000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000002010c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000004c7eef4100000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002bc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000bb8a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000de0b6b3a7640000", + "calldata": "0x24856bc30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000100000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000004c7eef4100000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002bc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000bb8a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000", "value": "0" }, "_UNISWAP_V3_ETH_FOR_1000_DAI_2_HOP": { @@ -104,7 +104,7 @@ "value": "864590811545248284" }, "_UNISWAP_V3_DAI_FOR_1_ETH_2_HOP": { - "calldata": "0x24856bc3000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000002010c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000180000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000459d1582c218ed0d0700000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000042c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000bb8a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480001f46b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000de0b6b3a7640000", + "calldata": "0x24856bc30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000120000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000459d1582c218ed0d0700000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000042c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000bb8a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480001f46b175474e89094c44da98b954eedeac495271d0f000000000000000000000000000000000000000000000000000000000000", "value": "0" }, "_UNISWAP_V3_DAI_FOR_1_ETH_2_HOP_WITH_WETH_FEE": { @@ -168,7 +168,7 @@ "value": "1000000000000000000" }, "_UNISWAP_MIXED_DAI_FOR_ETH": { - "calldata": "0x24856bc300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000308000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000002a00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000003635c9adc5dea00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000028000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002ba0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000bb8c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000acc47d3615931ec", + "calldata": "0x24856bc300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000208000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001600000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000003635c9adc5dea00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000100000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000acc47d3615931ec00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002ba0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000bb8c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000", "value": "0" }, "_UNISWAP_MIXED_USDC_DAI_UNWRAP_WETH_V3_TO_V4": { @@ -199,4 +199,4 @@ "calldata": "0x24856bc300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000030709120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000020000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000ea8d710c6670fe50000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001000000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000000000000000000", "value": "0" } -} +} \ No newline at end of file diff --git a/sdks/universal-router-sdk/test/uniswapTrades.test.ts b/sdks/universal-router-sdk/test/uniswapTrades.test.ts index 86e3f4e74..41a2731d4 100644 --- a/sdks/universal-router-sdk/test/uniswapTrades.test.ts +++ b/sdks/universal-router-sdk/test/uniswapTrades.test.ts @@ -660,13 +660,12 @@ describe('Uniswap', () => { ) const feeOptions: FeeOptions = { fee: new Percent(5, 100), recipient: TEST_FEE_RECIPIENT_ADDRESS } const opts = swapOptions({ fee: feeOptions }) - buildTrade([trade]) const methodParameters = SwapRouter.swapCallParameters(buildTrade([trade]), opts) registerFixture('_UNISWAP_V4_USDC_FOR_1_ETH_2_HOP_WITH_ETH_FEE', methodParameters) expect(hexToDecimalString(methodParameters.value)).to.equal('0') }) - it('encodes a DAI->USDC->ETH swap with a wrap to recieve WETH', async () => { + it('encodes a USDC->DAI->ETH swap with a wrap to recieve WETH', async () => { const outputEther = utils.parseEther('1') const trade = await V4Trade.fromRoute( new V4Route([USDC_DAI_V4, ETH_DAI_V4], USDC, WETH), @@ -674,6 +673,54 @@ describe('Uniswap', () => { TradeType.EXACT_OUTPUT ) + const opts = swapOptions({}) + const methodParameters = SwapRouter.swapCallParameters(buildTrade([trade]), opts) + registerFixture('_UNISWAP_V4_1000_USDC_FOR_ETH_WITH_UNWRAP', methodParameters) + expect(hexToDecimalString(methodParameters.value)).to.equal('0') + }) + + it('encodes a USDC->DAI->ETH swap with a fee that must then wrap to recieve WETH', async () => { + const outputEther = utils.parseEther('1') + const adjustedOutputEther = outputEther + .mul(10000) + .div(10000 - 500) + .toString() + const trade = await V4Trade.fromRoute( + new V4Route([USDC_DAI_V4, ETH_DAI_V4], USDC, WETH), + CurrencyAmount.fromRawAmount(WETH, adjustedOutputEther), + TradeType.EXACT_OUTPUT + ) + + const feeOptions: FeeOptions = { fee: new Percent(5, 100), recipient: TEST_FEE_RECIPIENT_ADDRESS } + const opts = swapOptions({ fee: feeOptions }) + const methodParameters = SwapRouter.swapCallParameters(buildTrade([trade]), opts) + registerFixture('_UNISWAP_V4_1000_USDC_FOR_ETH_WITH_FEE_AND_UNWRAP', methodParameters) + expect(hexToDecimalString(methodParameters.value)).to.equal('0') + }) + + it('encodes an exactOutput ETH->DAI->USDC swap that must first wrap WETH', async () => { + const outputUSDC = utils.parseUnits('1000', 6).toString() + const trade = await V4Trade.fromRoute( + new V4Route([ETH_DAI_V4, USDC_DAI_V4], WETH, USDC), + CurrencyAmount.fromRawAmount(WETH, outputEther), + TradeType.EXACT_OUTPUT + ) + + const opts = swapOptions({}) + buildTrade([trade]) + const methodParameters = SwapRouter.swapCallParameters(buildTrade([trade]), opts) + registerFixture('_UNISWAP_V4_WRAP_WETH_TO_ETHFOR_1000_USDC', methodParameters) + expect(hexToDecimalString(methodParameters.value)).to.equal('0') + }) + + it('encodes an exactOutput WETH->DAI->USDC swap that must first wrap ETH', async () => { + const outputUSDC = utils.parseUnits('1000', 6).toString() + const trade = await V4Trade.fromRoute( + new V4Route([WETH_DAI_V4, USDC_DAI_V4], ETH, USDC), + CurrencyAmount.fromRawAmount(USDC, outputUSDC), + TradeType.EXACT_OUTPUT + ) + const opts = swapOptions({}) buildTrade([trade]) const methodParameters = SwapRouter.swapCallParameters(buildTrade([trade]), opts) From f042591fe5f551bde9856fe5fab6d67b01ee8b10 Mon Sep 17 00:00:00 2001 From: Emily Williams Date: Thu, 10 Oct 2024 16:20:02 -0400 Subject: [PATCH 05/23] Revert "fix encodeToPath" This reverts commit 1de63654e8607064cd7c9a2d2bfc06edcfeae19e. --- .../src/utils/encodeRouteToPath.test.ts | 38 +------------------ 1 file changed, 1 insertion(+), 37 deletions(-) diff --git a/sdks/v4-sdk/src/utils/encodeRouteToPath.test.ts b/sdks/v4-sdk/src/utils/encodeRouteToPath.test.ts index 5f0298679..7dc086010 100644 --- a/sdks/v4-sdk/src/utils/encodeRouteToPath.test.ts +++ b/sdks/v4-sdk/src/utils/encodeRouteToPath.test.ts @@ -1,4 +1,4 @@ -import { Ether, Token, WETH9 } from '@uniswap/sdk-core' +import { Ether, Token } from '@uniswap/sdk-core' import { encodeSqrtRatioX96 } from '@uniswap/v3-sdk' import { Route } from '../entities/route' import { Pool } from '../entities/pool' @@ -6,7 +6,6 @@ import { encodeRouteToPath } from './encodeRouteToPath' import { ADDRESS_ZERO, FEE_AMOUNT_MEDIUM, TICK_SPACING_TEN } from '../internalConstants' const eth = Ether.onChain(1) -const weth = WETH9[1] const currency1 = new Token(1, '0x0000000000000000000000000000000000000001', 18, 't1') const currency2 = new Token(1, '0x0000000000000000000000000000000000000002', 18, 't2') const currency3 = new Token(1, '0x0000000000000000000000000000000000000003', 18, 't3') @@ -23,18 +22,6 @@ const pool_eth_1 = new Pool( [] ) -const pool_weth_1 = new Pool( - weth, - currency1, - FEE_AMOUNT_MEDIUM, - TICK_SPACING_TEN, - ADDRESS_ZERO, - encodeSqrtRatioX96(1, 1), - 0, - 0, - [] -) - const pool_1_2 = new Pool( currency1, currency2, @@ -118,27 +105,4 @@ describe('RouterPlanner', () => { expect(encodeRouteToPath(route, exactOutput)).toEqual(expected) }) - - it.only('encodes the correct route with native pool token but wrapped output', async () => { - const newRoute = new Route([pool_1_2, pool_eth_1], currency2, weth) - const exactOutput = false - const expected = [ - { - intermediateCurrency: '0x0000000000000000000000000000000000000001', - fee: 3000, - tickSpacing: 10, - hooks: '0x0000000000000000000000000000000000000000', - hookData: '0x', - }, - { - intermediateCurrency: '0x0000000000000000000000000000000000000000', - fee: 3000, - tickSpacing: 10, - hooks: '0x0000000000000000000000000000000000000000', - hookData: '0x', - } - ] - - expect(encodeRouteToPath(newRoute, exactOutput)).toEqual(expected) - }) }) From 043c608e288b21020eddf0f935ebddce6c288952 Mon Sep 17 00:00:00 2001 From: Emily Williams Date: Thu, 10 Oct 2024 16:44:00 -0400 Subject: [PATCH 06/23] tons of tests failing, have to find what changed --- .../src/entities/actions/uniswap.ts | 13 ++++++++----- .../src/utils/getCurrencyAddress.ts | 6 ++++++ .../universal-router-sdk/test/forge/interop.json | 12 ++++++++++++ .../test/uniswapTrades.test.ts | 16 ++++++++-------- 4 files changed, 34 insertions(+), 13 deletions(-) create mode 100644 sdks/universal-router-sdk/src/utils/getCurrencyAddress.ts diff --git a/sdks/universal-router-sdk/src/entities/actions/uniswap.ts b/sdks/universal-router-sdk/src/entities/actions/uniswap.ts index 1b10c9e35..f4f261b82 100644 --- a/sdks/universal-router-sdk/src/entities/actions/uniswap.ts +++ b/sdks/universal-router-sdk/src/entities/actions/uniswap.ts @@ -29,6 +29,7 @@ import { getPathCurrency } from '../../utils/pathCurrency' import { Currency, TradeType, CurrencyAmount, Percent } from '@uniswap/sdk-core' import { Command, RouterActionType, TradeConfig } from '../Command' import { SENDER_AS_RECIPIENT, ROUTER_AS_RECIPIENT, CONTRACT_BALANCE, ETH_ADDRESS } from '../../utils/constants' +import { getCurrencyAddress } from '../../utils/getCurrencyAddress' import { encodeFeeBips } from '../../utils/numbers' import { BigNumber, BigNumberish } from 'ethers' import { TPool } from '@uniswap/router-sdk/dist/utils/TPool' @@ -190,15 +191,17 @@ export class UniswapTrade implements Command { // by this if-else clause. if (this.outputRequiresUnwrap) { planner.addCommand(CommandType.UNWRAP_WETH, [this.options.recipient, minimumAmountOut]) + } else if (this.outputRequiresWrap) { + planner.addCommand(CommandType.WRAP_ETH, [this.options.recipient, 0]) } else { - planner.addCommand(CommandType.SWEEP, [pathOutputCurrencyAddress, this.options.recipient, minimumAmountOut]) + planner.addCommand(CommandType.SWEEP, [ + getCurrencyAddress(this.trade.outputAmount.currency), + this.options.recipient, + minimumAmountOut, + ]) } } - if (this.outputRequiresWrap) { - planner.addCommand(CommandType.WRAP_ETH, [this.options.recipient, 0]) - } - if (this.inputRequiresWrap && (this.trade.tradeType === TradeType.EXACT_OUTPUT || riskOfPartialFill(this.trade))) { // for exactOutput swaps that take native currency as input // we need to send back the change to the user diff --git a/sdks/universal-router-sdk/src/utils/getCurrencyAddress.ts b/sdks/universal-router-sdk/src/utils/getCurrencyAddress.ts new file mode 100644 index 000000000..1f545fd6a --- /dev/null +++ b/sdks/universal-router-sdk/src/utils/getCurrencyAddress.ts @@ -0,0 +1,6 @@ +import { Currency } from '@uniswap/sdk-core' +import { ETH_ADDRESS } from './constants' + +export function getCurrencyAddress(currency: Currency): Currency { + return currency.isNative ? ETH_ADDRESS : currency.wrapped.address +} diff --git a/sdks/universal-router-sdk/test/forge/interop.json b/sdks/universal-router-sdk/test/forge/interop.json index b131d95c0..261f0c6af 100644 --- a/sdks/universal-router-sdk/test/forge/interop.json +++ b/sdks/universal-router-sdk/test/forge/interop.json @@ -198,5 +198,17 @@ "_UNISWAP_V4_1000_USDC_FOR_ETH_WITH_UNWRAP": { "calldata": "0x24856bc300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000030709120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000020000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000ea8d710c6670fe50000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001000000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000000000000000000", "value": "0" + }, + "_UNISWAP_V4_1000_USDC_FOR_ETH_WITH_FEE_AND_UNWRAP": { + "calldata": "0x24856bc3000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000003100604000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000052000000000000000000000000000000000000000000000000000000000000005a000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000030709120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000020000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000e9bb2d80e8435e5000000000000000000000000000000000000000000000000102a78813767ff570000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001000000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb00000000000000000000000000000000000000000000000000000000000001f40000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000de0b6b3a7640000", + "value": "0" + }, + "_UNISWAP_V4_UNWRAP_WETH_TO_ETH_FOR_1000_USDC": { + "calldata": "0x24856bc300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000030709120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000020000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000003b9aca00000000000000000000000000000000000000000000000000000000003ef64b1300000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000000000000000000", + "value": "0" + }, + "_UNISWAP_V4_WRAP_ETH_FOR_1000_USDC": { + "calldata": "0x24856bc300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004a000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000307091200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000380000000000000000000000000000000000000000000000000000000000000028000000000000000000000000000000000000000000000000000000000000000200000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000ea8d710c6670fe5000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000100000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000600000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000000000000000000", + "value": "1056330579666472933" } } \ No newline at end of file diff --git a/sdks/universal-router-sdk/test/uniswapTrades.test.ts b/sdks/universal-router-sdk/test/uniswapTrades.test.ts index 41a2731d4..5d90a7f79 100644 --- a/sdks/universal-router-sdk/test/uniswapTrades.test.ts +++ b/sdks/universal-router-sdk/test/uniswapTrades.test.ts @@ -699,33 +699,33 @@ describe('Uniswap', () => { }) it('encodes an exactOutput ETH->DAI->USDC swap that must first wrap WETH', async () => { - const outputUSDC = utils.parseUnits('1000', 6).toString() + const outputUSDC = utils.parseUnits('1000', 6).toString() const trade = await V4Trade.fromRoute( new V4Route([ETH_DAI_V4, USDC_DAI_V4], WETH, USDC), - CurrencyAmount.fromRawAmount(WETH, outputEther), + CurrencyAmount.fromRawAmount(USDC, outputUSDC), TradeType.EXACT_OUTPUT ) const opts = swapOptions({}) buildTrade([trade]) const methodParameters = SwapRouter.swapCallParameters(buildTrade([trade]), opts) - registerFixture('_UNISWAP_V4_WRAP_WETH_TO_ETHFOR_1000_USDC', methodParameters) + registerFixture('_UNISWAP_V4_UNWRAP_WETH_TO_ETH_FOR_1000_USDC', methodParameters) expect(hexToDecimalString(methodParameters.value)).to.equal('0') }) it('encodes an exactOutput WETH->DAI->USDC swap that must first wrap ETH', async () => { - const outputUSDC = utils.parseUnits('1000', 6).toString() + const outputDAI = BigNumber.from(utils.parseEther('1')) const trade = await V4Trade.fromRoute( - new V4Route([WETH_DAI_V4, USDC_DAI_V4], ETH, USDC), - CurrencyAmount.fromRawAmount(USDC, outputUSDC), + new V4Route([WETH_USDC_V4, USDC_DAI_V4], ETHER, DAI), + CurrencyAmount.fromRawAmount(DAI, outputDAI), TradeType.EXACT_OUTPUT ) const opts = swapOptions({}) buildTrade([trade]) const methodParameters = SwapRouter.swapCallParameters(buildTrade([trade]), opts) - registerFixture('_UNISWAP_V4_1000_USDC_FOR_ETH_WITH_UNWRAP', methodParameters) - expect(hexToDecimalString(methodParameters.value)).to.equal('0') + registerFixture('_UNISWAP_V4_WRAP_ETH_FOR_1000_USDC', methodParameters) + expect(hexToDecimalString(methodParameters.value)).to.not.equal('0') }) }) From eb8c6953c8a6d5d0e8fb2f0124e29625bb566c9f Mon Sep 17 00:00:00 2001 From: Emily Williams Date: Thu, 10 Oct 2024 16:51:58 -0400 Subject: [PATCH 07/23] found bug all previous tests now back to passing, moving onto my new test cases --- .../src/entities/actions/uniswap.ts | 2 +- .../test/forge/interop.json | 22 +++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/sdks/universal-router-sdk/src/entities/actions/uniswap.ts b/sdks/universal-router-sdk/src/entities/actions/uniswap.ts index f4f261b82..17385b458 100644 --- a/sdks/universal-router-sdk/src/entities/actions/uniswap.ts +++ b/sdks/universal-router-sdk/src/entities/actions/uniswap.ts @@ -106,7 +106,7 @@ export class UniswapTrade implements Command { } get outputRequiresTransition(): boolean { - this.outputRequiresWrap || this.outputRequiresUnwrap + return this.outputRequiresWrap || this.outputRequiresUnwrap } encode(planner: RoutePlanner, _config: TradeConfig): void { diff --git a/sdks/universal-router-sdk/test/forge/interop.json b/sdks/universal-router-sdk/test/forge/interop.json index 261f0c6af..3761b32c3 100644 --- a/sdks/universal-router-sdk/test/forge/interop.json +++ b/sdks/universal-router-sdk/test/forge/interop.json @@ -16,7 +16,7 @@ "value": "1000000000000000000" }, "_UNISWAP_V2_1000_USDC_FOR_ETH": { - "calldata": "0x24856bc30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000100000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa000000000000000000000000000000000000000000000000000000003b9aca000000000000000000000000000000000000000000000000000ad3290bba9e3f6100000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", + "calldata": "0x24856bc3000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000002080c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000003b9aca00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000040000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000ad3290bba9e3f61", "value": "0" }, "_UNISWAP_V2_1000_USDC_FOR_ETH_WITH_WETH_FEE": { @@ -24,19 +24,19 @@ "value": "0" }, "_UNISWAP_V2_1000_USDC_FOR_ETH_PERMIT": { - "calldata": "0x24856bc30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000020a080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001c00000000000000000000000000000000000000000000000000000000000000160000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000003b9aca00000000000000000000000000000000000000000000000000000002ba7def30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e808c1cfeebb6cb36b537b82fa7c9eef31415a05000000000000000000000000000000000000000000000000000002ba7def300000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000004164e5751a7231f6f26fb08faf68a060e16db971c6425fb7a3b6bb7d88cec73f1b31c8522be432d1eac3d755bf7aa83de5147578f6e7f22c06fd038130d680d5061c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa000000000000000000000000000000000000000000000000000000003b9aca000000000000000000000000000000000000000000000000000ad3290bba9e3f6100000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", + "calldata": "0x24856bc30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000030a080c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000160000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000003b9aca00000000000000000000000000000000000000000000000000000002ba7def30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e808c1cfeebb6cb36b537b82fa7c9eef31415a05000000000000000000000000000000000000000000000000000002ba7def300000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000004164e5751a7231f6f26fb08faf68a060e16db971c6425fb7a3b6bb7d88cec73f1b31c8522be432d1eac3d755bf7aa83de5147578f6e7f22c06fd038130d680d5061c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000003b9aca00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000040000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000ad3290bba9e3f61", "value": "0" }, "_UNISWAP_V2_1000_USDC_FOR_ETH_2098_PERMIT": { - "calldata": "0x24856bc30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000020a080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001c00000000000000000000000000000000000000000000000000000000000000160000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000003b9aca00000000000000000000000000000000000000000000000000000002ba7def30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e808c1cfeebb6cb36b537b82fa7c9eef31415a05000000000000000000000000000000000000000000000000000002ba7def300000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000004164e5751a7231f6f26fb08faf68a060e16db971c6425fb7a3b6bb7d88cec73f1b31c8522be432d1eac3d755bf7aa83de5147578f6e7f22c06fd038130d680d5061c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa000000000000000000000000000000000000000000000000000000003b9aca000000000000000000000000000000000000000000000000000ad3290bba9e3f6100000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", + "calldata": "0x24856bc30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000030a080c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000160000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000003b9aca00000000000000000000000000000000000000000000000000000002ba7def30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e808c1cfeebb6cb36b537b82fa7c9eef31415a05000000000000000000000000000000000000000000000000000002ba7def300000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000004164e5751a7231f6f26fb08faf68a060e16db971c6425fb7a3b6bb7d88cec73f1b31c8522be432d1eac3d755bf7aa83de5147578f6e7f22c06fd038130d680d5061c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000003b9aca00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000040000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000ad3290bba9e3f61", "value": "0" }, "_UNISWAP_V2_1000_USDC_FOR_ETH_PERMIT_V_RECOVERY_PARAM": { - "calldata": "0x24856bc30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000020a080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001c00000000000000000000000000000000000000000000000000000000000000160000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000003b9aca00000000000000000000000000000000000000000000000000000002ba7def30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e808c1cfeebb6cb36b537b82fa7c9eef31415a05000000000000000000000000000000000000000000000000000002ba7def300000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000004164e5751a7231f6f26fb08faf68a060e16db971c6425fb7a3b6bb7d88cec73f1b31c8522be432d1eac3d755bf7aa83de5147578f6e7f22c06fd038130d680d5061c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa000000000000000000000000000000000000000000000000000000003b9aca000000000000000000000000000000000000000000000000000ad3290bba9e3f6100000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", + "calldata": "0x24856bc30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000030a080c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000160000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000003b9aca00000000000000000000000000000000000000000000000000000002ba7def30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e808c1cfeebb6cb36b537b82fa7c9eef31415a05000000000000000000000000000000000000000000000000000002ba7def300000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000004164e5751a7231f6f26fb08faf68a060e16db971c6425fb7a3b6bb7d88cec73f1b31c8522be432d1eac3d755bf7aa83de5147578f6e7f22c06fd038130d680d5061c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000003b9aca00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000040000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000ad3290bba9e3f61", "value": "0" }, "_UNISWAP_V2_10_DAI_FOR_ETH_2_HOP": { - "calldata": "0x24856bc30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000120000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000008ac7230489e80000000000000000000000000000000000000000000000000000001bac9d330942bf00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000030000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", + "calldata": "0x24856bc3000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000002080c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000180000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000008ac7230489e80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000030000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000040000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa000000000000000000000000000000000000000000000000001bac9d330942bf", "value": "0" }, "_UNISWAP_V2_ETH_FOR_1000_USDC": { @@ -56,7 +56,7 @@ "value": "0" }, "_UNISWAP_V2_USDC_FOR_1_ETH": { - "calldata": "0x24856bc30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000100000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000004c6a57e800000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", + "calldata": "0x24856bc3000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000002090c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000004c6a57e800000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000040000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000de0b6b3a7640000", "value": "0" }, "_UNISWAP_V3_1_ETH_FOR_USDC": { @@ -72,7 +72,7 @@ "value": "1000000000000000000" }, "_UNISWAP_V3_1000_USDC_FOR_ETH": { - "calldata": "0x24856bc30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000100000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa000000000000000000000000000000000000000000000000000000003b9aca000000000000000000000000000000000000000000000000000ad03bb7d9487c3b00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002ba0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000bb8c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000", + "calldata": "0x24856bc3000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000002000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000003b9aca00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002ba0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000bb8c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000ad03bb7d9487c3b", "value": "0" }, "_UNISWAP_V3_1000_USDC_FOR_ETH_WITH_WETH_FEE": { @@ -80,7 +80,7 @@ "value": "0" }, "_UNISWAP_V3_1000_USDC_FOR_ETH_PERMIT": { - "calldata": "0x24856bc30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000020a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001c00000000000000000000000000000000000000000000000000000000000000160000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000003b9aca00000000000000000000000000000000000000000000000000000002ba7def30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e808c1cfeebb6cb36b537b82fa7c9eef31415a05000000000000000000000000000000000000000000000000000002ba7def300000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000004164e5751a7231f6f26fb08faf68a060e16db971c6425fb7a3b6bb7d88cec73f1b31c8522be432d1eac3d755bf7aa83de5147578f6e7f22c06fd038130d680d5061c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa000000000000000000000000000000000000000000000000000000003b9aca000000000000000000000000000000000000000000000000000ad03bb7d9487c3b00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002ba0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000bb8c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000", + "calldata": "0x24856bc30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000030a000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000160000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000003b9aca00000000000000000000000000000000000000000000000000000002ba7def30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e808c1cfeebb6cb36b537b82fa7c9eef31415a05000000000000000000000000000000000000000000000000000002ba7def300000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000004164e5751a7231f6f26fb08faf68a060e16db971c6425fb7a3b6bb7d88cec73f1b31c8522be432d1eac3d755bf7aa83de5147578f6e7f22c06fd038130d680d5061c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000003b9aca00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002ba0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000bb8c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000ad03bb7d9487c3b", "value": "0" }, "_UNISWAP_V3_1_ETH_FOR_DAI_2_HOP": { @@ -96,7 +96,7 @@ "value": "864236051489390501" }, "_UNISWAP_V3_USDC_FOR_1_ETH": { - "calldata": "0x24856bc30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000100000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000004c7eef4100000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002bc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000bb8a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000", + "calldata": "0x24856bc3000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000002010c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000004c7eef4100000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002bc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000bb8a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000de0b6b3a7640000", "value": "0" }, "_UNISWAP_V3_ETH_FOR_1000_DAI_2_HOP": { @@ -104,7 +104,7 @@ "value": "864590811545248284" }, "_UNISWAP_V3_DAI_FOR_1_ETH_2_HOP": { - "calldata": "0x24856bc30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000120000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000459d1582c218ed0d0700000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000042c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000bb8a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480001f46b175474e89094c44da98b954eedeac495271d0f000000000000000000000000000000000000000000000000000000000000", + "calldata": "0x24856bc3000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000002010c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000180000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000459d1582c218ed0d0700000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000042c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000bb8a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480001f46b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000de0b6b3a7640000", "value": "0" }, "_UNISWAP_V3_DAI_FOR_1_ETH_2_HOP_WITH_WETH_FEE": { @@ -168,7 +168,7 @@ "value": "1000000000000000000" }, "_UNISWAP_MIXED_DAI_FOR_ETH": { - "calldata": "0x24856bc300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000208000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001600000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000003635c9adc5dea00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000100000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000acc47d3615931ec00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002ba0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000bb8c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000", + "calldata": "0x24856bc300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000308000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000002a00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000003635c9adc5dea00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000028000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002ba0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000bb8c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000acc47d3615931ec", "value": "0" }, "_UNISWAP_MIXED_USDC_DAI_UNWRAP_WETH_V3_TO_V4": { From 3ab390379904930e1a07144b53182ee727326a25 Mon Sep 17 00:00:00 2001 From: Emily Williams Date: Thu, 10 Oct 2024 16:57:12 -0400 Subject: [PATCH 08/23] install new v4-sdk --- sdks/universal-router-sdk/package.json | 2 +- yarn.lock | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/sdks/universal-router-sdk/package.json b/sdks/universal-router-sdk/package.json index 272769b39..b56a5ac1b 100644 --- a/sdks/universal-router-sdk/package.json +++ b/sdks/universal-router-sdk/package.json @@ -38,7 +38,7 @@ "@uniswap/v2-sdk": "^4.6.0", "@uniswap/v3-core": "1.0.0", "@uniswap/v3-sdk": "^3.17.0", - "@uniswap/v4-sdk": "^1.10.0", + "@uniswap/v4-sdk": "^1.10.3", "bignumber.js": "^9.0.2", "ethers": "^5.7.0" }, diff --git a/yarn.lock b/yarn.lock index 9b1d61507..04f011c98 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4737,7 +4737,7 @@ __metadata: "@uniswap/v2-sdk": ^4.6.0 "@uniswap/v3-core": 1.0.0 "@uniswap/v3-sdk": ^3.17.0 - "@uniswap/v4-sdk": ^1.10.0 + "@uniswap/v4-sdk": ^1.10.3 bignumber.js: ^9.0.2 chai: ^4.3.6 dotenv: ^16.0.3 @@ -4890,7 +4890,20 @@ __metadata: languageName: node linkType: hard -"@uniswap/v4-sdk@npm:^1.10.0, @uniswap/v4-sdk@npm:^1.9.0": +"@uniswap/v4-sdk@npm:^1.10.3": + version: 1.10.3 + resolution: "@uniswap/v4-sdk@npm:1.10.3" + dependencies: + "@ethersproject/solidity": ^5.0.9 + "@uniswap/sdk-core": ^5.3.1 + "@uniswap/v3-sdk": 3.12.0 + tiny-invariant: ^1.1.0 + tiny-warning: ^1.0.3 + checksum: ca0565f4e87c2b306dc642ca13b7e2605a994cf5e9cb661503a60a3cc8dd86727f73328ebd529f9a42cedf6751dde91735b4ff7e3468deef37fa254d47e3ee9b + languageName: node + linkType: hard + +"@uniswap/v4-sdk@npm:^1.9.0": version: 1.10.0 resolution: "@uniswap/v4-sdk@npm:1.10.0" dependencies: From dec6963f36c8eafd4c6620a7278132a84296cddd Mon Sep 17 00:00:00 2001 From: Emily Williams Date: Thu, 10 Oct 2024 19:00:23 -0400 Subject: [PATCH 09/23] import new router-sdk --- sdks/universal-router-sdk/package.json | 2 +- sdks/universal-router-sdk/test/forge/interop.json | 6 +++--- yarn.lock | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/sdks/universal-router-sdk/package.json b/sdks/universal-router-sdk/package.json index b56a5ac1b..9a9712401 100644 --- a/sdks/universal-router-sdk/package.json +++ b/sdks/universal-router-sdk/package.json @@ -31,7 +31,7 @@ "dependencies": { "@openzeppelin/contracts": "4.7.0", "@uniswap/permit2-sdk": "^1.3.0", - "@uniswap/router-sdk": "^1.14.2", + "@uniswap/router-sdk": "^1.14.3", "@uniswap/sdk-core": "^5.8.0", "@uniswap/universal-router": "2.0.0-beta.1", "@uniswap/v2-core": "^1.0.1", diff --git a/sdks/universal-router-sdk/test/forge/interop.json b/sdks/universal-router-sdk/test/forge/interop.json index 3761b32c3..65816db69 100644 --- a/sdks/universal-router-sdk/test/forge/interop.json +++ b/sdks/universal-router-sdk/test/forge/interop.json @@ -188,7 +188,7 @@ "value": "0" }, "_UNISWAP_V4_1_ETH_FOR_USDC_WITH_WRAP": { - "calldata": "0x24856bc300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000003c0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000003050912000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000d2d62035241defd00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000000000000000000", + "calldata": "0x24856bc300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000003c0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000003050912000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000d2d62035241defd00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000000000000000000", "value": "1000000000000000000" }, "_UNISWAP_V4_USDC_FOR_1_ETH_2_HOP_WITH_ETH_FEE": { @@ -196,11 +196,11 @@ "value": "0" }, "_UNISWAP_V4_1000_USDC_FOR_ETH_WITH_UNWRAP": { - "calldata": "0x24856bc300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000030709120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000020000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000ea8d710c6670fe50000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001000000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000000000000000000", + "calldata": "0x24856bc300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000030709120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000ea8d710c6670fe5000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000100000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000000000000000000", "value": "0" }, "_UNISWAP_V4_1000_USDC_FOR_ETH_WITH_FEE_AND_UNWRAP": { - "calldata": "0x24856bc3000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000003100604000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000052000000000000000000000000000000000000000000000000000000000000005a000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000030709120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000020000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000e9bb2d80e8435e5000000000000000000000000000000000000000000000000102a78813767ff570000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001000000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb00000000000000000000000000000000000000000000000000000000000001f40000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000de0b6b3a7640000", + "calldata": "0x24856bc3000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000003100604000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000052000000000000000000000000000000000000000000000000000000000000005a000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000030709120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000e9bb2d80e8435e5000000000000000000000000000000000000000000000000102a78813767ff57000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000100000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb00000000000000000000000000000000000000000000000000000000000001f40000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000de0b6b3a7640000", "value": "0" }, "_UNISWAP_V4_UNWRAP_WETH_TO_ETH_FOR_1000_USDC": { diff --git a/yarn.lock b/yarn.lock index 04f011c98..ab4216917 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4609,17 +4609,17 @@ __metadata: languageName: unknown linkType: soft -"@uniswap/router-sdk@npm:^1.14.2": - version: 1.14.2 - resolution: "@uniswap/router-sdk@npm:1.14.2" +"@uniswap/router-sdk@npm:^1.14.3": + version: 1.14.3 + resolution: "@uniswap/router-sdk@npm:1.14.3" dependencies: "@ethersproject/abi": ^5.5.0 "@uniswap/sdk-core": ^5.8.0 "@uniswap/swap-router-contracts": ^1.3.0 "@uniswap/v2-sdk": ^4.6.0 "@uniswap/v3-sdk": ^3.17.0 - "@uniswap/v4-sdk": ^1.9.0 - checksum: 2e4ff16421c02c40462c2082df2eb293724258b31dc9c8b4164880fc80f77de2357c1a38a2241f4c50f8d1fc6de36a244067d444f2507806d266818f82f93215 + "@uniswap/v4-sdk": ^1.10.3 + checksum: ba7e0800d493c0d5f71c050bb21b475f762e56f81de13be96f29bb792351ef9846929271d8befdab93eae0e2800d64516f93d86eecb0ae894da708f806a1010d languageName: node linkType: hard @@ -4730,7 +4730,7 @@ __metadata: "@types/node": ^18.7.16 "@types/node-fetch": ^2.6.2 "@uniswap/permit2-sdk": ^1.3.0 - "@uniswap/router-sdk": ^1.14.2 + "@uniswap/router-sdk": ^1.14.3 "@uniswap/sdk-core": ^5.8.0 "@uniswap/universal-router": 2.0.0-beta.1 "@uniswap/v2-core": ^1.0.1 From 80645799f01d58efba597e8b44d04ad49a56beee Mon Sep 17 00:00:00 2001 From: Emily Williams Date: Mon, 14 Oct 2024 15:57:13 -0400 Subject: [PATCH 10/23] all tests passing, still more tests to put in solidity --- .../src/entities/actions/uniswap.ts | 38 ++++++---- .../test/forge/SwapERC20CallParameters.t.sol | 21 +++++- .../test/forge/interop.json | 72 ++++++++++--------- .../test/uniswapTrades.test.ts | 4 +- 4 files changed, 83 insertions(+), 52 deletions(-) diff --git a/sdks/universal-router-sdk/src/entities/actions/uniswap.ts b/sdks/universal-router-sdk/src/entities/actions/uniswap.ts index 17385b458..99688076c 100644 --- a/sdks/universal-router-sdk/src/entities/actions/uniswap.ts +++ b/sdks/universal-router-sdk/src/entities/actions/uniswap.ts @@ -100,7 +100,7 @@ export class UniswapTrade implements Command { get outputRequiresWrap(): boolean { if (this.isAllV4) { - return !this.trade.outputAmount.currency.isNative && this.trade.swaps[0].route.output.isNative + return !this.trade.outputAmount.currency.isNative && this.trade.swaps[0].route.pathOutput.isNative } return false } @@ -192,7 +192,7 @@ export class UniswapTrade implements Command { if (this.outputRequiresUnwrap) { planner.addCommand(CommandType.UNWRAP_WETH, [this.options.recipient, minimumAmountOut]) } else if (this.outputRequiresWrap) { - planner.addCommand(CommandType.WRAP_ETH, [this.options.recipient, 0]) + planner.addCommand(CommandType.WRAP_ETH, [this.options.recipient, CONTRACT_BALANCE]) } else { planner.addCommand(CommandType.SWEEP, [ getCurrencyAddress(this.trade.outputAmount.currency), @@ -299,23 +299,33 @@ function addV4Swap( tradeType, }) - console.log(trade.route.pools) - console.log(inputAmount) - console.log(outputAmount) + // console.log(route) + // console.log(route.pools[0].currency0) + // console.log(route.pools[0].currency1) + // console.log(route.pools[1].currency0) + // console.log(route.pools[1].currency1) + // console.log(tradeType) + // console.log(trade) + // console.log(trade.swaps[0]) + // console.log(trade.inputAmount) + // console.log(trade.outputAmount) + + // console.log(payerIsUser) + // console.log(trade.tradeType === TradeType.EXACT_OUTPUT) + // + // console.log(encodeV4RouteToPath(trade.route, true)) + // console.log(trade.route.pathInput) + // console.log(trade.route.pathOutput) + + payerIsUser = payerIsUser && route.input == route.pathInput + const slippageToleranceOnSwap = routerMustCustody && tradeType == TradeType.EXACT_INPUT ? undefined : options.slippageTolerance - const inputWethFromRouter = inputAmount.currency.isNative && !route.input.isNative - if (inputWethFromRouter && !payerIsUser) throw new Error('Inconsistent payer') - const v4Planner = new V4Planner() v4Planner.addTrade(trade, slippageToleranceOnSwap) - console.log(v4Planner) - v4Planner.addSettle(inputWethFromRouter ? inputAmount.currency.wrapped : inputAmount.currency, payerIsUser) - - options.recipient = options.recipient ?? SENDER_AS_RECIPIENT - v4Planner.addTake(outputAmount.currency, routerMustCustody ? ROUTER_AS_RECIPIENT : options.recipient) - + v4Planner.addSettle(trade.route.pathInput, payerIsUser) + v4Planner.addTake(trade.route.pathOutput, routerMustCustody ? ROUTER_AS_RECIPIENT : options.recipient ?? SENDER_AS_RECIPIENT) planner.addCommand(CommandType.V4_SWAP, [v4Planner.finalize()]) } diff --git a/sdks/universal-router-sdk/test/forge/SwapERC20CallParameters.t.sol b/sdks/universal-router-sdk/test/forge/SwapERC20CallParameters.t.sol index eacd8bf26..5989a4e11 100644 --- a/sdks/universal-router-sdk/test/forge/SwapERC20CallParameters.t.sol +++ b/sdks/universal-router-sdk/test/forge/SwapERC20CallParameters.t.sol @@ -639,11 +639,28 @@ contract SwapERC20CallParametersTest is Test, Interop, DeployRouter { assertGe(from.balance, startingRecipientBalance); } - function testV4ExactInNativeOutputWithUnwrap() public { - MethodParameters memory params = readFixture(json, "._UNISWAP_V4_1000_USDC_FOR_ETH_WITH_UNWRAP"); + function testV4ExactOutNativeOutput() public { + MethodParameters memory params = readFixture(json, "._UNISWAP_V4_DAI_FOR_1_ETH_2_HOP"); + + deal(address(DAI), from, BALANCE); + DAI.approve(address(permit2), BALANCE); + permit2.approve(address(DAI), address(router), uint160(BALANCE), uint48(block.timestamp + 1000)); + assertEq(DAI.balanceOf(from), BALANCE); + uint256 startingRecipientBalance = from.balance; + + (bool success,) = address(router).call{value: params.value}(params.data); + require(success, "call failed"); + + assertLt(DAI.balanceOf(from), BALANCE - ONE_DAI); + assertGe(from.balance, startingRecipientBalance); + } + + function testV4ExactOutNativeOutputWithUnwrap() public { + MethodParameters memory params = readFixture(json, "._UNISWAP_V4_USDC_FOR_1_ETH_WITH_UNWRAP"); deal(address(USDC), from, BALANCE); USDC.approve(address(permit2), BALANCE); + permit2.approve(address(USDC), address(router), uint160(BALANCE), uint48(block.timestamp + 1000)); assertEq(USDC.balanceOf(from), BALANCE); uint256 startingRecipientBalance = RECIPIENT.balance; diff --git a/sdks/universal-router-sdk/test/forge/interop.json b/sdks/universal-router-sdk/test/forge/interop.json index 51060b660..d855b9262 100644 --- a/sdks/universal-router-sdk/test/forge/interop.json +++ b/sdks/universal-router-sdk/test/forge/interop.json @@ -115,6 +115,10 @@ "calldata": "0x24856bc300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000003c0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000003050912000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000d2d62035241defd00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000000000000000000", "value": "1000000000000000000" }, + "_UNISWAP_V4_1_ETH_FOR_USDC_WITH_WRAP": { + "calldata": "0x24856bc300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000003c0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000003050912000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000d2d62035241defd00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000000000000000000", + "value": "1000000000000000000" + }, "_UNISWAP_V4_1_ETH_FOR_USDC_WITH_FEE": { "calldata": "0x24856bc3000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000003100604000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000044000000000000000000000000000000000000000000000000000000000000004c000000000000000000000000000000000000000000000000000000000000003c0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000003050912000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb00000000000000000000000000000000000000000000000000000000000001f40000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000c940c1a716d6c20", "value": "1000000000000000000" @@ -135,30 +139,26 @@ "calldata": "0x24856bc300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000030709120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000ea8d710c6670fe50000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001000000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000000000000000000", "value": "0" }, - "_UNISWAP_MIXED_1_ETH_FOR_DAI_V2_ONLY": { - "calldata": "0x24856bc30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000020b080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000000000000000120000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000003e5cc69901a0222c0200000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000006b175474e89094c44da98b954eedeac495271d0f", - "value": "1000000000000000000" - }, - "_UNISWAP_MIXED_1_ETH_FOR_DAI_V3_ONLY": { - "calldata": "0x24856bc30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000020b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000000000000000120000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000003eb3459f0ce6ae000b00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000042c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000bb8a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480001f46b175474e89094c44da98b954eedeac495271d0f000000000000000000000000000000000000000000000000000000000000", - "value": "1000000000000000000" - }, - "_UNISWAP_SPLIT_TWO_ROUTES_ETH_TO_USDC": { - "calldata": "0x24856bc30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000050b08000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000220000000000000000000000000000000000000000000000000000000000000034000000000000000000000000000000000000000000000000000000000000004600000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000029a2241af62c0000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002bc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000bb8a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002bc02aaa39b223fe8d0a0e5c4f27ead9083c756cc20001f4a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa00000000000000000000000000000000000000000000000000000000ceebdd6e", - "value": "3000000000000000000" + "_UNISWAP_V4_USDC_FOR_1_ETH_2_HOP_WITH_ETH_FEE": { + "calldata": "0x24856bc3000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000003100604000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000052000000000000000000000000000000000000000000000000000000000000005a000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000030709120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000e9bb2d80e8435e5000000000000000000000000000000000000000000000000102a78813767ff57000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000100000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb00000000000000000000000000000000000000000000000000000000000001f400000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000de0b6b3a7640000", + "value": "0" }, - "_UNISWAP_SPLIT_THREE_ROUTES_ETH_TO_USDC": { - "calldata": "0x24856bc30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000050b08000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000220000000000000000000000000000000000000000000000000000000000000034000000000000000000000000000000000000000000000000000000000000004600000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000029a2241af62c0000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002bc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000bb8a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002bc02aaa39b223fe8d0a0e5c4f27ead9083c756cc20001f4a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa00000000000000000000000000000000000000000000000000000000ceebdd6e", - "value": "3000000000000000000" + "_UNISWAP_V4_1000_USDC_FOR_ETH_WITH_UNWRAP": { + "calldata": "0x24856bc300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000030709120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000ea8d710c6670fe5000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000100000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000000000000000000", + "value": "0" }, - "MIGRATE_WITH_PERMIT": { - "calldata": "0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000031112130000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000056000000000000000000000000000000000000000000000000000000000000000c47ac2ff7b0000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003c4ac9650d800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000001800000000000000000000000000000000000000000000000000000000000000260000000000000000000000000000000000000000000000000000000000000032000000000000000000000000000000000000000000000000000000000000000c47ac2ff7b0000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a40c49ccbe00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000084fc6f786500000000000000000000000000000000000000000000000000000000000000010000000000000000000000000048d1c09771bb87b6a44e1294769e1dfd69858400000000000000000000000000000000ffffffffffffffffffffffffffffffff00000000000000000000000000000000ffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002442966c68000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000524dd46508f0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000004c00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000050209091919000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000026000000000000000000000000000000000000000000000000000000000000002e0000000000000000000000000000000000000000000000000000000000000036000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000001f4000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000002000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa00000000000000000000000000000000000000000000000000000000", + "_UNISWAP_V4_1000_USDC_FOR_ETH_WITH_FEE_AND_UNWRAP": { + "calldata": "0x24856bc300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000310060b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000052000000000000000000000000000000000000000000000000000000000000005a000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000030709120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000e9bb2d80e8435e5000000000000000000000000000000000000000000000000102a78813767ff57000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000100000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb00000000000000000000000000000000000000000000000000000000000001f40000000000000000000000000000000000000000000000000000000000000040000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa8000000000000000000000000000000000000000000000000000000000000000", "value": "0" }, - "MIGRATE_WITHOUT_PERMIT": { - "calldata": "0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002121300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000032000000000000000000000000000000000000000000000000000000000000002a4ac9650d80000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000a40c49ccbe00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000084fc6f786500000000000000000000000000000000000000000000000000000000000000010000000000000000000000000048d1c09771bb87b6a44e1294769e1dfd69858400000000000000000000000000000000ffffffffffffffffffffffffffffffff00000000000000000000000000000000ffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002442966c68000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000524dd46508f0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000004c00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000050209091919000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000026000000000000000000000000000000000000000000000000000000000000002e0000000000000000000000000000000000000000000000000000000000000036000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000001f4000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000002000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa00000000000000000000000000000000000000000000000000000000", + "_UNISWAP_V4_UNWRAP_WETH_TO_ETH_FOR_1000_USDC": { + "calldata": "0x24856bc300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000030709120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000020000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000003b9aca00000000000000000000000000000000000000000000000000000000003ef64b1300000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000000000000000000", "value": "0" }, + "_UNISWAP_V4_WRAP_ETH_FOR_1000_USDC": { + "calldata": "0x24856bc300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004a000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000307091200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000380000000000000000000000000000000000000000000000000000000000000028000000000000000000000000000000000000000000000000000000000000000200000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000ea8d710c6670fe5000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000100000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000000000000000000", + "value": "1056330579666472933" + }, "_UNISWAP_MIXED_1_ETH_FOR_DAI": { "calldata": "0x24856bc30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000030b000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001e0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000ae461ca67b15dc8dc81ce7615e0320da1a9ab8d50000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002bc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000bb8a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003e6e6bec160b0fe3f600000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000006b175474e89094c44da98b954eedeac495271d0f", "value": "1000000000000000000" @@ -167,6 +167,14 @@ "calldata": "0x24856bc30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000030b080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001e0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000100000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003ea18c846eabcb202d00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002ba0b86991c6218b36c1d19d4a2e9eb0ce3606eb480001f46b175474e89094c44da98b954eedeac495271d0f000000000000000000000000000000000000000000", "value": "1000000000000000000" }, + "_UNISWAP_MIXED_1_ETH_FOR_DAI_V2_ONLY": { + "calldata": "0x24856bc30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000020b080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000000000000000120000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000003e5cc69901a0222c0200000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000006b175474e89094c44da98b954eedeac495271d0f", + "value": "1000000000000000000" + }, + "_UNISWAP_MIXED_1_ETH_FOR_DAI_V3_ONLY": { + "calldata": "0x24856bc30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000020b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000000000000000120000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000003eb3459f0ce6ae000b00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000042c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000bb8a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480001f46b175474e89094c44da98b954eedeac495271d0f000000000000000000000000000000000000000000000000000000000000", + "value": "1000000000000000000" + }, "_UNISWAP_MIXED_DAI_FOR_ETH": { "calldata": "0x24856bc300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000308000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000002a00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000003635c9adc5dea00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000028000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002ba0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000bb8c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000acc47d3615931ec", "value": "0" @@ -187,28 +195,24 @@ "calldata": "0x24856bc3000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000003100b08000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000044000000000000000000000000000000000000000000000000000000000000004a000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000309051200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000000600000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000000000000000000000000003635c9adc5dea00000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000000200000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000280000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001049ea901be00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "value": "0" }, - "_UNISWAP_V4_1_ETH_FOR_USDC_WITH_WRAP": { - "calldata": "0x24856bc300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000003c0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000003050912000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000d2d62035241defd00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000000000000000000", - "value": "1000000000000000000" + "_UNISWAP_SPLIT_TWO_ROUTES_ETH_TO_USDC": { + "calldata": "0x24856bc30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000050b08000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000220000000000000000000000000000000000000000000000000000000000000034000000000000000000000000000000000000000000000000000000000000004600000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000029a2241af62c0000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002bc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000bb8a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002bc02aaa39b223fe8d0a0e5c4f27ead9083c756cc20001f4a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa00000000000000000000000000000000000000000000000000000000ceebdd6e", + "value": "3000000000000000000" }, - "_UNISWAP_V4_USDC_FOR_1_ETH_2_HOP_WITH_ETH_FEE": { - "calldata": "0x24856bc3000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000003100604000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000052000000000000000000000000000000000000000000000000000000000000005a000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000030709120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000e9bb2d80e8435e5000000000000000000000000000000000000000000000000102a78813767ff57000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000100000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb00000000000000000000000000000000000000000000000000000000000001f400000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000de0b6b3a7640000", - "value": "0" + "_UNISWAP_SPLIT_THREE_ROUTES_ETH_TO_USDC": { + "calldata": "0x24856bc30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000050b08000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000220000000000000000000000000000000000000000000000000000000000000034000000000000000000000000000000000000000000000000000000000000004600000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000029a2241af62c0000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002bc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000bb8a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002bc02aaa39b223fe8d0a0e5c4f27ead9083c756cc20001f4a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa00000000000000000000000000000000000000000000000000000000ceebdd6e", + "value": "3000000000000000000" }, - "_UNISWAP_V4_1000_USDC_FOR_ETH_WITH_UNWRAP": { - "calldata": "0x24856bc300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000030709120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000ea8d710c6670fe500000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000000000000000000", + "MIGRATE_WITH_PERMIT": { + "calldata": "0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000031112130000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000056000000000000000000000000000000000000000000000000000000000000000c47ac2ff7b0000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003c4ac9650d800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000001800000000000000000000000000000000000000000000000000000000000000260000000000000000000000000000000000000000000000000000000000000032000000000000000000000000000000000000000000000000000000000000000c47ac2ff7b0000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a40c49ccbe00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000084fc6f786500000000000000000000000000000000000000000000000000000000000000010000000000000000000000000048d1c09771bb87b6a44e1294769e1dfd69858400000000000000000000000000000000ffffffffffffffffffffffffffffffff00000000000000000000000000000000ffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002442966c68000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000524dd46508f0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000004c00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000050209091919000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000026000000000000000000000000000000000000000000000000000000000000002e0000000000000000000000000000000000000000000000000000000000000036000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000001f4000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000002000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa00000000000000000000000000000000000000000000000000000000", "value": "0" }, - "_UNISWAP_V4_1000_USDC_FOR_ETH_WITH_FEE_AND_UNWRAP": { - "calldata": "0x24856bc3000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000003100604000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000052000000000000000000000000000000000000000000000000000000000000005a000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000030709120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000e9bb2d80e8435e5000000000000000000000000000000000000000000000000102a78813767ff57000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000100000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb00000000000000000000000000000000000000000000000000000000000001f40000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000de0b6b3a7640000", + "MIGRATE_WITHOUT_PERMIT": { + "calldata": "0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002121300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000032000000000000000000000000000000000000000000000000000000000000002a4ac9650d80000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000a40c49ccbe00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000084fc6f786500000000000000000000000000000000000000000000000000000000000000010000000000000000000000000048d1c09771bb87b6a44e1294769e1dfd69858400000000000000000000000000000000ffffffffffffffffffffffffffffffff00000000000000000000000000000000ffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002442966c68000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000524dd46508f0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000004c00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000050209091919000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000026000000000000000000000000000000000000000000000000000000000000002e0000000000000000000000000000000000000000000000000000000000000036000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000001f4000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000002000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa00000000000000000000000000000000000000000000000000000000", "value": "0" }, - "_UNISWAP_V4_UNWRAP_WETH_TO_ETH_FOR_1000_USDC": { - "calldata": "0x24856bc300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000030709120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000020000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000003b9aca00000000000000000000000000000000000000000000000000000000003ef64b1300000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000000000000000000", + "_UNISWAP_V4_USDC_FOR_1_ETH_WITH_UNWRAP": { + "calldata": "0x24856bc3000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000002100b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000030709120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000ea8d710c6670fe5000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000100000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa8000000000000000000000000000000000000000000000000000000000000000", "value": "0" - }, - "_UNISWAP_V4_WRAP_ETH_FOR_1000_USDC": { - "calldata": "0x24856bc300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004a000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000307091200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000380000000000000000000000000000000000000000000000000000000000000028000000000000000000000000000000000000000000000000000000000000000200000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000ea8d710c6670fe5000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000100000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000600000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000000000000000000", - "value": "1056330579666472933" } } \ No newline at end of file diff --git a/sdks/universal-router-sdk/test/uniswapTrades.test.ts b/sdks/universal-router-sdk/test/uniswapTrades.test.ts index 4f009807e..1b6bada9e 100644 --- a/sdks/universal-router-sdk/test/uniswapTrades.test.ts +++ b/sdks/universal-router-sdk/test/uniswapTrades.test.ts @@ -665,7 +665,7 @@ describe('Uniswap', () => { expect(hexToDecimalString(methodParameters.value)).to.equal('0') }) - it.only('encodes a USDC->DAI->ETH swap with a wrap to recieve WETH', async () => { + it('encodes a USDC->DAI->ETH swap with a wrap to recieve WETH', async () => { const outputEther = utils.parseEther('1') const trade = await V4Trade.fromRoute( new V4Route([USDC_DAI_V4, ETH_DAI_V4], USDC, WETH), @@ -675,7 +675,7 @@ describe('Uniswap', () => { const opts = swapOptions({}) const methodParameters = SwapRouter.swapCallParameters(buildTrade([trade]), opts) - registerFixture('_UNISWAP_V4_1000_USDC_FOR_ETH_WITH_UNWRAP', methodParameters) + registerFixture('_UNISWAP_V4_USDC_FOR_1_ETH_WITH_UNWRAP', methodParameters) expect(hexToDecimalString(methodParameters.value)).to.equal('0') }) From 5f78eb819740cfb9fc3ddf3e69dbcd66699361d9 Mon Sep 17 00:00:00 2001 From: Emily Williams Date: Mon, 14 Oct 2024 16:16:20 -0400 Subject: [PATCH 11/23] lint --- sdks/universal-router-sdk/src/entities/actions/uniswap.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sdks/universal-router-sdk/src/entities/actions/uniswap.ts b/sdks/universal-router-sdk/src/entities/actions/uniswap.ts index 99688076c..4beee6928 100644 --- a/sdks/universal-router-sdk/src/entities/actions/uniswap.ts +++ b/sdks/universal-router-sdk/src/entities/actions/uniswap.ts @@ -325,7 +325,10 @@ function addV4Swap( const v4Planner = new V4Planner() v4Planner.addTrade(trade, slippageToleranceOnSwap) v4Planner.addSettle(trade.route.pathInput, payerIsUser) - v4Planner.addTake(trade.route.pathOutput, routerMustCustody ? ROUTER_AS_RECIPIENT : options.recipient ?? SENDER_AS_RECIPIENT) + v4Planner.addTake( + trade.route.pathOutput, + routerMustCustody ? ROUTER_AS_RECIPIENT : options.recipient ?? SENDER_AS_RECIPIENT + ) planner.addCommand(CommandType.V4_SWAP, [v4Planner.finalize()]) } From f7fc070ca9617479f7336349ae30960bed26ae64 Mon Sep 17 00:00:00 2001 From: Emily Williams Date: Mon, 14 Oct 2024 16:24:48 -0400 Subject: [PATCH 12/23] lint interop --- sdks/universal-router-sdk/test/forge/interop.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdks/universal-router-sdk/test/forge/interop.json b/sdks/universal-router-sdk/test/forge/interop.json index 6067a5441..21330b017 100644 --- a/sdks/universal-router-sdk/test/forge/interop.json +++ b/sdks/universal-router-sdk/test/forge/interop.json @@ -211,4 +211,4 @@ "calldata": "0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000ffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000412121213000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000001600000000000000000000000000000000000000000000000000000000000000220000000000000000000000000000000000000000000000000000000000000028000000000000000000000000000000000000000000000000000000000000000a40c49ccbe000000000000000000000000000000000000000000000000000000000005c474000000000000000000000000000000000000000000000000000041b5de3f36ba0000000000000000000000000000000000000000000000000000000091637ff800000000000000000000000000000000000000000000000005e085d5c8a18a7e000000000000000000000000ffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000084fc6f7865000000000000000000000000000000000000000000000000000000000005c4740000000000000000000000002e234dae75c793f67a35089c9d99245e1c58470b00000000000000000000000000000000ffffffffffffffffffffffffffffffff00000000000000000000000000000000ffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002442966c68000000000000000000000000000000000000000000000000000000000005c474000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000524dd46508f0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000ffffffffffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000000004c00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000050209091919000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000026000000000000000000000000000000000000000000000000000000000000002e0000000000000000000000000000000000000000000000000000000000000036000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030d6800000000000000000000000000000000000000000000000000000000000493e000000000000000000000000000000000000000000000000000000000000186a000000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000000000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa00000000000000000000000000000000000000000000000000000000", "value": "0" } -} \ No newline at end of file +} From 9e97a4054faa8fcec81829288e3fd2b874eedeaf Mon Sep 17 00:00:00 2001 From: Emily Williams Date: Tue, 15 Oct 2024 13:37:29 -0400 Subject: [PATCH 13/23] support unwrapping WETH to trade ETH on v4 --- .../src/entities/actions/uniswap.ts | 71 ++++++++++--------- .../src/utils/pathCurrency.ts | 12 ++-- .../test/forge/SwapERC20CallParameters.t.sol | 68 ++++++++++++++---- .../test/forge/interop.json | 6 +- .../test/uniswapTrades.test.ts | 13 ++-- 5 files changed, 104 insertions(+), 66 deletions(-) diff --git a/sdks/universal-router-sdk/src/entities/actions/uniswap.ts b/sdks/universal-router-sdk/src/entities/actions/uniswap.ts index 4beee6928..6fde7efc0 100644 --- a/sdks/universal-router-sdk/src/entities/actions/uniswap.ts +++ b/sdks/universal-router-sdk/src/entities/actions/uniswap.ts @@ -66,8 +66,7 @@ export class UniswapTrade implements Command { constructor(public trade: RouterTrade, public options: SwapOptions) { if (!!options.fee && !!options.flatFee) throw new Error('Only one fee option permitted') - if (this.inputRequiresWrap) this.payerIsUser = false - else if (this.options.useRouterBalance) this.payerIsUser = false + if (this.inputRequiresWrap || this.inputRequiresUnwrap || this.options.useRouterBalance) this.payerIsUser = false else this.payerIsUser = true } @@ -89,13 +88,11 @@ export class UniswapTrade implements Command { } } - get outputRequiresUnwrap(): boolean { - if (!this.isAllV4) { - return this.trade.outputAmount.currency.isNative - } else { - // If the output currency is ETH and the output of the swap is not ETH it must be WETH that needs unwrapping - return this.trade.outputAmount.currency.isNative && !this.trade.swaps[0].route.output.isNative + get inputRequiresUnwrap(): boolean { + if (this.isAllV4) { + return !this.trade.inputAmount.currency.isNative && this.trade.swaps[0].route.pathInput.isNative } + return false } get outputRequiresWrap(): boolean { @@ -105,6 +102,15 @@ export class UniswapTrade implements Command { return false } + get outputRequiresUnwrap(): boolean { + if (!this.isAllV4) { + return this.trade.outputAmount.currency.isNative + } else { + // If the output currency is ETH and the output of the swap is not ETH it must be WETH that needs unwrapping + return this.trade.outputAmount.currency.isNative && !this.trade.swaps[0].route.output.isNative + } + } + get outputRequiresTransition(): boolean { return this.outputRequiresWrap || this.outputRequiresUnwrap } @@ -117,6 +123,14 @@ export class UniswapTrade implements Command { ROUTER_AS_RECIPIENT, this.trade.maximumAmountIn(this.options.slippageTolerance).quotient.toString(), ]) + } else if (this.inputRequiresUnwrap) { + // send wrapped token to router to unwrap + planner.addCommand(CommandType.PERMIT2_TRANSFER_FROM, [ + this.trade.inputAmount.currency.address, + ROUTER_AS_RECIPIENT, + this.trade.maximumAmountIn(this.options.slippageTolerance).quotient.toString() + ]) + planner.addCommand(CommandType.UNWRAP_WETH, [ROUTER_AS_RECIPIENT, 0]) } // The overall recipient at the end of the trade, SENDER_AS_RECIPIENT uses the msg.sender this.options.recipient = this.options.recipient ?? SENDER_AS_RECIPIENT @@ -152,7 +166,6 @@ export class UniswapTrade implements Command { let minimumAmountOut: BigNumber = BigNumber.from( this.trade.minimumAmountOut(this.options.slippageTolerance).quotient.toString() ) - // The router custodies for 3 reasons: to unwrap, to take a fee, and/or to do a slippage check if (routerMustCustody) { const pools = this.trade.swaps[0].route.pools @@ -202,10 +215,14 @@ export class UniswapTrade implements Command { } } - if (this.inputRequiresWrap && (this.trade.tradeType === TradeType.EXACT_OUTPUT || riskOfPartialFill(this.trade))) { - // for exactOutput swaps that take native currency as input - // we need to send back the change to the user - planner.addCommand(CommandType.UNWRAP_WETH, [this.options.recipient, 0]) + // for exactOutput swaps that take perform an inputToken transition (wrap or unwrap) + // we need to send back the change to the user + if (this.trade.tradeType === TradeType.EXACT_OUTPUT || riskOfPartialFill(this.trade)) { + if (this.inputRequiresWrap) { + planner.addCommand(CommandType.UNWRAP_WETH, [this.options.recipient, 0]) + } else if (this.inputRequiresUnwrap) { + planner.addCommand(CommandType.WRAP_ETH, [this.options.recipient, CONTRACT_BALANCE]) + } } if (this.options.safeMode) planner.addCommand(CommandType.SWEEP, [ETH_ADDRESS, this.options.recipient, 0]) @@ -286,38 +303,24 @@ function addV3Swap( function addV4Swap( planner: RoutePlanner, - { route, inputAmount, outputAmount }: Swap, + { inputAmount, outputAmount, route }: Swap, tradeType: TradeType, options: SwapOptions, payerIsUser: boolean, routerMustCustody: boolean ): void { + + // create a deep copy of pools since v4Planner encoding tampers with array + const pools = route.pools.map(p => p) + const v4Route = new V4Route(pools, inputAmount.currency, outputAmount.currency) const trade = V4Trade.createUncheckedTrade({ - route: route as RouteV4, + route: v4Route, inputAmount, outputAmount, tradeType, }) - // console.log(route) - // console.log(route.pools[0].currency0) - // console.log(route.pools[0].currency1) - // console.log(route.pools[1].currency0) - // console.log(route.pools[1].currency1) - // console.log(tradeType) - // console.log(trade) - // console.log(trade.swaps[0]) - // console.log(trade.inputAmount) - // console.log(trade.outputAmount) - - // console.log(payerIsUser) - // console.log(trade.tradeType === TradeType.EXACT_OUTPUT) - // - // console.log(encodeV4RouteToPath(trade.route, true)) - // console.log(trade.route.pathInput) - // console.log(trade.route.pathOutput) - - payerIsUser = payerIsUser && route.input == route.pathInput + payerIsUser = payerIsUser && v4Route.input == v4Route.pathInput const slippageToleranceOnSwap = routerMustCustody && tradeType == TradeType.EXACT_INPUT ? undefined : options.slippageTolerance diff --git a/sdks/universal-router-sdk/src/utils/pathCurrency.ts b/sdks/universal-router-sdk/src/utils/pathCurrency.ts index e7852b998..9c96d29ea 100644 --- a/sdks/universal-router-sdk/src/utils/pathCurrency.ts +++ b/sdks/universal-router-sdk/src/utils/pathCurrency.ts @@ -12,14 +12,10 @@ export function getPathCurrency(currency: Currency, pool: TPool): Currency { return currency.wrapped // return native currency if pool involves native version of wrapped currency (only applies to V4) - } else if (pool instanceof V4Pool) { - if (pool.token0.wrapped.equals(currency)) { - return pool.token0 - } else if (pool.token1.wrapped.equals(currency)) { - return pool.token1 - } - - // otherwise the token is invalid + } else if (pool instanceof V4Pool && pool.token0.wrapped.equals(currency)) { + return pool.token0 + } else if (pool instanceof V4Pool && pool.token1.wrapped.equals(currency)) { + return pool.token1 } else { throw new Error(`Expected currency ${currency.symbol} to be either ${pool.token0.symbol} or ${pool.token1.symbol}`) } diff --git a/sdks/universal-router-sdk/test/forge/SwapERC20CallParameters.t.sol b/sdks/universal-router-sdk/test/forge/SwapERC20CallParameters.t.sol index 28770a8f3..f56405787 100644 --- a/sdks/universal-router-sdk/test/forge/SwapERC20CallParameters.t.sol +++ b/sdks/universal-router-sdk/test/forge/SwapERC20CallParameters.t.sol @@ -580,6 +580,59 @@ contract SwapERC20CallParametersTest is Test, Interop, DeployRouter { assertEq(address(router).balance, 0); } + function testV4ExactOutNativeOutputWithUnwrap() public { + MethodParameters memory params = readFixture(json, "._UNISWAP_V4_USDC_FOR_1_ETH_WITH_UNWRAP"); + + deal(address(USDC), from, BALANCE); + USDC.approve(address(permit2), BALANCE); + permit2.approve(address(USDC), address(router), uint160(BALANCE), uint48(block.timestamp + 1000)); + assertEq(USDC.balanceOf(from), BALANCE); + uint256 startingRecipientBalance = RECIPIENT.balance; + + (bool success,) = address(router).call{value: params.value}(params.data); + require(success, "call failed"); + + assertEq(WETH.balanceOf(RECIPIENT), 1 ether); + } + + function testV4ExactInSwapWithETHFeeAndUnwrap() public { + MethodParameters memory params = readFixture(json, "._UNISWAP_V4_USDC_FOR_1000_ETH_WITH_FEE_AND_UNWRAP"); + deal(address(USDC), from, BALANCE); + USDC.approve(address(permit2), BALANCE); + permit2.approve(address(USDC), address(router), uint160(BALANCE), uint48(block.timestamp + 1000)); + + assertEq(USDC.balanceOf(from), BALANCE); + uint256 startingRecipientBalance = WETH.balanceOf(RECIPIENT); + uint256 startingFeeRecipientBalance = FEE_RECIPIENT.balance; + + (bool success,) = address(router).call{value: params.value}(params.data); + require(success, "call failed"); + + uint256 expectedAmount = 1 ether; + uint256 expectedFee = expectedAmount * 500 / 10000; + + assertEq(WETH.balanceOf(RECIPIENT) - startingRecipientBalance, expectedAmount); + assertEq(FEE_RECIPIENT.balance - startingFeeRecipientBalance, expectedFee); + } + + function testUnwrapWETHToTradeETHForUSDC() public { + MethodParameters memory params = readFixture(json, "._UNISWAP_V4_UNWRAP_WETH_TO_ETH_FOR_1000_USDC"); + deal(address(WETH), from, BALANCE); + WETH.approve(address(permit2), BALANCE); + permit2.approve(address(WETH), address(router), uint160(BALANCE), uint48(block.timestamp + 1000)); + + uint256 startingRecipientBalance = USDC.balanceOf(RECIPIENT); + + (bool success,) = address(router).call{value: params.value}(params.data); + require(success, "call failed"); + + uint256 expectedAmount = 1000 * 10 ** 6; + + assertEq(USDC.balanceOf(RECIPIENT) - startingRecipientBalance, expectedAmount); + assertEq(WETH.balanceOf(address(router)), 0); + assertEq(address(router).balance, 0); + } + function testV4ExactInWithFee() public { MethodParameters memory params = readFixture(json, "._UNISWAP_V4_1_ETH_FOR_USDC_WITH_FEE"); @@ -651,21 +704,6 @@ contract SwapERC20CallParametersTest is Test, Interop, DeployRouter { assertGe(from.balance, startingRecipientBalance); } - function testV4ExactOutNativeOutputWithUnwrap() public { - MethodParameters memory params = readFixture(json, "._UNISWAP_V4_USDC_FOR_1_ETH_WITH_UNWRAP"); - - deal(address(USDC), from, BALANCE); - USDC.approve(address(permit2), BALANCE); - permit2.approve(address(USDC), address(router), uint160(BALANCE), uint48(block.timestamp + 1000)); - assertEq(USDC.balanceOf(from), BALANCE); - uint256 startingRecipientBalance = RECIPIENT.balance; - - (bool success,) = address(router).call{value: params.value}(params.data); - require(success, "call failed"); - - assertEq(WETH.balanceOf(RECIPIENT), 1 ether); - } - function testV4ExactInMultiHop() public { MethodParameters memory params = readFixture(json, "._UNISWAP_V4_ETH_FOR_DAI"); diff --git a/sdks/universal-router-sdk/test/forge/interop.json b/sdks/universal-router-sdk/test/forge/interop.json index 21330b017..195c33ac7 100644 --- a/sdks/universal-router-sdk/test/forge/interop.json +++ b/sdks/universal-router-sdk/test/forge/interop.json @@ -152,7 +152,7 @@ "value": "0" }, "_UNISWAP_V4_UNWRAP_WETH_TO_ETH_FOR_1000_USDC": { - "calldata": "0x24856bc300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000030709120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000020000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000003b9aca00000000000000000000000000000000000000000000000000000000003ef64b1300000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000000000000000000", + "calldata": "0x24856bc3000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000004020c100b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000006200000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000003ef64b1300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000030709120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000020000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000003b9aca00000000000000000000000000000000000000000000000000000000003ef64b1300000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa8000000000000000000000000000000000000000000000000000000000000000", "value": "0" }, "_UNISWAP_V4_WRAP_ETH_FOR_1000_USDC": { @@ -210,5 +210,9 @@ "_MIGRATE_WITHOUT_PERMIT": { "calldata": "0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000ffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000412121213000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000001600000000000000000000000000000000000000000000000000000000000000220000000000000000000000000000000000000000000000000000000000000028000000000000000000000000000000000000000000000000000000000000000a40c49ccbe000000000000000000000000000000000000000000000000000000000005c474000000000000000000000000000000000000000000000000000041b5de3f36ba0000000000000000000000000000000000000000000000000000000091637ff800000000000000000000000000000000000000000000000005e085d5c8a18a7e000000000000000000000000ffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000084fc6f7865000000000000000000000000000000000000000000000000000000000005c4740000000000000000000000002e234dae75c793f67a35089c9d99245e1c58470b00000000000000000000000000000000ffffffffffffffffffffffffffffffff00000000000000000000000000000000ffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002442966c68000000000000000000000000000000000000000000000000000000000005c474000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000524dd46508f0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000ffffffffffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000000004c00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000050209091919000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000026000000000000000000000000000000000000000000000000000000000000002e0000000000000000000000000000000000000000000000000000000000000036000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030d6800000000000000000000000000000000000000000000000000000000000493e000000000000000000000000000000000000000000000000000000000000186a000000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000000000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa00000000000000000000000000000000000000000000000000000000", "value": "0" + }, + "_UNISWAP_V4_USDC_FOR_1000_ETH_WITH_FEE_AND_UNWRAP": { + "calldata": "0x24856bc300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000310050b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000052000000000000000000000000000000000000000000000000000000000000005a000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000030709120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000e92596fd62900000000000000000000000000000000000000000000000000000f647b8513b70838000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000100000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb00000000000000000000000000000000000000000000000000b1a2bc2ec500000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa8000000000000000000000000000000000000000000000000000000000000000", + "value": "0" } } diff --git a/sdks/universal-router-sdk/test/uniswapTrades.test.ts b/sdks/universal-router-sdk/test/uniswapTrades.test.ts index 753b877b9..cff1b6972 100644 --- a/sdks/universal-router-sdk/test/uniswapTrades.test.ts +++ b/sdks/universal-router-sdk/test/uniswapTrades.test.ts @@ -694,20 +694,17 @@ describe('Uniswap', () => { it('encodes a USDC->DAI->ETH swap with a fee that must then wrap to recieve WETH', async () => { const outputEther = utils.parseEther('1') - const adjustedOutputEther = outputEther - .mul(10000) - .div(10000 - 500) - .toString() + const flatFee = outputEther.mul('5').div('100') const trade = await V4Trade.fromRoute( new V4Route([USDC_DAI_V4, ETH_DAI_V4], USDC, WETH), - CurrencyAmount.fromRawAmount(WETH, adjustedOutputEther), + CurrencyAmount.fromRawAmount(WETH, outputEther.add(flatFee).toString()), TradeType.EXACT_OUTPUT ) - const feeOptions: FeeOptions = { fee: new Percent(5, 100), recipient: TEST_FEE_RECIPIENT_ADDRESS } - const opts = swapOptions({ fee: feeOptions }) + const feeOptions: FlatFeeOptions = { amount: flatFee, recipient: TEST_FEE_RECIPIENT_ADDRESS } + const opts = swapOptions({ flatFee: feeOptions }) const methodParameters = SwapRouter.swapCallParameters(buildTrade([trade]), opts) - registerFixture('_UNISWAP_V4_1000_USDC_FOR_ETH_WITH_FEE_AND_UNWRAP', methodParameters) + registerFixture('_UNISWAP_V4_USDC_FOR_1000_ETH_WITH_FEE_AND_UNWRAP', methodParameters) expect(hexToDecimalString(methodParameters.value)).to.equal('0') }) From 5529762d168d4d63bcf8ba253a1ab5c4cdd44319 Mon Sep 17 00:00:00 2001 From: Emily Williams Date: Tue, 15 Oct 2024 14:05:48 -0400 Subject: [PATCH 14/23] support wrapping ETH to trade on V4 (exact output) --- .../src/entities/actions/uniswap.ts | 15 ++++++--------- .../test/forge/SwapERC20CallParameters.t.sol | 17 ++++++++++++++++- .../test/forge/interop.json | 8 ++++++-- .../test/uniswapTrades.test.ts | 2 +- 4 files changed, 29 insertions(+), 13 deletions(-) diff --git a/sdks/universal-router-sdk/src/entities/actions/uniswap.ts b/sdks/universal-router-sdk/src/entities/actions/uniswap.ts index 6fde7efc0..01f1139d8 100644 --- a/sdks/universal-router-sdk/src/entities/actions/uniswap.ts +++ b/sdks/universal-router-sdk/src/entities/actions/uniswap.ts @@ -79,12 +79,10 @@ export class UniswapTrade implements Command { } get inputRequiresWrap(): boolean { - if (!this.isAllV4) { - return this.trade.inputAmount.currency.isNative + if (this.isAllV4) { + return this.trade.inputAmount.currency.isNative && !this.trade.swaps[0].route.pathInput.isNative } else { - // We only support wrapping all ETH or no ETH currently. We cannot support splitting where half needs to be wrapped - // If the input currency is ETH and the input of the first path is not ETH it must be WETH that needs wrapping - return this.trade.inputAmount.currency.isNative && !this.trade.swaps[0].route.input.isNative + return this.trade.inputAmount.currency.isNative } } @@ -103,11 +101,10 @@ export class UniswapTrade implements Command { } get outputRequiresUnwrap(): boolean { - if (!this.isAllV4) { - return this.trade.outputAmount.currency.isNative - } else { - // If the output currency is ETH and the output of the swap is not ETH it must be WETH that needs unwrapping + if (this.isAllV4) { return this.trade.outputAmount.currency.isNative && !this.trade.swaps[0].route.output.isNative + } else { + return this.trade.outputAmount.currency.isNative } } diff --git a/sdks/universal-router-sdk/test/forge/SwapERC20CallParameters.t.sol b/sdks/universal-router-sdk/test/forge/SwapERC20CallParameters.t.sol index f56405787..250944fbe 100644 --- a/sdks/universal-router-sdk/test/forge/SwapERC20CallParameters.t.sol +++ b/sdks/universal-router-sdk/test/forge/SwapERC20CallParameters.t.sol @@ -615,7 +615,7 @@ contract SwapERC20CallParametersTest is Test, Interop, DeployRouter { assertEq(FEE_RECIPIENT.balance - startingFeeRecipientBalance, expectedFee); } - function testUnwrapWETHToTradeETHForUSDC() public { + function testV4UnwrapWETHToTradeETHForUSDC() public { MethodParameters memory params = readFixture(json, "._UNISWAP_V4_UNWRAP_WETH_TO_ETH_FOR_1000_USDC"); deal(address(WETH), from, BALANCE); WETH.approve(address(permit2), BALANCE); @@ -633,6 +633,21 @@ contract SwapERC20CallParametersTest is Test, Interop, DeployRouter { assertEq(address(router).balance, 0); } + function testV4WrapETHToTradeWETHForDAI() public { + MethodParameters memory params = readFixture(json, "._UNISWAP_V4_WRAP_ETH_FOR_1_DAI"); + + uint256 startingRecipientBalance = USDC.balanceOf(RECIPIENT); + + (bool success,) = address(router).call{value: params.value}(params.data); + require(success, "call failed"); + + uint256 expectedAmount = 1 ether; + + assertEq(DAI.balanceOf(RECIPIENT) - startingRecipientBalance, expectedAmount); + assertEq(WETH.balanceOf(address(router)), 0); + assertEq(address(router).balance, 0); + } + function testV4ExactInWithFee() public { MethodParameters memory params = readFixture(json, "._UNISWAP_V4_1_ETH_FOR_USDC_WITH_FEE"); diff --git a/sdks/universal-router-sdk/test/forge/interop.json b/sdks/universal-router-sdk/test/forge/interop.json index 195c33ac7..3cb1ae10b 100644 --- a/sdks/universal-router-sdk/test/forge/interop.json +++ b/sdks/universal-router-sdk/test/forge/interop.json @@ -116,7 +116,7 @@ "value": "1000000000000000000" }, "_UNISWAP_V4_1_ETH_FOR_USDC_WITH_WRAP": { - "calldata": "0x24856bc300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000003c0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000003050912000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000d2d62035241defd00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000000000000000000", + "calldata": "0x24856bc30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000020b100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000000000000000003c0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000003050912000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000d2d62035241defd00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000000000000000000", "value": "1000000000000000000" }, "_UNISWAP_V4_1_ETH_FOR_USDC_WITH_FEE": { @@ -156,7 +156,7 @@ "value": "0" }, "_UNISWAP_V4_WRAP_ETH_FOR_1000_USDC": { - "calldata": "0x24856bc300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004a000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000307091200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000380000000000000000000000000000000000000000000000000000000000000028000000000000000000000000000000000000000000000000000000000000000200000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000ea8d710c6670fe5000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000100000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000000000000000000", + "calldata": "0x24856bc30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000030b100c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000580000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000ea8d710c6670fe500000000000000000000000000000000000000000000000000000000000004a000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000307091200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000380000000000000000000000000000000000000000000000000000000000000028000000000000000000000000000000000000000000000000000000000000000200000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000ea8d710c6670fe5000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000100000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000000000000000000", "value": "1056330579666472933" }, "_UNISWAP_MIXED_1_ETH_FOR_DAI": { @@ -214,5 +214,9 @@ "_UNISWAP_V4_USDC_FOR_1000_ETH_WITH_FEE_AND_UNWRAP": { "calldata": "0x24856bc300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000310050b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000052000000000000000000000000000000000000000000000000000000000000005a000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000030709120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000e92596fd62900000000000000000000000000000000000000000000000000000f647b8513b70838000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000100000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb00000000000000000000000000000000000000000000000000b1a2bc2ec500000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa8000000000000000000000000000000000000000000000000000000000000000", "value": "0" + }, + "_UNISWAP_V4_WRAP_ETH_FOR_1_DAI": { + "calldata": "0x24856bc30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000030b100c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000580000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000ea8d710c6670fe500000000000000000000000000000000000000000000000000000000000004a000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000307091200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000380000000000000000000000000000000000000000000000000000000000000028000000000000000000000000000000000000000000000000000000000000000200000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000ea8d710c6670fe5000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000100000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000000000000000000", + "value": "1056330579666472933" } } diff --git a/sdks/universal-router-sdk/test/uniswapTrades.test.ts b/sdks/universal-router-sdk/test/uniswapTrades.test.ts index cff1b6972..fd329899b 100644 --- a/sdks/universal-router-sdk/test/uniswapTrades.test.ts +++ b/sdks/universal-router-sdk/test/uniswapTrades.test.ts @@ -734,7 +734,7 @@ describe('Uniswap', () => { const opts = swapOptions({}) buildTrade([trade]) const methodParameters = SwapRouter.swapCallParameters(buildTrade([trade]), opts) - registerFixture('_UNISWAP_V4_WRAP_ETH_FOR_1000_USDC', methodParameters) + registerFixture('_UNISWAP_V4_WRAP_ETH_FOR_1_DAI', methodParameters) expect(hexToDecimalString(methodParameters.value)).to.not.equal('0') }) }) From 0553c968bdf6f3b89ec5e60f599a57929f189c2b Mon Sep 17 00:00:00 2001 From: Emily Williams Date: Tue, 15 Oct 2024 14:06:12 -0400 Subject: [PATCH 15/23] lint --- sdks/universal-router-sdk/src/entities/actions/uniswap.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sdks/universal-router-sdk/src/entities/actions/uniswap.ts b/sdks/universal-router-sdk/src/entities/actions/uniswap.ts index 01f1139d8..4389bf5b9 100644 --- a/sdks/universal-router-sdk/src/entities/actions/uniswap.ts +++ b/sdks/universal-router-sdk/src/entities/actions/uniswap.ts @@ -125,9 +125,9 @@ export class UniswapTrade implements Command { planner.addCommand(CommandType.PERMIT2_TRANSFER_FROM, [ this.trade.inputAmount.currency.address, ROUTER_AS_RECIPIENT, - this.trade.maximumAmountIn(this.options.slippageTolerance).quotient.toString() + this.trade.maximumAmountIn(this.options.slippageTolerance).quotient.toString(), ]) - planner.addCommand(CommandType.UNWRAP_WETH, [ROUTER_AS_RECIPIENT, 0]) + planner.addCommand(CommandType.UNWRAP_WETH, [ROUTER_AS_RECIPIENT, 0]) } // The overall recipient at the end of the trade, SENDER_AS_RECIPIENT uses the msg.sender this.options.recipient = this.options.recipient ?? SENDER_AS_RECIPIENT @@ -306,9 +306,8 @@ function addV4Swap( payerIsUser: boolean, routerMustCustody: boolean ): void { - // create a deep copy of pools since v4Planner encoding tampers with array - const pools = route.pools.map(p => p) + const pools = route.pools.map((p) => p) const v4Route = new V4Route(pools, inputAmount.currency, outputAmount.currency) const trade = V4Trade.createUncheckedTrade({ route: v4Route, From 1b49ea19564f5ea8b116f1c7c3ecd06a3a494a75 Mon Sep 17 00:00:00 2001 From: Emily Williams Date: Tue, 15 Oct 2024 14:23:46 -0400 Subject: [PATCH 16/23] force types to appease build (better way to do this??) --- .../src/entities/actions/uniswap.ts | 27 +++++++++++++------ .../src/utils/getCurrencyAddress.ts | 2 +- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/sdks/universal-router-sdk/src/entities/actions/uniswap.ts b/sdks/universal-router-sdk/src/entities/actions/uniswap.ts index 4389bf5b9..fb6d7b5ba 100644 --- a/sdks/universal-router-sdk/src/entities/actions/uniswap.ts +++ b/sdks/universal-router-sdk/src/entities/actions/uniswap.ts @@ -16,7 +16,6 @@ import { IRoute, RouteV2, RouteV3, - RouteV4, MixedRouteSDK, MixedRoute, SwapOptions as RouterSwapOptions, @@ -26,7 +25,7 @@ import { } from '@uniswap/router-sdk' import { Permit2Permit } from '../../utils/inputTokens' import { getPathCurrency } from '../../utils/pathCurrency' -import { Currency, TradeType, CurrencyAmount, Percent } from '@uniswap/sdk-core' +import { Currency, TradeType, Token, CurrencyAmount, Percent } from '@uniswap/sdk-core' import { Command, RouterActionType, TradeConfig } from '../Command' import { SENDER_AS_RECIPIENT, ROUTER_AS_RECIPIENT, CONTRACT_BALANCE, ETH_ADDRESS } from '../../utils/constants' import { getCurrencyAddress } from '../../utils/getCurrencyAddress' @@ -80,7 +79,10 @@ export class UniswapTrade implements Command { get inputRequiresWrap(): boolean { if (this.isAllV4) { - return this.trade.inputAmount.currency.isNative && !this.trade.swaps[0].route.pathInput.isNative + return ( + this.trade.inputAmount.currency.isNative && + !(this.trade.swaps[0].route as unknown as V4Route).pathInput.isNative + ) } else { return this.trade.inputAmount.currency.isNative } @@ -88,21 +90,30 @@ export class UniswapTrade implements Command { get inputRequiresUnwrap(): boolean { if (this.isAllV4) { - return !this.trade.inputAmount.currency.isNative && this.trade.swaps[0].route.pathInput.isNative + return ( + !this.trade.inputAmount.currency.isNative && + (this.trade.swaps[0].route as unknown as V4Route).pathInput.isNative + ) } return false } get outputRequiresWrap(): boolean { if (this.isAllV4) { - return !this.trade.outputAmount.currency.isNative && this.trade.swaps[0].route.pathOutput.isNative + return ( + !this.trade.outputAmount.currency.isNative && + (this.trade.swaps[0].route as unknown as V4Route).pathOutput.isNative + ) } return false } get outputRequiresUnwrap(): boolean { if (this.isAllV4) { - return this.trade.outputAmount.currency.isNative && !this.trade.swaps[0].route.output.isNative + return ( + this.trade.outputAmount.currency.isNative && + !(this.trade.swaps[0].route as unknown as V4Route).pathOutput.isNative + ) } else { return this.trade.outputAmount.currency.isNative } @@ -123,7 +134,7 @@ export class UniswapTrade implements Command { } else if (this.inputRequiresUnwrap) { // send wrapped token to router to unwrap planner.addCommand(CommandType.PERMIT2_TRANSFER_FROM, [ - this.trade.inputAmount.currency.address, + (this.trade.inputAmount.currency as Token).address, ROUTER_AS_RECIPIENT, this.trade.maximumAmountIn(this.options.slippageTolerance).quotient.toString(), ]) @@ -307,7 +318,7 @@ function addV4Swap( routerMustCustody: boolean ): void { // create a deep copy of pools since v4Planner encoding tampers with array - const pools = route.pools.map((p) => p) + const pools = route.pools.map((p) => p) as V4Pool[] const v4Route = new V4Route(pools, inputAmount.currency, outputAmount.currency) const trade = V4Trade.createUncheckedTrade({ route: v4Route, diff --git a/sdks/universal-router-sdk/src/utils/getCurrencyAddress.ts b/sdks/universal-router-sdk/src/utils/getCurrencyAddress.ts index 1f545fd6a..9c215927e 100644 --- a/sdks/universal-router-sdk/src/utils/getCurrencyAddress.ts +++ b/sdks/universal-router-sdk/src/utils/getCurrencyAddress.ts @@ -1,6 +1,6 @@ import { Currency } from '@uniswap/sdk-core' import { ETH_ADDRESS } from './constants' -export function getCurrencyAddress(currency: Currency): Currency { +export function getCurrencyAddress(currency: Currency): string { return currency.isNative ? ETH_ADDRESS : currency.wrapped.address } From f445984a13fedaf08dd1c42ef4545329d093ba5b Mon Sep 17 00:00:00 2001 From: Emily Williams Date: Thu, 17 Oct 2024 11:09:25 -0400 Subject: [PATCH 17/23] PR comments --- sdks/universal-router-sdk/src/entities/actions/uniswap.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sdks/universal-router-sdk/src/entities/actions/uniswap.ts b/sdks/universal-router-sdk/src/entities/actions/uniswap.ts index fb6d7b5ba..21247ab6b 100644 --- a/sdks/universal-router-sdk/src/entities/actions/uniswap.ts +++ b/sdks/universal-router-sdk/src/entities/actions/uniswap.ts @@ -177,8 +177,9 @@ export class UniswapTrade implements Command { // The router custodies for 3 reasons: to unwrap, to take a fee, and/or to do a slippage check if (routerMustCustody) { const pools = this.trade.swaps[0].route.pools - const pathOutputCurrency = getPathCurrency(this.trade.outputAmount.currency, pools[pools.length - 1]) - const pathOutputCurrencyAddress = pathOutputCurrency.isNative ? ETH_ADDRESS : pathOutputCurrency.address + const pathOutputCurrencyAddress = getCurrencyAddress( + getPathCurrency(this.trade.outputAmount.currency, pools[pools.length - 1]) + ) // If there is a fee, that percentage is sent to the fee recipient // In the case where ETH is the output currency, the fee is taken in WETH (for gas reasons) @@ -327,8 +328,6 @@ function addV4Swap( tradeType, }) - payerIsUser = payerIsUser && v4Route.input == v4Route.pathInput - const slippageToleranceOnSwap = routerMustCustody && tradeType == TradeType.EXACT_INPUT ? undefined : options.slippageTolerance From 38ebcebf14adf91cc4aec6f22f8cb6911e0a9cf7 Mon Sep 17 00:00:00 2001 From: Emily Williams Date: Mon, 4 Nov 2024 21:35:47 -0500 Subject: [PATCH 18/23] PR comments --- .../src/entities/actions/uniswap.ts | 8 ++++++-- .../test/forge/SwapERC20CallParameters.t.sol | 13 +++++++++---- sdks/universal-router-sdk/test/forge/interop.json | 2 +- .../universal-router-sdk/test/uniswapTrades.test.ts | 4 ++-- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/sdks/universal-router-sdk/src/entities/actions/uniswap.ts b/sdks/universal-router-sdk/src/entities/actions/uniswap.ts index 21247ab6b..0f059fac3 100644 --- a/sdks/universal-router-sdk/src/entities/actions/uniswap.ts +++ b/sdks/universal-router-sdk/src/entities/actions/uniswap.ts @@ -65,8 +65,12 @@ export class UniswapTrade implements Command { constructor(public trade: RouterTrade, public options: SwapOptions) { if (!!options.fee && !!options.flatFee) throw new Error('Only one fee option permitted') - if (this.inputRequiresWrap || this.inputRequiresUnwrap || this.options.useRouterBalance) this.payerIsUser = false - else this.payerIsUser = true + + if (this.inputRequiresWrap || this.inputRequiresUnwrap || this.options.useRouterBalance) { + this.payerIsUser = false + } else { + this.payerIsUser = true + } } get isAllV4(): boolean { diff --git a/sdks/universal-router-sdk/test/forge/SwapERC20CallParameters.t.sol b/sdks/universal-router-sdk/test/forge/SwapERC20CallParameters.t.sol index 250944fbe..60fc2c8c2 100644 --- a/sdks/universal-router-sdk/test/forge/SwapERC20CallParameters.t.sol +++ b/sdks/universal-router-sdk/test/forge/SwapERC20CallParameters.t.sol @@ -555,7 +555,7 @@ contract SwapERC20CallParametersTest is Test, Interop, DeployRouter { // assertGt(USDC.balanceOf(RECIPIENT), 2000 * ONE_USDC); // } - function testV4ExactInputDAIForETHwithETHFee() public { + function testV4ExactInputUSDCForETHwithETHFee() public { MethodParameters memory params = readFixture(json, "._UNISWAP_V4_USDC_FOR_1_ETH_2_HOP_WITH_ETH_FEE"); deal(address(USDC), from, BALANCE); USDC.approve(address(permit2), BALANCE); @@ -581,18 +581,19 @@ contract SwapERC20CallParametersTest is Test, Interop, DeployRouter { } function testV4ExactOutNativeOutputWithUnwrap() public { - MethodParameters memory params = readFixture(json, "._UNISWAP_V4_USDC_FOR_1_ETH_WITH_UNWRAP"); + MethodParameters memory params = readFixture(json, "._UNISWAP_V4_USDC_FOR_1_ETH_WITH_WRAP"); deal(address(USDC), from, BALANCE); USDC.approve(address(permit2), BALANCE); permit2.approve(address(USDC), address(router), uint160(BALANCE), uint48(block.timestamp + 1000)); assertEq(USDC.balanceOf(from), BALANCE); - uint256 startingRecipientBalance = RECIPIENT.balance; + uint256 startingRecipientBalance = USDC.balanceOf(from); (bool success,) = address(router).call{value: params.value}(params.data); require(success, "call failed"); assertEq(WETH.balanceOf(RECIPIENT), 1 ether); + assertLt(USDC.balanceOf(from), startingRecipientBalance); } function testV4ExactInSwapWithETHFeeAndUnwrap() public { @@ -622,6 +623,7 @@ contract SwapERC20CallParametersTest is Test, Interop, DeployRouter { permit2.approve(address(WETH), address(router), uint160(BALANCE), uint48(block.timestamp + 1000)); uint256 startingRecipientBalance = USDC.balanceOf(RECIPIENT); + uint256 startingFromBalance = WETH.balanceOf(from); (bool success,) = address(router).call{value: params.value}(params.data); require(success, "call failed"); @@ -631,12 +633,14 @@ contract SwapERC20CallParametersTest is Test, Interop, DeployRouter { assertEq(USDC.balanceOf(RECIPIENT) - startingRecipientBalance, expectedAmount); assertEq(WETH.balanceOf(address(router)), 0); assertEq(address(router).balance, 0); + assertLt(WETH.balanceOf(from), startingFromBalance); } function testV4WrapETHToTradeWETHForDAI() public { MethodParameters memory params = readFixture(json, "._UNISWAP_V4_WRAP_ETH_FOR_1_DAI"); - uint256 startingRecipientBalance = USDC.balanceOf(RECIPIENT); + uint256 startingRecipientBalance = DAI.balanceOf(RECIPIENT); + uint256 startingFromBalance = from.balance; (bool success,) = address(router).call{value: params.value}(params.data); require(success, "call failed"); @@ -646,6 +650,7 @@ contract SwapERC20CallParametersTest is Test, Interop, DeployRouter { assertEq(DAI.balanceOf(RECIPIENT) - startingRecipientBalance, expectedAmount); assertEq(WETH.balanceOf(address(router)), 0); assertEq(address(router).balance, 0); + assertLt(from.balance, startingFromBalance); } function testV4ExactInWithFee() public { diff --git a/sdks/universal-router-sdk/test/forge/interop.json b/sdks/universal-router-sdk/test/forge/interop.json index 3cb1ae10b..f3c479f10 100644 --- a/sdks/universal-router-sdk/test/forge/interop.json +++ b/sdks/universal-router-sdk/test/forge/interop.json @@ -143,7 +143,7 @@ "calldata": "0x24856bc3000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000003100604000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000052000000000000000000000000000000000000000000000000000000000000005a000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000030709120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000e9bb2d80e8435e5000000000000000000000000000000000000000000000000102a78813767ff57000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000100000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb00000000000000000000000000000000000000000000000000000000000001f400000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000de0b6b3a7640000", "value": "0" }, - "_UNISWAP_V4_USDC_FOR_1_ETH_WITH_UNWRAP": { + "_UNISWAP_V4_USDC_FOR_1_ETH_WITH_WRAP": { "calldata": "0x24856bc3000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000002100b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000030709120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000ea8d710c6670fe5000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000100000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa8000000000000000000000000000000000000000000000000000000000000000", "value": "0" }, diff --git a/sdks/universal-router-sdk/test/uniswapTrades.test.ts b/sdks/universal-router-sdk/test/uniswapTrades.test.ts index fd329899b..2080dc41e 100644 --- a/sdks/universal-router-sdk/test/uniswapTrades.test.ts +++ b/sdks/universal-router-sdk/test/uniswapTrades.test.ts @@ -688,7 +688,7 @@ describe('Uniswap', () => { const opts = swapOptions({}) const methodParameters = SwapRouter.swapCallParameters(buildTrade([trade]), opts) - registerFixture('_UNISWAP_V4_USDC_FOR_1_ETH_WITH_UNWRAP', methodParameters) + registerFixture('_UNISWAP_V4_USDC_FOR_1_ETH_WITH_WRAP', methodParameters) expect(hexToDecimalString(methodParameters.value)).to.equal('0') }) @@ -708,7 +708,7 @@ describe('Uniswap', () => { expect(hexToDecimalString(methodParameters.value)).to.equal('0') }) - it('encodes an exactOutput ETH->DAI->USDC swap that must first wrap WETH', async () => { + it('encodes an exactOutput ETH->DAI->USDC swap that must first unwrap WETH', async () => { const outputUSDC = utils.parseUnits('1000', 6).toString() const trade = await V4Trade.fromRoute( new V4Route([ETH_DAI_V4, USDC_DAI_V4], WETH, USDC), From 73457b3016a2a830758e3a79e688d36b4d5ea7a0 Mon Sep 17 00:00:00 2001 From: Emily Williams Date: Tue, 5 Nov 2024 15:18:31 -0500 Subject: [PATCH 19/23] woops forgot one PR comment --- .../test/forge/SwapERC20CallParameters.t.sol | 2 +- sdks/universal-router-sdk/test/forge/interop.json | 2 +- sdks/universal-router-sdk/test/uniswapTrades.test.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sdks/universal-router-sdk/test/forge/SwapERC20CallParameters.t.sol b/sdks/universal-router-sdk/test/forge/SwapERC20CallParameters.t.sol index 60fc2c8c2..20dabbd13 100644 --- a/sdks/universal-router-sdk/test/forge/SwapERC20CallParameters.t.sol +++ b/sdks/universal-router-sdk/test/forge/SwapERC20CallParameters.t.sol @@ -597,7 +597,7 @@ contract SwapERC20CallParametersTest is Test, Interop, DeployRouter { } function testV4ExactInSwapWithETHFeeAndUnwrap() public { - MethodParameters memory params = readFixture(json, "._UNISWAP_V4_USDC_FOR_1000_ETH_WITH_FEE_AND_UNWRAP"); + MethodParameters memory params = readFixture(json, "._UNISWAP_V4_USDC_FOR_1000_ETH_WITH_FEE_AND_WRAP"); deal(address(USDC), from, BALANCE); USDC.approve(address(permit2), BALANCE); permit2.approve(address(USDC), address(router), uint160(BALANCE), uint48(block.timestamp + 1000)); diff --git a/sdks/universal-router-sdk/test/forge/interop.json b/sdks/universal-router-sdk/test/forge/interop.json index f3c479f10..1b4df82f6 100644 --- a/sdks/universal-router-sdk/test/forge/interop.json +++ b/sdks/universal-router-sdk/test/forge/interop.json @@ -211,7 +211,7 @@ "calldata": "0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000ffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000412121213000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000001600000000000000000000000000000000000000000000000000000000000000220000000000000000000000000000000000000000000000000000000000000028000000000000000000000000000000000000000000000000000000000000000a40c49ccbe000000000000000000000000000000000000000000000000000000000005c474000000000000000000000000000000000000000000000000000041b5de3f36ba0000000000000000000000000000000000000000000000000000000091637ff800000000000000000000000000000000000000000000000005e085d5c8a18a7e000000000000000000000000ffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000084fc6f7865000000000000000000000000000000000000000000000000000000000005c4740000000000000000000000002e234dae75c793f67a35089c9d99245e1c58470b00000000000000000000000000000000ffffffffffffffffffffffffffffffff00000000000000000000000000000000ffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002442966c68000000000000000000000000000000000000000000000000000000000005c474000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000524dd46508f0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000ffffffffffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000000004c00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000050209091919000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000026000000000000000000000000000000000000000000000000000000000000002e0000000000000000000000000000000000000000000000000000000000000036000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030d6800000000000000000000000000000000000000000000000000000000000493e000000000000000000000000000000000000000000000000000000000000186a000000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000000000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa00000000000000000000000000000000000000000000000000000000", "value": "0" }, - "_UNISWAP_V4_USDC_FOR_1000_ETH_WITH_FEE_AND_UNWRAP": { + "_UNISWAP_V4_USDC_FOR_1000_ETH_WITH_FEE_AND_WRAP": { "calldata": "0x24856bc300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000310050b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000052000000000000000000000000000000000000000000000000000000000000005a000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000030709120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000e92596fd62900000000000000000000000000000000000000000000000000000f647b8513b70838000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000100000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb00000000000000000000000000000000000000000000000000b1a2bc2ec500000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa8000000000000000000000000000000000000000000000000000000000000000", "value": "0" }, diff --git a/sdks/universal-router-sdk/test/uniswapTrades.test.ts b/sdks/universal-router-sdk/test/uniswapTrades.test.ts index 2080dc41e..b48a9ad8e 100644 --- a/sdks/universal-router-sdk/test/uniswapTrades.test.ts +++ b/sdks/universal-router-sdk/test/uniswapTrades.test.ts @@ -704,7 +704,7 @@ describe('Uniswap', () => { const feeOptions: FlatFeeOptions = { amount: flatFee, recipient: TEST_FEE_RECIPIENT_ADDRESS } const opts = swapOptions({ flatFee: feeOptions }) const methodParameters = SwapRouter.swapCallParameters(buildTrade([trade]), opts) - registerFixture('_UNISWAP_V4_USDC_FOR_1000_ETH_WITH_FEE_AND_UNWRAP', methodParameters) + registerFixture('_UNISWAP_V4_USDC_FOR_1000_ETH_WITH_FEE_AND_WRAP', methodParameters) expect(hexToDecimalString(methodParameters.value)).to.equal('0') }) From 61c8505e00338edfdca91157bf04690465efccb6 Mon Sep 17 00:00:00 2001 From: Emily Williams Date: Tue, 5 Nov 2024 16:06:31 -0500 Subject: [PATCH 20/23] revert submodule change --- sdks/universal-router-sdk/lib/universal-router | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdks/universal-router-sdk/lib/universal-router b/sdks/universal-router-sdk/lib/universal-router index 5e9f4c9f0..5bc8881f2 160000 --- a/sdks/universal-router-sdk/lib/universal-router +++ b/sdks/universal-router-sdk/lib/universal-router @@ -1 +1 @@ -Subproject commit 5e9f4c9f063661bc43a3e5f2c0ef3d86612038ce +Subproject commit 5bc8881f29584b68f8b79bdd714b080a29b5dac4 From b38b124a5016fc7c9100346b8d5dda46742dd83f Mon Sep 17 00:00:00 2001 From: Emily Williams Date: Thu, 14 Nov 2024 16:23:15 -0500 Subject: [PATCH 21/23] refund ETH on exactOutput native trade --- .../src/entities/actions/uniswap.ts | 5 ++++- .../test/forge/SwapERC20CallParameters.t.sol | 18 +++++++++++++++++ .../test/forge/interop.json | 4 ++++ .../test/uniswapTrades.test.ts | 20 +++++++++++++++++-- 4 files changed, 44 insertions(+), 3 deletions(-) diff --git a/sdks/universal-router-sdk/src/entities/actions/uniswap.ts b/sdks/universal-router-sdk/src/entities/actions/uniswap.ts index 0f059fac3..5659b09dd 100644 --- a/sdks/universal-router-sdk/src/entities/actions/uniswap.ts +++ b/sdks/universal-router-sdk/src/entities/actions/uniswap.ts @@ -228,13 +228,16 @@ export class UniswapTrade implements Command { } } - // for exactOutput swaps that take perform an inputToken transition (wrap or unwrap) + // for exactOutput swaps that with native input or perform an inputToken transition (wrap or unwrap) // we need to send back the change to the user if (this.trade.tradeType === TradeType.EXACT_OUTPUT || riskOfPartialFill(this.trade)) { if (this.inputRequiresWrap) { planner.addCommand(CommandType.UNWRAP_WETH, [this.options.recipient, 0]) } else if (this.inputRequiresUnwrap) { planner.addCommand(CommandType.WRAP_ETH, [this.options.recipient, CONTRACT_BALANCE]) + } else if (this.trade.inputAmount.currency.isNative) { + // must refund extra native currency sent along for native v4 trades (no input transition) + planner.addCommand(CommandType.SWEEP, [ETH_ADDRESS, this.options.recipient, 0]) } } diff --git a/sdks/universal-router-sdk/test/forge/SwapERC20CallParameters.t.sol b/sdks/universal-router-sdk/test/forge/SwapERC20CallParameters.t.sol index 8e1b24be9..5f408e6e4 100644 --- a/sdks/universal-router-sdk/test/forge/SwapERC20CallParameters.t.sol +++ b/sdks/universal-router-sdk/test/forge/SwapERC20CallParameters.t.sol @@ -616,6 +616,24 @@ contract SwapERC20CallParametersTest is Test, Interop, DeployRouter { assertEq(FEE_RECIPIENT.balance - startingFeeRecipientBalance, expectedFee); } + function testV4ExactOutputETHForUSDC() public { + MethodParameters memory params = readFixture(json, "._UNISWAP_V4_ETH_FOR_1000_USDC"); + deal(address(WETH), from, BALANCE); + WETH.approve(address(permit2), BALANCE); + permit2.approve(address(WETH), address(router), uint160(BALANCE), uint48(block.timestamp + 1000)); + + uint256 startingRecipientBalance = USDC.balanceOf(RECIPIENT); + uint256 startingFromBalance = WETH.balanceOf(from); + + (bool success,) = address(router).call{value: params.value}(params.data); + require(success, "call failed"); + + uint256 expectedAmount = 1000 * 10 ** 6; + + assertEq(USDC.balanceOf(RECIPIENT) - startingRecipientBalance, expectedAmount); + assertEq(address(router).balance, 0); + } + function testV4UnwrapWETHToTradeETHForUSDC() public { MethodParameters memory params = readFixture(json, "._UNISWAP_V4_UNWRAP_WETH_TO_ETH_FOR_1000_USDC"); deal(address(WETH), from, BALANCE); diff --git a/sdks/universal-router-sdk/test/forge/interop.json b/sdks/universal-router-sdk/test/forge/interop.json index d4390edad..47ff0279d 100644 --- a/sdks/universal-router-sdk/test/forge/interop.json +++ b/sdks/universal-router-sdk/test/forge/interop.json @@ -214,5 +214,9 @@ "_MIGRATE_WITH_PERMIT_AND_POOL_INITIALIZE": { "calldata": "0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000ffffffffffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000000000061311121212140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000002a00000000000000000000000000000000000000000000000000000000000000380000000000000000000000000000000000000000000000000000000000000044000000000000000000000000000000000000000000000000000000000000004a000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000000000001f4000000000000000000000000000000000000000000000000000000000000003c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000c47ac2ff7b0000000000000000000000003fc91a3afd70395cd496c647d5a6cc9d4b2b7fad000000000000000000000000000000000000000000000000000000000005c474000000000000000000000000ffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000001b732094f18c1e15040f57cb172420ada5f052aecf36e59c690b5264c0b7ea17f4793408cafb3c3b5da7cd773d894a98b00cd6058280da7c6c6c814efacd6fc6fd0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a40c49ccbe000000000000000000000000000000000000000000000000000000000005c474000000000000000000000000000000000000000000000000000041b5de3f36ba0000000000000000000000000000000000000000000000000000000091637ff800000000000000000000000000000000000000000000000005e085d5c8a18a7e000000000000000000000000ffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000084fc6f7865000000000000000000000000000000000000000000000000000000000005c4740000000000000000000000002e234dae75c793f67a35089c9d99245e1c58470b00000000000000000000000000000000ffffffffffffffffffffffffffffffff00000000000000000000000000000000ffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002442966c68000000000000000000000000000000000000000000000000000000000005c474000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000524dd46508f0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000ffffffffffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000000004c00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000050209091919000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000026000000000000000000000000000000000000000000000000000000000000002e0000000000000000000000000000000000000000000000000000000000000036000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000000000001f4000000000000000000000000000000000000000000000000000000000000003c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030d6800000000000000000000000000000000000000000000000000000000000493e000000000000000000000000000000000000000000000000000000000000186a000000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000000000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa00000000000000000000000000000000000000000000000000000000", "value": "0" + }, + "_UNISWAP_V4_ETH_FOR_1000_USDC": { + "calldata": "0x24856bc3000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000002100400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000030709120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000020000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000003b9aca00000000000000000000000000000000000000000000000000000000003ef64b1300000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000000000000000000", + "value": "1056328467" } } diff --git a/sdks/universal-router-sdk/test/uniswapTrades.test.ts b/sdks/universal-router-sdk/test/uniswapTrades.test.ts index 853762755..296618fba 100644 --- a/sdks/universal-router-sdk/test/uniswapTrades.test.ts +++ b/sdks/universal-router-sdk/test/uniswapTrades.test.ts @@ -691,7 +691,7 @@ describe('Uniswap', () => { expect(hexToDecimalString(methodParameters.value)).to.equal('0') }) - it('encodes a USDC->DAI->ETH swap with a wrap to recieve WETH', async () => { + it('encodes an exactOuput USDC->DAI->ETH swap with a wrap to recieve WETH', async () => { const outputEther = utils.parseEther('1') const trade = await V4Trade.fromRoute( new V4Route([USDC_DAI_V4, ETH_DAI_V4], USDC, WETH), @@ -705,7 +705,7 @@ describe('Uniswap', () => { expect(hexToDecimalString(methodParameters.value)).to.equal('0') }) - it('encodes a USDC->DAI->ETH swap with a fee that must then wrap to recieve WETH', async () => { + it('encodes an exactOutput USDC->DAI->ETH swap with a fee that must then wrap to recieve WETH', async () => { const outputEther = utils.parseEther('1') const flatFee = outputEther.mul('5').div('100') const trade = await V4Trade.fromRoute( @@ -721,6 +721,22 @@ describe('Uniswap', () => { expect(hexToDecimalString(methodParameters.value)).to.equal('0') }) + it('encodes an exactOutput ETH->DAI->USDC swap', async () => { + const outputUSDC = utils.parseUnits('1000', 6).toString() + const trade = await V4Trade.fromRoute( + new V4Route([ETH_DAI_V4, USDC_DAI_V4], ETHER, USDC), + CurrencyAmount.fromRawAmount(USDC, outputUSDC), + TradeType.EXACT_OUTPUT + ) + + const opts = swapOptions({}) + buildTrade([trade]) + const methodParameters = SwapRouter.swapCallParameters(buildTrade([trade]), opts) + registerFixture('_UNISWAP_V4_ETH_FOR_1000_USDC', methodParameters) + expect(hexToDecimalString(methodParameters.value)).to.not.equal('0') + }) + + it('encodes an exactOutput ETH->DAI->USDC swap that must first unwrap WETH', async () => { const outputUSDC = utils.parseUnits('1000', 6).toString() const trade = await V4Trade.fromRoute( From 276aa21006a2b489ff10c944dfc58194870ce275 Mon Sep 17 00:00:00 2001 From: Emily Williams Date: Thu, 14 Nov 2024 16:24:56 -0500 Subject: [PATCH 22/23] typo --- sdks/universal-router-sdk/src/entities/actions/uniswap.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdks/universal-router-sdk/src/entities/actions/uniswap.ts b/sdks/universal-router-sdk/src/entities/actions/uniswap.ts index 5659b09dd..f00464555 100644 --- a/sdks/universal-router-sdk/src/entities/actions/uniswap.ts +++ b/sdks/universal-router-sdk/src/entities/actions/uniswap.ts @@ -228,7 +228,7 @@ export class UniswapTrade implements Command { } } - // for exactOutput swaps that with native input or perform an inputToken transition (wrap or unwrap) + // for exactOutput swaps with native input or that perform an inputToken transition (wrap or unwrap) // we need to send back the change to the user if (this.trade.tradeType === TradeType.EXACT_OUTPUT || riskOfPartialFill(this.trade)) { if (this.inputRequiresWrap) { From bf5cb50aad05f71cc0aed0a2442fc6d253da937b Mon Sep 17 00:00:00 2001 From: Emily Williams Date: Mon, 18 Nov 2024 14:48:06 -0500 Subject: [PATCH 23/23] lint --- sdks/universal-router-sdk/test/uniswapTrades.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/sdks/universal-router-sdk/test/uniswapTrades.test.ts b/sdks/universal-router-sdk/test/uniswapTrades.test.ts index 296618fba..67f122014 100644 --- a/sdks/universal-router-sdk/test/uniswapTrades.test.ts +++ b/sdks/universal-router-sdk/test/uniswapTrades.test.ts @@ -736,7 +736,6 @@ describe('Uniswap', () => { expect(hexToDecimalString(methodParameters.value)).to.not.equal('0') }) - it('encodes an exactOutput ETH->DAI->USDC swap that must first unwrap WETH', async () => { const outputUSDC = utils.parseUnits('1000', 6).toString() const trade = await V4Trade.fromRoute(