Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

feat: Angle crosschain #252

wants to merge 2 commits into from

Conversation

sogipec
Copy link
Contributor

@sogipec sogipec commented Apr 12, 2024

No description provided.

) 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

Comment on lines +258 to +261
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

Comment on lines +17 to +333
_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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant