Skip to main content

Custom Metrics Dimensions

When querying custom metrics, there is a field named dimensions. This is a jsonb field that can hold any attributes of your custom metric that are useful for filtering, grouping, etc.

What Dimensions Does a Metric Have?

If you are looking at a particular custom metric definition and want to see what dimensions the data contains, this query might be useful:

with latest_metrics as (
select dimensions
from custom_metrics cm
where custom_metric_definition_id = '<put_the_custom_metric_definition_id>'
order by updated_time desc
limit 25
)
select distinct jsonb_object_keys(dimensions)
from latest_metrics;

Commonly Used Dimensions

The list below is not all-encompassing, but it provides some detail around common dimensions used by many of our custom metrics:

  • address
    • address associated with the data
  • balance
    • balance in LP tokens, need to use exchangeRate to convert to pool denominated tokens for the associated account
  • borrowAPY or borrowRate
    • to calculate borrowAPR: borrowAPY _ 31536000 / 1E18 _ 100
    • to calculate borrowAPY: POWER(1 + (borrowAPY / 1E18) , 31536000) - 1) * 100
    • 31536000 comes from the jump rate model contract - function: timestampsPerYear
  • borrowBalance
    • Balance of tokens for the associated account
  • borrowCap
    • in cTokens
    • decimal by dividing by coalesce(am.context->>'underlying_token_decimals', am.contextz->>'decimals') from the address_metadata table
  • borrowPaused
    • 1 or 0, yes or no
  • cash
    • in cTokens (liquidity = cash - totalReserves)
    • decimal by dividing by coalesce(am.context->>'underlying_token_decimals', am.contextz->>'decimals') from the address_metadata table
  • collateralFactor in %
    • divide by 1e18
  • customMetricEvaluationSuccess
    • 1 or 0
  • exchangeRate
    • exchange rate between LP tokens and pool tokens LPtoken * exchange rate = pool denominated tokens
  • mintPaused
    • 1 or 0
  • price (pyth for now)
    • cm.val::numeric / POWER(10, 18) / POWER(10, 18 - CAST(am.context->>'underlying_token_decimals' as numeric))
  • reserveFactor in %
    • divide by 1e18
  • supplyAPY or supplyRate
    • to calculate supplyAPR: supplyAPY _ 31536000 / 1E18 _ 100
    • to calculate supplyAPY: POWER(1 + (supplyAPY / 1E18) , 31536000) - 1) * 100
  • totalBorrows
    • in cTokens
    • decimal by dividing by coalesce(am.context->>'underlying_token_decimals', am.contextz->>'decimals') from the address_metadata table
  • totalReserves in cTokens
    • USDC, USDT, ATOM divide by 1e30
    • WBTC, WETH divide by 1e28
    • EVMOS divide by 1e18
  • totalSupply of LP tokens for the lending pool contract
  • totalUnderlyingSupply - the total underlying supply for the lending pool contract in tokens
    • decimal by dividing by coalesce(am.context->>'underlying_token_decimals', am.context->>'decimals') from the address_metadata table