From b2dcefd08fd79d2d46874f827ec46d8e5aa429c7 Mon Sep 17 00:00:00 2001 From: James Lawton Date: Wed, 14 Jan 2026 09:53:02 +0000 Subject: [PATCH] Update sdk/hooks.mdx Co-Authored-By: mintlify[bot] <109931778+mintlify[bot]@users.noreply.github.com> --- sdk/hooks.mdx | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/sdk/hooks.mdx b/sdk/hooks.mdx index 5bc71a8..484356a 100644 --- a/sdk/hooks.mdx +++ b/sdk/hooks.mdx @@ -273,6 +273,46 @@ type UseTokenBalancesForMultipleAccountsReturn = { } ``` +## Prices + +```ts +import { clearLocalStoragePriceCache, cleanupExpiredPriceCache } from '0xtrails' +``` + +The Trails SDK automatically caches token prices in localStorage for 60 seconds to improve performance and reduce API calls. These utility functions allow you to manually manage the price cache for advanced use cases. + +### clearLocalStoragePriceCache + +Clears all cached token prices from localStorage. This is useful when you need to force a fresh fetch of all prices or when implementing cache invalidation logic. + +**Signature**: `() => void` + +**Usage**: +```ts +import { clearLocalStoragePriceCache } from '0xtrails' + +// Clear all cached prices +clearLocalStoragePriceCache() +``` + +### cleanupExpiredPriceCache + +Removes only expired price entries from the localStorage cache while keeping valid entries. The SDK automatically runs cleanup periodically (every 5 minutes), but you can manually trigger it if needed. + +**Signature**: `() => void` + +**Usage**: +```ts +import { cleanupExpiredPriceCache } from '0xtrails' + +// Remove expired entries from cache +cleanupExpiredPriceCache() +``` + + +The price cache is automatically managed by the SDK. These functions are provided for advanced use cases where manual cache control is needed, such as implementing custom cache invalidation strategies or debugging price-related issues. + + ## Quotes and Swapping ```ts