import { type Signer, type Wallet } from 'ethers'; import type { IAddress, IContractRunner, IGetOriginInfoOptions, IOriginInfo, ISwapRouterDepositResult, ISwapRouterDepositResultOptions } from '../../types'; /** * Resolve the `SwapRouter` address for a chain. * * @param chainId - EVM chain ID. * @returns The router address, or `undefined` if no SwapRouter is deployed. * @example * ```ts * const router = getSwapRouterAddress(1); * // '0xAC771209FF2b71EECfF6E85a9AD01db8Ff2618B0' * ``` */ export declare function getSwapRouterAddress(chainId: number): IAddress | undefined; /** * Resolve the human-readable display name of the `SwapRouter` periphery * contract for a chain. * * The contract exposes no name on-chain, so this reads the SDK-maintained * {@link SWAP_ROUTER_NAMES} registry. Intended for UI surfaces that label the * contract a swap-and-deposit routes through (e.g. a "Router" row in a * transaction overview) — display metadata only, never routing logic. * * @param chainId - EVM chain ID. * @returns The display name (e.g. `'Upshift Swap Router'`), or `undefined` * when no SwapRouter is deployed on the chain — callers should omit the * label rather than show an address. * @example * ```ts * const name = getSwapRouterName(1); * // 'Upshift Swap Router' * ``` */ export declare function getSwapRouterName(chainId: number): string | undefined; /** * Whether a vault is eligible for the any-token `SwapRouter` deposit surface * (the SwapRouter is `enableVault`-ed for it on-chain). Address comparison is * case-insensitive. * * This gates the (flag-controlled) swap-router deposit UI and can fail-fast a * {@link swapRouterDeposit} call. It does **not** affect {@link vaultDeposit}, * which never swaps (see `getDepositRoute` for when it uses the router). * * @param vaultAddress - August vault address. * @returns `true` when the vault is in {@link SWAP_ROUTER_ELIGIBLE_VAULTS}. * @deprecated Superseded by {@link getSwapRouterEligibleVaults}, which resolves * eligibility from the router's on-chain `VaultEnabled` history + current * `vaultInfo` registration instead of this static snapshot. Kept functional as * the zero-RPC sync fallback (seed data, fail-fast checks); migrate UI gates * to the async resolver. */ export declare function isSwapRouterEligible(vaultAddress: IAddress): boolean; /** * @deprecated Renamed to {@link isSwapRouterEligible} (itself now superseded by * {@link getSwapRouterEligibleVaults}, the on-chain-derived resolver). The * meaning also changed: it no longer implies `vaultDeposit` routes the vault * through the SwapRouter (that behavior was removed) — it only reports * swap-router *eligibility* for the opt-in deposit surface. Kept as an alias * for one release; migrate to the async resolver. */ export declare const vaultUsesSwapRouter: typeof isSwapRouterEligible; /** * Normalize an optional origin code to the value to send on-chain. * * Returns the caller-supplied code when present (an explicit all-zero * sentinel opts one call out), otherwise the SDK instance's * `attribution.originCode` when `chainId` is in * {@link ORIGIN_ATTRIBUTION_CHAINS} (Ethereum mainnet only), otherwise the * default (all-zero) sentinel from {@link ORIGIN_CODES}. Validates that any * supplied code is exactly 32 bytes (66 chars including the `0x` prefix); * the on-chain SwapRouter reverts with `InvalidOrigin` otherwise, but * surfacing the failure here as a typed SDK error gives partners a * grepable Sentry event instead of a generic `execution reverted`. * * @param provided - Optional caller-supplied origin code. * @param chainId - Chain the deposit is sent on. The instance code is never * returned without it, or on a chain outside * {@link ORIGIN_ATTRIBUTION_CHAINS}. * @returns The 32-byte origin code to pass to the router. * @throws {@link AugustValidationError} when `provided` is not a 32-byte hex string. */ export declare function resolveOriginCode(provided?: `0x${string}`, chainId?: number): `0x${string}`; /** * Resolves the real, post-execution outcome of a SwapRouter deposit from its * mined transaction receipt. The SwapRouter contract itself emits no * deposit/amount-out event — only the vault does, via its own `Deposit` event * — so this decodes that log directly rather than trusting the pre-trade quote * a UI shows before the user submits (the true post-swap amount depends on * execution-time price and can differ from that estimate). * * Works for both vault generations without the caller resolving the version * first: evm-1 (ERC-4626-style `Deposit(sender, owner, assets, shares)`) and * evm-2 (`Deposit(assetIn, amountIn, shares, senderAddr, receiverAddr)`) have * different event signatures (different topic0), so both are registered and * whichever matches the vault's actual log is decoded. * * @param signer - ethers `Signer` or `Wallet` connected to a provider (used * read-only here — no transaction is sent). * @param options - {@link ISwapRouterDepositResultOptions}. * @returns The decoded {@link ISwapRouterDepositResult}, or `null` if the * receipt isn't found yet or carries no `Deposit` log from `vault` (e.g. the * hash is wrong, or the tx hasn't mined). * @throws {@link AugustValidationError} if `signer` has no connected provider. * @worstCaseRpcCalls 1 — a single `getTransactionReceipt` call; decoding is * local. * @example * ```ts * const hash = await augustSdk.evm.swapRouterDeposit({ ... }); * const result = await augustSdk.evm.getSwapRouterDepositResult({ * txHash: hash, * vault: '0x74ad2f789ed583dbd141bbdafc673fe1f033718b', * }); * // result?.amountOut — actual reference-asset amount received after the swap * ``` */ export declare function getSwapRouterDepositResult(signer: Signer | Wallet, { txHash, vault }: ISwapRouterDepositResultOptions): Promise; /** * Read how an origin code is registered on a chain's `SwapRouter`: whether it * exists, its origin fee, and its fee collector. * * Check a partner code with this before configuring it as * `attribution.originCode` — the router reverts every deposit carrying an * unregistered code with `InvalidOrigin`. A code is registered when its * collector is non-zero (`addOrigin` always sets one); a zero-fee code is * still registered but never emits `OriginFeeApplied`. Cached per (chain, * router, code) for 5 minutes. * * @param options - {@link IGetOriginInfoOptions}. * @returns {@link IOriginInfo}; `registered: false` with a zero fee and * collector, and no RPC, on a chain with no SwapRouter deployment. * @throws {@link AugustValidationError} when `originCode` is not a 32-byte hex * string. * @throws {@link AugustSDKError} when the `origins(bytes32)` read fails. * @worstCaseRpcCalls 1 — one `origins(bytes32)` call; none on a cache hit. * @example * ```ts * const info = await getOriginInfo({ chainId: 1, originCode, rpcUrl }); * if (!info.registered) throw new Error('origin code is not registered'); * ``` */ export declare function getOriginInfo({ chainId, originCode, rpcUrl, }: IGetOriginInfoOptions): Promise; /** * {@link getOriginInfo} without input validation, reading through a caller * runner (created lazily, only on a cache miss). Shared with the deposit-route * resolver so both hit the same cache entry. * @internal */ export declare function readOriginInfo(chainId: number, originCode: `0x${string}`, runner: () => IContractRunner): Promise; /** * Read a vault's `SwapRouter` registration (`vaultInfo`), cached for 5 * minutes like the other router reads. * * @returns The router's `referenceAsset` for the vault (the zero address when * it is not registered) and its `vaultType`; `undefined` on a chain with no * SwapRouter. * @internal */ export declare function readSwapRouterVaultInfo(runner: IContractRunner, chainId: number, vault: IAddress): Promise<{ referenceAsset: IAddress; vaultType: number; } | undefined>; /** * Read whether a chain's `SwapRouter` whitelists `token` * (`whitelistedTokens`), cached for 5 minutes like the other router reads. * `SwapRouter.deposit` reverts `InputTokenNotWhitelisted` for any token it * does not whitelist, the vault's reference asset included. * * @returns `false` on a chain with no SwapRouter. * @internal */ export declare function readSwapRouterTokenWhitelisted(runner: IContractRunner, chainId: number, token: IAddress): Promise; /** * Read whether a chain's `SwapRouter` is paused (`isPaused()`), cached for 15 * seconds. Every router entry point (`deposit`, `swapAndDeposit`, * `depositNativeToken`) reverts with `ContractIsPaused` while the router is * paused, so callers check this before routing a deposit or sending an * approval to the router. * * @param runner - Contract runner (provider or signer) used for the read. * @param chainId - EVM chain ID. * @returns `true` while the router is paused; `false` when it is not, or on a * chain with no SwapRouter (no RPC). * @throws When the `isPaused()` read fails. Callers wrap it in * {@link AugustSDKError}. * @worstCaseRpcCalls 1 — one `isPaused()` call; none on a cache hit. * @internal */ export declare function readSwapRouterPaused(runner: IContractRunner, chainId: number): Promise; /** * Resolve the ERC-20 tokens currently whitelisted for the `SwapRouter` on a * chain — the any-token set a UI can offer as swap-and-deposit inputs. * * The router exposes its allowlist only as `mapping(address => bool) * whitelistedTokens` with **no on-chain enumeration**, so this cannot be a * single view call. It runs in two stages: * 1. Scan the router's `TokenEnabled(address)` event history (from the chain's * {@link SWAP_ROUTER_DEPLOY_BLOCKS} floor, in `eth_getLogs` chunks sized by * {@link determineBlockSkipInternal}) to reconstruct the candidate set of * every token ever enabled. * 2. Re-read `whitelistedTokens(token)` for each candidate — batched via * Multicall3 where verified, else per-call — and keep only those the * mapping currently returns `true` for. This step makes later disables (and * disable-then-re-enable) correct without replaying `TokenDisabled`, and is * the fail-closed source of truth: a token surfaces only on a definite * on-chain `true`. * * The resolved list is cached per chain for 5 minutes — the allowlist changes * only via an admin `enableToken`/`disableToken` transaction, so a short TTL * keeps the (multi-RPC) scan off the hot path without going stale for long. * * @param chainId - EVM chain ID. Chains without a {@link SWAP_ROUTER_ADDRESSES} * entry resolve to `[]` with no RPC. * @param options - `rpcUrl` (required) must point at `chainId`'s network; * `fromBlock` overrides the default deploy-block scan floor (e.g. to widen a * scan on a chain missing from {@link SWAP_ROUTER_DEPLOY_BLOCKS}). * @returns Checksummed addresses of the currently-whitelisted tokens, deduped. * Empty when no router is deployed or none are enabled. Callers still filter * out a given vault's natively-accepted assets (those deposit without a swap). * @throws AugustValidationError when `rpcUrl` is missing/empty. * @throws AugustSDKError when an `eth_getLogs` chunk fails — surfaced (not * swallowed) so a partial scan never masquerades as a complete allowlist. * @worstCaseRpcCalls On mainnet, 1 `eth_blockNumber` + ~4 `eth_getLogs` chunks * (router-lifetime ÷ 50k-block window) + 1 Multicall3 `eth_call` ≈ 6; scales * with the router's on-chain age, not with candidate count. * @example * ```ts * const tokens = await getSwapRouterWhitelistedTokens(1, { * rpcUrl: 'https://eth-mainnet.example/v2/KEY', * }); * // ['0xA0b8…', '0xdAC1…', '0xC02a…', '0x2260…'] (USDC, USDT, WETH, WBTC) * ``` */ export declare function getSwapRouterWhitelistedTokens(chainId: number, options: { rpcUrl: string; fromBlock?: number; }): Promise; /** * Resolve the vaults currently eligible for the any-token `SwapRouter` deposit * surface on a chain — i.e. every vault the router has `enableVault`-ed that is * still registered on-chain. * * The router stores registrations as `mapping(address => VaultInfo) vaultInfo` * with **no on-chain enumeration**, so (exactly like * {@link getSwapRouterWhitelistedTokens}) this runs in two stages: * 1. Scan the router's `VaultEnabled(address)` event history (from the chain's * {@link SWAP_ROUTER_DEPLOY_BLOCKS} floor, in `eth_getLogs` chunks sized by * {@link determineBlockSkipInternal}) to reconstruct the candidate set of * every vault ever enabled. * 2. Re-read `vaultInfo(vault)` for each candidate — batched via Multicall3 * where verified, else per-call — and keep only those whose * `referenceAsset != address(0)` (an unregistered vault reverts with * `InvalidVault` at deposit time). This makes later disables correct * without replaying `VaultDisabled`, and is the fail-closed source of * truth: a vault surfaces only on a definite on-chain registration. * * This is the dynamic successor to the static * {@link SWAP_ROUTER_ELIGIBLE_VAULTS} snapshot / {@link isSwapRouterEligible}. * It reports **on-chain eligibility only** — app-level policy (e.g. excluding * OVault-enabled vaults that have their own deposit flow) remains the caller's * responsibility, as does the flag gating of the UI surface. * * The resolved list is cached per chain for 5 minutes — registrations change * only via an admin `enableVault`/`disableVault` transaction, so a short TTL * keeps the (multi-RPC) scan off the hot path without going stale for long. * * @param chainId - EVM chain ID. Chains without a {@link SWAP_ROUTER_ADDRESSES} * entry resolve to `[]` with no RPC. * @param options - `rpcUrl` (required) must point at `chainId`'s network; * `fromBlock` overrides the default deploy-block scan floor. * @returns Checksummed addresses of the currently-registered eligible vaults, * deduped. Empty when no router is deployed or none are registered. * @throws AugustValidationError when `rpcUrl` is missing/empty. * @throws AugustSDKError when an `eth_getLogs` chunk fails — surfaced (not * swallowed) so a partial scan never masquerades as the complete set. * @worstCaseRpcCalls On mainnet, 1 `eth_blockNumber` + ~4 `eth_getLogs` chunks * (router-lifetime ÷ 50k-block window) + 1 Multicall3 `eth_call` ≈ 6; scales * with the router's on-chain age, not with candidate count. * @example * ```ts * const vaults = await getSwapRouterEligibleVaults(1, { * rpcUrl: 'https://eth-mainnet.example/v2/KEY', * }); * // ['0x74aD…718b', '0xE9B7…9D32'] (Sentora USD, Upshift Core USDC) * ``` */ export declare function getSwapRouterEligibleVaults(chainId: number, options: { rpcUrl: string; fromBlock?: number; }): Promise;