uniswap execution fixes, logs, and tests

This commit is contained in:
Tim Olson
2023-10-27 16:07:02 -04:00
parent 73ab4fb0e0
commit e1eecad898
3 changed files with 47 additions and 8 deletions

View File

@@ -47,7 +47,29 @@ contract TestOrder is MockEnv, Test {
vault.placeOrder(order);
}
function testExecuteOrder() public {
function testExecuteOrderExactOutput() public {
OrderLib.Tranche[] memory tranches = new OrderLib.Tranche[](1);
OrderLib.Constraint[] memory constraints1 = new OrderLib.Constraint[](1);
constraints1[0] = OrderLib.Constraint(OrderLib.ConstraintMode.Time, bytes(hex"0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000046500"));
tranches[0] = OrderLib.Tranche(type(uint16).max,constraints1);
uint256 amount = 3*10**USD.decimals() / 10; // 0.3 USD
COIN.mint(address(vault), amount); // create COIN to sell
OrderLib.SwapOrder memory order = OrderLib.SwapOrder(
address(COIN), address(USD), // sell COIN for USD
OrderLib.Route(OrderLib.Exchange.UniswapV3, 500), amount, false, false,
OrderLib.NO_CHAIN, tranches
);
uint64 orderIndex = vault.numSwapOrders();
vault.placeOrder(order);
console2.log('placed order');
console2.log(uint(orderIndex));
string memory result;
vault.execute(orderIndex, 0, OrderLib.PriceProof(0));
console2.log('executed');
}
function testExecuteOrderExactInput() public {
OrderLib.Tranche[] memory tranches = new OrderLib.Tranche[](1);
OrderLib.Constraint[] memory constraints1 = new OrderLib.Constraint[](1);
constraints1[0] = OrderLib.Constraint(OrderLib.ConstraintMode.Time, bytes(hex"0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000046500"));