Meteora 백서

Meteora

원문

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 75쪽 중 29쪽

int)` | Scan pools by `tokenAMint`. | | `fetchPoolFees(pool)` | Decode the pod-aligned base-fee data stored in one pool account. | | `fetchPositionState(position)` | Fetch one position account. | | `getMultipleConfigs(configs)` | Batch fetch config accounts. | | `getMultiplePools(pools)` | Batch fetch pool accounts. | | `getMultiplePositions(positions)` | Batch fetch position accounts. | | `getAllConfigs()` | Scan all config accounts. | | `getStaticConfigs()` | Scan static configs with default vault and creator authorities. | | `getAllPools()` | Scan all pool accounts. Prefer an indexed API for broad app discovery. | | `getAllPositions()` | Scan all position accounts. | | `getAllPositionsByPool(pool)` | Scan all position accounts for one pool. | | `getUserPositionByPool(pool, user)` | Resolve a user's position NFTs and filter them to one pool. | | `getPositionsByUser(user)` | Resolve all Token-2022 position NFTs owned by a wallet and fetch their positions. | | `getAllVestingsByPosition(position)` | Fetch vesting accounts attached to one position. | | `isPoolExist(pool)` | Return whether a pool account exists. | ### `CpAmm` Position State Helpers | Method | Use | | - | - | | `isLockedPosition(position)` | Check whether a position has any locked liquidity. | | `isPermanentLockedPosition(positionState)` | Check whether a position has permanently locked liquidity. | | `canUnlockPosition(positionState, vestings, currentPoint)` | Check unlock eligibility against permanent locks and vesting schedules. | ### `CpAmm` Quote And Preparation Methods | Method | Use | | - | - | | `getLiquidityDelta(params)` | Compute Q64 liquidity from token amount caps, price range, and collect-fee mode. | | `getQuote(params)` | Legacy exact-in swap quote. | | `getQuote2(params)` | Preferred swap quote for exact-in, partial-fill, and exact-out modes. | | `getDepositQuote(params)` | Convert a token input amount into liquidity and counterpart amount. | | `getWithdrawQuote(params)` | Convert liquidity into expected token A and token B outputs. | | `preparePoolCreationSingleSide(params)` | Prepare one-sided concentrated pool creation where the initial price is the min price. | | `preparePoolCreationParams(params)` | Compute initial square-root price, liquidity, and token amounts for pool creation. | ### `CpAmm` Transaction Builders | Method | Use | | - | - | | `createPool(params)` | Build a permissionless pool creation transaction. Rejects `RateLimiter` with `DeprecatedBaseFeeModeError`. | | `createCustomPool(params)` | Build a customizable pool creation transaction and return `{ tx, pool, position }`. Rejects `RateLimiter` with `DeprecatedBaseFeeModeError`. | | `createCustomPoolWithDynamicConfig(params)` | Build a customizable pool creation transaction with dynamic config and return `{ tx, pool, position }`. Rejects `RateLimiter` with `DeprecatedBaseFeeModeError`. | | `createPosition(params)` | Build a transaction that creates a position NFT and position account. | | `addLiquidity(params)` | Build a transaction that adds liquidity to an existing position. | | `createPositionAndAddLiquidity(params)` | Build a combined position creation and add-liquidity transaction. | | `removeLiquidity(params)` | Build a transaction that removes a liquidity delta from a position. | | `removeAllLiquidity(params)` | Build a transaction that removes all unlocked liquidity from a position. | | `swap(params)` | Build the legacy swap transaction. | | `swap2(params)` | Build the preferred swap transaction for `SwapMode.ExactIn`, `PartialFill`, or `ExactOut`. | | `lockPosition(params)` | Build a transaction that locks liquidity with vesting. | | `permanentLockPosition(params)` | Build a transaction that permanently locks liquidity. | | `refreshVesting(params)` | Build a transaction that refreshes vesting state for a position. | | `closePosition(params)` | Build a transaction that closes an empty position. | | `removeAllLiquidityAndClosePosition(params)` | Build a combined claim-fee, remove-all-liquidity, and close-position transaction. | | `mergePosition(params)` | Build a transaction that claims fees, removes source liquidity, adds it to a target position, and closes the source position. | | `initializeReward(params)` | Build a transaction that initializes a reward slot. | | `initializeAndFundReward(params)` | Build a transaction that initializes and funds a reward slot. | | `updateRewardDuration(params)` | Build a transaction that updates reward duration. | | `updateRewardFunder(params)` | Build a transaction that updates reward funder authority. | | `fundReward(params)` | Build a transaction that funds an initialized reward. | | `withdrawIneligibleReward(params)` | Build a transaction that withdraws ineligible reward emissions. | | `claimPositionFee(params)` | Build a transaction that claims position trading fees. | | `claimPositionFee2(params)` | Build the newer position-fee claim transaction. | | `claimReward(params)` | Build a transaction that claims one reward index for a position. | | `splitPosition(params)` | Build a transaction that splits a position into a new position with explicit token amounts. | | `splitPosition2(params)` | Build the newer split transaction using a numerator over `SPLIT_POSITION_DENOMINATOR`. | ### PDA Helpers | Function | Use | | - | - | | `getFirstKey(key1, key2)` | Return the lexicographically first key buffer for sorted mint seeds. | | `getSecondKey(key1, key2)` | Return the lexicographically second key buffer for sorted mint seeds. | | `derivePoolAuthority()` | Derive the global pool authority PDA. | | `deriveConfigAddress(index)` | Derive a config PDA from a `u64` index. | | `derivePoolAddress(config, tokenAMint, tokenBMint)` | Derive a permissionless pool PDA from config and sorted token mints. | | `derivePositionAddress(positionNft)` | Derive a position PDA from the position NFT mint. | | `deriveTokenVaultAddress(tokenMint, pool)` | Derive a token vault PDA. | | `deriveRewardVaultAddress(pool, rewardIndex)` | Derive a reward vault PDA. | | `deriveCustomizablePoolAddress(tokenAMint, tokenBMint)` | Derive a customizable pool PDA from sorted token mints. | | `deriveTokenBadgeAddress(tokenMint)` | Derive a token badge PDA. | | `deriveClaimFeeOperatorAddress(operator)` | Derive a claim-fee operator PDA. | | `derivePositionNftAccount(positionNftMint)` | Derive the canonical position NFT token account. | | `deriveOperatorAddress(whitelistedAddress)` | Derive an operator PDA for a whitelisted address. | ### Token, Account, And Compute Helpers | Function | Use | | - | - | | `getTokenProgram(flag)` | Convert a pool token flag into the SPL Token or Token-2022 program ID. | | `getTokenDecimals(connection, mint, tokenProgram)` | Fetch mint decimals. | | `getOrCreateATAInstruction(tokenMint, owner, payer, allowOwnerOffCurve, tokenProgram)` | Resolve an ATA and return creation instructions when needed. | | `wrapSOLInstruction(from, to, amount)` | Build native SOL wrapping instructions. | | `unwrapSOLInstruction(owner, receiver?, allowOwnerOffCurve?)` | Build a wrapped SOL close-account instruction. | | `getAllUserPositionNftAccount(connection, user)` | Fetch the user's position NFT accounts. | | `getAllPositionNftAccountByOwner(connection, user)` | Fetch Token-2022 position NFT accounts by owner. | | `getSimulationComputeUnits(connection, instructions, payer, lookupTables, commitment?)` | Simulate instructions and return consumed compute units. | | `getEstimatedComputeUnitUsageWithBuffer(connection, instructions, feePayer, buffer?)` | Estimate compute units with a bounded buffer. | | `getEstimatedComputeUnitIxWithBuffer(connection, instructions, feePayer, buffer?)` | Build a compute-budget instruction from estimated units. | ### UI, Price, Reward, And Account Filter Helpers | Function | Use | | - | - | | `getMaxAmountWithSlippage(amount, rate)` | Apply a max slippage rate to an amount. | | `getAmountWithSlippage(amount, slippageBps, swapMode)` | Adjust an amount by slippage according to swap mode. | | `getPriceImpact(amountIn, amountOut, currentSqrtPrice, aToB, tokenADecimal, tokenBDecimal)` | Compute price impact for a quote. | | `getPriceChange(nextSqrtPrice, currentSqrtPrice)` | Compute price-change percentage from two square-root prices. | | `getPriceFromSqrtPrice(sqrtPrice, tokenADecimal, tokenBDecimal)` | Convert Q64 square-root price to UI price. | | `getSqrtPriceFromPrice(price, tokenADecimal, tokenBDecimal)` | Convert UI price to Q64 square-root price. | | `getUnClaimLpFee(poolState, positionState)` | Compute unclaimed LP fee amounts. | | `getRewardInfo(poolState, rewardIndex, periodTime, currentTime)` | Compute current reward info for one reward index. | | `getUserRewardPending(poolState, positionState, rewardIndex, currentTime, periodTime)` | Compute pending user reward for one position and reward index. | | `positionByPoolFilter(pool)` | Build a `getProgramAccounts` filter for positions by pool. | | `vestingByPositionFilter(position)` | Build a `getProgramAccounts` filter for vesting accounts by position. | | `offsetBasedFilter(value, offset)` | Build a memcmp filter at an arbitrary account offset. | ### Token-2022 Helpers | Function | Use | | - | - | | `calculateTransferFeeIncludedAmount(transferFeeExcludedAmount, mint, currentEpoch)` | Compute an amount that includes Token-2022 transfer fees. | | `calculateTransferFeeExcludedAmount(transferFeeIncludedAmount, mint, currentEpoch)` | Compute the post-fee amount for a Token-2022 transfer. | | `hasTransferHookExtension(connection, mint)` | Detect whether a mint uses a transfer-hook extension. | | `validateNoTransferHook(connection, tokenAMint, tokenBMint)` | Throw when either token mint has a Transfer Hook extension that is not permissionlessly accepted (hook program ID or authority still set). | ### Vesting Helpers | Function | Use | | - | - | | `isVestingComplete(vestingData, currentPoint)` | Check whether a vesting schedule is complete. | | `getTotalLockedLiquidity(vestingData)` | Sum locked liquidity in a vesting account. | | `getAvailableVestingLiquidity(vestingData, currentPoint)` | Compute currently unlocked liquidity from vesting data. | ### Validation Helpers | Function | Use | | - | - | | `validateFeeTimeScheduler(numberOfPeriod, periodFrequency, reductionFactor, cliffFeeNumerator, baseFeeMode, feeVersion)` | Validate time-scheduler fee parameters. | | `validateFeeTimeSchedulerBaseFeeIsStatic(currentPoint, activationPoint, numberOfPeriod, periodFrequency)` | Check whether a time-scheduler base fee is already static. | | `validateFeeMarketCapScheduler(cliffFeeNumerator, numberOfPeriod, sqrtPriceStepBps, reductionFactor, schedulerExpirationDuration, feeMarketCapSchedulerMode, feeVersion)` | Validate market-cap scheduler parameters. | | `validateFeeMarketCapBaseFeeIsStatic(currentPoint, activationPoint, schedulerExpirationDuration)` | Check whether a market-cap scheduler base fee is already static. | | `validateFeeRateLimiter(cliffFeeNumerator, feeIncrementBps, maxFeeBps, maxLimiterDuration, referenceAmount, collectFeeMode, activationType, feeVersion)` | Validate rate-limiter fee parameters. | | `validateFeeRateLimiterBaseFeeIsStatic(currentPoint, activationPoint, maxLimiterDuration, referenceAmount, maxFeeBps, feeIncrementBps)` | Check whether a rate-limiter base fee is already static. | | `validateFeeFraction(numerator, denominator)` | Validate a fee fraction. | | `validateCollectFeeMode(collectFeeMode)` | Validate a collect-fee mode value. | | `validateActivationType(activationType)` | Validate an activation type value. | | `validatePriceRange(collectFeeMode, sqrtMinPrice, sqrtMaxPrice)` | Validate a pool price range for the chosen collect-fee mode. | | `validateInitialSqrtPrice(collectFeeMode, initSqrtPrice, sqrtMinPrice, sqrtMaxPrice)` | Validate an initial square-root price. | | `validateCompoundingFee(collectFeeMode, compoundingFeeBps)` | Validate compounding-fee settings. | | `validateDynamicFee(dynamicFee)` | Validate dynamic-fee parameters. | | `validatePoolFees(poolFees, collectFeeMode, activationType, feeVersion?)` | Validate pool fee settings. Throws `DeprecatedBaseFeeModeError` for `RateLimiter`. | | `validateCustomizablePoolParams(params)` | Validate customizable pool creation parameters. | | `validateTokenMints(tokenAMint, tokenBMint)` | Validate that token mints are distinct. | | `validateCreatePoolParams(params)` | Validate permissionless pool creation parameters. | | `validateAddLiquidityParams(liquidityDelta)` | Validate add-liquidity amount. | | `validateRemoveLiquidityParams(liquidityDelta)` | Validate remove-liquidity amount. | | `validateSplitPositionParams(params)` | Validate legacy split-position parameters. | | `validateSplitPosition2Params(numerator)` | Validate split-position v2 ratio numerator. | | `validateLockPositionParams(params)` | Validate lock-position parameters. | | `validateRewardIndex(rewardIndex)` | Validate a reward index against `NUM_REWARDS`. | | `validateRewardDuration(rewardDuration)` | Validate reward duration bounds. | | `isConfigPermissionAllow(permission, flag)` | Return whether a `ConfigState.permission` bitmask (`BN`) includes a `ConfigPermission` flag. | ### Common Fee Encoding Helpers | Function | Use | | - | - | | `getCurrentPoint(connection, activationType)` | Fetch current slot or timestamp for an activation type. | | `isSwapEnabled(pool)` | Check pool status and activation point before swapping. | | `convertToFeeSchedulerSecondFactor(value)` | Convert a scheduler second factor into byte data. | | `parseFeeSchedulerSecondFactor(secondFactor)` | Parse scheduler second-factor bytes. | | `convertToRateLimiterSecondFactor(maxLimiterDuration, maxFeeBps)` | Convert rate-limiter secondary params into byte data. | | `parseRateLimiterSecondFactor(secondFactor)` | Parse rate-limiter secondary params from bytes. | | `bpsToFeeNumerator(bps)` | Convert basis points to DAMM v2 fee numerator. | | `feeNumeratorToBps(feeNumerator)` | Convert DAMM v2 fee numerator to basis points. | | `convertToLamports(amount, tokenDecimal)` | Convert UI token amount to integer token units. | | `fromDecimalToBN(value)` | Convert a `Decimal` to `BN`. | | `getFeeTimeSchedulerParams(startingBaseFeeBps, endingBaseFeeBps, baseFeeMode, numberOfPeriod, totalDuration)` | Build time-scheduler base-fee params. | | `computeSqrtPriceStepBps(priceMultiple, numberOfPeriod)` | Compute market-cap scheduler square-root price step bps. | | `getFeeMarketCapSchedulerParams(startingBaseFeeBps, endingBaseFeeBps, baseFeeMode, numberOfPeriod, priceMultiple, schedulerExpirationDuration)` | Build market-cap scheduler base-fee params. | | `getRateLimiterParams(baseFeeBps, feeIncrementBps, referenceAmount, maxLimiterDuration, maxFeeBps, tokenBDecimal, activationType)` | Build rate-limiter base-fee params for existing rate-limiter pools. Still requires `tokenBDecimal` and `activationType`. | | `getBaseFeeParams(baseFeeParams)` | Build base-fee params from a high-level config object. Throws `DeprecatedBaseFeeModeError` when `baseFeeMode` is `RateLimiter`. | | `getDynamicFeeParams(baseFeeBps, maxPriceChangeBps?)` | Build default dynamic-fee params from base fee and max price change. | | `encodeFeeTimeSchedulerParams(cliffFeeNumerator, numberOfPeriod, periodFrequency, reductionFactor, baseFeeMode)` | Borsh-encode time-scheduler fee params. | | `decodeFeeTimeSchedulerParams(data)` | Decode Borsh time-scheduler fee params, such as event data. | | `decodePodAlignedFeeTimeScheduler(data)` | Decode pod-aligned time-scheduler params from pool state. | | `encodeFeeMarketCapSchedulerParams(cliffFeeNumerator, numberOfPeriod, sqrtPriceStepBps, schedulerExpirationDuration, reductionFactor, baseFeeMode)` | Borsh-encode market-cap scheduler params. | | `decodeFeeMarketCapSchedulerParams(data)` | Decode Borsh market-cap scheduler params, such as event data. | | `decodePodAlignedFeeMarketCapScheduler(data)` | Decode pod-aligned market-cap scheduler params from pool state. | | `encodeFeeRateLimiterParams(cliffFeeNumerator, feeIncrementBps, maxLimiterDuration, maxFeeBps, referenceAmount)` | Borsh-encode rate-limiter params. | | `decodeFeeRateLimiterParams(data)` | Decode Borsh rate-limiter params, such as event data. | | `decodePodAlignedFeeRateLimiter(data)` | Decode pod-aligned rate-limiter params from pool state. | <Warning> The same base-fee mode uses different byte layouts in initialize events and pool accounts. Decode `EvtInitializePool` base-fee data with Borsh decoders and pool-state base-fee data with pod-aligned decoders. </Warning> ### Compounding Liquidity Math | Function | Use | | - | - | | `getInitialCompoundingPoolInformation(sqrtPrice, liquidity)` | Compute initial compounding pool bounds and reserves. | | `getAmountsForModifyForCompoundingLiquidity(tokenAAmount, tokenBAmount, liquidity, liquidityDelta, round)` | Compute proportional token amounts for modifying compounding liquidity. | | `calculateAtoBFromAmountInForCompoundingLiquidity(tokenAAmount, tokenBAmount, amountIn)` | Simulate exact-input A to B swap math for compounding liquidity. | | `calculateBtoAFromAmountInForCompoundingLiquidity(tokenAAmount, tokenBAmount, amountIn)` | Simulate exact-input B to A swap math for compounding liquidity. | | `calculateAtoBFromPartialAmountInForCompoundingLiquidity(tokenAAmount, tokenBAmount, amountIn)` | Simulate partial-input A to B swap math for compounding liquidity. | | `calculateBtoAFromPartialAmountInForCompoundingLiquidity(tokenAAmount, tokenBAmount, amountIn)` | Simulate partial-input B to A swap math for compounding liquidity. | | `calculateAtoBFromAmountOutForCompoundingLiquidity(tokenAAmount, tokenBAmount, amountOut)` | Simulate exact-output A to B swap math for compounding liquidity. | | `calculateBtoAFromAmountOutForCompoundingLiquidity(tokenAAmount, tokenBAmount, amountOut)` | Simulate exact-output B to A swap math for compounding liquidity. | | `getReservesAmountForCompoundingLiquidity(tokenAAmount, tokenBAmount)` | Return compounding reserves. | | `getNextSqrtPriceForCompoundingLiquidity(tokenAAmount, tokenBAmount)` | Compute next square-root price from reserves. | | `getSqrtPriceFromAmountsForCompoundingLiquidity(tokenAAmount, tokenBAmount)` | Compute square-root price from token amounts. | | `getAmountAFromLiquidityDeltaForCompoundingLiquidity(liquidityDelta, tokenAAmount, liquidity, rounding)` | Compute token A amount from compounding liquidity delta. | | `getAmountBFromLiquidityDeltaForCompoundingLiquidity(liquidityDelta, tokenBAmount, liquidity, rounding)` | Compute token B amount from compounding liquidity delta. | | `getPoolCreationAmountAFromLiquidityDeltaForCompoundingLiquidity(sqrtPrice, liquidity)` | Compute token A needed for compounding pool creation. | | `getPoolCreationAmountBFromLiquidityDeltaForCompoundingLiquidity(sqrtPrice, liquidity)` | Compute token B needed for compounding pool creation. | | `getLiquidityDeltaFromAmountAForCompoundingLiquidity(amountA, tokenAAmount, liquidity)` | Compute compounding liquidity delta from token A amount. | | `getLiquidityDeltaFromAmountBForCompoundingLiquidity(amountB, tokenBAmount, liquidity)` | Compute compounding liquidity delta from token B amount. | | `getPoolCreationLiquidityDeltaFromAmountAForCompoundingLiquidity(amountA, sqrtPrice)` | Compute compounding pool-creation liquidity from token A. | | `getPoolCreationLiquidityDeltaFromAmountBForCompoundingLiquidity(amountB, sqrtPrice)` | Compute compounding pool-creation liquidity from token B. | ### Concentrated Liquidity Math | Function | Use | | - | - | | `getInitialConcentratedLiquidityPoolInformation(sqrtMinPrice, sqrtMaxPrice, sqrtPrice, liquidity)` | Compute initial concentrated pool information. | | `getAmountsForModifyForConcentratedLiquidity(sqrtPrice, sqrtMinPrice, sqrtMaxPrice, liquidityDelta, round)` | Compute token amounts for modifying concentrated liquidity. | | `calculateAtoBFromAmountInForConcentratedLiquidity(sqrtMinPrice, sqrtPri
프로젝트로 돌아가기