Aave V4 Hub read operations.
One module for all three Hubs (Core, Prime, Plus). Wraps Hub-level reads: member Spokes, credit-line inventory and caps, the Hub rate environment / utilization, IHubBase share-to-asset preview converters, and IHub bound constants. Amounts stay raw integers (token units, RAY, BPS) — conversion is the caller's job given per-asset decimals.
Error Format
Errors pass through from the underlying module that failed:
| Source | Error Shape |
|---|---|
| Hub atom | {:error, {:unknown_hub, hub}} |
Onchain.Address.validate/1 | {:error, {:invalid_address, input}} |
Onchain.Aave.Contracts.address/2 | {:error, {:unsupported_network, network}}, {:error, {:unknown_contract, key}} |
Onchain.Contract.call/5 | {:error, {:encode_error, ...}}, {:error, {:rpc_error, ...}}, {:error, {:decode_error, ...}} |
Functions
| Function | Purpose |
|---|---|
hub_address/2 | Resolve :core / :prime / :plus to the Hub contract |
get_spoke_count/3 | Member Spokes listed for an asset |
is_spoke_listed/4 | Whether a Spoke is listed for an asset |
get_spoke_address/4 | Spoke address at a list index |
get_spoke/4 | Credit-line inventory + caps (SpokeData) |
get_spoke_config/4 | Caps / threshold / active / halted |
get_spoke_added_assets/4 | Assets added by a Spoke |
get_spoke_added_shares/4 | Shares added by a Spoke |
get_spoke_drawn_shares/4 | Drawn shares (credit line drawn) |
get_spoke_owed/4 | Drawn + premium owed by a Spoke |
get_spoke_total_owed/4 | Total owed by a Spoke |
get_spoke_premium_ray/4 | Premium owed by a Spoke (RAY) |
get_spoke_premium_data/4 | Premium shares + offset for a Spoke |
get_spoke_deficit_ray/4 | Spoke deficit (RAY) |
underlying_listed?/3 | Whether an underlying is listed |
get_asset_count/2 | Listed assets on the Hub |
get_asset/3 | Full Asset (liquidity, rates, shares) |
get_asset_config/3 | Fee receiver, fee, strategy, controller |
get_added_assets/3 | Total assets added across Spokes |
get_added_shares/3 | Total shares added across Spokes |
get_asset_liquidity/3 | Available liquidity |
get_asset_owed/3 | Hub-wide drawn + premium owed |
get_asset_total_owed/3 | Hub-wide total owed |
get_asset_premium_ray/3 | Hub-wide premium owed (RAY) |
get_asset_drawn_shares/3 | Hub-wide drawn shares |
get_asset_premium_data/3 | Hub-wide premium shares + offset |
get_asset_deficit_ray/3 | Hub-wide deficit (RAY) |
get_asset_accrued_fees/3 | Accrued fees not yet minted |
get_asset_swept/3 | Liquidity held by the reinvestment controller |
get_asset_drawn_rate/3 | Current drawn rate (RAY) |
get_asset_drawn_index/3 | Current drawn index (RAY) |
get_asset_id/3 | Asset id for an underlying |
get_asset_underlying_and_decimals/3 | Underlying token + decimals |
preview_add_by_assets/4 | Shares added for assets (round down) |
preview_add_by_shares/4 | Assets added for shares (round up) |
preview_remove_by_assets/4 | Shares removed for assets (round up) |
preview_remove_by_shares/4 | Assets removed for shares (round down) |
preview_draw_by_assets/4 | Shares drawn for assets (round up) |
preview_draw_by_shares/4 | Assets drawn for shares (round down) |
preview_restore_by_assets/4 | Shares restored for assets (round down) |
preview_restore_by_shares/4 | Assets restored for shares (round up) |
max_allowed_underlying_decimals/2 | Inclusive max underlying decimals |
min_allowed_underlying_decimals/2 | Inclusive min underlying decimals |
max_allowed_spoke_cap/2 | SpokeConfig add/draw cap sentinel (no cap) |
max_risk_premium_threshold/2 | SpokeConfig risk-premium sentinel (no threshold) |
API Functions
| Function | Arity | Description | Param Kinds |
|---|---|---|---|
max_risk_premium_threshold | 2 | Maximum Spoke risk-premium threshold. Using this value on SpokeConfig means no threshold. | hub: value, opts: value |
max_allowed_spoke_cap | 2 | Maximum Spoke add/draw cap. Using this value on SpokeConfig means no cap. | hub: value, opts: value |
min_allowed_underlying_decimals | 2 | Inclusive minimum allowed underlying-asset decimals. | hub: value, opts: value |
max_allowed_underlying_decimals | 2 | Inclusive maximum allowed underlying-asset decimals. | hub: value, opts: value |
preview_restore_by_shares | 4 | Assets that would be restored for the given shares. Rounds up. | hub: value, asset_id: value, shares: value, opts: value |
preview_restore_by_assets | 4 | Shares that would be restored for the given assets. Rounds down. | hub: value, asset_id: value, assets: value, opts: value |
preview_draw_by_shares | 4 | Assets that would be drawn for the given shares. Rounds down. | hub: value, asset_id: value, shares: value, opts: value |
preview_draw_by_assets | 4 | Shares that would be drawn for the given assets. Rounds up. | hub: value, asset_id: value, assets: value, opts: value |
preview_remove_by_shares | 4 | Assets that would be removed for the given shares. Rounds down. | hub: value, asset_id: value, shares: value, opts: value |
preview_remove_by_assets | 4 | Shares that would be removed for the given assets. Rounds up. | hub: value, asset_id: value, assets: value, opts: value |
preview_add_by_shares | 4 | Assets that would be added for the given shares. Rounds up. | hub: value, asset_id: value, shares: value, opts: value |
preview_add_by_assets | 4 | Shares that would be added for the given assets. Rounds down. | hub: value, asset_id: value, assets: value, opts: value |
get_asset_underlying_and_decimals | 3 | Underlying token address and decimals for a Hub asset. | hub: value, asset_id: value, opts: value |
get_asset_id | 3 | Hub asset identifier for an underlying token. | hub: value, underlying: value, opts: value |
get_asset_drawn_index | 3 | Current drawn index for an asset, RAY-scaled. | hub: value, asset_id: value, opts: value |
get_asset_drawn_rate | 3 | Current drawn rate for an asset, RAY-scaled. | hub: value, asset_id: value, opts: value |
get_asset_deficit_ray | 3 | Hub-wide deficit for an asset, RAY-scaled. | hub: value, asset_id: value, opts: value |
get_asset_premium_data | 3 | Hub-wide premium shares and offset for an asset. | hub: value, asset_id: value, opts: value |
get_asset_drawn_shares | 3 | Hub-wide drawn shares for an asset. | hub: value, asset_id: value, opts: value |
get_asset_premium_ray | 3 | Hub-wide premium owed for an asset, RAY-scaled. | hub: value, asset_id: value, opts: value |
get_asset_total_owed | 3 | Hub-wide total amount owed for an asset. | hub: value, asset_id: value, opts: value |
get_asset_owed | 3 | Hub-wide drawn and premium amounts owed for an asset. | hub: value, asset_id: value, opts: value |
get_asset_liquidity | 3 | Available Hub liquidity for an asset. | hub: value, asset_id: value, opts: value |
get_added_shares | 3 | Total added shares on the Hub across all Spokes. | hub: value, asset_id: value, opts: value |
get_added_assets | 3 | Total assets added to the Hub across all Spokes. | hub: value, asset_id: value, opts: value |
get_asset_swept | 3 | Liquidity held by the asset's reinvestment controller. | hub: value, asset_id: value, opts: value |
get_asset_accrued_fees | 3 | Accrued asset fees not yet minted as shares. | hub: value, asset_id: value, opts: value |
get_asset_config | 3 | Hub asset fee and interest-rate configuration. | hub: value, asset_id: value, opts: value |
get_asset | 3 | Full Hub asset position, including liquidity and drawn rate/index. | hub: value, asset_id: value, opts: value |
get_asset_count | 2 | Number of assets listed on the Hub. | hub: value, opts: value |
underlying_listed? | 3 | Whether an underlying token is listed on the Hub. | hub: value, underlying: value, opts: value |
get_spoke_deficit_ray | 4 | Spoke deficit for an asset, RAY-scaled. | hub: value, asset_id: value, spoke: value, opts: value |
get_spoke_premium_data | 4 | Premium shares and offset for a Spoke. | hub: value, asset_id: value, spoke: value, opts: value |
get_spoke_premium_ray | 4 | Premium a Spoke owes the Hub, RAY-scaled. | hub: value, asset_id: value, spoke: value, opts: value |
get_spoke_total_owed | 4 | Total amount a Spoke owes the Hub for an asset. | hub: value, asset_id: value, spoke: value, opts: value |
get_spoke_owed | 4 | Drawn and premium amounts a Spoke owes the Hub. | hub: value, asset_id: value, spoke: value, opts: value |
get_spoke_drawn_shares | 4 | Drawn shares of an asset for a Spoke. | hub: value, asset_id: value, spoke: value, opts: value |
get_spoke_added_shares | 4 | Shares added to the Hub by a Spoke. | hub: value, asset_id: value, spoke: value, opts: value |
get_spoke_added_assets | 4 | Assets added to the Hub by a Spoke. | hub: value, asset_id: value, spoke: value, opts: value |
get_spoke_config | 4 | Spoke caps, risk-premium threshold, and active/halted flags. | hub: value, asset_id: value, spoke: value, opts: value |
get_spoke | 4 | Spoke credit-line inventory and caps for an asset. | hub: value, asset_id: value, spoke: value, opts: value |
get_spoke_address | 4 | Spoke address for an asset at the given list index. | hub: value, asset_id: value, index: value, opts: value |
is_spoke_listed | 4 | Whether a Spoke is listed for an asset on the Hub. | hub: value, asset_id: value, spoke: value, opts: value |
get_spoke_count | 3 | Number of Spokes listed for an asset on the Hub. | hub: value, asset_id: value, opts: value |
hub_address | 2 | Resolve a V4 Hub atom to its checksummed contract address. | hub: value, opts: value |
Summary
Functions
Total assets added to the Hub across all Spokes.
Total added shares on the Hub across all Spokes.
Full Hub asset position, including liquidity and drawn rate/index.
Accrued asset fees not yet minted as shares.
Hub asset fee and interest-rate configuration.
Number of assets listed on the Hub.
Hub-wide deficit for an asset, RAY-scaled.
Current drawn index for an asset, RAY-scaled.
Current drawn rate for an asset, RAY-scaled.
Hub-wide drawn shares for an asset.
Hub asset identifier for an underlying token.
Available Hub liquidity for an asset.
Hub-wide drawn and premium amounts owed for an asset.
Hub-wide premium shares and offset for an asset.
Hub-wide premium owed for an asset, RAY-scaled.
Liquidity held by the asset's reinvestment controller.
Hub-wide total amount owed for an asset.
Underlying token address and decimals for a Hub asset.
Spoke credit-line inventory and caps for an asset.
Assets added to the Hub by a Spoke.
Shares added to the Hub by a Spoke.
Spoke address for an asset at the given list index.
Spoke caps, risk-premium threshold, and active/halted flags.
Number of Spokes listed for an asset on the Hub.
Spoke deficit for an asset, RAY-scaled.
Drawn shares of an asset for a Spoke.
Drawn and premium amounts a Spoke owes the Hub.
Premium shares and offset for a Spoke.
Premium a Spoke owes the Hub, RAY-scaled.
Total amount a Spoke owes the Hub for an asset.
Resolve a V4 Hub atom to its checksummed contract address.
Whether a Spoke is listed for an asset on the Hub.
Maximum Spoke add/draw cap. Using this value on SpokeConfig means no cap.
Inclusive maximum allowed underlying-asset decimals.
Maximum Spoke risk-premium threshold. Using this value on SpokeConfig means no threshold.
Inclusive minimum allowed underlying-asset decimals.
Shares that would be added for the given assets. Rounds down.
Assets that would be added for the given shares. Rounds up.
Shares that would be drawn for the given assets. Rounds up.
Assets that would be drawn for the given shares. Rounds down.
Shares that would be removed for the given assets. Rounds up.
Assets that would be removed for the given shares. Rounds down.
Shares that would be restored for the given assets. Rounds down.
Assets that would be restored for the given shares. Rounds up.
Whether an underlying token is listed on the Hub.
Types
Functions
@spec get_added_assets(hub(), non_neg_integer(), keyword()) :: {:ok, non_neg_integer()} | {:error, term()}
Total assets added to the Hub across all Spokes.
Parameters
hub- Hub atom: :core, :prime, or :plus (value)asset_id- Hub asset identifier (value)opts- Options: :network (default :ethereum), :rpc_url, :timeout, :block (default:[], value)
Returns
Added assets in token units ({:ok, non_neg_integer()} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :network (default :ethereum), :rpc_url, :timeout, :block",
kind: :value
},
hub: %{description: "Hub atom: :core, :prime, or :plus", kind: :value},
asset_id: %{description: "Hub asset identifier", kind: :value}
},
returns: %{
type: "{:ok, non_neg_integer()} | {:error, term()}",
description: "Added assets in token units"
}
}
@spec get_asset(hub(), non_neg_integer(), keyword()) :: {:ok, Onchain.Aave.V4.Hub.Asset.t()} | {:error, term()}
Full Hub asset position, including liquidity and drawn rate/index.
Parameters
hub- Hub atom: :core, :prime, or :plus (value)asset_id- Hub asset identifier (value)opts- Options: :network (default :ethereum), :rpc_url, :timeout, :block (default:[], value)
Returns
Asset struct ({:ok, Asset.t()} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :network (default :ethereum), :rpc_url, :timeout, :block",
kind: :value
},
hub: %{description: "Hub atom: :core, :prime, or :plus", kind: :value},
asset_id: %{description: "Hub asset identifier", kind: :value}
},
returns: %{
type: "{:ok, Asset.t()} | {:error, term()}",
description: "Asset struct"
}
}
@spec get_asset_accrued_fees(hub(), non_neg_integer(), keyword()) :: {:ok, non_neg_integer()} | {:error, term()}
Accrued asset fees not yet minted as shares.
Parameters
hub- Hub atom: :core, :prime, or :plus (value)asset_id- Hub asset identifier (value)opts- Options: :network (default :ethereum), :rpc_url, :timeout, :block (default:[], value)
Returns
Accrued fees in asset units ({:ok, non_neg_integer()} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :network (default :ethereum), :rpc_url, :timeout, :block",
kind: :value
},
hub: %{description: "Hub atom: :core, :prime, or :plus", kind: :value},
asset_id: %{description: "Hub asset identifier", kind: :value}
},
returns: %{
type: "{:ok, non_neg_integer()} | {:error, term()}",
description: "Accrued fees in asset units"
}
}
@spec get_asset_config(hub(), non_neg_integer(), keyword()) :: {:ok, Onchain.Aave.V4.Hub.AssetConfig.t()} | {:error, term()}
Hub asset fee and interest-rate configuration.
Parameters
hub- Hub atom: :core, :prime, or :plus (value)asset_id- Hub asset identifier (value)opts- Options: :network (default :ethereum), :rpc_url, :timeout, :block (default:[], value)
Returns
AssetConfig struct ({:ok, AssetConfig.t()} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :network (default :ethereum), :rpc_url, :timeout, :block",
kind: :value
},
hub: %{description: "Hub atom: :core, :prime, or :plus", kind: :value},
asset_id: %{description: "Hub asset identifier", kind: :value}
},
returns: %{
type: "{:ok, AssetConfig.t()} | {:error, term()}",
description: "AssetConfig struct"
}
}
@spec get_asset_count( hub(), keyword() ) :: {:ok, non_neg_integer()} | {:error, term()}
Number of assets listed on the Hub.
Parameters
hub- Hub atom: :core, :prime, or :plus (value)opts- Options: :network (default :ethereum), :rpc_url, :timeout, :block (default:[], value)
Returns
Listed asset count ({:ok, non_neg_integer()} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :network (default :ethereum), :rpc_url, :timeout, :block",
kind: :value
},
hub: %{description: "Hub atom: :core, :prime, or :plus", kind: :value}
},
returns: %{
type: "{:ok, non_neg_integer()} | {:error, term()}",
description: "Listed asset count"
}
}
@spec get_asset_deficit_ray(hub(), non_neg_integer(), keyword()) :: {:ok, non_neg_integer()} | {:error, term()}
Hub-wide deficit for an asset, RAY-scaled.
Parameters
hub- Hub atom: :core, :prime, or :plus (value)asset_id- Hub asset identifier (value)opts- Options: :network (default :ethereum), :rpc_url, :timeout, :block (default:[], value)
Returns
Deficit in asset units, RAY-scaled ({:ok, non_neg_integer()} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :network (default :ethereum), :rpc_url, :timeout, :block",
kind: :value
},
hub: %{description: "Hub atom: :core, :prime, or :plus", kind: :value},
asset_id: %{description: "Hub asset identifier", kind: :value}
},
returns: %{
type: "{:ok, non_neg_integer()} | {:error, term()}",
description: "Deficit in asset units, RAY-scaled"
}
}
@spec get_asset_drawn_index(hub(), non_neg_integer(), keyword()) :: {:ok, non_neg_integer()} | {:error, term()}
Current drawn index for an asset, RAY-scaled.
Parameters
hub- Hub atom: :core, :prime, or :plus (value)asset_id- Hub asset identifier (value)opts- Options: :network (default :ethereum), :rpc_url, :timeout, :block (default:[], value)
Returns
Drawn index (RAY) ({:ok, non_neg_integer()} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :network (default :ethereum), :rpc_url, :timeout, :block",
kind: :value
},
hub: %{description: "Hub atom: :core, :prime, or :plus", kind: :value},
asset_id: %{description: "Hub asset identifier", kind: :value}
},
returns: %{
type: "{:ok, non_neg_integer()} | {:error, term()}",
description: "Drawn index (RAY)"
}
}
@spec get_asset_drawn_rate(hub(), non_neg_integer(), keyword()) :: {:ok, non_neg_integer()} | {:error, term()}
Current drawn rate for an asset, RAY-scaled.
Parameters
hub- Hub atom: :core, :prime, or :plus (value)asset_id- Hub asset identifier (value)opts- Options: :network (default :ethereum), :rpc_url, :timeout, :block (default:[], value)
Returns
Drawn rate (RAY) ({:ok, non_neg_integer()} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :network (default :ethereum), :rpc_url, :timeout, :block",
kind: :value
},
hub: %{description: "Hub atom: :core, :prime, or :plus", kind: :value},
asset_id: %{description: "Hub asset identifier", kind: :value}
},
returns: %{
type: "{:ok, non_neg_integer()} | {:error, term()}",
description: "Drawn rate (RAY)"
}
}
@spec get_asset_id(hub(), String.t() | binary(), keyword()) :: {:ok, non_neg_integer()} | {:error, term()}
Hub asset identifier for an underlying token.
Parameters
hub- Hub atom: :core, :prime, or :plus (value)underlying- Underlying asset address as 0x hex or 20-byte binary (value)opts- Options: :network (default :ethereum), :rpc_url, :timeout, :block (default:[], value)
Returns
Asset identifier ({:ok, non_neg_integer()} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :network (default :ethereum), :rpc_url, :timeout, :block",
kind: :value
},
hub: %{description: "Hub atom: :core, :prime, or :plus", kind: :value},
underlying: %{
description: "Underlying asset address as 0x hex or 20-byte binary",
kind: :value
}
},
returns: %{
type: "{:ok, non_neg_integer()} | {:error, term()}",
description: "Asset identifier"
}
}
@spec get_asset_liquidity(hub(), non_neg_integer(), keyword()) :: {:ok, non_neg_integer()} | {:error, term()}
Available Hub liquidity for an asset.
Parameters
hub- Hub atom: :core, :prime, or :plus (value)asset_id- Hub asset identifier (value)opts- Options: :network (default :ethereum), :rpc_url, :timeout, :block (default:[], value)
Returns
Available liquidity (token units) ({:ok, non_neg_integer()} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :network (default :ethereum), :rpc_url, :timeout, :block",
kind: :value
},
hub: %{description: "Hub atom: :core, :prime, or :plus", kind: :value},
asset_id: %{description: "Hub asset identifier", kind: :value}
},
returns: %{
type: "{:ok, non_neg_integer()} | {:error, term()}",
description: "Available liquidity (token units)"
}
}
@spec get_asset_owed(hub(), non_neg_integer(), keyword()) :: {:ok, {non_neg_integer(), non_neg_integer()}} | {:error, term()}
Hub-wide drawn and premium amounts owed for an asset.
Parameters
hub- Hub atom: :core, :prime, or :plus (value)asset_id- Hub asset identifier (value)opts- Options: :network (default :ethereum), :rpc_url, :timeout, :block (default:[], value)
Returns
{drawn, premium} in token units ({:ok, {non_neg_integer(), non_neg_integer()}} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :network (default :ethereum), :rpc_url, :timeout, :block",
kind: :value
},
hub: %{description: "Hub atom: :core, :prime, or :plus", kind: :value},
asset_id: %{description: "Hub asset identifier", kind: :value}
},
returns: %{
type: "{:ok, {non_neg_integer(), non_neg_integer()}} | {:error, term()}",
description: "{drawn, premium} in token units"
}
}
@spec get_asset_swept(hub(), non_neg_integer(), keyword()) :: {:ok, non_neg_integer()} | {:error, term()}
Liquidity held by the asset's reinvestment controller.
Parameters
hub- Hub atom: :core, :prime, or :plus (value)asset_id- Hub asset identifier (value)opts- Options: :network (default :ethereum), :rpc_url, :timeout, :block (default:[], value)
Returns
Swept liquidity in asset units ({:ok, non_neg_integer()} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :network (default :ethereum), :rpc_url, :timeout, :block",
kind: :value
},
hub: %{description: "Hub atom: :core, :prime, or :plus", kind: :value},
asset_id: %{description: "Hub asset identifier", kind: :value}
},
returns: %{
type: "{:ok, non_neg_integer()} | {:error, term()}",
description: "Swept liquidity in asset units"
}
}
@spec get_asset_total_owed(hub(), non_neg_integer(), keyword()) :: {:ok, non_neg_integer()} | {:error, term()}
Hub-wide total amount owed for an asset.
Parameters
hub- Hub atom: :core, :prime, or :plus (value)asset_id- Hub asset identifier (value)opts- Options: :network (default :ethereum), :rpc_url, :timeout, :block (default:[], value)
Returns
Total owed (token units) ({:ok, non_neg_integer()} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :network (default :ethereum), :rpc_url, :timeout, :block",
kind: :value
},
hub: %{description: "Hub atom: :core, :prime, or :plus", kind: :value},
asset_id: %{description: "Hub asset identifier", kind: :value}
},
returns: %{
type: "{:ok, non_neg_integer()} | {:error, term()}",
description: "Total owed (token units)"
}
}
@spec get_asset_underlying_and_decimals(hub(), non_neg_integer(), keyword()) :: {:ok, {String.t(), non_neg_integer()}} | {:error, term()}
Underlying token address and decimals for a Hub asset.
Parameters
hub- Hub atom: :core, :prime, or :plus (value)asset_id- Hub asset identifier (value)opts- Options: :network (default :ethereum), :rpc_url, :timeout, :block (default:[], value)
Returns
{checksummed underlying, decimals} ({:ok, {String.t(), non_neg_integer()}} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :network (default :ethereum), :rpc_url, :timeout, :block",
kind: :value
},
hub: %{description: "Hub atom: :core, :prime, or :plus", kind: :value},
asset_id: %{description: "Hub asset identifier", kind: :value}
},
returns: %{
type: "{:ok, {String.t(), non_neg_integer()}} | {:error, term()}",
description: "{checksummed underlying, decimals}"
}
}
@spec get_spoke(hub(), non_neg_integer(), String.t() | binary(), keyword()) :: {:ok, Onchain.Aave.V4.Hub.SpokeData.t()} | {:error, term()}
Spoke credit-line inventory and caps for an asset.
Parameters
hub- Hub atom: :core, :prime, or :plus (value)asset_id- Hub asset identifier (value)spoke- Spoke address as 0x hex string or 20-byte binary (value)opts- Options: :network (default :ethereum), :rpc_url, :timeout, :block (default:[], value)
Returns
SpokeData struct ({:ok, SpokeData.t()} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :network (default :ethereum), :rpc_url, :timeout, :block",
kind: :value
},
hub: %{description: "Hub atom: :core, :prime, or :plus", kind: :value},
asset_id: %{description: "Hub asset identifier", kind: :value},
spoke: %{
description: "Spoke address as 0x hex string or 20-byte binary",
kind: :value
}
},
returns: %{
type: "{:ok, SpokeData.t()} | {:error, term()}",
description: "SpokeData struct"
}
}
@spec get_spoke_added_assets( hub(), non_neg_integer(), String.t() | binary(), keyword() ) :: {:ok, non_neg_integer()} | {:error, term()}
Assets added to the Hub by a Spoke.
Parameters
hub- Hub atom: :core, :prime, or :plus (value)asset_id- Hub asset identifier (value)spoke- Spoke address as 0x hex string or 20-byte binary (value)opts- Options: :network (default :ethereum), :rpc_url, :timeout, :block (default:[], value)
Returns
Added assets (token units) ({:ok, non_neg_integer()} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :network (default :ethereum), :rpc_url, :timeout, :block",
kind: :value
},
hub: %{description: "Hub atom: :core, :prime, or :plus", kind: :value},
asset_id: %{description: "Hub asset identifier", kind: :value},
spoke: %{
description: "Spoke address as 0x hex string or 20-byte binary",
kind: :value
}
},
returns: %{
type: "{:ok, non_neg_integer()} | {:error, term()}",
description: "Added assets (token units)"
}
}
@spec get_spoke_address(hub(), non_neg_integer(), non_neg_integer(), keyword()) :: {:ok, String.t()} | {:error, term()}
Spoke address for an asset at the given list index.
Parameters
hub- Hub atom: :core, :prime, or :plus (value)asset_id- Hub asset identifier (value)index- Zero-based index into the Hub's spoke list (value)opts- Options: :network (default :ethereum), :rpc_url, :timeout, :block (default:[], value)
Returns
Checksummed Spoke address ({:ok, String.t()} | {:error, term()})
# descripex:contract
%{
params: %{
index: %{
description: "Zero-based index into the Hub's spoke list",
kind: :value
},
opts: %{
default: [],
description: "Options: :network (default :ethereum), :rpc_url, :timeout, :block",
kind: :value
},
hub: %{description: "Hub atom: :core, :prime, or :plus", kind: :value},
asset_id: %{description: "Hub asset identifier", kind: :value}
},
returns: %{
type: "{:ok, String.t()} | {:error, term()}",
description: "Checksummed Spoke address"
}
}
@spec get_spoke_config(hub(), non_neg_integer(), String.t() | binary(), keyword()) :: {:ok, Onchain.Aave.V4.Hub.SpokeConfig.t()} | {:error, term()}
Spoke caps, risk-premium threshold, and active/halted flags.
Parameters
hub- Hub atom: :core, :prime, or :plus (value)asset_id- Hub asset identifier (value)spoke- Spoke address as 0x hex string or 20-byte binary (value)opts- Options: :network (default :ethereum), :rpc_url, :timeout, :block (default:[], value)
Returns
SpokeConfig struct ({:ok, SpokeConfig.t()} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :network (default :ethereum), :rpc_url, :timeout, :block",
kind: :value
},
hub: %{description: "Hub atom: :core, :prime, or :plus", kind: :value},
asset_id: %{description: "Hub asset identifier", kind: :value},
spoke: %{
description: "Spoke address as 0x hex string or 20-byte binary",
kind: :value
}
},
returns: %{
type: "{:ok, SpokeConfig.t()} | {:error, term()}",
description: "SpokeConfig struct"
}
}
@spec get_spoke_count(hub(), non_neg_integer(), keyword()) :: {:ok, non_neg_integer()} | {:error, term()}
Number of Spokes listed for an asset on the Hub.
Parameters
hub- Hub atom: :core, :prime, or :plus (value)asset_id- Hub asset identifier (value)opts- Options: :network (default :ethereum), :rpc_url, :timeout, :block (default:[], value)
Returns
Listed spoke count ({:ok, non_neg_integer()} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :network (default :ethereum), :rpc_url, :timeout, :block",
kind: :value
},
hub: %{description: "Hub atom: :core, :prime, or :plus", kind: :value},
asset_id: %{description: "Hub asset identifier", kind: :value}
},
returns: %{
type: "{:ok, non_neg_integer()} | {:error, term()}",
description: "Listed spoke count"
}
}
@spec get_spoke_deficit_ray( hub(), non_neg_integer(), String.t() | binary(), keyword() ) :: {:ok, non_neg_integer()} | {:error, term()}
Spoke deficit for an asset, RAY-scaled.
Parameters
hub- Hub atom: :core, :prime, or :plus (value)asset_id- Hub asset identifier (value)spoke- Spoke address as 0x hex string or 20-byte binary (value)opts- Options: :network (default :ethereum), :rpc_url, :timeout, :block (default:[], value)
Returns
Deficit in asset units, RAY-scaled ({:ok, non_neg_integer()} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :network (default :ethereum), :rpc_url, :timeout, :block",
kind: :value
},
hub: %{description: "Hub atom: :core, :prime, or :plus", kind: :value},
asset_id: %{description: "Hub asset identifier", kind: :value},
spoke: %{
description: "Spoke address as 0x hex string or 20-byte binary",
kind: :value
}
},
returns: %{
type: "{:ok, non_neg_integer()} | {:error, term()}",
description: "Deficit in asset units, RAY-scaled"
}
}
@spec get_spoke_owed(hub(), non_neg_integer(), String.t() | binary(), keyword()) :: {:ok, {non_neg_integer(), non_neg_integer()}} | {:error, term()}
Drawn and premium amounts a Spoke owes the Hub.
Parameters
hub- Hub atom: :core, :prime, or :plus (value)asset_id- Hub asset identifier (value)spoke- Spoke address as 0x hex string or 20-byte binary (value)opts- Options: :network (default :ethereum), :rpc_url, :timeout, :block (default:[], value)
Returns
{drawn, premium} in token units ({:ok, {non_neg_integer(), non_neg_integer()}} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :network (default :ethereum), :rpc_url, :timeout, :block",
kind: :value
},
hub: %{description: "Hub atom: :core, :prime, or :plus", kind: :value},
asset_id: %{description: "Hub asset identifier", kind: :value},
spoke: %{
description: "Spoke address as 0x hex string or 20-byte binary",
kind: :value
}
},
returns: %{
type: "{:ok, {non_neg_integer(), non_neg_integer()}} | {:error, term()}",
description: "{drawn, premium} in token units"
}
}
@spec get_spoke_total_owed(hub(), non_neg_integer(), String.t() | binary(), keyword()) :: {:ok, non_neg_integer()} | {:error, term()}
Total amount a Spoke owes the Hub for an asset.
Parameters
hub- Hub atom: :core, :prime, or :plus (value)asset_id- Hub asset identifier (value)spoke- Spoke address as 0x hex string or 20-byte binary (value)opts- Options: :network (default :ethereum), :rpc_url, :timeout, :block (default:[], value)
Returns
Total owed (token units) ({:ok, non_neg_integer()} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :network (default :ethereum), :rpc_url, :timeout, :block",
kind: :value
},
hub: %{description: "Hub atom: :core, :prime, or :plus", kind: :value},
asset_id: %{description: "Hub asset identifier", kind: :value},
spoke: %{
description: "Spoke address as 0x hex string or 20-byte binary",
kind: :value
}
},
returns: %{
type: "{:ok, non_neg_integer()} | {:error, term()}",
description: "Total owed (token units)"
}
}
Resolve a V4 Hub atom to its checksummed contract address.
Parameters
hub- Hub atom: :core, :prime, or :plus (value)opts- Options: [network: :ethereum] (default:[], value)
Returns
Checksummed Hub address ({:ok, String.t()} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: [network: :ethereum]",
kind: :value
},
hub: %{description: "Hub atom: :core, :prime, or :plus", kind: :value}
},
returns: %{
type: "{:ok, String.t()} | {:error, term()}",
description: "Checksummed Hub address",
example: "0xCca852Bc40e560adC3b1Cc58CA5b55638ce826c9"
}
}
@spec is_spoke_listed(hub(), non_neg_integer(), String.t() | binary(), keyword()) :: {:ok, boolean()} | {:error, term()}
Whether a Spoke is listed for an asset on the Hub.
Parameters
hub- Hub atom: :core, :prime, or :plus (value)asset_id- Hub asset identifier (value)spoke- Spoke address as 0x hex string or 20-byte binary (value)opts- Options: :network (default :ethereum), :rpc_url, :timeout, :block (default:[], value)
Returns
true if the Spoke is listed ({:ok, boolean()} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :network (default :ethereum), :rpc_url, :timeout, :block",
kind: :value
},
hub: %{description: "Hub atom: :core, :prime, or :plus", kind: :value},
asset_id: %{description: "Hub asset identifier", kind: :value},
spoke: %{
description: "Spoke address as 0x hex string or 20-byte binary",
kind: :value
}
},
returns: %{
type: "{:ok, boolean()} | {:error, term()}",
description: "true if the Spoke is listed"
}
}
@spec max_allowed_spoke_cap( hub(), keyword() ) :: {:ok, non_neg_integer()} | {:error, term()}
Maximum Spoke add/draw cap. Using this value on SpokeConfig means no cap.
Parameters
hub- Hub atom: :core, :prime, or :plus (value)opts- Options: :network (default :ethereum), :rpc_url, :timeout, :block (default:[], value)
Returns
Cap bound (uint40 whole assets; max means no cap) ({:ok, non_neg_integer()} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :network (default :ethereum), :rpc_url, :timeout, :block",
kind: :value
},
hub: %{description: "Hub atom: :core, :prime, or :plus", kind: :value}
},
returns: %{
type: "{:ok, non_neg_integer()} | {:error, term()}",
description: "Cap bound (uint40 whole assets; max means no cap)"
}
}
@spec max_allowed_underlying_decimals( hub(), keyword() ) :: {:ok, non_neg_integer()} | {:error, term()}
Inclusive maximum allowed underlying-asset decimals.
Parameters
hub- Hub atom: :core, :prime, or :plus (value)opts- Options: :network (default :ethereum), :rpc_url, :timeout, :block (default:[], value)
Returns
Max decimals (inclusive, uint8) ({:ok, non_neg_integer()} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :network (default :ethereum), :rpc_url, :timeout, :block",
kind: :value
},
hub: %{description: "Hub atom: :core, :prime, or :plus", kind: :value}
},
returns: %{
type: "{:ok, non_neg_integer()} | {:error, term()}",
description: "Max decimals (inclusive, uint8)"
}
}
@spec min_allowed_underlying_decimals( hub(), keyword() ) :: {:ok, non_neg_integer()} | {:error, term()}
Inclusive minimum allowed underlying-asset decimals.
Parameters
hub- Hub atom: :core, :prime, or :plus (value)opts- Options: :network (default :ethereum), :rpc_url, :timeout, :block (default:[], value)
Returns
Min decimals (inclusive, uint8) ({:ok, non_neg_integer()} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :network (default :ethereum), :rpc_url, :timeout, :block",
kind: :value
},
hub: %{description: "Hub atom: :core, :prime, or :plus", kind: :value}
},
returns: %{
type: "{:ok, non_neg_integer()} | {:error, term()}",
description: "Min decimals (inclusive, uint8)"
}
}
@spec preview_add_by_assets(hub(), non_neg_integer(), non_neg_integer(), keyword()) :: {:ok, non_neg_integer()} | {:error, term()}
Shares that would be added for the given assets. Rounds down.
Parameters
hub- Hub atom: :core, :prime, or :plus (value)asset_id- Hub asset identifier (value)assets- Asset amount in token units (value)opts- Options: :network (default :ethereum), :rpc_url, :timeout, :block (default:[], value)
Returns
Shares added (rounded down) ({:ok, non_neg_integer()} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :network (default :ethereum), :rpc_url, :timeout, :block",
kind: :value
},
assets: %{description: "Asset amount in token units", kind: :value},
hub: %{description: "Hub atom: :core, :prime, or :plus", kind: :value},
asset_id: %{description: "Hub asset identifier", kind: :value}
},
returns: %{
type: "{:ok, non_neg_integer()} | {:error, term()}",
description: "Shares added (rounded down)"
}
}
@spec preview_draw_by_assets(hub(), non_neg_integer(), non_neg_integer(), keyword()) :: {:ok, non_neg_integer()} | {:error, term()}
Shares that would be drawn for the given assets. Rounds up.
Parameters
hub- Hub atom: :core, :prime, or :plus (value)asset_id- Hub asset identifier (value)assets- Asset amount in token units (value)opts- Options: :network (default :ethereum), :rpc_url, :timeout, :block (default:[], value)
Returns
Shares drawn (rounded up) ({:ok, non_neg_integer()} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :network (default :ethereum), :rpc_url, :timeout, :block",
kind: :value
},
assets: %{description: "Asset amount in token units", kind: :value},
hub: %{description: "Hub atom: :core, :prime, or :plus", kind: :value},
asset_id: %{description: "Hub asset identifier", kind: :value}
},
returns: %{
type: "{:ok, non_neg_integer()} | {:error, term()}",
description: "Shares drawn (rounded up)"
}
}
@spec preview_remove_by_assets(hub(), non_neg_integer(), non_neg_integer(), keyword()) :: {:ok, non_neg_integer()} | {:error, term()}
Shares that would be removed for the given assets. Rounds up.
Parameters
hub- Hub atom: :core, :prime, or :plus (value)asset_id- Hub asset identifier (value)assets- Asset amount in token units (value)opts- Options: :network (default :ethereum), :rpc_url, :timeout, :block (default:[], value)
Returns
Shares removed (rounded up) ({:ok, non_neg_integer()} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :network (default :ethereum), :rpc_url, :timeout, :block",
kind: :value
},
assets: %{description: "Asset amount in token units", kind: :value},
hub: %{description: "Hub atom: :core, :prime, or :plus", kind: :value},
asset_id: %{description: "Hub asset identifier", kind: :value}
},
returns: %{
type: "{:ok, non_neg_integer()} | {:error, term()}",
description: "Shares removed (rounded up)"
}
}
@spec preview_restore_by_assets( hub(), non_neg_integer(), non_neg_integer(), keyword() ) :: {:ok, non_neg_integer()} | {:error, term()}
Shares that would be restored for the given assets. Rounds down.
Parameters
hub- Hub atom: :core, :prime, or :plus (value)asset_id- Hub asset identifier (value)assets- Asset amount in token units (value)opts- Options: :network (default :ethereum), :rpc_url, :timeout, :block (default:[], value)
Returns
Shares restored (rounded down) ({:ok, non_neg_integer()} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :network (default :ethereum), :rpc_url, :timeout, :block",
kind: :value
},
assets: %{description: "Asset amount in token units", kind: :value},
hub: %{description: "Hub atom: :core, :prime, or :plus", kind: :value},
asset_id: %{description: "Hub asset identifier", kind: :value}
},
returns: %{
type: "{:ok, non_neg_integer()} | {:error, term()}",
description: "Shares restored (rounded down)"
}
}
@spec underlying_listed?(hub(), String.t() | binary(), keyword()) :: {:ok, boolean()} | {:error, term()}
Whether an underlying token is listed on the Hub.
Parameters
hub- Hub atom: :core, :prime, or :plus (value)underlying- Underlying asset address as 0x hex or 20-byte binary (value)opts- Options: :network (default :ethereum), :rpc_url, :timeout, :block (default:[], value)
Returns
true if the underlying is listed ({:ok, boolean()} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :network (default :ethereum), :rpc_url, :timeout, :block",
kind: :value
},
hub: %{description: "Hub atom: :core, :prime, or :plus", kind: :value},
underlying: %{
description: "Underlying asset address as 0x hex or 20-byte binary",
kind: :value
}
},
returns: %{
type: "{:ok, boolean()} | {:error, term()}",
description: "true if the underlying is listed"
}
}