Skip to content

Commit 7df33d8

Browse files
committed
fix unused imports and updated names
1 parent 40c91a0 commit 7df33d8

File tree

4 files changed

+15
-26
lines changed

4 files changed

+15
-26
lines changed

src/router.sol

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@ import { IAsyncSwapAMM } from "@async-swap/interfaces/IAsyncSwapAMM.sol";
55
import { IRouter } from "@async-swap/interfaces/IRouter.sol";
66
import { AsyncOrder } from "@async-swap/types/AsyncOrder.sol";
77
import { CurrencySettler } from "@uniswap/v4-core/test/utils/CurrencySettler.sol";
8-
import { console } from "forge-std/Test.sol";
98
import { IPoolManager } from "v4-core/interfaces/IPoolManager.sol";
109
import { IERC20Minimal } from "v4-core/interfaces/external/IERC20Minimal.sol";
1110
import { SafeCast } from "v4-core/libraries/SafeCast.sol";
1211
import { Currency, CurrencyLibrary } from "v4-core/types/Currency.sol";
13-
import { PoolKey } from "v4-core/types/PoolKey.sol";
1412

1513
/// @title Router Contract
1614
/// @author Async Labs
@@ -23,9 +21,9 @@ contract Router is IRouter {
2321
using SafeCast for *;
2422

2523
/// PoolManager contract to interact with the pools.
26-
IPoolManager immutable poolManager;
24+
IPoolManager immutable POOLMANAGER;
2725
/// Async Swap Hook contract to execute async orders.
28-
IAsyncSwapAMM immutable hook;
26+
IAsyncSwapAMM immutable HOOK;
2927

3028
/// keccak256("Router.ActionType") - 1
3129
bytes32 constant ACTION_LOCATION = 0xf3b150ebf41dad0872df6788629edb438733cb4a5c9ea779b1b1f3614faffc69;
@@ -38,13 +36,13 @@ contract Router is IRouter {
3836
/// @param _poolManager The PoolManager contract that manages the pools.
3937
/// @param _hook The Async CSMM hook contract that executes async orders.
4038
constructor(IPoolManager _poolManager, IAsyncSwapAMM _hook) {
41-
poolManager = _poolManager;
42-
hook = _hook;
39+
POOLMANAGER = _poolManager;
40+
HOOK = _hook;
4341
}
4442

4543
/// Only allow the PoolManager to call certain functions.
4644
modifier onlyPoolManager() {
47-
require(msg.sender == address(poolManager));
45+
require(msg.sender == address(POOLMANAGER));
4846
_;
4947
}
5048

@@ -58,7 +56,7 @@ contract Router is IRouter {
5856
tstore(ASYNC_FILLER_LOCATION, onBehalf)
5957
}
6058

61-
poolManager.unlock(abi.encode(SwapCallback(ActionType.Swap, order)));
59+
POOLMANAGER.unlock(abi.encode(SwapCallback(ActionType.Swap, order)));
6260
}
6361

6462
/// @inheritdoc IRouter
@@ -70,7 +68,7 @@ contract Router is IRouter {
7068
tstore(ASYNC_FILLER_LOCATION, onBehalf)
7169
}
7270

73-
poolManager.unlock(abi.encode(SwapCallback(ActionType.FillOrder, order)));
71+
POOLMANAGER.unlock(abi.encode(SwapCallback(ActionType.FillOrder, order)));
7472
}
7573

7674
/// Callback handler to unlock the PoolManager after a swap or fill order.
@@ -93,15 +91,15 @@ contract Router is IRouter {
9391
if (action == 0) {
9492
SwapCallback memory orderData = abi.decode(data, (SwapCallback));
9593

96-
poolManager.swap(
94+
POOLMANAGER.swap(
9795
orderData.order.key,
9896
IPoolManager.SwapParams(
9997
orderData.order.zeroForOne, -orderData.order.amountIn.toInt256(), orderData.order.sqrtPrice
10098
),
10199
abi.encode(user, asyncFiller)
102100
);
103101
Currency specified = orderData.order.zeroForOne ? orderData.order.key.currency0 : orderData.order.key.currency1;
104-
specified.settle(poolManager, user, orderData.order.amountIn, false); // transfer
102+
specified.settle(POOLMANAGER, user, orderData.order.amountIn, false); // transfer
105103
}
106104

107105
/// @notice Handle Async Order Fill
@@ -110,8 +108,8 @@ contract Router is IRouter {
110108
SwapCallback memory orderData = abi.decode(data, (SwapCallback));
111109
Currency currency = orderData.order.zeroForOne ? orderData.order.key.currency1 : orderData.order.key.currency0;
112110
assert(IERC20Minimal(Currency.unwrap(currency)).transferFrom(user, asyncFiller, orderData.order.amountIn));
113-
assert(IERC20Minimal(Currency.unwrap(currency)).approve(address(hook), orderData.order.amountIn));
114-
hook.executeOrder(orderData.order, abi.encode(asyncFiller));
111+
assert(IERC20Minimal(Currency.unwrap(currency)).approve(address(HOOK), orderData.order.amountIn));
112+
HOOK.executeOrder(orderData.order, abi.encode(asyncFiller));
115113
}
116114

117115
return "";

test/Algorithm2Test.t.sol

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,15 @@
22
pragma solidity ^0.8.13;
33

44
import { SetupHook } from "./SetupHook.sol";
5-
import { Algorithm2 } from "@async-swap/algorithms/algorithm-2.sol";
65
import { IAlgorithm } from "@async-swap/interfaces/IAlgorithm.sol";
7-
import "forge-std/Test.sol";
86

97
contract Algorithm2Test is SetupHook {
108

119
IAlgorithm algorithm;
1210

1311
function setUp() public override {
1412
super.setUp();
15-
algorithm = hook.algorithm();
13+
algorithm = hook.ALGORITHM();
1614
}
1715

1816
/// this should test the intialized algoritm was selected

test/AsyncSwap.t.sol

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,14 @@
22
pragma solidity ^0.8.13;
33

44
import { SetupHook } from "./SetupHook.sol";
5-
import { AsyncSwap } from "@async-swap/AsyncSwap.sol";
6-
import { IRouter } from "@async-swap/interfaces/IRouter.sol";
7-
import { AsyncFiller } from "@async-swap/libraries/AsyncFiller.sol";
85
import { AsyncOrder } from "@async-swap/types/AsyncOrder.sol";
9-
import { console } from "forge-std/Test.sol";
10-
import { Currency, IHooks, IPoolManager } from "v4-core/interfaces/IPoolManager.sol";
11-
import { PoolSwapTest } from "v4-core/test/PoolSwapTest.sol";
6+
import { Currency } from "v4-core/interfaces/IPoolManager.sol";
127
import { CurrencyLibrary } from "v4-core/types/Currency.sol";
13-
import { PoolKey } from "v4-core/types/PoolKey.sol";
148

159
/// @title Async Swap test contract
1610
contract AsyncSwapTest is SetupHook {
1711

1812
using CurrencyLibrary for Currency;
19-
using AsyncFiller for AsyncOrder;
2013

2114
address asyncFiller = makeAddr("asyncFiller");
2215
address user = makeAddr("user");

test/SetupHook.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ pragma solidity ^0.8.13;
33

44
import { AsyncSwap } from "@async-swap/AsyncSwap.sol";
55
import { Router } from "@async-swap/router.sol";
6-
import { Test, console } from "forge-std/Test.sol";
6+
import { Test } from "forge-std/Test.sol";
77
import { MockERC20 } from "solmate/src/test/utils/mocks/MockERC20.sol";
88
import { PoolManager } from "v4-core/PoolManager.sol";
9-
import { Currency, IHooks, IPoolManager } from "v4-core/interfaces/IPoolManager.sol";
9+
import { Currency, IPoolManager } from "v4-core/interfaces/IPoolManager.sol";
1010
import { Hooks } from "v4-core/libraries/Hooks.sol";
1111
import { LPFeeLibrary } from "v4-core/libraries/LPFeeLibrary.sol";
1212
import { PoolId } from "v4-core/types/PoolId.sol";

0 commit comments

Comments
 (0)