quotes-service

command
v0.0.0-...-1305305 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 30, 2021 License: Apache-2.0 Imports: 32 Imported by: 0

README

quotes-service

Global asynchronous quote service

Motivation:

The concept is to make the Quote service a fully independent service, sitting outside API Service. This change will mean that the RFI and OFI back-ends talk to the Quote Service without the postbox in the middle. The Advantage of having global quote service are:

  1. Enable the dispute resolutions between RFI/OFI
  2. Fast

Quotes Handler

RFI will do a GET request to the Quote service for a set of quotes using the same payload as we've had. This call can be synchronous as what's returned to the RFI is an acknowledgement of the Quote and a Quote ID generated by Quote service.

Quote service will query the PR or the directory to find the RFIs that can give quotes.

Quote service will make asynchronous calls (multi-threaded) to as many RFIs as needed, and pass along the Quote ID. These would probably be the same as the callback APIs today, but the implementation will now be asynchronous.

RFIs will take their time to create the quotes, and then call Quotes service with a POST for with the Quote ID, and the Quote they are giving.

Quote service will time stamp these quotes as they arrive.

OFI can call a GET endpoint with the Quote ID as often as they wish to retrieve the set of latest quotes.

RFI can cancel the quotes by calling a DELETE endpoint on the Quotes service.

RFI can get a list of quotes they've made using a GET endpoint.

Exchange Handler

Regarding to the exchange module within the quotes-service(NQS) , the process will be as follow:

  1. the OFI backend initiating a execution request with its own signature attached to the NQS.

  2. the NQS will verified the quote status in the quoteDB (prevent replay attack and concurrency issue). NQS then request the gas service for <IBM gas account, sequence number>.

  3. the quotes-service then send the <IBM gas account, sequence number> and the OFI's signature in the 1st step to the OFI's signing service. the signing service will then verify its own signature then response the NQS's request synchronously with the signed XDR.

  4. the NQS then send the OFR's signed XDR to the RFI signing service with the signed quote response in the quoteDB. the RFI's signing service then verify its own signature of the quote, then response back to NQS with its signed XDR synchronously.

  5. the NQS received the signed XDR by OFI and RFI, and the send it to gas service.

  6. the gas service will then perform another signing and send it to stellar core.

Quote Status

The quotes stutus are defined as the following: 1 = pending, 2 = updated, 3 = executing 4 = executed, 98 = failed 99 = cancelled

##Base64 Encoding of requests:

Encoding the Exchange Request to base64 string:
let exchange = {
   "account_name_receive":"issuing",
   "account_name_send":"issuing",
   "amount":1,
   "quote":   {
      "account_name_receive":"issuing",
      "account_name_send":"issuing",
      "exchange_rate":0.6046602,
      "limit_max":1000,
      "quote_id":"5d4fded4-170d-4e83-aad9-0f4420b78e33hk.one.payments.worldwire.io",
      "quote_request":{
         "limit_max":2000,
         "limit_min":1,
         "ofi_id":"hk.one.payments.worldwire.io",
         "source_asset":{
            "asset_code":"SGDDO",
            "asset_type":"DO",
            "issuer_id":"ie.one.payments.worldwire.io"
            
         },
         
         "target_asset":{
            "asset_code":"THBDO",
            "asset_type":"DO",
            "issuer_id":"hk.one.payments.worldwire.io"
         },
         "time_expire":1644516034
      },
      "rfi_id":"ie.one.payments.worldwire.io",
      "time_expire":1644516034,
      "time_start":1544516034
   }
}

let exchangeJsonStr = JSON.stringify(exchange);
let exchangeJsonB64 = Buffer.from(exchangeJsonStr).toString("base64");

Crypto service url

Since the crypto service is a internal service: The url of the cryto service will be dynamic generated instead of residing in the Participant Registry. the proposed url format would be: {participate.ID}-cryptoservice:10042

Alternatives considered using para/secret manager in that case we can omit the latency of hitting secret manager if the link is dynamically generate

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL