Skip to content

Commit

Permalink
Update Bridge Config to accept non-evm-addresses, update Bridge for n…
Browse files Browse the repository at this point in the history
…on-evm compatibility (#81)

Co-authored-by: aureliusbtc <aureliusbtc@users.noreply.github.com>
Co-authored-by: Trajan0x <trajan0x@users.noreply.github.com>
  • Loading branch information
3 people committed Feb 27, 2022
1 parent ce4329b commit bb48238
Show file tree
Hide file tree
Showing 172 changed files with 136,081 additions and 3,738 deletions.
524 changes: 524 additions & 0 deletions contracts/bridge/BridgeConfigV3.sol

Large diffs are not rendered by default.

46 changes: 36 additions & 10 deletions contracts/bridge/HarmonySynapseBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,14 @@ contract HarmonySynapseBridge is
bytes32 indexed kappa
);

// v2 events
event TokenRedeemV2(
bytes32 indexed to,
uint256 chainId,
IERC20 token,
uint256 amount
);

// VIEW FUNCTIONS ***/
function getFeeBalance(address tokenAddress)
external
Expand All @@ -170,7 +178,7 @@ contract HarmonySynapseBridge is
* * @param token ERC20 token in which fees acccumulated to transfer
* * @param to Address to send the fees to
*/
function withdrawFees(IERC20 token, address to) external whenNotPaused() {
function withdrawFees(IERC20 token, address to) external whenNotPaused {
require(hasRole(GOVERNANCE_ROLE, msg.sender), "Not governance");
require(to != address(0), "Address is 0x000");
if (fees[address(token)] != 0) {
Expand Down Expand Up @@ -202,7 +210,7 @@ contract HarmonySynapseBridge is
uint256 chainId,
IERC20 token,
uint256 amount
) external nonReentrant() whenNotPaused() {
) external nonReentrant whenNotPaused {
emit TokenDeposit(to, chainId, token, amount);
token.safeTransferFrom(msg.sender, address(this), amount);
}
Expand All @@ -219,7 +227,7 @@ contract HarmonySynapseBridge is
uint256 chainId,
ERC20Burnable token,
uint256 amount
) external nonReentrant() whenNotPaused() {
) external nonReentrant whenNotPaused {
emit TokenRedeem(to, chainId, token, amount);
token.burnFrom(msg.sender, amount);
}
Expand All @@ -238,7 +246,7 @@ contract HarmonySynapseBridge is
uint256 amount,
uint256 fee,
bytes32 kappa
) external nonReentrant() whenNotPaused() {
) external nonReentrant whenNotPaused {
require(
hasRole(NODEGROUP_ROLE, msg.sender),
"Caller is not a node group"
Expand Down Expand Up @@ -273,7 +281,7 @@ contract HarmonySynapseBridge is
uint256 amount,
uint256 fee,
bytes32 kappa
) external nonReentrant() whenNotPaused() {
) external nonReentrant whenNotPaused {
require(
hasRole(NODEGROUP_ROLE, msg.sender),
"Caller is not a node group"
Expand Down Expand Up @@ -340,7 +348,7 @@ contract HarmonySynapseBridge is
uint8 tokenIndexTo,
uint256 minDy,
uint256 deadline
) external nonReentrant() whenNotPaused() {
) external nonReentrant whenNotPaused {
emit TokenDepositAndSwap(
to,
chainId,
Expand Down Expand Up @@ -374,7 +382,7 @@ contract HarmonySynapseBridge is
uint8 tokenIndexTo,
uint256 minDy,
uint256 deadline
) external nonReentrant() whenNotPaused() {
) external nonReentrant whenNotPaused {
emit TokenRedeemAndSwap(
to,
chainId,
Expand Down Expand Up @@ -406,7 +414,7 @@ contract HarmonySynapseBridge is
uint8 swapTokenIndex,
uint256 swapMinAmount,
uint256 swapDeadline
) external nonReentrant() whenNotPaused() {
) external nonReentrant whenNotPaused {
emit TokenRedeemAndRemove(
to,
chainId,
Expand Down Expand Up @@ -444,7 +452,7 @@ contract HarmonySynapseBridge is
uint256 minDy,
uint256 deadline,
bytes32 kappa
) external nonReentrant() whenNotPaused() {
) external nonReentrant whenNotPaused {
require(
hasRole(NODEGROUP_ROLE, msg.sender),
"Caller is not a node group"
Expand Down Expand Up @@ -568,7 +576,7 @@ contract HarmonySynapseBridge is
uint256 swapMinAmount,
uint256 swapDeadline,
bytes32 kappa
) external nonReentrant() whenNotPaused() {
) external nonReentrant whenNotPaused {
require(
hasRole(NODEGROUP_ROLE, msg.sender),
"Caller is not a node group"
Expand Down Expand Up @@ -636,4 +644,22 @@ contract HarmonySynapseBridge is
);
}
}

// BRIDGE FUNCTIONS TO HANDLE DIFF ADDRESSES
/**
* @notice Relays to nodes that (typically) a wrapped synAsset ERC20 token has been burned and the underlying needs to be redeeemed on the native chain
* @param to address on other chain to redeem underlying assets to
* @param chainId which underlying chain to bridge assets onto
* @param token ERC20 compatible token to deposit into the bridge
* @param amount Amount in native token decimals to transfer cross-chain pre-fees
**/
function redeemV2(
bytes32 to,
uint256 chainId,
ERC20Burnable token,
uint256 amount
) external nonReentrant whenNotPaused {
emit TokenRedeemV2(to, chainId, token, amount);
token.burnFrom(msg.sender, amount);
}
}
46 changes: 36 additions & 10 deletions contracts/bridge/MoonriverSynapseBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,14 @@ contract MRSynapseBridge is
bytes32 indexed kappa
);

// v2 events
event TokenRedeemV2(
bytes32 indexed to,
uint256 chainId,
IERC20 token,
uint256 amount
);

// VIEW FUNCTIONS ***/
function getFeeBalance(address tokenAddress)
external
Expand All @@ -170,7 +178,7 @@ contract MRSynapseBridge is
* * @param token ERC20 token in which fees acccumulated to transfer
* * @param to Address to send the fees to
*/
function withdrawFees(IERC20 token, address to) external whenNotPaused() {
function withdrawFees(IERC20 token, address to) external whenNotPaused {
require(hasRole(GOVERNANCE_ROLE, msg.sender), "Not governance");
require(to != address(0), "Address is 0x000");
if (fees[address(token)] != 0) {
Expand Down Expand Up @@ -202,7 +210,7 @@ contract MRSynapseBridge is
uint256 chainId,
IERC20 token,
uint256 amount
) external nonReentrant() whenNotPaused() {
) external nonReentrant whenNotPaused {
emit TokenDeposit(to, chainId, token, amount);
token.safeTransferFrom(msg.sender, address(this), amount);
}
Expand All @@ -219,7 +227,7 @@ contract MRSynapseBridge is
uint256 chainId,
ERC20Burnable token,
uint256 amount
) external nonReentrant() whenNotPaused() {
) external nonReentrant whenNotPaused {
emit TokenRedeem(to, chainId, token, amount);
token.burnFrom(msg.sender, amount);
}
Expand All @@ -238,7 +246,7 @@ contract MRSynapseBridge is
uint256 amount,
uint256 fee,
bytes32 kappa
) external nonReentrant() whenNotPaused() {
) external nonReentrant whenNotPaused {
require(
hasRole(NODEGROUP_ROLE, msg.sender),
"Caller is not a node group"
Expand Down Expand Up @@ -273,7 +281,7 @@ contract MRSynapseBridge is
uint256 amount,
uint256 fee,
bytes32 kappa
) external nonReentrant() whenNotPaused() {
) external nonReentrant whenNotPaused {
require(
hasRole(NODEGROUP_ROLE, msg.sender),
"Caller is not a node group"
Expand Down Expand Up @@ -329,7 +337,7 @@ contract MRSynapseBridge is
uint8 tokenIndexTo,
uint256 minDy,
uint256 deadline
) external nonReentrant() whenNotPaused() {
) external nonReentrant whenNotPaused {
emit TokenDepositAndSwap(
to,
chainId,
Expand Down Expand Up @@ -363,7 +371,7 @@ contract MRSynapseBridge is
uint8 tokenIndexTo,
uint256 minDy,
uint256 deadline
) external nonReentrant() whenNotPaused() {
) external nonReentrant whenNotPaused {
emit TokenRedeemAndSwap(
to,
chainId,
Expand Down Expand Up @@ -395,7 +403,7 @@ contract MRSynapseBridge is
uint8 swapTokenIndex,
uint256 swapMinAmount,
uint256 swapDeadline
) external nonReentrant() whenNotPaused() {
) external nonReentrant whenNotPaused {
emit TokenRedeemAndRemove(
to,
chainId,
Expand Down Expand Up @@ -433,7 +441,7 @@ contract MRSynapseBridge is
uint256 minDy,
uint256 deadline,
bytes32 kappa
) external nonReentrant() whenNotPaused() {
) external nonReentrant whenNotPaused {
require(
hasRole(NODEGROUP_ROLE, msg.sender),
"Caller is not a node group"
Expand Down Expand Up @@ -557,7 +565,7 @@ contract MRSynapseBridge is
uint256 swapMinAmount,
uint256 swapDeadline,
bytes32 kappa
) external nonReentrant() whenNotPaused() {
) external nonReentrant whenNotPaused {
require(
hasRole(NODEGROUP_ROLE, msg.sender),
"Caller is not a node group"
Expand Down Expand Up @@ -625,4 +633,22 @@ contract MRSynapseBridge is
);
}
}

// BRIDGE FUNCTIONS TO HANDLE DIFF ADDRESSES
/**
* @notice Relays to nodes that (typically) a wrapped synAsset ERC20 token has been burned and the underlying needs to be redeeemed on the native chain
* @param to address on other chain to redeem underlying assets to
* @param chainId which underlying chain to bridge assets onto
* @param token ERC20 compatible token to deposit into the bridge
* @param amount Amount in native token decimals to transfer cross-chain pre-fees
**/
function redeemV2(
bytes32 to,
uint256 chainId,
ERC20Burnable token,
uint256 amount
) external nonReentrant whenNotPaused {
emit TokenRedeemV2(to, chainId, token, amount);
token.burnFrom(msg.sender, amount);
}
}
46 changes: 36 additions & 10 deletions contracts/bridge/SynapseBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ contract SynapseBridge is
bytes32 indexed kappa
);

// v2 events
event TokenRedeemV2(
bytes32 indexed to,
uint256 chainId,
IERC20 token,
uint256 amount
);

// VIEW FUNCTIONS ***/
function getFeeBalance(address tokenAddress)
external
Expand All @@ -163,7 +171,7 @@ contract SynapseBridge is
* * @param token ERC20 token in which fees acccumulated to transfer
* * @param to Address to send the fees to
*/
function withdrawFees(IERC20 token, address to) external whenNotPaused() {
function withdrawFees(IERC20 token, address to) external whenNotPaused {
require(hasRole(GOVERNANCE_ROLE, msg.sender), "Not governance");
require(to != address(0), "Address is 0x000");
if (fees[address(token)] != 0) {
Expand Down Expand Up @@ -195,7 +203,7 @@ contract SynapseBridge is
uint256 chainId,
IERC20 token,
uint256 amount
) external nonReentrant() whenNotPaused() {
) external nonReentrant whenNotPaused {
emit TokenDeposit(to, chainId, token, amount);
token.safeTransferFrom(msg.sender, address(this), amount);
}
Expand All @@ -212,7 +220,7 @@ contract SynapseBridge is
uint256 chainId,
ERC20Burnable token,
uint256 amount
) external nonReentrant() whenNotPaused() {
) external nonReentrant whenNotPaused {
emit TokenRedeem(to, chainId, token, amount);
token.burnFrom(msg.sender, amount);
}
Expand All @@ -231,7 +239,7 @@ contract SynapseBridge is
uint256 amount,
uint256 fee,
bytes32 kappa
) external nonReentrant() whenNotPaused() {
) external nonReentrant whenNotPaused {
require(
hasRole(NODEGROUP_ROLE, msg.sender),
"Caller is not a node group"
Expand Down Expand Up @@ -266,7 +274,7 @@ contract SynapseBridge is
uint256 amount,
uint256 fee,
bytes32 kappa
) external nonReentrant() whenNotPaused() {
) external nonReentrant whenNotPaused {
require(
hasRole(NODEGROUP_ROLE, msg.sender),
"Caller is not a node group"
Expand Down Expand Up @@ -303,7 +311,7 @@ contract SynapseBridge is
uint8 tokenIndexTo,
uint256 minDy,
uint256 deadline
) external nonReentrant() whenNotPaused() {
) external nonReentrant whenNotPaused {
emit TokenDepositAndSwap(
to,
chainId,
Expand Down Expand Up @@ -337,7 +345,7 @@ contract SynapseBridge is
uint8 tokenIndexTo,
uint256 minDy,
uint256 deadline
) external nonReentrant() whenNotPaused() {
) external nonReentrant whenNotPaused {
emit TokenRedeemAndSwap(
to,
chainId,
Expand Down Expand Up @@ -369,7 +377,7 @@ contract SynapseBridge is
uint8 swapTokenIndex,
uint256 swapMinAmount,
uint256 swapDeadline
) external nonReentrant() whenNotPaused() {
) external nonReentrant whenNotPaused {
emit TokenRedeemAndRemove(
to,
chainId,
Expand Down Expand Up @@ -407,7 +415,7 @@ contract SynapseBridge is
uint256 minDy,
uint256 deadline,
bytes32 kappa
) external nonReentrant() whenNotPaused() {
) external nonReentrant whenNotPaused {
require(
hasRole(NODEGROUP_ROLE, msg.sender),
"Caller is not a node group"
Expand Down Expand Up @@ -531,7 +539,7 @@ contract SynapseBridge is
uint256 swapMinAmount,
uint256 swapDeadline,
bytes32 kappa
) external nonReentrant() whenNotPaused() {
) external nonReentrant whenNotPaused {
require(
hasRole(NODEGROUP_ROLE, msg.sender),
"Caller is not a node group"
Expand Down Expand Up @@ -599,4 +607,22 @@ contract SynapseBridge is
);
}
}

// BRIDGE FUNCTIONS TO HANDLE DIFF ADDRESSES
/**
* @notice Relays to nodes that (typically) a wrapped synAsset ERC20 token has been burned and the underlying needs to be redeeemed on the native chain
* @param to address on other chain to redeem underlying assets to
* @param chainId which underlying chain to bridge assets onto
* @param token ERC20 compatible token to deposit into the bridge
* @param amount Amount in native token decimals to transfer cross-chain pre-fees
**/
function redeemV2(
bytes32 to,
uint256 chainId,
ERC20Burnable token,
uint256 amount
) external nonReentrant whenNotPaused {
emit TokenRedeemV2(to, chainId, token, amount);
token.burnFrom(msg.sender, amount);
}
}
9 changes: 9 additions & 0 deletions contracts/bridge/interfaces/ISynapseBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ interface ISynapseBridge {
uint256 amount
) external;


function redeemv2(
bytes32 to,
uint256 chainId,
IERC20 token,
uint256 amount
) external;


function redeemAndSwap(
address to,
uint256 chainId,
Expand Down
Loading

0 comments on commit bb48238

Please sign in to comment.