@axonfi/sdk 0.8.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 +38 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -33
- package/dist/index.d.ts +28 -33
- package/dist/index.js +38 -32
- 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,11 +153,9 @@ 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
|
-
{ name: "extraTokens", type: "address[]" },
|
|
160
|
-
{ name: "extraAmounts", type: "uint256[]" },
|
|
161
159
|
{ name: "deadline", type: "uint256" },
|
|
162
160
|
{ name: "ref", type: "bytes32" }
|
|
163
161
|
]
|
|
@@ -211,11 +209,9 @@ async function signExecuteIntent(walletClient, vaultAddress, chainId, intent) {
|
|
|
211
209
|
bot: intent.bot,
|
|
212
210
|
protocol: intent.protocol,
|
|
213
211
|
calldataHash: intent.calldataHash,
|
|
214
|
-
|
|
215
|
-
|
|
212
|
+
tokens: intent.tokens,
|
|
213
|
+
amounts: intent.amounts,
|
|
216
214
|
value: intent.value,
|
|
217
|
-
extraTokens: intent.extraTokens,
|
|
218
|
-
extraAmounts: intent.extraAmounts,
|
|
219
215
|
deadline: intent.deadline,
|
|
220
216
|
ref: intent.ref
|
|
221
217
|
}
|
|
@@ -726,30 +722,20 @@ var AxonVaultAbi = [
|
|
|
726
722
|
"internalType": "bytes32"
|
|
727
723
|
},
|
|
728
724
|
{
|
|
729
|
-
"name": "
|
|
730
|
-
"type": "address",
|
|
731
|
-
"internalType": "address"
|
|
725
|
+
"name": "tokens",
|
|
726
|
+
"type": "address[]",
|
|
727
|
+
"internalType": "address[]"
|
|
732
728
|
},
|
|
733
729
|
{
|
|
734
|
-
"name": "
|
|
735
|
-
"type": "uint256",
|
|
736
|
-
"internalType": "uint256"
|
|
730
|
+
"name": "amounts",
|
|
731
|
+
"type": "uint256[]",
|
|
732
|
+
"internalType": "uint256[]"
|
|
737
733
|
},
|
|
738
734
|
{
|
|
739
735
|
"name": "value",
|
|
740
736
|
"type": "uint256",
|
|
741
737
|
"internalType": "uint256"
|
|
742
738
|
},
|
|
743
|
-
{
|
|
744
|
-
"name": "extraTokens",
|
|
745
|
-
"type": "address[]",
|
|
746
|
-
"internalType": "address[]"
|
|
747
|
-
},
|
|
748
|
-
{
|
|
749
|
-
"name": "extraAmounts",
|
|
750
|
-
"type": "uint256[]",
|
|
751
|
-
"internalType": "uint256[]"
|
|
752
|
-
},
|
|
753
739
|
{
|
|
754
740
|
"name": "deadline",
|
|
755
741
|
"type": "uint256",
|
|
@@ -2599,6 +2585,11 @@ var AxonVaultAbi = [
|
|
|
2599
2585
|
"name": "TooManySpendingLimits",
|
|
2600
2586
|
"inputs": []
|
|
2601
2587
|
},
|
|
2588
|
+
{
|
|
2589
|
+
"type": "error",
|
|
2590
|
+
"name": "TooManyTokens",
|
|
2591
|
+
"inputs": []
|
|
2592
|
+
},
|
|
2602
2593
|
{
|
|
2603
2594
|
"type": "error",
|
|
2604
2595
|
"name": "UnexpectedETH",
|
|
@@ -4224,15 +4215,30 @@ Timestamp: ${timestamp}`;
|
|
|
4224
4215
|
}
|
|
4225
4216
|
_buildExecuteIntent(input) {
|
|
4226
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
|
+
}
|
|
4227
4235
|
return {
|
|
4228
4236
|
bot: this.botAddress,
|
|
4229
4237
|
protocol: input.protocol,
|
|
4230
4238
|
calldataHash: viem.keccak256(input.callData),
|
|
4231
|
-
|
|
4232
|
-
|
|
4239
|
+
tokens: resolvedTokens,
|
|
4240
|
+
amounts: inputTokens.map((t, i) => parseAmount(inputAmounts[i], t, this.chainId)),
|
|
4233
4241
|
value: input.value ?? 0n,
|
|
4234
|
-
extraTokens: input.extraTokens ?? [],
|
|
4235
|
-
extraAmounts: input.extraAmounts ?? [],
|
|
4236
4242
|
deadline: input.deadline ?? this._defaultDeadline(),
|
|
4237
4243
|
ref: this._resolveRef(input.memo, input.ref)
|
|
4238
4244
|
};
|
|
@@ -4275,7 +4281,7 @@ Timestamp: ${timestamp}`;
|
|
|
4275
4281
|
async _submitExecute(intent, signature, input) {
|
|
4276
4282
|
const idempotencyKey = input.idempotencyKey ?? generateUuid();
|
|
4277
4283
|
const fromToken = input.fromToken !== void 0 ? resolveToken(input.fromToken, this.chainId) : void 0;
|
|
4278
|
-
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;
|
|
4279
4285
|
const body = {
|
|
4280
4286
|
chainId: this.chainId,
|
|
4281
4287
|
vaultAddress: this.vaultAddress,
|
|
@@ -4283,8 +4289,8 @@ Timestamp: ${timestamp}`;
|
|
|
4283
4289
|
bot: intent.bot,
|
|
4284
4290
|
protocol: intent.protocol,
|
|
4285
4291
|
calldataHash: intent.calldataHash,
|
|
4286
|
-
|
|
4287
|
-
|
|
4292
|
+
tokens: intent.tokens,
|
|
4293
|
+
amounts: intent.amounts.map((a) => a.toString()),
|
|
4288
4294
|
value: intent.value.toString(),
|
|
4289
4295
|
deadline: intent.deadline.toString(),
|
|
4290
4296
|
ref: intent.ref,
|