/** * Stellar Vault Getters * * Data fetching for Stellar vaults. Enriches backend metadata with on-chain * total assets, total supply, and share decimals from Soroban RPC. Also * provides user position queries and deposit preview (convertToShares). * Falls back to backend TVL for total assets, zero for total supply, and * STELLAR_FALLBACK_DECIMALS for share decimals when on-chain queries fail. */ import type { ITokenizedVault, IVault } from '../../types'; import type { IVaultBaseOptions } from '../../modules/vaults/types'; import type { IStellarNetwork, IStellarUserPosition } from './types'; /** * Build a unified IVault from backend + on-chain data for Stellar vaults. * Reads total assets and total supply from the Soroban contract via RPC. * Falls back to backend `latest_reported_tvl` for total assets, or zero * for total supply, when on-chain queries fail. */ export declare const getStellarVault: (tokenizedVault: ITokenizedVault, options: IVaultBaseOptions) => Promise; /** * Get user position for a Stellar vault. * Queries the vault contract's balance(address) and decimals() functions via Soroban RPC. * * Returns `{ shares, decimals, decimalsFromFallback }` on success (shares may be * '0' for zero balance), or null when the balance query fails. The two reads are * independent: a `decimals()` failure does NOT null the result — instead * `decimals` falls back to STELLAR_FALLBACK_DECIMALS (7) and * `decimalsFromFallback` is set to `true` so callers can tell a fabricated 7 * apart from a genuine 7-decimal vault. * * Why this matters: an ERC4626 offset vault has share decimals = asset + offset * (e.g. 13). A consumer that sizes a redeem trusting a silent fallback 7 would * under-redeem by `10^offset`. Callers that settle a redeem from this position * MUST refuse (surface an error) when `decimalsFromFallback` is `true` rather * than trusting `decimals`. * * @param vaultAddress - Stellar vault contract ID (C… address) * @param walletAddress - User's Stellar account (G… address); validated upfront * @param network - 'mainnet' | 'testnet' (defaults to 'mainnet') * @param sorobanRpcUrl - Optional override Soroban RPC endpoint (e.g. a keyed * Alchemy URL); becomes the primary with the SDK's public endpoints kept as * failover. Omit to use the public endpoints. * @returns The position, or `null` if the balance read failed or was unparseable. * @throws AugustValidationError on an invalid `walletAddress`. * @example * ```ts * const pos = await getStellarUserPosition(vault, wallet, 'mainnet'); * if (!pos || pos.decimalsFromFallback) { * // Refuse to size a redeem — share scale is not authoritatively known. * throw new Error('Stellar share decimals unresolved'); * } * const human = Number(pos.shares) / 10 ** pos.decimals; * ``` */ export declare const getStellarUserPosition: (vaultAddress: string, walletAddress: string, network?: IStellarNetwork, sorobanRpcUrl?: string) => Promise; /** * Query the vault's `convert_to_shares` to preview how many shares a deposit * amount would yield. Returns the raw share amount as a string, or null on * failure. * * @param vaultAddress Stellar contract ID (C… address) * @param rawAmount Deposit amount in the deposit token's smallest unit * @param network 'mainnet' | 'testnet' * @param sorobanRpcUrl - Optional override Soroban RPC endpoint (e.g. a keyed * Alchemy URL); becomes the primary with the SDK's public endpoints kept as * failover. Omit to use the public endpoints. */ export declare const convertToShares: (vaultAddress: string, rawAmount: string, network?: IStellarNetwork, sorobanRpcUrl?: string) => Promise;