How To Integrate

Overview

Solvers on the network receive information via continuous GET requests on Mystic's API to know when an instant redemption request or liquidation happens. They then sign and send a quote with the price they offer to settle the trade at. Mystic will then choose the one with the best price, give it the trade and settle the transaction. Here we go over how a solver can integrate with Mystic to receive our trade requests and send us their bids. There are 4 steps to follow:

  • Register as a Solver;

  • Query Requests;

  • (Optional) Approve the Mystic contract;

  • Sign and send quote.

Let us now look at how to do each one.

Register as a Solver

Anyone can see open RFQs, but only registered Solvers can bid on them. To participate in the Mystic RFQ process, you first need to register as a Solver with our team. It's a straightforward process, all we need is your firm's name, the address of the wallet you'll be bidding with (and on what chain) and a general awareness of what RFQ's interest you. To register as a Solver, contact us via emailenvelope.

Query Redemption Requests

To see all requests you can bid on at any moment, all you have to do is query this API endpoint according to our API Referencearrow-up-right:

https://api.mysticfinance.xyz/redemption/requests

This is the response you would receive, assuming you see only one redemption request for WPLUME:

Once you see all the available opportunities, you can start defining a thesis around which ones you want to bid on and which ones you do not. After you know on which RFQ's you want to start participating in, you can now start automatically sending us quotes when you receive relevant RFQ's.

(Optional) Approve Contract

You will need to approve Mystic's contract so it can take assets from your wallet when you win RFQs. You can either choose to do an unlimited approval of the relevant contract address once before you start bidding, or do it for smaller amounts every time you bid. We advise you to approve it once, as it will make bidding easier for you moving forward.

Here is a code sample of how you can approve contract via code by referencing variables available in Query Redemption Requests:

Sign Order

For your quote to be able to fill an RFQ, you need first sign the respective order. You will be signing and sending a quote every time you wish to participate in an RFQ. Here is a code sample of how you sign one:

Send Quotes

To send us a quote, you need to both sign and send us a response via POST request to the following endpoint:

Assuming you have already signed as per the code sample in the previous section, this is the format that the POST request you're sending should be in, which includes the signature above:

Do note:

  • The price you are quoting is calculated as takerAmount/makerAmount;

  • maker is your own address, with which you first registered as a Solver;

  • Responses must be sent before the expiry date in the request for quote (1760089073 in the example above).

Winner Selection

When the request for quote hits its expiry date, Mystic selects the bid with the best price and awards it the trade. We then use the winning bid's details to create an RFQ object which will be used to fill the order on-chain. As such, once the RFQ object is created, Mystic fills the trade with the winning bid by bundling settlement and fee distribution. At once, two things happen:

  • RFQ order fill - effectively taking the redemption asset from the Solver and giving it to the user and taking the redeem asset from the user and giving it to the Solver.

  • Fee settlement - taking the protocol fee and sending the remaining assets to the Solver.

Once this is done, Mystic updates the losing bids to Rejected , the winning bid to Accepted and the redemption request to Completed.

Last updated