Skip to content

Commit 4534e48

Browse files
committed
fix: address audit comments
1 parent 1b7f868 commit 4534e48

File tree

3 files changed

+28
-21
lines changed

3 files changed

+28
-21
lines changed

src/v3/RelayApprovalProxyV3.sol

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22
pragma solidity ^0.8.23;
33

44
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
5-
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
5+
import {
6+
SafeERC20
7+
} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
68
import {IPermit2} from "permit2-relay/src/interfaces/IPermit2.sol";
7-
import {ISignatureTransfer} from "permit2-relay/src/interfaces/ISignatureTransfer.sol";
9+
import {
10+
ISignatureTransfer
11+
} from "permit2-relay/src/interfaces/ISignatureTransfer.sol";
812
import {Ownable} from "solady/src/auth/Ownable.sol";
913
import {SignatureCheckerLib} from "solady/src/utils/SignatureCheckerLib.sol";
1014
import {TrustlessPermit} from "trustlessPermit/TrustlessPermit.sol";
@@ -63,8 +67,15 @@ contract RelayApprovalProxyV3 is Ownable {
6367
}
6468

6569
/// @notice Withdraw function in case funds get stuck in contract
66-
function withdraw() external onlyOwner {
67-
_send(msg.sender, address(this).balance);
70+
function withdraw(address token) external onlyOwner {
71+
if (token == address(0)) {
72+
_send(msg.sender, address(this).balance);
73+
} else {
74+
IERC20(token).safeTransfer(
75+
msg.sender,
76+
IERC20(token).balanceOf(address(this))
77+
);
78+
}
6879
}
6980

7081
/// @notice Transfer tokens to RelayRouter and perform multicall in a single tx

src/v3/RelayRouterV3.sol

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ contract RelayRouterV3 is Multicall3, ReentrancyGuardMsgSender {
1515
/// @notice Revert if this contract is set as the recipient
1616
error InvalidRecipient(address recipient);
1717

18-
/// @notice Revert if the target is invalid
19-
error InvalidTarget(address target);
20-
2118
/// @notice Revert if the native transfer failed
2219
error NativeTransferFailed();
2320

@@ -42,7 +39,7 @@ contract RelayRouterV3 is Multicall3, ReentrancyGuardMsgSender {
4239
bytes metadata
4340
);
4441

45-
uint256 RECIPIENT_STORAGE_SLOT =
42+
uint256 private constant RECIPIENT_STORAGE_SLOT =
4643
uint256(keccak256("RelayRouter.recipient")) - 1;
4744

4845
constructor() {}
@@ -102,7 +99,7 @@ contract RelayRouterV3 is Multicall3, ReentrancyGuardMsgSender {
10299
address[] calldata recipients,
103100
uint256[] calldata amounts,
104101
bytes calldata metadata
105-
) public {
102+
) public nonReentrant {
106103
// Revert if array lengths do not match
107104
if (
108105
tokens.length != amounts.length ||
@@ -147,7 +144,7 @@ contract RelayRouterV3 is Multicall3, ReentrancyGuardMsgSender {
147144
address[] calldata tos,
148145
bytes[] calldata datas,
149146
uint256[] calldata amounts
150-
) public {
147+
) public nonReentrant {
151148
// Revert if array lengths do not match
152149
if (
153150
tokens.length != amounts.length ||
@@ -189,7 +186,7 @@ contract RelayRouterV3 is Multicall3, ReentrancyGuardMsgSender {
189186
uint256 amount,
190187
address recipient,
191188
bytes calldata metadata
192-
) public {
189+
) public nonReentrant {
193190
// If recipient is address(0), set to msg.sender
194191
address recipientAddr = recipient == address(0)
195192
? msg.sender
@@ -220,7 +217,7 @@ contract RelayRouterV3 is Multicall3, ReentrancyGuardMsgSender {
220217
uint256 amount,
221218
address to,
222219
bytes calldata data
223-
) public {
220+
) public nonReentrant {
224221
uint256 amountToTransfer = amount == 0 ? address(this).balance : amount;
225222

226223
if (amountToTransfer > 0) {

src/v3/RelayRouterV3_NonTstore.sol

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import {IERC1155} from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
77
import {SafeTransferLib} from "solady/src/utils/SafeTransferLib.sol";
88

99
import {Call3Value, Multicall3, Result} from "../common/Multicall3.sol";
10-
import {ReentrancyGuardMsgSender_NonTstore} from "../common/ReentrancyGuardMsgSender_NonTstore.sol";
10+
import {
11+
ReentrancyGuardMsgSender_NonTstore
12+
} from "../common/ReentrancyGuardMsgSender_NonTstore.sol";
1113

1214
contract RelayRouterV3_NonTstore is
1315
Multicall3,
@@ -18,9 +20,6 @@ contract RelayRouterV3_NonTstore is
1820
/// @notice Revert if this contract is set as the recipient
1921
error InvalidRecipient(address recipient);
2022

21-
/// @notice Revert if the target is invalid
22-
error InvalidTarget(address target);
23-
2423
/// @notice Revert if the native transfer failed
2524
error NativeTransferFailed();
2625

@@ -45,7 +44,7 @@ contract RelayRouterV3_NonTstore is
4544
bytes metadata
4645
);
4746

48-
uint256 RECIPIENT_STORAGE_SLOT =
47+
uint256 private constant RECIPIENT_STORAGE_SLOT =
4948
uint256(keccak256("RelayRouter.recipient")) - 1;
5049

5150
constructor() {}
@@ -105,7 +104,7 @@ contract RelayRouterV3_NonTstore is
105104
address[] calldata recipients,
106105
uint256[] calldata amounts,
107106
bytes calldata metadata
108-
) public {
107+
) public nonReentrant {
109108
// Revert if array lengths do not match
110109
if (
111110
tokens.length != amounts.length ||
@@ -150,7 +149,7 @@ contract RelayRouterV3_NonTstore is
150149
address[] calldata tos,
151150
bytes[] calldata datas,
152151
uint256[] calldata amounts
153-
) public {
152+
) public nonReentrant {
154153
// Revert if array lengths do not match
155154
if (
156155
tokens.length != amounts.length ||
@@ -192,7 +191,7 @@ contract RelayRouterV3_NonTstore is
192191
uint256 amount,
193192
address recipient,
194193
bytes calldata metadata
195-
) public {
194+
) public nonReentrant {
196195
// If recipient is address(0), set to msg.sender
197196
address recipientAddr = recipient == address(0)
198197
? msg.sender
@@ -223,7 +222,7 @@ contract RelayRouterV3_NonTstore is
223222
uint256 amount,
224223
address to,
225224
bytes calldata data
226-
) public {
225+
) public nonReentrant {
227226
uint256 amountToTransfer = amount == 0 ? address(this).balance : amount;
228227

229228
if (amountToTransfer > 0) {

0 commit comments

Comments
 (0)