Onchain.Aave.V4.Hub (onchain_aave v0.4.0)

Copy Markdown View Source

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:

SourceError 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

FunctionPurpose
hub_address/2Resolve :core / :prime / :plus to the Hub contract
get_spoke_count/3Member Spokes listed for an asset
is_spoke_listed/4Whether a Spoke is listed for an asset
get_spoke_address/4Spoke address at a list index
get_spoke/4Credit-line inventory + caps (SpokeData)
get_spoke_config/4Caps / threshold / active / halted
get_spoke_added_assets/4Assets added by a Spoke
get_spoke_added_shares/4Shares added by a Spoke
get_spoke_drawn_shares/4Drawn shares (credit line drawn)
get_spoke_owed/4Drawn + premium owed by a Spoke
get_spoke_total_owed/4Total owed by a Spoke
get_spoke_premium_ray/4Premium owed by a Spoke (RAY)
get_spoke_premium_data/4Premium shares + offset for a Spoke
get_spoke_deficit_ray/4Spoke deficit (RAY)
underlying_listed?/3Whether an underlying is listed
get_asset_count/2Listed assets on the Hub
get_asset/3Full Asset (liquidity, rates, shares)
get_asset_config/3Fee receiver, fee, strategy, controller
get_added_assets/3Total assets added across Spokes
get_added_shares/3Total shares added across Spokes
get_asset_liquidity/3Available liquidity
get_asset_owed/3Hub-wide drawn + premium owed
get_asset_total_owed/3Hub-wide total owed
get_asset_premium_ray/3Hub-wide premium owed (RAY)
get_asset_drawn_shares/3Hub-wide drawn shares
get_asset_premium_data/3Hub-wide premium shares + offset
get_asset_deficit_ray/3Hub-wide deficit (RAY)
get_asset_accrued_fees/3Accrued fees not yet minted
get_asset_swept/3Liquidity held by the reinvestment controller
get_asset_drawn_rate/3Current drawn rate (RAY)
get_asset_drawn_index/3Current drawn index (RAY)
get_asset_id/3Asset id for an underlying
get_asset_underlying_and_decimals/3Underlying token + decimals
preview_add_by_assets/4Shares added for assets (round down)
preview_add_by_shares/4Assets added for shares (round up)
preview_remove_by_assets/4Shares removed for assets (round up)
preview_remove_by_shares/4Assets removed for shares (round down)
preview_draw_by_assets/4Shares drawn for assets (round up)
preview_draw_by_shares/4Assets drawn for shares (round down)
preview_restore_by_assets/4Shares restored for assets (round down)
preview_restore_by_shares/4Assets restored for shares (round up)
max_allowed_underlying_decimals/2Inclusive max underlying decimals
min_allowed_underlying_decimals/2Inclusive min underlying decimals
max_allowed_spoke_cap/2SpokeConfig add/draw cap sentinel (no cap)
max_risk_premium_threshold/2SpokeConfig risk-premium sentinel (no threshold)

API Functions

FunctionArityDescriptionParam Kinds
max_risk_premium_threshold2Maximum Spoke risk-premium threshold. Using this value on SpokeConfig means no threshold.hub: value, opts: value
max_allowed_spoke_cap2Maximum Spoke add/draw cap. Using this value on SpokeConfig means no cap.hub: value, opts: value
min_allowed_underlying_decimals2Inclusive minimum allowed underlying-asset decimals.hub: value, opts: value
max_allowed_underlying_decimals2Inclusive maximum allowed underlying-asset decimals.hub: value, opts: value
preview_restore_by_shares4Assets that would be restored for the given shares. Rounds up.hub: value, asset_id: value, shares: value, opts: value
preview_restore_by_assets4Shares that would be restored for the given assets. Rounds down.hub: value, asset_id: value, assets: value, opts: value
preview_draw_by_shares4Assets that would be drawn for the given shares. Rounds down.hub: value, asset_id: value, shares: value, opts: value
preview_draw_by_assets4Shares that would be drawn for the given assets. Rounds up.hub: value, asset_id: value, assets: value, opts: value
preview_remove_by_shares4Assets that would be removed for the given shares. Rounds down.hub: value, asset_id: value, shares: value, opts: value
preview_remove_by_assets4Shares that would be removed for the given assets. Rounds up.hub: value, asset_id: value, assets: value, opts: value
preview_add_by_shares4Assets that would be added for the given shares. Rounds up.hub: value, asset_id: value, shares: value, opts: value
preview_add_by_assets4Shares that would be added for the given assets. Rounds down.hub: value, asset_id: value, assets: value, opts: value
get_asset_underlying_and_decimals3Underlying token address and decimals for a Hub asset.hub: value, asset_id: value, opts: value
get_asset_id3Hub asset identifier for an underlying token.hub: value, underlying: value, opts: value
get_asset_drawn_index3Current drawn index for an asset, RAY-scaled.hub: value, asset_id: value, opts: value
get_asset_drawn_rate3Current drawn rate for an asset, RAY-scaled.hub: value, asset_id: value, opts: value
get_asset_deficit_ray3Hub-wide deficit for an asset, RAY-scaled.hub: value, asset_id: value, opts: value
get_asset_premium_data3Hub-wide premium shares and offset for an asset.hub: value, asset_id: value, opts: value
get_asset_drawn_shares3Hub-wide drawn shares for an asset.hub: value, asset_id: value, opts: value
get_asset_premium_ray3Hub-wide premium owed for an asset, RAY-scaled.hub: value, asset_id: value, opts: value
get_asset_total_owed3Hub-wide total amount owed for an asset.hub: value, asset_id: value, opts: value
get_asset_owed3Hub-wide drawn and premium amounts owed for an asset.hub: value, asset_id: value, opts: value
get_asset_liquidity3Available Hub liquidity for an asset.hub: value, asset_id: value, opts: value
get_added_shares3Total added shares on the Hub across all Spokes.hub: value, asset_id: value, opts: value
get_added_assets3Total assets added to the Hub across all Spokes.hub: value, asset_id: value, opts: value
get_asset_swept3Liquidity held by the asset's reinvestment controller.hub: value, asset_id: value, opts: value
get_asset_accrued_fees3Accrued asset fees not yet minted as shares.hub: value, asset_id: value, opts: value
get_asset_config3Hub asset fee and interest-rate configuration.hub: value, asset_id: value, opts: value
get_asset3Full Hub asset position, including liquidity and drawn rate/index.hub: value, asset_id: value, opts: value
get_asset_count2Number of assets listed on the Hub.hub: value, opts: value
underlying_listed?3Whether an underlying token is listed on the Hub.hub: value, underlying: value, opts: value
get_spoke_deficit_ray4Spoke deficit for an asset, RAY-scaled.hub: value, asset_id: value, spoke: value, opts: value
get_spoke_premium_data4Premium shares and offset for a Spoke.hub: value, asset_id: value, spoke: value, opts: value
get_spoke_premium_ray4Premium a Spoke owes the Hub, RAY-scaled.hub: value, asset_id: value, spoke: value, opts: value
get_spoke_total_owed4Total amount a Spoke owes the Hub for an asset.hub: value, asset_id: value, spoke: value, opts: value
get_spoke_owed4Drawn and premium amounts a Spoke owes the Hub.hub: value, asset_id: value, spoke: value, opts: value
get_spoke_drawn_shares4Drawn shares of an asset for a Spoke.hub: value, asset_id: value, spoke: value, opts: value
get_spoke_added_shares4Shares added to the Hub by a Spoke.hub: value, asset_id: value, spoke: value, opts: value
get_spoke_added_assets4Assets added to the Hub by a Spoke.hub: value, asset_id: value, spoke: value, opts: value
get_spoke_config4Spoke caps, risk-premium threshold, and active/halted flags.hub: value, asset_id: value, spoke: value, opts: value
get_spoke4Spoke credit-line inventory and caps for an asset.hub: value, asset_id: value, spoke: value, opts: value
get_spoke_address4Spoke address for an asset at the given list index.hub: value, asset_id: value, index: value, opts: value
is_spoke_listed4Whether a Spoke is listed for an asset on the Hub.hub: value, asset_id: value, spoke: value, opts: value
get_spoke_count3Number of Spokes listed for an asset on the Hub.hub: value, asset_id: value, opts: value
hub_address2Resolve 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

hub()

@type hub() :: :core | :prime | :plus

Functions

get_added_assets(hub, asset_id, opts \\ [])

@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"
  }
}

get_added_shares(hub, asset_id, opts \\ [])

@spec get_added_shares(hub(), non_neg_integer(), keyword()) ::
  {:ok, non_neg_integer()} | {:error, term()}

Total added shares on 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 shares ({: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 shares"
  }
}

get_asset(hub, asset_id, opts \\ [])

@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"
  }
}

get_asset_accrued_fees(hub, asset_id, opts \\ [])

@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"
  }
}

get_asset_config(hub, asset_id, opts \\ [])

@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"
  }
}

get_asset_count(hub, opts \\ [])

@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"
  }
}

get_asset_deficit_ray(hub, asset_id, opts \\ [])

@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"
  }
}

get_asset_drawn_index(hub, asset_id, opts \\ [])

@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)"
  }
}

get_asset_drawn_rate(hub, asset_id, opts \\ [])

@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)"
  }
}

get_asset_drawn_shares(hub, asset_id, opts \\ [])

@spec get_asset_drawn_shares(hub(), non_neg_integer(), keyword()) ::
  {:ok, non_neg_integer()} | {:error, term()}

Hub-wide drawn shares 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 shares ({: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 shares"
  }
}

get_asset_id(hub, underlying, opts \\ [])

@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"
  }
}

get_asset_liquidity(hub, asset_id, opts \\ [])

@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)"
  }
}

get_asset_owed(hub, asset_id, opts \\ [])

@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"
  }
}

get_asset_premium_data(hub, asset_id, opts \\ [])

@spec get_asset_premium_data(hub(), non_neg_integer(), keyword()) ::
  {:ok, {non_neg_integer(), integer()}} | {:error, term()}

Hub-wide premium shares and offset 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

{premium shares, premium offset RAY} ({:ok, {non_neg_integer(), 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(), integer()}} | {:error, term()}",
    description: "{premium shares, premium offset RAY}"
  }
}

get_asset_premium_ray(hub, asset_id, opts \\ [])

@spec get_asset_premium_ray(hub(), non_neg_integer(), keyword()) ::
  {:ok, non_neg_integer()} | {:error, term()}

Hub-wide premium owed 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

Premium owed, 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: "Premium owed, RAY-scaled"
  }
}

get_asset_swept(hub, asset_id, opts \\ [])

@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"
  }
}

get_asset_total_owed(hub, asset_id, opts \\ [])

@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)"
  }
}

get_asset_underlying_and_decimals(hub, asset_id, opts \\ [])

@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}"
  }
}

get_spoke(hub, asset_id, spoke, opts \\ [])

@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"
  }
}

get_spoke_added_assets(hub, asset_id, spoke, opts \\ [])

@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)"
  }
}

get_spoke_added_shares(hub, asset_id, spoke, opts \\ [])

@spec get_spoke_added_shares(
  hub(),
  non_neg_integer(),
  String.t() | binary(),
  keyword()
) ::
  {:ok, non_neg_integer()} | {:error, term()}

Shares 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 shares ({: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 shares"
  }
}

get_spoke_address(hub, asset_id, index, opts \\ [])

@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"
  }
}

get_spoke_config(hub, asset_id, spoke, opts \\ [])

@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"
  }
}

get_spoke_count(hub, asset_id, opts \\ [])

@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"
  }
}

get_spoke_deficit_ray(hub, asset_id, spoke, opts \\ [])

@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"
  }
}

get_spoke_drawn_shares(hub, asset_id, spoke, opts \\ [])

@spec get_spoke_drawn_shares(
  hub(),
  non_neg_integer(),
  String.t() | binary(),
  keyword()
) ::
  {:ok, non_neg_integer()} | {:error, term()}

Drawn shares of an asset for 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

Drawn shares ({: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: "Drawn shares"
  }
}

get_spoke_owed(hub, asset_id, spoke, opts \\ [])

@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"
  }
}

get_spoke_premium_data(hub, asset_id, spoke, opts \\ [])

@spec get_spoke_premium_data(
  hub(),
  non_neg_integer(),
  String.t() | binary(),
  keyword()
) ::
  {:ok, {non_neg_integer(), integer()}} | {:error, term()}

Premium shares and offset for 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

{premium shares, premium offset RAY} ({:ok, {non_neg_integer(), 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(), integer()}} | {:error, term()}",
    description: "{premium shares, premium offset RAY}"
  }
}

get_spoke_premium_ray(hub, asset_id, spoke, opts \\ [])

@spec get_spoke_premium_ray(
  hub(),
  non_neg_integer(),
  String.t() | binary(),
  keyword()
) ::
  {:ok, non_neg_integer()} | {:error, term()}

Premium a Spoke owes the Hub, 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

Premium owed, 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: "Premium owed, RAY-scaled"
  }
}

get_spoke_total_owed(hub, asset_id, spoke, opts \\ [])

@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)"
  }
}

hub_address(hub, opts \\ [])

@spec hub_address(
  atom(),
  keyword()
) :: {:ok, String.t()} | {:error, term()}

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"
  }
}

is_spoke_listed(hub, asset_id, spoke, opts \\ [])

@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"
  }
}

max_allowed_spoke_cap(hub, opts \\ [])

@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)"
  }
}

max_allowed_underlying_decimals(hub, opts \\ [])

@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)"
  }
}

max_risk_premium_threshold(hub, opts \\ [])

@spec max_risk_premium_threshold(
  hub(),
  keyword()
) :: {:ok, non_neg_integer()} | {:error, term()}

Maximum Spoke risk-premium threshold. Using this value on SpokeConfig means no threshold.

Parameters

  • hub - Hub atom: :core, :prime, or :plus (value)
  • opts - Options: :network (default :ethereum), :rpc_url, :timeout, :block (default: [], value)

Returns

Threshold bound (uint24 BPS; max means no threshold) ({: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: "Threshold bound (uint24 BPS; max means no threshold)"
  }
}

min_allowed_underlying_decimals(hub, opts \\ [])

@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)"
  }
}

preview_add_by_assets(hub, asset_id, assets, opts \\ [])

@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)"
  }
}

preview_add_by_shares(hub, asset_id, shares, opts \\ [])

@spec preview_add_by_shares(hub(), non_neg_integer(), non_neg_integer(), keyword()) ::
  {:ok, non_neg_integer()} | {:error, term()}

Assets that would be added for the given shares. Rounds up.

Parameters

  • hub - Hub atom: :core, :prime, or :plus (value)
  • asset_id - Hub asset identifier (value)
  • shares - Share amount (value)
  • opts - Options: :network (default :ethereum), :rpc_url, :timeout, :block (default: [], value)

Returns

Assets added (rounded up) ({: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},
    shares: %{description: "Share amount", kind: :value}
  },
  returns: %{
    type: "{:ok, non_neg_integer()} | {:error, term()}",
    description: "Assets added (rounded up)"
  }
}

preview_draw_by_assets(hub, asset_id, assets, opts \\ [])

@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)"
  }
}

preview_draw_by_shares(hub, asset_id, shares, opts \\ [])

@spec preview_draw_by_shares(hub(), non_neg_integer(), non_neg_integer(), keyword()) ::
  {:ok, non_neg_integer()} | {:error, term()}

Assets that would be drawn for the given shares. Rounds down.

Parameters

  • hub - Hub atom: :core, :prime, or :plus (value)
  • asset_id - Hub asset identifier (value)
  • shares - Share amount (value)
  • opts - Options: :network (default :ethereum), :rpc_url, :timeout, :block (default: [], value)

Returns

Assets drawn (rounded down) ({: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},
    shares: %{description: "Share amount", kind: :value}
  },
  returns: %{
    type: "{:ok, non_neg_integer()} | {:error, term()}",
    description: "Assets drawn (rounded down)"
  }
}

preview_remove_by_assets(hub, asset_id, assets, opts \\ [])

@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)"
  }
}

preview_remove_by_shares(hub, asset_id, shares, opts \\ [])

@spec preview_remove_by_shares(hub(), non_neg_integer(), non_neg_integer(), keyword()) ::
  {:ok, non_neg_integer()} | {:error, term()}

Assets that would be removed for the given shares. Rounds down.

Parameters

  • hub - Hub atom: :core, :prime, or :plus (value)
  • asset_id - Hub asset identifier (value)
  • shares - Share amount (value)
  • opts - Options: :network (default :ethereum), :rpc_url, :timeout, :block (default: [], value)

Returns

Assets removed (rounded down) ({: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},
    shares: %{description: "Share amount", kind: :value}
  },
  returns: %{
    type: "{:ok, non_neg_integer()} | {:error, term()}",
    description: "Assets removed (rounded down)"
  }
}

preview_restore_by_assets(hub, asset_id, assets, opts \\ [])

@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)"
  }
}

preview_restore_by_shares(hub, asset_id, shares, opts \\ [])

@spec preview_restore_by_shares(
  hub(),
  non_neg_integer(),
  non_neg_integer(),
  keyword()
) ::
  {:ok, non_neg_integer()} | {:error, term()}

Assets that would be restored for the given shares. Rounds up.

Parameters

  • hub - Hub atom: :core, :prime, or :plus (value)
  • asset_id - Hub asset identifier (value)
  • shares - Share amount (value)
  • opts - Options: :network (default :ethereum), :rpc_url, :timeout, :block (default: [], value)

Returns

Assets restored (rounded up) ({: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},
    shares: %{description: "Share amount", kind: :value}
  },
  returns: %{
    type: "{:ok, non_neg_integer()} | {:error, term()}",
    description: "Assets restored (rounded up)"
  }
}

underlying_listed?(hub, underlying, opts \\ [])

@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"
  }
}