test-raydium-sdk-v2
Version:
An SDK for building applications on top of Raydium.
1 lines • 351 kB
Source Map (JSON)
{"version":3,"sources":["../../../src/raydium/utils1216/utils1216.ts","../../../src/common/logger.ts","../../../src/common/txTool/txTool.ts","../../../src/common/txTool/txType.ts","../../../src/common/txTool/txUtils.ts","../../../src/common/txTool/lookupTable.ts","../../../src/common/accountInfo.ts","../../../src/common/utility.ts","../../../src/module/amount.ts","../../../src/common/bignumber.ts","../../../node_modules/decimal.js/decimal.mjs","../../../src/module/token.ts","../../../src/common/pubKey.ts","../../../src/raydium/token/constant.ts","../../../src/module/fraction.ts","../../../src/module/formatter.ts","../../../src/module/price.ts","../../../src/module/currency.ts","../../../src/module/percent.ts","../../../src/common/lodash.ts","../../../src/common/programId.ts","../../../src/common/pda.ts","../../../src/common/transfer.ts","../../../src/raydium/moduleBase.ts","../../../src/marshmallow/index.ts","../../../src/marshmallow/buffer-layout.ts"],"sourcesContent":["import { TOKEN_PROGRAM_ID } from \"@solana/spl-token\";\nimport { Connection, PublicKey, Signer, Transaction, TransactionInstruction } from \"@solana/web3.js\";\nimport BN from \"bn.js\";\nimport ModuleBase from \"../moduleBase\";\nimport { findProgramAddress, forecastTransactionSize, getMultipleAccountsInfo } from \"@/common\";\nimport { Token } from \"@/module\";\nimport { blob, publicKey, seq, struct, u64, u8 } from \"@/marshmallow\";\n\nexport interface SHOW_INFO {\n programId: PublicKey;\n poolId: PublicKey;\n ammId: PublicKey;\n ownerAccountId: PublicKey;\n snapshotLpAmount: BN;\n\n openTime: number;\n endTime: number;\n\n project: typeof Utils1216.VERSION_PROJECT[number];\n\n canClaim: boolean;\n canClaimErrorType: canClaimErrorType;\n\n tokenInfo: {\n mintAddress: PublicKey;\n mintVault: PublicKey;\n mintDecimals: number;\n perLpLoss: BN;\n debtAmount: BN;\n }[];\n}\n\nexport type canClaimErrorType = \"outOfOperationalTime\" | \"alreadyClaimIt\" | undefined;\n\nexport default class Utils1216 extends ModuleBase {\n static CLAIMED_NUM = 3;\n static POOL_LAYOUT = struct([\n blob(8),\n u8(\"bump\"),\n u8(\"status\"),\n u64(\"openTime\"),\n u64(\"endTime\"),\n publicKey(\"ammId\"),\n\n seq(\n struct([\n u8(\"mintDecimals\"),\n publicKey(\"mintAddress\"),\n publicKey(\"mintVault\"),\n u64(\"perLpLoss\"),\n u64(\"totalClaimedAmount\"),\n ]),\n Utils1216.CLAIMED_NUM,\n \"tokenInfo\",\n ),\n seq(u64(), 10, \"padding\"),\n ]);\n\n static OWNER_LAYOUT = struct([\n blob(8),\n u8(\"bump\"),\n u8(\"version\"),\n publicKey(\"poolId\"),\n publicKey(\"owner\"),\n u64(\"lpAmount\"),\n\n seq(\n struct([publicKey(\"mintAddress\"), u64(\"debtAmount\"), u64(\"claimedAmount\")]),\n Utils1216.CLAIMED_NUM,\n \"tokenInfo\",\n ),\n seq(u64(), 4, \"padding\"),\n ]);\n\n static DEFAULT_POOL_ID = [\n \"58oQChx4yWmvKdwLLZzBi4ChoCc2fqCUWBkwMihLYQo2\",\n \"6UmmUiYoBjSrhakAobJw8BvkmJtDVxaeBtbt7rxWo1mg\",\n \"AVs9TA4nWDzfPJE9gGVNJMVhcQy3V9PGazuz33BfG2RA\",\n \"DVa7Qmb5ct9RCpaU7UTpSaf3GVMYz17vNVU67XpdCRut\",\n \"7XawhbbxtsRcQA8KTkHT9f9nc6d69UwqCDh6U5EEbEmX\",\n \"6a1CsrpeZubDjEJE9s1CMVheB6HWM5d7m1cj2jkhyXhj\",\n \"EoNrn8iUhwgJySD1pHu8Qxm5gSQqLK3za4m8xzD2RuEb\",\n \"AceAyRTWt4PyB2pHqf2qhDgNZDtKVNaxgL8Ru3V4aN1P\",\n \"6tmFJbMk5yVHFcFy7X2K8RwHjKLr6KVFLYXpgpBNeAxB\",\n ].map((i) => new PublicKey(i));\n\n static SEED_CONFIG = {\n pool: {\n id: Buffer.from(\"pool_seed\", \"utf8\"),\n },\n owner: {\n id: Buffer.from(\"user_claim_seed\", \"utf8\"),\n },\n };\n\n static VERSION_PROJECT = [undefined, \"Francium\", \"Tulip\", \"Larix\"] as const;\n\n // pda\n static getPdaPoolId(\n programId: PublicKey,\n ammId: PublicKey,\n ): {\n publicKey: PublicKey;\n nonce: number;\n } {\n return findProgramAddress([Utils1216.SEED_CONFIG.pool.id, ammId.toBuffer()], programId);\n }\n\n static getPdaOwnerId(\n programId: PublicKey,\n poolId: PublicKey,\n owner: PublicKey,\n version: number,\n ): {\n publicKey: PublicKey;\n nonce: number;\n } {\n return findProgramAddress(\n [\n Utils1216.SEED_CONFIG.owner.id,\n poolId.toBuffer(),\n owner.toBuffer(),\n // new BN(version).toBuffer()\n Buffer.from(new BN(version).toArray()),\n ],\n programId,\n );\n }\n\n static async getAllInfo({\n connection,\n programId,\n poolIds,\n wallet,\n chainTime,\n }: {\n connection: Connection;\n programId: PublicKey;\n poolIds: PublicKey[];\n wallet: PublicKey;\n chainTime: number;\n }): Promise<SHOW_INFO[]> {\n if (poolIds.length === 0) return [];\n\n const allPoolPda = poolIds.map((id) => Utils1216.getPdaPoolId(programId, id).publicKey);\n\n const allOwnerPda: PublicKey[] = [];\n for (let itemVersion = 0; itemVersion < Utils1216.VERSION_PROJECT.length; itemVersion++) {\n allOwnerPda.push(\n ...allPoolPda.map((id) => Utils1216.getPdaOwnerId(programId, id, wallet, itemVersion).publicKey),\n );\n }\n\n const pdaInfo = await getMultipleAccountsInfo(connection, [...allPoolPda, ...allOwnerPda]);\n\n const info: SHOW_INFO[] = [];\n for (let index = 0; index < pdaInfo.length; index++) {\n const version = Math.floor(index / poolIds.length);\n const i = index % poolIds.length;\n\n const itemPoolId = allPoolPda[i];\n const itemOwnerId = allOwnerPda[index];\n const itemPoolInfoS = pdaInfo[i];\n const itemOwnerInfoS = pdaInfo[poolIds.length + index];\n if (!(itemPoolInfoS && itemOwnerInfoS)) continue;\n if (\n itemPoolInfoS.data.length !== Utils1216.POOL_LAYOUT.span ||\n itemOwnerInfoS.data.length !== Utils1216.OWNER_LAYOUT.span\n )\n continue;\n\n const itemPoolInfo = Utils1216.POOL_LAYOUT.decode(itemPoolInfoS.data);\n const itemOwnerInfo = Utils1216.OWNER_LAYOUT.decode(itemOwnerInfoS.data);\n\n const openTime = itemPoolInfo.openTime.toNumber();\n const endTime = itemPoolInfo.endTime.toNumber();\n\n const hasCanClaimToken =\n itemOwnerInfo.tokenInfo.map((i) => i.debtAmount.gt(new BN(0))).filter((i) => !i).length !== 3;\n const inCanClaimTime = chainTime > openTime && chainTime < endTime && itemPoolInfo.status === 1;\n\n const canClaim = hasCanClaimToken && inCanClaimTime;\n\n info.push({\n programId,\n poolId: itemPoolId,\n ammId: itemPoolInfo.ammId,\n ownerAccountId: itemOwnerId,\n snapshotLpAmount: itemOwnerInfo.lpAmount,\n\n project: Utils1216.VERSION_PROJECT[version],\n\n openTime,\n endTime,\n\n canClaim,\n canClaimErrorType: !hasCanClaimToken ? \"alreadyClaimIt\" : !inCanClaimTime ? \"outOfOperationalTime\" : undefined,\n\n tokenInfo: itemPoolInfo.tokenInfo.map((itemPoolToken, i) => ({\n mintAddress: itemPoolToken.mintAddress,\n mintVault: itemPoolToken.mintVault,\n mintDecimals: itemPoolToken.mintDecimals,\n perLpLoss: itemPoolToken.perLpLoss,\n debtAmount: itemOwnerInfo.tokenInfo[i].debtAmount.add(itemOwnerInfo.tokenInfo[i].claimedAmount),\n })),\n });\n }\n\n return info;\n }\n\n public async makeClaimTransaction({\n poolInfo,\n ownerInfo,\n }: {\n connection: Connection;\n poolInfo: SHOW_INFO;\n ownerInfo: {\n wallet?: PublicKey;\n associatedOnly: boolean;\n };\n }): Promise<\n {\n transaction: Transaction;\n signer: Signer[];\n }[]\n > {\n if (!ownerInfo.wallet) this.scope.checkOwner();\n const txBuilder = this.createTxBuilder();\n const wallet = ownerInfo.wallet || this.scope.ownerPubKey;\n\n const ownerVaultList: PublicKey[] = [];\n for (const itemToken of poolInfo.tokenInfo) {\n const { account, instructionParams } = await this.scope.account.getOrCreateTokenAccount({\n mint: itemToken.mintAddress,\n owner: this.scope.ownerPubKey,\n notUseTokenAccount: itemToken.mintAddress.equals(Token.WSOL.mint),\n createInfo: {\n payer: wallet,\n amount: 0,\n },\n skipCloseAccount: !itemToken.mintAddress.equals(Token.WSOL.mint),\n\n associatedOnly: itemToken.mintAddress.equals(Token.WSOL.mint) ? false : ownerInfo.associatedOnly,\n });\n instructionParams && txBuilder.addInstruction(instructionParams);\n ownerVaultList.push(account!);\n }\n\n txBuilder.addInstruction({\n instructions: [\n Utils1216.makeClaimInstruction({\n programId: poolInfo.programId,\n poolInfo,\n ownerInfo: {\n wallet,\n ownerPda: poolInfo.ownerAccountId,\n claimAddress: ownerVaultList,\n },\n }),\n ],\n });\n const { transaction, signers } = txBuilder.build();\n\n return [\n {\n transaction,\n signer: signers,\n },\n ];\n }\n\n public async makeClaimAllTransaction({\n poolInfos,\n ownerInfo,\n }: {\n poolInfos: SHOW_INFO[];\n ownerInfo: {\n wallet?: PublicKey;\n associatedOnly: boolean;\n };\n }): Promise<\n {\n transaction: Transaction;\n signer: Signer[];\n }[]\n > {\n const txBuilder = this.createTxBuilder();\n const wallet = ownerInfo.wallet || this.scope.ownerPubKey;\n\n const tempNewVault: { [mint: string]: PublicKey } = {};\n\n for (const poolInfo of poolInfos) {\n const ownerVaultList: PublicKey[] = [];\n for (const itemToken of poolInfo.tokenInfo) {\n const { account: tempVault, instructionParams } = await this.scope.account.getOrCreateTokenAccount({\n mint: itemToken.mintAddress,\n owner: this.scope.ownerPubKey,\n notUseTokenAccount: itemToken.mintAddress.equals(Token.WSOL.mint),\n createInfo: {\n payer: wallet,\n amount: 0,\n },\n skipCloseAccount: !itemToken.mintAddress.equals(Token.WSOL.mint),\n\n associatedOnly: itemToken.mintAddress.equals(Token.WSOL.mint) ? false : ownerInfo.associatedOnly,\n });\n instructionParams && txBuilder.addInstruction(instructionParams);\n\n if (tempVault) {\n tempNewVault[itemToken.mintAddress.toString()] = tempVault;\n ownerVaultList.push(tempVault);\n }\n }\n\n txBuilder.addInstruction({\n instructions: [\n Utils1216.makeClaimInstruction({\n programId: poolInfo.programId,\n poolInfo,\n ownerInfo: {\n wallet,\n ownerPda: poolInfo.ownerAccountId,\n claimAddress: ownerVaultList,\n },\n }),\n ],\n });\n }\n\n const { transaction, signers } = txBuilder.build();\n const instructions = txBuilder.allInstructions;\n\n if (forecastTransactionSize(instructions, [wallet, ...signers.map((s) => s.publicKey)])) {\n return [\n {\n transaction,\n signer: signers,\n },\n ];\n } else {\n return [\n {\n transaction: new Transaction().add(...instructions.slice(0, txBuilder.AllTxData.instructions.length - 1)),\n signer: signers,\n },\n {\n transaction: new Transaction().add(...instructions.slice(txBuilder.AllTxData.instructions.length - 1)),\n signer: [],\n },\n { transaction: new Transaction().add(...txBuilder.AllTxData.endInstructions), signer: [] },\n ];\n }\n }\n\n static makeClaimInstruction({\n programId,\n poolInfo,\n ownerInfo,\n }: {\n programId: PublicKey;\n\n poolInfo: SHOW_INFO;\n ownerInfo: {\n wallet: PublicKey;\n ownerPda: PublicKey;\n claimAddress: PublicKey[];\n };\n }): TransactionInstruction {\n const dataLayout = struct([]);\n\n const keys = [\n { pubkey: ownerInfo.wallet, isSigner: true, isWritable: true },\n { pubkey: poolInfo.poolId, isSigner: false, isWritable: true },\n { pubkey: ownerInfo.ownerPda, isSigner: false, isWritable: true },\n\n ...ownerInfo.claimAddress.map((i) => ({ pubkey: i, isSigner: false, isWritable: true })),\n ...poolInfo.tokenInfo.map(({ mintVault }) => ({ pubkey: mintVault, isSigner: false, isWritable: true })),\n\n { pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },\n ];\n\n const data = Buffer.alloc(dataLayout.span);\n dataLayout.encode({}, data);\n const aData = Buffer.from([...[10, 66, 208, 184, 161, 6, 191, 98], ...data]);\n\n return new TransactionInstruction({\n keys,\n programId,\n data: aData,\n });\n }\n}\n","import { get, set } from \"lodash\";\nimport dayjs from \"dayjs\";\nimport utc from \"dayjs/plugin/utc\";\ndayjs.extend(utc);\n\nexport type ModuleName = \"Common.Api\";\n\nexport enum LogLevel {\n Error,\n Warning,\n Info,\n Debug,\n}\nexport class Logger {\n private logLevel: LogLevel;\n private name: string;\n constructor(params: { name: string; logLevel?: LogLevel }) {\n this.logLevel = params.logLevel !== undefined ? params.logLevel : LogLevel.Error;\n this.name = params.name;\n }\n\n set level(logLevel: LogLevel) {\n this.logLevel = logLevel;\n }\n get time(): string {\n return dayjs().utc().format(\"YYYY/MM/DD HH:mm:ss UTC\");\n }\n get moduleName(): string {\n return this.name;\n }\n\n private isLogLevel(level: LogLevel): boolean {\n return level <= this.logLevel;\n }\n\n public error(...props): Logger {\n if (!this.isLogLevel(LogLevel.Error)) return this;\n console.error(this.time, this.name, \"sdk logger error\", ...props);\n return this;\n }\n\n public logWithError(...props): Logger {\n // this.error(...props)\n const msg = props.map((arg) => (typeof arg === \"object\" ? JSON.stringify(arg) : arg)).join(\", \");\n throw new Error(msg);\n }\n\n public warning(...props): Logger {\n if (!this.isLogLevel(LogLevel.Warning)) return this;\n console.warn(this.time, this.name, \"sdk logger warning\", ...props);\n return this;\n }\n\n public info(...props): Logger {\n if (!this.isLogLevel(LogLevel.Info)) return this;\n console.info(this.time, this.name, \"sdk logger info\", ...props);\n return this;\n }\n\n public debug(...props): Logger {\n if (!this.isLogLevel(LogLevel.Debug)) return this;\n console.debug(this.time, this.name, \"sdk logger debug\", ...props);\n return this;\n }\n}\n\nconst moduleLoggers: { [key in ModuleName]?: Logger } = {};\nconst moduleLevels: { [key in ModuleName]?: LogLevel } = {};\n\nexport function createLogger(moduleName: string): Logger {\n let logger = get(moduleLoggers, moduleName);\n if (!logger) {\n // default level is error\n const logLevel = get(moduleLevels, moduleName);\n\n logger = new Logger({ name: moduleName, logLevel });\n set(moduleLoggers, moduleName, logger);\n }\n\n return logger;\n}\n\nexport function setLoggerLevel(moduleName: string, level: LogLevel): void {\n set(moduleLevels, moduleName, level);\n\n const logger = get(moduleLoggers, moduleName);\n if (logger) logger.level = level;\n}\n","import {\n Connection,\n PublicKey,\n sendAndConfirmTransaction,\n Signer,\n Transaction,\n TransactionInstruction,\n TransactionMessage,\n VersionedTransaction,\n} from \"@solana/web3.js\";\nimport axios from \"axios\";\n\nimport { SignAllTransactions, ComputeBudgetConfig } from \"@/raydium/type\";\nimport { TxVersion } from \"./txType\";\nimport { Owner } from \"../owner\";\nimport { getRecentBlockHash, addComputeBudget, checkLegacyTxSize, checkV0TxSize, printSimulate } from \"./txUtils\";\nimport { CacheLTA, getMultipleLookupTableInfo, LOOKUP_TABLE_CACHE } from \"./lookupTable\";\n\ninterface SolanaFeeInfo {\n min: number;\n max: number;\n avg: number;\n priorityTx: number;\n nonVotes: number;\n priorityRatio: number;\n avgCuPerBlock: number;\n blockspaceUsageRatio: number;\n}\ntype SolanaFeeInfoJson = {\n \"1\": SolanaFeeInfo;\n \"5\": SolanaFeeInfo;\n \"15\": SolanaFeeInfo;\n};\n\ninterface TxBuilderInit {\n connection: Connection;\n feePayer: PublicKey;\n owner?: Owner;\n signAllTransactions?: SignAllTransactions;\n}\n\nexport interface AddInstructionParam {\n addresses?: Record<string, PublicKey>;\n instructions?: TransactionInstruction[];\n endInstructions?: TransactionInstruction[];\n lookupTableAddress?: string[];\n signers?: Signer[];\n instructionTypes?: string[];\n endInstructionTypes?: string[];\n}\n\nexport interface TxBuildData<T = Record<string, any>> {\n builder: TxBuilder;\n transaction: Transaction;\n instructionTypes: string[];\n signers: Signer[];\n execute: () => Promise<{ txId: string; signedTx: Transaction }>;\n extInfo: T;\n}\n\nexport interface TxV0BuildData<T = Record<string, any>> extends Omit<TxBuildData<T>, \"transaction\" | \"execute\"> {\n builder: TxBuilder;\n transaction: VersionedTransaction;\n buildProps?: {\n lookupTableCache?: CacheLTA;\n lookupTableAddress?: string[];\n };\n execute: () => Promise<{ txId: string; signedTx: VersionedTransaction }>;\n}\n\nexport interface ExecuteParam {\n sequentially: boolean;\n onTxUpdate?: (completeTxs: { txId: string; status: \"success\" | \"error\" | \"sent\" }[]) => void;\n}\nexport interface MultiTxBuildData<T = Record<string, any>> {\n builder: TxBuilder;\n transactions: Transaction[];\n instructionTypes: string[];\n signers: Signer[][];\n execute: (executeParams?: ExecuteParam) => Promise<{ txIds: string[]; signedTxs: Transaction[] }>;\n extInfo: T;\n}\n\nexport interface MultiTxV0BuildData<T = Record<string, any>>\n extends Omit<MultiTxBuildData<T>, \"transactions\" | \"execute\"> {\n builder: TxBuilder;\n transactions: VersionedTransaction[];\n buildProps?: {\n lookupTableCache?: CacheLTA;\n lookupTableAddress?: string[];\n };\n execute: (executeParams?: ExecuteParam) => Promise<{ txIds: string[]; signedTxs: VersionedTransaction[] }>;\n}\n\nexport type MakeMultiTxData<T = TxVersion.LEGACY, O = Record<string, any>> = T extends TxVersion.LEGACY\n ? MultiTxBuildData<O>\n : MultiTxV0BuildData<O>;\n\nexport type MakeTxData<T = TxVersion.LEGACY, O = Record<string, any>> = T extends TxVersion.LEGACY\n ? TxBuildData<O>\n : TxV0BuildData<O>;\n\nexport class TxBuilder {\n private connection: Connection;\n private owner?: Owner;\n private instructions: TransactionInstruction[] = [];\n private endInstructions: TransactionInstruction[] = [];\n private lookupTableAddress: string[] = [];\n private signers: Signer[] = [];\n private instructionTypes: string[] = [];\n private endInstructionTypes: string[] = [];\n private feePayer: PublicKey;\n private signAllTransactions?: SignAllTransactions;\n\n constructor(params: TxBuilderInit) {\n this.connection = params.connection;\n this.feePayer = params.feePayer;\n this.signAllTransactions = params.signAllTransactions;\n this.owner = params.owner;\n }\n\n get AllTxData(): {\n instructions: TransactionInstruction[];\n endInstructions: TransactionInstruction[];\n signers: Signer[];\n instructionTypes: string[];\n endInstructionTypes: string[];\n lookupTableAddress: string[];\n } {\n return {\n instructions: this.instructions,\n endInstructions: this.endInstructions,\n signers: this.signers,\n instructionTypes: this.instructionTypes,\n endInstructionTypes: this.endInstructionTypes,\n lookupTableAddress: this.lookupTableAddress,\n };\n }\n\n get allInstructions(): TransactionInstruction[] {\n return [...this.instructions, ...this.endInstructions];\n }\n\n public async getComputeBudgetConfig(): Promise<ComputeBudgetConfig | undefined> {\n const json = (\n await axios.get<SolanaFeeInfoJson>(`https://solanacompass.com/api/fees?cacheFreshTime=${5 * 60 * 1000}`)\n ).data;\n const { avg } = json?.[15] ?? {};\n if (!avg) return undefined;\n return {\n units: 600000,\n microLamports: Math.min(Math.ceil((avg * 1000000) / 600000), 25000),\n };\n }\n\n public addCustomComputeBudget(config?: ComputeBudgetConfig) {\n if (config) {\n const { instructions, instructionTypes } = addComputeBudget(config);\n this.instructions.unshift(...instructions);\n this.instructionTypes.unshift(...instructionTypes);\n return true;\n }\n return false;\n }\n\n public async calComputeBudget({\n config: propConfig,\n defaultIns,\n }: {\n config?: ComputeBudgetConfig;\n defaultIns?: TransactionInstruction[];\n }): Promise<void> {\n try {\n const config = propConfig || (await this.getComputeBudgetConfig());\n if (this.addCustomComputeBudget(config)) return;\n defaultIns && this.instructions.unshift(...defaultIns);\n } catch {\n defaultIns && this.instructions.unshift(...defaultIns);\n }\n }\n\n public addInstruction({\n instructions = [],\n endInstructions = [],\n signers = [],\n instructionTypes = [],\n endInstructionTypes = [],\n lookupTableAddress = [],\n }: AddInstructionParam): TxBuilder {\n this.instructions.push(...instructions);\n this.endInstructions.push(...endInstructions);\n this.signers.push(...signers);\n this.instructionTypes.push(...instructionTypes);\n this.endInstructionTypes.push(...endInstructionTypes);\n this.lookupTableAddress.push(...lookupTableAddress.filter((address) => address !== PublicKey.default.toString()));\n return this;\n }\n\n public async versionBuild<O = Record<string, any>>({\n txVersion,\n extInfo,\n }: {\n txVersion?: TxVersion;\n extInfo?: O;\n }): Promise<MakeTxData<TxVersion.LEGACY, O> | MakeTxData<TxVersion.V0, O>> {\n if (txVersion === TxVersion.V0) return (await this.buildV0({ ...(extInfo || {}) })) as MakeTxData<TxVersion.V0, O>;\n return this.build<O>(extInfo) as MakeTxData<TxVersion.LEGACY, O>;\n }\n\n public build<O = Record<string, any>>(extInfo?: O): MakeTxData<TxVersion.LEGACY, O> {\n const transaction = new Transaction();\n if (this.allInstructions.length) transaction.add(...this.allInstructions);\n transaction.feePayer = this.feePayer;\n\n return {\n builder: this,\n transaction,\n signers: this.signers,\n instructionTypes: [...this.instructionTypes, ...this.endInstructionTypes],\n execute: async () => {\n const recentBlockHash = await getRecentBlockHash(this.connection);\n transaction.recentBlockhash = recentBlockHash;\n if (this.signers.length) transaction.sign(...this.signers);\n printSimulate([transaction]);\n if (this.owner?.isKeyPair) {\n return {\n txId: await sendAndConfirmTransaction(this.connection, transaction, this.signers),\n signedTx: transaction,\n };\n }\n if (this.signAllTransactions) {\n const txs = await this.signAllTransactions([transaction]);\n return {\n txId: await this.connection.sendRawTransaction(txs[0].serialize(), { skipPreflight: true }),\n signedTx: txs[0],\n };\n }\n throw new Error(\"please connect wallet first\");\n },\n extInfo: extInfo || ({} as O),\n };\n }\n\n public buildMultiTx<T = Record<string, any>>(params: {\n extraPreBuildData?: MakeTxData<TxVersion.LEGACY>[];\n extInfo?: T;\n }): MultiTxBuildData {\n const { extraPreBuildData = [], extInfo } = params;\n const { transaction } = this.build(extInfo);\n\n const filterExtraBuildData = extraPreBuildData.filter((data) => data.transaction.instructions.length > 0);\n\n const allTransactions: Transaction[] = [transaction, ...filterExtraBuildData.map((data) => data.transaction)];\n const allSigners: Signer[][] = [this.signers, ...filterExtraBuildData.map((data) => data.signers)];\n const allInstructionTypes: string[] = [\n ...this.instructionTypes,\n ...filterExtraBuildData.map((data) => data.instructionTypes).flat(),\n ];\n\n return {\n builder: this,\n transactions: allTransactions,\n signers: allSigners,\n instructionTypes: allInstructionTypes,\n execute: async (executeParams?: ExecuteParam) => {\n const { sequentially, onTxUpdate } = executeParams || {};\n const recentBlockHash = await getRecentBlockHash(this.connection);\n if (this.owner?.isKeyPair) {\n return {\n txIds: await await Promise.all(\n allTransactions.map(async (tx, idx) => {\n tx.recentBlockhash = recentBlockHash;\n return await sendAndConfirmTransaction(this.connection, tx, allSigners[idx]);\n }),\n ),\n signedTxs: allTransactions,\n };\n }\n\n if (this.signAllTransactions) {\n const partialSignedTxs = allTransactions.map((tx, idx) => {\n tx.recentBlockhash = recentBlockHash;\n if (allSigners[idx].length) tx.sign(...allSigners[idx]);\n return tx;\n });\n printSimulate(partialSignedTxs);\n const signedTxs = await this.signAllTransactions(partialSignedTxs);\n if (sequentially) {\n let i = 0;\n const processedTxs: { txId: string; status: \"success\" | \"error\" | \"sent\" }[] = [];\n const checkSendTx = async (): Promise<void> => {\n if (!signedTxs[i]) return;\n const txId = await this.connection.sendRawTransaction(signedTxs[i].serialize(), { skipPreflight: true });\n processedTxs.push({ txId, status: \"sent\" });\n onTxUpdate?.([...processedTxs]);\n i++;\n this.connection.onSignature(\n txId,\n (signatureResult) => {\n const targetTxIdx = processedTxs.findIndex((tx) => tx.txId === txId);\n if (targetTxIdx > -1) processedTxs[targetTxIdx].status = signatureResult.err ? \"error\" : \"success\";\n onTxUpdate?.([...processedTxs]);\n checkSendTx();\n },\n \"processed\",\n );\n this.connection.getSignatureStatus(txId);\n };\n await checkSendTx();\n return {\n txIds: processedTxs.map((d) => d.txId),\n signedTxs,\n };\n } else {\n const txIds: string[] = [];\n for (let i = 0; i < signedTxs.length; i += 1) {\n const txId = await this.connection.sendRawTransaction(signedTxs[i].serialize(), { skipPreflight: true });\n txIds.push(txId);\n }\n return {\n txIds,\n signedTxs,\n };\n }\n }\n throw new Error(\"please connect wallet first\");\n },\n extInfo: extInfo || {},\n };\n }\n\n public async versionMultiBuild<T extends TxVersion, O = Record<string, any>>({\n extraPreBuildData,\n txVersion,\n extInfo,\n }: {\n extraPreBuildData?: MakeTxData<TxVersion.V0>[] | MakeTxData<TxVersion.LEGACY>[];\n txVersion?: T;\n extInfo?: O;\n }): Promise<MakeMultiTxData<T, O>> {\n if (txVersion === TxVersion.V0)\n return (await this.buildV0MultiTx({\n extraPreBuildData: extraPreBuildData as MakeTxData<TxVersion.V0>[],\n buildProps: extInfo || {},\n })) as MakeMultiTxData<T, O>;\n return this.buildMultiTx<O>({\n extraPreBuildData: extraPreBuildData as MakeTxData<TxVersion.LEGACY>[],\n extInfo,\n }) as MakeMultiTxData<T, O>;\n }\n\n public async buildV0<O = Record<string, any>>(\n props?: O & {\n lookupTableCache?: CacheLTA;\n lookupTableAddress?: string[];\n forerunCreate?: boolean;\n },\n ): Promise<MakeTxData<TxVersion.V0, O>> {\n const { lookupTableCache = {}, lookupTableAddress = [], forerunCreate, ...extInfo } = props || {};\n const lookupTableAddressAccount = {\n ...LOOKUP_TABLE_CACHE,\n ...lookupTableCache,\n };\n const allLTA = Array.from(new Set<string>([...lookupTableAddress, ...this.lookupTableAddress]));\n const needCacheLTA: PublicKey[] = [];\n for (const item of allLTA) {\n if (lookupTableAddressAccount[item] === undefined) needCacheLTA.push(new PublicKey(item));\n }\n const newCacheLTA = await getMultipleLookupTableInfo({ connection: this.connection, address: needCacheLTA });\n for (const [key, value] of Object.entries(newCacheLTA)) lookupTableAddressAccount[key] = value;\n\n const messageV0 = new TransactionMessage({\n payerKey: this.feePayer,\n recentBlockhash: forerunCreate ? PublicKey.default.toBase58() : await getRecentBlockHash(this.connection),\n instructions: [...this.allInstructions],\n }).compileToV0Message(Object.values(lookupTableAddressAccount));\n const transaction = new VersionedTransaction(messageV0);\n transaction.sign(this.signers);\n\n return {\n builder: this,\n transaction,\n signers: this.signers,\n instructionTypes: [...this.instructionTypes, ...this.endInstructionTypes],\n execute: async () => {\n printSimulate([transaction]);\n if (this.owner?.isKeyPair) {\n transaction.sign([this.owner.signer as Signer]);\n return {\n txId: await this.connection.sendTransaction(transaction, { skipPreflight: true }),\n signedTx: transaction,\n };\n }\n if (this.signAllTransactions) {\n const txs = await this.signAllTransactions<VersionedTransaction>([transaction]);\n return {\n txId: await this.connection.sendTransaction(txs[0], { skipPreflight: true }),\n signedTx: txs[0],\n };\n }\n throw new Error(\"please connect wallet first\");\n },\n extInfo: (extInfo || {}) as O,\n };\n }\n\n public async buildV0MultiTx<T = Record<string, any>>(params: {\n extraPreBuildData?: MakeTxData<TxVersion.V0>[];\n buildProps?: T & {\n lookupTableCache?: CacheLTA;\n lookupTableAddress?: string[];\n };\n }): Promise<MultiTxV0BuildData> {\n const { extraPreBuildData = [], buildProps } = params;\n const { transaction } = await this.buildV0(buildProps);\n\n const filterExtraBuildData = extraPreBuildData.filter((data) => data.builder.instructions.length > 0);\n\n const allTransactions: VersionedTransaction[] = [\n transaction,\n ...filterExtraBuildData.map((data) => data.transaction),\n ];\n const allSigners: Signer[][] = [this.signers, ...filterExtraBuildData.map((data) => data.signers)];\n const allInstructionTypes: string[] = [\n ...this.instructionTypes,\n ...filterExtraBuildData.map((data) => data.instructionTypes).flat(),\n ];\n\n allTransactions.forEach(async (tx, idx) => {\n tx.sign(allSigners[idx]);\n });\n\n return {\n builder: this,\n transactions: allTransactions,\n signers: allSigners,\n instructionTypes: allInstructionTypes,\n buildProps,\n execute: async (executeParams?: ExecuteParam) => {\n printSimulate(allTransactions);\n const { sequentially, onTxUpdate } = executeParams || {};\n if (this.owner?.isKeyPair) {\n allTransactions.forEach((tx) => tx.sign([this.owner!.signer as Signer]));\n return {\n txIds: await Promise.all(\n allTransactions.map(async (tx) => {\n return await this.connection.sendTransaction(tx);\n }),\n ),\n signedTxs: allTransactions,\n };\n }\n\n if (this.signAllTransactions) {\n const signedTxs = await this.signAllTransactions(allTransactions);\n\n if (sequentially) {\n let i = 0;\n const processedTxs: { txId: string; status: \"success\" | \"error\" | \"sent\" }[] = [];\n const checkSendTx = async (): Promise<void> => {\n if (!signedTxs[i]) return;\n const txId = await this.connection.sendTransaction(signedTxs[i], { skipPreflight: true });\n processedTxs.push({ txId, status: \"sent\" });\n onTxUpdate?.([...processedTxs]);\n i++;\n this.connection.onSignature(\n txId,\n (signatureResult) => {\n const targetTxIdx = processedTxs.findIndex((tx) => tx.txId === txId);\n if (targetTxIdx > -1) processedTxs[targetTxIdx].status = signatureResult.err ? \"error\" : \"success\";\n onTxUpdate?.([...processedTxs]);\n checkSendTx();\n },\n \"processed\",\n );\n this.connection.getSignatureStatus(txId);\n };\n checkSendTx();\n return {\n txIds: [],\n signedTxs,\n };\n } else {\n const txIds: string[] = [];\n for (let i = 0; i < signedTxs.length; i += 1) {\n const txId = await this.connection.sendTransaction(signedTxs[i], { skipPreflight: true });\n txIds.push(txId);\n }\n return { txIds, signedTxs };\n }\n }\n throw new Error(\"please connect wallet first\");\n },\n extInfo: buildProps || {},\n };\n }\n\n public async sizeCheckBuild(\n props?: Record<string, any> & { autoComputeBudget?: boolean },\n ): Promise<MultiTxBuildData> {\n const { autoComputeBudget = false, ...extInfo } = props || {};\n\n let computeBudgetData: { instructions: TransactionInstruction[]; instructionTypes: string[] } = {\n instructions: [],\n instructionTypes: [],\n };\n\n if (autoComputeBudget) {\n const computeConfig = autoComputeBudget ? await this.getComputeBudgetConfig() : undefined;\n computeBudgetData =\n autoComputeBudget && computeConfig\n ? addComputeBudget(computeConfig)\n : { instructions: [], instructionTypes: [] };\n }\n\n const signerKey: { [key: string]: Signer } = this.signers.reduce(\n (acc, cur) => ({ ...acc, [cur.publicKey.toBase58()]: cur }),\n {},\n );\n\n const allTransactions: Transaction[] = [];\n const allSigners: Signer[][] = [];\n\n let instructionQueue: TransactionInstruction[] = [];\n this.allInstructions.forEach((item) => {\n const _itemIns = [...instructionQueue, item];\n const _itemInsWithCompute = autoComputeBudget ? [...computeBudgetData.instructions, ..._itemIns] : _itemIns;\n const _signerStrs = new Set<string>(\n _itemIns.map((i) => i.keys.filter((ii) => ii.isSigner).map((ii) => ii.pubkey.toString())).flat(),\n );\n const _signer = [..._signerStrs.values()].map((i) => new PublicKey(i));\n\n if (\n (instructionQueue.length < 12 &&\n checkLegacyTxSize({ instructions: _itemInsWithCompute, payer: this.feePayer, signers: _signer })) ||\n checkLegacyTxSize({ instructions: _itemIns, payer: this.feePayer, signers: _signer })\n ) {\n // current ins add to queue still not exceed tx size limit\n instructionQueue.push(item);\n } else {\n if (instructionQueue.length === 0) throw Error(\"item ins too big\");\n\n // if add computeBudget still not exceed tx size limit\n if (\n checkLegacyTxSize({\n instructions: autoComputeBudget\n ? [...computeBudgetData.instructions, ...instructionQueue]\n : [...instructionQueue],\n payer: this.feePayer,\n signers: _signer,\n })\n ) {\n allTransactions.push(new Transaction().add(...computeBudgetData.instructions, ...instructionQueue));\n } else {\n allTransactions.push(new Transaction().add(...instructionQueue));\n }\n allSigners.push(\n Array.from(\n new Set<string>(\n instructionQueue.map((i) => i.keys.filter((ii) => ii.isSigner).map((ii) => ii.pubkey.toString())).flat(),\n ),\n )\n .map((i) => signerKey[i])\n .filter((i) => i !== undefined),\n );\n instructionQueue = [item];\n }\n });\n\n if (instructionQueue.length > 0) {\n const _signerStrs = new Set<string>(\n instructionQueue.map((i) => i.keys.filter((ii) => ii.isSigner).map((ii) => ii.pubkey.toString())).flat(),\n );\n const _signers = [..._signerStrs.values()].map((i) => signerKey[i]).filter((i) => i !== undefined);\n\n if (\n checkLegacyTxSize({\n instructions: autoComputeBudget\n ? [...computeBudgetData.instructions, ...instructionQueue]\n : [...instructionQueue],\n payer: this.feePayer,\n signers: _signers.map((s) => s.publicKey),\n })\n ) {\n allTransactions.push(new Transaction().add(...computeBudgetData.instructions, ...instructionQueue));\n } else {\n allTransactions.push(new Transaction().add(...instructionQueue));\n }\n allSigners.push(_signers);\n }\n allTransactions.forEach((tx) => (tx.feePayer = this.feePayer));\n\n return {\n builder: this,\n transactions: allTransactions,\n signers: allSigners,\n instructionTypes: this.instructionTypes,\n execute: async (executeParams?: ExecuteParam) => {\n const { sequentially, onTxUpdate } = executeParams || {};\n const recentBlockHash = await getRecentBlockHash(this.connection);\n allTransactions.forEach(async (tx, idx) => {\n tx.recentBlockhash = recentBlockHash;\n if (allSigners[idx].length) tx.sign(...allSigners[idx]);\n });\n printSimulate(allTransactions);\n if (this.owner?.isKeyPair) {\n return {\n txIds: await Promise.all(\n allTransactions.map(async (tx, idx) => {\n return await sendAndConfirmTransaction(this.connection, tx, allSigners[idx]);\n }),\n ),\n signedTxs: allTransactions,\n };\n }\n if (this.signAllTransactions) {\n const signedTxs = await this.signAllTransactions(allTransactions);\n if (sequentially) {\n let i = 0;\n const processedTxs: { txId: string; status: \"success\" | \"error\" | \"sent\" }[] = [];\n const checkSendTx = async (): Promise<void> => {\n if (!signedTxs[i]) return;\n const txId = await this.connection.sendRawTransaction(signedTxs[i].serialize(), { skipPreflight: true });\n processedTxs.push({ txId, status: \"sent\" });\n onTxUpdate?.([...processedTxs]);\n i++;\n this.connection.onSignature(\n txId,\n (signatureResult) => {\n const targetTxIdx = processedTxs.findIndex((tx) => tx.txId === txId);\n if (targetTxIdx > -1) processedTxs[targetTxIdx].status = signatureResult.err ? \"error\" : \"success\";\n onTxUpdate?.([...processedTxs]);\n checkSendTx();\n },\n \"processed\",\n );\n this.connection.getSignatureStatus(txId);\n };\n await checkSendTx();\n return {\n txIds: processedTxs.map((d) => d.txId),\n signedTxs,\n };\n } else {\n const txIds: string[] = [];\n for (let i = 0; i < signedTxs.length; i += 1) {\n const txId = await this.connection.sendRawTransaction(signedTxs[i].serialize(), { skipPreflight: true });\n txIds.push(txId);\n }\n return { txIds, signedTxs };\n }\n }\n throw new Error(\"please connect wallet first\");\n },\n extInfo: extInfo || {},\n };\n }\n\n public async sizeCheckBuildV0(\n props?: Record<string, any> & {\n autoComputeBudget?: boolean;\n lookupTableCache?: CacheLTA;\n lookupTableAddress?: string[];\n },\n ): Promise<MultiTxV0BuildData> {\n const { autoComputeBudget = false, lookupTableCache = {}, lookupTableAddress = [], ...extInfo } = props || {};\n const lookupTableAddressAccount = {\n ...LOOKUP_TABLE_CACHE,\n ...lookupTableCache,\n };\n const allLTA = Array.from(new Set<string>([...this.lookupTableAddress, ...lookupTableAddress]));\n const needCacheLTA: PublicKey[] = [];\n for (const item of allLTA) {\n if (lookupTableAddressAccount[item] === undefined) needCacheLTA.push(new PublicKey(item));\n }\n const newCacheLTA = await getMultipleLookupTableInfo({ connection: this.connection, address: needCacheLTA });\n for (const [key, value] of Object.entries(newCacheLTA)) lookupTableAddressAccount[key] = value;\n\n let computeBudgetData: { instructions: TransactionInstruction[]; instructionTypes: string[] } = {\n instructions: [],\n instructionTypes: [],\n };\n\n if (autoComputeBudget) {\n const computeConfig = autoComputeBudget ? await this.getComputeBudgetConfig() : undefined;\n computeBudgetData =\n autoComputeBudget && computeConfig\n ? addComputeBudget(computeConfig)\n : { instructions: [], instructionTypes: [] };\n }\n\n const blockHash = await getRecentBlockHash(this.connection);\n\n const signerKey: { [key: string]: Signer } = this.signers.reduce(\n (acc, cur) => ({ ...acc, [cur.publicKey.toBase58()]: cur }),\n {},\n );\n\n const allTransactions: VersionedTransaction[] = [];\n const allSigners: Signer[][] = [];\n\n let instructionQueue: TransactionInstruction[] = [];\n this.allInstructions.forEach((item) => {\n const _itemIns = [...instructionQueue, item];\n const _itemInsWithCompute = autoComputeBudget ? [...computeBudgetData.instructions, ..._itemIns] : _itemIns;\n if (\n (instructionQueue.length < 12 &&\n checkV0TxSize({ instructions: _itemInsWithCompute, payer: this.feePayer, lookupTableAddressAccount })) ||\n checkV0TxSize({ instructions: _itemIns, payer: this.feePayer, lookupTableAddressAccount })\n ) {\n // current ins add to queue still not exceed tx size limit\n instructionQueue.push(item);\n } else {\n if (instructionQueue.length === 0) throw Error(\"item ins too big\");\n\n const lookupTableAddress: undefined | CacheLTA = {};\n for (const item of [...new Set<string>(allLTA)]) {\n if (lookupTableAddressAccount[item] !== undefined) lookupTableAddress[item] = lookupTableAddressAccount[item];\n }\n // if add computeBudget still not exceed tx size limit\n if (\n autoComputeBudget &&\n checkV0TxSize({\n instructions: [...computeBudgetData.instructions, ...instructionQueue],\n payer: this.feePayer,\n lookupTableAddressAccount,\n recentBlockhash: blockHash,\n })\n ) {\n const messageV0 = new TransactionMessage({\n payerKey: this.feePayer,\n recentBlockhash: blockHash,\n\n instructions: [...computeBudgetData.instructions, ...instructionQueue],\n }).compileToV0Message(Object.values(lookupTableAddressAccount));\n allTransactions.push(new VersionedTransaction(messageV0));\n } else {\n const messageV0 = new TransactionMessage({\n payerKey: this.feePayer,\n recentBlockhash: blockHash,\n instructions: [...instructionQueue],\n }).compileToV0Message(Object.values(lookupTableAddressAccount));\n allTransactions.push(new VersionedTransaction(messageV0));\n }\n allSigners.push(\n Array.from(\n new Set<string>(\n instructionQueue.map((i) => i.keys.filter((ii) => ii.isSigner).map((ii) => ii.pubkey.toString())).flat(),\n ),\n )\n .map((i) => signerKey[i])\n .filter((i) => i !== undefined),\n );\n instructionQueue = [item];\n }\n });\n\n if (instructionQueue.length > 0) {\n const _signerStrs = new Set<string>(\n instructionQueue.map((i) => i.keys.filter((ii) => ii.isSigner).map((ii) => ii.pubkey.toString())).flat(),\n );\n const _signers = [..._signerStrs.values()].map((i) => signerKey[i]).filter((i) => i !== undefined);\n\n if (\n autoComputeBudget &&\n checkV0TxSize({\n instructions: [...computeBudgetData.instructions, ...instructionQueue],\n payer: this.feePayer,\n lookupTableAddressAccount,\n recentBlockhash: blockHash,\n })\n ) {\n const messageV0 = new TransactionMessage({\n payerKey: this.feePayer,\n recentBlockhash: blockHash,\n instructions: [...computeBudgetData.instructions, ...instructionQueue],\n }).compileToV0Message(Object.values(lookupTableAddressAccount));\n allTransactions.push(new VersionedTransaction(messageV0));\n } else {\n const messageV0 = new TransactionMessage({\n payerKey: this.feePayer,\n recentBlockhash: blockHash,\n instructions: [...instructionQueue],\n }).compileToV0Message(Object.values(lookupTableAddressAccount));\n allTransactions.push(new VersionedTransaction(messageV0));\n }\n allSigners.push(_signers);\n }\n\n return {\n builder: this,\n transactions: allTransactions,\n buildProps: props,\n signers: allSigners,\n instructionTypes: this.instructionTypes,\n execute: async (executeParams?: ExecuteParam) => {\n const { sequentially, onTxUpdate } = executeParams || {};\n allTransactions.map(async (tx, idx) => {\n if (allSigners[idx].length) tx.sign(allSigners[idx]);\n });\n printSimulate(allTransactions);\n if (this.owner?.isKeyPair) {\n return {\n txIds: await Promise.all(\n allTransactions.map(async (tx) => {\n return await this.connection.sendTransaction(tx, { skipPreflight: true });\n }),\n ),\n signedTxs: allTransactions,\n };\n }\n if (this.signAllTransactions) {\n const signedTxs = await this.signAllTransactions(allTransactions);\n if (sequentially) {\n let i = 0;\n const processedTxs: { txId: string; status: \"success\" | \"error\" | \"sent\" }[] = [];\n const checkSendTx = async (): Promise<void> => {\n if (!signedTxs[i]) return;\n const txId = await this.connection.sendTransaction(signedTxs[i], { skipPreflight: true });\n processedTxs.push({ txId, status: \"sent\" });\n onTxUpdate?.([...processedTxs]);\n i++;\n this.connection.onSignature(\n txId,\n (signatureResult) => {\n const targetTxIdx = processedTxs.findIndex((tx) => tx.txId === txId);\n if (targetTxIdx > -1) processedTxs[targetTxIdx].status = signatureResult.err ? \"error\" : \"success\";\n onTxUpdate?.([...processedTxs]);\n checkSendTx();\n },\n \"processed\",\n );\n this.connection.getSignatureStatus(txId);\n };\n checkSendTx();\n return {\n txIds: [],\n signedTxs,\n };\n } else {\n const txIds: string[] = [];\n for (let i = 0; i < signedTxs.length; i += 1) {\n const txId = await this.connection.sendTransaction(signedTxs[i], { skipPreflight: true });\n txIds.push(txId);\n }\n return { txIds, signedTxs };\n }\n }\n throw new Error(\"please connect wallet first\");\n },\n extInfo: extInfo || {},\n };\n }\n}\n","export enum TxVersion {\n \"V0\",\n \"LEGACY\",\n}\n\nexport const InstructionType = {\n CreateAccount: \"CreateAccount\",\n InitAccount: \"InitAccount\",\n CreateATA: \"CreateATA\",\n CloseAccount: \"CloseAccount\",\n TransferAmount: \"TransferAmount\",\n InitMint: \"InitMint\",\n MintTo: \"MintTo\",\n\n InitMarket: \"InitMarket\", // create market main ins\n Util1216OwnerClaim: \"Util1216OwnerClaim\", // owner claim token ins\n\n SetComputeUnitPrice: \"SetComputeUnitPrice\",\n SetComputeUnitLimit: \"SetComputeUnitLimit\",\n\n // CLMM\n ClmmCreatePool: \"ClmmCreatePool\",\n ClmmOpenPosition: \"ClmmOpenPosition\",\n ClmmIncreasePosition: \"ClmmIncreasePosition\",\n ClmmDecreasePosition: \"ClmmDecreasePosition\",\n ClmmClosePosition: \"ClmmClosePosition\",\n ClmmSwapBaseIn: \"ClmmSwapBaseIn\",\n ClmmSwapBaseOut: \"ClmmSwapBaseOut\",\n ClmmInitReward: \"ClmmInitReward\",\n ClmmSetReward: \"ClmmSetReward\",\n ClmmCollectReward: \"ClmmCollectReward\",\n\n AmmV4Swap: \"AmmV4Swap\",\n AmmV4AddLiquidity: \"AmmV4AddLiquidity\",\n AmmV4RemoveLiquidity: \"AmmV4RemoveLiquidity\",\n AmmV4SimulatePoolInfo: \"AmmV4SimulatePoolInfo\",\n AmmV4SwapBaseIn: \"AmmV4SwapBaseIn\",\n AmmV4SwapBaseOut: \"AmmV4SwapBaseOut\",\n AmmV4CreatePool: \"AmmV4CreatePool\",\n AmmV4InitPool: \"AmmV4InitPool\",\n\n AmmV5AddLiquidity: \"AmmV5AddLiquidity\",\n AmmV5RemoveLiquidity: \"AmmV5RemoveLiquidity\",\n AmmV5SimulatePoolInfo: \"AmmV5SimulatePoolInfo\",\n AmmV5SwapBaseIn: \"AmmV5SwapBaseIn\",\n AmmV5SwapBaseOut: \"AmmV5SwapBaseOut\",\n\n RouteSwap: \"RouteSwap\",\n RouteSwap1: \"RouteSwap1\",\n RouteSwap2: \"RouteSwap2\",\n\n FarmV3Deposit: \"FarmV3Deposit\",\n FarmV3Withdraw: \"FarmV3Withdraw\",\n FarmV3CreateLedger: \"FarmV3CreateLedger\",\n\n FarmV5Deposit: \"FarmV5Deposit\",\n