-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Angle crosschain #252
base: main
Are you sure you want to change the base?
Conversation
) internal { | ||
if (bridges[bridgeToken].allowed || bridgeToken == address(0)) revert InvalidToken(); | ||
if (fee > BASE_PARAMS) revert TooHighParameterValue(); | ||
BridgeDetails memory _bridge; |
Check warning
Code scanning / Slither
Uninitialized local variables Medium
function recoverERC20(address tokenAddress, address to, uint256 amountToRecover) external onlyGovernor { | ||
IERC20(tokenAddress).safeTransfer(to, amountToRecover); | ||
emit Recovered(tokenAddress, to, amountToRecover); | ||
} |
Check notice
Code scanning / Slither
Reentrancy vulnerabilities Low
External calls:
- IERC20(tokenAddress).safeTransfer(to,amountToRecover)
Event emitted after the call(s):
- Recovered(tokenAddress,to,amountToRecover)
_addBridgeToken(bridgeToken, limit, hourlyLimit, fee, paused); | ||
} | ||
|
||
/// @notice Removes support for a token | ||
/// @param bridgeToken Address of the bridge token to remove support for | ||
function removeBridgeToken(address bridgeToken) external onlyGovernor { | ||
if (IERC20(bridgeToken).balanceOf(address(this)) != 0) revert AssetStillControlledInReserves(); | ||
delete bridges[bridgeToken]; | ||
// Deletion from `bridgeTokensList` loop | ||
uint256 bridgeTokensListLength = bridgeTokensList.length; | ||
for (uint256 i = 0; i < bridgeTokensListLength - 1; i++) { | ||
if (bridgeTokensList[i] == bridgeToken) { | ||
// Replace the `bridgeToken` to remove with the last of the list | ||
bridgeTokensList[i] = bridgeTokensList[bridgeTokensListLength - 1]; | ||
break; | ||
} | ||
} | ||
// Remove last element in array | ||
bridgeTokensList.pop(); | ||
emit BridgeTokenRemoved(bridgeToken); | ||
} | ||
|
||
/// @notice Recovers any ERC20 token | ||
/// @dev Can be used to withdraw bridge tokens for them to be de-bridged on mainnet | ||
function recoverERC20(address tokenAddress, address to, uint256 amountToRecover) external onlyGovernor { | ||
IERC20(tokenAddress).safeTransfer(to, amountToRecover); | ||
emit Recovered(tokenAddress, to, amountToRecover); | ||
} | ||
|
||
/// @notice Updates the `limit` amount for `bridgeToken` | ||
function setLimit(address bridgeToken, uint256 limit) external onlyGovernorOrGuardian { | ||
if (!bridges[bridgeToken].allowed) revert InvalidToken(); | ||
bridges[bridgeToken].limit = limit; | ||
emit BridgeTokenLimitUpdated(bridgeToken, limit); | ||
} | ||
|
||
/// @notice Updates the `hourlyLimit` amount for `bridgeToken` | ||
function setHourlyLimit(address bridgeToken, uint256 hourlyLimit) external onlyGovernorOrGuardian { | ||
if (!bridges[bridgeToken].allowed) revert InvalidToken(); | ||
bridges[bridgeToken].hourlyLimit = hourlyLimit; | ||
emit BridgeTokenHourlyLimitUpdated(bridgeToken, hourlyLimit); | ||
} | ||
|
||
/// @notice Updates the `chainTotalHourlyLimit` amount | ||
function setChainTotalHourlyLimit(uint256 hourlyLimit) external onlyGovernorOrGuardian { | ||
_setChainTotalHourlyLimit(hourlyLimit); | ||
} | ||
|
||
/// @notice Updates the `fee` value for `bridgeToken` | ||
function setSwapFee(address bridgeToken, uint64 fee) external onlyGovernorOrGuardian { | ||
if (!bridges[bridgeToken].allowed) revert InvalidToken(); | ||
if (fee > BASE_PARAMS) revert TooHighParameterValue(); | ||
bridges[bridgeToken].fee = fee; | ||
emit BridgeTokenFeeUpdated(bridgeToken, fee); | ||
} | ||
|
||
/// @notice Pauses or unpauses swapping in and out for a token | ||
function toggleBridge(address bridgeToken) external onlyGovernorOrGuardian { | ||
if (!bridges[bridgeToken].allowed) revert InvalidToken(); | ||
bool pausedStatus = bridges[bridgeToken].paused; | ||
bridges[bridgeToken].paused = !pausedStatus; | ||
emit BridgeTokenToggled(bridgeToken, !pausedStatus); | ||
} | ||
|
||
/// @notice Toggles fees for the address `theAddress` | ||
function toggleFeesForAddress(address theAddress) external onlyGovernorOrGuardian { | ||
uint256 feeExemptStatus = 1 - isFeeExempt[theAddress]; | ||
isFeeExempt[theAddress] = feeExemptStatus; | ||
emit FeeToggled(theAddress, feeExemptStatus); | ||
} | ||
|
||
// ============================= INTERNAL FUNCTIONS ============================ | ||
|
||
/// @notice Internal version of the `addBridgeToken` function | ||
function _addBridgeToken( | ||
address bridgeToken, | ||
uint256 limit, | ||
uint256 hourlyLimit, | ||
uint64 fee, | ||
bool paused | ||
) internal { | ||
if (bridges[bridgeToken].allowed || bridgeToken == address(0)) revert InvalidToken(); | ||
if (fee > BASE_PARAMS) revert TooHighParameterValue(); | ||
BridgeDetails memory _bridge; | ||
_bridge.limit = limit; | ||
_bridge.hourlyLimit = hourlyLimit; | ||
_bridge.paused = paused; | ||
_bridge.fee = fee; | ||
_bridge.allowed = true; | ||
bridges[bridgeToken] = _bridge; | ||
bridgeTokensList.push(bridgeToken); | ||
emit BridgeTokenAdded(bridgeToken, limit, hourlyLimit, fee, paused); | ||
} | ||
|
||
/// @notice Internal version of the `setChainTotalHourlyLimit` | ||
function _setChainTotalHourlyLimit(uint256 hourlyLimit) internal { | ||
chainTotalHourlyLimit = hourlyLimit; | ||
emit HourlyLimitUpdated(hourlyLimit); | ||
} | ||
} |
Check warning
Code scanning / Slither
Missing inheritance Warning
No description provided.