Skip to content

Commit

Permalink
Tasks: Fix Hop bridger task when bridging to L1 (#164)
Browse files Browse the repository at this point in the history
Co-authored-by: lgalende <[email protected]>
  • Loading branch information
facuspagnuolo and lgalende committed Sep 25, 2024
1 parent a6f7eb8 commit b911329
Show file tree
Hide file tree
Showing 3 changed files with 190 additions and 169 deletions.
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),
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();
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

0 comments on commit b911329

Please sign in to comment.