import { AssetType, ChainId } from "../../model/primitives.js"; import { CuratorName } from "../../model/curators.js"; import "../../model/index.js"; import { AddressMap } from "../utils/AddressMap.js"; import { AddressSet } from "../utils/AddressSet.js"; import { Address, Chain } from "viem"; import { z } from "zod/v4"; //#region src/onchain/chain/chains.d.ts /** * Extended viem {@link Chain} with Gearbox-specific metadata. * * Every supported network is represented by a `GearboxChain` instance in * the {@link chains} record. **/ export interface GearboxChain extends Chain { /** * Gearbox network type label (e.g. `"Mainnet"`, `"Arbitrum"`). **/ network: NetworkType; /** * Market configurator addresses operated by known curators on this chain. **/ defaultMarketConfigurators: AddressMap; /** * Known RWA factory addresses on this chain */ rwaFactories: Address[]; /** * Market configurators used in test/staging environments. **/ testMarketConfigurators?: AddressMap; /** * Denomination class of the market underlyings on this chain. * * Nothing on-chain says what a token is denominated in, so this is a manually * curated table. It only covers underlyings — there are few of them — and a * token missing from it is simply unclassified. An RWA market's compliance * wrapper does not belong here: it is unwrapped before the lookup, so the * token it holds is what needs an entry. **/ underlyingAssetTypes?: AddressMap; /** * Tokens on this chain that represent a real-world asset. A market that * accepts one of them as collateral is reported as an RWA opportunity. **/ rwaTokens?: AddressSet; /** * Collateral whose sale pays part of the proceeds later, as a direct * transfer of another token to the credit account. Maps collateral → the * token transferred. **/ directTransfers?: AddressMap
; /** * Pools being wound down. Curated, and unrelated to any on-chain flag. **/ sunsetPools?: AddressSet; /** * Credit managers whose strategies are being wound down. Curated, and * unrelated to the credit facade's expiration date. **/ sunsetStrategies?: AddressSet; /** * Legacy credit managers whose target collateral cannot be inferred from * the collateral list. Maps credit manager → target collateral. **/ legacyStrategyTargets?: AddressMap
; /** * Existing credit accounts whose target collateral must stay pinned, even * when the credit manager's current target would say otherwise. Maps credit * account → target collateral. **/ accountTargetCollaterals?: AddressMap
; /** * Display names that replace the on-chain ticker in {@link TokensMeta}, * e.g. a Beefy vault rewritten as `"Beefy WBTC/cbBTC/hemiBTC"`. **/ tokenPrettyNames?: AddressMap; /** * Whether this chain is production-ready **/ isPublic: boolean; /** * A well-known ERC-20 token that uniquely identifies this chain. * * Used by {@link detectNetwork} to determine which chain an arbitrary * RPC endpoint is connected to. **/ wellKnownToken: { address: Address; symbol: string; }; /** * Block number when the Gearbox address provider was deployed. **/ firstBlock?: bigint; /** * Default read-only calls gas limit for this chain. */ gasLimit: bigint; } /** * Tuple of all network labels the SDK can work with. **/ export declare const SUPPORTED_NETWORKS: readonly ["Mainnet", "Arbitrum", "Optimism", "Base", "Sonic", "MegaETH", "Monad", "Berachain", "Avalanche", "BNB", "WorldChain", "Etherlink", "Hemi", "Lisk", "Plasma", "Somnia"]; /** * Zod schema for validating/parsing network type strings. **/ export declare const NetworkType: z.ZodEnum<{ Arbitrum: "Arbitrum"; Avalanche: "Avalanche"; BNB: "BNB"; Base: "Base"; Berachain: "Berachain"; Etherlink: "Etherlink"; Hemi: "Hemi"; Lisk: "Lisk"; Mainnet: "Mainnet"; MegaETH: "MegaETH"; Monad: "Monad"; Optimism: "Optimism"; Plasma: "Plasma"; Somnia: "Somnia"; Sonic: "Sonic"; WorldChain: "WorldChain"; }>; /** * All supported Gearbox network labels **/ export type NetworkType = z.infer; /** * Pre-configured {@link GearboxChain} instances for every supported network. **/ export declare const chains: Record; /** * Returns the {@link GearboxChain} for a given chain ID or network type label. * * @param chainIdOrNetworkType - Numeric chain ID, bigint chain ID, or a {@link NetworkType} string. * @throws If the chain ID / network type is not supported. **/ export declare function getChain(chainIdOrNetworkType: number | bigint | NetworkType): GearboxChain; /** * Resolves a numeric chain ID to its {@link NetworkType} label. * * @param chainId - Numeric or bigint chain ID. * @throws If the chain ID does not correspond to a supported network. **/ export declare function getNetworkType(chainId: number | bigint): NetworkType; /** * Chain IDs of chains named as {@link NetworkType} labels or as IDs already, * e.g. `sdk.opportunities.list({ chainIds: toChainIds(["Mainnet"]) })`. * * @param scope - Chains as labels, or already as IDs. * @throws If any entry is not a supported network. **/ export declare function toChainIds(scope: NetworkType[] | ChainId[]): ChainId[]; /** * Type guard that checks whether a chain ID belongs to a supported Gearbox network. * * @param chainId - Numeric chain ID, or `undefined`. **/ export declare function isSupportedNetwork(chainId: number | undefined): chainId is number; /** * Returns `true` if the given network or chain ID has a publicly deployed Gearbox instance. * * @param networkOrChainId - {@link NetworkType} string or numeric chain ID. **/ export declare function isPublicNetwork(networkOrChainId: NetworkType | number | bigint): boolean; /** * Looks up the {@link CuratorName} name for a market configurator address. * * Searches default and test market configurators across all chains, or * a single network if provided. * * @param marketConfigurator - On-chain market configurator address. * @param network - Optional network to restrict the search to. * @returns The curator name, or `undefined` if not found. **/ export declare function getCuratorName(marketConfigurator: Address, network?: NetworkType): CuratorName | undefined; /** * Finds the market configurator address for a given curator on a network. * * @param curator - Curator name to search for. * @param network - Network to search in. * @returns The market configurator address, or `undefined` if the curator * has no configurator on this network. **/ export declare function findCuratorMarketConfigurator(curator: CuratorName, network: NetworkType): Address | undefined; /** * Looks up the {@link AssetType} of a token in hardcoded classifier. * Not all tokens are classified, only underlyings, so the default answer is `undefined`. * * @param token - Token address * @param network - Network the token lives on. * @returns The asset type, or `undefined` when the token is not classified **/ export declare function getAssetType(token: Address, network: NetworkType): AssetType | undefined; /** * Checks whether a token represents a real-world asset, per the curated list of * a network. * * @param token - Token address. * @param network - Network the token lives on. **/ export declare function isRWAToken(token: Address, network: NetworkType): boolean; /** * Checks whether a pool is on the sunset list of a network. * * @param pool - Pool address. * @param network - Network the pool lives on. **/ export declare function isSunsetPool(pool: Address, network: NetworkType): boolean; /** * Checks whether a credit manager is on the sunset list of a network. * * @param creditManager - Credit manager address. * @param network - Network the credit manager lives on. **/ export declare function isSunsetStrategy(creditManager: Address, network: NetworkType): boolean; /** * Token a collateral's sale later transfers directly to the credit account, * or `undefined` when the collateral is not in the table. * * @param collateral - Collateral token address. * @param network - Chain id or {@link NetworkType} label. **/ export declare function getDirectTransferToken(collateral: Address, network: number | bigint | NetworkType): Address | undefined; /** * Hardcoded target collateral of a legacy credit manager, or `undefined` when * the manager is not in the table and the on-chain rule should apply. * * @param creditManager - Credit manager address. * @param network - Chain id or {@link NetworkType} label. **/ export declare function getLegacyStrategyTarget(creditManager: Address, network: number | bigint | NetworkType): Address | undefined; /** * Hardcoded target collateral of an already-existing credit account, or * `undefined` when the account is not in the table and the credit manager's * target should apply. * * @param creditAccount - Credit account address. * @param network - Chain id or {@link NetworkType} label. **/ export declare function getAccountTargetCollateral(creditAccount: Address, network: number | bigint | NetworkType): Address | undefined; //#endregion