@axonfi/sdk 0.3.3 → 0.3.5

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Axon
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -29,7 +29,7 @@ npm install @axonfi/sdk
29
29
  ### With Encrypted Keystore (recommended)
30
30
 
31
31
  ```typescript
32
- import { AxonClient, decryptKeystore } from '@axonfi/sdk';
32
+ import { AxonClient, Chain, Token, decryptKeystore } from '@axonfi/sdk';
33
33
  import fs from 'fs';
34
34
 
35
35
  const keystore = fs.readFileSync('./axon-bot.json', 'utf8');
@@ -37,14 +37,14 @@ const botPrivateKey = await decryptKeystore(keystore, process.env.BOT_PASSPHRASE
37
37
 
38
38
  const axon = new AxonClient({
39
39
  vaultAddress: '0x...',
40
- chainId: 8453, // Base
40
+ chainId: Chain.Base,
41
41
  botPrivateKey,
42
42
  });
43
43
 
44
44
  // Pay 5 USDC — SDK handles decimals automatically
45
45
  const result = await axon.pay({
46
46
  to: '0xRecipient',
47
- token: 'USDC',
47
+ token: Token.USDC,
48
48
  amount: 5,
49
49
  memo: 'API call payment',
50
50
  });
@@ -55,11 +55,11 @@ console.log(result.status, result.txHash);
55
55
  ### With Raw Private Key
56
56
 
57
57
  ```typescript
58
- import { AxonClient } from '@axonfi/sdk';
58
+ import { AxonClient, Chain } from '@axonfi/sdk';
59
59
 
60
60
  const axon = new AxonClient({
61
61
  vaultAddress: '0x...',
62
- chainId: 8453,
62
+ chainId: Chain.Base,
63
63
  botPrivateKey: process.env.BOT_PRIVATE_KEY!,
64
64
  });
65
65
  ```
@@ -70,13 +70,13 @@ The SDK accepts amounts in three formats:
70
70
 
71
71
  ```typescript
72
72
  // Human-readable number — SDK converts using token decimals
73
- await axon.pay({ to, token: 'USDC', amount: 5.2 });
73
+ await axon.pay({ to, token: Token.USDC, amount: 5.2 });
74
74
 
75
75
  // Human-readable string — recommended for computed values
76
- await axon.pay({ to, token: 'USDC', amount: '5.2' });
76
+ await axon.pay({ to, token: Token.USDC, amount: '5.2' });
77
77
 
78
78
  // Raw bigint — base units, passed through as-is
79
- await axon.pay({ to, token: 'USDC', amount: 5_200_000n });
79
+ await axon.pay({ to, token: Token.USDC, amount: 5_200_000n });
80
80
  ```
81
81
 
82
82
  Token field accepts addresses, `Token` enum values, or symbol strings:
@@ -98,8 +98,8 @@ Send USDC (or any ERC-20) to any address. The bot signs an EIP-712 intent — Ax
98
98
  ```typescript
99
99
  const result = await axon.pay({
100
100
  to: '0xRecipient',
101
- token: 'USDC', // or Token.USDC, or an address
102
- amount: 25, // or '25', or 25_000_000n
101
+ token: Token.USDC,
102
+ amount: 25,
103
103
  memo: 'Invoice #42',
104
104
  });
105
105
 
@@ -113,7 +113,7 @@ Rebalance tokens inside your vault without withdrawing. Swap between any tokens
113
113
 
114
114
  ```typescript
115
115
  const result = await axon.swap({
116
- toToken: 'WETH',
116
+ toToken: Token.WETH,
117
117
  minToAmount: 0.001,
118
118
  memo: 'Rebalance to WETH',
119
119
  });
@@ -127,7 +127,7 @@ Interact with DeFi and Web3 protocols (Uniswap, Aave, GMX, etc.) that need permi
127
127
  const result = await axon.execute({
128
128
  protocol: '0xUniswapRouter',
129
129
  callData: '0x...',
130
- token: 'USDC',
130
+ token: Token.USDC,
131
131
  amount: 100,
132
132
  });
133
133
  ```
@@ -184,13 +184,16 @@ Payments resolve through one of three paths:
184
184
  | Optimism | 10 | Coming soon |
185
185
  | Polygon PoS | 137 | Coming soon |
186
186
 
187
- ## Documentation
187
+ ## Links
188
188
 
189
- - [Full SDK Reference](https://axonfi.xyz/docs/sdk/typescript/client)
190
- - [Quickstart Guide](https://axonfi.xyz/docs/getting-started/quickstart)
191
- - [How It Works](https://axonfi.xyz/docs/getting-started/how-it-works)
192
- - [Security Model](https://axonfi.xyz/docs/architecture/security-model)
193
- - [HTTP 402 Payments](https://axonfi.xyz/docs/guides/http-402)
189
+ - [Website](https://axonfi.xyz)
190
+ - [Dashboard](https://app.axonfi.xyz)
191
+ - [Documentation](https://axonfi.xyz/llms.txt)
192
+ - [npm — @axonfi/sdk](https://www.npmjs.com/package/@axonfi/sdk)
193
+ - [PyPI axonfi](https://pypi.org/project/axonfi/) (Python SDK)
194
+ - [Smart Contracts](https://github.com/axonfi/contracts)
195
+ - [Examples](https://github.com/axonfi/examples)
196
+ - [Twitter/X — @axonfixyz](https://x.com/axonfixyz)
194
197
 
195
198
  ## License
196
199
 
package/dist/index.cjs CHANGED
@@ -264,11 +264,6 @@ var AxonVaultAbi = [
264
264
  "name": "_axonRegistry",
265
265
  "type": "address",
266
266
  "internalType": "address"
267
- },
268
- {
269
- "name": "_trackUsedIntents",
270
- "type": "bool",
271
- "internalType": "bool"
272
267
  }
273
268
  ],
274
269
  "stateMutability": "nonpayable"
@@ -1330,19 +1325,6 @@ var AxonVaultAbi = [
1330
1325
  "outputs": [],
1331
1326
  "stateMutability": "nonpayable"
1332
1327
  },
1333
- {
1334
- "type": "function",
1335
- "name": "trackUsedIntents",
1336
- "inputs": [],
1337
- "outputs": [
1338
- {
1339
- "name": "",
1340
- "type": "bool",
1341
- "internalType": "bool"
1342
- }
1343
- ],
1344
- "stateMutability": "view"
1345
- },
1346
1328
  {
1347
1329
  "type": "function",
1348
1330
  "name": "transferOwnership",
@@ -2242,6 +2224,11 @@ var AxonVaultAbi = [
2242
2224
  }
2243
2225
  ]
2244
2226
  },
2227
+ {
2228
+ "type": "error",
2229
+ "name": "SameTokenSwap",
2230
+ "inputs": []
2231
+ },
2245
2232
  {
2246
2233
  "type": "error",
2247
2234
  "name": "SelfPayment",
@@ -2350,13 +2337,7 @@ var AxonVaultFactoryAbi = [
2350
2337
  {
2351
2338
  "type": "function",
2352
2339
  "name": "deployVault",
2353
- "inputs": [
2354
- {
2355
- "name": "trackUsedIntents",
2356
- "type": "bool",
2357
- "internalType": "bool"
2358
- }
2359
- ],
2340
+ "inputs": [],
2360
2341
  "outputs": [
2361
2342
  {
2362
2343
  "name": "vault",
@@ -2533,12 +2514,6 @@ var AxonVaultFactoryAbi = [
2533
2514
  "type": "address",
2534
2515
  "indexed": false,
2535
2516
  "internalType": "address"
2536
- },
2537
- {
2538
- "name": "trackUsedIntents",
2539
- "type": "bool",
2540
- "indexed": false,
2541
- "internalType": "bool"
2542
2517
  }
2543
2518
  ],
2544
2519
  "anonymous": false
@@ -2691,13 +2666,6 @@ async function getVaultOperator(publicClient, vaultAddress) {
2691
2666
  functionName: "operator"
2692
2667
  });
2693
2668
  }
2694
- async function getTrackUsedIntents(publicClient, vaultAddress) {
2695
- return publicClient.readContract({
2696
- address: vaultAddress,
2697
- abi: AxonVaultAbi,
2698
- functionName: "trackUsedIntents"
2699
- });
2700
- }
2701
2669
  async function isDestinationAllowed(publicClient, vaultAddress, botAddress, destination) {
2702
2670
  const isBlacklisted = await publicClient.readContract({
2703
2671
  address: vaultAddress,
@@ -2759,7 +2727,7 @@ async function isRebalanceTokenWhitelisted(publicClient, vaultAddress, token) {
2759
2727
  args: [token]
2760
2728
  });
2761
2729
  }
2762
- async function deployVault(walletClient, publicClient, factoryAddress, trackUsedIntents = true) {
2730
+ async function deployVault(walletClient, publicClient, factoryAddress) {
2763
2731
  if (!walletClient.account) {
2764
2732
  throw new Error("walletClient has no account attached");
2765
2733
  }
@@ -2767,7 +2735,7 @@ async function deployVault(walletClient, publicClient, factoryAddress, trackUsed
2767
2735
  address: factoryAddress,
2768
2736
  abi: AxonVaultFactoryAbi,
2769
2737
  functionName: "deployVault",
2770
- args: [trackUsedIntents],
2738
+ args: [],
2771
2739
  account: walletClient.account,
2772
2740
  chain: walletClient.chain ?? null
2773
2741
  });
@@ -2825,6 +2793,7 @@ var KNOWN_TOKENS = {
2825
2793
  decimals: 6,
2826
2794
  addresses: {
2827
2795
  8453: "0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2",
2796
+ 84532: "0x323e78f944A9a1FcF3a10efcC5319DBb0bB6e673",
2828
2797
  42161: "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"
2829
2798
  }
2830
2799
  },
@@ -2845,7 +2814,8 @@ var KNOWN_TOKENS = {
2845
2814
  addresses: {
2846
2815
  8453: "0x4200000000000000000000000000000000000006",
2847
2816
  84532: "0x4200000000000000000000000000000000000006",
2848
- 42161: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"
2817
+ 42161: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
2818
+ 421614: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"
2849
2819
  }
2850
2820
  },
2851
2821
  WBTC: {
@@ -2995,6 +2965,9 @@ function getTokenSymbolByAddress(address) {
2995
2965
  }
2996
2966
  function resolveToken(token, chainId) {
2997
2967
  if (typeof token === "string" && token.startsWith("0x")) {
2968
+ if (token === "0x0000000000000000000000000000000000000000") {
2969
+ throw new Error("Token address cannot be the zero address");
2970
+ }
2998
2971
  return token;
2999
2972
  }
3000
2973
  const entry = KNOWN_TOKENS[token];
@@ -3178,7 +3151,7 @@ var AxonClient = class {
3178
3151
  // ============================================================================
3179
3152
  // getVaultInfo() — via relayer
3180
3153
  // ============================================================================
3181
- /** Returns high-level vault info (owner, operator, paused, version, trackUsedIntents) via relayer. */
3154
+ /** Returns high-level vault info (owner, operator, paused, version) via relayer. */
3182
3155
  async getVaultInfo() {
3183
3156
  const path = RELAYER_API.vaultInfo(this.vaultAddress, this.chainId);
3184
3157
  return this._get(path);
@@ -3316,6 +3289,9 @@ Timestamp: ${timestamp}`;
3316
3289
  return "0x0000000000000000000000000000000000000000000000000000000000000000";
3317
3290
  }
3318
3291
  _buildPaymentIntent(input) {
3292
+ if (input.to === "0x0000000000000000000000000000000000000000") {
3293
+ throw new Error("Payment recipient cannot be the zero address");
3294
+ }
3319
3295
  return {
3320
3296
  bot: this.botAddress,
3321
3297
  to: input.to,
@@ -3960,7 +3936,6 @@ exports.getKnownTokensForChain = getKnownTokensForChain;
3960
3936
  exports.getOperatorCeilings = getOperatorCeilings;
3961
3937
  exports.getRebalanceTokenCount = getRebalanceTokenCount;
3962
3938
  exports.getTokenSymbolByAddress = getTokenSymbolByAddress;
3963
- exports.getTrackUsedIntents = getTrackUsedIntents;
3964
3939
  exports.getVaultOperator = getVaultOperator;
3965
3940
  exports.getVaultOwner = getVaultOwner;
3966
3941
  exports.getVaultVersion = getVaultVersion;