API Reference
Note: The APIs are currently in closed alpha testing and not yet live. This reference is for partners to review and understand our development progress.
Generates a unique nonce and signing message for wallet-based authentication.
Flow:
Call this endpoint with your wallet address
Receive a nonce and message to sign
Sign the message with your wallet
Submit signature to
/auth/login
Data Source: PostgreSQL Expires: 5 minutes
^0x[a-fA-F0-9]{40}$Nonce created successfully
Invalid wallet address format
Authenticates a user by verifying their wallet signature against the nonce. Returns a JWT token and API key for subsequent requests.
Security: ECDSA signature verification ensures only the wallet owner can authenticate.
Returns:
JWT bearer token (for session-based auth)
API key credentials (for programmatic access)
Hex-encoded ECDSA signature
Login successful
Invalid request payload
Signature verification failed or nonce expired
Returns all API keys associated with the authenticated user.
Note: Secrets are not returned. Only key metadata is shown.
API key authentication. Contact the Tetrics team to obtain your API key.
Format: Authorization: ApiKey <key_id>:<secret>
Example: Authorization: ApiKey 550e8400-e29b-41d4-a716-446655440000:your-secret-key
API keys retrieved
Unauthorized
Creates a new API key with custom permissions and rate limits.
Use Cases:
Separate keys for different applications
Custom rate limits per use case
Role-based access control
Important: The secret is only returned once. Store it securely.
API key authentication. Contact the Tetrics team to obtain your API key.
Format: Authorization: ApiKey <key_id>:<secret>
Example: Authorization: ApiKey 550e8400-e29b-41d4-a716-446655440000:your-secret-key
API key created
Invalid request
Unauthorized
Permanently revokes an API key. This action cannot be undone.
Use Cases:
Rotating compromised keys
Deactivating unused keys
Security best practices
API key authentication. Contact the Tetrics team to obtain your API key.
Format: Authorization: ApiKey <key_id>:<secret>
Example: Authorization: ApiKey 550e8400-e29b-41d4-a716-446655440000:your-secret-key
API key ID to revoke
API key revoked successfully
Unauthorized
API key not found
Returns aggregated staking metrics for a protocol (APY, TVL, total stakers).
Scope: Protocol-wide (not user-specific) Data Source: Mixed (DeFiLlama API, protocol APIs, on-chain queries) Data Freshness: Cached (refreshed every 5-15 minutes)
Supported Protocols:
lido: Ethereum staking via Lidowsteth: Wrapped stETHmorpho: Morpho lending protocolhype-staking: HYPE staking for beHYPEhyperlend: HyperLend protocolfelix: Felix CDP protocolhyperbeat: HyperBeat meta vault
Use Cases: Protocol comparison, APY discovery, TVL monitoring
Protocol identifier
Protocol metrics
Protocol not found
Returns protocol configuration including supported methods, parameter constraints, and gas estimates.
Data Source: JSON protocol configuration files Use Cases: Dynamic form generation, parameter validation, gas estimation
Protocol metadata
Protocol metadata
Returns current staking balances across all supported protocols by querying blockchain in real-time.
Position Type: Yield-bearing ERC20 tokens (stETH, wstETH, beHYPE, etc.) Data Source: On-chain (Ethereum/Hyperliquid RPC via PositionTracker) Data Freshness: Real-time blockchain query Chain Scope: Multi-chain (Ethereum + Hyperliquid)
Returns:
All non-zero token balances for staking protocols
Current USD values
Protocol metadata
Use Cases: Real-time portfolio tracking, yield monitoring, liquidity management
API key authentication. Contact the Tetrics team to obtain your API key.
Format: Authorization: ApiKey <key_id>:<secret>
Example: Authorization: ApiKey 550e8400-e29b-41d4-a716-446655440000:your-secret-key
Wallet address
^0x[a-fA-F0-9]{40}$Current staking positions
Unauthorized
Returns historical staking transactions (stakes, withdrawals) for the user.
Data Source: PostgreSQL (staking_position_history table) Data Freshness: Updated after each staking transaction
Use Cases: Transaction history, audit trails, rewards tracking
API key authentication. Contact the Tetrics team to obtain your API key.
Format: Authorization: ApiKey <key_id>:<secret>
Example: Authorization: ApiKey 550e8400-e29b-41d4-a716-446655440000:your-secret-key
Filter by protocol
50Staking history
Staking history
Returns aggregated staking statistics across all protocols for the user.
Data Source: Computed from on-chain positions Aggregations: Total staked value (USD), positions by protocol, positions by chain
Use Cases: Portfolio overview, total value calculation, protocol diversification analysis
API key authentication. Contact the Tetrics team to obtain your API key.
Format: Authorization: ApiKey <key_id>:<secret>
Example: Authorization: ApiKey 550e8400-e29b-41d4-a716-446655440000:your-secret-key
Staking summary
Staking summary
Executes a staking transaction (stake, unstake, withdraw, etc.) for the specified protocol.
Execution Modes:
direct: API executes transaction with its own wallet (testing/development)broadcast: User provides signed transaction for broadcasting (production)
Supported Methods (vary by protocol):
deposit,stake: Stake tokenswithdraw,unstake: Withdraw staked tokenswrap,unwrap: Convert between token forms (e.g., stETH ↔ wstETH)supply,borrow,repay,redeem: Lending operations (Morpho, HyperLend)
Data Source: On-chain execution via protocol adapters Returns: Transaction receipt with gas used, output amounts
API key authentication. Contact the Tetrics team to obtain your API key.
Format: Authorization: ApiKey <key_id>:<secret>
Example: Authorization: ApiKey 550e8400-e29b-41d4-a716-446655440000:your-secret-key
Amount in token units (wei for ETH)
For broadcast mode
Transaction executed
Invalid parameters
Transaction failed
Simulates a staking transaction to preview gas costs and output amounts without executing on-chain.
Use Cases: Gas estimation, parameter validation, dry-run testing
Returns:
Estimated gas cost
Expected output amount
Validation errors (if any)
API key authentication. Contact the Tetrics team to obtain your API key.
Format: Authorization: ApiKey <key_id>:<secret>
Example: Authorization: ApiKey 550e8400-e29b-41d4-a716-446655440000:your-secret-key
Amount in token units (wei for ETH)
For broadcast mode
Preview result
Invalid parameters
Returns unified view of all collateral and debt positions across lending protocols and chains.
Position Type: Collateral deposits and borrowed amounts Data Source: PostgreSQL (cross_chain_positions table) Data Freshness: Last sync timestamp (call /sync to update) Chain Scope: Cross-chain (Ethereum + Hyperliquid) Protocols: Morpho, HyperLend, Aave-like protocols
Returns:
All collateral positions
All debt positions
Grouped by chain and protocol
USD values and weighted amounts
Market overview and top exposures
Use Cases:
Unified portfolio view
Cross-protocol position tracking
Collateral diversification analysis
Important: Data is synced from blockchain. Call /api/margin/sync/:address to refresh.
API key authentication. Contact the Tetrics team to obtain your API key.
Format: Authorization: ApiKey <key_id>:<secret>
Example: Authorization: ApiKey 550e8400-e29b-41d4-a716-446655440000:your-secret-key
Margin account address
^0x[a-fA-F0-9]{40}$Margin positions
Unauthorized
Margin account not found
Returns detailed health factor analysis and liquidation risk metrics.
Data Source: PostgreSQL (health_snapshots table) Calculation: Weighted collateral / weighted debt with protocol-specific LTV ratios Data Freshness: Last sync timestamp
Metrics:
Health factor (>1.0 = safe, <1.0 = liquidatable)
Total collateral (USD)
Weighted collateral with LTV ratios
Total debt (USD)
Distance to liquidation (%)
Max borrowable amount
Risk level (healthy/warning/critical)
Use Cases:
Liquidation prevention
Risk monitoring alerts
Borrowing capacity calculation
Important: Call /api/margin/sync/:address first for up-to-date health metrics.
API key authentication. Contact the Tetrics team to obtain your API key.
Format: Authorization: ApiKey <key_id>:<secret>
Example: Authorization: ApiKey 550e8400-e29b-41d4-a716-446655440000:your-secret-key
Health metrics
Unauthorized
Triggers synchronization of margin positions from on-chain state to database.
Process:
Queries all lending protocols on-chain
Fetches oracle prices
Calculates health metrics
Updates database with latest positions
Data Source: On-chain → PostgreSQL via PositionSyncService Duration: ~2-5 seconds Protocols Synced: All enabled lending protocols (optional filter)
Use Cases:
Before checking health factor
After executing positions on-chain
Scheduled background jobs
Returns: Sync job status with updated position counts
API key authentication. Contact the Tetrics team to obtain your API key.
Format: Authorization: ApiKey <key_id>:<secret>
Example: Authorization: ApiKey 550e8400-e29b-41d4-a716-446655440000:your-secret-key
Optional filter for specific protocols
Sync completed
Unauthorized
Sync failed
Returns lending market metrics across all supported protocols with advanced filtering.
Scope: Protocol-wide market data (not user-specific) Data Source: PostgreSQL (market_metrics, market_protocol_metrics tables) Data Freshness: Background scheduler updates every 5-15 minutes
Metrics:
Total supply and borrow (USD)
Utilization rate
Supply APY and borrow APY
Oracle health status
Risk score
Market volatility
Filters:
protocol: Filter by protocol namechain: Filter by chainasset: Filter by asset symbolmarket_type: lending/borrowing/vaultrisk_min/risk_max: Filter by risk score
Use Cases:
Market opportunity discovery
Yield comparison across protocols
Risk-based market filtering
Note: This endpoint should ideally be at /api/markets (not /api/margin/markets).
API key authentication. Contact the Tetrics team to obtain your API key.
Format: Authorization: ApiKey <key_id>:<secret>
Example: Authorization: ApiKey 550e8400-e29b-41d4-a716-446655440000:your-secret-key
Market metrics
Unauthorized
Returns all lending markets and aggregated protocol metrics for a single protocol.
Data Source: PostgreSQL Returns:
Individual market metrics
Protocol-level aggregates (total TVL, average utilization, etc.)
Use Cases: Protocol-specific analysis, deep-dive into single protocol
API key authentication. Contact the Tetrics team to obtain your API key.
Format: Authorization: ApiKey <key_id>:<secret>
Example: Authorization: ApiKey 550e8400-e29b-41d4-a716-446655440000:your-secret-key
Protocol identifier (e.g., "morpho", "hyperlend")
Protocol markets
Unauthorized
Protocol not found
Returns historical snapshots of market metrics for trend analysis.
Data Source: PostgreSQL (market_metrics_history table) Granularity: Hourly or daily snapshots Time Range: Configurable via query parameters
Use Cases:
Utilization trend charts
APY history tracking
Market volatility analysis
Query Parameters:
market_id: Specific market identifier (required)start_date: Start of time rangeend_date: End of time rangelimit: Max number of snapshots
API key authentication. Contact the Tetrics team to obtain your API key.
Format: Authorization: ApiKey <key_id>:<secret>
Example: Authorization: ApiKey 550e8400-e29b-41d4-a716-446655440000:your-secret-key
100Market history
Unauthorized
Simulates the impact of a supply or borrow action on market metrics.
Simulation Logic:
Adds hypothetical supply/borrow to current market state
Recalculates utilization rate
Projects new APY based on utilization curve
Estimates new risk score
Use Cases:
What-if analysis before large positions
Optimal amount calculation
Market impact estimation
Inputs:
market_id: Target marketaction: "supply" or "borrow"amount: Amount to simulate (in token units)stress_pct: Optional stress test % (default: 0)
Returns:
Projected supply and borrow amounts
Projected utilization rate
Projected risk score
Warnings if thresholds exceeded
API key authentication. Contact the Tetrics team to obtain your API key.
Format: Authorization: ApiKey <key_id>:<secret>
Example: Authorization: ApiKey 550e8400-e29b-41d4-a716-446655440000:your-secret-key
Amount in token units
Stress test percentage (default 0)
Simulation result
Invalid simulation parameters
Unauthorized
Returns ETH and token balances for the provided wallet across all supported chains.
Wallet address (0x-prefixed)
^0x[a-fA-F0-9]{40}$Balance snapshot
Invalid account address supplied
Establishes a WebSocket connection for streaming real-time strategy execution updates, transaction receipts, and balance changes.
Message Types:
strategy_progress- Step-by-step execution updatestransaction_update- Transaction confirmation eventsbalance_update- Wallet balance changeserror- Execution errors and warnings
Example Message:
{
"type": "strategy_progress",
"data": {
"execution_id": "abc-123",
"step": 2,
"total_steps": 5,
"protocol": "lido",
"status": "completed"
}
}WebSocket connection established
Invalid WebSocket upgrade request
No content
Last updated