Skip to content

vinhlochuynh17/axelarscan-api

 
 

Repository files navigation

Axelarscan API

A comprehensive API service for Axelar's blockchain data, providing TVL calculations, token information, cross-chain analytics, and real-time blockchain data management.

🚀 Getting Started

Prerequisites

Before you begin, ensure you have the following installed:

1. Install Node Version Manager (nvm)

Follow the instructions on its repo.

2. Install Node.js and pnpm

# Install the project's version
nvm use

# Verify installation
node --version  # Should show v20.19.4

# Enable pnpm
corepack enable pnpm

3. Install Dependencies

pnpm i

Development Tools

TypeScript Support

This project has TypeScript support configured:

# Build TypeScript files
pnpm run build

# Build and watch for changes
pnpm run build:watch

# Clean build output
pnpm run clean

The built files are located in the dist directory.

Local Development

For local development, refer to the local directory.

Linting and Formatting

This project uses ESLint for linting and Prettier for code formatting:

# Check linting
pnpm run lint:check

# Fix linting issues automatically
pnpm run lint

# Check code formatting
pnpm run format:check

# Format code automatically
pnpm run format

# Run both linting and formatting
pnpm run lint:format

API Endpoints

Stacks

  • AWS Lambda
  • AWS API Gateway
  • AWS EventBridge
  • OpenSearch (for caching and indexing)

Architecture

TVL (Total Value Locked) System

The TVL system is built using caching and background processing.

Core Components

  1. getTVL Function (methods/tvl/getTVL.js)

    • Calculates TVL across all supported assets and chains
    • Supports caching for fast response times
    • Processes 31+ assets across 70+ blockchain networks
  2. Background Update Service (services/interval-update/updateTVL.js)

    • Runs periodically to pre-calculate TVL data
    • Processes assets in batches to avoid timeouts
    • Only runs on mainnet in production
  3. OpenSearch Caching (services/indexer/)

    • Stores calculated TVL data for fast retrieval
    • Manages IBC channel data and token information
    • Provides search and query capabilities

Caching Strategy

Production Behavior:

  • Background job processes assets in 10 groups over 10-minute intervals
  • Each asset is calculated individually and cached immediately
  • API calls return cached data (sub-second response times)
  • Only processes ~3 assets per 6-minute window

Cache Parameters:

  • forceCache: true - Forces fresh calculation, bypasses cache
  • isIntervalUpdate: true - Indicates background job execution
  • customAssetsOnly: true - Processes only custom/contract assets

Cache Collections:

  • token_tvls - Individual asset TVL data
  • ibc_channels - Inter-blockchain communication channel data
  • token_prices - Token price information
  • token_infos - Token metadata and configuration

Performance Characteristics

  • Production: Sub-second response (cached data)
  • Local Development: 5-10 minutes (full calculation)
  • Background Processing: ~3 assets per 6-minute window
  • Total Operations: 31 assets × 71 chains = 2,201 blockchain queries

Local Development

For local development setup and usage instructions, see local/README.md.

Quick start:

# Setup OpenSearch indices and populate IBC data
node local/setup-indexer.js

# Pre-populate cache data (recommended)
node local/run-updates.js

# Run the dev server
pnpm dev

Deployment

Prerequisites

  1. Install AWS CLI
  2. Configuring the AWS CLI
  3. Install terraform
pnpm i
cd ./terraform/testnet
terraform init
terraform apply

About

Axelarscan API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 82.6%
  • HCL 10.4%
  • TypeScript 6.8%
  • Dockerfile 0.2%