API ReferenceReact provider and hooksFunction
useCollateralTokens()
function useCollateralTokens(params?): UseCollateralTokensResult;Fetches the Anvil protocol’s collateral tokens. Maps to the action getCollateralTokens.
Pages are fetched progressively and each is held fresh for five minutes. Omitting params.limit
applies the SDK’s default collection page size.
Parameters
| Parameter | Type | Description |
|---|---|---|
params? | GetCollateralTokensParams | Pagination and filter options forwarded to getCollateralTokens. Omit for the default first page. |
Returns
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> )} </> );}