@axonfi/sdk 0.10.0 → 0.11.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": [
@@ -2233,55 +2195,6 @@ var AxonVaultAbi = [
2233
2195
  ],
2234
2196
  "anonymous": false
2235
2197
  },
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
2198
  {
2286
2199
  "type": "event",
2287
2200
  "name": "Unpaused",
@@ -2424,22 +2337,22 @@ var AxonVaultAbi = [
2424
2337
  },
2425
2338
  {
2426
2339
  "type": "error",
2427
- "name": "InsufficientBalance",
2340
+ "name": "IntentAlreadyUsed",
2428
2341
  "inputs": []
2429
2342
  },
2430
2343
  {
2431
2344
  "type": "error",
2432
- "name": "IntentAlreadyUsed",
2345
+ "name": "InvalidInitialization",
2433
2346
  "inputs": []
2434
2347
  },
2435
2348
  {
2436
2349
  "type": "error",
2437
- "name": "InvalidInitialization",
2350
+ "name": "InvalidSignature",
2438
2351
  "inputs": []
2439
2352
  },
2440
2353
  {
2441
2354
  "type": "error",
2442
- "name": "InvalidSignature",
2355
+ "name": "InvalidSpendingWindow",
2443
2356
  "inputs": []
2444
2357
  },
2445
2358
  {
@@ -3250,6 +3163,12 @@ function createAxonWalletClient(privateKey, chainId) {
3250
3163
  var USDC_DECIMALS = 6n;
3251
3164
  var USDC_UNIT = 10n ** USDC_DECIMALS;
3252
3165
  function toBotConfigParams(input) {
3166
+ for (const sl of input.spendingLimits) {
3167
+ if (!ALLOWED_WINDOWS.has(BigInt(sl.windowSeconds))) {
3168
+ const allowed = [...ALLOWED_WINDOWS].map((w) => `${Number(w)}s`).join(", ");
3169
+ throw new Error(`Invalid spending window: ${sl.windowSeconds}s. Allowed values: ${allowed}. Use WINDOW constants.`);
3170
+ }
3171
+ }
3253
3172
  return {
3254
3173
  maxPerTxAmount: BigInt(Math.round(input.maxPerTxAmount * Number(USDC_UNIT))),
3255
3174
  maxRebalanceAmount: BigInt(Math.round(input.maxRebalanceAmount * Number(USDC_UNIT))),
@@ -4009,6 +3928,12 @@ var AxonClient = class {
4009
3928
  * The vault approves `token` to `protocol`, calls it with `callData`,
4010
3929
  * then revokes the approval. Tokens stay in the vault or go to the protocol
4011
3930
  * as specified by the calldata.
3931
+ *
3932
+ * **Approval rules for default tokens** (USDC, WETH, etc.): when calling
3933
+ * `approve()` on a default token, the spender must be an approved protocol
3934
+ * or swap router — the contract rejects arbitrary addresses. The approve
3935
+ * amount is capped by the bot's `maxPerTxAmount` and counts toward
3936
+ * spending limits.
4012
3937
  */
4013
3938
  async execute(input) {
4014
3939
  const intent = this._buildExecuteIntent(input);
@@ -5035,6 +4960,7 @@ var AxonRegistryAbi = [
5035
4960
  }
5036
4961
  ];
5037
4962
 
4963
+ exports.ALLOWED_WINDOWS = ALLOWED_WINDOWS;
5038
4964
  exports.AxonClient = AxonClient;
5039
4965
  exports.AxonRegistryAbi = AxonRegistryAbi;
5040
4966
  exports.AxonVaultAbi = AxonVaultAbi;