Skip to content

Commit

Permalink
rp3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Siddharth2207 committed Mar 12, 2024
1 parent 5212420 commit e0cbe98
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 60 deletions.
2 changes: 1 addition & 1 deletion lib/h20.pubstrats
61 changes: 12 additions & 49 deletions src/TrancheMirror.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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"));

Expand Down Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions test/TrancheMirrorTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
12 changes: 6 additions & 6 deletions test/util/TrancheMirrorUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
}

Expand Down

0 comments on commit e0cbe98

Please sign in to comment.