Spoke Contracts

Interfaces for contracts deployed on supported Everclear chains.

/**
 * @title IConnextSpoke
 * @notice Interface for the ConnextSpoke contract
 */
interface IConnextSpoke is IBaseSpoke {
  /*///////////////////////////////////////////////////////////////
                              STRUCTS
  //////////////////////////////////////////////////////////////*/
  /**
   * @notice Parameters needed to execute a permit
   * @param deadline The deadline of the permit
   * @param v The v of the signature
   * @param r The r of the signature
   * @param s The s of the signature
   */
  struct PermitParams {
    uint256 deadline;
    uint8 v;
    bytes32 r;
    bytes32 s;
  }

  /*///////////////////////////////////////////////////////////////
                              EVENTS
  //////////////////////////////////////////////////////////////*/

  /**
   * @notice emitted when a new intent is added on origin (_messageId is not definitive)
   * @param _intentId The ID of the intent
   * @param _queueIdx The index of the intent in the IntentQueue
   * @param _intent The intent structure
   */
  event IntentAdded(bytes32 indexed _intentId, uint256 _queueIdx, Intent _intent);

  /**
   * @notice emitted when an intent is filled on destination (_messageId is not definitive)
   * @param _intentId The ID of the intent
   * @param _filler The address of the intent filler
   * @param _totalFeeBPS The total amount of fee deducted from the transferred amount
   * @param _queueIdx The index of the FillMessage in the FillQueue
   * @param _intent The full intent object
   */
  event IntentFilled(
    bytes32 indexed _intentId, address indexed _filler, uint256 _totalFeeBPS, uint256 _queueIdx, Intent _intent
  );

  /**
   * @notice emitted when an intent is executed on destination
   * @param _intentId The ID of the intent
   * @param _executor The address of the intent executor
   * @param _asset The address of the intent asset
   * @param _amount The amount of the intent asset
   * @param _fee The fee paid to cover relaying the message
   */
  event IntentExecuted(
    bytes32 indexed _intentId, address indexed _executor, address _asset, uint256 _amount, uint24 _fee
  );

  /**
   * @notice emmited when xcall is called by a user
   * @param _intentId The ID of the intent
   */
  event XCalled(bytes32 indexed _intentId);

  /**
   * @notice emitted when an intent is bumped
   * @param _intentId The ID of the intent
   * @param _amount The amount of the bump
   */
  event IntentBumped(bytes32 _intentId, uint256 _amount);

  /**
   * @notice emitted when solver (or anyone) deposits an asset into the ConnextSpoke
   * @param _depositant The address of the depositant
   * @param _asset The address of the deposited asset
   * @param _amount The amount of the deposited asset
   */
  event Deposited(address indexed _depositant, address indexed _asset, uint256 _amount);

  /**
   * @notice emitted when solver (or anyone) withdraws an asset from the ConnextSpoke
   * @param _withdrawer The address of the withdrawer
   * @param _asset The address of the withdrawn asset
   * @param _amount The amount of the withdrawn asset
   */
  event Withdrawn(address indexed _withdrawer, address indexed _asset, uint256 _amount);

  /**
   * @notice emitted when the protocol is paused (domain-level)
   */
  event Paused();

  /**
   * @notice emitted when the protocol is paused (domain-level)
   */
  event Unpaused();

  /**
   * @notice Emitted when the intent queue is processed
   * @param _messageId The ID of the message
   * @param _firstIdx The first index of the queue to be processed
   * @param _lastIdx The last index of the queue to be processed
   * @param _quote The quote amount
   */
  event IntentQueueProcessed(bytes32 indexed _messageId, uint256 _firstIdx, uint256 _lastIdx, uint256 _quote);

  /**
   * @notice Emitted when the fill queue is processed
   * @param _messageId The ID of the message
   * @param _firstIdx The first index of the queue to be processed
   * @param _lastIdx The last index of the queue to be processed
   * @param _quote The quote amount
   */
  event FillQueueProcessed(bytes32 indexed _messageId, uint256 _firstIdx, uint256 _lastIdx, uint256 _quote);

  /**
   * @notice Emitted when an external call is executed
   * @param _intentId The ID of the intent
   * @param _success Whether the call was successful
   * @param _returnData The return data of the call
   */
  event ExternalCalldataExecuted(bytes32 indexed _intentId, bool _success, bytes _returnData);

  /**
   * @notice emitted when the BaseSpoke processes a settlement
   * @param _intentId The ID of the intent
   * @param _account The address of the account
   * @param _asset The address of the asset
   * @param _amount The amount of the asset
   */
  event Settled(bytes32 indexed _intentId, address _account, address _asset, uint256 _amount);

  /*///////////////////////////////////////////////////////////////
                              ERRORS
  //////////////////////////////////////////////////////////////*/

  /**
   * @notice Thrown when the intent is already filled
   * @param _intentId The ID of the intent
   */
  error ConnextSpoke_FillIntent_AlreadyFilled(bytes32 _intentId);

  /**
   * @notice Thrown when the fill intent message destination is wrong
   */
  error ConnextSpoke_FillIntent_WrongDestination();

  /**
   * @notice Thrown when trying to fill an expired intent
   */
  error ConnextSpoke_FillIntent_IntentExpired(bytes32 _intentId);

  /**
   * @notice Thrown when calling newIntent with the wrong destination
   */
  error ConnextSpoke_NewIntent_WrongDestination();

  /**
   * @notice Thrown when the maxRoutersFee is exceeded
   * @param _fee The max fee requested
   * @param _maxRoutersFee The maximum fee allowed
   */
  error ConnextSpoke_NewIntent_MaxFeeExceeded(uint256 _fee, uint24 _maxRoutersFee);

  /**
   * @notice Thrown when the external call failed on fillIntent
   */
  error ConnextSpoke_FillIntent_ExternalCallFailed();

  /**
   * @notice Thrown when the router doesnt have sufficient funds to fill an intent
   */
  error ConnextSpoke_FillIntent_InsufficientFunds(uint256 _requested, uint256 _available);

  /**
   * @notice Thrown when the fee exceeds the maximum fee
   * @param _fee The fee charged
   * @param _maxRoutersFee The maximum fee allowed
   */
  error ConnextSpoke_FillIntent_MaxFeeExceeded(uint256 _fee, uint24 _maxRoutersFee);

  /**
   * @notice Thrown when there are insufficient funds to settle a message
   */
  error ConnextSpoke_Settlement_InsufficientFunds(uint256 _requested, uint256 _available);

  /**
   * @notice Thrown when the intent is already settled
   */
  error ConnextSpoke_Settlement_AlreadySettled(bytes32 _intentId);

  /**
   * @notice Thrown when a signature signer doesn't match the expected address
   */
  error ConnextSpoke_InvalidSignature();

  /**
   * @notice Thrown when the domain does not match the expected domain
   */
  error ConnextSpoke_ProcessFillViaRelayer_WrongDomain();

  /**
   * @notice Thrown when the relayer address doesn't match msg.sender
   */
  error ConnextSpoke_ProcessFillViaRelayer_NotRelayer();

  /**
   * @notice Thrown when the TTL of the message has expired
   */
  error ConnextSpoke_ProcessFillViaRelayer_TTLExpired();

  /**
   * @notice Thrown when trying to bump an intent with a status different of added
   */
  error ConnextSpoke_Bump_InvalidStatus(bytes32 _intentId);

  /*///////////////////////////////////////////////////////////////
                              LOGIC
  //////////////////////////////////////////////////////////////*/

  /**
   * @notice Creates a new intent
   * @param _destination The destination chain of the intent
   * @param _to The destinantion address of the intent
   * @param _inputAsset The asset address on origin
   * @param _outputAsset The asset address on destination
   * @param _amount The amount of the asset
   * @param _data The data of the intent
   * @return _intentId The ID of the intent
   * @return _intent The intent object
   */
  function newIntent(
    uint32 _destination,
    address _to,
    address _inputAsset,
    address _outputAsset,
    uint256 _amount,
    bytes calldata _data
  ) external returns (bytes32 _intentId, Intent memory _intent);

  /**
   * @notice creates a xcall new intent
   * @param _destination the destination chainId
   * @param _to The destination address of the intent
   * @param _inputAsset The asset address on origin
   * @param _outputAsset The asset address on destination
   * @param _amount The amount of the asset
   * @param _maxRoutersFee The maximum fee that can be taken by routers
   * @param _data The data of the intent
   * @return _intentId The ID of the intent
   * @return _intent The intent object
   */
  function xcall(
    uint32 _destination,
    address _to,
    address _inputAsset,
    address _outputAsset,
    uint256 _amount,
    uint24 _maxRoutersFee,
    bytes calldata _data
  ) external returns (bytes32 _intentId, Intent memory _intent);

  /**
   * @notice creates a xcall new intent using ERC20 Permit
   * @param _destination the destination chainId
   * @param _to The destination address of the intent
   * @param _inputAsset The asset address on origin
   * @param _outputAsset The asset address on destination
   * @param _amount The amount of the asset
   * @param _maxRoutersFee The maximum fee that can be taken by routers
   * @param _data The data of the intent
   * @param _permitParams The permit parameters
   * @return _intentId The ID of the intent
   * @return _intent The intent object
   */
  function xcall(
    uint32 _destination,
    address _to,
    address _inputAsset,
    address _outputAsset,
    uint256 _amount,
    uint24 _maxRoutersFee,
    bytes calldata _data,
    PermitParams calldata _permitParams
  ) external returns (bytes32 _intentId, Intent memory _intent);

  /**
   * @notice bumps an intent
   * @param _intent The intent structure
   * @param _amount The amount to bump
   */
  function bump(Intent calldata _intent, uint256 _amount) external payable;

  /**
   * @notice executes an intent
   * @param _intent The intent structure
   * @param _fee The fee paid to cover relaying the message
   * @return _fillMessage The enqueued fill message
   */
  function execute(Intent calldata _intent, uint24 _fee) external returns (FillMessage memory _fillMessage);

  /**
   * @notice fills an intent
   * @param _intent The intent structure
   * @return _fillMessage The enqueued fill message
   */
  function fillIntent(Intent calldata _intent) external returns (FillMessage memory _fillMessage);

  /**
   * @notice Allows a relayer to fill an intent for a router
   * @param _router The address of the router
   * @param _data The data of the intent: abi.encode(Intent, fee)
   * @param _signature The signed data
   * @return _fillMessage The enqueued fill message
   */
  function executeForRouter(
    address _router,
    bytes memory _data,
    bytes memory _signature
  ) external returns (FillMessage memory _fillMessage);

  /**
   * @notice Allows a relayer to fill an intent for a router
   * @param _router The address of the router
   * @param _data The data of the intent: abi.encode(Intent)
   * @param _signature The signature of the intent
   * @return _fillMessage The enqueued fill message
   */
  function fillIntentForRouter(
    address _router,
    bytes memory _data,
    bytes memory _signature
  ) external returns (FillMessage memory _fillMessage);

  /**
   * @notice deposits an asset into the ConnextSpoke
   * @dev should be only called by routers but it is permissionless
   * @param _asset The address of the asset
   * @param _amount The amount of the asset
   */
  function deposit(address _asset, uint256 _amount) external;

  /**
   * @notice withdraws an asset from the ConnextSpoke
   * @dev can be called by routers or users
   * @param _asset The address of the asset
   * @param _amount The amount of the asset
   */
  function withdraw(address _asset, uint256 _amount) external;

  /**
   * @notice Process the intent queue messages to send a batching message to the transport layer
   * @param _amount The amount of messages to process
   */
  function processIntentQueue(uint32 _amount) external payable;

  /**
   * @notice Process the fill queue messages to send a batching message to the transport layer
   * @param _amount The amount of messages to process
   */
  function processFillQueue(uint32 _amount) external payable;

  /**
   * @notice Process the intent queue messages to send a batching message to the transport layer (via relayer)
   * @param _data The data being signed by the lighthouse
   * @param _signature The signature of the data
   */
  function processIntentQueueViaRelayer(bytes memory _data, bytes memory _signature) external;

  /**
   * @notice Process the fill queue messages to send a batching message to the transport layer (via relayer)
   * @param _data The data being signed by the lighthouse
   * @param _signature The signature of the data
   */
  function processFillQueueViaRelayer(bytes memory _data, bytes memory _signature) external;

  /**
   * @notice Updates the gateway
   * @param _newGateway The address of the new gateway
   */
  function updateGateway(address _newGateway) external;

  /**
   * @notice Authorizes an address to receive gas
   * @param _address The address to authorize
   * @param _authorized True if the address is to be authorized
   */
  function authorizeGasReceiver(address _address, bool _authorized) external;

  /*///////////////////////////////////////////////////////////////
                              VIEWS
  //////////////////////////////////////////////////////////////*/

  /**
   * @notice returns the paused status of the spoke
   */
  function paused() external view returns (bool _paused);

  /**
   * @notice returns the balance of an asset for a user
   * @param _asset The address of the asset
   * @param _user The address of the user
   */
  function balances(bytes32 _asset, bytes32 _user) external view returns (uint256 _amount);

  /**
   * @notice returns the call executor
   */
  function callExecutor() external view returns (ICallExecutor __callExecutor);

  /**
   * @notice returns the gateway
   */
  function gateway() external view returns (ISpokeGateway __gateway);

  /**
   * @notice returns the status of an intent
   * @param _intentId The ID of the intent
   */
  function status(bytes32 _intentId) external view returns (IntentStatus __status);

  /**
   * @notice returns the unclaimed balance of an asset
   * @param _asset The address of the asset
   */
  function unclaimed(bytes32 _asset) external view returns (uint256 _amount);

  /**
   * @notice returns the lighthouse address
   */
  function lighthouse() external view returns (address _lighthouse);

  /**
   * @notice returns the watchtower address
   */
  function watchtower() external view returns (address _watchtower);

  /**
   * @notice returns the intent time to live
   */
  function intentTTL() external view returns (uint256 _intentTTL);

  /**
   * @notice returns the max routers fee
   */
  function maxRoutersFee() external view returns (uint24 _maxRoutersFee);

  /**
   * @notice returns the owner address
   */
  function owner() external view returns (address _owner);
}

Last updated