UNPKG

four-flap-meme-sdk

Version:

SDK for Flap bonding curve and four.meme TokenManager

140 lines (139 loc) 3.93 kB
import { type FlapChain } from '../flap/portal.js'; /** DEX 配置 */ export interface DexConfig { name: string; v2Factory?: string; v3Factory?: string; v2Router?: string; v3Router?: string; quoterV2?: string; enabled: boolean; } /** 链配置 */ export interface ChainDexConfig { wrappedNative: string; wrappedNativeSymbol: string; stableCoins: Array<{ address: string; symbol: string; decimals: number; }>; dexes: Record<string, DexConfig>; } /** 单个交易对信息 */ export interface PoolPairInfo { quoteToken: string; quoteSymbol: string; quoteDecimals: number; pairAddress: string; reserveToken: string; reserveQuote: string; reserveQuoteRaw?: bigint; reserveTokenRaw?: bigint; poolRatio?: string; } /** V3 池子信息(带 fee) */ export interface V3PoolInfo extends PoolPairInfo { fee: number; } /** DEX 池子信息 */ export interface DexPoolInfo { dexName: string; dexKey: string; v2Pairs: PoolPairInfo[]; v3Pools: V3PoolInfo[]; } /** 最佳池子推荐 */ export interface BestPoolInfo { dex: string; dexKey: string; version: 'v2' | 'v3'; fee?: number; quoteToken: string; quoteSymbol: string; quoteDecimals: number; pairAddress: string; liquidity: string; liquidityRaw: bigint; reserveToken?: string; reserveTokenRaw?: bigint; poolRatio?: string; } /** LP 平台类型 */ export type LPPlatform = 'FOUR' | 'FLAP' | 'PANCAKESWAP_V2' | 'PANCAKESWAP_V3' | 'UNISWAP_V2' | 'UNISWAP_V3' | 'MULTI_DEX' | 'UNKNOWN'; /** LP 信息返回类型 */ export interface LPInfo { platform: LPPlatform; decimals?: number; totalSupply?: string; totalSupplyRaw?: bigint; four?: { helper: string; reserveNative?: string; offerTokens?: string; lastPrice?: string; }; flap?: { quoteToken?: string; quoteSymbol?: string; quoteDecimals?: number; reserveNative?: string; circulatingSupply?: string; price?: string; }; allPools: DexPoolInfo[]; bestPools: BestPoolInfo[]; } /** 查询选项 */ export interface InspectOptions { chain: 'BSC' | 'MONAD' | 'XLAYER'; rpcUrl: string; flapChain?: FlapChain; v3FeeTiers?: number[]; customDexConfig?: Partial<ChainDexConfig>; multicall3?: string; debug?: boolean; formatBalances?: boolean; } /** * 从 Router 合约获取 Factory 地址 * 支持 Uniswap V2 Router 和 V3 SwapRouter02 */ export declare function getFactoryFromRouter(routerAddress: string, rpcUrl: string, routerType?: 'v2' | 'v3'): Promise<{ v2Factory?: string; v3Factory?: string; }>; /** * 动态注册 DYORSwap(从 Router 获取 Factory) */ export declare function registerDYORSwap(rpcUrl: string): Promise<boolean>; /** 注册新的 DEX */ export declare function registerDex(chain: string, dexKey: string, config: DexConfig): void; /** 注册新的稳定币 */ export declare function registerStableCoin(chain: string, coin: { address: string; symbol: string; decimals: number; }): void; /** 获取链配置(优先运行时配置) */ export declare function getChainConfig(chain: string): ChainDexConfig | undefined; /** 获取支持的 DEX 列表 */ export declare function getSupportedDexes(chain: string): Array<{ key: string; name: string; enabled: boolean; }>; /** 获取支持的稳定币列表 */ export declare function getSupportedStableCoins(chain: string): Array<{ address: string; symbol: string; decimals: number; }>; /** 获取所有报价代币(包装原生 + 稳定币) */ export declare function getQuoteTokens(chain: string): Array<{ address: string; symbol: string; decimals: number; isNative: boolean; }>; export declare function inspectTokenLP(token: string, opts: InspectOptions): Promise<LPInfo>;