@axonfi/sdk 0.10.0 → 0.12.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/dist/index.cjs CHANGED
@@ -66,10 +66,12 @@ var EXPLORER_ADDR = {
66
66
  var DEFAULT_DEADLINE_SECONDS = 300;
67
67
  var WINDOW = {
68
68
  ONE_HOUR: 3600n,
69
+ THREE_HOURS: 10800n,
69
70
  ONE_DAY: 86400n,
70
71
  ONE_WEEK: 604800n,
71
72
  THIRTY_DAYS: 2592000n
72
73
  };
74
+ var ALLOWED_WINDOWS = new Set(Object.values(WINDOW));
73
75
  var PaymentErrorCode = {
74
76
  /** Payment destination is the vault itself */
75
77
  SELF_PAYMENT: "SELF_PAYMENT",
@@ -672,26 +674,6 @@ var AxonVaultAbi = [
672
674
  "name": "signature",
673
675
  "type": "bytes",
674
676
  "internalType": "bytes"
675
- },
676
- {
677
- "name": "fromToken",
678
- "type": "address",
679
- "internalType": "address"
680
- },
681
- {
682
- "name": "maxFromAmount",
683
- "type": "uint256",
684
- "internalType": "uint256"
685
- },
686
- {
687
- "name": "swapRouter",
688
- "type": "address",
689
- "internalType": "address"
690
- },
691
- {
692
- "name": "swapCalldata",
693
- "type": "bytes",
694
- "internalType": "bytes"
695
677
  }
696
678
  ],
697
679
  "outputs": [],
@@ -757,26 +739,6 @@ var AxonVaultAbi = [
757
739
  "name": "callData",
758
740
  "type": "bytes",
759
741
  "internalType": "bytes"
760
- },
761
- {
762
- "name": "fromToken",
763
- "type": "address",
764
- "internalType": "address"
765
- },
766
- {
767
- "name": "maxFromAmount",
768
- "type": "uint256",
769
- "internalType": "uint256"
770
- },
771
- {
772
- "name": "swapRouter",
773
- "type": "address",
774
- "internalType": "address"
775
- },
776
- {
777
- "name": "swapCalldata",
778
- "type": "bytes",
779
- "internalType": "bytes"
780
742
  }
781
743
  ],
782
744
  "outputs": [
@@ -1241,19 +1203,6 @@ var AxonVaultAbi = [
1241
1203
  ],
1242
1204
  "stateMutability": "view"
1243
1205
  },
1244
- {
1245
- "type": "function",
1246
- "name": "operatorMaxDrainPerDay",
1247
- "inputs": [],
1248
- "outputs": [
1249
- {
1250
- "name": "",
1251
- "type": "uint256",
1252
- "internalType": "uint256"
1253
- }
1254
- ],
1255
- "stateMutability": "view"
1256
- },
1257
1206
  {
1258
1207
  "type": "function",
1259
1208
  "name": "owner",
@@ -2233,55 +2182,6 @@ var AxonVaultAbi = [
2233
2182
  ],
2234
2183
  "anonymous": false
2235
2184
  },
2236
- {
2237
- "type": "event",
2238
- "name": "SwapPaymentExecuted",
2239
- "inputs": [
2240
- {
2241
- "name": "bot",
2242
- "type": "address",
2243
- "indexed": true,
2244
- "internalType": "address"
2245
- },
2246
- {
2247
- "name": "to",
2248
- "type": "address",
2249
- "indexed": true,
2250
- "internalType": "address"
2251
- },
2252
- {
2253
- "name": "fromToken",
2254
- "type": "address",
2255
- "indexed": false,
2256
- "internalType": "address"
2257
- },
2258
- {
2259
- "name": "toToken",
2260
- "type": "address",
2261
- "indexed": false,
2262
- "internalType": "address"
2263
- },
2264
- {
2265
- "name": "fromAmount",
2266
- "type": "uint256",
2267
- "indexed": false,
2268
- "internalType": "uint256"
2269
- },
2270
- {
2271
- "name": "toAmount",
2272
- "type": "uint256",
2273
- "indexed": false,
2274
- "internalType": "uint256"
2275
- },
2276
- {
2277
- "name": "ref",
2278
- "type": "bytes32",
2279
- "indexed": false,
2280
- "internalType": "bytes32"
2281
- }
2282
- ],
2283
- "anonymous": false
2284
- },
2285
2185
  {
2286
2186
  "type": "event",
2287
2187
  "name": "Unpaused",
@@ -2424,22 +2324,22 @@ var AxonVaultAbi = [
2424
2324
  },
2425
2325
  {
2426
2326
  "type": "error",
2427
- "name": "InsufficientBalance",
2327
+ "name": "IntentAlreadyUsed",
2428
2328
  "inputs": []
2429
2329
  },
2430
2330
  {
2431
2331
  "type": "error",
2432
- "name": "IntentAlreadyUsed",
2332
+ "name": "InvalidInitialization",
2433
2333
  "inputs": []
2434
2334
  },
2435
2335
  {
2436
2336
  "type": "error",
2437
- "name": "InvalidInitialization",
2337
+ "name": "InvalidSignature",
2438
2338
  "inputs": []
2439
2339
  },
2440
2340
  {
2441
2341
  "type": "error",
2442
- "name": "InvalidSignature",
2342
+ "name": "InvalidSpendingWindow",
2443
2343
  "inputs": []
2444
2344
  },
2445
2345
  {
@@ -3250,6 +3150,12 @@ function createAxonWalletClient(privateKey, chainId) {
3250
3150
  var USDC_DECIMALS = 6n;
3251
3151
  var USDC_UNIT = 10n ** USDC_DECIMALS;
3252
3152
  function toBotConfigParams(input) {
3153
+ for (const sl of input.spendingLimits) {
3154
+ if (!ALLOWED_WINDOWS.has(BigInt(sl.windowSeconds))) {
3155
+ const allowed = [...ALLOWED_WINDOWS].map((w) => `${Number(w)}s`).join(", ");
3156
+ throw new Error(`Invalid spending window: ${sl.windowSeconds}s. Allowed values: ${allowed}. Use WINDOW constants.`);
3157
+ }
3158
+ }
3253
3159
  return {
3254
3160
  maxPerTxAmount: BigInt(Math.round(input.maxPerTxAmount * Number(USDC_UNIT))),
3255
3161
  maxRebalanceAmount: BigInt(Math.round(input.maxRebalanceAmount * Number(USDC_UNIT))),
@@ -3318,13 +3224,6 @@ async function getOperatorCeilings(publicClient, vaultAddress) {
3318
3224
  minAiTriggerFloor
3319
3225
  };
3320
3226
  }
3321
- async function operatorMaxDrainPerDay(publicClient, vaultAddress) {
3322
- return publicClient.readContract({
3323
- address: vaultAddress,
3324
- abi: AxonVaultAbi,
3325
- functionName: "operatorMaxDrainPerDay"
3326
- });
3327
- }
3328
3227
  async function isErc1271BotsEnabled(publicClient, vaultAddress) {
3329
3228
  return publicClient.readContract({
3330
3229
  address: vaultAddress,
@@ -4009,6 +3908,12 @@ var AxonClient = class {
4009
3908
  * The vault approves `token` to `protocol`, calls it with `callData`,
4010
3909
  * then revokes the approval. Tokens stay in the vault or go to the protocol
4011
3910
  * as specified by the calldata.
3911
+ *
3912
+ * **Approval rules for default tokens** (USDC, WETH, etc.): when calling
3913
+ * `approve()` on a default token, the spender must be an approved protocol
3914
+ * or swap router — the contract rejects arbitrary addresses. The approve
3915
+ * amount is capped by the bot's `maxPerTxAmount` and counts toward
3916
+ * spending limits.
4012
3917
  */
4013
3918
  async execute(input) {
4014
3919
  const intent = this._buildExecuteIntent(input);
@@ -5035,6 +4940,7 @@ var AxonRegistryAbi = [
5035
4940
  }
5036
4941
  ];
5037
4942
 
4943
+ exports.ALLOWED_WINDOWS = ALLOWED_WINDOWS;
5038
4944
  exports.AxonClient = AxonClient;
5039
4945
  exports.AxonRegistryAbi = AxonRegistryAbi;
5040
4946
  exports.AxonVaultAbi = AxonVaultAbi;
@@ -5089,7 +4995,6 @@ exports.isDestinationAllowed = isDestinationAllowed;
5089
4995
  exports.isErc1271BotsEnabled = isErc1271BotsEnabled;
5090
4996
  exports.isRebalanceTokenWhitelisted = isRebalanceTokenWhitelisted;
5091
4997
  exports.isVaultPaused = isVaultPaused;
5092
- exports.operatorMaxDrainPerDay = operatorMaxDrainPerDay;
5093
4998
  exports.parseAmount = parseAmount;
5094
4999
  exports.parseChainId = parseChainId;
5095
5000
  exports.parsePaymentRequired = parsePaymentRequired;