@axonfi/sdk 0.7.0 → 0.9.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 +6 -6
- package/dist/index.cjs +82 -55
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +62 -47
- package/dist/index.d.ts +62 -47
- package/dist/index.js +82 -55
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -238,8 +238,8 @@ Interact with DeFi and Web3 protocols (Uniswap, Aave, GMX, Ostium, etc.) from yo
|
|
|
238
238
|
const result = await axon.execute({
|
|
239
239
|
protocol: '0xUniswapRouter',
|
|
240
240
|
callData: '0x...',
|
|
241
|
-
|
|
242
|
-
|
|
241
|
+
tokens: [Token.USDC],
|
|
242
|
+
amounts: [100],
|
|
243
243
|
});
|
|
244
244
|
```
|
|
245
245
|
|
|
@@ -268,8 +268,8 @@ const OSTIUM_TRADING_STORAGE = '0x...'; // pulls USDC via transferFrom()
|
|
|
268
268
|
await axon.execute({
|
|
269
269
|
protocol: USDC, // call target: the token contract itself
|
|
270
270
|
callData: encodeApprove(OSTIUM_TRADING_STORAGE, MaxUint256),
|
|
271
|
-
|
|
272
|
-
|
|
271
|
+
tokens: [USDC],
|
|
272
|
+
amounts: [0], // no token spend, just setting an allowance
|
|
273
273
|
protocolName: 'USDC Approve',
|
|
274
274
|
});
|
|
275
275
|
|
|
@@ -277,8 +277,8 @@ await axon.execute({
|
|
|
277
277
|
await axon.execute({
|
|
278
278
|
protocol: OSTIUM_TRADING, // call target: the Trading contract
|
|
279
279
|
callData: encodeOpenTrade(...),
|
|
280
|
-
|
|
281
|
-
|
|
280
|
+
tokens: [USDC],
|
|
281
|
+
amounts: [50_000_000], // 50 USDC — passed for dashboard/AI visibility
|
|
282
282
|
protocolName: 'Ostium',
|
|
283
283
|
});
|
|
284
284
|
```
|
package/dist/index.cjs
CHANGED
|
@@ -18,7 +18,7 @@ var PAYMENT_INTENT_TYPEHASH = viem.keccak256(
|
|
|
18
18
|
);
|
|
19
19
|
var EXECUTE_INTENT_TYPEHASH = viem.keccak256(
|
|
20
20
|
viem.stringToBytes(
|
|
21
|
-
"ExecuteIntent(address bot,address protocol,bytes32 calldataHash,address
|
|
21
|
+
"ExecuteIntent(address bot,address protocol,bytes32 calldataHash,address[] tokens,uint256[] amounts,uint256 value,uint256 deadline,bytes32 ref)"
|
|
22
22
|
)
|
|
23
23
|
);
|
|
24
24
|
var SWAP_INTENT_TYPEHASH = viem.keccak256(
|
|
@@ -153,8 +153,8 @@ var EXECUTE_INTENT_TYPES = {
|
|
|
153
153
|
{ name: "bot", type: "address" },
|
|
154
154
|
{ name: "protocol", type: "address" },
|
|
155
155
|
{ name: "calldataHash", type: "bytes32" },
|
|
156
|
-
{ name: "
|
|
157
|
-
{ name: "
|
|
156
|
+
{ name: "tokens", type: "address[]" },
|
|
157
|
+
{ name: "amounts", type: "uint256[]" },
|
|
158
158
|
{ name: "value", type: "uint256" },
|
|
159
159
|
{ name: "deadline", type: "uint256" },
|
|
160
160
|
{ name: "ref", type: "bytes32" }
|
|
@@ -209,8 +209,8 @@ async function signExecuteIntent(walletClient, vaultAddress, chainId, intent) {
|
|
|
209
209
|
bot: intent.bot,
|
|
210
210
|
protocol: intent.protocol,
|
|
211
211
|
calldataHash: intent.calldataHash,
|
|
212
|
-
|
|
213
|
-
|
|
212
|
+
tokens: intent.tokens,
|
|
213
|
+
amounts: intent.amounts,
|
|
214
214
|
value: intent.value,
|
|
215
215
|
deadline: intent.deadline,
|
|
216
216
|
ref: intent.ref
|
|
@@ -614,6 +614,19 @@ var AxonVaultAbi = [
|
|
|
614
614
|
],
|
|
615
615
|
"stateMutability": "view"
|
|
616
616
|
},
|
|
617
|
+
{
|
|
618
|
+
"type": "function",
|
|
619
|
+
"name": "erc1271BotsEnabled",
|
|
620
|
+
"inputs": [],
|
|
621
|
+
"outputs": [
|
|
622
|
+
{
|
|
623
|
+
"name": "",
|
|
624
|
+
"type": "bool",
|
|
625
|
+
"internalType": "bool"
|
|
626
|
+
}
|
|
627
|
+
],
|
|
628
|
+
"stateMutability": "view"
|
|
629
|
+
},
|
|
617
630
|
{
|
|
618
631
|
"type": "function",
|
|
619
632
|
"name": "executePayment",
|
|
@@ -709,14 +722,14 @@ var AxonVaultAbi = [
|
|
|
709
722
|
"internalType": "bytes32"
|
|
710
723
|
},
|
|
711
724
|
{
|
|
712
|
-
"name": "
|
|
713
|
-
"type": "address",
|
|
714
|
-
"internalType": "address"
|
|
725
|
+
"name": "tokens",
|
|
726
|
+
"type": "address[]",
|
|
727
|
+
"internalType": "address[]"
|
|
715
728
|
},
|
|
716
729
|
{
|
|
717
|
-
"name": "
|
|
718
|
-
"type": "uint256",
|
|
719
|
-
"internalType": "uint256"
|
|
730
|
+
"name": "amounts",
|
|
731
|
+
"type": "uint256[]",
|
|
732
|
+
"internalType": "uint256[]"
|
|
720
733
|
},
|
|
721
734
|
{
|
|
722
735
|
"name": "value",
|
|
@@ -1057,32 +1070,6 @@ var AxonVaultAbi = [
|
|
|
1057
1070
|
],
|
|
1058
1071
|
"stateMutability": "view"
|
|
1059
1072
|
},
|
|
1060
|
-
{
|
|
1061
|
-
"type": "function",
|
|
1062
|
-
"name": "erc1271BotsEnabled",
|
|
1063
|
-
"inputs": [],
|
|
1064
|
-
"outputs": [
|
|
1065
|
-
{
|
|
1066
|
-
"name": "",
|
|
1067
|
-
"type": "bool",
|
|
1068
|
-
"internalType": "bool"
|
|
1069
|
-
}
|
|
1070
|
-
],
|
|
1071
|
-
"stateMutability": "view"
|
|
1072
|
-
},
|
|
1073
|
-
{
|
|
1074
|
-
"type": "function",
|
|
1075
|
-
"name": "setErc1271Bots",
|
|
1076
|
-
"inputs": [
|
|
1077
|
-
{
|
|
1078
|
-
"name": "enabled",
|
|
1079
|
-
"type": "bool",
|
|
1080
|
-
"internalType": "bool"
|
|
1081
|
-
}
|
|
1082
|
-
],
|
|
1083
|
-
"outputs": [],
|
|
1084
|
-
"stateMutability": "nonpayable"
|
|
1085
|
-
},
|
|
1086
1073
|
{
|
|
1087
1074
|
"type": "function",
|
|
1088
1075
|
"name": "onERC1155BatchReceived",
|
|
@@ -1435,6 +1422,19 @@ var AxonVaultAbi = [
|
|
|
1435
1422
|
"outputs": [],
|
|
1436
1423
|
"stateMutability": "nonpayable"
|
|
1437
1424
|
},
|
|
1425
|
+
{
|
|
1426
|
+
"type": "function",
|
|
1427
|
+
"name": "setErc1271Bots",
|
|
1428
|
+
"inputs": [
|
|
1429
|
+
{
|
|
1430
|
+
"name": "enabled",
|
|
1431
|
+
"type": "bool",
|
|
1432
|
+
"internalType": "bool"
|
|
1433
|
+
}
|
|
1434
|
+
],
|
|
1435
|
+
"outputs": [],
|
|
1436
|
+
"stateMutability": "nonpayable"
|
|
1437
|
+
},
|
|
1438
1438
|
{
|
|
1439
1439
|
"type": "function",
|
|
1440
1440
|
"name": "setOperator",
|
|
@@ -1682,19 +1682,6 @@ var AxonVaultAbi = [
|
|
|
1682
1682
|
"outputs": [],
|
|
1683
1683
|
"stateMutability": "nonpayable"
|
|
1684
1684
|
},
|
|
1685
|
-
{
|
|
1686
|
-
"type": "event",
|
|
1687
|
-
"name": "ERC1271BotsToggled",
|
|
1688
|
-
"inputs": [
|
|
1689
|
-
{
|
|
1690
|
-
"name": "enabled",
|
|
1691
|
-
"type": "bool",
|
|
1692
|
-
"indexed": false,
|
|
1693
|
-
"internalType": "bool"
|
|
1694
|
-
}
|
|
1695
|
-
],
|
|
1696
|
-
"anonymous": false
|
|
1697
|
-
},
|
|
1698
1685
|
{
|
|
1699
1686
|
"type": "event",
|
|
1700
1687
|
"name": "BotAdded",
|
|
@@ -1858,6 +1845,19 @@ var AxonVaultAbi = [
|
|
|
1858
1845
|
],
|
|
1859
1846
|
"anonymous": false
|
|
1860
1847
|
},
|
|
1848
|
+
{
|
|
1849
|
+
"type": "event",
|
|
1850
|
+
"name": "ERC1271BotsToggled",
|
|
1851
|
+
"inputs": [
|
|
1852
|
+
{
|
|
1853
|
+
"name": "enabled",
|
|
1854
|
+
"type": "bool",
|
|
1855
|
+
"indexed": false,
|
|
1856
|
+
"internalType": "bool"
|
|
1857
|
+
}
|
|
1858
|
+
],
|
|
1859
|
+
"anonymous": false
|
|
1860
|
+
},
|
|
1861
1861
|
{
|
|
1862
1862
|
"type": "event",
|
|
1863
1863
|
"name": "ERC721Withdrawn",
|
|
@@ -2330,6 +2330,11 @@ var AxonVaultAbi = [
|
|
|
2330
2330
|
"name": "AmountMismatch",
|
|
2331
2331
|
"inputs": []
|
|
2332
2332
|
},
|
|
2333
|
+
{
|
|
2334
|
+
"type": "error",
|
|
2335
|
+
"name": "ArrayLengthMismatch",
|
|
2336
|
+
"inputs": []
|
|
2337
|
+
},
|
|
2333
2338
|
{
|
|
2334
2339
|
"type": "error",
|
|
2335
2340
|
"name": "BotAlreadyExists",
|
|
@@ -2580,6 +2585,11 @@ var AxonVaultAbi = [
|
|
|
2580
2585
|
"name": "TooManySpendingLimits",
|
|
2581
2586
|
"inputs": []
|
|
2582
2587
|
},
|
|
2588
|
+
{
|
|
2589
|
+
"type": "error",
|
|
2590
|
+
"name": "TooManyTokens",
|
|
2591
|
+
"inputs": []
|
|
2592
|
+
},
|
|
2583
2593
|
{
|
|
2584
2594
|
"type": "error",
|
|
2585
2595
|
"name": "UnexpectedETH",
|
|
@@ -4205,12 +4215,29 @@ Timestamp: ${timestamp}`;
|
|
|
4205
4215
|
}
|
|
4206
4216
|
_buildExecuteIntent(input) {
|
|
4207
4217
|
_rejectBurnAddress(input.protocol, "Protocol address");
|
|
4218
|
+
const inputTokens = input.tokens ?? [];
|
|
4219
|
+
const inputAmounts = input.amounts ?? [];
|
|
4220
|
+
if (inputTokens.length !== inputAmounts.length) {
|
|
4221
|
+
throw new Error(`tokens length (${inputTokens.length}) must match amounts length (${inputAmounts.length})`);
|
|
4222
|
+
}
|
|
4223
|
+
if (inputTokens.length > 5) {
|
|
4224
|
+
throw new Error(`Too many tokens (${inputTokens.length}): maximum 5 allowed. Contact Axon if you need more.`);
|
|
4225
|
+
}
|
|
4226
|
+
const resolvedTokens = inputTokens.map((t) => resolveToken(t, this.chainId));
|
|
4227
|
+
const zeroAddr = "0x0000000000000000000000000000000000000000";
|
|
4228
|
+
for (const t of resolvedTokens) {
|
|
4229
|
+
if (t.toLowerCase() === zeroAddr) throw new Error("Zero address not allowed in tokens array");
|
|
4230
|
+
}
|
|
4231
|
+
const uniqueTokens = new Set(resolvedTokens.map((t) => t.toLowerCase()));
|
|
4232
|
+
if (uniqueTokens.size !== resolvedTokens.length) {
|
|
4233
|
+
throw new Error("Duplicate token addresses in tokens array");
|
|
4234
|
+
}
|
|
4208
4235
|
return {
|
|
4209
4236
|
bot: this.botAddress,
|
|
4210
4237
|
protocol: input.protocol,
|
|
4211
4238
|
calldataHash: viem.keccak256(input.callData),
|
|
4212
|
-
|
|
4213
|
-
|
|
4239
|
+
tokens: resolvedTokens,
|
|
4240
|
+
amounts: inputTokens.map((t, i) => parseAmount(inputAmounts[i], t, this.chainId)),
|
|
4214
4241
|
value: input.value ?? 0n,
|
|
4215
4242
|
deadline: input.deadline ?? this._defaultDeadline(),
|
|
4216
4243
|
ref: this._resolveRef(input.memo, input.ref)
|
|
@@ -4254,7 +4281,7 @@ Timestamp: ${timestamp}`;
|
|
|
4254
4281
|
async _submitExecute(intent, signature, input) {
|
|
4255
4282
|
const idempotencyKey = input.idempotencyKey ?? generateUuid();
|
|
4256
4283
|
const fromToken = input.fromToken !== void 0 ? resolveToken(input.fromToken, this.chainId) : void 0;
|
|
4257
|
-
const maxFromAmount = input.maxFromAmount !== void 0 ? parseAmount(input.maxFromAmount, input.fromToken ?? input.
|
|
4284
|
+
const maxFromAmount = input.maxFromAmount !== void 0 ? parseAmount(input.maxFromAmount, input.fromToken ?? input.tokens?.[0] ?? "USDC", this.chainId) : void 0;
|
|
4258
4285
|
const body = {
|
|
4259
4286
|
chainId: this.chainId,
|
|
4260
4287
|
vaultAddress: this.vaultAddress,
|
|
@@ -4262,8 +4289,8 @@ Timestamp: ${timestamp}`;
|
|
|
4262
4289
|
bot: intent.bot,
|
|
4263
4290
|
protocol: intent.protocol,
|
|
4264
4291
|
calldataHash: intent.calldataHash,
|
|
4265
|
-
|
|
4266
|
-
|
|
4292
|
+
tokens: intent.tokens,
|
|
4293
|
+
amounts: intent.amounts.map((a) => a.toString()),
|
|
4267
4294
|
value: intent.value.toString(),
|
|
4268
4295
|
deadline: intent.deadline.toString(),
|
|
4269
4296
|
ref: intent.ref,
|