Skip to content

Commit ec04b39

Browse files
committed
add asyncfiller to hook
1 parent 01b54ed commit ec04b39

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/AsyncSwapCSMM.sol

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Algorithm2 } from "@async-swap/algorithms/algorithm-2.sol";
55
import { IAlgorithm } from "@async-swap/interfaces/IAlgorithm.sol";
66
import { IAsyncSwapAMM, IAsyncSwapOrder } from "@async-swap/interfaces/IAsyncSwapAMM.sol";
77
import { IRouter } from "@async-swap/interfaces/IRouter.sol";
8+
import { AsyncFiller } from "@async-swap/libraries/AsyncFiller.sol";
89
import { AsyncOrder } from "@async-swap/types/AsyncOrder.sol";
910
import { CurrencySettler } from "@uniswap/v4-core/test/utils/CurrencySettler.sol";
1011
import { IPoolManager } from "v4-core/interfaces/IPoolManager.sol";
@@ -30,6 +31,7 @@ contract AsyncSwapCSMM is BaseHook, IAsyncSwapAMM {
3031
IAlgorithm public algorithm;
3132
/// @notice Mapping to store async orders.
3233
mapping(PoolId poolId => mapping(address user => mapping(bool zeroForOne => uint256 claimable))) public asyncOrders;
34+
// mapping(PoolId poolId => AsyncFiller.State) public asyncOrders;
3335
/// @notice Mapping to store executor permissions for users.
3436
mapping(address owner => mapping(address executor => bool)) public setExecutor;
3537

@@ -40,6 +42,7 @@ contract AsyncSwapCSMM is BaseHook, IAsyncSwapAMM {
4042
/// @param amount1 The amount of currency1 taken in the swap (negative for exact input).
4143
/// @param hookLPfeeAmount0 Fee amount taken for LP in currency0.
4244
/// @param hookLPfeeAmount1 Fee amount taken for LP in currency1.
45+
4346
event HookSwap(
4447
bytes32 indexed id,
4548
address indexed sender,
@@ -77,7 +80,7 @@ contract AsyncSwapCSMM is BaseHook, IAsyncSwapAMM {
7780
afterSwap: false,
7881
beforeDonate: false,
7982
afterDonate: false,
80-
beforeSwapReturnDelta: true, // allow beforeSwap to return a custom delta, for custom ordering
83+
beforeSwapReturnDelta: true, // need must for async
8184
afterSwapReturnDelta: false,
8285
afterAddLiquidityReturnDelta: false,
8386
afterRemoveLiquidityReturnDelta: false
@@ -104,6 +107,8 @@ contract AsyncSwapCSMM is BaseHook, IAsyncSwapAMM {
104107
}
105108

106109
function calculatePoolFee(uint24, uint256) public pure returns (uint256) {
110+
/// TODO: check for dynamic fees
111+
/// TODO: Read from the state slot
107112
return 0;
108113
}
109114

@@ -128,7 +133,9 @@ contract AsyncSwapCSMM is BaseHook, IAsyncSwapAMM {
128133

129134
if (amountIn == 0) revert ZeroFillOrder();
130135

136+
/// TODO: Document what this does
131137
uint256 amountToFill = uint256(amountIn);
138+
// AsyncFiller.State storage _asyncOrders = asyncOrders[poolId];
132139
uint256 claimableAmount = asyncOrders[poolId][owner][zeroForOne];
133140
require(amountToFill <= claimableAmount, "Max fill order limit exceed");
134141
require(isExecutor(owner, msg.sender), "Caller is valid not excutor");
@@ -145,6 +152,7 @@ contract AsyncSwapCSMM is BaseHook, IAsyncSwapAMM {
145152
}
146153

147154
asyncOrders[poolId][owner][zeroForOne] -= amountToFill;
155+
/// TODO: check if this is needed, we could just burn
148156
poolManager.transfer(owner, currencyTake.toId(), amountToFill);
149157
emit AsyncOrderFilled(poolId, owner, zeroForOne, amountToFill);
150158

0 commit comments

Comments
 (0)