order placement doesnt crash
This commit is contained in:
@@ -37,8 +37,10 @@ contract MockEnv {
|
||||
token0 = inverted ? address(USD) : address(COIN);
|
||||
token1 = inverted ? address(COIN) : address(USD);
|
||||
uint160 initialPrice = uint160(79228162514264337593543); // price 1e-12 = sqrt price 1e-6 = 2**96 / 10**6
|
||||
console2.log('if this is the last line before a revert then make sure to run forge with --rpc-url');
|
||||
// if this reverts here make sure Anvil is started and you are running forge with --rpc-url
|
||||
pool = IUniswapV3Pool(nfpm.createAndInitializePoolIfNecessary(token0, token1, fee, initialPrice));
|
||||
console2.log('created v3 pool successfully');
|
||||
int24 ts = pool.tickSpacing();
|
||||
(, int24 lower, , , , ,) = pool.slot0();
|
||||
int24 upper = lower;
|
||||
|
||||
@@ -4,7 +4,9 @@ pragma abicoder v2;
|
||||
|
||||
import "./MockEnv.sol";
|
||||
import "forge-std/Test.sol";
|
||||
import "forge-std/console2.sol";
|
||||
import "../src/Factory.sol";
|
||||
import "../src/OrderLib.sol";
|
||||
|
||||
contract TestOrder is MockEnv, Test {
|
||||
Factory public factory;
|
||||
@@ -23,7 +25,23 @@ contract TestOrder is MockEnv, Test {
|
||||
|
||||
|
||||
function testOrder() public {
|
||||
|
||||
OrderLib.Tranche[] memory tranches = new OrderLib.Tranche[](3);
|
||||
OrderLib.Constraint[] memory constraints1 = new OrderLib.Constraint[](1);
|
||||
constraints1[0] = OrderLib.Constraint(OrderLib.ConstraintMode.Time, bytes(hex"0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000046500"));
|
||||
OrderLib.Constraint[] memory constraints2 = new OrderLib.Constraint[](1);
|
||||
constraints2[0] = OrderLib.Constraint(OrderLib.ConstraintMode.Time, bytes(hex"000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000464fb0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000008c9fb"));
|
||||
OrderLib.Constraint[] memory constraints3 = new OrderLib.Constraint[](1);
|
||||
constraints3[0] = OrderLib.Constraint(OrderLib.ConstraintMode.Time, bytes(hex"0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000008c9f6000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000d2ef6"));
|
||||
tranches[0] = OrderLib.Tranche(21845,constraints1);
|
||||
tranches[1] = OrderLib.Tranche(21845,constraints2);
|
||||
tranches[2] = OrderLib.Tranche(21845,constraints3);
|
||||
OrderLib.SwapOrder memory order = OrderLib.SwapOrder(
|
||||
0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9, 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1,
|
||||
OrderLib.Route(OrderLib.Exchange.UniswapV3, 500), 100000000000000000000, true, false,
|
||||
18446744073709551615, tranches
|
||||
);
|
||||
console2.logBytes(abi.encode(order));
|
||||
vault.placeOrder(order);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user