-
Notifications
You must be signed in to change notification settings - Fork 17
feat: Angle crosschain #252
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
Open
sogipec
wants to merge
2
commits into
main
Choose a base branch
from
angle-crosschain
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
) 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
TokenSideChainMultiBridge._addBridgeToken(address,uint256,uint256,uint64,bool)._bridge is a local variable never initialized
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
Reentrancy in TokenSideChainMultiBridge.recoverERC20(address,address,uint256):
External calls:
- IERC20(tokenAddress).safeTransfer(to,amountToRecover)
Event emitted after the call(s):
- Recovered(tokenAddress,to,amountToRecover)
External calls:
- IERC20(tokenAddress).safeTransfer(to,amountToRecover)
Event emitted after the call(s):
- Recovered(tokenAddress,to,amountToRecover)
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
TokenSideChainMultiBridge should inherit from IAgTokenSideChainMultiBridge
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.