View Source Stellar.Horizon.Offers (Elixir Stellar SDK v0.7.1)
Exposes functions to interact with Offers in Horizon.
You can:
- Retrieve an offer.
- List all offers.
- List an offer's trades.
Horizon API reference: https://developers.stellar.org/api/resources/offers/
Link to this section Summary
Functions
Lists all currently open offers.
Lists all trades for a given offer.
Retrieves information of a specific offer.
Link to this section Types
@type offer_id() :: String.t()
@type options() :: Keyword.t()
@type resource() :: Stellar.Horizon.Offer.t() | Stellar.Horizon.Collection.t()
@type response() :: {:ok, resource()} | {:error, Stellar.Horizon.Error.t()}
Link to this section Functions
Lists all currently open offers.
options
Options
sponsor: The account ID of the sponsor who is paying the reserves for all the offers included in the response.seller: The account ID of the offer creator.selling_asset_type: The type for the selling asset. Eithernative,credit_alphanum4, orcredit_alphanum12.selling_asset_issuer: The account ID of the selling asset’s issuer.selling_asset_code: The code for the selling asset.buying_asset_type: The type for the buying asset. Eithernative,credit_alphanum4, orcredit_alphanum12.buying_asset_issuer: The account ID of the buying asset’s issuer.buying_asset_code: The code for the buying asset.cursor: A number that points to a specific location in a collection of responses and is pulled from thepaging_tokenvalue of a record.order: A designation of the order in which records should appear. Options includeasc(ascending) ordesc(descending).limit: The maximum number of records returned. The limit can range from 1 to 200. Defaults to 10.
examples
Examples
iex> Offers.all(limit: 20, order: :asc)
{:ok, %Collection{records: [%Offer{}, ...]}}
# list by sponsor
iex> Offers.all(sponsor: "GCXMWUAUF37IWOOV2FRDKWEX3O2IHLM2FYH4WPI4PYUKAIFQEUU5X3TD")
{:ok, %Collection{records: [%Offer{}, ...]}}
# list by seller
iex> Offers.all(seller: "GCXMWUAUF37IWOOV2FRDKWEX3O2IHLM2FYH4WPI4PYUKAIFQEUU5X3TD", order: :desc)
{:ok, %Collection{records: [%Offer{}, ...]}}
# list by selling_asset_issuer
iex> Offers.all(selling_asset_issuer: "GCXMWUAUF37IWOOV2FRDKWEX3O2IHLM2FYH4WPI4PYUKAIFQEUU5X3TD", limit: 20)
{:ok, %Collection{records: [%Offer{}, ...]}}
# list by buying_asset_type and buying_asset_code
iex> Offers.all(buying_asset_type: "credit_alphanum4", buying_asset_code: "TEST")
{:ok, %Collection{records: [%Offer{}, ...]}}
Lists all trades for a given offer.
parameters
Parameters
offer_id: The unique identifier for the offer.
options
Options
cursor: A number that points to a specific location in a collection of responses and is pulled from thepaging_tokenvalue of a record.order: A designation of the order in which records should appear. Options includeasc(ascending) ordesc(descending).limit: The maximum number of records returned. The limit can range from 1 to 200. Defaults to 10.
examples
Examples
iex> Offers.list_trades(165563085, limit: 20)
{:ok, %Collection{records: [%Trade{}, ...]}}
Retrieves information of a specific offer.
parameters
Parameters:
offer_id: The unique identifier for the offer.
examples
Examples
iex> Offers.retrieve(165563085)
{:ok, %Offer{}}