@flaunch/sdk
Version:
Flaunch SDK to easily interact with the Flaunch protocol
1,043 lines • 51.5 kB
TypeScript
import { Drift, HexString, ReadWriteAdapter, type Address } from "@delvtech/drift";
import { type PublicClient, Hex } from "viem";
import { ReadFlaunchPositionManager, ReadWriteFlaunchPositionManager, WatchPoolCreatedParams, WatchPoolSwapParams as WatchPoolSwapParamsPositionManager } from "../clients/FlaunchPositionManagerClient";
import { ReadPoolManager, PositionInfoParams } from "../clients/PoolManagerClient";
import { ReadStateView } from "../clients/StateViewClient";
import { ReadFairLaunch } from "../clients/FairLaunchClient";
import { ReadBidWall } from "../clients/BidWallClient";
import { AnyBidWall } from "../clients/AnyBidWall";
import { ReadFlaunchZap, ReadWriteFlaunchZap, FlaunchParams, FlaunchIPFSParams, FlaunchWithRevenueManagerParams, FlaunchWithRevenueManagerIPFSParams, FlaunchWithSplitManagerParams, FlaunchWithSplitManagerIPFSParams, DeployRevenueManagerParams, DeployStakingManagerParams, DeployBuyBackManagerParams } from "../clients/FlaunchZapClient";
import { ReadFlaunch } from "../clients/FlaunchClient";
import { ReadAnyFlaunch } from "../clients/AnyFlaunchClient";
import { ReadQuoter } from "clients/QuoterClient";
import { ReadPermit2, ReadWritePermit2 } from "clients/Permit2Client";
import { ReadFlaunchPositionManagerV1_1, ReadWriteFlaunchPositionManagerV1_1 } from "clients/FlaunchPositionManagerV1_1Client";
import { ReadFlaunchPositionManagerV1_2 } from "clients/FlaunchPositionManagerV1_2Client";
import { AnyFlaunchParams, ReadAnyPositionManager, ReadWriteAnyPositionManager } from "clients/AnyPositionManagerClient";
import { ReadTokenImporter, ReadWriteTokenImporter } from "clients/TokenImporter";
import { ReadFeeEscrow, ReadWriteFeeEscrow } from "clients/FeeEscrowClient";
import { ReadReferralEscrow, ReadWriteReferralEscrow } from "clients/ReferralEscrowClient";
import { ReadBidWallV1_1 } from "clients/BidWallV1_1Client";
import { ReadFairLaunchV1_1 } from "clients/FairLaunchV1_1Client";
import { ReadFlaunchV1_1 } from "clients/FlaunchV1_1Client";
import { ReadFlaunchV1_2 } from "clients/FlaunchV1_2Client";
import { ReadWriteTreasuryManagerFactory } from "clients/TreasuryManagerFactoryClient";
import { CallWithDescription, CoinMetadata, FlaunchVersion, LiquidityMode, Permissions, ImportMemecoinParams, GetAddLiquidityCallsParams, CalculateAddLiquidityAmountsParams, CheckSingleSidedAddLiquidityParams, SingleSidedLiquidityInfo, PoolWithHookData, GetSingleSidedCoinAddLiquidityCallsParams, ImportAndSingleSidedCoinAddLiquidityWithMarketCap, ImportAndSingleSidedCoinAddLiquidityWithPrice, ImportAndAddLiquidityWithMarketCap, ImportAndAddLiquidityWithPrice, ImportAndAddLiquidityWithExactAmounts, PoolCreatedEventData } from "types";
import { PermitSingle } from "utils/universalRouter";
export type { PoolCreatedEventData } from "types";
type WatchPoolSwapParams = Omit<WatchPoolSwapParamsPositionManager<boolean>, "flETHIsCurrencyZero"> & {
filterByCoin?: Address;
};
type GenericBaseSwapLog = {
timestamp: number;
transactionHash: Hex;
blockNumber: bigint;
args: any;
};
type GenericBuySwapLog = GenericBaseSwapLog & {
type: "BUY";
delta: {
coinsBought: bigint;
flETHSold: bigint;
fees: {
isInFLETH: boolean;
amount: bigint;
};
};
};
type GenericSellSwapLog = GenericBaseSwapLog & {
type: "SELL";
delta: {
coinsSold: bigint;
flETHBought: bigint;
fees: {
isInFLETH: boolean;
amount: bigint;
};
};
};
type BuyCoinBase = {
coinAddress: Address;
slippagePercent: number;
referrer?: Address;
intermediatePoolKey?: PoolWithHookData;
permitSingle?: PermitSingle;
signature?: Hex;
hookData?: Hex;
};
type BuyCoinExactInParams = BuyCoinBase & {
swapType: "EXACT_IN";
amountIn: bigint;
amountOutMin?: bigint;
};
type BuyCoinExactOutParams = BuyCoinBase & {
swapType: "EXACT_OUT";
amountOut: bigint;
amountInMax?: bigint;
};
type BuyCoinParams = BuyCoinExactInParams | BuyCoinExactOutParams;
type SellCoinParams = {
coinAddress: Address;
amountIn: bigint;
slippagePercent: number;
amountOutMin?: bigint;
referrer?: Address;
intermediatePoolKey?: PoolWithHookData;
permitSingle?: PermitSingle;
signature?: HexString;
};
/**
* Base class for interacting with Flaunch protocol in read-only mode
*/
export declare class ReadFlaunchSDK {
readonly drift: Drift;
readonly chainId: number;
readonly publicClient: PublicClient | undefined;
readonly TICK_SPACING = 60;
readonly readPositionManager: ReadFlaunchPositionManager;
readonly readPositionManagerV1_1: ReadFlaunchPositionManagerV1_1;
readonly readAnyPositionManager: ReadAnyPositionManager;
readonly readTokenImporter: ReadTokenImporter;
readonly readFeeEscrow: ReadFeeEscrow;
readonly readReferralEscrow: ReadReferralEscrow;
readonly readFlaunchZap: ReadFlaunchZap;
readonly readPoolManager: ReadPoolManager;
readonly readStateView: ReadStateView;
readonly readFairLaunch: ReadFairLaunch;
readonly readFairLaunchV1_1: ReadFairLaunchV1_1;
readonly readBidWall: ReadBidWall;
readonly readAnyBidWall: AnyBidWall;
readonly readBidWallV1_1: ReadBidWallV1_1;
readonly readFlaunch: ReadFlaunch;
readonly readFlaunchV1_1: ReadFlaunchV1_1;
readonly readAnyFlaunch: ReadAnyFlaunch;
readonly readQuoter: ReadQuoter;
readonly readPermit2: ReadPermit2;
readonly readPositionManagerV1_2: ReadFlaunchPositionManagerV1_2;
readonly readFlaunchV1_2: ReadFlaunchV1_2;
resolveIPFS: (value: string) => string;
constructor(chainId: number, drift?: Drift, publicClient?: PublicClient);
/**
* Checks if a given coin address is a valid Flaunch coin (supports all versions)
* @param coinAddress - The address of the coin to check
* @returns Promise<boolean> - True if the coin is valid, false otherwise
*/
isValidCoin(coinAddress: Address): Promise<boolean>;
/**
* Determines the version of a Flaunch coin
* @param coinAddress - The address of the coin to check
* @returns Promise<FlaunchVersion> - The version of the coin
*/
getCoinVersion(coinAddress: Address): Promise<FlaunchVersion>;
/**
* Gets the position manager instance for a given version
* @param version - The version to get the position manager instance for
*/
getPositionManager(version: FlaunchVersion): ReadFlaunchPositionManager | ReadFlaunchPositionManagerV1_1 | ReadFlaunchPositionManagerV1_2 | ReadAnyPositionManager;
/**
* Gets the fair launch instance for a given version
* @param version - The version to get the fair launch instance for
*/
getFairLaunch(version: FlaunchVersion): ReadFairLaunch | ReadFairLaunchV1_1;
/**
* Gets the bid wall instance for a given version
* @param version - The version to get the bid wall instance for
*/
getBidWall(version: FlaunchVersion): ReadBidWall | AnyBidWall | ReadBidWallV1_1;
/**
* Gets the flaunch contract instance for a given version
* @param version - The version to get the flaunch contract instance for
*/
getFlaunch(version: FlaunchVersion): ReadFlaunch | ReadAnyFlaunch | ReadFlaunchV1_1 | ReadFlaunchV1_2;
/**
* Gets the flaunch contract address for a given version
* @param version - The version to get the flaunch contract address for
*/
getFlaunchAddress(version: FlaunchVersion): `0x${string}`;
getPositionManagerAddress(version: FlaunchVersion): `0x${string}`;
getFairLaunchAddress(version: FlaunchVersion): `0x${string}`;
getBidWallAddress(version: FlaunchVersion): `0x${string}`;
/**
* Gets the flaunch contract address and token ID for a memecoin
* @param coinAddress - The address of the memecoin
* @returns Promise<{ flaunchAddress: Address; tokenId: bigint }> - The flaunch contract address and token ID
*/
getFlaunchTokenIdForMemecoin(coinAddress: Address): Promise<{
flaunchAddress: Address;
tokenId: bigint;
}>;
/**
* Retrieves metadata for a given Flaunch coin
* @param coinAddress - The address of the coin
* @returns Promise<CoinMetadata & { symbol: string }> - The coin's metadata including name, symbol, description, and social links
*/
getCoinMetadata(coinAddress: Address): Promise<CoinMetadata & {
symbol: string;
}>;
/**
* Retrieves metadata for a given Flaunch coin using its token ID & Flaunch contract address
* @param flaunch - The address of the Flaunch contract
* @param tokenId - The token ID of the coin
* @returns The coin's metadata including name, symbol, description, and social links
*/
getCoinMetadataFromTokenId(flaunch: Address, tokenId: bigint): Promise<CoinMetadata & {
symbol: string;
}>;
/**
* Retrieves metadata for multiple Flaunch coins using their token IDs & Flaunch contract addresses
* @param params - An array of objects containing flaunch contract address and token ID
* @param batchSize - Optional, the number of ipfs requests to process in each batch
* @param batchDelay - Optional, the delay in milliseconds between batches
* @returns An array of objects containing coin address, name, symbol, description, and social links
*/
getCoinMetadataFromTokenIds(params: {
flaunch: Address;
tokenId: bigint;
}[], batchSize?: number, batchDelay?: number): Promise<{
coinAddress: Address;
name: string;
symbol: string;
description: any;
image: string;
external_link: any;
collaborators: any;
discordUrl: any;
twitterUrl: any;
telegramUrl: any;
}[]>;
/**
* Watches for pool creation events
* @param params - Parameters for watching pool creation
* @param version - Version of Flaunch to use (defaults to V1_1)
* @returns Subscription to pool creation events
*/
watchPoolCreated(params: WatchPoolCreatedParams, version?: FlaunchVersion): Promise<{
cleanup: () => void;
pollPoolCreatedNow: () => Promise<void>;
}>;
/**
* Polls for current pool creation events
* @param version - Version of Flaunch to use (defaults to V1_1)
* @returns Current pool creation events or undefined if polling is not available
*/
pollPoolCreatedNow(version?: FlaunchVersion): Promise<void> | undefined;
/**
* Parses a transaction to extract PoolCreated event data
* @param txHash - The transaction hash to parse
* @returns PoolCreated event parameters or null if not found
*/
getPoolCreatedFromTx(txHash: Hex): Promise<PoolCreatedEventData | null>;
/**
* Watches for pool swap events
* @param params - Parameters for watching pool swaps including optional coin filter
* @param version - Version of Flaunch to use (defaults to V1_1)
* @returns Subscription to pool swap events
*/
watchPoolSwap(params: WatchPoolSwapParams, version?: FlaunchVersion): Promise<{
cleanup: () => void;
pollPoolSwapNow: () => Promise<void>;
}>;
/**
* Polls for current pool swap events
* @param version - Version of Flaunch to use (defaults to V1_1)
* @returns Current pool swap events or undefined if polling is not available
*/
pollPoolSwapNow(version?: FlaunchVersion): Promise<void> | undefined;
/**
* Gets information about a liquidity position
* @param params - Parameters for querying position info
* @returns Position information from the state view contract
*/
positionInfo(params: PositionInfoParams): Promise<{
liquidity: bigint;
feeGrowthInside0LastX128: bigint;
feeGrowthInside1LastX128: bigint;
} | {
liquidity: bigint;
feeGrowthInside0LastX128: bigint;
feeGrowthInside1LastX128: bigint;
}>;
/**
* Gets the current tick for a given coin's pool
* @param coinAddress - The address of the coin
* @param version - Optional specific version to use. If not provided, will be determined automatically
* @returns Promise<number> - The current tick of the pool
*/
currentTick(coinAddress: Address, version?: FlaunchVersion): Promise<number>;
/**
* Calculates the coin price in ETH based on the current tick
* @param coinAddress - The address of the coin
* @param version - Optional specific version to use. If not provided, will be determined automatically
* @returns Promise<string> - The price of the coin in ETH with 18 decimals precision
*/
coinPriceInETH(coinAddress: Address, version?: FlaunchVersion): Promise<string>;
/**
* Calculates the coin price in USD based on the current ETH/USDC price
* @param coinAddress - The address of the coin
* @param version - Optional specific version to use. If not provided, will be determined automatically
* @returns Promise<string> - The price of the coin in USD with 18 decimal precision
*/
coinPriceInUSD({ coinAddress, version, drift, }: {
coinAddress: Address;
version?: FlaunchVersion;
drift?: Drift;
}): Promise<string>;
coinMarketCapInUSD({ coinAddress, version, drift, }: {
coinAddress: Address;
version?: FlaunchVersion;
drift?: Drift;
}): Promise<string>;
/**
* Gets the current ETH/USDC price
* @param drift - Optional drift instance to get price from Base Mainnet
* @returns Promise<number> - The current ETH/USDC price
*/
getETHUSDCPrice(drift?: Drift): Promise<number>;
initialSqrtPriceX96(params: {
coinAddress: Address;
initialMarketCapUSD: number;
}): Promise<bigint>;
/**
* Gets information about a fair launch for a given coin
* @param coinAddress - The address of the coin
* @param version - Optional specific version to use. If not provided, will be determined automatically
* @returns Fair launch information from the appropriate contract version
*/
fairLaunchInfo(coinAddress: Address, version?: FlaunchVersion): Promise<{
startsAt: bigint;
endsAt: bigint;
initialTick: number;
revenue: bigint;
supply: bigint;
closed: boolean;
}>;
/**
* Checks if a fair launch is currently active for a given coin
* @param coinAddress - The address of the coin
* @param version - Optional specific version to use. If not provided, will be determined automatically
* @returns Promise<boolean> - True if fair launch is active, false otherwise
*/
isFairLaunchActive(coinAddress: Address, version?: FlaunchVersion): Promise<boolean>;
trustedPoolKeySignerStatus(coinAddress: Address, version?: FlaunchVersion): Promise<{
isCurrentlyEnabled: boolean;
trustedSignerEnabled: boolean;
signer: Address;
fairLaunchStartsAt: number;
fairLaunchEndsAt: number;
isFairLaunchActive: boolean;
}>;
/**
* Gets the duration of a fair launch for a given coin
* @param coinAddress - The address of the coin
* @param version - Optional specific version to use. If not provided, will be determined automatically
* @returns Promise<number> - The duration in seconds (30 minutes for V1, variable for V1.1)
*/
fairLaunchDuration(coinAddress: Address, version?: FlaunchVersion): Promise<number | bigint>;
/**
* Gets the initial tick for a fair launch
* @param coinAddress - The address of the coin
* @param version - Optional specific version to use. If not provided, will be determined automatically
* @returns Promise<number> - The initial tick value
*/
initialTick(coinAddress: Address, version?: FlaunchVersion): Promise<number>;
/**
* Gets information about the ETH-only position in a fair launch
* @param coinAddress - The address of the coin
* @param version - Optional specific version to use. If not provided, will be determined automatically
* @returns Promise<{flETHAmount: bigint, coinAmount: bigint, tickLower: number, tickUpper: number}> - Position details
*/
fairLaunchETHOnlyPosition(coinAddress: Address, version?: FlaunchVersion): Promise<{
flETHAmount: bigint;
coinAmount: bigint;
tickLower: number;
tickUpper: number;
}>;
/**
* Gets information about the coin-only position in a fair launch
* @param coinAddress - The address of the coin
* @param version - Optional specific version to use. If not provided, will be determined automatically
* @returns Promise<{flETHAmount: bigint, coinAmount: bigint, tickLower: number, tickUpper: number}> - Position details
*/
fairLaunchCoinOnlyPosition(coinAddress: Address, version?: FlaunchVersion): Promise<{
flETHAmount: bigint;
coinAmount: bigint;
tickLower: number;
tickUpper: number;
}>;
/**
* Gets information about the bid wall position for a coin
* @param coinAddress - The address of the coin
* @param version - Optional specific version to use. If not provided, will be determined automatically
* @returns Promise<{flETHAmount: bigint, coinAmount: bigint, pendingEth: bigint, tickLower: number, tickUpper: number}> - Bid wall position details
*/
bidWallPosition(coinAddress: Address, version?: FlaunchVersion): Promise<{
flETHAmount: bigint;
coinAmount: bigint;
pendingEth: bigint;
tickLower: number;
tickUpper: number;
}>;
/**
* Gets the ETH balance for the creator to claim
* @param creator - The address of the creator to check
* @param isV1 - Optional boolean to check the balance for V1. V1.1 & AnyPositionManager use the same FeeEscrow contract
* @returns The balance of the creator
*/
creatorRevenue(creator: Address, isV1?: boolean): Promise<bigint>;
/**
* Gets the balance of a recipient for a given coin
* @param recipient - The address of the recipient to check
* @param coinAddress - The address of the coin
* @returns Promise<bigint> - The balance of the recipient
*/
referralBalance(recipient: Address, coinAddress: Address): Promise<bigint>;
/**
* Gets the claimable balance of ETH for the recipient from a revenue manager
* @param params - Parameters for checking the balance
* @param params.revenueManagerAddress - The address of the revenue manager
* @param params.recipient - The address of the recipient to check
* @returns Promise<bigint> - The claimable balance of ETH
*/
revenueManagerBalance(params: {
revenueManagerAddress: Address;
recipient: Address;
}): Promise<bigint>;
/**
* Gets the claimable balance of ETH for the protocol from a revenue manager
* @param revenueManagerAddress - The address of the revenue manager
* @returns Promise<bigint> - The claimable balance of ETH
*/
revenueManagerProtocolBalance(revenueManagerAddress: Address): Promise<bigint>;
/**
* Gets the total number of tokens managed by a revenue manager
* @param revenueManagerAddress - The address of the revenue manager
* @returns Promise<bigint> - The total count of tokens
*/
revenueManagerTokensCount(revenueManagerAddress: Address): Promise<bigint>;
/**
* Gets all tokens created by a specific creator address
* @param params - Parameters for querying tokens by creator
* @param params.revenueManagerAddress - The address of the revenue manager
* @param params.creator - The address of the creator to query tokens for
* @param params.sortByDesc - Whether to sort the tokens by descending order
* @returns Promise<Array<{flaunch: Address, tokenId: bigint}>> - Array of token objects containing flaunch address and token ID
*/
revenueManagerAllTokensByCreator(params: {
revenueManagerAddress: Address;
creator: Address;
sortByDesc?: boolean;
}): Promise<readonly {
flaunch: `0x${string}`;
tokenId: bigint;
}[]>;
/**
* Gets all tokens currently managed by a revenue manager
* @param params - Parameters for querying tokens in manager
* @param params.revenueManagerAddress - The address of the revenue manager
* @param params.sortByDesc - Optional boolean to sort tokens in descending order (default: false)
* @returns Promise<Array<{flaunch: Address, tokenId: bigint}>> - Array of token objects containing flaunch address and token ID
*/
revenueManagerAllTokensInManager(params: {
revenueManagerAddress: Address;
sortByDesc?: boolean;
}): Promise<{
flaunch: `0x${string}`;
tokenId: bigint;
}[]>;
/**
* Gets treasury manager information including owner and permissions
* @param treasuryManagerAddress - The address of the treasury manager
* @returns Promise<{managerOwner: Address, permissions: Address}> - Treasury manager owner and permissions contract addresses
*/
treasuryManagerInfo(treasuryManagerAddress: Address): Promise<{
managerOwner: `0x${string}`;
permissions: `0x${string}`;
}>;
/**
* Gets the pool ID for a given coin
* @param coinAddress - The address of the coin
* @param version - Optional specific version to use
* @returns Promise<string> - The pool ID
*/
poolId(coinAddress: Address, version?: FlaunchVersion): Promise<`0x${string}`>;
/**
* Gets the flaunching fee for a given initial price and slippage percent
* @param params.sender - The address of the sender
* @param params.initialMarketCapUSD - The initial market cap in USD
* @param params.slippagePercent - The slippage percent
* @returns Promise<bigint> - The flaunching fee
*/
getFlaunchingFee(params: {
sender: Address;
initialMarketCapUSD: number;
slippagePercent?: number;
}): Promise<bigint>;
/**
* Calculates the ETH required to flaunch a token, takes into account the ETH for premine and the flaunching fee
* @param params.premineAmount - The amount of coins to be premined
* @param params.initialMarketCapUSD - The initial market cap in USD
* @param params.slippagePercent - The slippage percent
* @returns Promise<bigint> - The ETH required to flaunch
*/
ethRequiredToFlaunch(params: {
premineAmount: bigint;
initialMarketCapUSD: number;
slippagePercent?: number;
}): Promise<bigint>;
/**
* Gets a quote for selling an exact amount of tokens for ETH
* @param coinAddress - The address of the token to sell
* @param version - Optional specify Flaunch version, if not provided, will determine automatically
* @param amountIn - The exact amount of tokens to sell
* @param intermediatePoolKey - Optional intermediate pool key to use containing outputToken and ETH as currencies
* @returns Promise<bigint> - The expected amount of ETH to receive
*/
getSellQuoteExactInput({ coinAddress, version, amountIn, intermediatePoolKey, }: {
coinAddress: Address;
version?: FlaunchVersion;
amountIn: bigint;
intermediatePoolKey?: PoolWithHookData;
}): Promise<bigint>;
/**
* Gets a quote for buying tokens with an exact amount of ETH or inputToken
* @param coinAddress - The address of the token to buy
* @param version - Optional specify Flaunch version, if not provided, will determine automatically
* @param amountIn - The exact amount of ETH or inputToken to spend
* @param intermediatePoolKey - Optional intermediate pool key to use containing inputToken and ETH as currencies
* @param hookData - Optional hook data to use for the fleth <> coin swap. Only used when TrustedSigner is currently enabled
* @param userWallet - Optional user wallet to use for the swap. Only used when TrustedSigner is currently enabled
* @returns Promise<bigint> - The expected amount of coins to receive
*/
getBuyQuoteExactInput({ coinAddress, version, amountIn, intermediatePoolKey, hookData, userWallet, }: {
coinAddress: Address;
version?: FlaunchVersion;
amountIn: bigint;
intermediatePoolKey?: PoolWithHookData;
hookData?: Hex;
userWallet?: Address;
}): Promise<bigint>;
/**
* Gets a quote for buying an exact amount of tokens with ETH or inputToken
* @param coinAddress - The address of the token to buy
* @param version - Optional specify Flaunch version, if not provided, will determine automatically
* @param coinOut - The exact amount of tokens to receive
* @param intermediatePoolKey - Optional intermediate pool key to use containing inputToken and ETH as currencies
* @param hookData - Optional hook data to use for the fleth <> coin swap. Only used when TrustedSigner is currently enabled
* @param userWallet - Optional user wallet to use for the swap. Only used when TrustedSigner is currently enabled
* @returns Promise<bigint> - The required amount of ETH or inputToken to spend
*/
getBuyQuoteExactOutput({ coinAddress, amountOut, version, intermediatePoolKey, hookData, userWallet, }: {
coinAddress: Address;
amountOut: bigint;
version?: FlaunchVersion;
intermediatePoolKey?: PoolWithHookData;
hookData?: Hex;
userWallet?: Address;
}): Promise<bigint>;
/**
* Determines if flETH is currency0 in the pool
* @param coinAddress - The address of the coin
* @returns boolean - True if flETH is currency0, false otherwise
*/
flETHIsCurrencyZero(coinAddress: Address): boolean;
/**
* Sets a custom IPFS resolver function
* @dev this is used to resolve IPFS hash to a gateway URL
* eg: input: Qabc, output: https://ipfs.io/ipfs/Qabc
* @param resolverFn - Custom function to resolve IPFS URIs
*/
setIPFSResolver(resolverFn: (ipfsHash: string) => string): void;
/**
* Parses a transaction hash to extract PoolSwap events and return parsed swap data
* @param params - Object containing parsing parameters
* @param params.txHash - The transaction hash to parse
* @param params.version - The Flaunch version to use for parsing
* @param params.flETHIsCurrencyZero - Whether flETH is currency 0 in the pool (optional)
* @returns Parsed swap log or undefined if no PoolSwap event found.
* If flETHIsCurrencyZero is provided, returns typed swap data with BUY/SELL information.
* If flETHIsCurrencyZero is undefined, returns basic swap log without parsed delta.
*/
parseSwapTx<T extends boolean | undefined = undefined>(params: {
txHash: Hex;
version: FlaunchVersion;
flETHIsCurrencyZero?: T;
}): Promise<T extends boolean ? GenericBuySwapLog | GenericSellSwapLog | undefined : GenericBaseSwapLog | undefined>;
/**
* Verifies if a memecoin is valid for importing
* @param memecoin - The address of the memecoin to import
* @returns Promise<{ isValid: boolean; verifier: Address }> - The result of the verification
*/
tokenImporterVerifyMemecoin(memecoin: Address): Promise<{
isValid: boolean;
verifier: Address;
}>;
/**
* Gets basic coin information (total supply and decimals)
*/
getCoinInfo(coinAddress: Address): Promise<{
totalSupply: bigint;
decimals: number;
formattedTotalSupplyInDecimals: number;
}>;
/**
* Gets market context information needed for tick calculations
*/
getMarketContext(coinAddress: Address, coinDecimals: number): Promise<{
ethUsdPrice: number;
isFlethZero: boolean;
decimals0: number;
decimals1: number;
}>;
/**
* Converts market cap in USD to token price in ETH
*/
marketCapToTokenPriceEth(marketCapUsd: number, formattedTotalSupplyInDecimals: number, ethUsdPrice: number): number;
/**
* Converts token price in ETH to tick
*/
convertPriceToTick(priceEth: number, isFlethZero: boolean, decimals0: number, decimals1: number): number;
/**
* Calculates current tick from market cap if provided
*/
calculateCurrentTickFromMarketCap(currentMarketCap: string | undefined, formattedTotalSupplyInDecimals: number, marketContext: {
ethUsdPrice: number;
isFlethZero: boolean;
decimals0: number;
decimals1: number;
}): number | undefined;
calculateAddLiquidityTicks({ coinAddress, liquidityMode, minMarketCap, maxMarketCap, currentMarketCap, }: {
coinAddress: Address;
liquidityMode: LiquidityMode;
minMarketCap: string;
maxMarketCap: string;
currentMarketCap?: string;
}): Promise<{
tickLower: number;
tickUpper: number;
currentTick?: number;
coinTotalSupply: bigint;
coinDecimals: number;
}>;
checkSingleSidedAddLiquidity(params: CheckSingleSidedAddLiquidityParams): Promise<SingleSidedLiquidityInfo>;
calculateAddLiquidityAmounts(params: CalculateAddLiquidityAmountsParams): Promise<{
coinAmount: bigint;
ethAmount: bigint;
tickLower: number;
tickUpper: number;
currentTick: number;
}>;
/**
* Checks if an external memecoin has been imported to Flaunch
* @param memecoin - The address of the memecoin to check
* @returns Promise<boolean> - True if the memecoin has been imported
*/
isMemecoinImported(memecoin: Address): Promise<boolean>;
/**
* Checks if an operator is approved for all flaunch tokens of an owner
* @param version - The flaunch version to determine the correct contract address
* @param owner - The owner address to check
* @param operator - The operator address to check
* @returns Promise<boolean> - True if operator is approved for all tokens
*/
isFlaunchTokenApprovedForAll(version: FlaunchVersion, owner: Address, operator: Address): Promise<boolean>;
/**
* Determines the version for a coin, using provided version or fetching it
* @param coinAddress - The coin address
* @param version - Optional version, if not provided will be fetched
* @returns The determined version
*/
protected determineCoinVersion(coinAddress: Address, version?: FlaunchVersion): Promise<FlaunchVersion>;
/**
* Creates a pool key for the given coin and version
* @param coinAddress - The coin address
* @param version - The version to use for position manager
* @returns The ordered pool key
*/
protected createPoolKey(coinAddress: Address, version: FlaunchVersion): {
currency0: `0x${string}`;
currency1: `0x${string}`;
fee: number;
tickSpacing: number;
hooks: import("abitype").Address;
};
}
export declare class ReadWriteFlaunchSDK extends ReadFlaunchSDK {
drift: Drift<ReadWriteAdapter>;
readonly readWritePositionManager: ReadWriteFlaunchPositionManager;
readonly readWritePositionManagerV1_1: ReadWriteFlaunchPositionManagerV1_1;
readonly readWriteAnyPositionManager: ReadWriteAnyPositionManager;
readonly readWriteTokenImporter: ReadWriteTokenImporter;
readonly readWriteFeeEscrow: ReadWriteFeeEscrow;
readonly readWriteReferralEscrow: ReadWriteReferralEscrow;
readonly readWriteFlaunchZap: ReadWriteFlaunchZap;
readonly readWriteTreasuryManagerFactory: ReadWriteTreasuryManagerFactory;
readonly readWritePermit2: ReadWritePermit2;
constructor(chainId: number, drift?: Drift<ReadWriteAdapter>, publicClient?: PublicClient);
/**
* Deploys a new revenue manager
* @param params - Parameters for deploying the revenue manager
* @param params.protocolRecipient - The address of the protocol recipient
* @param params.protocolFeePercent - The percentage of the protocol fee
* @param params.permissions - The permissions for the revenue manager
* @returns Address of the deployed revenue manager
*/
deployRevenueManager(params: DeployRevenueManagerParams): Promise<Address>;
/**
* Deploys a new staking manager
* @param params - Parameters for deploying the staking manager
* @param params.managerOwner - The address of the manager owner
* @param params.stakingToken - The address of the token to be staked
* @param params.minEscrowDuration - The minimum duration (in seconds) that the creator's NFT is locked for
* @param params.minStakeDuration - The minimum duration (in seconds) that the user's tokens are locked for
* @param params.creatorSharePercent - The % share that a creator will earn from their token
* @param params.ownerSharePercent - The % share that the manager owner will earn from their token
* @param params.permissions - The permissions for the staking manager
* @returns Address of the deployed staking manager
*/
deployStakingManager(params: DeployStakingManagerParams): Promise<Address>;
/**
* Deploys a new BuyBack manager
* @param params - Parameters for deploying the BuyBack manager
* @param params.managerOwner - The address of the manager owner
* @param params.creatorSharePercent - The % share that a creator will earn from their token (0-100)
* @param params.ownerSharePercent - The % share that the manager owner will earn from their token (0-100)
* @param params.buyBackPoolKey - The Uniswap V4 pool key configuration for the buyback pool
* @param params.buyBackPoolKey.currency0 - The lower currency of the pool (sorted numerically)
* @param params.buyBackPoolKey.currency1 - The higher currency of the pool (sorted numerically)
* @param params.buyBackPoolKey.fee - The pool LP fee, capped at 1_000_000
* @param params.buyBackPoolKey.tickSpacing - Tick spacing for the pool
* @param params.buyBackPoolKey.hooks - The hooks address of the pool
* @param params.permissions - The permissions for the BuyBack manager
* @returns Address of the deployed BuyBack manager
*/
deployBuyBackManager(params: DeployBuyBackManagerParams): Promise<Address>;
/**
* Creates a new Flaunch on the specified version
* @param params - Parameters for creating the Flaunch
* @returns Transaction response
*/
flaunch(params: FlaunchParams): Promise<`0x${string}`>;
/**
* Creates a new Flaunch with IPFS metadata and optional version specification
* @param params - Parameters for creating the Flaunch with IPFS data
* @returns Transaction response
*/
flaunchIPFS(params: FlaunchIPFSParams): Promise<`0x${string}`>;
/**
* Creates a new Flaunch with revenue manager configuration
* @param params - Parameters for creating the Flaunch with revenue manager
* @throws Error if FlaunchZap is not deployed on the current chain
* @returns Transaction response
*/
flaunchWithRevenueManager(params: FlaunchWithRevenueManagerParams): Promise<`0x${string}`>;
/**
* Creates a new Flaunch with revenue manager configuration and IPFS metadata
* @param params - Parameters for creating the Flaunch with revenue manager and IPFS data
* @throws Error if FlaunchZap is not deployed on the current chain
* @returns Transaction response
*/
flaunchIPFSWithRevenueManager(params: FlaunchWithRevenueManagerIPFSParams): Promise<`0x${string}`>;
/**
* Creates a new Flaunch that splits the creator fees to the creator and a list of recipients
* @param params - Parameters for creating the Flaunch with split manager
* @returns Transaction response
*/
flaunchWithSplitManager(params: FlaunchWithSplitManagerParams): Promise<`0x${string}`>;
/**
* Creates a new Flaunch that splits the creator fees to the creator and a list of recipients, storing the token metadata on IPFS
* @param params - Parameters for creating the Flaunch with split manager including all IPFS metadata
* @returns Transaction response
*/
flaunchIPFSWithSplitManager(params: FlaunchWithSplitManagerIPFSParams): Promise<`0x${string}`>;
/**
* Creates a new Flaunch with AnyPositionManager for external coins
* @param params - Parameters for creating the Flaunch with AnyPositionManager
* @returns Transaction response
*/
anyFlaunch(params: AnyFlaunchParams): Promise<`0x${string}`>;
/**
* Gets the balance of a specific coin for the connected wallet
* @param coinAddress - The address of the coin to check
* @returns Promise<bigint> - The balance of the coin
*/
coinBalance(coinAddress: Address): Promise<bigint>;
/**
* Buys a coin with ETH or custom inputToken via intermediatePoolKey
* @param params - Parameters for buying the coin including amount, slippage, and referrer
* @param version - Optional specific version to use. If not provided, will determine automatically
* @returns Transaction response for the buy operation
*/
buyCoin(params: BuyCoinParams, version?: FlaunchVersion): Promise<`0x${string}`>;
/**
* Sells a coin for ETH
* @param params - Parameters for selling the coin including amount, slippage, permit data, and referrer
* @param version - Optional specific version to use. If not provided, will determine automatically
* @returns Transaction response for the sell operation
*/
sellCoin(params: SellCoinParams, version?: FlaunchVersion): Promise<`0x${string}`>;
/**
* Gets the typed data for a Permit2 signature
* @param coinAddress - The address of the coin to permit
* @param deadline - Optional deadline for the permit (defaults to 10 years)
* @returns The typed data object for signing
*/
getPermit2TypedData(coinAddress: Address, deadline?: bigint): Promise<{
typedData: {
primaryType: string;
domain: {
name: string;
chainId: number;
verifyingContract: import("abitype").Address;
};
types: typeof import("utils/universalRouter").PERMIT_TYPES;
message: PermitSingle;
};
permitSingle: PermitSingle;
}>;
/**
* Gets the current Permit2 allowance and nonce for a coin
* @param coinAddress - The address of the coin to check
* @returns Promise<{allowance: bigint, nonce: bigint}> - Current allowance and nonce
*/
getPermit2AllowanceAndNonce(coinAddress: Address): Promise<{
allowance: bigint;
nonce: number;
}>;
/**
* Gets the allowance of an ERC20 token to Permit2 contract. Flaunch coins automatically have infinite approval for Permit2.
* this function is for external tokens.
* @param coinAddress - The address of the coin to check
* @returns Promise<bigint> - The allowance of the coin to Permit2
*/
getERC20AllowanceToPermit2(coinAddress: Address): Promise<bigint>;
/**
* Sets the allowance of an ERC20 token to Permit2 contract. Flaunch coins automatically have infinite approval for Permit2.
* this function is for external tokens.
* @param coinAddress - The address of the coin to approve
* @param amount - The amount of the token to approve
* @returns Promise<Hex> - The transaction hash
*/
setERC20AllowanceToPermit2(coinAddress: Address, amount: bigint): Promise<`0x${string}`>;
/**
* Withdraws the creator's share of the revenue
* @param params - Parameters for withdrawing the creator's share of the revenue
* @param params.recipient - The address to withdraw the revenue to. Defaults to the connected wallet
* @param params.isV1 - Optional boolean to withdraw from V1. V1.1 & AnyPositionManager use the same FeeEscrow contract
* @returns Transaction response
*/
withdrawCreatorRevenue(params: {
recipient?: Address;
isV1?: boolean;
}): Promise<`0x${string}`>;
/**
* Claims the referral balance for a given recipient
* @param coins - The addresses of the coins to claim
* @param recipient - The address of the recipient to claim the balance for
* @returns Transaction response
*/
claimReferralBalance(coins: Address[], recipient: Address): Promise<`0x${string}`>;
/**
* Claims the protocol's share of the revenue
* @param params - Parameters for claiming the protocol's share of the revenue
* @returns Transaction response
*/
revenueManagerProtocolClaim(params: {
revenueManagerAddress: Address;
}): Promise<`0x${string}`>;
/**
* Claims the total creator's share of the revenue from a revenue manager
* @param params - Parameters for claiming the creator's share of the revenue
* @returns Transaction response
*/
revenueManagerCreatorClaim(params: {
revenueManagerAddress: Address;
}): Promise<`0x${string}`>;
/**
* Claims the creator's share of the revenue from specific flaunch tokens
* @param params - Parameters for claiming the creator's share of the revenue
* @returns Transaction response
*/
revenueManagerCreatorClaimForTokens(params: {
revenueManagerAddress: Address;
flaunchTokens: {
flaunch: Address;
tokenId: bigint;
}[];
}): Promise<`0x${string}`>;
/**
* Sets the permissions contract address for a treasury manager
* @param treasuryManagerAddress - The address of the treasury manager
* @param permissions - The permissions enum value to set
* @returns Transaction response
*/
treasuryManagerSetPermissions(treasuryManagerAddress: Address, permissions: Permissions): Promise<`0x${string}`>;
/**
* Transfers the ownership of a treasury manager to a new address
* @param treasuryManagerAddress - The address of the treasury manager
* @param newManagerOwner - The address of the new manager owner
* @returns Transaction response
*/
treasuryManagerTransferOwnership(treasuryManagerAddress: Address, newManagerOwner: Address): Promise<`0x${string}`>;
/**
* Sets approval for all flaunch tokens to an operator
* @param version - The flaunch version to determine the correct contract address
* @param operator - The operator address to approve/revoke
* @param approved - Whether to approve or revoke approval
* @returns Transaction response
*/
setFlaunchTokenApprovalForAll(version: FlaunchVersion, operator: Address, approved: boolean): Promise<`0x${string}`>;
/**
* Adds an existing flaunch token to a treasury manager. NFT approval must be given prior to calling this function.
* @param treasuryManagerAddress - The address of the treasury manager
* @param version - The flaunch version to determine the correct contract address
* @param tokenId - The token ID to deposit
* @param creator - Optional creator address. If not provided, uses the connected wallet address
* @param data - Optional additional data for the deposit (defaults to empty bytes)
* @returns Transaction response
*/
addToTreasuryManager(treasuryManagerAddress: Address, version: FlaunchVersion, tokenId: bigint, creator?: Address, data?: `0x${string}`): Promise<`0x${string}`>;
/**
* Imports a memecoin into the TokenImporter
* @param params.coinAddress - The address of the memecoin to import
* @param params.creatorFeeAllocationPercent - The creator fee allocation percentage
* @param params.initialMarketCapUSD - The initial market cap in USD
* @param params.verifier - Optional verifier to use for importing the memecoin
* @returns Transaction response
*/
importMemecoin(params: ImportMemecoinParams): Promise<`0x${string}`>;
/**
* Gets the calls needed to add liquidity to flaunch or imported coins
* @param params - Parameters for adding liquidity
* @returns Array of calls with descriptions
*/
getAddLiquidityCalls(params: GetAddLiquidityCallsParams): Promise<CallWithDescription[]>;
/**
* Gets the calls needed to import a memecoin to Flaunch and add liquidity to AnyPositionManager as a batch
* @param params - Parameters for importing and adding liquidity with market cap constraints
* @returns Array of calls with descriptions
*
* @example
* ```typescript
* const calls = await sdk.getImportAndAddLiquidityCalls({
* coinAddress: "0x...",
* verifier: Verifier.CLANKER,
* creatorFeeAllocationPercent: 5,
* liquidityMode: LiquidityMode.CONCENTRATED,
* coinOrEthInputAmount: parseEther("1"),
* inputToken: "eth",
* minMarketCap: "10000",
* maxMarketCap: "100000",
* initialMarketCapUSD: 50000
* });
* ```
*/
getImportAndAddLiquidityCalls(params: ImportAndAddLiquidityWithMarketCap): Promise<CallWithDescription[]>;
/**
* Gets the calls needed to import a memecoin to Flaunch and add liquidity to AnyPositionManager as a batch
* @param params - Parameters for importing and adding liquidity with price constraints
* @returns Array of calls with descriptions
*
* @example
* ```typescript
* const calls = await sdk.getImportAndAddLiquidityCalls({
* coinAddress: "0x...",
* verifier: Verifier.CLANKER,
* creatorFeeAllocationPercent: 5,
* liquidityMode: LiquidityMode.CONCENTRATED,
* coinOrEthInputAmount: parseEther("1"),
* inputToken: "eth",
* minPriceUSD: "0.0001",
* maxPriceUSD: "0.001",
* initialPriceUSD: 0.0005
* });
* ```
*/
getImportAndAddLiquidityCalls(params: ImportAndAddLiquidityWithPrice): Promise<CallWithDescription[]>;
/**
* Gets the calls needed to import a memecoin to Flaunch and add liquidity to AnyPositionManager as a batch
* @param params - Parameters for importing and adding liquidity with exact amounts
* @returns Array of calls with descriptions
*
* @example
* ```typescript
* const calls = await sdk.getImportAndAddLiquidityCalls({
* coinAddress: "0x...",
* verifier: Verifier.CLANKER,
* creatorFeeAllocationPercent: 5,
* coinAmount: parseEther("1000"),
* flethAmount: parseEther("0.5"),
* tickLower: -887220,
* tickUpper: 887220,
* currentTick: 0
* });
* ```
*/
getImportAndAddLiquidityCalls(params: ImportAndAddLiquidityWithExactAmounts): Promise<CallWithDescription[]>;
/**
* Gets the calls needed to add single-sided liquidity in coin from current tick to infinity
* @param params - Parameters for adding single-sided liquidity
* @returns Array of calls with descriptions
*/
getSingleSidedCoinAddLiquidityCalls(params: GetSingleSidedCoinAddLiquidityCallsParams): Promise<CallWithDescription[]>;
/**
* Gets the calls needed to import a memecoin to Flaunch and single-sided liquidity in coin (from current tick to infinity) to AnyPositionManager as a batch
* @param params - Parameters for importing and adding liquidity with initial market cap
* @returns Array of calls with descriptions
*
* @example
* ```typescript
* const calls = await sdk.getImportAndSingleSidedCoinAddLiquidityCalls({
* coinAddress: "0x...",
* verifier: Verifier.CLANKER,
* creatorFeeAllocationPercent: 5,
* coinAmount: parseEther("1000"),
* initialMarketCapUSD: 50000
* });
* ```
*/
getImportAndSingleSidedCoinAddLiquidityCalls(params: ImportAndSingleSidedCoinAddLiquidityWithMarketCap): Promise<CallWithDescription[]>;
/**
* Gets the calls needed to import a memecoin to Flaunch and single-sided liquidity in coin (from current tick to infinity) to AnyPositionManager as a batch
* @param params - Parameters for importing and adding liquidity with initial market cap
* @returns Array of calls with descriptions
*
* @example
* ```typescript
* const calls = await sdk.getImportAndSingleSidedCoinAddLiquidityCalls({
* coinAddress: "0x...",
* verifier: Verifier.CLANKER,
* creatorFeeAllocationPercent: 5,
* coinAmount: parseEther("1000"),
* initialMarketCapUSD: 50000,
* tokenSupply: 1000000e6 // 1 million tokens (6 decimals)
* });
* ```
*/
getImportAndSingleSidedCoinAddLiquidityCalls(params: ImportAndSingleSidedCoinAddLiquidityWithMarketCap & {
tokenSupply: bigint;
}): Promise<CallWithDescription[]>;
/**
* Gets the calls needed to import a memecoin to Flaunch and single-sided liquidity in coin (from current tick to infinity) to AnyPositionManager as a batch
* @param params - Parameters for importing and adding liquidity with initial price
* @returns Array of calls with descriptions
*
* @example
* ```typescript
* const calls = await sdk.getImportAndSingleSidedCoinAddLiquidityCalls({
* coinAddress: "0x...",
* verifier: Verifier.CLANKER,
* creatorFeeAllocationPercent: 5,
* coinAmount: parseEther("1000"),
* initialPriceUSD: 0.001
* });
* ```
*/
getImportAndSingleSidedCoinAddLiquidityCalls(params: ImportAndSingleSidedCoinAddLiquidityWithPrice): Promise<CallWithDescription[]>;
/**
* Gets the calls needed to import a memecoin to Flaunch and single-sided liquidity in coin (from current tick to infinity) to AnyPositionManager as a batch
* @param params - Parameters for importing and adding liquidity with initial price
* @returns Array of calls with descriptions
*
* @example
* ```typescript
* const cal