@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 +19 -114
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -96
- package/dist/index.d.ts +21 -96
- package/dist/index.js +19 -114
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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
|
-
/**
|
|
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
|
|
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
|
|
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
|
/**
|
|
@@ -1003,12 +1016,6 @@ declare function getBotConfig(publicClient: PublicClient, vaultAddress: Address,
|
|
|
1003
1016
|
declare function isBotActive(publicClient: PublicClient, vaultAddress: Address, botAddress: Address): Promise<boolean>;
|
|
1004
1017
|
/** Returns the operator ceilings set by the vault owner. */
|
|
1005
1018
|
declare function getOperatorCeilings(publicClient: PublicClient, vaultAddress: Address): Promise<OperatorCeilings>;
|
|
1006
|
-
/**
|
|
1007
|
-
* Returns the maximum USDC an operator-compromised wallet could drain per day.
|
|
1008
|
-
* Computed on-chain as: min(maxOperatorBots × maxBotDailyLimit, vaultDailyAggregate).
|
|
1009
|
-
* Returns 0n if operator has no bot-add permission.
|
|
1010
|
-
*/
|
|
1011
|
-
declare function operatorMaxDrainPerDay(publicClient: PublicClient, vaultAddress: Address): Promise<bigint>;
|
|
1012
1019
|
/**
|
|
1013
1020
|
* Returns whether ERC-1271 bot signatures are enabled on the vault.
|
|
1014
1021
|
*
|
|
@@ -1649,22 +1656,6 @@ declare const AxonVaultAbi: readonly [{
|
|
|
1649
1656
|
readonly name: "signature";
|
|
1650
1657
|
readonly type: "bytes";
|
|
1651
1658
|
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
1659
|
}];
|
|
1669
1660
|
readonly outputs: readonly [];
|
|
1670
1661
|
readonly stateMutability: "nonpayable";
|
|
@@ -1716,22 +1707,6 @@ declare const AxonVaultAbi: readonly [{
|
|
|
1716
1707
|
readonly name: "callData";
|
|
1717
1708
|
readonly type: "bytes";
|
|
1718
1709
|
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
1710
|
}];
|
|
1736
1711
|
readonly outputs: readonly [{
|
|
1737
1712
|
readonly name: "";
|
|
@@ -2086,16 +2061,6 @@ declare const AxonVaultAbi: readonly [{
|
|
|
2086
2061
|
readonly internalType: "uint256";
|
|
2087
2062
|
}];
|
|
2088
2063
|
readonly stateMutability: "view";
|
|
2089
|
-
}, {
|
|
2090
|
-
readonly type: "function";
|
|
2091
|
-
readonly name: "operatorMaxDrainPerDay";
|
|
2092
|
-
readonly inputs: readonly [];
|
|
2093
|
-
readonly outputs: readonly [{
|
|
2094
|
-
readonly name: "";
|
|
2095
|
-
readonly type: "uint256";
|
|
2096
|
-
readonly internalType: "uint256";
|
|
2097
|
-
}];
|
|
2098
|
-
readonly stateMutability: "view";
|
|
2099
2064
|
}, {
|
|
2100
2065
|
readonly type: "function";
|
|
2101
2066
|
readonly name: "owner";
|
|
@@ -2863,46 +2828,6 @@ declare const AxonVaultAbi: readonly [{
|
|
|
2863
2828
|
readonly internalType: "bytes32";
|
|
2864
2829
|
}];
|
|
2865
2830
|
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
2831
|
}, {
|
|
2907
2832
|
readonly type: "event";
|
|
2908
2833
|
readonly name: "Unpaused";
|
|
@@ -3013,10 +2938,6 @@ declare const AxonVaultAbi: readonly [{
|
|
|
3013
2938
|
readonly type: "error";
|
|
3014
2939
|
readonly name: "ExpectedPause";
|
|
3015
2940
|
readonly inputs: readonly [];
|
|
3016
|
-
}, {
|
|
3017
|
-
readonly type: "error";
|
|
3018
|
-
readonly name: "InsufficientBalance";
|
|
3019
|
-
readonly inputs: readonly [];
|
|
3020
2941
|
}, {
|
|
3021
2942
|
readonly type: "error";
|
|
3022
2943
|
readonly name: "IntentAlreadyUsed";
|
|
@@ -3029,6 +2950,10 @@ declare const AxonVaultAbi: readonly [{
|
|
|
3029
2950
|
readonly type: "error";
|
|
3030
2951
|
readonly name: "InvalidSignature";
|
|
3031
2952
|
readonly inputs: readonly [];
|
|
2953
|
+
}, {
|
|
2954
|
+
readonly type: "error";
|
|
2955
|
+
readonly name: "InvalidSpendingWindow";
|
|
2956
|
+
readonly inputs: readonly [];
|
|
3032
2957
|
}, {
|
|
3033
2958
|
readonly type: "error";
|
|
3034
2959
|
readonly name: "MaxPerTxExceeded";
|
|
@@ -3822,4 +3747,4 @@ declare const AxonRegistryAbi: readonly [{
|
|
|
3822
3747
|
readonly inputs: readonly [];
|
|
3823
3748
|
}];
|
|
3824
3749
|
|
|
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,
|
|
3750
|
+
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, 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
|
-
/**
|
|
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
|
|
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
|
|
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
|
/**
|
|
@@ -1003,12 +1016,6 @@ declare function getBotConfig(publicClient: PublicClient, vaultAddress: Address,
|
|
|
1003
1016
|
declare function isBotActive(publicClient: PublicClient, vaultAddress: Address, botAddress: Address): Promise<boolean>;
|
|
1004
1017
|
/** Returns the operator ceilings set by the vault owner. */
|
|
1005
1018
|
declare function getOperatorCeilings(publicClient: PublicClient, vaultAddress: Address): Promise<OperatorCeilings>;
|
|
1006
|
-
/**
|
|
1007
|
-
* Returns the maximum USDC an operator-compromised wallet could drain per day.
|
|
1008
|
-
* Computed on-chain as: min(maxOperatorBots × maxBotDailyLimit, vaultDailyAggregate).
|
|
1009
|
-
* Returns 0n if operator has no bot-add permission.
|
|
1010
|
-
*/
|
|
1011
|
-
declare function operatorMaxDrainPerDay(publicClient: PublicClient, vaultAddress: Address): Promise<bigint>;
|
|
1012
1019
|
/**
|
|
1013
1020
|
* Returns whether ERC-1271 bot signatures are enabled on the vault.
|
|
1014
1021
|
*
|
|
@@ -1649,22 +1656,6 @@ declare const AxonVaultAbi: readonly [{
|
|
|
1649
1656
|
readonly name: "signature";
|
|
1650
1657
|
readonly type: "bytes";
|
|
1651
1658
|
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
1659
|
}];
|
|
1669
1660
|
readonly outputs: readonly [];
|
|
1670
1661
|
readonly stateMutability: "nonpayable";
|
|
@@ -1716,22 +1707,6 @@ declare const AxonVaultAbi: readonly [{
|
|
|
1716
1707
|
readonly name: "callData";
|
|
1717
1708
|
readonly type: "bytes";
|
|
1718
1709
|
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
1710
|
}];
|
|
1736
1711
|
readonly outputs: readonly [{
|
|
1737
1712
|
readonly name: "";
|
|
@@ -2086,16 +2061,6 @@ declare const AxonVaultAbi: readonly [{
|
|
|
2086
2061
|
readonly internalType: "uint256";
|
|
2087
2062
|
}];
|
|
2088
2063
|
readonly stateMutability: "view";
|
|
2089
|
-
}, {
|
|
2090
|
-
readonly type: "function";
|
|
2091
|
-
readonly name: "operatorMaxDrainPerDay";
|
|
2092
|
-
readonly inputs: readonly [];
|
|
2093
|
-
readonly outputs: readonly [{
|
|
2094
|
-
readonly name: "";
|
|
2095
|
-
readonly type: "uint256";
|
|
2096
|
-
readonly internalType: "uint256";
|
|
2097
|
-
}];
|
|
2098
|
-
readonly stateMutability: "view";
|
|
2099
2064
|
}, {
|
|
2100
2065
|
readonly type: "function";
|
|
2101
2066
|
readonly name: "owner";
|
|
@@ -2863,46 +2828,6 @@ declare const AxonVaultAbi: readonly [{
|
|
|
2863
2828
|
readonly internalType: "bytes32";
|
|
2864
2829
|
}];
|
|
2865
2830
|
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
2831
|
}, {
|
|
2907
2832
|
readonly type: "event";
|
|
2908
2833
|
readonly name: "Unpaused";
|
|
@@ -3013,10 +2938,6 @@ declare const AxonVaultAbi: readonly [{
|
|
|
3013
2938
|
readonly type: "error";
|
|
3014
2939
|
readonly name: "ExpectedPause";
|
|
3015
2940
|
readonly inputs: readonly [];
|
|
3016
|
-
}, {
|
|
3017
|
-
readonly type: "error";
|
|
3018
|
-
readonly name: "InsufficientBalance";
|
|
3019
|
-
readonly inputs: readonly [];
|
|
3020
2941
|
}, {
|
|
3021
2942
|
readonly type: "error";
|
|
3022
2943
|
readonly name: "IntentAlreadyUsed";
|
|
@@ -3029,6 +2950,10 @@ declare const AxonVaultAbi: readonly [{
|
|
|
3029
2950
|
readonly type: "error";
|
|
3030
2951
|
readonly name: "InvalidSignature";
|
|
3031
2952
|
readonly inputs: readonly [];
|
|
2953
|
+
}, {
|
|
2954
|
+
readonly type: "error";
|
|
2955
|
+
readonly name: "InvalidSpendingWindow";
|
|
2956
|
+
readonly inputs: readonly [];
|
|
3032
2957
|
}, {
|
|
3033
2958
|
readonly type: "error";
|
|
3034
2959
|
readonly name: "MaxPerTxExceeded";
|
|
@@ -3822,4 +3747,4 @@ declare const AxonRegistryAbi: readonly [{
|
|
|
3822
3747
|
readonly inputs: readonly [];
|
|
3823
3748
|
}];
|
|
3824
3749
|
|
|
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,
|
|
3750
|
+
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, 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": [
|
|
@@ -1239,19 +1201,6 @@ var AxonVaultAbi = [
|
|
|
1239
1201
|
],
|
|
1240
1202
|
"stateMutability": "view"
|
|
1241
1203
|
},
|
|
1242
|
-
{
|
|
1243
|
-
"type": "function",
|
|
1244
|
-
"name": "operatorMaxDrainPerDay",
|
|
1245
|
-
"inputs": [],
|
|
1246
|
-
"outputs": [
|
|
1247
|
-
{
|
|
1248
|
-
"name": "",
|
|
1249
|
-
"type": "uint256",
|
|
1250
|
-
"internalType": "uint256"
|
|
1251
|
-
}
|
|
1252
|
-
],
|
|
1253
|
-
"stateMutability": "view"
|
|
1254
|
-
},
|
|
1255
1204
|
{
|
|
1256
1205
|
"type": "function",
|
|
1257
1206
|
"name": "owner",
|
|
@@ -2231,55 +2180,6 @@ var AxonVaultAbi = [
|
|
|
2231
2180
|
],
|
|
2232
2181
|
"anonymous": false
|
|
2233
2182
|
},
|
|
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
2183
|
{
|
|
2284
2184
|
"type": "event",
|
|
2285
2185
|
"name": "Unpaused",
|
|
@@ -2422,22 +2322,22 @@ var AxonVaultAbi = [
|
|
|
2422
2322
|
},
|
|
2423
2323
|
{
|
|
2424
2324
|
"type": "error",
|
|
2425
|
-
"name": "
|
|
2325
|
+
"name": "IntentAlreadyUsed",
|
|
2426
2326
|
"inputs": []
|
|
2427
2327
|
},
|
|
2428
2328
|
{
|
|
2429
2329
|
"type": "error",
|
|
2430
|
-
"name": "
|
|
2330
|
+
"name": "InvalidInitialization",
|
|
2431
2331
|
"inputs": []
|
|
2432
2332
|
},
|
|
2433
2333
|
{
|
|
2434
2334
|
"type": "error",
|
|
2435
|
-
"name": "
|
|
2335
|
+
"name": "InvalidSignature",
|
|
2436
2336
|
"inputs": []
|
|
2437
2337
|
},
|
|
2438
2338
|
{
|
|
2439
2339
|
"type": "error",
|
|
2440
|
-
"name": "
|
|
2340
|
+
"name": "InvalidSpendingWindow",
|
|
2441
2341
|
"inputs": []
|
|
2442
2342
|
},
|
|
2443
2343
|
{
|
|
@@ -3248,6 +3148,12 @@ function createAxonWalletClient(privateKey, chainId) {
|
|
|
3248
3148
|
var USDC_DECIMALS = 6n;
|
|
3249
3149
|
var USDC_UNIT = 10n ** USDC_DECIMALS;
|
|
3250
3150
|
function toBotConfigParams(input) {
|
|
3151
|
+
for (const sl of input.spendingLimits) {
|
|
3152
|
+
if (!ALLOWED_WINDOWS.has(BigInt(sl.windowSeconds))) {
|
|
3153
|
+
const allowed = [...ALLOWED_WINDOWS].map((w) => `${Number(w)}s`).join(", ");
|
|
3154
|
+
throw new Error(`Invalid spending window: ${sl.windowSeconds}s. Allowed values: ${allowed}. Use WINDOW constants.`);
|
|
3155
|
+
}
|
|
3156
|
+
}
|
|
3251
3157
|
return {
|
|
3252
3158
|
maxPerTxAmount: BigInt(Math.round(input.maxPerTxAmount * Number(USDC_UNIT))),
|
|
3253
3159
|
maxRebalanceAmount: BigInt(Math.round(input.maxRebalanceAmount * Number(USDC_UNIT))),
|
|
@@ -3316,13 +3222,6 @@ async function getOperatorCeilings(publicClient, vaultAddress) {
|
|
|
3316
3222
|
minAiTriggerFloor
|
|
3317
3223
|
};
|
|
3318
3224
|
}
|
|
3319
|
-
async function operatorMaxDrainPerDay(publicClient, vaultAddress) {
|
|
3320
|
-
return publicClient.readContract({
|
|
3321
|
-
address: vaultAddress,
|
|
3322
|
-
abi: AxonVaultAbi,
|
|
3323
|
-
functionName: "operatorMaxDrainPerDay"
|
|
3324
|
-
});
|
|
3325
|
-
}
|
|
3326
3225
|
async function isErc1271BotsEnabled(publicClient, vaultAddress) {
|
|
3327
3226
|
return publicClient.readContract({
|
|
3328
3227
|
address: vaultAddress,
|
|
@@ -4007,6 +3906,12 @@ var AxonClient = class {
|
|
|
4007
3906
|
* The vault approves `token` to `protocol`, calls it with `callData`,
|
|
4008
3907
|
* then revokes the approval. Tokens stay in the vault or go to the protocol
|
|
4009
3908
|
* as specified by the calldata.
|
|
3909
|
+
*
|
|
3910
|
+
* **Approval rules for default tokens** (USDC, WETH, etc.): when calling
|
|
3911
|
+
* `approve()` on a default token, the spender must be an approved protocol
|
|
3912
|
+
* or swap router — the contract rejects arbitrary addresses. The approve
|
|
3913
|
+
* amount is capped by the bot's `maxPerTxAmount` and counts toward
|
|
3914
|
+
* spending limits.
|
|
4010
3915
|
*/
|
|
4011
3916
|
async execute(input) {
|
|
4012
3917
|
const intent = this._buildExecuteIntent(input);
|
|
@@ -5033,6 +4938,6 @@ var AxonRegistryAbi = [
|
|
|
5033
4938
|
}
|
|
5034
4939
|
];
|
|
5035
4940
|
|
|
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,
|
|
4941
|
+
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, parseAmount, parseChainId, parsePaymentRequired, predictVaultAddress, randomNonce, randomPermit2Nonce, removeBot, resolveToken, resolveTokenDecimals, signExecuteIntent, signPayment, signPermit2WitnessTransfer, signSwapIntent, signTransferWithAuthorization, toBotConfigParams, updateBotConfig };
|
|
5037
4942
|
//# sourceMappingURL=index.js.map
|
|
5038
4943
|
//# sourceMappingURL=index.js.map
|