Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions sdk/hooks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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()
```

<Note>
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.
</Note>

## Quotes and Swapping

```ts
Expand Down