From e0cbe981183b31d9588861e346d883c758df92e3 Mon Sep 17 00:00:00 2001 From: Siddharth2207 Date: Tue, 12 Mar 2024 15:47:23 +0530 Subject: [PATCH] rp3.2 --- lib/h20.pubstrats | 2 +- src/TrancheMirror.sol | 61 +++++++------------------------- test/TrancheMirrorTest.t.sol | 8 ++--- test/util/TrancheMirrorUtils.sol | 12 +++---- 4 files changed, 23 insertions(+), 60 deletions(-) diff --git a/lib/h20.pubstrats b/lib/h20.pubstrats index 955bd6c..4d75dba 160000 --- a/lib/h20.pubstrats +++ b/lib/h20.pubstrats @@ -1 +1 @@ -Subproject commit 955bd6ce6f36d444b0347b59f3bf60e97104f882 +Subproject commit 4d75dbad007907064500934d4a0f00039b8c7af0 diff --git a/src/TrancheMirror.sol b/src/TrancheMirror.sol index c76a85a..2d52cd2 100644 --- a/src/TrancheMirror.sol +++ b/src/TrancheMirror.sol @@ -23,8 +23,8 @@ uint256 constant INITIAL_TRANCHE_SPACE = 0; uint256 constant TRANCHE_SPACE_SNAP_THRESHOLD = 1e12; -/// @dev https://polygonscan.com/address/0x0a6e511Fe663827b9cA7e2D2542b20B37fC217A6 -IRouteProcessor constant ROUTE_PROCESSOR = IRouteProcessor(address(0x0a6e511Fe663827b9cA7e2D2542b20B37fC217A6)); +/// @dev https://polygonscan.com/address/0xE7eb31f23A5BefEEFf76dbD2ED6AdC822568a5d2 +IRouteProcessor constant ROUTE_PROCESSOR = IRouteProcessor(address(0xE7eb31f23A5BefEEFf76dbD2ED6AdC822568a5d2)); uint256 constant VAULT_ID = uint256(keccak256("vault")); @@ -53,54 +53,17 @@ IERC20 constant WETH_TOKEN = IERC20(0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270); /// @dev https://docs.sushi.com/docs/Products/Classic%20AMM/Deployment%20Addresses address constant POLYGON_SUSHI_V2_ROUTER = 0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506; -bytes constant SELL_ROUTE = - //offset - hex"0000000000000000000000000000000000000000000000000000000000000020" - //stream length - hex"0000000000000000000000000000000000000000000000000000000000000042" - //command 2 = processUserERC20 - hex"02" - //token address - hex"d0e9c8f5fae381459cf07ec506c1d2896e8b5df6" - //number of pools - hex"01" - // pool share - hex"ffff" - // pool type - hex"00" - // pool address - hex"316bc12871c807020ef8c1bc7771061c4e7a04ed" - // direction 1 - hex"00" - // to - hex"0D7896d70FE84e88CC8e8BaDcB14D612Eee4Bbe0" - // padding - hex"000000000000000000000000000000000000000000000000000000000000"; - -bytes constant BUY_ROUTE = - //offset - hex"0000000000000000000000000000000000000000000000000000000000000020" - //stream length - hex"0000000000000000000000000000000000000000000000000000000000000042" - //command 2 = processUserERC20 - hex"02" - //token address - hex"0d500b1d8e8ef31e21c99d1db9a6444d3adf1270" - //number of pools - hex"01" - // pool share - hex"ffff" - // pool type - hex"00" - // pool address - hex"316bc12871c807020ef8c1bc7771061c4e7a04ed" - // direction 1 - hex"01" - // to - hex"0D7896d70FE84e88CC8e8BaDcB14D612Eee4Bbe0" - // padding - hex"000000000000000000000000000000000000000000000000000000000000"; +function getUniV3TradeSellRoute(address toAddress) pure returns (bytes memory){ + bytes memory ROUTE_PRELUDE = + hex"02d0e9c8f5fae381459cf07ec506c1d2896e8b5df601ffff00316bc12871c807020ef8c1bc7771061c4e7a04ed00"; + return abi.encode(bytes.concat(ROUTE_PRELUDE, abi.encodePacked(toAddress))); +} +function getUniV3TradeBuyRoute(address toAddress) pure returns (bytes memory){ + bytes memory ROUTE_PRELUDE = + hex"020d500b1d8e8ef31e21c99d1db9a6444d3adf127001ffff00316bc12871c807020ef8c1bc7771061c4e7a04ed01"; + return abi.encode(bytes.concat(ROUTE_PRELUDE, abi.encodePacked(toAddress))); +} function polygonIeonIo() pure returns (IO memory) { return IO(address(IEON_TOKEN), 18, VAULT_ID); diff --git a/test/TrancheMirrorTest.t.sol b/test/TrancheMirrorTest.t.sol index 1a57d96..4bfc986 100644 --- a/test/TrancheMirrorTest.t.sol +++ b/test/TrancheMirrorTest.t.sol @@ -50,10 +50,10 @@ contract TrancheMirrorTest is TrancheMirrorUtils { address(IEON_TOKEN), POLYGON_WETH_HOLDER, 1000e18, - BUY_ROUTE + getUniV3TradeBuyRoute(address(ARB_INSTANCE)) ); vm.recordLogs(); - takeOrder(trancheOrder, SELL_ROUTE,1,0); + takeOrder(trancheOrder, getUniV3TradeSellRoute(address(ARB_INSTANCE)),1,0); Vm.Log[] memory entries = vm.getRecordedLogs(); (,distributorTokenOut) = getContextInputOutput(entries); @@ -66,10 +66,10 @@ contract TrancheMirrorTest is TrancheMirrorUtils { address(WETH_TOKEN), POLYGON_IEON_HOLDER, 10000000e18, - SELL_ROUTE + getUniV3TradeSellRoute(address(ARB_INSTANCE)) ); vm.recordLogs(); - takeOrder(trancheOrder, BUY_ROUTE,0,1); + takeOrder(trancheOrder, getUniV3TradeBuyRoute(address(ARB_INSTANCE)),0,1); Vm.Log[] memory entries = vm.getRecordedLogs(); (distributorTokenIn,) = getContextInputOutput(entries); diff --git a/test/util/TrancheMirrorUtils.sol b/test/util/TrancheMirrorUtils.sol index 519317d..5e36900 100644 --- a/test/util/TrancheMirrorUtils.sol +++ b/test/util/TrancheMirrorUtils.sol @@ -21,7 +21,7 @@ contract TrancheMirrorUtils is RainContracts, Test { using LibFixedPointDecimalArithmeticOpenZeppelin for uint256; using LibFixedPointDecimalScale for uint256; - uint256 constant FORK_BLOCK_NUMBER = 54561421; + uint256 constant FORK_BLOCK_NUMBER = 54565408; uint256 constant CONTEXT_VAULT_IO_ROWS = 5; function selectPolygonFork() internal { @@ -41,15 +41,15 @@ contract TrancheMirrorUtils is RainContracts, Test { function setUp() public { selectPolygonFork(); - PARSER = IParserV1(0xbe7eF1c2E86cd36642Be685715a089ecc1a15f5C); - STORE = IInterpreterStoreV2(0xCCe6D0653B6DAC3B5fAd3F2A8E47cCE537126aD0); - INTERPRETER = IInterpreterV2(0x8bb0e1Ade233f386668f6e3c11762f18bF8293b3); - EXPRESSION_DEPLOYER = IExpressionDeployerV3(0xB16bbF12ECE3414af72F660aB63F4dDa1D7250FA); + PARSER = IParserV1(0x42354C16c8FcFf044c5ee73798F250138ef0A813); + STORE = IInterpreterStoreV2(0x9Ba76481F8cF7F52e440B13981e0003De474A9f7); + INTERPRETER = IInterpreterV2(0xbbe5a04A9a20c47b1A93e755aE712cb84538cd5a); + EXPRESSION_DEPLOYER = IExpressionDeployerV3(0xc64B01aB4b5549dE91e5A4425883Dff87Ceaaf29); ORDERBOOK_SUPARSER = ISubParserV2(0x14c5D39dE54D498aFD3C803D3B5c88bbEcadcc48); ORDERBOOK = IOrderBookV3(0xDE5aBE2837bc042397D80E37fb7b2C850a8d5a6C); ARB_IMPLEMENTATION = IOrderBookV3ArbOrderTaker(0x8F29083140559bd1771eDBfB73656A9f676c00Fd); - ARB_INSTANCE = IOrderBookV3ArbOrderTaker(0x0D7896d70FE84e88CC8e8BaDcB14D612Eee4Bbe0); + ARB_INSTANCE = IOrderBookV3ArbOrderTaker(0x9571FAcfdeAb981E039aAb30aD3B222709F5cfB4); CLONE_FACTORY = ICloneableFactoryV2(0x6d0c39093C21dA1230aCDD911420BBfA353A3FBA); }