Creating Quotes
When you receive an RFQ message, you’ll want to do the following:
- Store the
RFQmessage in your database - Get the
Offeringspecified byofferingIdin theRFQ - Create a
Quoteand store it in your database
Store RFQ message
An RFQ is the first message of an exchange.
When a Wallet application sends your PFI an RFQ message, your server's onCreateExchange() callback parameter will be invoked.
This is where you should implement your business logic for determining the customer's exact Quote.
As a best practice, store the RFQ message in your Exchanges database so that both you and the Wallet app can access it.
Get the Offering
After inserting the RFQ into your database, you can search your database for the Offering the RFQ is requesting.
RFQs contain a required offeringId field that you pass to your Offerings API provider’s getOffering() method to obtain the exact Offering.
Building on the example from the Exchange API Provider section, your code might look like this:
Verify Credentials
Upon receiving an RFQ, the tbDEX SDK will automatically verify the submitted credentials to guarantee their integrity and authenticity as well as ensure that they meet the requiredClaims specified in the Offering.
Create a Quote
Before creating a Quote in response to the received RFQ, you can review the protocol definition for Quotes.
With that in mind, you can then create your quote using the Quote.create() method as shown below:
With the Quote created, you’ll then sign it for authorization purposes and write it to your own database: