diff --git a/addresses.json b/addresses.json index 60bc828..093e80c 100644 --- a/addresses.json +++ b/addresses.json @@ -3,7 +3,7 @@ "UniswapV2CalleeDai": "0x49399BB0Fcb52b32aB5A0909206BFf7B54FF80b3", "UniswapV2LpTokenCalleeDai": "0x74893C37beACf205507ea794470b13DE06294220", "UniswapV3Callee": "0xdB9C76109d102d2A1E645dCa3a7E671EBfd8e11A", - "WstETHCurveUniv3Callee": "0xC2D837173592194131827775a6Cd88322a98C825", + "WstETHCurveUniv3Callee": "0x21540b2653FeBa52eE2c8714CA7Abfb522bb5e8C", "CurveLpTokenUniv3Callee": "0x71f2198849F3B1372EA90c079BD634928583f2d2" }, "0x5": { diff --git a/src/WstETHCurveUniv3Callee.sol b/src/WstETHCurveUniv3Callee.sol index 150014d..d1fd289 100644 --- a/src/WstETHCurveUniv3Callee.sol +++ b/src/WstETHCurveUniv3Callee.sol @@ -118,9 +118,9 @@ contract WstETHCurveUniv3Callee { address to, // address to send remaining DAI to address gemJoin, // gemJoin adapter address uint256 minProfit, // minimum profit in DAI to make [wad] - uint24 poolFee, // uniswap V3 WETH-DAI pool fee + bytes memory path, // uniswap v3 path address charterManager // pass address(0) if no manager - ) = abi.decode(data, (address, address, uint256, uint24, address)); + ) = abi.decode(data, (address, address, uint256, bytes, address)); address gem = GemJoinLike(gemJoin).gem(); @@ -157,7 +157,6 @@ contract WstETHCurveUniv3Callee { uint256 daiToJoin = _divup(owe, RAY); // Do operation and get dai amount bought (checking the profit is achieved) - bytes memory path = abi.encodePacked(gem, poolFee, address(dai)); UniV3RouterLike.ExactInputParams memory params = UniV3RouterLike.ExactInputParams({ path: path, recipient: address(this), @@ -180,4 +179,3 @@ contract WstETHCurveUniv3Callee { dai.transfer(to, dai.balanceOf(address(this))); } } - diff --git a/src/test/Simulation.t.sol b/src/test/Simulation.t.sol index aed9a91..f85c76e 100644 --- a/src/test/Simulation.t.sol +++ b/src/test/Simulation.t.sol @@ -684,7 +684,8 @@ contract SimulationTests is DSTest { } function testFrobMax() public { - uint256 amountLink = 2_000 * WAD; + (,,,, uint256 dustRad) = vat.ilks(linkName); + uint256 amountLink = (dustRad / getLinkPriceRay()) * 2; getLink(amountLink); joinLink(amountLink); frobMax(amountLink, linkName); @@ -739,7 +740,8 @@ contract SimulationTests is DSTest { } function testBarkLink() public { - uint256 amountLink = 2_000 * WAD; + (,,,, uint256 dustRad) = vat.ilks(linkName); + uint256 amountLink = (dustRad / getLinkPriceRay()) * 2; uint256 kicksPre = linkClip.kicks(); getLink(amountLink); joinLink(amountLink); diff --git a/src/test/WstETHCurveUniv3Callee.t.sol b/src/test/WstETHCurveUniv3Callee.t.sol index 3f36a03..943844b 100644 --- a/src/test/WstETHCurveUniv3Callee.t.sol +++ b/src/test/WstETHCurveUniv3Callee.t.sol @@ -91,11 +91,16 @@ contract CurveCalleeTest is DSTest { WstETHCurveUniv3Callee callee; uint256 tail; address vat; + address weth; + address dai; + address usdc; function setUp() public { clipper = Chainlog(chainlog).getAddress("MCD_CLIP_WSTETH_A"); address daiJoin = Chainlog(chainlog).getAddress("MCD_JOIN_DAI"); - address weth = Chainlog(chainlog).getAddress("ETH"); + weth = Chainlog(chainlog).getAddress("ETH"); + dai = Chainlog(chainlog).getAddress("MCD_DAI"); + usdc = Chainlog(chainlog).getAddress("USDC"); callee = new WstETHCurveUniv3Callee(curve, uniV3, daiJoin, weth); vat = Chainlog(chainlog).getAddress("MCD_VAT"); Vat(vat).hope(clipper); @@ -138,11 +143,12 @@ contract CurveCalleeTest is DSTest { function test_baseline() public { uint256 amt = 50 * WAD; newAuction(amt); + uint24 poolFee = 3000; bytes memory data = abi.encode( address(123), address(gemJoin), uint256(0), - uint24(3000), + abi.encodePacked(weth, poolFee, dai), address(0) ); Hevm(hevm).warp(block.timestamp + tail / 2); @@ -153,28 +159,29 @@ contract CurveCalleeTest is DSTest { who: address(callee), data: data }); - address dai = Chainlog(chainlog).getAddress("MCD_DAI"); assertEq(Token(dai).balanceOf(address(this)), 0); assertEq(Token(wstEth).balanceOf(address(this)), 0); } - function test_bigAmt() public { + function test_bigAmtWithComplexPath() public { uint256 amt = 3000 * WAD; newAuction(amt); + uint24 poolAFee = 500; + uint24 poolBFee = 100; bytes memory data = abi.encode( address(this), address(gemJoin), uint256(0), - uint24(3000), + abi.encodePacked(weth, poolAFee, usdc, poolBFee, dai), address(0) ); Hevm(hevm).warp(block.timestamp + tail / 2); Clipper(clipper).take({ - id: id, - amt: amt, - max: type(uint256).max, - who: address(callee), - data: data + id: id, + amt: amt, + max: type(uint256).max, + who: address(callee), + data: data }); } @@ -182,11 +189,12 @@ contract CurveCalleeTest is DSTest { uint256 minProfit = 10_000 * WAD; uint256 amt = 50 * WAD; newAuction(amt); + uint24 poolFee = 3000; bytes memory data = abi.encode( address(123), address(gemJoin), uint256(minProfit), - uint24(3000), + abi.encodePacked(weth, poolFee, dai), address(0) ); Hevm(hevm).warp(block.timestamp + tail / 2); @@ -197,7 +205,6 @@ contract CurveCalleeTest is DSTest { who: address(callee), data: data }); - address dai = Chainlog(chainlog).getAddress("MCD_DAI"); assertGe(Token(dai).balanceOf(address(123)), minProfit); } @@ -209,7 +216,7 @@ contract CurveCalleeTest is DSTest { address(this), address(gemJoin), uint256(0), - poolFee, + abi.encodePacked(weth, poolFee, dai), address(0) ); Hevm(hevm).warp(block.timestamp + tail / 2); @@ -230,7 +237,7 @@ contract CurveCalleeTest is DSTest { address(this), address(gemJoin), uint256(0), - poolFee, + abi.encodePacked(weth, poolFee, dai), address(0) ); Hevm(hevm).warp(block.timestamp + tail / 2); @@ -246,11 +253,12 @@ contract CurveCalleeTest is DSTest { function test_maxPrice() public { uint256 amt = 50 * WAD; newAuction(amt); + uint24 poolFee = 3000; bytes memory data = abi.encode( address(this), address(gemJoin), uint256(0), - uint24(3000), + abi.encodePacked(weth, poolFee, dai), address(0) ); Hevm(hevm).warp(block.timestamp + tail / 2); @@ -274,11 +282,12 @@ contract CurveCalleeTest is DSTest { function testFail_maxPrice() public { uint256 amt = 50 * WAD; newAuction(amt); + uint24 poolFee = 3000; bytes memory data = abi.encode( address(this), address(gemJoin), uint256(0), - uint24(3000), + abi.encodePacked(weth, poolFee, dai), address(0) ); Hevm(hevm).warp(block.timestamp + tail / 5);