Retrieve Rates
GET/rate
Transactions that involve two non-equivalent on & off-chain assets (such as USDC on Stellar and fiat EUR) must use exchange rates that are communicated to the client application requesting the transaction. When clients make requests to the Platform for these exchange rates, the Platform sends this request to the anchor to fetch it.
Rates can be indicative or firm. The anchor must provide an ID and expiration if the client requests a firm rate.
Anchors can provide discounted rates specific client applications. The Platform includes the client_id parameter
for this reason.
Either sell_amount or buy_amount will be included in requests as parameters, but never both. In the same way,
either sell_delivery_method and buy_delivery_method may be included in requests, but never both, since either
sell_asset or buy_asset is a Stellar asset.
Upon receiving the response, the Anchor Platform will validate the amount and price of the response.
If the validation fails, the Platform will respond to the client application's request with a HTTP status
code of 502 Bad Gateway.
The sell_amount, buy_amount, price, and fee are validated as follows:
- if
rate.feeexists,rate.fee.assetmust have a positive value ofsignificant_decimalsdefined in the asset configuration.rate.fee.totalmust equal to the sum ofrate.fee.details.amount.- if the
rate.fee.asset == rate.sell_asset,sell_amount ~= price * buy_amount + feemust hold true. - if the
rate.fee.asset == rate.buy_asset,sell_amount ~= price * (buy_amount + fee)must hold true.
- if
rate.feedoes not exist,sell_amount ~= price * buy_amountmust hold true.
The ~= is defined as equality within rounding error.
The rounding error is defined as 10^(-significant_decimals)
Request
Responses
- 200
- 422
- 500
Success.
Unprocessable Entity. This status should be returned when the anchor understood the request but cannot
return a success response.
In these cases, the Platform will respond to the client application's request with a 400 Bad Request
and include the error message provided by the anchor in the response body.
Error. The Platform will respond to the client application with the same response code and body.