@axonfi/sdk 0.4.3 → 0.5.0
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 +160 -11
- package/dist/index.cjs +227 -34
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +174 -29
- package/dist/index.d.ts +174 -29
- package/dist/index.js +223 -36
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,23 +24,109 @@ Your agents pay. You stay in control.
|
|
|
24
24
|
npm install @axonfi/sdk
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
##
|
|
27
|
+
## Setup
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
There are two ways to set up an Axon vault: through the **dashboard** (UI) or entirely through the **SDK** (programmatic). Both produce the same on-chain result.
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
### Option A: Dashboard Setup
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
1. Go to [app.axonfi.xyz](https://app.axonfi.xyz), connect your wallet, deploy a vault
|
|
34
|
+
2. Fund the vault — send USDC, ETH, or any ERC-20 to the vault address
|
|
35
|
+
3. Register a bot — generate a keypair or bring your own key
|
|
36
|
+
4. Configure policies — per-tx caps, daily limits, AI threshold
|
|
37
|
+
5. Give the bot key to your agent
|
|
34
38
|
|
|
35
|
-
|
|
36
|
-
- **Generate a new keypair** (recommended) — the dashboard creates a key and downloads an encrypted keystore JSON file. You set the passphrase.
|
|
37
|
-
- **Bring your own key** — paste an existing public key if you manage keys externally.
|
|
39
|
+
### Option B: Full SDK Setup (Programmatic)
|
|
38
40
|
|
|
39
|
-
|
|
41
|
+
Everything can be done from code — no dashboard needed. An agent can bootstrap its own vault end-to-end.
|
|
40
42
|
|
|
41
|
-
|
|
43
|
+
```typescript
|
|
44
|
+
import {
|
|
45
|
+
AxonClient, deployVault, addBot, deposit,
|
|
46
|
+
createAxonPublicClient, createAxonWalletClient,
|
|
47
|
+
NATIVE_ETH, USDC, WINDOW, Chain,
|
|
48
|
+
} from '@axonfi/sdk';
|
|
49
|
+
import { parseUnits } from 'viem';
|
|
50
|
+
import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts';
|
|
51
|
+
|
|
52
|
+
// ── 1. Owner wallet (funded with ETH for gas) ─────────────────────
|
|
53
|
+
const ownerKey = '0x...'; // or generate: generatePrivateKey()
|
|
54
|
+
const chainId = Chain.BaseSepolia;
|
|
55
|
+
const ownerWallet = createAxonWalletClient(ownerKey, chainId);
|
|
56
|
+
const publicClient = createAxonPublicClient(chainId, 'https://sepolia.base.org');
|
|
57
|
+
|
|
58
|
+
// ── 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);
|
|
61
|
+
console.log('Vault deployed:', vaultAddress);
|
|
62
|
+
|
|
63
|
+
// ── 3. Generate a bot keypair ──────────────────────────────────────
|
|
64
|
+
const botKey = generatePrivateKey();
|
|
65
|
+
const botAddress = privateKeyToAccount(botKey).address;
|
|
66
|
+
|
|
67
|
+
// ── 4. Accept Terms of Service (wallet signature, no gas) ─────────
|
|
68
|
+
const axon = new AxonClient({ vaultAddress, chainId, botPrivateKey: botKey });
|
|
69
|
+
await axon.acceptTos(ownerWallet, ownerWallet.account!.address);
|
|
70
|
+
|
|
71
|
+
// ── 5. Register the bot on the vault (on-chain tx, ~0.0005 ETH gas)
|
|
72
|
+
await addBot(ownerWallet, publicClient, vaultAddress, botAddress, {
|
|
73
|
+
maxPerTxAmount: parseUnits('100', 6), // $100 hard cap per tx
|
|
74
|
+
maxRebalanceAmount: 0n, // no rebalance cap
|
|
75
|
+
spendingLimits: [{
|
|
76
|
+
amount: parseUnits('1000', 6), // $1,000/day rolling limit
|
|
77
|
+
maxCount: 0n, // no tx count limit
|
|
78
|
+
windowSeconds: WINDOW.ONE_DAY,
|
|
79
|
+
}],
|
|
80
|
+
aiTriggerThreshold: parseUnits('50', 6), // AI scan above $50
|
|
81
|
+
requireAiVerification: false,
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
// ── 6. Deposit funds (on-chain tx, ~0.0005 ETH gas) ───────────────
|
|
85
|
+
// Option A: Deposit ETH (vault accepts native ETH directly)
|
|
86
|
+
await deposit(ownerWallet, publicClient, vaultAddress,
|
|
87
|
+
NATIVE_ETH, parseUnits('0.1', 18));
|
|
88
|
+
|
|
89
|
+
// Option B: Deposit USDC (SDK handles approve + deposit)
|
|
90
|
+
await deposit(ownerWallet, publicClient, vaultAddress,
|
|
91
|
+
USDC[chainId], parseUnits('500', 6));
|
|
92
|
+
|
|
93
|
+
// ── 7. Bot is ready — gasless from here ────────────────────────────
|
|
94
|
+
// Save botKey securely. The bot never needs ETH.
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### What Needs Gas vs. What's Gasless
|
|
98
|
+
|
|
99
|
+
| Step | Who pays gas | Notes |
|
|
100
|
+
|------|-------------|-------|
|
|
101
|
+
| Deploy vault | Owner | ~0.001 ETH. One-time. |
|
|
102
|
+
| Accept ToS | Owner | Wallet signature only (no gas). |
|
|
103
|
+
| Register bot | Owner | ~0.0005 ETH. One per bot. |
|
|
104
|
+
| Configure bot | Owner | ~0.0003 ETH. Only when changing limits. |
|
|
105
|
+
| Deposit ETH | Depositor | Anyone can deposit. ETH sent directly. |
|
|
106
|
+
| Deposit ERC-20 | Depositor | Anyone can deposit. SDK handles approve + deposit. |
|
|
107
|
+
| **Pay** | **Free (relayer)** | **Bot signs EIP-712 intent. Axon pays gas.** |
|
|
108
|
+
| **Execute (DeFi)** | **Free (relayer)** | **Bot signs intent. Axon pays gas.** |
|
|
109
|
+
| **Swap (rebalance)** | **Free (relayer)** | **Bot signs intent. Axon pays gas.** |
|
|
110
|
+
| Pause/unpause | Owner | ~0.0002 ETH. Emergency only. |
|
|
111
|
+
| Withdraw | Owner | ~0.0003 ETH. Owner-only. |
|
|
112
|
+
|
|
113
|
+
**The key insight:** Setup operations (deploy, add bot, deposit) require gas from the owner. Once setup is complete, all bot operations (payments, DeFi, swaps) are gasless — the bot never needs ETH. The relayer pays all execution gas.
|
|
114
|
+
|
|
115
|
+
### Depositing ETH
|
|
42
116
|
|
|
43
|
-
|
|
117
|
+
Vaults accept native ETH directly — no wrapping needed. You can start a vault with only ETH:
|
|
118
|
+
|
|
119
|
+
```typescript
|
|
120
|
+
// Deploy vault + deposit ETH — no USDC needed
|
|
121
|
+
const vault = await deployVault(ownerWallet, publicClient, factory);
|
|
122
|
+
await addBot(ownerWallet, publicClient, vault, botAddress, config);
|
|
123
|
+
await deposit(ownerWallet, publicClient, vault, NATIVE_ETH, parseUnits('0.5', 18));
|
|
124
|
+
|
|
125
|
+
// Bot can now pay in any token — the relayer swaps ETH → USDC automatically
|
|
126
|
+
await axon.pay({ to: '0x...', token: 'USDC', amount: 10 });
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
When a bot pays in a token the vault doesn't hold directly (e.g., USDC when the vault only has ETH), the relayer automatically routes through a swap. The bot doesn't need to know or care what tokens are in the vault.
|
|
44
130
|
|
|
45
131
|
## Quick Start
|
|
46
132
|
|
|
@@ -139,7 +225,7 @@ const result = await axon.swap({
|
|
|
139
225
|
|
|
140
226
|
### DeFi Protocol Execution
|
|
141
227
|
|
|
142
|
-
Interact with DeFi and Web3 protocols (Uniswap, Aave, GMX, etc.)
|
|
228
|
+
Interact with DeFi and Web3 protocols (Uniswap, Aave, GMX, Ostium, etc.) 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.
|
|
143
229
|
|
|
144
230
|
```typescript
|
|
145
231
|
const result = await axon.execute({
|
|
@@ -150,6 +236,69 @@ const result = await axon.execute({
|
|
|
150
236
|
});
|
|
151
237
|
```
|
|
152
238
|
|
|
239
|
+
#### When the approval target differs from the call target
|
|
240
|
+
|
|
241
|
+
In simple cases (Uniswap, Aave), the contract you call is the same contract that pulls your tokens — `execute()` handles this automatically in a single call.
|
|
242
|
+
|
|
243
|
+
But many DeFi protocols split these into two contracts:
|
|
244
|
+
|
|
245
|
+
- **Call target** (`protocol`) — the contract you send the transaction to (e.g., Ostium's `Trading` for `openTrade()`)
|
|
246
|
+
- **Approval target** — the contract that actually calls `transferFrom()` to pull tokens from your vault (e.g., Ostium's `TradingStorage`)
|
|
247
|
+
|
|
248
|
+
When these differ, you need a **two-step pattern**: first give the approval target a persistent token allowance, then call the action.
|
|
249
|
+
|
|
250
|
+
**Example — Ostium perpetual futures:**
|
|
251
|
+
|
|
252
|
+
Ostium's `openTrade()` lives on the Trading contract, but collateral gets pulled by TradingStorage. The vault must approve TradingStorage, not Trading.
|
|
253
|
+
|
|
254
|
+
```typescript
|
|
255
|
+
const USDC = '0x...'; // USDC on your chain
|
|
256
|
+
const OSTIUM_TRADING = '0x...'; // calls openTrade()
|
|
257
|
+
const OSTIUM_TRADING_STORAGE = '0x...'; // pulls USDC via transferFrom()
|
|
258
|
+
|
|
259
|
+
// Step 1: Persistent approval (one-time) — call approve() on the token contract
|
|
260
|
+
// This tells USDC to let TradingStorage spend from the vault.
|
|
261
|
+
await axon.execute({
|
|
262
|
+
protocol: USDC, // call target: the token contract itself
|
|
263
|
+
callData: encodeApprove(OSTIUM_TRADING_STORAGE, MaxUint256),
|
|
264
|
+
token: USDC,
|
|
265
|
+
amount: 0, // no token spend, just setting an allowance
|
|
266
|
+
protocolName: 'USDC Approve',
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
// Step 2: Open trade — call the action contract
|
|
270
|
+
await axon.execute({
|
|
271
|
+
protocol: OSTIUM_TRADING, // call target: the Trading contract
|
|
272
|
+
callData: encodeOpenTrade(...),
|
|
273
|
+
token: USDC,
|
|
274
|
+
amount: 50_000_000, // 50 USDC — passed for dashboard/AI visibility
|
|
275
|
+
protocolName: 'Ostium',
|
|
276
|
+
});
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
**Vault setup (owner, one-time):** Two contracts must be approved via `approveProtocol()`:
|
|
280
|
+
1. **USDC** (the token contract) — because the vault calls `approve()` on it directly
|
|
281
|
+
2. **Trading** — because the vault calls `openTrade()` on it
|
|
282
|
+
|
|
283
|
+
TradingStorage does *not* need to be approved — it's just an argument to `approve()`, not a contract the vault calls.
|
|
284
|
+
|
|
285
|
+
> **Note:** Common tokens (USDC, USDT, WETH, etc.) are pre-approved globally via the Axon registry as default tokens, so you typically only need to approve the DeFi protocol contract itself. You only need to approve a token if it's uncommon and not in the registry defaults.
|
|
286
|
+
|
|
287
|
+
> **Testnet note:** If the protocol uses a custom token that isn't on Uniswap (e.g., Ostium's testnet USDC), set the bot's `maxPerTxAmount` to `0` to skip TWAP oracle pricing.
|
|
288
|
+
|
|
289
|
+
This pattern applies to any protocol where the approval target differs from the call target (GMX, some lending protocols, etc.).
|
|
290
|
+
|
|
291
|
+
#### `ContractNotApproved` error
|
|
292
|
+
|
|
293
|
+
If `execute()` reverts with `ContractNotApproved`, the `protocol` address you're calling isn't approved. Two possible causes:
|
|
294
|
+
|
|
295
|
+
1. **The DeFi protocol contract isn't approved** — the vault owner must call `approveProtocol(address)` on the vault for the protocol contract (e.g., Uniswap Router, Ostium Trading, Lido stETH).
|
|
296
|
+
2. **The token contract isn't approved** — when doing a token approval (Step 1 above), the token must either be approved on the vault via `approveProtocol(tokenAddress)` or be a registry default token. Common tokens (USDC, USDT, WETH, DAI, etc.) are pre-approved globally by Axon, but uncommon tokens (e.g., stETH, aUSDC, cTokens) may need manual approval.
|
|
297
|
+
|
|
298
|
+
**Example — Lido staking/unstaking:** To unstake stETH, Lido's withdrawal contract calls `transferFrom()` to pull stETH from your vault. You need:
|
|
299
|
+
- `approveProtocol(stETH)` — so the vault can call `approve()` on the stETH token to grant Lido an allowance
|
|
300
|
+
- `approveProtocol(lidoWithdrawalQueue)` — so the vault can call `requestWithdrawals()` on Lido
|
|
301
|
+
|
|
153
302
|
### Vault Reads
|
|
154
303
|
|
|
155
304
|
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).
|
package/dist/index.cjs
CHANGED
|
@@ -439,12 +439,12 @@ var AxonVaultAbi = [
|
|
|
439
439
|
},
|
|
440
440
|
{
|
|
441
441
|
"type": "function",
|
|
442
|
-
"name": "
|
|
442
|
+
"name": "addRebalanceTokens",
|
|
443
443
|
"inputs": [
|
|
444
444
|
{
|
|
445
|
-
"name": "
|
|
446
|
-
"type": "address",
|
|
447
|
-
"internalType": "address"
|
|
445
|
+
"name": "tokens",
|
|
446
|
+
"type": "address[]",
|
|
447
|
+
"internalType": "address[]"
|
|
448
448
|
}
|
|
449
449
|
],
|
|
450
450
|
"outputs": [],
|
|
@@ -452,12 +452,12 @@ var AxonVaultAbi = [
|
|
|
452
452
|
},
|
|
453
453
|
{
|
|
454
454
|
"type": "function",
|
|
455
|
-
"name": "
|
|
455
|
+
"name": "approveProtocol",
|
|
456
456
|
"inputs": [
|
|
457
457
|
{
|
|
458
|
-
"name": "
|
|
459
|
-
"type": "address
|
|
460
|
-
"internalType": "address
|
|
458
|
+
"name": "protocol",
|
|
459
|
+
"type": "address",
|
|
460
|
+
"internalType": "address"
|
|
461
461
|
}
|
|
462
462
|
],
|
|
463
463
|
"outputs": [],
|
|
@@ -1015,7 +1015,7 @@ var AxonVaultAbi = [
|
|
|
1015
1015
|
},
|
|
1016
1016
|
{
|
|
1017
1017
|
"type": "function",
|
|
1018
|
-
"name": "
|
|
1018
|
+
"name": "isContractApproved",
|
|
1019
1019
|
"inputs": [
|
|
1020
1020
|
{
|
|
1021
1021
|
"name": "protocol",
|
|
@@ -1239,19 +1239,6 @@ var AxonVaultAbi = [
|
|
|
1239
1239
|
"outputs": [],
|
|
1240
1240
|
"stateMutability": "nonpayable"
|
|
1241
1241
|
},
|
|
1242
|
-
{
|
|
1243
|
-
"type": "function",
|
|
1244
|
-
"name": "removeProtocol",
|
|
1245
|
-
"inputs": [
|
|
1246
|
-
{
|
|
1247
|
-
"name": "protocol",
|
|
1248
|
-
"type": "address",
|
|
1249
|
-
"internalType": "address"
|
|
1250
|
-
}
|
|
1251
|
-
],
|
|
1252
|
-
"outputs": [],
|
|
1253
|
-
"stateMutability": "nonpayable"
|
|
1254
|
-
},
|
|
1255
1242
|
{
|
|
1256
1243
|
"type": "function",
|
|
1257
1244
|
"name": "removeRebalanceTokens",
|
|
@@ -1272,6 +1259,19 @@ var AxonVaultAbi = [
|
|
|
1272
1259
|
"outputs": [],
|
|
1273
1260
|
"stateMutability": "nonpayable"
|
|
1274
1261
|
},
|
|
1262
|
+
{
|
|
1263
|
+
"type": "function",
|
|
1264
|
+
"name": "revokeProtocol",
|
|
1265
|
+
"inputs": [
|
|
1266
|
+
{
|
|
1267
|
+
"name": "protocol",
|
|
1268
|
+
"type": "address",
|
|
1269
|
+
"internalType": "address"
|
|
1270
|
+
}
|
|
1271
|
+
],
|
|
1272
|
+
"outputs": [],
|
|
1273
|
+
"stateMutability": "nonpayable"
|
|
1274
|
+
},
|
|
1275
1275
|
{
|
|
1276
1276
|
"type": "function",
|
|
1277
1277
|
"name": "setOperator",
|
|
@@ -1782,7 +1782,7 @@ var AxonVaultAbi = [
|
|
|
1782
1782
|
},
|
|
1783
1783
|
{
|
|
1784
1784
|
"type": "event",
|
|
1785
|
-
"name": "
|
|
1785
|
+
"name": "ProtocolApproved",
|
|
1786
1786
|
"inputs": [
|
|
1787
1787
|
{
|
|
1788
1788
|
"name": "protocol",
|
|
@@ -1832,7 +1832,7 @@ var AxonVaultAbi = [
|
|
|
1832
1832
|
},
|
|
1833
1833
|
{
|
|
1834
1834
|
"type": "event",
|
|
1835
|
-
"name": "
|
|
1835
|
+
"name": "ProtocolRevoked",
|
|
1836
1836
|
"inputs": [
|
|
1837
1837
|
{
|
|
1838
1838
|
"name": "protocol",
|
|
@@ -2029,6 +2029,11 @@ var AxonVaultAbi = [
|
|
|
2029
2029
|
"name": "CalldataHashMismatch",
|
|
2030
2030
|
"inputs": []
|
|
2031
2031
|
},
|
|
2032
|
+
{
|
|
2033
|
+
"type": "error",
|
|
2034
|
+
"name": "ContractNotApproved",
|
|
2035
|
+
"inputs": []
|
|
2036
|
+
},
|
|
2032
2037
|
{
|
|
2033
2038
|
"type": "error",
|
|
2034
2039
|
"name": "DeadlineExpired",
|
|
@@ -2193,11 +2198,6 @@ var AxonVaultAbi = [
|
|
|
2193
2198
|
"name": "ProtocolNotApproved",
|
|
2194
2199
|
"inputs": []
|
|
2195
2200
|
},
|
|
2196
|
-
{
|
|
2197
|
-
"type": "error",
|
|
2198
|
-
"name": "ProtocolNotInList",
|
|
2199
|
-
"inputs": []
|
|
2200
|
-
},
|
|
2201
2201
|
{
|
|
2202
2202
|
"type": "error",
|
|
2203
2203
|
"name": "RebalanceTokenNotAllowed",
|
|
@@ -2546,8 +2546,6 @@ var AxonVaultFactoryAbi = [
|
|
|
2546
2546
|
"inputs": []
|
|
2547
2547
|
}
|
|
2548
2548
|
];
|
|
2549
|
-
|
|
2550
|
-
// src/vault.ts
|
|
2551
2549
|
function getChain(chainId) {
|
|
2552
2550
|
switch (chainId) {
|
|
2553
2551
|
case 8453:
|
|
@@ -2751,6 +2749,79 @@ async function deployVault(walletClient, publicClient, factoryAddress) {
|
|
|
2751
2749
|
}
|
|
2752
2750
|
throw new Error("VaultDeployed event not found in transaction receipt");
|
|
2753
2751
|
}
|
|
2752
|
+
async function addBot(walletClient, publicClient, vaultAddress, botAddress, config) {
|
|
2753
|
+
if (!walletClient.account) {
|
|
2754
|
+
throw new Error("walletClient has no account attached");
|
|
2755
|
+
}
|
|
2756
|
+
const hash = await walletClient.writeContract({
|
|
2757
|
+
address: vaultAddress,
|
|
2758
|
+
abi: AxonVaultAbi,
|
|
2759
|
+
functionName: "addBot",
|
|
2760
|
+
args: [botAddress, config],
|
|
2761
|
+
account: walletClient.account,
|
|
2762
|
+
chain: walletClient.chain ?? null
|
|
2763
|
+
});
|
|
2764
|
+
await publicClient.waitForTransactionReceipt({ hash });
|
|
2765
|
+
return hash;
|
|
2766
|
+
}
|
|
2767
|
+
async function updateBotConfig(walletClient, publicClient, vaultAddress, botAddress, config) {
|
|
2768
|
+
if (!walletClient.account) {
|
|
2769
|
+
throw new Error("walletClient has no account attached");
|
|
2770
|
+
}
|
|
2771
|
+
const hash = await walletClient.writeContract({
|
|
2772
|
+
address: vaultAddress,
|
|
2773
|
+
abi: AxonVaultAbi,
|
|
2774
|
+
functionName: "updateBotConfig",
|
|
2775
|
+
args: [botAddress, config],
|
|
2776
|
+
account: walletClient.account,
|
|
2777
|
+
chain: walletClient.chain ?? null
|
|
2778
|
+
});
|
|
2779
|
+
await publicClient.waitForTransactionReceipt({ hash });
|
|
2780
|
+
return hash;
|
|
2781
|
+
}
|
|
2782
|
+
async function removeBot(walletClient, publicClient, vaultAddress, botAddress) {
|
|
2783
|
+
if (!walletClient.account) {
|
|
2784
|
+
throw new Error("walletClient has no account attached");
|
|
2785
|
+
}
|
|
2786
|
+
const hash = await walletClient.writeContract({
|
|
2787
|
+
address: vaultAddress,
|
|
2788
|
+
abi: AxonVaultAbi,
|
|
2789
|
+
functionName: "removeBot",
|
|
2790
|
+
args: [botAddress],
|
|
2791
|
+
account: walletClient.account,
|
|
2792
|
+
chain: walletClient.chain ?? null
|
|
2793
|
+
});
|
|
2794
|
+
await publicClient.waitForTransactionReceipt({ hash });
|
|
2795
|
+
return hash;
|
|
2796
|
+
}
|
|
2797
|
+
async function deposit(walletClient, publicClient, vaultAddress, token, amount, ref = "0x0000000000000000000000000000000000000000000000000000000000000000") {
|
|
2798
|
+
if (!walletClient.account) {
|
|
2799
|
+
throw new Error("walletClient has no account attached");
|
|
2800
|
+
}
|
|
2801
|
+
const isEth = token.toLowerCase() === NATIVE_ETH.toLowerCase();
|
|
2802
|
+
if (!isEth) {
|
|
2803
|
+
const approveTx = await walletClient.writeContract({
|
|
2804
|
+
address: token,
|
|
2805
|
+
abi: viem.erc20Abi,
|
|
2806
|
+
functionName: "approve",
|
|
2807
|
+
args: [vaultAddress, amount],
|
|
2808
|
+
account: walletClient.account,
|
|
2809
|
+
chain: walletClient.chain ?? null
|
|
2810
|
+
});
|
|
2811
|
+
await publicClient.waitForTransactionReceipt({ hash: approveTx });
|
|
2812
|
+
}
|
|
2813
|
+
const hash = await walletClient.writeContract({
|
|
2814
|
+
address: vaultAddress,
|
|
2815
|
+
abi: AxonVaultAbi,
|
|
2816
|
+
functionName: "deposit",
|
|
2817
|
+
args: [token, amount, ref],
|
|
2818
|
+
account: walletClient.account,
|
|
2819
|
+
chain: walletClient.chain ?? null,
|
|
2820
|
+
...isEth ? { value: amount } : {}
|
|
2821
|
+
});
|
|
2822
|
+
await publicClient.waitForTransactionReceipt({ hash });
|
|
2823
|
+
return hash;
|
|
2824
|
+
}
|
|
2754
2825
|
|
|
2755
2826
|
// src/tokens.ts
|
|
2756
2827
|
var Token = /* @__PURE__ */ ((Token2) => {
|
|
@@ -2763,6 +2834,7 @@ var Token = /* @__PURE__ */ ((Token2) => {
|
|
|
2763
2834
|
Token2["cbETH"] = "cbETH";
|
|
2764
2835
|
Token2["wstETH"] = "wstETH";
|
|
2765
2836
|
Token2["rETH"] = "rETH";
|
|
2837
|
+
Token2["weETH"] = "weETH";
|
|
2766
2838
|
Token2["LINK"] = "LINK";
|
|
2767
2839
|
Token2["UNI"] = "UNI";
|
|
2768
2840
|
Token2["AAVE"] = "AAVE";
|
|
@@ -2860,9 +2932,19 @@ var KNOWN_TOKENS = {
|
|
|
2860
2932
|
name: "Rocket Pool ETH",
|
|
2861
2933
|
decimals: 18,
|
|
2862
2934
|
addresses: {
|
|
2935
|
+
8453: "0xB6fe221Fe9EeF5aBa221c348bA20A1Bf5e73624c",
|
|
2863
2936
|
42161: "0xEC70Dcb4A1EFa46b8F2D97C310C9c4790ba5ffA8"
|
|
2864
2937
|
}
|
|
2865
2938
|
},
|
|
2939
|
+
weETH: {
|
|
2940
|
+
symbol: "weETH",
|
|
2941
|
+
name: "EtherFi Wrapped eETH",
|
|
2942
|
+
decimals: 18,
|
|
2943
|
+
addresses: {
|
|
2944
|
+
8453: "0x04C0599Ae5A44757c0af6F9eC3b93da8976c150A",
|
|
2945
|
+
42161: "0x35751007a407ca6FEFfE80b3cB397736D2cf4dbe"
|
|
2946
|
+
}
|
|
2947
|
+
},
|
|
2866
2948
|
// ── DeFi blue-chips ─────────────────────────────────────
|
|
2867
2949
|
LINK: {
|
|
2868
2950
|
symbol: "LINK",
|
|
@@ -2944,6 +3026,27 @@ var KNOWN_TOKENS = {
|
|
|
2944
3026
|
}
|
|
2945
3027
|
}
|
|
2946
3028
|
};
|
|
3029
|
+
var DEFAULT_APPROVED_TOKENS = [
|
|
3030
|
+
"USDC",
|
|
3031
|
+
"USDT",
|
|
3032
|
+
"DAI",
|
|
3033
|
+
"WETH",
|
|
3034
|
+
"WBTC",
|
|
3035
|
+
"cbBTC",
|
|
3036
|
+
"wstETH",
|
|
3037
|
+
"weETH",
|
|
3038
|
+
"cbETH",
|
|
3039
|
+
"rETH"
|
|
3040
|
+
];
|
|
3041
|
+
function getDefaultApprovedTokens(chainId) {
|
|
3042
|
+
const addresses = [];
|
|
3043
|
+
for (const symbol of DEFAULT_APPROVED_TOKENS) {
|
|
3044
|
+
const entry = KNOWN_TOKENS[symbol];
|
|
3045
|
+
const addr = entry.addresses[chainId];
|
|
3046
|
+
if (addr) addresses.push(addr);
|
|
3047
|
+
}
|
|
3048
|
+
return addresses;
|
|
3049
|
+
}
|
|
2947
3050
|
var addressToSymbol = /* @__PURE__ */ new Map();
|
|
2948
3051
|
for (const token of Object.values(KNOWN_TOKENS)) {
|
|
2949
3052
|
for (const addr of Object.values(token.addresses)) {
|
|
@@ -3525,10 +3628,10 @@ var AxonClient = class {
|
|
|
3525
3628
|
return this._get(path);
|
|
3526
3629
|
}
|
|
3527
3630
|
// ============================================================================
|
|
3528
|
-
//
|
|
3631
|
+
// isContractApproved() — via relayer
|
|
3529
3632
|
// ============================================================================
|
|
3530
|
-
/** Returns whether a
|
|
3531
|
-
async
|
|
3633
|
+
/** Returns whether a contract address (protocol or token) is approved for executeProtocol() calls (via relayer). */
|
|
3634
|
+
async isContractApproved(protocol) {
|
|
3532
3635
|
const path = RELAYER_API.protocolCheck(this.vaultAddress, protocol, this.chainId);
|
|
3533
3636
|
const data = await this._get(path);
|
|
3534
3637
|
return data.approved;
|
|
@@ -3890,6 +3993,19 @@ var AxonRegistryAbi = [
|
|
|
3890
3993
|
],
|
|
3891
3994
|
"stateMutability": "nonpayable"
|
|
3892
3995
|
},
|
|
3996
|
+
{
|
|
3997
|
+
"type": "function",
|
|
3998
|
+
"name": "VERSION",
|
|
3999
|
+
"inputs": [],
|
|
4000
|
+
"outputs": [
|
|
4001
|
+
{
|
|
4002
|
+
"name": "",
|
|
4003
|
+
"type": "uint256",
|
|
4004
|
+
"internalType": "uint256"
|
|
4005
|
+
}
|
|
4006
|
+
],
|
|
4007
|
+
"stateMutability": "view"
|
|
4008
|
+
},
|
|
3893
4009
|
{
|
|
3894
4010
|
"type": "function",
|
|
3895
4011
|
"name": "acceptOwnership",
|
|
@@ -3923,6 +4039,19 @@ var AxonRegistryAbi = [
|
|
|
3923
4039
|
"outputs": [],
|
|
3924
4040
|
"stateMutability": "nonpayable"
|
|
3925
4041
|
},
|
|
4042
|
+
{
|
|
4043
|
+
"type": "function",
|
|
4044
|
+
"name": "approveDefaultToken",
|
|
4045
|
+
"inputs": [
|
|
4046
|
+
{
|
|
4047
|
+
"name": "token",
|
|
4048
|
+
"type": "address",
|
|
4049
|
+
"internalType": "address"
|
|
4050
|
+
}
|
|
4051
|
+
],
|
|
4052
|
+
"outputs": [],
|
|
4053
|
+
"stateMutability": "nonpayable"
|
|
4054
|
+
},
|
|
3926
4055
|
{
|
|
3927
4056
|
"type": "function",
|
|
3928
4057
|
"name": "isApprovedSwapRouter",
|
|
@@ -3961,6 +4090,25 @@ var AxonRegistryAbi = [
|
|
|
3961
4090
|
],
|
|
3962
4091
|
"stateMutability": "view"
|
|
3963
4092
|
},
|
|
4093
|
+
{
|
|
4094
|
+
"type": "function",
|
|
4095
|
+
"name": "isDefaultToken",
|
|
4096
|
+
"inputs": [
|
|
4097
|
+
{
|
|
4098
|
+
"name": "token",
|
|
4099
|
+
"type": "address",
|
|
4100
|
+
"internalType": "address"
|
|
4101
|
+
}
|
|
4102
|
+
],
|
|
4103
|
+
"outputs": [
|
|
4104
|
+
{
|
|
4105
|
+
"name": "",
|
|
4106
|
+
"type": "bool",
|
|
4107
|
+
"internalType": "bool"
|
|
4108
|
+
}
|
|
4109
|
+
],
|
|
4110
|
+
"stateMutability": "view"
|
|
4111
|
+
},
|
|
3964
4112
|
{
|
|
3965
4113
|
"type": "function",
|
|
3966
4114
|
"name": "owner",
|
|
@@ -4020,6 +4168,19 @@ var AxonRegistryAbi = [
|
|
|
4020
4168
|
"outputs": [],
|
|
4021
4169
|
"stateMutability": "nonpayable"
|
|
4022
4170
|
},
|
|
4171
|
+
{
|
|
4172
|
+
"type": "function",
|
|
4173
|
+
"name": "revokeDefaultToken",
|
|
4174
|
+
"inputs": [
|
|
4175
|
+
{
|
|
4176
|
+
"name": "token",
|
|
4177
|
+
"type": "address",
|
|
4178
|
+
"internalType": "address"
|
|
4179
|
+
}
|
|
4180
|
+
],
|
|
4181
|
+
"outputs": [],
|
|
4182
|
+
"stateMutability": "nonpayable"
|
|
4183
|
+
},
|
|
4023
4184
|
{
|
|
4024
4185
|
"type": "function",
|
|
4025
4186
|
"name": "setOracleConfig",
|
|
@@ -4095,6 +4256,32 @@ var AxonRegistryAbi = [
|
|
|
4095
4256
|
],
|
|
4096
4257
|
"stateMutability": "view"
|
|
4097
4258
|
},
|
|
4259
|
+
{
|
|
4260
|
+
"type": "event",
|
|
4261
|
+
"name": "DefaultTokenApproved",
|
|
4262
|
+
"inputs": [
|
|
4263
|
+
{
|
|
4264
|
+
"name": "token",
|
|
4265
|
+
"type": "address",
|
|
4266
|
+
"indexed": true,
|
|
4267
|
+
"internalType": "address"
|
|
4268
|
+
}
|
|
4269
|
+
],
|
|
4270
|
+
"anonymous": false
|
|
4271
|
+
},
|
|
4272
|
+
{
|
|
4273
|
+
"type": "event",
|
|
4274
|
+
"name": "DefaultTokenRevoked",
|
|
4275
|
+
"inputs": [
|
|
4276
|
+
{
|
|
4277
|
+
"name": "token",
|
|
4278
|
+
"type": "address",
|
|
4279
|
+
"indexed": true,
|
|
4280
|
+
"internalType": "address"
|
|
4281
|
+
}
|
|
4282
|
+
],
|
|
4283
|
+
"anonymous": false
|
|
4284
|
+
},
|
|
4098
4285
|
{
|
|
4099
4286
|
"type": "event",
|
|
4100
4287
|
"name": "OracleConfigUpdated",
|
|
@@ -4265,6 +4452,7 @@ exports.AxonVaultAbi = AxonVaultAbi;
|
|
|
4265
4452
|
exports.AxonVaultFactoryAbi = AxonVaultFactoryAbi;
|
|
4266
4453
|
exports.CHAIN_NAMES = CHAIN_NAMES;
|
|
4267
4454
|
exports.Chain = Chain;
|
|
4455
|
+
exports.DEFAULT_APPROVED_TOKENS = DEFAULT_APPROVED_TOKENS;
|
|
4268
4456
|
exports.DEFAULT_DEADLINE_SECONDS = DEFAULT_DEADLINE_SECONDS;
|
|
4269
4457
|
exports.EIP712_DOMAIN_NAME = EIP712_DOMAIN_NAME;
|
|
4270
4458
|
exports.EIP712_DOMAIN_VERSION = EIP712_DOMAIN_VERSION;
|
|
@@ -4285,10 +4473,12 @@ exports.USDC_EIP712_DOMAIN = USDC_EIP712_DOMAIN;
|
|
|
4285
4473
|
exports.WINDOW = WINDOW;
|
|
4286
4474
|
exports.WITNESS_TYPE_STRING = WITNESS_TYPE_STRING;
|
|
4287
4475
|
exports.X402_PROXY_ADDRESS = X402_PROXY_ADDRESS;
|
|
4476
|
+
exports.addBot = addBot;
|
|
4288
4477
|
exports.createAxonPublicClient = createAxonPublicClient;
|
|
4289
4478
|
exports.createAxonWalletClient = createAxonWalletClient;
|
|
4290
4479
|
exports.decryptKeystore = decryptKeystore;
|
|
4291
4480
|
exports.deployVault = deployVault;
|
|
4481
|
+
exports.deposit = deposit;
|
|
4292
4482
|
exports.encodeRef = encodeRef;
|
|
4293
4483
|
exports.encryptKeystore = encryptKeystore;
|
|
4294
4484
|
exports.extractX402Metadata = extractX402Metadata;
|
|
@@ -4296,6 +4486,7 @@ exports.findMatchingOption = findMatchingOption;
|
|
|
4296
4486
|
exports.formatPaymentSignature = formatPaymentSignature;
|
|
4297
4487
|
exports.getBotConfig = getBotConfig;
|
|
4298
4488
|
exports.getChain = getChain;
|
|
4489
|
+
exports.getDefaultApprovedTokens = getDefaultApprovedTokens;
|
|
4299
4490
|
exports.getDomainSeparator = getDomainSeparator;
|
|
4300
4491
|
exports.getKnownTokensForChain = getKnownTokensForChain;
|
|
4301
4492
|
exports.getOperatorCeilings = getOperatorCeilings;
|
|
@@ -4314,6 +4505,7 @@ exports.parseChainId = parseChainId;
|
|
|
4314
4505
|
exports.parsePaymentRequired = parsePaymentRequired;
|
|
4315
4506
|
exports.randomNonce = randomNonce;
|
|
4316
4507
|
exports.randomPermit2Nonce = randomPermit2Nonce;
|
|
4508
|
+
exports.removeBot = removeBot;
|
|
4317
4509
|
exports.resolveToken = resolveToken;
|
|
4318
4510
|
exports.resolveTokenDecimals = resolveTokenDecimals;
|
|
4319
4511
|
exports.signExecuteIntent = signExecuteIntent;
|
|
@@ -4321,5 +4513,6 @@ exports.signPayment = signPayment;
|
|
|
4321
4513
|
exports.signPermit2WitnessTransfer = signPermit2WitnessTransfer;
|
|
4322
4514
|
exports.signSwapIntent = signSwapIntent;
|
|
4323
4515
|
exports.signTransferWithAuthorization = signTransferWithAuthorization;
|
|
4516
|
+
exports.updateBotConfig = updateBotConfig;
|
|
4324
4517
|
//# sourceMappingURL=index.cjs.map
|
|
4325
4518
|
//# sourceMappingURL=index.cjs.map
|