Skip to content

Commit

Permalink
final patches
Browse files Browse the repository at this point in the history
  • Loading branch information
proletesseract committed Oct 26, 2023
1 parent 140b51b commit cd63d62
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/interfaces/root/IRootERC20Bridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ interface IRootERC20BridgeEvents {
uint256 amount
);
event IMXDeposit(address indexed rootToken, address depositor, address indexed receiver, uint256 amount);
event WETHDeposit(address indexed rootToken, address depositor, address indexed receiver, uint256 amount);
event WETHDeposit(address indexed rootToken, address indexed childToken, address depositor, address indexed receiver, uint256 amount);
event NativeEthDeposit(
address indexed rootToken,
address indexed childToken,
Expand Down
8 changes: 4 additions & 4 deletions src/root/RootERC20Bridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,13 @@ contract RootERC20Bridge is

function _depositToken(IERC20Metadata rootToken, address receiver, uint256 amount) private {
if (address(rootToken) == rootWETHToken) {
_unwrapETH(amount);
_deposit(IERC20Metadata(rootWETHToken), receiver, amount);
_depositWrappedETH(receiver, amount);
} else {
_depositERC20(rootToken, receiver, amount);
}
}

function _unwrapETH(uint256 amount) private {
function _depositWrappedETH(address receiver, uint256 amount) private {
uint256 expectedBalance = address(this).balance + amount;

IERC20Metadata erc20WETH = IERC20Metadata(rootWETHToken);
Expand All @@ -172,6 +171,7 @@ contract RootERC20Bridge is
if (address(this).balance != expectedBalance) {
revert BalanceInvariantCheckFailed(address(this).balance, expectedBalance);
}
_deposit(IERC20Metadata(rootWETHToken), receiver, amount);
}

function _depositERC20(IERC20Metadata rootToken, address receiver, uint256 amount) private {
Expand Down Expand Up @@ -263,7 +263,7 @@ contract RootERC20Bridge is
if (address(rootToken) == NATIVE_ETH) {
emit NativeEthDeposit(address(rootToken), childETHToken, msg.sender, receiver, amount);
} else if (address(rootToken) == rootWETHToken) {
emit WETHDeposit(address(rootToken), msg.sender, receiver, amount);
emit WETHDeposit(address(rootToken), childETHToken, msg.sender, receiver, amount);
} else if (address(rootToken) == rootIMXToken) {
emit IMXDeposit(address(rootToken), msg.sender, receiver, amount);
} else {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/root/RootERC20Bridge.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ contract RootERC20BridgeIntegrationTest is Test, IRootERC20BridgeEvents, IRootAx
vm.expectEmit(address(axelarAdaptor));
emit MapTokenAxelarMessage(CHILD_CHAIN_NAME, childBridgeAdaptorString, predictedPayload);
vm.expectEmit(address(rootBridge));
emit WETHDeposit(address(WRAPPED_ETH), address(this), address(this), tokenAmount);
emit WETHDeposit(address(WRAPPED_ETH), rootBridge.childETHToken(), address(this), address(this), tokenAmount);
vm.expectCall(
address(axelarAdaptor),
depositFee,
Expand Down
4 changes: 2 additions & 2 deletions test/unit/root/RootERC20Bridge.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ contract RootERC20BridgeUnitTest is Test, IRootERC20BridgeEvents, IRootERC20Brid
setupDeposit(WRAPPED_ETH, rootBridge, mapTokenFee, depositFee, amount, false);

vm.expectEmit();
emit WETHDeposit(WRAPPED_ETH, address(this), address(this), amount);
emit WETHDeposit(WRAPPED_ETH, rootBridge.childETHToken(), address(this), address(this), amount);
rootBridge.deposit{value: depositFee}(IERC20Metadata(WRAPPED_ETH), amount);
}

Expand All @@ -359,7 +359,7 @@ contract RootERC20BridgeUnitTest is Test, IRootERC20BridgeEvents, IRootERC20Brid
setupDepositTo(WRAPPED_ETH, rootBridge, mapTokenFee, depositFee, amount, receiver, false);

vm.expectEmit();
emit WETHDeposit(WRAPPED_ETH, address(this), receiver, amount);
emit WETHDeposit(WRAPPED_ETH, rootBridge.childETHToken(), address(this), receiver, amount);
rootBridge.depositTo{value: depositFee}(IERC20Metadata(WRAPPED_ETH), receiver, amount);
}

Expand Down

0 comments on commit cd63d62

Please sign in to comment.