Skip to main content

JBCCIPSucker

Git Source

Inherits: JBSucker, IAny2EVMMessageReceiver

A JBSucker implementation to suck tokens between chains with Chainlink CCIP

State Variables

CCIP_ROUTER

ICCIPRouter public immutable CCIP_ROUTER;

REMOTE_CHAIN_ID

uint256 public immutable REMOTE_CHAIN_ID;

REMOTE_CHAIN_SELECTOR

uint64 public immutable REMOTE_CHAIN_SELECTOR;

Functions

constructor

constructor(
JBCCIPSuckerDeployer deployer,
IJBDirectory directory,
IJBTokens tokens,
IJBPermissions permissions,
JBAddToBalanceMode addToBalanceMode,
address trusted_forwarder
)
JBSucker(directory, permissions, tokens, addToBalanceMode, trusted_forwarder);

Parameters

NameTypeDescription
deployerJBCCIPSuckerDeployerA contract that deploys the clones for this contracts.
directoryIJBDirectoryA contract storing directories of terminals and controllers for each project.
tokensIJBTokensA contract that manages token minting and burning.
permissionsIJBPermissionsA contract storing permissions.
addToBalanceModeJBAddToBalanceModeThe mode of adding tokens to balance.
trusted_forwarderaddress

peerChainId

Returns the chain on which the peer is located.

function peerChainId() external view virtual override returns (uint256 chainId);

Returns

NameTypeDescription
chainIduint256of the peer.

getRouter

Return the current router

function getRouter() public view returns (address);

Returns

NameTypeDescription
<none>addressCCIP router address

supportsInterface

IERC165 supports an interfaceId

Should indicate whether the contract implements IAny2EVMMessageReceiver e.g. return interfaceId == type(IAny2EVMMessageReceiver).interfaceId || interfaceId == type(IERC165).interfaceId This allows CCIP to check if ccipReceive is available before calling it. If this returns false or reverts, only tokens are transferred to the receiver. If this returns true, tokens are transferred and ccipReceive is called atomically. Additionally, if the receiver address does not have code associated with it at the time of execution (EXTCODESIZE returns 0), only tokens will be transferred.

function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool);

Parameters

NameTypeDescription
interfaceIdbytes4The interfaceId to check

Returns

NameTypeDescription
<none>booltrue if the interfaceId is supported

ccipReceive

The entrypoint for the CCIP router to call. This function should never revert, all errors should be handled internally in this contract.

Extremely important to ensure only router calls this.

function ccipReceive(Client.Any2EVMMessage calldata any2EvmMessage) external override;

Parameters

NameTypeDescription
any2EvmMessageClient.Any2EVMMessageThe message to process.

_isRemotePeer

Unused in this context.

function _isRemotePeer(address sender) internal view override returns (bool _valid);

_sendRootOverAMB

function _sendRootOverAMB(
uint256 transportPayment,
uint256,
address token,
uint256 amount,
JBRemoteToken memory remoteToken,
JBMessageRoot memory sucker_message
)
internal
override;

Parameters

NameTypeDescription
transportPaymentuint256the amount of msg.value that is going to get paid for sending this message.
<none>uint256
tokenaddressThe token to bridge the outbox tree for.
amountuint256
remoteTokenJBRemoteTokenInformation about the remote token being bridged to.
sucker_messageJBMessageRoot

_validateTokenMapping

Allow sucker implementations to add/override mapping rules to suite their specific needs.

function _validateTokenMapping(JBTokenMapping calldata map) internal pure virtual override;

Errors

JBCCIPSucker_FailedToRefundFee

error JBCCIPSucker_FailedToRefundFee();

JBCCIPSucker_InvalidRouter

error JBCCIPSucker_InvalidRouter(address router);

JBCCIPSucker_UnexpectedAmountOfTokens

error JBCCIPSucker_UnexpectedAmountOfTokens(uint256 nOfTokens);