All projects

CRE CCIP Relayer

Instantly relays CCIP token transfers using the CRE as a source of truth

DeFi & Tokenization

What it is

DeFi users expect immediate cross-chain transfers, but secure bridges must await finality before each transfer. Relayers fill this gap by sending funds immediately to the user, to be later reimbursed by the underlying bridge. Using the Chainlink Runtime Environment, a relayer-endpoint system can be quickly deployed on any blockchain with CCIP v1.6 OnRamp contracts.

Previously I built Chronomancer, a cross-chain relaying bot, during the Block Magic hackathon. A CRE-based solution addresses several weaknesses of that system:

  • Liquidity providers no longer need to download and run a bot; they can simply deposit tokens on the endpoint contract.

  • Liquidity can now be safely pooled, because the CRE acts as a trusted forwarder of CCIP messages pulled from OnRamp contracts.

  • Bots no longer compete to fill orders, eliminating redundant transactions and wasted gas.

Additionally, because of CCIP v1.6, the relayer endpoint can now immediately serve any outgoing transfer of any CCIP-enabled token from any monitored OnRamp, without complex lane and token configuration.

Simply define in your workflow which OnRamp you want to monitor and which endpoints you want to serve, and deploy.

How it Works

The workflow starts with a Log Trigger: CRE monitors an OnRamp contract to catch CCIPMessageSent events, from which it grabs outgoing EVM2AnyRampMessages. From the message header it reads the destChainSelector to determine the destination chain, and then checks if the receiver is the relayer endpoint contract deployed on that chain. If it's a match, CRE performs an EVM Write, relaying the message to the endpoint, where a transfer takes place if sufficient liquidity is available.

Liquidity provision uses a simple Uniswap v2 inspired model, where LPers obtain shares of the liquidity pool by depositing tokens. Whenever a transfer is relayed, a small fee is assessed, growing the liquidity pool slightly without increasing the number of shares -- thereby paying the liquidity providers for the service. Although the available "float" of the pool will vary, the underlying assets are tracked by the contract and solvency is guaranteed by incoming CCIP messages reimbursing all funds sent out by the pool. LPers can withdraw at any time, as long as liquidity is available.

Links

Created by

  • Cactus