Here’s how to import and use an adapter programmatically:
import { runAdapter } from "./utils/adapter.ts";import sonicAdapter from "./adapters/sonic.ts";// Run the adapterconst address = "0x3c2573b002cf51e64ab6d051814648eb3a305363";const result = await runAdapter(sonicAdapter, address);// Access the normalized dataconsole.log("Total Points:", result.total);console.log("User Rank:", result.rank);console.log("Detailed Data:", result.data);// Check if rewards are claimableif (result.claimable) { console.log("You have claimable rewards!");}
Some adapters return labeled points instead of a single number:
import { runAdapter } from "./utils/adapter.ts";import etherfiAdapter from "./adapters/etherfi.ts";const result = await runAdapter(etherfiAdapter, "0x...");// ether.fi returns grouped dataconsole.log(result.data);/*{ "All Time Points": { "Loyalty Points": 1000, "Liquid Points": 500, // ... }, "Current Points": { "Loyalty Points": 800, "Liquid Points": 400, }}*/// Total is also a simple number for ether.ficonsole.log(result.total); // 1200