Onchain.Aave.Types.BaseCurrencyInfo (onchain_aave v0.2.0)

Copy Markdown View Source

Typed struct for Aave V3 BaseCurrencyInfo from getReservesData.

Wraps the 4 values returned alongside reserve data into named fields. market_reference_currency_price_in_usd is converted with Onchain.Aave.Math.to_usd/1 (Aave fixed 10^8 scale). network_base_token_price_in_usd is scaled using the returned network_base_token_price_decimals.

Fields

FieldRaw TypeElixir TypeConversion
market_reference_currency_unituint256integerraw
market_reference_currency_price_in_usdint256Decimal.t()to_usd/1 (10^8)
network_base_token_price_in_usdint256Decimal.t()div_pow10/2 with network_base_token_price_decimals
network_base_token_price_decimalsuint8integerraw

API Functions

FunctionArityDescriptionParam Kinds
from_raw1Convert raw BaseCurrencyInfo tuple from getReservesData into a typed struct.raw: exchange_data

Summary

Functions

Convert raw BaseCurrencyInfo tuple from getReservesData into a typed struct.

Types

t()

@type t() :: %Onchain.Aave.Types.BaseCurrencyInfo{
  market_reference_currency_price_in_usd: Decimal.t(),
  market_reference_currency_unit: non_neg_integer(),
  network_base_token_price_decimals: non_neg_integer(),
  network_base_token_price_in_usd: Decimal.t()
}

Functions

from_raw(arg)

@spec from_raw({integer(), integer(), integer(), non_neg_integer()}) :: t()

Convert raw BaseCurrencyInfo tuple from getReservesData into a typed struct.

Parameters

  • raw - 4-element tuple: {unit, market_ref_price, network_token_price, price_decimals} (exchange_data)

Returns

%BaseCurrencyInfo{} with converted fields (struct)

# descripex:contract
%{
  params: %{
    raw: %{
      description: "4-element tuple: {unit, market_ref_price, network_token_price, price_decimals}",
      source: "Onchain.Aave.UiPoolDataProvider.get_reserves_data/1",
      kind: :exchange_data
    }
  },
  returns: %{
    type: :struct,
    description: "%BaseCurrencyInfo{} with converted fields"
  }
}