How does it work?
When a user wishes to bridge, they submit an order and a transfer to the Relay solver, who validates the order and sends the funds to the user on the destination chain. Relay maintains a balance on all chains in order to make executions, and then periodically rebalances to ensure there is sufficient liquidity on all chains. In the rare case of a transaction failure, Relay refunds the user directly as soon as possible. While this model requires trust in Relay as a service provider, it reduces the costs of executing cross-chain actions to an absolute minimum. Since each cross-chain action is simply an origin chain transfer and a destination chain transfer (42000 gas total), it is substantively cheaper than bridging on other bridges.Why start with a trusted system?
The current state of Relay, which requires trust in Relay’s solver, is an important part of the protocol development process. It is not intended as a final state of the system, but as a way to introduce the core concepts, and learn from users, developers, and relayers about what is most important in the future decentralized system. If you are interested in learning more about where Relay is headed, you can read the protocol overview here.Technical overview
Here we walk through some technical details about how the Relay solver functions.Getting a quote
When a user wishes to Relay, the application receives an order (quote) from the Relay SDK/API. The quote returns both a cost for execution, and an expected time. The quote is a total value required by the user for the action to proceed. The quote encompasses the execution value, the estimated destination chain gas fee, and the relayer fee. This quote covers the gas cost on the destination chain. The transfer call data for order acceptance is also included in the returned data.Quote Execution Flow:
- User gets a quote.
- User submits the quote, the solver will revalidate the quote to get up to date fees.
- If the recomputed quote is lower than the minimum amount, the refund flow is triggered.
- If the recomputed quote is higher than or equal to the original quote, the solver proceeds with filling the quote.
- In the refund case, the user is refunded on the origin chain.
Onchain order attribution
When the user accepts the order, they submit a transfer to the solver. An order ID associated with the quote is appended in the tx calldata. This order ID will be used on the destination chain to link fills across chains.Order validation and filling
Upon validation of the inbound transfer transaction, the Relay solver will fill the order on the destination chain. Included in the fill transaction is the order ID associated with the quote. Relay maps the origin and destination chain transactions together by order ID to ensure the transaction is filled appropriately.Rebalancing
The Relay solver uses a robust rebalancing algorithm to make sure funds are as available as possible for cross-chain executions. The user is not responsible for any rebalancing activity. If the Relay solver becomes “off-balance”, the capacity for instant relaying may be limited.Refunds
If for some reason the quoted execution is no longer available by the time of relay submission, the user may be refunded. Refunds are as instant as possible and are refunded on the destination chain by default, and the origin chain otherwise. TherefundOnOrigin param can be passed into the bridge/call apis and sdk actions to override the refund logic.