Skip to content

Commit b01d556

Browse files
authored
Merge pull request #340 from consenlabs/style/format-imports
specify dependency version in import paths and organize imports by sorting
2 parents ded59b3 + 37cc0c8 commit b01d556

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+208
-160
lines changed

contracts/AllowanceTarget.sol

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity 0.8.26;
33

4-
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
5-
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
6-
import { Pausable } from "@openzeppelin/contracts/utils/Pausable.sol";
4+
import { IERC20 } from "@openzeppelin/contracts@v5.0.2/token/ERC20/IERC20.sol";
5+
import { SafeERC20 } from "@openzeppelin/contracts@v5.0.2/token/ERC20/utils/SafeERC20.sol";
6+
import { Pausable } from "@openzeppelin/contracts@v5.0.2/utils/Pausable.sol";
77

88
import { Ownable } from "./abstracts/Ownable.sol";
9+
910
import { IAllowanceTarget } from "./interfaces/IAllowanceTarget.sol";
1011

1112
/// @title AllowanceTarget Contract
@@ -22,7 +23,7 @@ contract AllowanceTarget is IAllowanceTarget, Pausable, Ownable {
2223
/// @param trustedCaller An array of addresses that are initially authorized to call spendFromUserTo.
2324
constructor(address _owner, address[] memory trustedCaller) Ownable(_owner) {
2425
uint256 callerCount = trustedCaller.length;
25-
for (uint256 i = 0; i < callerCount; ++i) {
26+
for (uint256 i; i < callerCount; ++i) {
2627
authorized[trustedCaller[i]] = true;
2728
}
2829
}

contracts/CoordinatedTaker.sol

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity 0.8.26;
33

4-
import { TokenCollector } from "./abstracts/TokenCollector.sol";
54
import { AdminManagement } from "./abstracts/AdminManagement.sol";
65
import { EIP712 } from "./abstracts/EIP712.sol";
7-
import { IWETH } from "./interfaces/IWETH.sol";
6+
import { TokenCollector } from "./abstracts/TokenCollector.sol";
7+
88
import { ICoordinatedTaker } from "./interfaces/ICoordinatedTaker.sol";
99
import { ILimitOrderSwap } from "./interfaces/ILimitOrderSwap.sol";
10-
import { LimitOrder, getLimitOrderHash } from "./libraries/LimitOrder.sol";
10+
import { IWETH } from "./interfaces/IWETH.sol";
11+
1112
import { AllowFill, getAllowFillHash } from "./libraries/AllowFill.sol";
1213
import { Asset } from "./libraries/Asset.sol";
14+
import { LimitOrder, getLimitOrderHash } from "./libraries/LimitOrder.sol";
1315
import { SignatureValidator } from "./libraries/SignatureValidator.sol";
1416

1517
/// @title CoordinatedTaker Contract

contracts/GenericSwap.sol

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity 0.8.26;
33

4-
import { TokenCollector } from "./abstracts/TokenCollector.sol";
54
import { EIP712 } from "./abstracts/EIP712.sol";
5+
import { TokenCollector } from "./abstracts/TokenCollector.sol";
6+
67
import { IGenericSwap } from "./interfaces/IGenericSwap.sol";
78
import { IStrategy } from "./interfaces/IStrategy.sol";
8-
import { GenericSwapData, getGSDataHash } from "./libraries/GenericSwapData.sol";
9+
910
import { Asset } from "./libraries/Asset.sol";
11+
import { GenericSwapData, getGSDataHash } from "./libraries/GenericSwapData.sol";
1012
import { SignatureValidator } from "./libraries/SignatureValidator.sol";
1113

1214
/// @title GenericSwap Contract

contracts/LimitOrderSwap.sol

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity 0.8.26;
33

4-
import { ReentrancyGuard } from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
4+
import { ReentrancyGuard } from "@openzeppelin/contracts@v5.0.2/utils/ReentrancyGuard.sol";
55

6-
import { TokenCollector } from "./abstracts/TokenCollector.sol";
7-
import { Ownable } from "./abstracts/Ownable.sol";
86
import { EIP712 } from "./abstracts/EIP712.sol";
9-
import { IWETH } from "./interfaces/IWETH.sol";
7+
import { Ownable } from "./abstracts/Ownable.sol";
8+
import { TokenCollector } from "./abstracts/TokenCollector.sol";
9+
1010
import { ILimitOrderSwap } from "./interfaces/ILimitOrderSwap.sol";
1111
import { IStrategy } from "./interfaces/IStrategy.sol";
12+
import { IWETH } from "./interfaces/IWETH.sol";
13+
14+
import { Asset } from "./libraries/Asset.sol";
1215
import { Constant } from "./libraries/Constant.sol";
1316
import { LimitOrder, getLimitOrderHash } from "./libraries/LimitOrder.sol";
14-
import { Asset } from "./libraries/Asset.sol";
1517
import { SignatureValidator } from "./libraries/SignatureValidator.sol";
1618

1719
/// @title LimitOrderSwap Contract
@@ -88,7 +90,7 @@ contract LimitOrderSwap is ILimitOrderSwap, Ownable, TokenCollector, EIP712, Ree
8890
uint256[] memory takerTokenAmounts = new uint256[](orders.length);
8991
uint256 wethToPay;
9092
address payable _feeCollector = feeCollector;
91-
for (uint256 i = 0; i < orders.length; ++i) {
93+
for (uint256 i; i < orders.length; ++i) {
9294
LimitOrder calldata order = orders[i];
9395
uint256 makingAmount = makerTokenAmounts[i];
9496
if (makingAmount == 0) revert ZeroMakerSpendingAmount();
@@ -133,13 +135,13 @@ contract LimitOrderSwap is ILimitOrderSwap, Ownable, TokenCollector, EIP712, Ree
133135
}
134136
}
135137

136-
for (uint256 i = 0; i < orders.length; ++i) {
138+
for (uint256 i; i < orders.length; ++i) {
137139
LimitOrder calldata order = orders[i];
138140
order.takerToken.transferTo(order.maker, takerTokenAmounts[i]);
139141
}
140142

141143
// any token left is considered as profit
142-
for (uint256 i = 0; i < profitTokens.length; ++i) {
144+
for (uint256 i; i < profitTokens.length; ++i) {
143145
uint256 profit = profitTokens[i].getBalance(address(this));
144146
profitTokens[i].transferTo(payable(msg.sender), profit);
145147
}

contracts/RFQ.sol

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity 0.8.26;
33

4-
import { Address } from "@openzeppelin/contracts/utils/Address.sol";
4+
import { Address } from "@openzeppelin/contracts@v5.0.2/utils/Address.sol";
55

6-
import { TokenCollector } from "./abstracts/TokenCollector.sol";
7-
import { Ownable } from "./abstracts/Ownable.sol";
86
import { EIP712 } from "./abstracts/EIP712.sol";
9-
import { IWETH } from "./interfaces/IWETH.sol";
7+
import { Ownable } from "./abstracts/Ownable.sol";
8+
import { TokenCollector } from "./abstracts/TokenCollector.sol";
9+
1010
import { IRFQ } from "./interfaces/IRFQ.sol";
11+
import { IWETH } from "./interfaces/IWETH.sol";
1112
import { Asset } from "./libraries/Asset.sol";
13+
14+
import { Constant } from "./libraries/Constant.sol";
1215
import { RFQOffer, getRFQOfferHash } from "./libraries/RFQOffer.sol";
1316
import { RFQTx, getRFQTxHash } from "./libraries/RFQTx.sol";
14-
import { Constant } from "./libraries/Constant.sol";
1517
import { SignatureValidator } from "./libraries/SignatureValidator.sol";
1618

1719
/// @title RFQ Contract

contracts/SmartOrderStrategy.sol

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity 0.8.26;
33

4-
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
4+
import { IERC20 } from "@openzeppelin/contracts@v5.0.2/token/ERC20/IERC20.sol";
55

66
import { AdminManagement } from "./abstracts/AdminManagement.sol";
7-
import { Asset } from "./libraries/Asset.sol";
8-
import { IWETH } from "./interfaces/IWETH.sol";
7+
98
import { ISmartOrderStrategy } from "./interfaces/ISmartOrderStrategy.sol";
109
import { IStrategy } from "./interfaces/IStrategy.sol";
10+
import { IWETH } from "./interfaces/IWETH.sol";
11+
12+
import { Asset } from "./libraries/Asset.sol";
1113

1214
/// @title SmartOrderStrategy Contract
1315
/// @author imToken Labs
@@ -52,7 +54,7 @@ contract SmartOrderStrategy is ISmartOrderStrategy, AdminManagement {
5254
}
5355

5456
uint256 opsCount = ops.length;
55-
for (uint256 i = 0; i < opsCount; ++i) {
57+
for (uint256 i; i < opsCount; ++i) {
5658
Operation memory op = ops[i];
5759
_call(op.dest, op.inputToken, op.ratioNumerator, op.ratioDenominator, op.dataOffset, op.value, op.data);
5860
}

contracts/abstracts/AdminManagement.sol

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.0;
33

4-
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
5-
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
4+
import { IERC20 } from "@openzeppelin/contracts@v5.0.2/token/ERC20/IERC20.sol";
5+
import { SafeERC20 } from "@openzeppelin/contracts@v5.0.2/token/ERC20/utils/SafeERC20.sol";
66

7-
import { Ownable } from "./Ownable.sol";
87
import { Asset } from "../libraries/Asset.sol";
98

9+
import { Ownable } from "./Ownable.sol";
10+
1011
/// @title AdminManagement Contract
1112
/// @author imToken Labs
1213
/// @notice This contract provides administrative functions for token management.
@@ -22,8 +23,8 @@ abstract contract AdminManagement is Ownable {
2223
/// @param tokens The array of token addresses to approve.
2324
/// @param spenders The array of spender addresses to approve for each token.
2425
function approveTokens(address[] calldata tokens, address[] calldata spenders) external onlyOwner {
25-
for (uint256 i = 0; i < tokens.length; ++i) {
26-
for (uint256 j = 0; j < spenders.length; ++j) {
26+
for (uint256 i; i < tokens.length; ++i) {
27+
for (uint256 j; j < spenders.length; ++j) {
2728
IERC20(tokens[i]).forceApprove(spenders[j], type(uint256).max);
2829
}
2930
}
@@ -34,7 +35,7 @@ abstract contract AdminManagement is Ownable {
3435
/// @param tokens An array of token addresses to rescue.
3536
/// @param recipient The address to which rescued tokens will be transferred.
3637
function rescueTokens(address[] calldata tokens, address recipient) external onlyOwner {
37-
for (uint256 i = 0; i < tokens.length; ++i) {
38+
for (uint256 i; i < tokens.length; ++i) {
3839
uint256 selfBalance = Asset.getBalance(tokens[i], address(this));
3940
Asset.transferTo(tokens[i], payable(recipient), selfBalance);
4041
}

contracts/abstracts/TokenCollector.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity 0.8.26;
33

4-
import { IERC20Permit } from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol";
5-
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
6-
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
4+
import { IERC20 } from "@openzeppelin/contracts@v5.0.2/token/ERC20/IERC20.sol";
5+
import { IERC20Permit } from "@openzeppelin/contracts@v5.0.2/token/ERC20/extensions/IERC20Permit.sol";
6+
import { SafeERC20 } from "@openzeppelin/contracts@v5.0.2/token/ERC20/utils/SafeERC20.sol";
77

8-
import { IUniswapPermit2 } from "../interfaces/IUniswapPermit2.sol";
98
import { IAllowanceTarget } from "../interfaces/IAllowanceTarget.sol";
9+
import { IUniswapPermit2 } from "../interfaces/IUniswapPermit2.sol";
1010

1111
/// @title TokenCollector Contract
1212
/// @author imToken Labs

contracts/interfaces/ICoordinatedTaker.sol

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,24 @@ import { LimitOrder } from "../libraries/LimitOrder.sol";
66
/// @title ICoordinatedTaker Interface
77
/// @author imToken Labs
88
interface ICoordinatedTaker {
9+
/// @title Coordinator Parameters
10+
/// @dev Contains the signature, salt, and expiry for coordinator authorization.
11+
struct CoordinatorParams {
12+
bytes sig;
13+
uint256 salt;
14+
uint256 expiry;
15+
}
16+
17+
/// @notice Emitted when a limit order is filled by the coordinator.
18+
/// @param user The address of the user.
19+
/// @param orderHash The hash of the order.
20+
/// @param allowFillHash The hash of the allowed fill.
21+
event CoordinatorFill(address indexed user, bytes32 indexed orderHash, bytes32 indexed allowFillHash);
22+
23+
/// @notice Emitted when the coordinator address is updated.
24+
/// @param newCoordinator The address of the new coordinator.
25+
event SetCoordinator(address newCoordinator);
26+
927
/// @notice Error to be thrown when a permission is reused.
1028
/// @dev This error is used to prevent the reuse of permissions.
1129
error ReusedPermission();
@@ -26,24 +44,6 @@ interface ICoordinatedTaker {
2644
/// @dev This error is used to ensure that a valid address is provided.
2745
error ZeroAddress();
2846

29-
/// @title Coordinator Parameters
30-
/// @dev Contains the signature, salt, and expiry for coordinator authorization.
31-
struct CoordinatorParams {
32-
bytes sig;
33-
uint256 salt;
34-
uint256 expiry;
35-
}
36-
37-
/// @notice Emitted when a limit order is filled by the coordinator.
38-
/// @param user The address of the user.
39-
/// @param orderHash The hash of the order.
40-
/// @param allowFillHash The hash of the allowed fill.
41-
event CoordinatorFill(address indexed user, bytes32 indexed orderHash, bytes32 indexed allowFillHash);
42-
43-
/// @notice Emitted when the coordinator address is updated.
44-
/// @param newCoordinator The address of the new coordinator.
45-
event SetCoordinator(address newCoordinator);
46-
4747
/// @notice Submits a limit order fill with additional coordination parameters..
4848
/// @param order The limit order to be filled.
4949
/// @param makerSignature The signature of the maker.

contracts/libraries/Asset.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.0;
33

4-
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
5-
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
4+
import { IERC20 } from "@openzeppelin/contracts@v5.0.2/token/ERC20/IERC20.sol";
5+
import { SafeERC20 } from "@openzeppelin/contracts@v5.0.2/token/ERC20/utils/SafeERC20.sol";
66

77
import { Constant } from "./Constant.sol";
88

0 commit comments

Comments
 (0)