JSPM

  • Created
  • Published
  • Downloads 148
  • Score
    100M100P100Q99246F
  • License MIT

Give your AI agents a wallet they can't drain. TypeScript SDK for Axon Finance.

Package Exports

  • @axonfi/sdk

Readme

@axonfi/sdk

Give your AI agents a wallet they can't drain.

What is Axon Finance

Treasury and payment infrastructure for autonomous AI agents. Non-custodial vaults, gasless bots, AI verification.

Why Axon Finance

Giving bots funded wallets is risky: scattered keys, no spending controls, one compromised key drains everything. Axon flips this model:

  • Non-custodial vaults — each owner deploys their own vault. Only the owner can withdraw. Enforced on-chain.
  • Bounded risk — per-tx caps, daily limits, velocity windows, destination whitelists. Bots can only operate within the policies you set.
  • AI verification — 3-agent LLM consensus (safety, behavioral, reasoning) for flagged transactions. 2/3 consensus required.
  • Gasless bots — bots sign EIP-712 intents off-chain. Axon's relayer handles gas, simulation, and on-chain execution.
  • Multi-chain — Base, Arbitrum, Optimism, Polygon. USDC as base asset.

Your agents pay. You stay in control.

Install

npm install @axonfi/sdk

Quick Start

import { AxonClient, Chain, Token, decryptKeystore } from '@axonfi/sdk';
import fs from 'fs';

const keystore = fs.readFileSync('./axon-bot.json', 'utf8');
const botPrivateKey = await decryptKeystore(keystore, process.env.BOT_PASSPHRASE!);

const axon = new AxonClient({
  vaultAddress: '0x...',
  chainId: Chain.Base,
  botPrivateKey,
});

// Pay 5 USDC — SDK handles decimals automatically
const result = await axon.pay({
  to: '0xRecipient',
  token: Token.USDC,
  amount: 5,
  memo: 'API call payment',
});

console.log(result.status, result.txHash);

With Raw Private Key

import { AxonClient, Chain } from '@axonfi/sdk';

const axon = new AxonClient({
  vaultAddress: '0x...',
  chainId: Chain.Base,
  botPrivateKey: process.env.BOT_PRIVATE_KEY!,
});

Human-Friendly Amounts

The SDK accepts amounts in three formats:

// Human-readable number — SDK converts using token decimals
await axon.pay({ to, token: Token.USDC, amount: 5.2 });

// Human-readable string — recommended for computed values
await axon.pay({ to, token: Token.USDC, amount: '5.2' });

// Raw bigint — base units, passed through as-is
await axon.pay({ to, token: Token.USDC, amount: 5_200_000n });

Token field accepts addresses, Token enum values, or symbol strings:

import { Token, USDC } from '@axonfi/sdk';

token: 'USDC'; // bare symbol string
token: Token.USDC; // type-safe enum
token: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'; // raw address

API

Payments

Send USDC (or any ERC-20) to any address. The bot signs an EIP-712 intent — Axon verifies it against your vault's spending policies, simulates the transaction, and executes on-chain. If the payment exceeds the AI threshold, it goes through 3-agent verification before execution.

const result = await axon.pay({
  to: '0xRecipient',
  token: Token.USDC,
  amount: 25,
  memo: 'Invoice #42',
});

// Poll async payments (AI scan or human review)
const status = await axon.poll(result.requestId);

In-Vault Swaps

Rebalance tokens inside your vault without withdrawing. Swap between any tokens on the vault's rebalance whitelist (set by the owner). Each bot has a separate maxRebalanceAmount cap — independent from payment limits.

const result = await axon.swap({
  toToken: Token.WETH,
  minToAmount: 0.001,
  memo: 'Rebalance to WETH',
});

DeFi Protocol Execution

Interact with DeFi and Web3 protocols (Uniswap, Aave, GMX, etc.) that need permission to access collateral from your vault. The bot signs an ExecuteIntent specifying the target contract and calldata. The relayer handles token approvals, execution, and revocation in a single atomic transaction. All executions are subject to the bot's per-transaction and daily spending limits.

const result = await axon.execute({
  protocol: '0xUniswapRouter',
  callData: '0x...',
  token: Token.USDC,
  amount: 100,
});

Vault Reads

Query your vault's on-chain state — balances, bot status, pause state, and destination checks. All reads go through the relayer (no RPC connection needed).

await axon.getBalance('USDC'); // vault token balance
await axon.isActive(); // bot registered + active?
await axon.isPaused(); // vault paused?
await axon.getVaultInfo(); // owner, operator, version
await axon.canPayTo('0xRecipient'); // destination allowed?

Utilities

Helper functions for amount conversion, token resolution, and reference encoding.

import { parseAmount, resolveTokenDecimals, resolveToken, encodeRef } from '@axonfi/sdk';

parseAmount(5.2, 'USDC'); // 5_200_000n
resolveTokenDecimals('WETH'); // 18
resolveToken('USDC', 8453); // 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
encodeRef('invoice-042'); // keccak256 → bytes32

Response Paths

Payments resolve through one of three paths:

Path Trigger Timing Response
Fast Below all thresholds ~2s status: "approved", txHash
AI Scan Exceeds AI threshold ~30s status: "approved" or routes to review
Human Review No AI consensus Async status: "pending_review", poll for result

Security Model

  • Owners control everything: bot whitelist, spending limits, withdrawal. Hardware wallet recommended.
  • Bots only sign payment intents. They never hold ETH, never submit transactions, and can be removed instantly.
  • Relayer (Axon) can only execute bot-signed intents within configured limits. Cannot withdraw or modify vault config.
  • If Axon goes offline, the owner retains full withdrawal access directly through the on-chain vault contract.

Chains

Chain ID Status
Base Sepolia 84532 Live
Base 8453 Coming soon
Arbitrum One 42161 Coming soon
Optimism 10 Coming soon
Polygon PoS 137 Coming soon

License

MIT