Skip to content

Conversation

eliyahud
Copy link
Contributor

No description provided.

@@ -0,0 +1,67 @@
// SPDX-License-Identifier: UNLICENSED

pragma solidity ^0.8.7;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use 0.8.21 now


pragma solidity ^0.8.7;

import "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try openzeppelin-5, its aliased to the latest openzeppelin contracts which are better

bytes32 public constant BRIDGE_ROLE = keccak256("BRIDGE_ROLE");

// @dev Address of paraswap
address internal _target = 0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make these all contstants

) external payable onlyRole(BRIDGE_ROLE) {
require(amount <= IERC20(fromToken).balanceOf(address(this)), "Amount exceeds balance");
IERC20(fromToken).safeApprove(_allowanceTarget, amount);
_target.call{ value: msg.value }(swapData);
Copy link
Collaborator

@ohitslaurence ohitslaurence Nov 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(bool success, ) = _target.call{ value: msg.value }(swapData);
if (!success) {
assembly {
returndatacopy(0, 0, returndatasize())
revert(0, returndatasize())
}
}

* @param to Target address
*/
function sweep(IERC20 token, address to) external onlyRole(BRIDGE_ROLE) {
token.transfer(to, token.balanceOf(address(this)));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

safeTransfer, just because it can cause issues in some cases where the token doesn't conform properly

require(amount <= IERC20(fromToken).balanceOf(address(this)), "Amount exceeds balance");
IERC20(fromToken).safeApprove(_allowanceTarget, amount);
_target.call{ value: msg.value }(swapData);
IERC20(toToken).transfer(_circleReceiving, IERC20(toToken).balanceOf(address(this)));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

safeTransfer

* @param swapData Data for paraswap call
*/
function swapToken(
address fromToken,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can cast this to IERC20 then you wont need to do it everywhere else

// @dev Circle receiving address
address internal _circleReceiving = 0xb0E2D41a14494717f42Ffc6327F9D250b0ad32a8;

constructor(address bridgeRole) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can make the constructor payable to save some gas

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.

2 participants