Rujira.Fin.Order (rujira_ex v0.0.4)

Copy Markdown View Source

Trading order for the FIN protocol.

Struct, construction, and queries. Use Rujira.Fin as the public API.

Summary

Functions

Memoized fetch of a single order by (owner, side, price) on a contract.

Memoized full fetch of orders on a contract, optionally filtered by owner.

Types

deviation()

@type deviation() :: nil | integer()

side()

@type side() :: :base | :quote

t()

@type t() :: %Rujira.Fin.Order{
  deviation: deviation(),
  filled: Rujira.Amount.t(),
  filled_fee: Rujira.Amount.t(),
  filled_value: Rujira.Amount.t(),
  id: String.t() | nil,
  offer: Rujira.Amount.t(),
  offer_value: Rujira.Amount.t(),
  owner: String.t() | nil,
  pair: String.t() | nil,
  rate: Decimal.t(),
  remaining: Rujira.Amount.t(),
  remaining_value: Rujira.Amount.t(),
  side: side() | nil,
  type: type_order() | nil,
  updated_at: DateTime.t() | nil,
  value_usd: Rujira.Amount.t()
}

type_order()

@type type_order() :: :fixed | :oracle

Functions

from_id(id)

@spec from_id(String.t()) :: {:ok, t()} | {:error, term()}

list(pair, owner \\ nil, limit \\ nil)

@spec list(Rujira.Fin.Pair.t(), String.t() | nil, integer() | nil) ::
  {:ok, [t()]} | {:error, term()}

list_all_pairs(address)

@spec list_all_pairs(String.t()) :: {:ok, [t()]} | {:error, term()}

load(pair, side, price, owner)

@spec load(Rujira.Fin.Pair.t(), String.t(), String.t(), String.t()) ::
  {:ok, t()} | {:error, term()}

new(map1, map2)

@spec new(Rujira.Fin.Pair.t(), map()) :: {:ok, t()} | {:error, term()}

query(t1, t2, t3, t4)

@spec query(String.t(), String.t(), String.t(), String.t()) ::
  {:ok, map()} | {:error, term()}

Memoized fetch of a single order by (owner, side, price) on a contract.

Invalidate with Memoize.invalidate(Rujira.Fin.Order, :query, [address, owner, side, price]).

query_orders(t1, t2)

@spec query_orders(String.t(), String.t() | nil) :: {:ok, [map()]} | {:error, term()}

Memoized full fetch of orders on a contract, optionally filtered by owner.

Returns the flat list of raw order maps from the chain, paginated internally. Invalidate with Memoize.invalidate(Rujira.Fin.Order, :query_orders, [contract, owner]).