Stellar PHP SDK API Documentation

QuoteService
in package

Implements SEP-0038 - Anchor RFQ API v2.5.0.

This service provides indicative and firm quotes for asset exchanges between Stellar assets and off-chain assets. Supports SEP-10/SEP-45 authentication for protected endpoints.

Tags
see

SEP-0038 Specification

Table of Contents

Methods

__construct()  : mixed
Constructor.
fromDomain()  : QuoteService
Creates an instance of this class by loading the anchor quote server SEP-38 url from the given domain stellar toml file (ANCHOR_QUOTE_SERVER).
getQuote()  : SEP38QuoteResponse
This endpoint can be used to fetch a previously-provided firm quote by id.
info()  : SEP38InfoResponse
This endpoint returns the supported Stellar assets and off-chain assets available for trading.
postQuote()  : SEP38QuoteResponse
This endpoint can be used to request a firm quote for a Stellar asset and off-chain asset pair.
price()  : SEP38PriceResponse
This endpoint can be used to fetch the indicative price for a given asset pair.
prices()  : SEP38PricesResponse
This endpoint can be used to fetch the indicative prices of available off-chain assets in exchange for a Stellar asset and vice versa.

Methods

__construct()

Constructor.

public __construct(string $serviceAddress[, Client|null $httpClient = null ]) : mixed
Parameters
$serviceAddress : string

for the server (ANCHOR_QUOTE_SERVER in stellar.toml).

$httpClient : Client|null = null

to be used for requests. If not provided, this service will use its own http client.

fromDomain()

Creates an instance of this class by loading the anchor quote server SEP-38 url from the given domain stellar toml file (ANCHOR_QUOTE_SERVER).

public static fromDomain(string $domain[, Client|null $httpClient = null ]) : QuoteService
Parameters
$domain : string

to load the service address from.

$httpClient : Client|null = null
Tags
throws
Exception

if the loading of the service address for the given domain failed.

Return values
QuoteService

the initialized QuoteService

getQuote()

This endpoint can be used to fetch a previously-provided firm quote by id.

public getQuote(string $id, string $jwt) : SEP38QuoteResponse
Parameters
$id : string

of the quote to load.

$jwt : string

JWT token obtained with SEP-10/SEP-45 authentication.

Tags
throws
GuzzleException
throws
SEP38BadRequestException
throws
SEP38NotFoundException
throws
SEP38PermissionDeniedException
throws
SEP38UnknownResponseException
Return values
SEP38QuoteResponse

Object containing the response data.

info()

This endpoint returns the supported Stellar assets and off-chain assets available for trading.

public info([string|null $jwt = null ]) : SEP38InfoResponse

See: https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0038.md#get-info

Parameters
$jwt : string|null = null

Optional JWT token obtained with SEP-10/SEP-45 authentication.

Tags
throws
GuzzleException
throws
SEP38BadRequestException
throws
SEP38UnknownResponseException
Return values
SEP38InfoResponse

object containing the response data.

postQuote()

This endpoint can be used to request a firm quote for a Stellar asset and off-chain asset pair.

public postQuote(SEP38PostQuoteRequest $request, string $jwt) : SEP38QuoteResponse
Parameters
$request : SEP38PostQuoteRequest

request Data.

$jwt : string

JWT token obtained with SEP-10/SEP-45 authentication.

Tags
throws
GuzzleException
throws
SEP38BadRequestException
throws
SEP38PermissionDeniedException
throws
SEP38UnknownResponseException
Return values
SEP38QuoteResponse

Object containing the response data.

price()

This endpoint can be used to fetch the indicative price for a given asset pair.

public price(string $context, string $sellAsset, string $buyAsset[, string|null $sellAmount = null ][, string|null $buyAmount = null ][, string|null $sellDeliveryMethod = null ][, string|null $buyDeliveryMethod = null ][, string|null $countryCode = null ][, string|null $jwt = null ]) : SEP38PriceResponse

See: https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0038.md#get-price The client must provide either sellAmount or buyAmount, but not both.

Parameters
$context : string

The context for what this quote will be used for. Must be one of 'sep6', 'sep24', or 'sep31'.

$sellAsset : string

The asset the client would like to sell. Ex. stellar:USDC:G..., iso4217:ARS

$buyAsset : string

The asset the client would like to exchange for sellAsset.

$sellAmount : string|null = null

Optional, the amount of sellAsset the client would like to exchange for buyAsset.

$buyAmount : string|null = null

Optional, the amount of buyAsset the client would like to exchange for sellAsset.

$sellDeliveryMethod : string|null = null

Optional, one of the name values specified by the sell_delivery_methods array for the associated asset returned from GET /info. Can be provided if the user is delivering an off-chain asset to the anchor but is not strictly required.

$buyDeliveryMethod : string|null = null

Optional, one of the name values specified by the buy_delivery_methods array for the associated asset returned from GET /info. Can be provided if the user intends to receive an off-chain asset from the anchor but is not strictly required.

$countryCode : string|null = null

Optional, The ISO 3166-2 or ISO-3166-1 alpha-2 code of the user's current address. Should be provided if there are two or more country codes available for the desired asset in GET /info.

$jwt : string|null = null

Optional JWT token obtained with SEP-10/SEP-45 authentication.

Tags
throws
GuzzleException
throws
SEP38BadRequestException
throws
SEP38UnknownResponseException
Return values
SEP38PriceResponse

Object containing the response data.

prices()

This endpoint can be used to fetch the indicative prices of available off-chain assets in exchange for a Stellar asset and vice versa.

public prices(string $sellAsset, string $sellAmount[, string|null $sellDeliveryMethod = null ][, string|null $buyDeliveryMethod = null ][, string|null $countryCode = null ][, string|null $jwt = null ]) : SEP38PricesResponse
Parameters
$sellAsset : string

The asset you want to sell, using the Asset Identification Format.

$sellAmount : string

The amount of sell_asset the client would exchange for each of the buy_assets.

$sellDeliveryMethod : string|null = null

Optional, one of the name values specified by the sell_delivery_methods array for the associated asset returned from GET /info. Can be provided if the user is delivering an off-chain asset to the anchor but is not strictly required.

$buyDeliveryMethod : string|null = null

Optional, one of the name values specified by the buy_delivery_methods array for the associated asset returned from GET /info. Can be provided if the user intends to receive an off-chain asset from the anchor but is not strictly required.

$countryCode : string|null = null

Optional, The ISO 3166-2 or ISO-3166-1 alpha-2 code of the user's current address. Should be provided if there are two or more country codes available for the desired asset in GET /info.

$jwt : string|null = null

Optional JWT token obtained with SEP-10/SEP-45 authentication.

Tags
throws
GuzzleException
throws
SEP38BadRequestException
throws
SEP38UnknownResponseException
Return values
SEP38PricesResponse

Object containing the response data.


        
On this page

Search results