{"version":3,"sources":["../../../src/raydium/launchpad/curveRule.ts","../../../src/raydium/launchpad/type.ts"],"sourcesContent":["import BN from \"bn.js\";\nimport {\n  LAUNCHPAD_CURVE_RULE_CONSTANT_PRODUCT_ONLY_FIELDS,\n  LAUNCHPAD_MAX_CONSTRAINTS_PER_GROUP,\n  LAUNCHPAD_MAX_CURVE_RULE_GROUPS,\n  LaunchpadCurveRuleBaseTokenProgram,\n  LaunchpadCurveRuleConstraint,\n  LaunchpadCurveRuleField,\n  LaunchpadCurveRuleInfo,\n  LaunchpadCurveRuleOp,\n} from \"./type\";\n\nconst RATE_DENOMINATOR = new BN(1_000_000);\n\n\nexport interface LaunchpadCurveRuleContext {\n  curveType: number;\n  migrateType: number;\n  migrateCpmmFeeOn: number;\n  supply: BN;\n  totalSellA: BN;\n  totalFundRaisingB: BN;\n  totalLockedAmount: BN;\n  cliffPeriod: BN;\n  unlockPeriod: BN;\n  baseTokenProgram: LaunchpadCurveRuleBaseTokenProgram;\n  transferFee?: { basisPoints: number; maximumFee: BN };\n  unixTimestamp: BN;\n}\n\n\nexport function getCurveRuleFieldValue(\n  context: LaunchpadCurveRuleContext,\n  field: number,\n): BN | undefined {\n  const rateOf = (amount: BN): BN | undefined =>\n    context.supply.isZero() ? undefined : amount.mul(RATE_DENOMINATOR).div(context.supply);\n  const migrateAmountA = (): BN | undefined => {\n    const rest = context.supply.sub(context.totalSellA).sub(context.totalLockedAmount);\n    return rest.isNeg() ? undefined : rest;\n  };\n\n  switch (field) {\n    case LaunchpadCurveRuleField.CurveType:\n      return new BN(context.curveType);\n    case LaunchpadCurveRuleField.MigrateType:\n      return new BN(context.migrateType);\n    case LaunchpadCurveRuleField.MigrateCpmmFeeOn:\n      return new BN(context.migrateCpmmFeeOn);\n    case LaunchpadCurveRuleField.Supply:\n      return context.supply;\n    case LaunchpadCurveRuleField.TotalSellA:\n      return context.totalSellA;\n    case LaunchpadCurveRuleField.TotalFundRaisingB:\n      return context.totalFundRaisingB;\n    case LaunchpadCurveRuleField.TotalLockedAmount:\n      return context.totalLockedAmount;\n    case LaunchpadCurveRuleField.CliffPeriod:\n      return context.cliffPeriod;\n    case LaunchpadCurveRuleField.UnlockPeriod:\n      return context.unlockPeriod;\n    case LaunchpadCurveRuleField.BaseTokenProgram:\n      return new BN(context.baseTokenProgram);\n    case LaunchpadCurveRuleField.TransferFeeEnabled:\n      return new BN(context.transferFee === undefined ? 0 : 1);\n    case LaunchpadCurveRuleField.TransferFeeBasisPoints:\n      return new BN(context.transferFee?.basisPoints ?? 0);\n    case LaunchpadCurveRuleField.TransferFeeMaximumFee:\n      return context.transferFee?.maximumFee ?? new BN(0);\n    case LaunchpadCurveRuleField.SellRateA:\n      return rateOf(context.totalSellA);\n    case LaunchpadCurveRuleField.LockRate:\n      return rateOf(context.totalLockedAmount);\n    case LaunchpadCurveRuleField.MigrateAmountA:\n      return migrateAmountA();\n    case LaunchpadCurveRuleField.MigrateRateA: {\n      const amount = migrateAmountA();\n      return amount === undefined ? undefined : rateOf(amount);\n    }\n    case LaunchpadCurveRuleField.FundRaisingRateB:\n      return rateOf(context.totalFundRaisingB);\n    case LaunchpadCurveRuleField.UnixTimestamp:\n      return context.unixTimestamp;\n    default:\n      return undefined;\n  }\n}\n\nexport function isCurveRuleConstraintSatisfied(\n  constraint: LaunchpadCurveRuleConstraint,\n  context: LaunchpadCurveRuleContext,\n): boolean {\n  const actual = getCurveRuleFieldValue(context, constraint.field);\n  if (actual === undefined) return false;\n\n  switch (constraint.op) {\n    case LaunchpadCurveRuleOp.Eq:\n      return actual.eq(constraint.value);\n    case LaunchpadCurveRuleOp.Gte:\n      return actual.gte(constraint.value);\n    case LaunchpadCurveRuleOp.Lte:\n      return actual.lte(constraint.value);\n    case LaunchpadCurveRuleOp.Neq:\n      return !actual.eq(constraint.value);\n    default:\n      return false;\n  }\n}\n\nexport interface CurveRuleUnsatisfiedConstraint extends LaunchpadCurveRuleConstraint {\n  /** the value these launch parameters produce, `undefined` when it cannot be computed */\n  actual?: BN;\n}\n\nexport interface CurveRuleCheckResult {\n  ok: boolean;\n  matchedGroupId?: number;\n  groupFailures: { groupId: number; unsatisfied: CurveRuleUnsatisfiedConstraint[] }[];\n}\n\nexport function checkLaunchAgainstCurveRule({\n  rule,\n  context,\n}: {\n  rule: Pick<LaunchpadCurveRuleInfo, \"groups\"> | undefined;\n  context: LaunchpadCurveRuleContext;\n}): CurveRuleCheckResult {\n  const groups = rule?.groups ?? [];\n  if (groups.length === 0) return { ok: true, groupFailures: [] };\n\n  const groupFailures: CurveRuleCheckResult[\"groupFailures\"] = [];\n  for (const group of groups) {\n    const unsatisfied = group.constraints\n      .filter((constraint) => !isCurveRuleConstraintSatisfied(constraint, context))\n      .map((constraint) => ({ ...constraint, actual: getCurveRuleFieldValue(context, constraint.field) }));\n\n    if (unsatisfied.length === 0) return { ok: true, matchedGroupId: group.groupId, groupFailures: [] };\n    groupFailures.push({ groupId: group.groupId, unsatisfied });\n  }\n\n  return { ok: false, groupFailures };\n}\n\nexport interface CurveRuleWriteCheckResult {\n  ok: boolean;\n  errors: {\n    code:\n    | \"CurveRuleGroupsExceeded\"\n    | \"InvalidCurveRuleConstraint\"\n    | \"CurveRuleFieldNotSupportedByCurve\";\n    message: string;\n  }[];\n}\n\nexport function checkCurveRuleGroupWritable({\n  groupId,\n  constraints,\n  curveType,\n  existingGroupIds = [],\n}: {\n  groupId: number;\n  constraints: LaunchpadCurveRuleConstraint[];\n  curveType: number;\n  existingGroupIds?: number[];\n}): CurveRuleWriteCheckResult {\n  const errors: CurveRuleWriteCheckResult[\"errors\"] = [];\n\n  if (!existingGroupIds.includes(groupId) && existingGroupIds.length >= LAUNCHPAD_MAX_CURVE_RULE_GROUPS) {\n    errors.push({\n      code: \"CurveRuleGroupsExceeded\",\n      message: `a rule holds at most ${LAUNCHPAD_MAX_CURVE_RULE_GROUPS} groups, and group ${groupId} would be a new one`,\n    });\n  }\n\n  if (constraints.length > LAUNCHPAD_MAX_CONSTRAINTS_PER_GROUP) {\n    errors.push({\n      code: \"InvalidCurveRuleConstraint\",\n      message: `a group holds at most ${LAUNCHPAD_MAX_CONSTRAINTS_PER_GROUP} constraints, got ${constraints.length}`,\n    });\n  }\n\n  const seen = new Set<string>();\n  constraints.forEach((constraint, index) => {\n    if (constraint.field > LaunchpadCurveRuleField.UnixTimestamp) {\n      errors.push({\n        code: \"InvalidCurveRuleConstraint\",\n        message: `constraint ${index}: unknown field id ${constraint.field}`,\n      });\n    }\n    if (constraint.op > LaunchpadCurveRuleOp.Neq) {\n      errors.push({\n        code: \"InvalidCurveRuleConstraint\",\n        message: `constraint ${index}: unknown op id ${constraint.op}`,\n      });\n    }\n\n    const key = `${constraint.field}/${constraint.op}`;\n    if (seen.has(key)) {\n      errors.push({\n        code: \"InvalidCurveRuleConstraint\",\n        message: `constraint ${index}: field ${constraint.field} already has an op ${constraint.op} constraint in this group. A range uses two different ops on one field`,\n      });\n    }\n    seen.add(key);\n\n    if (\n      curveType !== 0 &&\n      LAUNCHPAD_CURVE_RULE_CONSTANT_PRODUCT_ONLY_FIELDS.includes(constraint.field)\n    ) {\n      errors.push({\n        code: \"CurveRuleFieldNotSupportedByCurve\",\n        message: `constraint ${index}: field ${constraint.field} reads totalSellA, which curve type ${curveType} derives itself, so the program refuses it on this config`,\n      });\n    }\n  });\n\n  return { ok: errors.length === 0, errors };\n}\n","import { PublicKey, Signer } from \"@solana/web3.js\";\nimport { ComputeBudgetConfig, TxTipConfig } from \"../type\";\nimport { TxVersion } from \"@/common\";\nimport BN from \"bn.js\";\nimport { LaunchpadPool, LaunchpadConfig, PlatformConfig, PlatformCurveRule } from \"./layout\";\nimport { TransferFeeConfig } from \"@solana/spl-token\";\n\nexport interface CreateLaunchPad<T = TxVersion.LEGACY> {\n  mintA: PublicKey;\n  name: string;\n  symbol: string;\n  buyAmount: BN;\n  platformId?: PublicKey;\n\n  programId?: PublicKey; // default mainnet\n  authProgramId?: PublicKey; // default mainnet\n  decimals?: number; // default 6\n  mintBDecimals?: number; // default 9\n  curType?: number; // default 0\n  configId: PublicKey;\n  configInfo?: LaunchpadConfigInfo;\n\n  minMintAAmount?: BN; // default calculated by realtime rpc data\n  slippage?: BN;\n\n  uri: string;\n  migrateType: \"amm\" | \"cpmm\";\n\n  supply?: BN;\n  totalSellA?: BN;\n  totalFundRaisingB?: BN;\n  totalLockedAmount?: BN;\n  cliffPeriod?: BN;\n  unlockPeriod?: BN;\n\n  shareFeeRate?: BN;\n  shareFeeReceiver?: PublicKey;\n  platformFeeRate?: BN; // for preload usage\n  platformVestingScale?: BN; // for preload usage\n\n  createOnly?: boolean;\n\n  computeBudgetConfig?: ComputeBudgetConfig;\n  txTipConfig?: TxTipConfig;\n  txVersion?: T;\n  feePayer?: PublicKey;\n  associatedOnly?: boolean;\n  checkCreateATAOwner?: boolean;\n  extraSigners?: Signer[];\n\n  token2022?: boolean;\n  transferFeeExtensionParams?: { transferFeeBasePoints: number; maxinumFee: BN };\n  creatorFeeOn?: CpmmCreatorFeeOn;\n  platformAllowConfig?: boolean;\n\n  mintBProgram?: PublicKey;\n  transferFeeConfigB?: TransferFeeConfig | undefined;\n  skipCheckMintB?: boolean;\n}\n\nexport interface BuyToken<T = TxVersion.LEGACY> {\n  mintA: PublicKey;\n  mintAProgram?: PublicKey;\n  mintBProgram?: PublicKey;\n  buyAmount: BN;\n\n  programId?: PublicKey; // default mainnet\n  authProgramId?: PublicKey; // default mainnet\n  mintB?: PublicKey; // default SOL\n  poolInfo?: LaunchpadPoolInfo; // default calculated from mint\n  minMintAAmount?: BN; // default calculated by realtime rpc data\n  slippage?: BN;\n  shareFeeRate?: BN;\n  shareFeeReceiver?: PublicKey;\n\n  configInfo?: LaunchpadConfigInfo; // for preload usage\n  platformFeeRate?: BN; // for preload usage\n\n  computeBudgetConfig?: ComputeBudgetConfig;\n  txTipConfig?: TxTipConfig;\n  txVersion?: T;\n  feePayer?: PublicKey;\n  associatedOnly?: boolean;\n  checkCreateATAOwner?: boolean;\n  transferFeeConfigA?: TransferFeeConfig | undefined;\n  transferFeeConfigB?: TransferFeeConfig | undefined;\n  skipCheckMintA?: boolean;\n  skipCheckMintB?: boolean;\n  fromCreate?: boolean;\n}\n\nexport interface BuyTokenExactOut<T = TxVersion.LEGACY>\n  extends Omit<BuyToken, \"buyAmount\" | \"minMintAAmount\" | \"txVersion\"> {\n  maxBuyAmount?: BN;\n  outAmount: BN;\n  txVersion?: T;\n}\n\nexport interface SellToken<T = TxVersion.LEGACY> {\n  mintA: PublicKey;\n  mintAProgram?: PublicKey;\n  mintBProgram?: PublicKey;\n  sellAmount: BN;\n  slippage?: BN;\n\n  programId?: PublicKey; // default mainnet\n  authProgramId?: PublicKey; // default mainnet\n  poolInfo?: LaunchpadPoolInfo; // default calculated from mint\n  mintB?: PublicKey; // default SOL\n  minAmountB?: BN; // default SOL decimals 9\n\n  shareFeeRate?: BN;\n  shareFeeReceiver?: PublicKey;\n\n  configInfo?: LaunchpadConfigInfo; // for preload usage\n  platformFeeRate?: BN; // for preload usage\n\n  computeBudgetConfig?: ComputeBudgetConfig;\n  txTipConfig?: TxTipConfig;\n  txVersion?: T;\n  feePayer?: PublicKey;\n  associatedOnly?: boolean;\n  checkCreateATAOwner?: boolean;\n  transferFeeConfigB?: TransferFeeConfig | undefined;\n  skipCheckMintA?: boolean;\n  skipCheckMintB?: boolean;\n}\n\nexport interface SellTokenExactOut<T = TxVersion.LEGACY> extends Omit<SellToken, \"sellAmount\" | \"txVersion\"> {\n  maxSellAmount?: BN;\n  inAmount: BN;\n  txVersion?: T;\n}\n\nexport interface CreatePlatform<T = TxVersion.LEGACY> {\n  programId?: PublicKey;\n\n  platformAdmin: PublicKey;\n  platformClaimFeeWallet: PublicKey;\n  platformLockNftWallet: PublicKey;\n  platformVestingWallet: PublicKey;\n  cpConfigId: PublicKey;\n\n  migrateCpLockNftScale: {\n    platformScale: BN;\n    creatorScale: BN;\n    burnScale: BN;\n  };\n\n  transferFeeExtensionAuth: PublicKey;\n  creatorFeeRate: BN;\n  feeRate: BN;\n  name: string;\n  web: string;\n  img: string;\n  platformVestingScale?: BN;\n\n  computeBudgetConfig?: ComputeBudgetConfig;\n  txTipConfig?: TxTipConfig;\n  txVersion?: T;\n  feePayer?: PublicKey;\n}\n\nexport interface CreatePlatformAllowConfig<T = TxVersion.LEGACY> {\n  programId?: PublicKey;\n\n  platformAdmin: PublicKey;\n  platformId: PublicKey;\n\n  configInfo: {\n    mintB: string | PublicKey;\n    curveType: number;\n    index: number;\n  };\n\n  computeBudgetConfig?: ComputeBudgetConfig;\n  txTipConfig?: TxTipConfig;\n  txVersion?: T;\n  feePayer?: PublicKey;\n}\n\nexport interface CreatePlatformCurveRule<T = TxVersion.LEGACY> {\n  programId?: PublicKey;\n\n  curveRuleAuthority?: PublicKey;\n  platformId: PublicKey;\n  configId: PublicKey;\n\n  computeBudgetConfig?: ComputeBudgetConfig;\n  txTipConfig?: TxTipConfig;\n  txVersion?: T;\n  feePayer?: PublicKey;\n}\n\nexport interface UpdatePlatformCurveRule<T = TxVersion.LEGACY> {\n  programId?: PublicKey;\n\n  curveRuleAuthority?: PublicKey;\n  platformCurveRuleId: PublicKey;\n  groupId: number;\n  constraints: LaunchpadCurveRuleConstraint[];\n\n  computeBudgetConfig?: ComputeBudgetConfig;\n  txTipConfig?: TxTipConfig;\n  txVersion?: T;\n  feePayer?: PublicKey;\n}\n\nexport interface UpdatePlatform<T = TxVersion.LEGACY> {\n  programId?: PublicKey;\n\n  platformAdmin: PublicKey;\n  platformId?: PublicKey;\n\n  updateInfo:\n    | { type: \"updateClaimFeeWallet\" | \"updateLockNftWallet\"; value: PublicKey }\n    | { type: \"updateFeeRate\"; value: BN }\n    | { type: \"updateName\" | \"updateImg\" | \"updateWeb\"; value: string }\n    | { type: \"migrateCpLockNftScale\"; value: { platformScale: BN; creatorScale: BN; burnScale: BN } }\n    | { type: \"updateCpConfigId\"; value: PublicKey }\n    | { type: \"updateVestingWallet\"; value: PublicKey }\n    | { type: \"updatePlatformVestingScale\"; value: BN }\n    | { type: \"updatePlatformCpCreator\"; value: PublicKey }\n    | { type: \"updateRestrictGlobalConfig\"; value: BN }\n    | { type: \"updateRestrictCurveParam\"; value: BN }\n    | { type: \"updateCurveRuleManager\"; value: PublicKey }\n    | {\n        type: \"updateAll\";\n        value: {\n          platformClaimFeeWallet: PublicKey;\n          platformLockNftWallet: PublicKey;\n          platformVestingWallet: PublicKey;\n          cpConfigId: PublicKey;\n          migrateCpLockNftScale: {\n            platformScale: BN;\n            creatorScale: BN;\n            burnScale: BN;\n          };\n          feeRate: BN;\n          name: string;\n          web: string;\n          img: string;\n          transferFeeExtensionAuth: PublicKey;\n          creatorFeeRate: BN;\n          platformVestingScale: BN;\n        };\n      };\n\n  computeBudgetConfig?: ComputeBudgetConfig;\n  txTipConfig?: TxTipConfig;\n  txVersion?: T;\n  feePayer?: PublicKey;\n}\n\nexport interface CreatePlatformVestingAccount<T = TxVersion.LEGACY> {\n  programId?: PublicKey;\n\n  platformVestingWallet: PublicKey;\n  beneficiary: PublicKey;\n  platformId: PublicKey;\n  poolId: PublicKey;\n  vestingRecord?: PublicKey;\n\n  computeBudgetConfig?: ComputeBudgetConfig;\n  txTipConfig?: TxTipConfig;\n  txVersion?: T;\n  feePayer?: PublicKey;\n}\nexport interface ClaimPlatformFee<T = TxVersion.LEGACY> {\n  programId?: PublicKey;\n  authProgramId?: PublicKey;\n  platformId: PublicKey;\n  platformClaimFeeWallet: PublicKey;\n  poolId: PublicKey;\n\n  mintB?: PublicKey;\n  vaultB?: PublicKey;\n  mintBProgram?: PublicKey;\n\n  computeBudgetConfig?: ComputeBudgetConfig;\n  txTipConfig?: TxTipConfig;\n  txVersion?: T;\n  feePayer?: PublicKey;\n}\n\nexport interface ClaimAllPlatformFee<T = TxVersion.LEGACY> {\n  programId?: PublicKey;\n  authProgramId?: PublicKey;\n  platformId: PublicKey;\n  platformClaimFeeWallet: PublicKey;\n\n  computeBudgetConfig?: ComputeBudgetConfig;\n  txTipConfig?: TxTipConfig;\n  txVersion?: T;\n  feePayer?: PublicKey;\n}\n\nexport interface CreateVesting<T = TxVersion.LEGACY> {\n  programId?: PublicKey;\n  poolId: PublicKey;\n  beneficiary: PublicKey;\n  shareAmount: BN;\n\n  computeBudgetConfig?: ComputeBudgetConfig;\n  txTipConfig?: TxTipConfig;\n  txVersion?: T;\n  feePayer?: PublicKey;\n}\n\nexport interface CreateMultipleVesting<T = TxVersion.LEGACY> {\n  programId?: PublicKey;\n  poolId: PublicKey;\n  beneficiaryList: {\n    wallet: PublicKey;\n    shareAmount: BN;\n  }[];\n\n  computeBudgetConfig?: ComputeBudgetConfig;\n  txVersion?: T;\n  feePayer?: PublicKey;\n}\n\nexport interface ClaimVesting<T = TxVersion.LEGACY> {\n  programId?: PublicKey;\n\n  poolId: PublicKey;\n  vestingRecord?: PublicKey;\n  poolInfo?: LaunchpadPoolInfo;\n\n  computeBudgetConfig?: ComputeBudgetConfig;\n  txTipConfig?: TxTipConfig;\n  txVersion?: T;\n  feePayer?: PublicKey;\n}\n\nexport interface ClaimMultiVesting<T = TxVersion.LEGACY> {\n  programId?: PublicKey;\n  poolIdList: PublicKey[];\n  vestingRecords?: Record<string, PublicKey>;\n  poolsInfo?: Record<\n    string,\n    {\n      mintA: PublicKey;\n      vaultA: PublicKey;\n    }\n  >;\n\n  computeBudgetConfig?: ComputeBudgetConfig;\n  txVersion?: T;\n  feePayer?: PublicKey;\n}\n\nexport interface ClaimVaultPlatformFee<T = TxVersion.LEGACY> {\n  programId?: PublicKey;\n\n  platformId: PublicKey;\n  mintB: PublicKey;\n  mintBProgram?: PublicKey;\n\n  claimFeeWallet?: PublicKey;\n\n  computeBudgetConfig?: ComputeBudgetConfig;\n  txTipConfig?: TxTipConfig;\n  txVersion?: T;\n  feePayer?: PublicKey;\n}\n\nexport interface ClaimMultipleVaultPlatformFee<T = TxVersion.LEGACY> {\n  programId?: PublicKey;\n\n  platformList: {\n    id: PublicKey;\n    mintB: PublicKey;\n    mintBProgram?: PublicKey;\n    claimFeeWallet?: PublicKey;\n  }[];\n\n  unwrapSol?: boolean;\n  computeBudgetConfig?: ComputeBudgetConfig;\n  txVersion?: T;\n  feePayer?: PublicKey;\n  associatedOnly?: boolean;\n  checkCreateATAOwner?: boolean;\n}\n\nexport interface ClaimCreatorFee<T = TxVersion.LEGACY> {\n  programId?: PublicKey;\n  mintB: PublicKey;\n  mintBProgram?: PublicKey;\n  computeBudgetConfig?: ComputeBudgetConfig;\n  txTipConfig?: TxTipConfig;\n  txVersion?: T;\n  feePayer?: PublicKey;\n}\n\nexport interface ClaimMultiCreatorFee<T = TxVersion.LEGACY> {\n  programId?: PublicKey;\n  mintBList: {\n    pubKey: PublicKey;\n    programId?: PublicKey;\n  }[];\n  computeBudgetConfig?: ComputeBudgetConfig;\n  txTipConfig?: TxTipConfig;\n  txVersion?: T;\n  feePayer?: PublicKey;\n}\n\nexport type LaunchpadPoolInfo = ReturnType<typeof LaunchpadPool.decode>;\nexport type LaunchpadConfigInfo = ReturnType<typeof LaunchpadConfig.decode>;\nexport type LaunchpadPlatformInfo = ReturnType<typeof PlatformConfig.decode>;\nexport type LaunchpadCurveRuleInfo = ReturnType<typeof PlatformCurveRule.decode>;\n\nexport enum LaunchpadCurveRuleField {\n  CurveType = 0,\n  MigrateType = 1,\n  MigrateCpmmFeeOn = 2,\n  Supply = 3,\n  TotalSellA = 4,\n  TotalFundRaisingB = 5,\n  TotalLockedAmount = 6,\n  CliffPeriod = 7,\n  UnlockPeriod = 8,\n  /** 0: the base mint belongs to spl token, 1: to token2022, see LaunchpadCurveRuleBaseTokenProgram */\n  BaseTokenProgram = 9,\n  /** 1 when the base mint carries the transfer fee extension, 0 when it does not */\n  TransferFeeEnabled = 10,\n  /** the transfer fee rate of the base mint, denominator 10000, 0 without the extension */\n  TransferFeeBasisPoints = 11,\n  /** the maximum transfer fee of the base mint, 0 without the extension */\n  TransferFeeMaximumFee = 12,\n  /** derived: totalSellA / supply, denominated in 10^-6 */\n  SellRateA = 13,\n  /** derived: totalLockedAmount / supply, denominated in 10^-6 */\n  LockRate = 14,\n  /** derived: supply - totalSellA - totalLockedAmount, the base amount reaching the migrated pool */\n  MigrateAmountA = 15,\n  /** derived: migrate amount / supply, denominated in 10^-6 */\n  MigrateRateA = 16,\n  /** derived: totalFundRaisingB / supply, denominated in 10^-6, a band on the graduation valuation */\n  FundRaisingRateB = 17,\n  /** the block time the pool is created at, in seconds, it lets a group carry a validity window */\n  UnixTimestamp = 18,\n}\n\n/**\n * The fields that read totalSellA. They are only accepted on a constant product config: the\n * fixed and the linear curve derive the sell amount themselves, so the program refuses\n * these fields when the rule of such a config is written.\n */\nexport const LAUNCHPAD_CURVE_RULE_CONSTANT_PRODUCT_ONLY_FIELDS = [\n  LaunchpadCurveRuleField.TotalSellA,\n  LaunchpadCurveRuleField.SellRateA,\n  LaunchpadCurveRuleField.MigrateAmountA,\n  LaunchpadCurveRuleField.MigrateRateA,\n];\n\nexport enum LaunchpadCurveRuleOp {\n  Eq = 0,\n  /** min */\n  Gte = 1,\n  /** max */\n  Lte = 2,\n  Neq = 3,\n}\n\nexport enum LaunchpadCurveRuleBaseTokenProgram {\n  SplToken = 0,\n  Token2022 = 1,\n}\n\nexport interface LaunchpadCurveRuleConstraint {\n  field: LaunchpadCurveRuleField;\n  op: LaunchpadCurveRuleOp;\n  value: BN;\n}\n\nexport const LAUNCHPAD_MAX_CURVE_RULE_GROUPS = 10;\nexport const LAUNCHPAD_MAX_CONSTRAINTS_PER_GROUP = 25;\nexport enum CpmmCreatorFeeOn {\n  OnlyTokenB,\n  BothToken,\n}\n"],"mappings":"6aAAA,qBCicO,GAAM,GAAoD,CAC/D,EACA,GACA,GACA,EACF,EAsBO,GAAM,GAAkC,GAClC,EAAsC,GDjdnD,GAAM,GAAmB,GAAI,GAAG,GAAS,EAmBlC,WACL,EACA,EACgB,CAlClB,YAmCE,GAAM,GAAS,AAAC,GACd,EAAQ,OAAO,OAAO,EAAI,OAAY,EAAO,IAAI,CAAgB,EAAE,I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