@axonfi/sdk 0.5.0 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -18,6 +18,17 @@ Giving bots funded wallets is risky: scattered keys, no spending controls, one c
18
18
 
19
19
  Your agents pay. You stay in control.
20
20
 
21
+ ## Features
22
+
23
+ - **Payments** — Send USDC or any ERC-20 to any address. Gasless for bots (EIP-712 intents, relayer pays gas). Per-tx caps, daily limits, AI verification.
24
+ - **DeFi Protocol Execution** — Interact with Uniswap, Aave, GMX, Ostium, Lido, and any on-chain protocol from your vault. Atomic approve/call/revoke.
25
+ - **In-Vault Swaps** — Rebalance tokens inside the vault without withdrawing. Separate caps from payment limits.
26
+ - **HTTP 402 Paywalls (x402)** — Native support for [x402](https://www.x402.org/) APIs. One-call `handlePaymentRequired()` handles parsing, vault funding, signing, and retry headers. EIP-3009 (USDC) and Permit2 (any ERC-20).
27
+ - **AI Verification** — 3-agent LLM consensus (safety, behavioral, reasoning) for flagged transactions. Configurable per bot: threshold-based or always-on.
28
+ - **Non-Custodial Vaults** — Each owner deploys their own vault. Only the owner can withdraw. Enforced on-chain.
29
+ - **Human-Friendly Amounts** — Pass `5`, `"5.2"`, or `5_200_000n`. SDK handles decimals. Token resolution by symbol, enum, or address.
30
+ - **Multi-Chain** — Base, Arbitrum. USDC as base asset. Same SDK, same API.
31
+
21
32
  ## Install
22
33
 
23
34
  ```bash
@@ -44,7 +55,7 @@ Everything can be done from code — no dashboard needed. An agent can bootstrap
44
55
  import {
45
56
  AxonClient, deployVault, addBot, deposit,
46
57
  createAxonPublicClient, createAxonWalletClient,
47
- NATIVE_ETH, USDC, WINDOW, Chain,
58
+ WINDOW, Chain,
48
59
  } from '@axonfi/sdk';
49
60
  import { parseUnits } from 'viem';
50
61
  import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts';
@@ -56,8 +67,7 @@ const ownerWallet = createAxonWalletClient(ownerKey, chainId);
56
67
  const publicClient = createAxonPublicClient(chainId, 'https://sepolia.base.org');
57
68
 
58
69
  // ── 2. Deploy vault (on-chain tx, ~0.001 ETH gas) ─────────────────
59
- const FACTORY = '0x...'; // AxonVaultFactory address for your chain
60
- const vaultAddress = await deployVault(ownerWallet, publicClient, FACTORY);
70
+ const vaultAddress = await deployVault(ownerWallet, publicClient);
61
71
  console.log('Vault deployed:', vaultAddress);
62
72
 
63
73
  // ── 3. Generate a bot keypair ──────────────────────────────────────
@@ -70,25 +80,25 @@ await axon.acceptTos(ownerWallet, ownerWallet.account!.address);
70
80
 
71
81
  // ── 5. Register the bot on the vault (on-chain tx, ~0.0005 ETH gas)
72
82
  await addBot(ownerWallet, publicClient, vaultAddress, botAddress, {
73
- maxPerTxAmount: parseUnits('100', 6), // $100 hard cap per tx
74
- maxRebalanceAmount: 0n, // no rebalance cap
83
+ maxPerTxAmount: 100, // $100 hard cap per tx
84
+ maxRebalanceAmount: 0, // no rebalance cap
75
85
  spendingLimits: [{
76
- amount: parseUnits('1000', 6), // $1,000/day rolling limit
77
- maxCount: 0n, // no tx count limit
86
+ amount: 1000, // $1,000/day rolling limit
87
+ maxCount: 0, // no tx count limit
78
88
  windowSeconds: WINDOW.ONE_DAY,
79
89
  }],
80
- aiTriggerThreshold: parseUnits('50', 6), // AI scan above $50
90
+ aiTriggerThreshold: 50, // AI scan above $50
81
91
  requireAiVerification: false,
82
92
  });
83
93
 
84
94
  // ── 6. Deposit funds (on-chain tx, ~0.0005 ETH gas) ───────────────
85
95
  // Option A: Deposit ETH (vault accepts native ETH directly)
86
96
  await deposit(ownerWallet, publicClient, vaultAddress,
87
- NATIVE_ETH, parseUnits('0.1', 18));
97
+ 'ETH', parseUnits('0.1', 18));
88
98
 
89
99
  // Option B: Deposit USDC (SDK handles approve + deposit)
90
100
  await deposit(ownerWallet, publicClient, vaultAddress,
91
- USDC[chainId], parseUnits('500', 6));
101
+ 'USDC', parseUnits('500', 6));
92
102
 
93
103
  // ── 7. Bot is ready — gasless from here ────────────────────────────
94
104
  // Save botKey securely. The bot never needs ETH.
@@ -120,7 +130,7 @@ Vaults accept native ETH directly — no wrapping needed. You can start a vault
120
130
  // Deploy vault + deposit ETH — no USDC needed
121
131
  const vault = await deployVault(ownerWallet, publicClient, factory);
122
132
  await addBot(ownerWallet, publicClient, vault, botAddress, config);
123
- await deposit(ownerWallet, publicClient, vault, NATIVE_ETH, parseUnits('0.5', 18));
133
+ await deposit(ownerWallet, publicClient, vault, 'ETH', parseUnits('0.5', 18));
124
134
 
125
135
  // Bot can now pay in any token — the relayer swaps ETH → USDC automatically
126
136
  await axon.pay({ to: '0x...', token: 'USDC', amount: 10 });