Documentation Index
Fetch the complete documentation index at: https://unevenlabs-ted-add-execute-bridge.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Introduction
Relay Protocol is a cross-chain payments system that connects users to relayers willing to perform onchain actions on their behalf. Relay’s design minimizes gas costs, enables rapid chain expansion, and maximizes capital efficiency, all while remaining open and trustless. Such a system is particularly well suited for low-value, high frequency cross-chain actions such as those expected in a world of chain abstraction.Background: Cross-Chain Relaying
Relay is similar to other “intent-based” protocols like Across, where liquidity providers known as Relayers use their own capital to “fast fill” user requests to move between chains, and then rebalance using slow, expensive bridges under the hood. This design has two key advantages over typical bridging:- Speed - Because relayers are fronting their own capital, they can take on confirmation risk and fill optimistically, without waiting for global consensus
- Cost - Because rebalancing is done infrequently and in batches, the security cost of using bridges is amortized across many users
- User escrows funds on the origin chain
- Relayer fills the order on the destination chain
- Relayer later settles the order on the origin, to claim payment
Each of these steps has a cost, which different protocols minimize in different ways. Across, which pioneered this design, reduces the cost of settlement with two optimizations:
- Instead of proving every fill with an oracle or cross-chain message, settlement is done optimistically, by assuming it is correct, and having a challenge period
- Settlement is done in large batches across the whole protocol, every 4 hours
Relay’s Design
Relay shares the same core components as as other escrow systems: escrow, fulfillment, settlement, and payment. However, it changes who, how and where they are executed, to improve efficiency.Settlement Chain
The key difference is that instead of users depositing funds into escrow on every chain that they want to pay from, relayers deposit into escrow on a single dedicated “Settlement Chain”. A number of significant benefits flow from this change:- Gas efficiency - Because users aren’t the ones escrowing funds, they can send payment directly to the relayer as an efficient raw transfer (only 21,000 gas)
- Deployment efficiency - Because all escrow and settlement happens on a single dedicated chain, supporting new origin / destination chains is much simpler
- Capital efficiency - Because this settlement chain can be a low-cost L2, orders can be settled immediately, preventing relayer capital from being locked up for hours
- Fee efficiency - Because relayers hold ETH on this low-cost L2, granular fees can be paid out with near-zero overhead
Direct Transfers
In Relay, the flow becomes:- Relayers escrow funds on the “Settlement Chain”
- User sends payment directly to the relayer wallet on the origin
- Relayer fills directly to the user wallet on the destination
- Relayer later settles, freeing their escrow to be used again in a future order
The biggest unlock from this is that because the relayer’s escrowed funds act as a bond, the user and relayer can safely make direct transfers to each other, reducing the deposit and fill to highly efficient direct transfers (~21,000 gas each). This makes it up to 5x cheaper than alternative relaying protocols.
This can make a huge difference to the sort of use-cases that are possible to implement cross-chain, especially when transaction values are low (e.g. $1 NFT mints).
Intuitively, it might seem insecure to send funds directly to the relayer, but the risk and UX is similar to the typical flow:
- User is transferring funds into a state where they no longer control them
- The full value of their transaction is locked in escrow as collateral
- In the event of the failure, user has a mechanism to get refunded, after a delay
Single Contract
Interoperability protocols are often slow in expanding to new chains for a number of reasons:- Global consensus must be achieved amongst a set of validators or token holders to begin supporting a chain
- Canonical smart contracts need to be deployed and managed on every supported chain by the core team
- Liquidity pools need sufficient depth to offer good prices
Immediate Settlement
Another advantage of having all settlement happen on a single chain is that you can choose a chain with optimal properties. On other protocols, where settlement happens on all chains, including high-security chains like Ethereum, batch settlement is critical to keep costs low. However, batch settlement has downsides:- Capital inefficiency - Relayer funds are tied up in between batches (4 hours for Across)
- Inflexibility - All orders must use the same settlement mechanism
Relay ETH
One major factor that needs to be considered when striving to reduce costs is the efficient collection of fees. It’s quite common for fees to be collected by various actors in the order pipeline, beyond just the relayer:- Protocol fees
- Interface / wallet fees
- Aggregator API fees
- Referrer fees
- User pays 1.003 to relayer on origin
- Relayer pays 1 to user on destination
- 0.002 in fees taken out of relayer balance on settlement chain
- Users can hold it, and use it as a low-cost cross-chain spending balance
- Unspent gas can be rebated as Relay ETH, removing the need for relayers to factor destination gas fluctuations in their quotes