@axonfi/sdk 0.15.0 → 0.16.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
@@ -329,6 +329,7 @@ declare const RELAYER_API: {
329
329
  readonly protocolCheck: (vault: string, protocol: string, chainId: number) => string;
330
330
  readonly rebalanceTokens: (vault: string, chainId: number) => string;
331
331
  readonly rebalanceTokenCheck: (vault: string, token: string, chainId: number) => string;
332
+ readonly vaultValue: (vault: string, chainId: number) => string;
332
333
  readonly tosStatus: (wallet: string) => string;
333
334
  readonly TOS_ACCEPT: "/v1/tos/accept";
334
335
  };
@@ -667,6 +668,32 @@ interface RebalanceTokensResult {
667
668
  /** Number of tokens set on-chain. 0 = using relayer defaults. */
668
669
  rebalanceTokenCount: number;
669
670
  }
671
+ /** A single token holding with USD valuation, returned by getVaultValue(). */
672
+ interface VaultValueToken {
673
+ /** Token contract address. */
674
+ token: Address;
675
+ /** Human-readable token symbol (e.g. "USDC"). */
676
+ symbol: string;
677
+ /** Raw balance in base units (string to preserve precision). */
678
+ balance: string;
679
+ /** Token decimals. */
680
+ decimals: number;
681
+ /** Price per token in USD. */
682
+ priceUsd: number;
683
+ /** Total USD value of this holding. */
684
+ valueUsd: number;
685
+ }
686
+ /** Result of AxonClient.getVaultValue() — total vault value with per-token breakdown. */
687
+ interface VaultValueResult {
688
+ /** Vault contract address. */
689
+ vault: Address;
690
+ /** Chain ID. */
691
+ chainId: number;
692
+ /** Total vault value in USD across all token holdings. */
693
+ totalValueUsd: number;
694
+ /** Per-token breakdown. */
695
+ tokens: VaultValueToken[];
696
+ }
670
697
  /** TOS acceptance status for a wallet. */
671
698
  interface TosStatus {
672
699
  accepted: boolean;
@@ -862,6 +889,13 @@ declare class AxonClient {
862
889
  isPaused(): Promise<boolean>;
863
890
  /** Returns high-level vault info (owner, operator, paused, version) via relayer. */
864
891
  getVaultInfo(): Promise<VaultInfo>;
892
+ /**
893
+ * Returns the total USD value of the vault with a per-token breakdown (via relayer).
894
+ *
895
+ * Includes all ERC-20 holdings with non-zero balances, their USD prices,
896
+ * and the aggregate vault value.
897
+ */
898
+ getVaultValue(): Promise<VaultValueResult>;
865
899
  /**
866
900
  * Check whether this bot can pay to a given destination address (via relayer).
867
901
  * Checks blacklist → global whitelist → bot whitelist, matching on-chain logic.
@@ -3932,4 +3966,4 @@ declare const AxonRegistryAbi: readonly [{
3932
3966
  readonly inputs: readonly [];
3933
3967
  }];
3934
3968
 
3935
- 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, type SwapSlippagePreview, 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, getMaxSwapSlippageBps, getOperatorCeilings, getRebalanceTokenCount, getTokenSymbolByAddress, getVaultOperator, getVaultOwner, getVaultVersion, isBotActive, isDestinationAllowed, isErc1271BotsEnabled, isRebalanceTokenWhitelisted, isVaultPaused, operatorMaxDrainPerDay, parseAmount, parseChainId, parsePaymentRequired, predictVaultAddress, previewSwapSlippage, randomNonce, randomPermit2Nonce, removeBot, resolveToken, resolveTokenDecimals, signExecuteIntent, signPayment, signPermit2WitnessTransfer, signSwapIntent, signTransferWithAuthorization, toBotConfigParams, updateBotConfig };
3969
+ 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, type SwapSlippagePreview, Token, type TokenInput, type TosStatus, type TransferAuthorization, USDC, USDC_EIP712_DOMAIN, type VaultInfo, type VaultValueResult, type VaultValueToken, 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, getMaxSwapSlippageBps, getOperatorCeilings, getRebalanceTokenCount, getTokenSymbolByAddress, getVaultOperator, getVaultOwner, getVaultVersion, isBotActive, isDestinationAllowed, isErc1271BotsEnabled, isRebalanceTokenWhitelisted, isVaultPaused, operatorMaxDrainPerDay, parseAmount, parseChainId, parsePaymentRequired, predictVaultAddress, previewSwapSlippage, randomNonce, randomPermit2Nonce, removeBot, resolveToken, resolveTokenDecimals, signExecuteIntent, signPayment, signPermit2WitnessTransfer, signSwapIntent, signTransferWithAuthorization, toBotConfigParams, updateBotConfig };
package/dist/index.d.ts CHANGED
@@ -329,6 +329,7 @@ declare const RELAYER_API: {
329
329
  readonly protocolCheck: (vault: string, protocol: string, chainId: number) => string;
330
330
  readonly rebalanceTokens: (vault: string, chainId: number) => string;
331
331
  readonly rebalanceTokenCheck: (vault: string, token: string, chainId: number) => string;
332
+ readonly vaultValue: (vault: string, chainId: number) => string;
332
333
  readonly tosStatus: (wallet: string) => string;
333
334
  readonly TOS_ACCEPT: "/v1/tos/accept";
334
335
  };
@@ -667,6 +668,32 @@ interface RebalanceTokensResult {
667
668
  /** Number of tokens set on-chain. 0 = using relayer defaults. */
668
669
  rebalanceTokenCount: number;
669
670
  }
671
+ /** A single token holding with USD valuation, returned by getVaultValue(). */
672
+ interface VaultValueToken {
673
+ /** Token contract address. */
674
+ token: Address;
675
+ /** Human-readable token symbol (e.g. "USDC"). */
676
+ symbol: string;
677
+ /** Raw balance in base units (string to preserve precision). */
678
+ balance: string;
679
+ /** Token decimals. */
680
+ decimals: number;
681
+ /** Price per token in USD. */
682
+ priceUsd: number;
683
+ /** Total USD value of this holding. */
684
+ valueUsd: number;
685
+ }
686
+ /** Result of AxonClient.getVaultValue() — total vault value with per-token breakdown. */
687
+ interface VaultValueResult {
688
+ /** Vault contract address. */
689
+ vault: Address;
690
+ /** Chain ID. */
691
+ chainId: number;
692
+ /** Total vault value in USD across all token holdings. */
693
+ totalValueUsd: number;
694
+ /** Per-token breakdown. */
695
+ tokens: VaultValueToken[];
696
+ }
670
697
  /** TOS acceptance status for a wallet. */
671
698
  interface TosStatus {
672
699
  accepted: boolean;
@@ -862,6 +889,13 @@ declare class AxonClient {
862
889
  isPaused(): Promise<boolean>;
863
890
  /** Returns high-level vault info (owner, operator, paused, version) via relayer. */
864
891
  getVaultInfo(): Promise<VaultInfo>;
892
+ /**
893
+ * Returns the total USD value of the vault with a per-token breakdown (via relayer).
894
+ *
895
+ * Includes all ERC-20 holdings with non-zero balances, their USD prices,
896
+ * and the aggregate vault value.
897
+ */
898
+ getVaultValue(): Promise<VaultValueResult>;
865
899
  /**
866
900
  * Check whether this bot can pay to a given destination address (via relayer).
867
901
  * Checks blacklist → global whitelist → bot whitelist, matching on-chain logic.
@@ -3932,4 +3966,4 @@ declare const AxonRegistryAbi: readonly [{
3932
3966
  readonly inputs: readonly [];
3933
3967
  }];
3934
3968
 
3935
- 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, type SwapSlippagePreview, 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, getMaxSwapSlippageBps, getOperatorCeilings, getRebalanceTokenCount, getTokenSymbolByAddress, getVaultOperator, getVaultOwner, getVaultVersion, isBotActive, isDestinationAllowed, isErc1271BotsEnabled, isRebalanceTokenWhitelisted, isVaultPaused, operatorMaxDrainPerDay, parseAmount, parseChainId, parsePaymentRequired, predictVaultAddress, previewSwapSlippage, randomNonce, randomPermit2Nonce, removeBot, resolveToken, resolveTokenDecimals, signExecuteIntent, signPayment, signPermit2WitnessTransfer, signSwapIntent, signTransferWithAuthorization, toBotConfigParams, updateBotConfig };
3969
+ 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, type SwapSlippagePreview, Token, type TokenInput, type TosStatus, type TransferAuthorization, USDC, USDC_EIP712_DOMAIN, type VaultInfo, type VaultValueResult, type VaultValueToken, 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, getMaxSwapSlippageBps, getOperatorCeilings, getRebalanceTokenCount, getTokenSymbolByAddress, getVaultOperator, getVaultOwner, getVaultVersion, isBotActive, isDestinationAllowed, isErc1271BotsEnabled, isRebalanceTokenWhitelisted, isVaultPaused, operatorMaxDrainPerDay, parseAmount, parseChainId, parsePaymentRequired, predictVaultAddress, previewSwapSlippage, randomNonce, randomPermit2Nonce, removeBot, resolveToken, resolveTokenDecimals, signExecuteIntent, signPayment, signPermit2WitnessTransfer, signSwapIntent, signTransferWithAuthorization, toBotConfigParams, updateBotConfig };
package/dist/index.js CHANGED
@@ -132,6 +132,8 @@ var RELAYER_API = {
132
132
  protocolCheck: (vault, protocol, chainId) => `/v1/vault/${vault}/protocol/${protocol}?chainId=${chainId}`,
133
133
  rebalanceTokens: (vault, chainId) => `/v1/vault/${vault}/rebalance-tokens?chainId=${chainId}`,
134
134
  rebalanceTokenCheck: (vault, token, chainId) => `/v1/vault/${vault}/rebalance-token/${token}?chainId=${chainId}`,
135
+ // Vault value endpoint
136
+ vaultValue: (vault, chainId) => `/v1/vault/${vault}/value?chainId=${chainId}`,
135
137
  // TOS endpoints
136
138
  tosStatus: (wallet) => `/v1/tos/status?wallet=${wallet}`,
137
139
  TOS_ACCEPT: "/v1/tos/accept"
@@ -3531,13 +3533,11 @@ async function deployVault(walletClient, publicClient, relayerUrl) {
3531
3533
  chain: walletClient.chain ?? null
3532
3534
  });
3533
3535
  const receipt = await publicClient.waitForTransactionReceipt({ hash });
3536
+ const vaultDeployedSig = "0x42315f4340c2734f2a8ef1b71fd45068eafc3ed5730a08a98e8d7ef57105626a";
3534
3537
  for (const log of receipt.logs) {
3535
- try {
3536
- if (log.topics.length >= 3 && log.topics[2]) {
3537
- const vaultAddress = `0x${log.topics[2].slice(26)}`;
3538
- return vaultAddress;
3539
- }
3540
- } catch {
3538
+ if (log.topics.length >= 3 && log.topics[0] === vaultDeployedSig && log.topics[2]) {
3539
+ const vaultAddress = `0x${log.topics[2].slice(26)}`;
3540
+ return vaultAddress;
3541
3541
  }
3542
3542
  }
3543
3543
  throw new Error("VaultDeployed event not found in transaction receipt");
@@ -4189,6 +4189,19 @@ var AxonClient = class {
4189
4189
  return this._get(path);
4190
4190
  }
4191
4191
  // ============================================================================
4192
+ // getVaultValue() — via relayer
4193
+ // ============================================================================
4194
+ /**
4195
+ * Returns the total USD value of the vault with a per-token breakdown (via relayer).
4196
+ *
4197
+ * Includes all ERC-20 holdings with non-zero balances, their USD prices,
4198
+ * and the aggregate vault value.
4199
+ */
4200
+ async getVaultValue() {
4201
+ const path = RELAYER_API.vaultValue(this.vaultAddress, this.chainId);
4202
+ return this._get(path);
4203
+ }
4204
+ // ============================================================================
4192
4205
  // canPayTo() — via relayer
4193
4206
  // ============================================================================
4194
4207
  /**