import { type Abi, type Address, type Hex, type PublicClient, erc20Abi } from 'viem'; import { CCA_ABI, LBP_STRATEGY_ABI, PERMIT2_ABI, STATE_VIEW_ABI } from './abis'; import type { TokenFactoryKind } from './addresses'; /** * Read layer. Every read is exposed two ways: * - a pure `*Call` **descriptor** — `{ address, abi, functionName, args }` — that drops straight * into wagmi `useReadContracts`, viem multicall, or any rpc client (the backend runs these * through its own client). The SDK never binds a transport. * - an async helper that executes the descriptor against a viem `PublicClient`, for scripts and * quick server-side use. */ /** A framework-agnostic contract read/write descriptor. */ export interface ContractCall { address: Address; abi: TAbi; functionName: string; args: readonly unknown[]; } /** Execute a descriptor against a viem `PublicClient`. */ export declare function readContract(client: PublicClient, call: ContractCall): Promise; /** `LBPStrategy.registeredPoolIds(poolId)` — returns the reserving initializer, or address(0) if free. */ export declare function registeredPoolIdCall(p: { lbpStrategy: Address; poolId: Hex; }): ContractCall; /** Reads which initializer reserved `poolId` (address(0) when the pool id is free). */ export declare function getRegisteredInitializer(client: PublicClient, p: { lbpStrategy: Address; poolId: Hex; }): Promise
; /** `StateView.getSlot0(poolId)` — pool state by id; `sqrtPriceX96 == 0` means uninitialized. */ export declare function slot0Call(p: { stateView: Address; poolId: Hex; }): ContractCall; /** Whether the v4 pool for `poolId` is already initialized (`sqrtPriceX96 != 0`). */ export declare function isV4PoolInitialized(client: PublicClient, p: { stateView: Address; poolId: Hex; }): Promise; /** `auction.isGraduated()` — whether the auction met its graduation criteria. */ export declare function isGraduatedCall(auction: Address): ContractCall; /** `auction.sweepUnsoldTokensBlock()` — 0 until the creator sweeps; non-zero once swept (one-shot). */ export declare function sweepUnsoldTokensBlockCall(auction: Address): ContractCall; /** `auction.sweepCurrencyBlock()` — 0 until the raised currency is swept (`migrate()` does this). */ export declare function sweepCurrencyBlockCall(auction: Address): ContractCall; /** `auction.currencyRaised()` — total currency raised so far. */ export declare function currencyRaisedCall(auction: Address): ContractCall; /** `auction.remainingSupply()` — tokens not (yet) sold; the graduated-path sweep amount. */ export declare function remainingSupplyCall(auction: Address): ContractCall; /** `auction.tokensRecipient()` — the only address allowed to call `sweepUnsoldTokens()`. */ export declare function tokensRecipientCall(auction: Address): ContractCall; /** `auction.endBlock()` — when the auction finishes (in the auction's block domain, see below). */ export declare function auctionEndBlockCall(auction: Address): ContractCall; /** `auction.claimBlock()` — when winning bids become claimable. */ export declare function auctionClaimBlockCall(auction: Address): ContractCall; export type AuctionOutcome = 'active' | 'graduated' | 'failed'; /** * Derives the auction outcome from already-read state (there is no failure enum on-chain): * `active` until `endBlock`, then `graduated` or `failed` by `isGraduated()`. A `failed` auction's * creator recovers the full deposited supply via {@link buildSweepUnsoldTokensTx}; a `graduated` * one migrates via {@link buildMigrateTx} (and can sweep only the unsold remainder). * * `currentBlock` must be in the auction's own block domain: the CCA is BlockNumberish-aware, so on * chains like Arbitrum it counts L1 (ArbSys) blocks, not the L2 blocks `eth_blockNumber` returns. */ export declare function deriveAuctionOutcome(p: { isGraduated: boolean; endBlock: bigint; currentBlock: bigint; }): AuctionOutcome; export declare function erc20DecimalsCall(token: Address): ContractCall; export declare function erc20BalanceCall(token: Address, account: Address): ContractCall; export declare function erc20AllowanceCall(token: Address, owner: Address, spender: Address): ContractCall; export declare function permit2AllowanceCall(p: { permit2: Address; owner: Address; token: Address; spender: Address; }): ContractCall; export declare function getErc20Decimals(client: PublicClient, token: Address): Promise; export declare function getErc20Balance(client: PublicClient, token: Address, account: Address): Promise; export declare function getErc20Allowance(client: PublicClient, token: Address, owner: Address, spender: Address): Promise; /** * Reads the Permit2 `amount` and `expiration` for `owner`'s `token` to `spender`. Callers must check * both: an allowance with sufficient amount but a past `expiration` is not spendable. */ export declare function getPermit2Allowance(client: PublicClient, p: { permit2: Address; owner: Address; token: Address; spender: Address; }): Promise<{ amount: bigint; expiration: number; }>; export interface PredictTokenParams { factory: Address; /** Selects the factory's address-derivation scheme (uERC20 vs super-uERC20). */ kind: TokenFactoryKind; /** msg.sender at the factory == the LiquidityLauncher (it calls createToken). */ launcherAddress: Address; /** The original creator (tx sender); folded into the graffiti. */ wallet: Address; name: string; symbol: string; decimals: number; /** Home chain (== launch chain) id, folded into the super-uERC20 salt. Unused for uERC20. */ homeChainId: bigint; } /** The factory view descriptor that returns the deterministic new-token address. */ export declare function predictTokenAddressCall(p: PredictTokenParams): ContractCall; /** Reads the deterministic new-token address from the factory. */ export declare function predictTokenAddress(client: PublicClient, p: PredictTokenParams): Promise
; export interface PredictAuctionParams { strategy: Address; token: Address; /** auctionSupply = totalSupply - reservedTokenAmountForLP. */ auctionSupply: bigint; /** `abi.encode(AuctionParameters)` — the inner initializer params. */ auctionParams: Hex; initializerSalt: Hex; } /** * Reads the deterministic auction (initializer) address. Two-step: the CCA factory address is read * from the strategy's `initializerFactory()`, then its `getAddress(...)` view is queried. The factory * re-derives the CREATE2 salt as `keccak256(abi.encode(sender, salt))` and rewrites the address(1) * recipient sentinel to `sender` — `sender` is the LBPStrategy (msg.sender), not the creator wallet. */ export declare function predictAuctionAddress(client: PublicClient, p: PredictAuctionParams): Promise
;