API ReferenceReact provider and hooksFunction
useCollateralTokens()
function useCollateralTokens(params?): UseCollateralTokensResult;Fetches every token the Collateral Vault knows as collateral, each with its enabled flag, one page
at a time and with React state for loading and errors. It reads the same data as
“@anvilresearchlabs/sdk”!LOCModule.getCollateralTokens.
Each page is reused for five minutes before it is read again. Omitting params.limit applies the
SDK’s default page size.
Parameters
| Parameter | Type | Description |
|---|---|---|
params? | GetCollateralTokensParams | Pagination and filter options forwarded to “@anvilresearchlabs/sdk”!LOCModule.getCollateralTokens. Omit for the default first page. |
params.collateralContractAddress? | `0x${string}` | Collateral Vault whose tokens to list; defaults to the profile’s current vault. |
params.cursor? | string | null | The nextCursor from the previous page, passed back unchanged. Omit it, or pass null, for the first page. |
params.enabled? | boolean | Filter on whether the Collateral Vault currently accepts the token for new deposits and reservations. true returns only usable tokens (the common case for a token picker); false returns tokens Anvil Governance has disabled but that may still back existing LOCs; omit for both. |
params.limit? | number | Maximum number of items on the page, from 1 to 1000. Defaults to 250. |
params.tokenAddressAllowlist? | `0x${string}`[] | Restrict results to these token addresses. Omit or pass [] for all collateral tokens. |
Returns
UseCollateralTokensResult
Progressive pages and flattened items, plus initial and next-page loading and error state. Call
fetchNextPage to follow the exact cursor or retry after a transient failure.
Throws
Error when rendered outside <AnvilProvider>, by way of useAnvilSDK.
Example
export function CollateralTokenList() { const { items, hasNextPage, fetchNextPage, isFetchingNextPage, error } = useCollateralTokens();
if (error) return <p>{error.message}</p>; return ( <> <ul> {items.map(token => ( <li key={token.token.address}>{token.token.symbol}</li> ))} </ul> {hasNextPage && ( <button onClick={fetchNextPage} disabled={isFetchingNextPage}> Load more </button> )} </> );}