-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
232 additions
and
53 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,8 +27,8 @@ contract DepositDataCodec { | |
} | ||
|
||
DepositData memory depositData; | ||
Check warning Code scanning / Slither Uninitialized local variables Medium
DepositDataCodec.decodeDepositData(bytes).depositData is a local variable never initialized
|
||
depositData.rate = uint256(bytes32(buffer[0:31])); | ||
depositData.time = uint256(bytes32(buffer[32:63])); | ||
depositData.rate = uint256(bytes32(buffer[0:32])); | ||
depositData.time = uint256(bytes32(buffer[32:64])); | ||
depositData.data = buffer[64:]; | ||
|
||
return depositData; | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,22 +68,7 @@ contract L1ERC20TokenBridge is | |
revert ErrorSenderNotEOA(); | ||
} | ||
|
||
DepositData memory depositData; | ||
depositData.rate = IERC20Wrapable(l1TokenNonRebasable).tokensPerStEth(); | ||
depositData.time = block.timestamp; | ||
depositData.data = data_; | ||
|
||
bytes memory encodedDepositData = encodeDepositData(depositData); | ||
|
||
if (isRebasableTokenFlow(l1Token_, l2Token_)) { | ||
IERC20(l1TokenRebasable).safeTransferFrom(msg.sender, address(this), amount_); | ||
IERC20(l1TokenRebasable).approve(l1TokenNonRebasable, amount_); | ||
uint256 wstETHAmount = IERC20Wrapable(l1TokenNonRebasable).wrap(amount_); | ||
_initiateERC20Deposit(l1TokenRebasable, l2TokenRebasable, msg.sender, msg.sender, wstETHAmount, l2Gas_, encodedDepositData); | ||
} else if (isNonRebasableTokenFlow(l1Token_, l2Token_)) { | ||
IERC20(l1TokenNonRebasable).safeTransferFrom(msg.sender, address(this), amount_); | ||
_initiateERC20Deposit(l1TokenNonRebasable, l2TokenNonRebasable, msg.sender, msg.sender, amount_, l2Gas_, encodedDepositData); | ||
} | ||
_depositERC20To(l1Token_, l2Token_, msg.sender, amount_, l2Gas_, data_); | ||
} | ||
|
||
/// @inheritdoc IL1ERC20Bridge | ||
|
@@ -101,7 +86,7 @@ contract L1ERC20TokenBridge is | |
onlySupportedL1Token(l1Token_) | ||
onlySupportedL2Token(l2Token_) | ||
{ | ||
_initiateERC20Deposit(l1Token_, l2Token_, msg.sender, to_, amount_, l2Gas_, data_); | ||
_depositERC20To(l1Token_, l2Token_, to_, amount_, l2Gas_, data_); | ||
} | ||
|
||
/// @inheritdoc IL1ERC20Bridge | ||
|
@@ -123,7 +108,7 @@ contract L1ERC20TokenBridge is | |
uint256 stETHAmount = IERC20Wrapable(l1TokenNonRebasable).unwrap(amount_); | ||
IERC20(l1TokenRebasable).safeTransfer(to_, stETHAmount); | ||
} else if (isNonRebasableTokenFlow(l1Token_, l2Token_)) { | ||
IERC20(l1Token_).safeTransfer(to_, amount_); | ||
IERC20(l1TokenNonRebasable).safeTransfer(to_, amount_); | ||
} | ||
|
||
emit ERC20WithdrawalFinalized( | ||
|
@@ -136,6 +121,38 @@ contract L1ERC20TokenBridge is | |
); | ||
} | ||
|
||
function _depositERC20To( | ||
address l1Token_, | ||
address l2Token_, | ||
address to_, | ||
uint256 amount_, | ||
uint32 l2Gas_, | ||
bytes calldata data_ | ||
) internal { | ||
|
||
DepositData memory depositData; | ||
Check warning Code scanning / Slither Uninitialized local variables Medium
L1ERC20TokenBridge._depositERC20To(address,address,address,uint256,uint32,bytes).depositData is a local variable never initialized
|
||
depositData.rate = IERC20Wrapable(l1TokenNonRebasable).tokensPerStEth(); | ||
depositData.time = block.timestamp; | ||
depositData.data = data_; | ||
|
||
bytes memory encodedDepositData = encodeDepositData(depositData); | ||
|
||
if (amount_ == 0) { | ||
_initiateERC20Deposit(l1Token_, l2Token_, msg.sender, to_, amount_, l2Gas_, encodedDepositData); | ||
return; | ||
} | ||
|
||
if (isRebasableTokenFlow(l1Token_, l2Token_)) { | ||
IERC20(l1TokenRebasable).safeTransferFrom(msg.sender, address(this), amount_); | ||
IERC20(l1TokenRebasable).approve(l1TokenNonRebasable, amount_); | ||
uint256 wstETHAmount = IERC20Wrapable(l1TokenNonRebasable).wrap(amount_); | ||
_initiateERC20Deposit(l1TokenRebasable, l2TokenRebasable, msg.sender, to_, wstETHAmount, l2Gas_, encodedDepositData); | ||
} else if (isNonRebasableTokenFlow(l1Token_, l2Token_)) { | ||
IERC20(l1TokenNonRebasable).safeTransferFrom(msg.sender, address(this), amount_); | ||
_initiateERC20Deposit(l1TokenNonRebasable, l2TokenNonRebasable, msg.sender, to_, amount_, l2Gas_, encodedDepositData); | ||
} | ||
} | ||
Check warning Code scanning / Slither Unused return Medium |
||
|
||
/// @dev Performs the logic for deposits by informing the L2 token bridge contract | ||
/// of the deposit and calling safeTransferFrom to lock the L1 funds. | ||
/// @param from_ Account to pull the deposit from on L1 | ||
|
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.