@@ -8,7 +8,6 @@ import { AsyncFiller } from "@async-swap/libraries/AsyncFiller.sol";
88import { AsyncOrder } from "@async-swap/types/AsyncOrder.sol " ;
99import { CurrencySettler } from "@uniswap/v4-core/test/utils/CurrencySettler.sol " ;
1010import { IPoolManager } from "v4-core/interfaces/IPoolManager.sol " ;
11- import { IERC20Minimal } from "v4-core/interfaces/external/IERC20Minimal.sol " ;
1211import { Hooks } from "v4-core/libraries/Hooks.sol " ;
1312import { LPFeeLibrary } from "v4-core/libraries/LPFeeLibrary.sol " ;
1413import { SafeCast } from "v4-core/libraries/SafeCast.sol " ;
@@ -51,6 +50,7 @@ contract AsyncSwap is BaseHook, IAsyncSwapAMM {
5150
5251 /// @notice Error thrown when liquidity is not supported in this hook.
5352 error UnsupportedLiquidity ();
53+ error OrderExpired ();
5454
5555 /// Initializes the Async Swap Hook contract with the PoolManager address and sets an transaction ordering algorithm.
5656 /// @param poolManager The address of the PoolManager contract.
@@ -122,7 +122,7 @@ contract AsyncSwap is BaseHook, IAsyncSwapAMM {
122122 /// Sort poolIDs
123123 /// Order swaps by poolId
124124
125- uint256 volatility = ALGORITHM.getVolatility (orders);
125+ // uint256 volatility = ALGORITHM.getVolatility(orders);
126126 for (uint8 i = 0 ; i < orders.length ; i++ ) {
127127 AsyncOrder calldata order = orders[i];
128128 // Use transaction ordering algorithm to ensure correct execution order
@@ -140,15 +140,16 @@ contract AsyncSwap is BaseHook, IAsyncSwapAMM {
140140 Currency currency1 = order.key.currency1;
141141 PoolId poolId = order.key.toId ();
142142 address filler = abi.decode (fillerData, (address ));
143-
143+ uint256 deadline = order.deadline;
144+ if (block .timestamp > deadline) revert OrderExpired ();
145+ AsyncFiller.State storage state = asyncOrders[poolId];
146+ require (order.isExecutor (state, msg .sender ), "Caller is valid not executor " );
144147 if (amountIn == 0 ) revert ZeroFillOrder ();
145148
146149 /// TODO: Document what this does
147150 uint256 amountToFill = uint256 (amountIn);
148151 uint256 claimableAmount = asyncOrders[poolId].asyncOrderAmount[owner][zeroForOne];
149152 require (amountToFill <= claimableAmount, "Max fill order limit exceed " );
150- AsyncFiller.State storage state = asyncOrders[poolId];
151- require (order.isExecutor (state, msg .sender ), "Caller is valid not excutor " );
152153
153154 /// @dev Transfer currency of async order to user
154155 Currency currencyTake;
@@ -164,7 +165,7 @@ contract AsyncSwap is BaseHook, IAsyncSwapAMM {
164165 asyncOrders[poolId].asyncOrderAmount[owner][zeroForOne] -= amountToFill;
165166 /// we could also burn
166167 poolManager.transfer (filler, currencyTake.toId (), amountToFill);
167- emit AsyncOrderFilled (poolId, owner, zeroForOne, amountToFill);
168+ emit AsyncOrderFilled (poolId, owner, zeroForOne, amountToFill, deadline );
168169
169170 /// @dev Take currencyFill from filler
170171 /// @dev Hook may charge filler a hook fee
0 commit comments