Indexes and processes transaction data from NEAR Intents 1-Click Explorer API. Outputs daily aggregated metrics to Vercel Blob Storage.
npm installCreate .env:
EXPLORER_API_KEY=your_explorer_api_key
BLOB_READ_WRITE_TOKEN=your_vercel_blob_tokennpm run workflowThis indexes new transactions and processes them. Uses deduplication to skip existing transactions automatically. Stops after 3 consecutive pages with no new data.
The daily JSON blob contains:
{
leaderboard: [{ referral: string, totalFeesUSD: number }],
chartData: [{ date: string, cumulativeFees: number, dailyFees: number }],
assetFlows: [{ symbol: string, totalInflowUSD: number, totalOutflowUSD: number, netFlowUSD: number, ... }],
chainFlows: [{ chain: string, totalInflowUSD: number, totalOutflowUSD: number, netFlowUSD: number, ... }],
providerFlows: [{ provider: string, totalInflowUSD: number, totalFeesUSD: number, averageFeeBps: number, ... }],
topRoutes: [{ fromAsset: string, toAsset: string, volumeUSD: number, count: number }],
totalInflowUSD: number,
totalOutflowUSD: number,
totalFees: number,
totalReferrals: number,
lastUpdated: string
}The data is uploaded to a stable URL that never changes:
const FEES_URL = 'https://thvomwknsgnklfce.public.blob.vercel-storage.com/referral-fees.json';
const response = await fetch(FEES_URL);
const data = await response.json();Add to crontab for daily runs:
0 0 * * * cd /path/to/fees && npm run workflow >> /var/log/fees.log 2>&1index.ts- Fetches transactions (deduplicates automatically)process.ts- Processes CSV, uploads to blobreferral-fees.csv- Local transaction storage