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

Copy Markdown View Source

Typed struct for Aave V3 getUserAccountData response.

Wraps the 6 raw uint256 values returned by the Pool contract into named fields with Decimal.t() values, converted via Onchain.Aave.Math.

Fields

FieldMathAave Meaning
total_collateral_baseto_usd/1 (10^8)Total collateral in base currency (USD)
total_debt_baseto_usd/1 (10^8)Total debt in base currency (USD)
available_borrows_baseto_usd/1 (10^8)Remaining borrowing power in base currency
current_liquidation_thresholdto_ltv/1 (10^4)Weighted avg liquidation threshold (0..1)
ltvto_ltv/1 (10^4)Weighted avg loan-to-value ratio (0..1)
health_factorto_health_factor/1 (10^18)Position health (> 1 = safe)

API Functions

FunctionArityDescriptionParam Kinds
from_raw1Convert raw uint256 list from getUserAccountData into a typed struct.raw: exchange_data

Summary

Functions

Convert raw uint256 list from getUserAccountData into a typed struct.

Types

t()

@type t() :: %Onchain.Aave.Types.UserAccountData{
  available_borrows_base: Decimal.t(),
  current_liquidation_threshold: Decimal.t(),
  health_factor: Decimal.t(),
  ltv: Decimal.t(),
  total_collateral_base: Decimal.t(),
  total_debt_base: Decimal.t()
}

Functions

from_raw(list)

@spec from_raw([integer()]) :: t()

Convert raw uint256 list from getUserAccountData into a typed struct.

Parameters

  • raw - 6-element list of integers: [collateral, debt, available_borrows, liq_threshold, ltv, health_factor] (exchange_data)

Returns

%UserAccountData{} with Decimal fields (struct)

# descripex:contract
%{
  params: %{
    raw: %{
      description: "6-element list of integers: [collateral, debt, available_borrows, liq_threshold, ltv, health_factor]",
      source: "Onchain.Aave.Pool.get_user_account_data/2",
      kind: :exchange_data
    }
  },
  returns: %{
    type: :struct,
    description: "%UserAccountData{} with Decimal fields"
  }
}