@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.d.cts CHANGED
@@ -249,13 +249,20 @@ declare const EXPLORER_TX: Record<number, string>;
249
249
  declare const EXPLORER_ADDR: Record<number, string>;
250
250
  /** Default intent validity window when no deadline is specified. */
251
251
  declare const DEFAULT_DEADLINE_SECONDS = 300;
252
- /** Window presets for SpendingLimit.windowSeconds. */
252
+ /**
253
+ * Allowed window presets for SpendingLimit.windowSeconds.
254
+ * These are the ONLY values accepted by the contract — arbitrary
255
+ * durations are rejected on-chain with InvalidSpendingWindow().
256
+ */
253
257
  declare const WINDOW: {
254
258
  readonly ONE_HOUR: 3600n;
259
+ readonly THREE_HOURS: 10800n;
255
260
  readonly ONE_DAY: 86400n;
256
261
  readonly ONE_WEEK: 604800n;
257
262
  readonly THIRTY_DAYS: 2592000n;
258
263
  };
264
+ /** Set of all allowed window values for validation. */
265
+ declare const ALLOWED_WINDOWS: ReadonlySet<bigint>;
259
266
  /**
260
267
  * Structured error codes returned by the relayer when a payment is rejected.
261
268
  * Bots should import these to programmatically handle failures.
@@ -346,7 +353,7 @@ interface SpendingLimit {
346
353
  amount: bigint;
347
354
  /** Max number of transactions in this window. 0 = no count limit. */
348
355
  maxCount: bigint;
349
- /** Window size: 3600=1h, 86400=1d, 604800=1w, 2592000=30d */
356
+ /** Window duration. Must be one of the allowed WINDOW values: 1h, 3h, 24h, 7d, 30d. */
350
357
  windowSeconds: bigint;
351
358
  }
352
359
  /** Per-bot configuration returned by getBotConfig(). */
@@ -379,7 +386,7 @@ interface SpendingLimitInput {
379
386
  amount: number;
380
387
  /** Max transactions in this window. 0 = no count limit. */
381
388
  maxCount: number;
382
- /** Window size in seconds: 3600=1h, 86400=1d, 604800=1w. Use WINDOW constants. */
389
+ /** Window duration. Must be one of the allowed WINDOW values: 1h, 3h, 24h, 7d, 30d. */
383
390
  windowSeconds: number;
384
391
  }
385
392
  /**
@@ -812,6 +819,12 @@ declare class AxonClient {
812
819
  * The vault approves `token` to `protocol`, calls it with `callData`,
813
820
  * then revokes the approval. Tokens stay in the vault or go to the protocol
814
821
  * as specified by the calldata.
822
+ *
823
+ * **Approval rules for default tokens** (USDC, WETH, etc.): when calling
824
+ * `approve()` on a default token, the spender must be an approved protocol
825
+ * or swap router — the contract rejects arbitrary addresses. The approve
826
+ * amount is capped by the bot's `maxPerTxAmount` and counts toward
827
+ * spending limits.
815
828
  */
816
829
  execute(input: ExecuteInput): Promise<PaymentResult>;
817
830
  /**
@@ -1649,22 +1662,6 @@ declare const AxonVaultAbi: readonly [{
1649
1662
  readonly name: "signature";
1650
1663
  readonly type: "bytes";
1651
1664
  readonly internalType: "bytes";
1652
- }, {
1653
- readonly name: "fromToken";
1654
- readonly type: "address";
1655
- readonly internalType: "address";
1656
- }, {
1657
- readonly name: "maxFromAmount";
1658
- readonly type: "uint256";
1659
- readonly internalType: "uint256";
1660
- }, {
1661
- readonly name: "swapRouter";
1662
- readonly type: "address";
1663
- readonly internalType: "address";
1664
- }, {
1665
- readonly name: "swapCalldata";
1666
- readonly type: "bytes";
1667
- readonly internalType: "bytes";
1668
1665
  }];
1669
1666
  readonly outputs: readonly [];
1670
1667
  readonly stateMutability: "nonpayable";
@@ -1716,22 +1713,6 @@ declare const AxonVaultAbi: readonly [{
1716
1713
  readonly name: "callData";
1717
1714
  readonly type: "bytes";
1718
1715
  readonly internalType: "bytes";
1719
- }, {
1720
- readonly name: "fromToken";
1721
- readonly type: "address";
1722
- readonly internalType: "address";
1723
- }, {
1724
- readonly name: "maxFromAmount";
1725
- readonly type: "uint256";
1726
- readonly internalType: "uint256";
1727
- }, {
1728
- readonly name: "swapRouter";
1729
- readonly type: "address";
1730
- readonly internalType: "address";
1731
- }, {
1732
- readonly name: "swapCalldata";
1733
- readonly type: "bytes";
1734
- readonly internalType: "bytes";
1735
1716
  }];
1736
1717
  readonly outputs: readonly [{
1737
1718
  readonly name: "";
@@ -2863,46 +2844,6 @@ declare const AxonVaultAbi: readonly [{
2863
2844
  readonly internalType: "bytes32";
2864
2845
  }];
2865
2846
  readonly anonymous: false;
2866
- }, {
2867
- readonly type: "event";
2868
- readonly name: "SwapPaymentExecuted";
2869
- readonly inputs: readonly [{
2870
- readonly name: "bot";
2871
- readonly type: "address";
2872
- readonly indexed: true;
2873
- readonly internalType: "address";
2874
- }, {
2875
- readonly name: "to";
2876
- readonly type: "address";
2877
- readonly indexed: true;
2878
- readonly internalType: "address";
2879
- }, {
2880
- readonly name: "fromToken";
2881
- readonly type: "address";
2882
- readonly indexed: false;
2883
- readonly internalType: "address";
2884
- }, {
2885
- readonly name: "toToken";
2886
- readonly type: "address";
2887
- readonly indexed: false;
2888
- readonly internalType: "address";
2889
- }, {
2890
- readonly name: "fromAmount";
2891
- readonly type: "uint256";
2892
- readonly indexed: false;
2893
- readonly internalType: "uint256";
2894
- }, {
2895
- readonly name: "toAmount";
2896
- readonly type: "uint256";
2897
- readonly indexed: false;
2898
- readonly internalType: "uint256";
2899
- }, {
2900
- readonly name: "ref";
2901
- readonly type: "bytes32";
2902
- readonly indexed: false;
2903
- readonly internalType: "bytes32";
2904
- }];
2905
- readonly anonymous: false;
2906
2847
  }, {
2907
2848
  readonly type: "event";
2908
2849
  readonly name: "Unpaused";
@@ -3013,10 +2954,6 @@ declare const AxonVaultAbi: readonly [{
3013
2954
  readonly type: "error";
3014
2955
  readonly name: "ExpectedPause";
3015
2956
  readonly inputs: readonly [];
3016
- }, {
3017
- readonly type: "error";
3018
- readonly name: "InsufficientBalance";
3019
- readonly inputs: readonly [];
3020
2957
  }, {
3021
2958
  readonly type: "error";
3022
2959
  readonly name: "IntentAlreadyUsed";
@@ -3029,6 +2966,10 @@ declare const AxonVaultAbi: readonly [{
3029
2966
  readonly type: "error";
3030
2967
  readonly name: "InvalidSignature";
3031
2968
  readonly inputs: readonly [];
2969
+ }, {
2970
+ readonly type: "error";
2971
+ readonly name: "InvalidSpendingWindow";
2972
+ readonly inputs: readonly [];
3032
2973
  }, {
3033
2974
  readonly type: "error";
3034
2975
  readonly name: "MaxPerTxExceeded";
@@ -3822,4 +3763,4 @@ declare const AxonRegistryAbi: readonly [{
3822
3763
  readonly inputs: readonly [];
3823
3764
  }];
3824
3765
 
3825
- export { type AmountInput, AxonClient, type AxonClientConfig, AxonRegistryAbi, AxonVaultAbi, AxonVaultFactoryAbi, type BotConfig, type BotConfigInput, type BotConfigParams, CHAIN_NAMES, Chain, DEFAULT_APPROVED_TOKENS, DEFAULT_DEADLINE_SECONDS, type DestinationCheckResult, EIP712_DOMAIN_NAME, EIP712_DOMAIN_VERSION, EXECUTE_INTENT_TYPEHASH, EXPLORER_ADDR, EXPLORER_TX, type ExecuteInput, type ExecuteIntent, KNOWN_TOKENS, type KeystoreV3, type KnownToken, type KnownTokenSymbol, NATIVE_ETH, type OperatorCeilings, PAYMENT_INTENT_TYPEHASH, PERMIT2_ADDRESS, type PayInput, PaymentErrorCode, type PaymentIntent, type PaymentResult, type PaymentStatus, type Permit2Authorization, RELAYER_API, type RebalanceTokensResult, SUPPORTED_CHAIN_IDS, SWAP_INTENT_TYPEHASH, type SpendingLimit, type SpendingLimitInput, type SupportedChainId, type SwapInput, type SwapIntent, Token, type TokenInput, type TosStatus, type TransferAuthorization, USDC, USDC_EIP712_DOMAIN, type VaultInfo, WINDOW, WITNESS_TYPE_STRING, type X402HandleResult, type X402PaymentOption, type X402PaymentRequired, type X402Resource, X402_PROXY_ADDRESS, addBot, createAxonPublicClient, createAxonWalletClient, decryptKeystore, deployVault, deposit, encodeRef, encryptKeystore, extractX402Metadata, findMatchingOption, formatPaymentSignature, getBotConfig, getChain, getDefaultApprovedTokens, getDomainSeparator, getKnownTokensForChain, getOperatorCeilings, getRebalanceTokenCount, getTokenSymbolByAddress, getVaultOperator, getVaultOwner, getVaultVersion, isBotActive, isDestinationAllowed, isErc1271BotsEnabled, isRebalanceTokenWhitelisted, isVaultPaused, operatorMaxDrainPerDay, parseAmount, parseChainId, parsePaymentRequired, predictVaultAddress, randomNonce, randomPermit2Nonce, removeBot, resolveToken, resolveTokenDecimals, signExecuteIntent, signPayment, signPermit2WitnessTransfer, signSwapIntent, signTransferWithAuthorization, toBotConfigParams, updateBotConfig };
3766
+ export { ALLOWED_WINDOWS, type AmountInput, AxonClient, type AxonClientConfig, AxonRegistryAbi, AxonVaultAbi, AxonVaultFactoryAbi, type BotConfig, type BotConfigInput, type BotConfigParams, CHAIN_NAMES, Chain, DEFAULT_APPROVED_TOKENS, DEFAULT_DEADLINE_SECONDS, type DestinationCheckResult, EIP712_DOMAIN_NAME, EIP712_DOMAIN_VERSION, EXECUTE_INTENT_TYPEHASH, EXPLORER_ADDR, EXPLORER_TX, type ExecuteInput, type ExecuteIntent, KNOWN_TOKENS, type KeystoreV3, type KnownToken, type KnownTokenSymbol, NATIVE_ETH, type OperatorCeilings, PAYMENT_INTENT_TYPEHASH, PERMIT2_ADDRESS, type PayInput, PaymentErrorCode, type PaymentIntent, type PaymentResult, type PaymentStatus, type Permit2Authorization, RELAYER_API, type RebalanceTokensResult, SUPPORTED_CHAIN_IDS, SWAP_INTENT_TYPEHASH, type SpendingLimit, type SpendingLimitInput, type SupportedChainId, type SwapInput, type SwapIntent, Token, type TokenInput, type TosStatus, type TransferAuthorization, USDC, USDC_EIP712_DOMAIN, type VaultInfo, WINDOW, WITNESS_TYPE_STRING, type X402HandleResult, type X402PaymentOption, type X402PaymentRequired, type X402Resource, X402_PROXY_ADDRESS, addBot, createAxonPublicClient, createAxonWalletClient, decryptKeystore, deployVault, deposit, encodeRef, encryptKeystore, extractX402Metadata, findMatchingOption, formatPaymentSignature, getBotConfig, getChain, getDefaultApprovedTokens, getDomainSeparator, getKnownTokensForChain, getOperatorCeilings, getRebalanceTokenCount, getTokenSymbolByAddress, getVaultOperator, getVaultOwner, getVaultVersion, isBotActive, isDestinationAllowed, isErc1271BotsEnabled, isRebalanceTokenWhitelisted, isVaultPaused, operatorMaxDrainPerDay, parseAmount, parseChainId, parsePaymentRequired, predictVaultAddress, randomNonce, randomPermit2Nonce, removeBot, resolveToken, resolveTokenDecimals, signExecuteIntent, signPayment, signPermit2WitnessTransfer, signSwapIntent, signTransferWithAuthorization, toBotConfigParams, updateBotConfig };
package/dist/index.d.ts CHANGED
@@ -249,13 +249,20 @@ declare const EXPLORER_TX: Record<number, string>;
249
249
  declare const EXPLORER_ADDR: Record<number, string>;
250
250
  /** Default intent validity window when no deadline is specified. */
251
251
  declare const DEFAULT_DEADLINE_SECONDS = 300;
252
- /** Window presets for SpendingLimit.windowSeconds. */
252
+ /**
253
+ * Allowed window presets for SpendingLimit.windowSeconds.
254
+ * These are the ONLY values accepted by the contract — arbitrary
255
+ * durations are rejected on-chain with InvalidSpendingWindow().
256
+ */
253
257
  declare const WINDOW: {
254
258
  readonly ONE_HOUR: 3600n;
259
+ readonly THREE_HOURS: 10800n;
255
260
  readonly ONE_DAY: 86400n;
256
261
  readonly ONE_WEEK: 604800n;
257
262
  readonly THIRTY_DAYS: 2592000n;
258
263
  };
264
+ /** Set of all allowed window values for validation. */
265
+ declare const ALLOWED_WINDOWS: ReadonlySet<bigint>;
259
266
  /**
260
267
  * Structured error codes returned by the relayer when a payment is rejected.
261
268
  * Bots should import these to programmatically handle failures.
@@ -346,7 +353,7 @@ interface SpendingLimit {
346
353
  amount: bigint;
347
354
  /** Max number of transactions in this window. 0 = no count limit. */
348
355
  maxCount: bigint;
349
- /** Window size: 3600=1h, 86400=1d, 604800=1w, 2592000=30d */
356
+ /** Window duration. Must be one of the allowed WINDOW values: 1h, 3h, 24h, 7d, 30d. */
350
357
  windowSeconds: bigint;
351
358
  }
352
359
  /** Per-bot configuration returned by getBotConfig(). */
@@ -379,7 +386,7 @@ interface SpendingLimitInput {
379
386
  amount: number;
380
387
  /** Max transactions in this window. 0 = no count limit. */
381
388
  maxCount: number;
382
- /** Window size in seconds: 3600=1h, 86400=1d, 604800=1w. Use WINDOW constants. */
389
+ /** Window duration. Must be one of the allowed WINDOW values: 1h, 3h, 24h, 7d, 30d. */
383
390
  windowSeconds: number;
384
391
  }
385
392
  /**
@@ -812,6 +819,12 @@ declare class AxonClient {
812
819
  * The vault approves `token` to `protocol`, calls it with `callData`,
813
820
  * then revokes the approval. Tokens stay in the vault or go to the protocol
814
821
  * as specified by the calldata.
822
+ *
823
+ * **Approval rules for default tokens** (USDC, WETH, etc.): when calling
824
+ * `approve()` on a default token, the spender must be an approved protocol
825
+ * or swap router — the contract rejects arbitrary addresses. The approve
826
+ * amount is capped by the bot's `maxPerTxAmount` and counts toward
827
+ * spending limits.
815
828
  */
816
829
  execute(input: ExecuteInput): Promise<PaymentResult>;
817
830
  /**
@@ -1649,22 +1662,6 @@ declare const AxonVaultAbi: readonly [{
1649
1662
  readonly name: "signature";
1650
1663
  readonly type: "bytes";
1651
1664
  readonly internalType: "bytes";
1652
- }, {
1653
- readonly name: "fromToken";
1654
- readonly type: "address";
1655
- readonly internalType: "address";
1656
- }, {
1657
- readonly name: "maxFromAmount";
1658
- readonly type: "uint256";
1659
- readonly internalType: "uint256";
1660
- }, {
1661
- readonly name: "swapRouter";
1662
- readonly type: "address";
1663
- readonly internalType: "address";
1664
- }, {
1665
- readonly name: "swapCalldata";
1666
- readonly type: "bytes";
1667
- readonly internalType: "bytes";
1668
1665
  }];
1669
1666
  readonly outputs: readonly [];
1670
1667
  readonly stateMutability: "nonpayable";
@@ -1716,22 +1713,6 @@ declare const AxonVaultAbi: readonly [{
1716
1713
  readonly name: "callData";
1717
1714
  readonly type: "bytes";
1718
1715
  readonly internalType: "bytes";
1719
- }, {
1720
- readonly name: "fromToken";
1721
- readonly type: "address";
1722
- readonly internalType: "address";
1723
- }, {
1724
- readonly name: "maxFromAmount";
1725
- readonly type: "uint256";
1726
- readonly internalType: "uint256";
1727
- }, {
1728
- readonly name: "swapRouter";
1729
- readonly type: "address";
1730
- readonly internalType: "address";
1731
- }, {
1732
- readonly name: "swapCalldata";
1733
- readonly type: "bytes";
1734
- readonly internalType: "bytes";
1735
1716
  }];
1736
1717
  readonly outputs: readonly [{
1737
1718
  readonly name: "";
@@ -2863,46 +2844,6 @@ declare const AxonVaultAbi: readonly [{
2863
2844
  readonly internalType: "bytes32";
2864
2845
  }];
2865
2846
  readonly anonymous: false;
2866
- }, {
2867
- readonly type: "event";
2868
- readonly name: "SwapPaymentExecuted";
2869
- readonly inputs: readonly [{
2870
- readonly name: "bot";
2871
- readonly type: "address";
2872
- readonly indexed: true;
2873
- readonly internalType: "address";
2874
- }, {
2875
- readonly name: "to";
2876
- readonly type: "address";
2877
- readonly indexed: true;
2878
- readonly internalType: "address";
2879
- }, {
2880
- readonly name: "fromToken";
2881
- readonly type: "address";
2882
- readonly indexed: false;
2883
- readonly internalType: "address";
2884
- }, {
2885
- readonly name: "toToken";
2886
- readonly type: "address";
2887
- readonly indexed: false;
2888
- readonly internalType: "address";
2889
- }, {
2890
- readonly name: "fromAmount";
2891
- readonly type: "uint256";
2892
- readonly indexed: false;
2893
- readonly internalType: "uint256";
2894
- }, {
2895
- readonly name: "toAmount";
2896
- readonly type: "uint256";
2897
- readonly indexed: false;
2898
- readonly internalType: "uint256";
2899
- }, {
2900
- readonly name: "ref";
2901
- readonly type: "bytes32";
2902
- readonly indexed: false;
2903
- readonly internalType: "bytes32";
2904
- }];
2905
- readonly anonymous: false;
2906
2847
  }, {
2907
2848
  readonly type: "event";
2908
2849
  readonly name: "Unpaused";
@@ -3013,10 +2954,6 @@ declare const AxonVaultAbi: readonly [{
3013
2954
  readonly type: "error";
3014
2955
  readonly name: "ExpectedPause";
3015
2956
  readonly inputs: readonly [];
3016
- }, {
3017
- readonly type: "error";
3018
- readonly name: "InsufficientBalance";
3019
- readonly inputs: readonly [];
3020
2957
  }, {
3021
2958
  readonly type: "error";
3022
2959
  readonly name: "IntentAlreadyUsed";
@@ -3029,6 +2966,10 @@ declare const AxonVaultAbi: readonly [{
3029
2966
  readonly type: "error";
3030
2967
  readonly name: "InvalidSignature";
3031
2968
  readonly inputs: readonly [];
2969
+ }, {
2970
+ readonly type: "error";
2971
+ readonly name: "InvalidSpendingWindow";
2972
+ readonly inputs: readonly [];
3032
2973
  }, {
3033
2974
  readonly type: "error";
3034
2975
  readonly name: "MaxPerTxExceeded";
@@ -3822,4 +3763,4 @@ declare const AxonRegistryAbi: readonly [{
3822
3763
  readonly inputs: readonly [];
3823
3764
  }];
3824
3765
 
3825
- export { type AmountInput, AxonClient, type AxonClientConfig, AxonRegistryAbi, AxonVaultAbi, AxonVaultFactoryAbi, type BotConfig, type BotConfigInput, type BotConfigParams, CHAIN_NAMES, Chain, DEFAULT_APPROVED_TOKENS, DEFAULT_DEADLINE_SECONDS, type DestinationCheckResult, EIP712_DOMAIN_NAME, EIP712_DOMAIN_VERSION, EXECUTE_INTENT_TYPEHASH, EXPLORER_ADDR, EXPLORER_TX, type ExecuteInput, type ExecuteIntent, KNOWN_TOKENS, type KeystoreV3, type KnownToken, type KnownTokenSymbol, NATIVE_ETH, type OperatorCeilings, PAYMENT_INTENT_TYPEHASH, PERMIT2_ADDRESS, type PayInput, PaymentErrorCode, type PaymentIntent, type PaymentResult, type PaymentStatus, type Permit2Authorization, RELAYER_API, type RebalanceTokensResult, SUPPORTED_CHAIN_IDS, SWAP_INTENT_TYPEHASH, type SpendingLimit, type SpendingLimitInput, type SupportedChainId, type SwapInput, type SwapIntent, Token, type TokenInput, type TosStatus, type TransferAuthorization, USDC, USDC_EIP712_DOMAIN, type VaultInfo, WINDOW, WITNESS_TYPE_STRING, type X402HandleResult, type X402PaymentOption, type X402PaymentRequired, type X402Resource, X402_PROXY_ADDRESS, addBot, createAxonPublicClient, createAxonWalletClient, decryptKeystore, deployVault, deposit, encodeRef, encryptKeystore, extractX402Metadata, findMatchingOption, formatPaymentSignature, getBotConfig, getChain, getDefaultApprovedTokens, getDomainSeparator, getKnownTokensForChain, getOperatorCeilings, getRebalanceTokenCount, getTokenSymbolByAddress, getVaultOperator, getVaultOwner, getVaultVersion, isBotActive, isDestinationAllowed, isErc1271BotsEnabled, isRebalanceTokenWhitelisted, isVaultPaused, operatorMaxDrainPerDay, parseAmount, parseChainId, parsePaymentRequired, predictVaultAddress, randomNonce, randomPermit2Nonce, removeBot, resolveToken, resolveTokenDecimals, signExecuteIntent, signPayment, signPermit2WitnessTransfer, signSwapIntent, signTransferWithAuthorization, toBotConfigParams, updateBotConfig };
3766
+ export { ALLOWED_WINDOWS, type AmountInput, AxonClient, type AxonClientConfig, AxonRegistryAbi, AxonVaultAbi, AxonVaultFactoryAbi, type BotConfig, type BotConfigInput, type BotConfigParams, CHAIN_NAMES, Chain, DEFAULT_APPROVED_TOKENS, DEFAULT_DEADLINE_SECONDS, type DestinationCheckResult, EIP712_DOMAIN_NAME, EIP712_DOMAIN_VERSION, EXECUTE_INTENT_TYPEHASH, EXPLORER_ADDR, EXPLORER_TX, type ExecuteInput, type ExecuteIntent, KNOWN_TOKENS, type KeystoreV3, type KnownToken, type KnownTokenSymbol, NATIVE_ETH, type OperatorCeilings, PAYMENT_INTENT_TYPEHASH, PERMIT2_ADDRESS, type PayInput, PaymentErrorCode, type PaymentIntent, type PaymentResult, type PaymentStatus, type Permit2Authorization, RELAYER_API, type RebalanceTokensResult, SUPPORTED_CHAIN_IDS, SWAP_INTENT_TYPEHASH, type SpendingLimit, type SpendingLimitInput, type SupportedChainId, type SwapInput, type SwapIntent, Token, type TokenInput, type TosStatus, type TransferAuthorization, USDC, USDC_EIP712_DOMAIN, type VaultInfo, WINDOW, WITNESS_TYPE_STRING, type X402HandleResult, type X402PaymentOption, type X402PaymentRequired, type X402Resource, X402_PROXY_ADDRESS, addBot, createAxonPublicClient, createAxonWalletClient, decryptKeystore, deployVault, deposit, encodeRef, encryptKeystore, extractX402Metadata, findMatchingOption, formatPaymentSignature, getBotConfig, getChain, getDefaultApprovedTokens, getDomainSeparator, getKnownTokensForChain, getOperatorCeilings, getRebalanceTokenCount, getTokenSymbolByAddress, getVaultOperator, getVaultOwner, getVaultVersion, isBotActive, isDestinationAllowed, isErc1271BotsEnabled, isRebalanceTokenWhitelisted, isVaultPaused, operatorMaxDrainPerDay, parseAmount, parseChainId, parsePaymentRequired, predictVaultAddress, randomNonce, randomPermit2Nonce, removeBot, resolveToken, resolveTokenDecimals, signExecuteIntent, signPayment, signPermit2WitnessTransfer, signSwapIntent, signTransferWithAuthorization, toBotConfigParams, updateBotConfig };
package/dist/index.js CHANGED
@@ -64,10 +64,12 @@ var EXPLORER_ADDR = {
64
64
  var DEFAULT_DEADLINE_SECONDS = 300;
65
65
  var WINDOW = {
66
66
  ONE_HOUR: 3600n,
67
+ THREE_HOURS: 10800n,
67
68
  ONE_DAY: 86400n,
68
69
  ONE_WEEK: 604800n,
69
70
  THIRTY_DAYS: 2592000n
70
71
  };
72
+ var ALLOWED_WINDOWS = new Set(Object.values(WINDOW));
71
73
  var PaymentErrorCode = {
72
74
  /** Payment destination is the vault itself */
73
75
  SELF_PAYMENT: "SELF_PAYMENT",
@@ -670,26 +672,6 @@ var AxonVaultAbi = [
670
672
  "name": "signature",
671
673
  "type": "bytes",
672
674
  "internalType": "bytes"
673
- },
674
- {
675
- "name": "fromToken",
676
- "type": "address",
677
- "internalType": "address"
678
- },
679
- {
680
- "name": "maxFromAmount",
681
- "type": "uint256",
682
- "internalType": "uint256"
683
- },
684
- {
685
- "name": "swapRouter",
686
- "type": "address",
687
- "internalType": "address"
688
- },
689
- {
690
- "name": "swapCalldata",
691
- "type": "bytes",
692
- "internalType": "bytes"
693
675
  }
694
676
  ],
695
677
  "outputs": [],
@@ -755,26 +737,6 @@ var AxonVaultAbi = [
755
737
  "name": "callData",
756
738
  "type": "bytes",
757
739
  "internalType": "bytes"
758
- },
759
- {
760
- "name": "fromToken",
761
- "type": "address",
762
- "internalType": "address"
763
- },
764
- {
765
- "name": "maxFromAmount",
766
- "type": "uint256",
767
- "internalType": "uint256"
768
- },
769
- {
770
- "name": "swapRouter",
771
- "type": "address",
772
- "internalType": "address"
773
- },
774
- {
775
- "name": "swapCalldata",
776
- "type": "bytes",
777
- "internalType": "bytes"
778
740
  }
779
741
  ],
780
742
  "outputs": [
@@ -2231,55 +2193,6 @@ var AxonVaultAbi = [
2231
2193
  ],
2232
2194
  "anonymous": false
2233
2195
  },
2234
- {
2235
- "type": "event",
2236
- "name": "SwapPaymentExecuted",
2237
- "inputs": [
2238
- {
2239
- "name": "bot",
2240
- "type": "address",
2241
- "indexed": true,
2242
- "internalType": "address"
2243
- },
2244
- {
2245
- "name": "to",
2246
- "type": "address",
2247
- "indexed": true,
2248
- "internalType": "address"
2249
- },
2250
- {
2251
- "name": "fromToken",
2252
- "type": "address",
2253
- "indexed": false,
2254
- "internalType": "address"
2255
- },
2256
- {
2257
- "name": "toToken",
2258
- "type": "address",
2259
- "indexed": false,
2260
- "internalType": "address"
2261
- },
2262
- {
2263
- "name": "fromAmount",
2264
- "type": "uint256",
2265
- "indexed": false,
2266
- "internalType": "uint256"
2267
- },
2268
- {
2269
- "name": "toAmount",
2270
- "type": "uint256",
2271
- "indexed": false,
2272
- "internalType": "uint256"
2273
- },
2274
- {
2275
- "name": "ref",
2276
- "type": "bytes32",
2277
- "indexed": false,
2278
- "internalType": "bytes32"
2279
- }
2280
- ],
2281
- "anonymous": false
2282
- },
2283
2196
  {
2284
2197
  "type": "event",
2285
2198
  "name": "Unpaused",
@@ -2422,22 +2335,22 @@ var AxonVaultAbi = [
2422
2335
  },
2423
2336
  {
2424
2337
  "type": "error",
2425
- "name": "InsufficientBalance",
2338
+ "name": "IntentAlreadyUsed",
2426
2339
  "inputs": []
2427
2340
  },
2428
2341
  {
2429
2342
  "type": "error",
2430
- "name": "IntentAlreadyUsed",
2343
+ "name": "InvalidInitialization",
2431
2344
  "inputs": []
2432
2345
  },
2433
2346
  {
2434
2347
  "type": "error",
2435
- "name": "InvalidInitialization",
2348
+ "name": "InvalidSignature",
2436
2349
  "inputs": []
2437
2350
  },
2438
2351
  {
2439
2352
  "type": "error",
2440
- "name": "InvalidSignature",
2353
+ "name": "InvalidSpendingWindow",
2441
2354
  "inputs": []
2442
2355
  },
2443
2356
  {
@@ -3248,6 +3161,12 @@ function createAxonWalletClient(privateKey, chainId) {
3248
3161
  var USDC_DECIMALS = 6n;
3249
3162
  var USDC_UNIT = 10n ** USDC_DECIMALS;
3250
3163
  function toBotConfigParams(input) {
3164
+ for (const sl of input.spendingLimits) {
3165
+ if (!ALLOWED_WINDOWS.has(BigInt(sl.windowSeconds))) {
3166
+ const allowed = [...ALLOWED_WINDOWS].map((w) => `${Number(w)}s`).join(", ");
3167
+ throw new Error(`Invalid spending window: ${sl.windowSeconds}s. Allowed values: ${allowed}. Use WINDOW constants.`);
3168
+ }
3169
+ }
3251
3170
  return {
3252
3171
  maxPerTxAmount: BigInt(Math.round(input.maxPerTxAmount * Number(USDC_UNIT))),
3253
3172
  maxRebalanceAmount: BigInt(Math.round(input.maxRebalanceAmount * Number(USDC_UNIT))),
@@ -4007,6 +3926,12 @@ var AxonClient = class {
4007
3926
  * The vault approves `token` to `protocol`, calls it with `callData`,
4008
3927
  * then revokes the approval. Tokens stay in the vault or go to the protocol
4009
3928
  * as specified by the calldata.
3929
+ *
3930
+ * **Approval rules for default tokens** (USDC, WETH, etc.): when calling
3931
+ * `approve()` on a default token, the spender must be an approved protocol
3932
+ * or swap router — the contract rejects arbitrary addresses. The approve
3933
+ * amount is capped by the bot's `maxPerTxAmount` and counts toward
3934
+ * spending limits.
4010
3935
  */
4011
3936
  async execute(input) {
4012
3937
  const intent = this._buildExecuteIntent(input);
@@ -5033,6 +4958,6 @@ var AxonRegistryAbi = [
5033
4958
  }
5034
4959
  ];
5035
4960
 
5036
- export { AxonClient, AxonRegistryAbi, AxonVaultAbi, AxonVaultFactoryAbi, CHAIN_NAMES, Chain, DEFAULT_APPROVED_TOKENS, DEFAULT_DEADLINE_SECONDS, EIP712_DOMAIN_NAME, EIP712_DOMAIN_VERSION, EXECUTE_INTENT_TYPEHASH, EXPLORER_ADDR, EXPLORER_TX, KNOWN_TOKENS, NATIVE_ETH, PAYMENT_INTENT_TYPEHASH, PERMIT2_ADDRESS, PaymentErrorCode, RELAYER_API, SUPPORTED_CHAIN_IDS, SWAP_INTENT_TYPEHASH, Token, USDC, USDC_EIP712_DOMAIN, WINDOW, WITNESS_TYPE_STRING, X402_PROXY_ADDRESS, addBot, createAxonPublicClient, createAxonWalletClient, decryptKeystore, deployVault, deposit, encodeRef, encryptKeystore, extractX402Metadata, findMatchingOption, formatPaymentSignature, getBotConfig, getChain, getDefaultApprovedTokens, getDomainSeparator, getKnownTokensForChain, getOperatorCeilings, getRebalanceTokenCount, getTokenSymbolByAddress, getVaultOperator, getVaultOwner, getVaultVersion, isBotActive, isDestinationAllowed, isErc1271BotsEnabled, isRebalanceTokenWhitelisted, isVaultPaused, operatorMaxDrainPerDay, parseAmount, parseChainId, parsePaymentRequired, predictVaultAddress, randomNonce, randomPermit2Nonce, removeBot, resolveToken, resolveTokenDecimals, signExecuteIntent, signPayment, signPermit2WitnessTransfer, signSwapIntent, signTransferWithAuthorization, toBotConfigParams, updateBotConfig };
4961
+ export { ALLOWED_WINDOWS, AxonClient, AxonRegistryAbi, AxonVaultAbi, AxonVaultFactoryAbi, CHAIN_NAMES, Chain, DEFAULT_APPROVED_TOKENS, DEFAULT_DEADLINE_SECONDS, EIP712_DOMAIN_NAME, EIP712_DOMAIN_VERSION, EXECUTE_INTENT_TYPEHASH, EXPLORER_ADDR, EXPLORER_TX, KNOWN_TOKENS, NATIVE_ETH, PAYMENT_INTENT_TYPEHASH, PERMIT2_ADDRESS, PaymentErrorCode, RELAYER_API, SUPPORTED_CHAIN_IDS, SWAP_INTENT_TYPEHASH, Token, USDC, USDC_EIP712_DOMAIN, WINDOW, WITNESS_TYPE_STRING, X402_PROXY_ADDRESS, addBot, createAxonPublicClient, createAxonWalletClient, decryptKeystore, deployVault, deposit, encodeRef, encryptKeystore, extractX402Metadata, findMatchingOption, formatPaymentSignature, getBotConfig, getChain, getDefaultApprovedTokens, getDomainSeparator, getKnownTokensForChain, getOperatorCeilings, getRebalanceTokenCount, getTokenSymbolByAddress, getVaultOperator, getVaultOwner, getVaultVersion, isBotActive, isDestinationAllowed, isErc1271BotsEnabled, isRebalanceTokenWhitelisted, isVaultPaused, operatorMaxDrainPerDay, parseAmount, parseChainId, parsePaymentRequired, predictVaultAddress, randomNonce, randomPermit2Nonce, removeBot, resolveToken, resolveTokenDecimals, signExecuteIntent, signPayment, signPermit2WitnessTransfer, signSwapIntent, signTransferWithAuthorization, toBotConfigParams, updateBotConfig };
5037
4962
  //# sourceMappingURL=index.js.map
5038
4963
  //# sourceMappingURL=index.js.map