fix: ci
This commit is contained in:
@@ -6,12 +6,12 @@ import "@permit2/src/interfaces/IAllowanceTransfer.sol";
|
|||||||
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
||||||
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
|
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
|
||||||
|
|
||||||
|
|
||||||
error TychoRouter__WithdrawalFailed();
|
error TychoRouter__WithdrawalFailed();
|
||||||
error TychoRouter__InvalidReceiver();
|
error TychoRouter__InvalidReceiver();
|
||||||
|
|
||||||
contract TychoRouter is AccessControl {
|
contract TychoRouter is AccessControl {
|
||||||
IAllowanceTransfer public immutable permit2;
|
IAllowanceTransfer public immutable permit2;
|
||||||
|
|
||||||
using SafeERC20 for IERC20;
|
using SafeERC20 for IERC20;
|
||||||
|
|
||||||
//keccak256("NAME_OF_ROLE") : save gas on deployment
|
//keccak256("NAME_OF_ROLE") : save gas on deployment
|
||||||
@@ -68,9 +68,8 @@ contract TychoRouter is AccessControl {
|
|||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Allows withdrawing any ERC20 funds if funds get stuck in case of a bug.
|
* @dev Allows withdrawing any ERC20 funds if funds get stuck in case of a bug.
|
||||||
*/
|
*/
|
||||||
function withdraw(IERC20[] memory tokens, address receiver)
|
function withdraw(IERC20[] memory tokens, address receiver)
|
||||||
@@ -78,37 +77,36 @@ contract TychoRouter is AccessControl {
|
|||||||
onlyRole(FUND_RESCUER_ROLE)
|
onlyRole(FUND_RESCUER_ROLE)
|
||||||
{
|
{
|
||||||
if (receiver == address(0)) revert TychoRouter__InvalidReceiver();
|
if (receiver == address(0)) revert TychoRouter__InvalidReceiver();
|
||||||
|
|
||||||
|
|
||||||
for (uint256 i = 0; i < tokens.length; i++) {
|
for (uint256 i = 0; i < tokens.length; i++) {
|
||||||
|
// slither-disable-next-line calls-loop
|
||||||
uint256 tokenBalance = tokens[i].balanceOf(address(this));
|
uint256 tokenBalance = tokens[i].balanceOf(address(this));
|
||||||
if (tokenBalance > 0) {
|
if (tokenBalance > 0) {
|
||||||
tokens[i].safeTransfer(receiver, tokenBalance);
|
|
||||||
emit Withdrawal(address(tokens[i]), tokenBalance);
|
emit Withdrawal(address(tokens[i]), tokenBalance);
|
||||||
|
tokens[i].safeTransfer(receiver, tokenBalance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Allows withdrawing any NATIVE funds if funds get stuck in case of a bug.
|
* @dev Allows withdrawing any NATIVE funds if funds get stuck in case of a bug.
|
||||||
* The contract should never hold any NATIVE tokens for security reasons.
|
* The contract should never hold any NATIVE tokens for security reasons.
|
||||||
*/
|
*/
|
||||||
function withdrawNative(address receiver)
|
function withdrawNative(address receiver)
|
||||||
external
|
external
|
||||||
onlyRole(FUND_RESCUER_ROLE)
|
onlyRole(FUND_RESCUER_ROLE)
|
||||||
{
|
{
|
||||||
if (receiver == address(0)) revert TychoRouter__InvalidReceiver();
|
if (receiver == address(0)) revert TychoRouter__InvalidReceiver();
|
||||||
|
|
||||||
uint256 amount = address(this).balance;
|
uint256 amount = address(this).balance;
|
||||||
if (amount > 0) {
|
if (amount > 0) {
|
||||||
// slither-disable-next-line arbitrary-send-eth
|
emit Withdrawal(address(0), amount);
|
||||||
|
// slither-disable-next-line arbitrary-send-eth
|
||||||
(bool success,) = receiver.call{value: amount}("");
|
(bool success,) = receiver.call{value: amount}("");
|
||||||
if (!success) revert TychoRouter__WithdrawalFailed();
|
if (!success) revert TychoRouter__WithdrawalFailed();
|
||||||
emit Withdrawal(address(0), amount);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Allows this contract to receive native token
|
* @dev Allows this contract to receive native token
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user