@axonfi/sdk 0.1.2 → 0.2.1

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 ADDED
@@ -0,0 +1,186 @@
1
+ # @axonfi/sdk
2
+
3
+ Give your AI agents a wallet they can't drain.
4
+
5
+ Treasury and payment infrastructure for autonomous AI agents. Non-custodial vaults, gasless bots, AI verification.
6
+
7
+ ## Why Axon Finance
8
+
9
+ Giving bots funded wallets is risky: scattered keys, no spending controls, one compromised key drains everything. Axon flips this model:
10
+
11
+ - **Non-custodial vaults** — each owner deploys their own vault. Only the owner can withdraw. Enforced on-chain.
12
+ - **Bounded risk** — per-tx caps, daily limits, velocity windows, destination whitelists. Bots can only operate within the policies you set.
13
+ - **AI verification** — 3-agent LLM consensus (safety, behavioral, reasoning) for flagged transactions. 2/3 consensus required.
14
+ - **Gasless bots** — bots sign EIP-712 intents off-chain. Axon's relayer handles gas, simulation, and on-chain execution.
15
+ - **Multi-chain** — Base, Arbitrum, Optimism, Polygon. USDC as base asset.
16
+
17
+ Your agents pay. You stay in control.
18
+
19
+ ## Install
20
+
21
+ ```bash
22
+ npm install @axonfi/sdk viem
23
+ ```
24
+
25
+ ## Quick Start
26
+
27
+ ```typescript
28
+ import { AxonClient } from '@axonfi/sdk';
29
+
30
+ const axon = new AxonClient({
31
+ vaultAddress: '0x...',
32
+ chainId: 8453, // Base
33
+ botPrivateKey: '0x...',
34
+ relayerUrl: 'https://relay.axonfi.xyz',
35
+ });
36
+
37
+ // Pay 5 USDC — SDK handles decimals automatically
38
+ const result = await axon.pay({
39
+ to: '0xRecipient',
40
+ token: 'USDC',
41
+ amount: 5,
42
+ memo: 'API call payment',
43
+ });
44
+
45
+ console.log(result.status, result.txHash);
46
+ ```
47
+
48
+ ### Human-Friendly Amounts
49
+
50
+ The SDK accepts amounts in three formats:
51
+
52
+ ```typescript
53
+ // Human-readable number — SDK converts using token decimals
54
+ await axon.pay({ to, token: 'USDC', amount: 5.2 });
55
+
56
+ // Human-readable string — recommended for computed values
57
+ await axon.pay({ to, token: 'USDC', amount: '5.2' });
58
+
59
+ // Raw bigint — base units, passed through as-is
60
+ await axon.pay({ to, token: 'USDC', amount: 5_200_000n });
61
+ ```
62
+
63
+ Token field accepts addresses, `Token` enum values, or symbol strings:
64
+
65
+ ```typescript
66
+ import { Token, USDC } from '@axonfi/sdk';
67
+
68
+ token: 'USDC'; // bare symbol string
69
+ token: Token.USDC; // type-safe enum
70
+ token: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'; // raw address
71
+ ```
72
+
73
+ ### Encrypted Bot Keys
74
+
75
+ ```typescript
76
+ import { AxonClient, decryptKeystore } from '@axonfi/sdk';
77
+ import fs from 'fs';
78
+
79
+ const keystore = fs.readFileSync('./axon-bot.json', 'utf8');
80
+ const botPrivateKey = await decryptKeystore(keystore, process.env.BOT_PASSPHRASE!);
81
+
82
+ const axon = new AxonClient({
83
+ vaultAddress: '0x...',
84
+ chainId: 8453,
85
+ botPrivateKey,
86
+ relayerUrl: 'https://relay.axonfi.xyz',
87
+ });
88
+ ```
89
+
90
+ ## API
91
+
92
+ ### Payments
93
+
94
+ ```typescript
95
+ // Send a payment
96
+ const result = await axon.pay({
97
+ to: '0xRecipient',
98
+ token: 'USDC', // or Token.USDC, or an address
99
+ amount: 25, // or '25', or 25_000_000n
100
+ memo: 'Invoice #42',
101
+ });
102
+
103
+ // Poll async payments
104
+ const status = await axon.poll(result.requestId);
105
+ ```
106
+
107
+ ### In-Vault Swaps
108
+
109
+ ```typescript
110
+ const result = await axon.swap({
111
+ toToken: 'WETH',
112
+ minToAmount: 0.001,
113
+ memo: 'Rebalance to WETH',
114
+ });
115
+ ```
116
+
117
+ ### DeFi Protocol Execution
118
+
119
+ ```typescript
120
+ const result = await axon.execute({
121
+ protocol: '0xUniswapRouter',
122
+ callData: '0x...',
123
+ token: 'USDC',
124
+ amount: 100,
125
+ });
126
+ ```
127
+
128
+ ### Vault Reads
129
+
130
+ ```typescript
131
+ await axon.getBalance('0xUSDC...'); // vault token balance
132
+ await axon.isActive(); // bot registered + active?
133
+ await axon.isPaused(); // vault paused?
134
+ await axon.getVaultInfo(); // owner, operator, version
135
+ await axon.canPayTo('0xRecipient'); // destination allowed?
136
+ ```
137
+
138
+ ### Utilities
139
+
140
+ ```typescript
141
+ import { parseAmount, resolveTokenDecimals, resolveToken, encodeRef } from '@axonfi/sdk';
142
+
143
+ parseAmount(5.2, 'USDC'); // 5_200_000n
144
+ resolveTokenDecimals('WETH'); // 18
145
+ resolveToken('USDC', 8453); // 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
146
+ encodeRef('invoice-042'); // keccak256 → bytes32
147
+ ```
148
+
149
+ ## Response Paths
150
+
151
+ Payments resolve through one of three paths:
152
+
153
+ | Path | Trigger | Timing | Response |
154
+ | ---------------- | -------------------- | ------ | ------------------------------------------- |
155
+ | **Fast** | Below all thresholds | ~2s | `status: "approved"`, `txHash` |
156
+ | **AI Scan** | Exceeds AI threshold | ~30s | `status: "approved"` or routes to review |
157
+ | **Human Review** | No AI consensus | Async | `status: "pending_review"`, poll for result |
158
+
159
+ ## Security Model
160
+
161
+ - **Owners** control everything: bot whitelist, spending limits, withdrawal. Hardware wallet recommended.
162
+ - **Bots** only sign payment intents. They never hold ETH, never submit transactions, and can be removed instantly.
163
+ - **Relayer** (Axon) can only execute bot-signed intents within configured limits. Cannot withdraw or modify vault config.
164
+ - **If Axon goes offline**, the owner retains full withdrawal access directly through the on-chain vault contract.
165
+
166
+ ## Chains
167
+
168
+ | Chain | ID | Status |
169
+ | ------------ | ----- | ------- |
170
+ | Base | 8453 | Live |
171
+ | Arbitrum One | 42161 | Live |
172
+ | Optimism | 10 | Live |
173
+ | Polygon PoS | 137 | Live |
174
+ | Base Sepolia | 84532 | Testnet |
175
+
176
+ ## Documentation
177
+
178
+ - [Full SDK Reference](https://axonfi.xyz/docs/sdk/typescript/client)
179
+ - [Quickstart Guide](https://axonfi.xyz/docs/getting-started/quickstart)
180
+ - [How It Works](https://axonfi.xyz/docs/getting-started/how-it-works)
181
+ - [Security Model](https://axonfi.xyz/docs/architecture/security-model)
182
+ - [HTTP 402 Payments](https://axonfi.xyz/docs/guides/http-402)
183
+
184
+ ## License
185
+
186
+ MIT