UNPKG

@agentek/tools

Version:

Blockchain tools for AI agents

69 lines 1.9 kB
import { RISK_THRESHOLDS } from '../constants.js'; // Helper function to format USD values export function formatUSD(value) { return `$${value.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2, })}`; } // Risk assessment function export function assessRisk(apy) { if (apy > RISK_THRESHOLDS.medium) return 'high'; if (apy > RISK_THRESHOLDS.low) return 'medium'; return 'low'; } // Helper function to get chain name export function getChainName(chainId) { const chainMap = { 1: 'Ethereum', 10: 'Optimism', 137: 'Polygon', 42161: 'Arbitrum', 8453: 'Base', 43114: 'Avalanche', 56: 'BSC', 250: 'Fantom', 100: 'Gnosis', 1399811149: 'Solana', 1101: 'Polygon zkEVM', 324: 'zkSync Era', }; return chainMap[chainId] || `Chain ${chainId}`; } // Helper function to calculate projected earnings export function calculateProjectedEarnings(amount, apy, days) { // Convert APY to daily rate const dailyRate = (1 + apy / 100) ** (1 / 365) - 1; // Compound interest formula return amount * ((1 + dailyRate) ** days - 1); } // Chain ID mapping for DefiLlama export const chainIdMap = { 'Ethereum': 1, 'Optimism': 10, 'Polygon': 137, 'Arbitrum': 42161, 'Base': 8453, 'Avalanche': 43114, 'BSC': 56, 'Fantom': 250, 'Gnosis': 100, 'Solana': 1399811149, 'Polygon zkEVM': 1101, 'zkSync Era': 324, }; // Get protocol project filter for DefiLlama export function getProjectFilter(protocol) { const projectMap = { 'Aave': 'aave', 'Compound': 'compound', 'Morpho': 'morpho', 'SparkLend': 'spark', 'Lido': 'lido', 'RocketPool': 'rocket-pool', }; return projectMap[protocol] || null; } //# sourceMappingURL=helpers.js.map