UNPKG

@raydium-io/raydium-sdk-v2

Version:

An SDK for building applications on top of Raydium.

445 lines (442 loc) 14.7 kB
import { PublicKey, Signer } from '@solana/web3.js'; import { bT as ComputeBudgetConfig, bU as TxTipConfig } from '../../api-97e39847.js'; import BN__default from 'bn.js'; import { TransferFeeConfig } from '@solana/spl-token'; import { TxVersion } from '../../common/txTool/txType.js'; import { LaunchpadPool, LaunchpadConfig, PlatformConfig, PlatformCurveRule } from './layout.js'; import 'axios'; import '../../solana/type.js'; import '../../api/url.js'; import '../../common/owner.js'; import '../../common/txTool/lookupTable.js'; import 'decimal.js'; import '../../module/token.js'; import '../../common/pubKey.js'; import '../../common/logger.js'; import '../../module/currency.js'; import '../../marshmallow/index.js'; import '../../marshmallow/buffer-layout.js'; interface CreateLaunchPad<T = TxVersion.LEGACY> { mintA: PublicKey; name: string; symbol: string; buyAmount: BN__default; platformId?: PublicKey; programId?: PublicKey; authProgramId?: PublicKey; decimals?: number; mintBDecimals?: number; curType?: number; configId: PublicKey; configInfo?: LaunchpadConfigInfo; minMintAAmount?: BN__default; slippage?: BN__default; uri: string; migrateType: "amm" | "cpmm"; supply?: BN__default; totalSellA?: BN__default; totalFundRaisingB?: BN__default; totalLockedAmount?: BN__default; cliffPeriod?: BN__default; unlockPeriod?: BN__default; shareFeeRate?: BN__default; shareFeeReceiver?: PublicKey; platformFeeRate?: BN__default; platformVestingScale?: BN__default; createOnly?: boolean; computeBudgetConfig?: ComputeBudgetConfig; txTipConfig?: TxTipConfig; txVersion?: T; feePayer?: PublicKey; associatedOnly?: boolean; checkCreateATAOwner?: boolean; extraSigners?: Signer[]; token2022?: boolean; transferFeeExtensionParams?: { transferFeeBasePoints: number; maxinumFee: BN__default; }; creatorFeeOn?: CpmmCreatorFeeOn; platformAllowConfig?: boolean; mintBProgram?: PublicKey; transferFeeConfigB?: TransferFeeConfig | undefined; skipCheckMintB?: boolean; } interface BuyToken<T = TxVersion.LEGACY> { mintA: PublicKey; mintAProgram?: PublicKey; mintBProgram?: PublicKey; buyAmount: BN__default; programId?: PublicKey; authProgramId?: PublicKey; mintB?: PublicKey; poolInfo?: LaunchpadPoolInfo; minMintAAmount?: BN__default; slippage?: BN__default; shareFeeRate?: BN__default; shareFeeReceiver?: PublicKey; configInfo?: LaunchpadConfigInfo; platformFeeRate?: BN__default; computeBudgetConfig?: ComputeBudgetConfig; txTipConfig?: TxTipConfig; txVersion?: T; feePayer?: PublicKey; associatedOnly?: boolean; checkCreateATAOwner?: boolean; transferFeeConfigA?: TransferFeeConfig | undefined; transferFeeConfigB?: TransferFeeConfig | undefined; skipCheckMintA?: boolean; skipCheckMintB?: boolean; fromCreate?: boolean; } interface BuyTokenExactOut<T = TxVersion.LEGACY> extends Omit<BuyToken, "buyAmount" | "minMintAAmount" | "txVersion"> { maxBuyAmount?: BN__default; outAmount: BN__default; txVersion?: T; } interface SellToken<T = TxVersion.LEGACY> { mintA: PublicKey; mintAProgram?: PublicKey; mintBProgram?: PublicKey; sellAmount: BN__default; slippage?: BN__default; programId?: PublicKey; authProgramId?: PublicKey; poolInfo?: LaunchpadPoolInfo; mintB?: PublicKey; minAmountB?: BN__default; shareFeeRate?: BN__default; shareFeeReceiver?: PublicKey; configInfo?: LaunchpadConfigInfo; platformFeeRate?: BN__default; computeBudgetConfig?: ComputeBudgetConfig; txTipConfig?: TxTipConfig; txVersion?: T; feePayer?: PublicKey; associatedOnly?: boolean; checkCreateATAOwner?: boolean; transferFeeConfigB?: TransferFeeConfig | undefined; skipCheckMintA?: boolean; skipCheckMintB?: boolean; } interface SellTokenExactOut<T = TxVersion.LEGACY> extends Omit<SellToken, "sellAmount" | "txVersion"> { maxSellAmount?: BN__default; inAmount: BN__default; txVersion?: T; } interface CreatePlatform<T = TxVersion.LEGACY> { programId?: PublicKey; platformAdmin: PublicKey; platformClaimFeeWallet: PublicKey; platformLockNftWallet: PublicKey; platformVestingWallet: PublicKey; cpConfigId: PublicKey; migrateCpLockNftScale: { platformScale: BN__default; creatorScale: BN__default; burnScale: BN__default; }; transferFeeExtensionAuth: PublicKey; creatorFeeRate: BN__default; feeRate: BN__default; name: string; web: string; img: string; platformVestingScale?: BN__default; computeBudgetConfig?: ComputeBudgetConfig; txTipConfig?: TxTipConfig; txVersion?: T; feePayer?: PublicKey; } interface CreatePlatformAllowConfig<T = TxVersion.LEGACY> { programId?: PublicKey; platformAdmin: PublicKey; platformId: PublicKey; configInfo: { mintB: string | PublicKey; curveType: number; index: number; }; computeBudgetConfig?: ComputeBudgetConfig; txTipConfig?: TxTipConfig; txVersion?: T; feePayer?: PublicKey; } interface CreatePlatformCurveRule<T = TxVersion.LEGACY> { programId?: PublicKey; curveRuleAuthority?: PublicKey; platformId: PublicKey; configId: PublicKey; computeBudgetConfig?: ComputeBudgetConfig; txTipConfig?: TxTipConfig; txVersion?: T; feePayer?: PublicKey; } interface UpdatePlatformCurveRule<T = TxVersion.LEGACY> { programId?: PublicKey; curveRuleAuthority?: PublicKey; platformCurveRuleId: PublicKey; groupId: number; constraints: LaunchpadCurveRuleConstraint[]; computeBudgetConfig?: ComputeBudgetConfig; txTipConfig?: TxTipConfig; txVersion?: T; feePayer?: PublicKey; } interface UpdatePlatform<T = TxVersion.LEGACY> { programId?: PublicKey; platformAdmin: PublicKey; platformId?: PublicKey; updateInfo: { type: "updateClaimFeeWallet" | "updateLockNftWallet"; value: PublicKey; } | { type: "updateFeeRate"; value: BN__default; } | { type: "updateName" | "updateImg" | "updateWeb"; value: string; } | { type: "migrateCpLockNftScale"; value: { platformScale: BN__default; creatorScale: BN__default; burnScale: BN__default; }; } | { type: "updateCpConfigId"; value: PublicKey; } | { type: "updateVestingWallet"; value: PublicKey; } | { type: "updatePlatformVestingScale"; value: BN__default; } | { type: "updatePlatformCpCreator"; value: PublicKey; } | { type: "updateRestrictGlobalConfig"; value: BN__default; } | { type: "updateRestrictCurveParam"; value: BN__default; } | { type: "updateCurveRuleManager"; value: PublicKey; } | { type: "updateAll"; value: { platformClaimFeeWallet: PublicKey; platformLockNftWallet: PublicKey; platformVestingWallet: PublicKey; cpConfigId: PublicKey; migrateCpLockNftScale: { platformScale: BN__default; creatorScale: BN__default; burnScale: BN__default; }; feeRate: BN__default; name: string; web: string; img: string; transferFeeExtensionAuth: PublicKey; creatorFeeRate: BN__default; platformVestingScale: BN__default; }; }; computeBudgetConfig?: ComputeBudgetConfig; txTipConfig?: TxTipConfig; txVersion?: T; feePayer?: PublicKey; } interface CreatePlatformVestingAccount<T = TxVersion.LEGACY> { programId?: PublicKey; platformVestingWallet: PublicKey; beneficiary: PublicKey; platformId: PublicKey; poolId: PublicKey; vestingRecord?: PublicKey; computeBudgetConfig?: ComputeBudgetConfig; txTipConfig?: TxTipConfig; txVersion?: T; feePayer?: PublicKey; } interface ClaimPlatformFee<T = TxVersion.LEGACY> { programId?: PublicKey; authProgramId?: PublicKey; platformId: PublicKey; platformClaimFeeWallet: PublicKey; poolId: PublicKey; mintB?: PublicKey; vaultB?: PublicKey; mintBProgram?: PublicKey; computeBudgetConfig?: ComputeBudgetConfig; txTipConfig?: TxTipConfig; txVersion?: T; feePayer?: PublicKey; } interface ClaimAllPlatformFee<T = TxVersion.LEGACY> { programId?: PublicKey; authProgramId?: PublicKey; platformId: PublicKey; platformClaimFeeWallet: PublicKey; computeBudgetConfig?: ComputeBudgetConfig; txTipConfig?: TxTipConfig; txVersion?: T; feePayer?: PublicKey; } interface CreateVesting<T = TxVersion.LEGACY> { programId?: PublicKey; poolId: PublicKey; beneficiary: PublicKey; shareAmount: BN__default; computeBudgetConfig?: ComputeBudgetConfig; txTipConfig?: TxTipConfig; txVersion?: T; feePayer?: PublicKey; } interface CreateMultipleVesting<T = TxVersion.LEGACY> { programId?: PublicKey; poolId: PublicKey; beneficiaryList: { wallet: PublicKey; shareAmount: BN__default; }[]; computeBudgetConfig?: ComputeBudgetConfig; txVersion?: T; feePayer?: PublicKey; } interface ClaimVesting<T = TxVersion.LEGACY> { programId?: PublicKey; poolId: PublicKey; vestingRecord?: PublicKey; poolInfo?: LaunchpadPoolInfo; computeBudgetConfig?: ComputeBudgetConfig; txTipConfig?: TxTipConfig; txVersion?: T; feePayer?: PublicKey; } interface ClaimMultiVesting<T = TxVersion.LEGACY> { programId?: PublicKey; poolIdList: PublicKey[]; vestingRecords?: Record<string, PublicKey>; poolsInfo?: Record<string, { mintA: PublicKey; vaultA: PublicKey; }>; computeBudgetConfig?: ComputeBudgetConfig; txVersion?: T; feePayer?: PublicKey; } interface ClaimVaultPlatformFee<T = TxVersion.LEGACY> { programId?: PublicKey; platformId: PublicKey; mintB: PublicKey; mintBProgram?: PublicKey; claimFeeWallet?: PublicKey; computeBudgetConfig?: ComputeBudgetConfig; txTipConfig?: TxTipConfig; txVersion?: T; feePayer?: PublicKey; } interface ClaimMultipleVaultPlatformFee<T = TxVersion.LEGACY> { programId?: PublicKey; platformList: { id: PublicKey; mintB: PublicKey; mintBProgram?: PublicKey; claimFeeWallet?: PublicKey; }[]; unwrapSol?: boolean; computeBudgetConfig?: ComputeBudgetConfig; txVersion?: T; feePayer?: PublicKey; associatedOnly?: boolean; checkCreateATAOwner?: boolean; } interface ClaimCreatorFee<T = TxVersion.LEGACY> { programId?: PublicKey; mintB: PublicKey; mintBProgram?: PublicKey; computeBudgetConfig?: ComputeBudgetConfig; txTipConfig?: TxTipConfig; txVersion?: T; feePayer?: PublicKey; } interface ClaimMultiCreatorFee<T = TxVersion.LEGACY> { programId?: PublicKey; mintBList: { pubKey: PublicKey; programId?: PublicKey; }[]; computeBudgetConfig?: ComputeBudgetConfig; txTipConfig?: TxTipConfig; txVersion?: T; feePayer?: PublicKey; } declare type LaunchpadPoolInfo = ReturnType<typeof LaunchpadPool.decode>; declare type LaunchpadConfigInfo = ReturnType<typeof LaunchpadConfig.decode>; declare type LaunchpadPlatformInfo = ReturnType<typeof PlatformConfig.decode>; declare type LaunchpadCurveRuleInfo = ReturnType<typeof PlatformCurveRule.decode>; declare enum LaunchpadCurveRuleField { CurveType = 0, MigrateType = 1, MigrateCpmmFeeOn = 2, Supply = 3, TotalSellA = 4, TotalFundRaisingB = 5, TotalLockedAmount = 6, CliffPeriod = 7, UnlockPeriod = 8, /** 0: the base mint belongs to spl token, 1: to token2022, see LaunchpadCurveRuleBaseTokenProgram */ BaseTokenProgram = 9, /** 1 when the base mint carries the transfer fee extension, 0 when it does not */ TransferFeeEnabled = 10, /** the transfer fee rate of the base mint, denominator 10000, 0 without the extension */ TransferFeeBasisPoints = 11, /** the maximum transfer fee of the base mint, 0 without the extension */ TransferFeeMaximumFee = 12, /** derived: totalSellA / supply, denominated in 10^-6 */ SellRateA = 13, /** derived: totalLockedAmount / supply, denominated in 10^-6 */ LockRate = 14, /** derived: supply - totalSellA - totalLockedAmount, the base amount reaching the migrated pool */ MigrateAmountA = 15, /** derived: migrate amount / supply, denominated in 10^-6 */ MigrateRateA = 16, /** derived: totalFundRaisingB / supply, denominated in 10^-6, a band on the graduation valuation */ FundRaisingRateB = 17, /** the block time the pool is created at, in seconds, it lets a group carry a validity window */ UnixTimestamp = 18 } /** * The fields that read totalSellA. They are only accepted on a constant product config: the * fixed and the linear curve derive the sell amount themselves, so the program refuses * these fields when the rule of such a config is written. */ declare const LAUNCHPAD_CURVE_RULE_CONSTANT_PRODUCT_ONLY_FIELDS: LaunchpadCurveRuleField[]; declare enum LaunchpadCurveRuleOp { Eq = 0, /** min */ Gte = 1, /** max */ Lte = 2, Neq = 3 } declare enum LaunchpadCurveRuleBaseTokenProgram { SplToken = 0, Token2022 = 1 } interface LaunchpadCurveRuleConstraint { field: LaunchpadCurveRuleField; op: LaunchpadCurveRuleOp; value: BN__default; } declare const LAUNCHPAD_MAX_CURVE_RULE_GROUPS = 10; declare const LAUNCHPAD_MAX_CONSTRAINTS_PER_GROUP = 25; declare enum CpmmCreatorFeeOn { OnlyTokenB = 0, BothToken = 1 } export { BuyToken, BuyTokenExactOut, ClaimAllPlatformFee, ClaimCreatorFee, ClaimMultiCreatorFee, ClaimMultiVesting, ClaimMultipleVaultPlatformFee, ClaimPlatformFee, ClaimVaultPlatformFee, ClaimVesting, CpmmCreatorFeeOn, CreateLaunchPad, CreateMultipleVesting, CreatePlatform, CreatePlatformAllowConfig, CreatePlatformCurveRule, CreatePlatformVestingAccount, CreateVesting, LAUNCHPAD_CURVE_RULE_CONSTANT_PRODUCT_ONLY_FIELDS, LAUNCHPAD_MAX_CONSTRAINTS_PER_GROUP, LAUNCHPAD_MAX_CURVE_RULE_GROUPS, LaunchpadConfigInfo, LaunchpadCurveRuleBaseTokenProgram, LaunchpadCurveRuleConstraint, LaunchpadCurveRuleField, LaunchpadCurveRuleInfo, LaunchpadCurveRuleOp, LaunchpadPlatformInfo, LaunchpadPoolInfo, SellToken, SellTokenExactOut, UpdatePlatform, UpdatePlatformCurveRule };