Skip to content

Commit

Permalink
wip tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Siddharth2207 committed Feb 21, 2024
1 parent ccd330b commit 4f106ae
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 20 deletions.
2 changes: 1 addition & 1 deletion lib/h20.pubstrats
26 changes: 14 additions & 12 deletions src/TrancheMirror.sol
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function uint2str(uint256 _i) pure returns (string memory _uintAsString) {
library LibTrancheSpreadOrders {
using Strings for address;

function getTrancheSpreadBuyOrder(Vm vm, address orderBookSubparser, address uniswapWords)
function getTrancheSpreadBuyOrder(Vm vm, address orderBookSubparser)
internal
returns (bytes memory trancheRefill)
{
Expand All @@ -91,27 +91,29 @@ library LibTrancheSpreadOrders {
ffi[11] = "--bind";
ffi[12] = "reserve-token=0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270";
ffi[13] = "--bind";
ffi[14] = string.concat("tranche-reserve-amount-base=", uint2str(1e18));
ffi[14] = "get-tranche-space='get-real-tranche-space";
ffi[15] = "--bind";
ffi[16] = string.concat("tranche-reserve-io-ratio-base=", uint2str(111e16));
ffi[16] = "set-tranche-space='set-real-tranche-space";
ffi[17] = "--bind";
ffi[18] = string.concat("spread-ratio=", uint2str(101e16));
ffi[18] = "tranche-reserve-amount-growth='tranche-reserve-amount-growth-constant";
ffi[19] = "--bind";
ffi[20] = string.concat("tranche-space-edge-guard-threshold=", uint2str(1e16));
ffi[20] = string.concat("tranche-reserve-amount-base=", uint2str(1e18));
ffi[21] = "--bind";
ffi[22] = "get-tranche-space='get-real-tranche-space";
ffi[22] = "tranche-reserve-io-ratio-growth='tranche-reserve-io-ratio-linear";
ffi[23] = "--bind";
ffi[24] = "set-tranche-space='set-real-tranche-space";
ffi[24] = string.concat("tranche-reserve-io-ratio-base=", uint2str(111e16));
ffi[25] = "--bind";
ffi[26] = "tranche-reserve-amount-growth='tranche-reserve-amount-growth-constant";
ffi[26] = string.concat("spread-ratio=", uint2str(101e16));
ffi[27] = "--bind";
ffi[28] = "tranche-reserve-io-ratio-growth='tranche-reserve-io-ratio-linear";
trancheRefill = bytes.concat(getSubparserPrelude(orderBookSubparser, uniswapWords), vm.ffi(ffi));
ffi[28] = string.concat("tranche-space-edge-guard-threshold=", uint2str(1e16));


trancheRefill = bytes.concat(getSubparserPrelude(orderBookSubparser), vm.ffi(ffi));
}

function getSubparserPrelude(address obSubparser, address uniswapWords) internal pure returns (bytes memory) {
function getSubparserPrelude(address obSubparser) internal pure returns (bytes memory) {
bytes memory RAINSTRING_OB_SUBPARSER =
bytes(string.concat("using-words-from ", obSubparser.toHexString(), " ", uniswapWords.toHexString(), " "));
bytes(string.concat("using-words-from ", obSubparser.toHexString(), " "));
return RAINSTRING_OB_SUBPARSER;
}
}
Expand Down
1 change: 0 additions & 1 deletion src/abstract/RainContracts.sol
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ abstract contract RainContracts {

function deployOrderBook() public {
ORDERBOOK = new OrderBook();
ORDERBOOK_SUPARSER = new OrderBookSubParser();
}

function deployOrderBookSubparser() public {
Expand Down
23 changes: 21 additions & 2 deletions test/TrancheMirrorTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,32 @@ import "src/TrancheMirror.sol";
contract TrancheMirrorTest is TrancheMirrorUtils {

function testParseOrder() public {
console2.log("PARSER : ",address(PARSER));
console2.log("INTERPRETER : ",address(INTERPRETER));
console2.log("STORE : ",address(STORE));
console2.log("EXPRESSION_DEPLOYER : ",address(EXPRESSION_DEPLOYER));
console2.log("ORDERBOOK_SUPARSER : ",address(ORDERBOOK_SUPARSER));


PARSER.parse(
LibTrancheSpreadOrders.getTrancheSpreadBuyOrder(
vm,
address(ORDERBOOK_SUPARSER),
address(UNISWAP_WORDS)
address(ORDERBOOK_SUPARSER)
)
);
}

function testParseOrderRainlang() public {
console2.log("PARSER : ",address(PARSER));
console2.log("INTERPRETER : ",address(INTERPRETER));
console2.log("STORE : ",address(STORE));
console2.log("EXPRESSION_DEPLOYER : ",address(EXPRESSION_DEPLOYER));
console2.log("ORDERBOOK_SUPARSER : ",address(ORDERBOOK_SUPARSER));

bytes memory rainlang = "_: decimal18-saturating-sub(1e18 2e18);";
PARSER.parse(
rainlang
);
}
}

8 changes: 4 additions & 4 deletions test/util/TrancheMirrorUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ contract TrancheMirrorUtils is RainContracts, Test {

deployExpressionDeployer(vm, address(INTERPRETER), address(STORE), address(PARSER));
deployOrderBookSubparser();
deployUniswapWords(vm);

// PARSER = IParserV1(0xc2D7890077F3EA75c2798D8624E1E0E6ef8C41e6);
deployUniswapWords(vm);
// PARSER = IParserV1(0xc2D7890077F3EA75c2798D8624E1E0E6ef8C41e6);
// INTERPRETER = IInterpreterV2(0xB7d691B7E3676cb70dB0cDae95797F24Eab6980D);
// STORE = IInterpreterStoreV2(0x0b5a2b0aCFc5B52bf341FAD638B63C9A6f82dcb9);
// EXPRESSION_DEPLOYER = IExpressionDeployerV3(0xE1E250a234aF6F343062873bf89c9D1a0a659c0b);
Expand All @@ -59,7 +59,7 @@ contract TrancheMirrorUtils is RainContracts, Test {
ORDERBOOK = IOrderBookV3(0xDE5aBE2837bc042397D80E37fb7b2C850a8d5a6C);
ARB_IMPLEMENTATION = IOrderBookV3ArbOrderTaker(0x8F29083140559bd1771eDBfB73656A9f676c00Fd);
ARB_INSTANCE = IOrderBookV3ArbOrderTaker(0x0D7896d70FE84e88CC8e8BaDcB14D612Eee4Bbe0);
CLONE_FACTORY = ICloneableFactoryV2(0x6d0c39093C21dA1230aCDD911420BBfA353A3FBA);
CLONE_FACTORY = ICloneableFactoryV2(0x6d0c39093C21dA1230aCDD911420BBfA353A3FBA);
}

}

0 comments on commit 4f106ae

Please sign in to comment.