Skip to content
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

Tasks: Fix Hop bridger task when bridging to L1 #164

Merged
merged 3 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions packages/tasks/contracts/bridge/HopBridger.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ import '../interfaces/bridge/IHopBridger.sol';
contract HopBridger is IHopBridger, BaseBridgeTask {
using FixedPoint for uint256;

// Ethereum mainnet chain ID = 1
uint256 private constant MAINNET_CHAIN_ID = 1;

// Execution type for relayers
bytes32 public constant override EXECUTION_TYPE = keccak256('HOP_BRIDGER');

Expand Down Expand Up @@ -97,7 +100,7 @@ contract HopBridger is IHopBridger, BaseBridgeTask {
}

/**
* @dev Sets the max deadline
* @dev Sets the max deadline. Only used when bridging to L2.
* @param newMaxDeadline New max deadline to be set
*/
function setMaxDeadline(uint256 newMaxDeadline) external override authP(authParams(newMaxDeadline)) {
Expand Down Expand Up @@ -128,8 +131,8 @@ contract HopBridger is IHopBridger, BaseBridgeTask {
if (amount == 0) amount = getTaskAmount(token);
_beforeHopBridger(token, amount, slippage, fee);

uint256 amountAfterFees = amount - fee;
uint256 minAmountOut = amountAfterFees.mulUp(FixedPoint.ONE - slippage);
uint256 destinationChain = getDestinationChain(token);
uint256 minAmountOut = (amount - fee).mulUp(FixedPoint.ONE - slippage);
bytes memory connectorData = abi.encodeWithSelector(
IHopBridgeConnector.execute.selector,
getDestinationChain(token),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
getDestinationChain(token),
destinationChain,

Copy link
Member Author

Choose a reason for hiding this comment

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

Stack too deep issues

Expand All @@ -138,7 +141,7 @@ contract HopBridger is IHopBridger, BaseBridgeTask {
minAmountOut,
recipient,
tokenHopEntrypoint[token],
block.timestamp + maxDeadline,
destinationChain == MAINNET_CHAIN_ID ? 0 : (block.timestamp + maxDeadline),
relayer,
fee
);
Expand Down Expand Up @@ -174,7 +177,6 @@ contract HopBridger is IHopBridger, BaseBridgeTask {
* @dev Sets the max deadline
*/
function _setMaxDeadline(uint256 _maxDeadline) internal {
if (_maxDeadline == 0) revert TaskMaxDeadlineZero();
lgalende marked this conversation as resolved.
Show resolved Hide resolved
maxDeadline = _maxDeadline;
emit MaxDeadlineSet(_maxDeadline);
}
Expand Down
5 changes: 0 additions & 5 deletions packages/tasks/contracts/interfaces/bridge/IHopBridger.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ import './IBaseBridgeTask.sol';
* @dev Hop bridger task interface
*/
interface IHopBridger is IBaseBridgeTask {
/**
* @dev The max deadline is zero
*/
error TaskMaxDeadlineZero();

/**
* @dev The Hop entrypoint is zero
*/
Expand Down
Loading
Loading