What is an Adapter?
An adapter is a standardized module that fetches, transforms, and exports points data from a specific protocol or platform. Each adapter implements a consistent interface that allows the SDK to query points balances across multiple protocols uniformly. Adapters abstract away the complexity of different API formats, authentication methods, and data structures, providing a clean interface for retrieving user points data.The AdapterExport Interface
Every adapter must implement theAdapterExport interface defined in utils/adapter.ts:12-20:
Required Properties
fetch
The core data retrieval function that fetches raw points data from the protocol’s API.
- Input: User’s blockchain address (EVM or SVM format)
- Output: Promise resolving to raw API response data
- Responsibility: Handle API calls, authentication, error handling
adapters/sonic.ts:21-29):
data
Transforms raw API response into a structured, human-readable format.
- Input: Raw data from
fetch - Output: Key-value pairs with display-friendly labels and values
- Responsibility: Extract relevant fields, format dates, organize nested data
adapters/etherfi.ts:17-61):
total
Calculates the total points balance for the address.
- Input: Raw data from
fetch - Output: Single number or labeled point categories
- Responsibility: Sum up all relevant point values
adapters/sonic.ts:41):
adapters/dolomite.ts:37-39):
supportedAddressTypes
Specifies which blockchain address formats this adapter supports.
- Values: Array containing
"evm"and/or"svm" - Responsibility: Declare address type compatibility
- Validation: The SDK validates addresses before calling
fetch
Optional Properties
claimable
Indicates whether the points are currently claimable/withdrawable.
adapters/dolomite.ts:41):
rank
Extracts the user’s leaderboard ranking if available.
adapters/sonic.ts:42):
deprecated
Marks certain point categories as deprecated with a Unix timestamp.
adapters/dolomite.ts:42-44):
Data Flow Through an Adapter
When you query an adapter, the data flows through these stages:Address Validation
The SDK validates the address format and checks if the adapter supports that address type (
utils/adapter.ts:32-47).Complete Adapter Example
Here’s the full Dolomite adapter showing all concepts together:Type Definitions
Key types used in adapters (utils/adapter.ts:6-9):
Best Practices
Use CORS Proxying
Always wrap API URLs with
maybeWrapCORSProxy for browser compatibility. See CORS Handling for details.Validate and Normalize Addresses
Use
checksumAddress or getAddress from viem for EVM addresses to ensure proper formatting.Handle Missing Data Gracefully
Always provide fallback values when API responses might be incomplete or null.
Include User-Agent Headers
Add identifying headers to API requests for better tracking and debugging.
Next Steps
Address Types
Learn about EVM and SVM address validation
CORS Handling
Understand browser compatibility and CORS proxying