Workflow

The end-to-end flow for Peti xRFQ

Without loss of generality, consider a cross-chain swap request: Swap token X on Chain A for token Y on Chain B. This swap request is referred to as an RFQ order.

Core Flow (cooperative case)

Below is the diagram for the Peti RFQ core flow where both the user and the market maker are cooperative. Note that the RFQ server is a centralized server.

Step 1

The user sends a quote request to the RFQ server. The request should specify the source chain, destination chain, source token, destination token, and the swap amount. Moreover, the request should specify two deadlines.

  1. Source submission deadline. The user must submit the order and lock his fund on the source chain contract before the src submission deadline; otherwise the quote expires and the tx will fail on-chain.

  2. Destination fund release deadline. The market maker must release the fund to the user before the destination release deadline; otherwise the RFQ order will become refundable.

Step 2

The RFQ server will forward the quote request to a set of whitelisted market makers.

Step 3

Each market maker decides if they would like to respond to a quote. If yes, the market maker should send a quote response to the RFQ server. Upon receiving the quotes, the RFQ server will select the one with the highest destination token amount and notify the corresponding market maker. The selected market maker should sign the quote response and send it back to the RFQ server.

Step 4

The RFQ server sends the signed quote response to the user.

Step 5

On the source chain, the user submits the signed quote on-chain and locks his source token in the RFQ contract. Note that this should be submitted on-chain before the source submission deadline. If the user submits the tx after the source submission deadline, the on-chain tx will fail. This on-chain tx will also send a cross-chain msg (cross-chain msg #1) to the destination chain (via Celer IM), indicating that the user has locked the funds for the order on the source chain and that the market maker may release the funds on the destination chain.

Step 6

On the destination chain, the market maker submits an on-chain tx which executes msg #1 and releases the destination tokens to the user. Note that this on-chain tx should be submitted before the destinationr release deadline. After the destination release deadline, if the fund is not yet released, the RFQ order will become refundable and a refund cross-chain msg may be sent back to the src chain if the tx was submitted after the destination release deadline, the tx should fail on-chain

This on-chain tx will also send a cross-chain msg (cross-chain msg #2) to the src chain, indicating that the destination token has been released to the user on the destination chain and that the source chain RFQ contract can release the funds to the market maker.

Step 7

On the source chain, the market maker submits an on-chain tx which executes cross-chain msg #2 and releases the funds to the market maker.

Refund Flow (non-cooperative case)

On the destination chain, if the market maker failed to release the correct amount of funds to the user before the destination release deadline, the order will become refundable. There is an RFQ sentinel process that constantly monitors such refundable orders and sends a refund cross-chain msg back to the source chain (cross-chain msg #3). The user can then execute the msg and get refunded on the source chain.

Last updated