Kujira.Fin.Trade (kujira v0.1.51)

An individual trade on an individual pair. For a market swap where orders at multiple price points are consumed, the trade is aggregated across all orders at each price.

Fields

  • :id - A unique ID for the trade; "#{txhash}-#{idx}"

  • :pair - The pair the trade was executed on

  • :price - The price the trade was executed at

  • :direction - Whether the taker of the trade was a buyer or a seller

  • :amount_base - The amount of the base token traded

  • :amount_quote - The amount of the quote token traded

  • :txhash - The hash of the transaction the trade was executed in

  • :height - The chain height when the trade was executed

  • :timestamp - The timestamp of the trade

  • :idx - The index of the trade within the transaction it was executed in.

Summary

Functions

Extracts all trade events from a tx_response.

Types

@type direction() :: :buy | :sell
@type t() :: %Kujira.Fin.Trade{
  amount_base: integer(),
  amount_quote: integer(),
  direction: direction(),
  height: integer(),
  id: String.t(),
  idx: integer(),
  pair: {Kujira.Fin.Pair, String.t()},
  price: Decimal.t(),
  timestamp: DateTime.t(),
  txhash: String.t()
}

Functions

Link to this function

from_tx_response(map)

@spec from_tx_response(Cosmos.Base.Abci.V1beta1.TxResponse.t()) :: [t()] | nil

Extracts all trade events from a tx_response.

N.B: Prior to height 6_549_066 (2022-12-26T10:15:13+00:00), the FIN contract did not emit the type event which classifies the Trade as a buy or a sell, and trades will not be collected by this function