Rujira.Fin.Range (rujira_ex v0.0.4)

Copy Markdown View Source

Concentrated liquidity position (range) for the FIN protocol.

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

Summary

Functions

Parses a range from a contract query response.

Memoized fetch of a single range by idx on a contract.

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

Types

t()

@type t() :: %Rujira.Fin.Range{
  ask: Decimal.t(),
  base: Rujira.Amount.t(),
  bid: Decimal.t(),
  fee: Decimal.t(),
  fees_base: Rujira.Amount.t(),
  fees_quote: Rujira.Amount.t(),
  high: Decimal.t(),
  id: String.t() | nil,
  idx: integer() | nil,
  low: Decimal.t(),
  owner: String.t() | nil,
  pair: String.t() | nil,
  price: Decimal.t(),
  quote: Rujira.Amount.t(),
  skew: Decimal.t(),
  spread: Decimal.t(),
  value_usd: Rujira.Amount.t()
}

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(owner \\ nil, contracts \\ nil)

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

load(pair, idx)

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

new(map1, map2)

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

Parses a range from a contract query response.

When called with a string address and integer index, creates a minimal range struct for subscription edge responses.

query(t1, t2)

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

Memoized fetch of a single range by idx on a contract.

Invalidate with Memoize.invalidate(Rujira.Fin.Range, :query, [address, idx]).

query_ranges(t1, t2)

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

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

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

total_tvl()

@spec total_tvl() :: {:ok, non_neg_integer()} | {:error, term()}

tvl(pair)

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