Meteora 백서

Meteora

원문

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

than the number of periods. * `validateConfigParameters` takes an options object, checks the curve shape before any curve math runs on it, and only applies the fee-claimer rule when `feeClaimer` is passed. * Rate-limiter validation checks the fee at `u64::MAX`. Swap quotes reject amounts outside the program's `u64` and `u128` bounds and `slippageBps` outside `[0, 10_000]`. * Errors that mirror a program error use the program's message: `Math operation overflow`, `Type cast error`, `Pool is completed`, `Amount left is not zero`, `Liquidity in bonding curve is insufficient`, `Invalid collect fee mode`, and so on. `ProgramError` in `./math` lists them. * `client.state.getPoolConfigsByOwner` filters on the config's fee claimer. It filtered on the leftover receiver since 1.0. * `getCurveBreakdown` consumes only the remaining threshold on each segment and stops at exact cumulative completion (PR #120, snuff12). * `getBaseTokenForSwap`, `getMigrationThresholdPrice`, `getSwapAmountWithBuffer`, `getCurveBreakdown` and `getQuoteReserveFromNextSqrtPrice` stop at the first zero point of a stored curve, like the program. `client.state.getPoolBaseTokenCurveProgress` threw `Math operation overflow` once the price reached the last curve point, and at any time for a config whose last point is the migration price. * `getBaseTokenForSwap` and `getMigrationThresholdPrice` accumulate without a per-segment `u64` bound, like the program. * The first-buy builders pass the instructions sysvar only when the config enables the first swap with the minimum fee. * `client.state.getDammV1MigrationMetadata` returns `null` instead of throwing when the account does not exist. * `client.state.getPoolMetadata(pool)` and `client.state.getPartnerMetadata(feeClaimer)` fetch the metadata PDA and return the account, or `null` when none was created, instead of an array. * `getTokenType` and `getTokenDecimals` take an optional commitment. * Synced the DAMM v2 IDL and `cp_amm.so` fixture to cp\_amm 0.2.5. * `docs.md` and `CHANGELOG.md` ship in the package. ### Deprecated * `client.partner.createConfig` in favour of `createConfig2`. `createConfig` and `createConfigWithTransferHook` reject a quote mint with a non-zero transfer fee or a live transfer fee config authority. * `getRateLimiterParams`. The program rejects `BaseFeeMode.RateLimiter` for new configs. ### Removed * Helpers nothing referenced: `getAccountData`, `getAccountCreationTimestamp`, `getAccountCreationTimestamps`, `prepareTokenAccountTx`, `cleanUpTokenAccountTx`, `checkRateLimiterApplied`, `validateBalance`, `validateBaseTokenType`, `validateQuoteMintBasic`, `deriveDammV1EventAuthority`, `deriveDammV1PoolAuthority`, `deriveDammV2LockEscrowAddress`, `findAssociatedTokenAddress`, `deriveVaultAddress`, `deriveTokenVaultKey`, `deriveVaultLpMintAddress`, `requirePublicKey`, `convertDecimalToBN` (use `fromDecimalToBN`), `mulShr`, `SafeMath.mod`, `getFeeSchedulerMaxBaseFeeNumerator`, `getRateLimiterMinBaseFeeNumerator`, `getDeltaAmountBaseUnsignedUnchecked` and `getDeltaAmountQuoteUnsignedUnchecked` (the `256` variants are the unbounded ones), `BaseFeeHandler.validate`, `getProgram()` on the services (use `program`), and `DynamicBondingCurveClient.create` (the constructor defaults `commitment` to `confirmed`). * Types nothing used: `SwapQuoteConfig`, `DynamicCurveProgram`, `CreateConfigAccounts`, `InitializeSplPoolAccounts`, `InitializeToken2022PoolAccounts`, `InitializePoolParameters`, `LockEscrow`, `FeeResult`, `ClaimCreatorTradingFeeWithQuoteMintNotSolParams` and `ClaimCreatorTradingFeeWithQuoteMintSolParams`. * The `jito-ts` dev dependency. ### Breaking Changes * Import from `@meteora-ag/dynamic-bonding-curve-sdk` or `@meteora-ag/dynamic-bonding-curve-sdk/math`. The package root is an explicit export list and the `exports` map exposes only those two entries. The curve, fee, transfer fee and swap math moved to `./math` (57 functions, among them `calculateBaseToQuoteFromAmountIn`, `getFeeMode`, `getIncludedFeeAmount`, `getFeeNumeratorFromIncludedAmount`, `getSwapResult`, the `getDeltaAmount*` and `getNextSqrtPrice*` functions, `SafeMath`, `mulDiv` and `pow`). `swapQuoteExactIn`, `swapQuoteExactOut`, `swapQuotePartialFill` and `DynamicBondingCurveProgram` are not exported; `swapQuote` stays on the root. Internal helpers such as `getOrCreateATAInstruction`, `unwrapSOLInstruction`, `wrapSOLInstruction`, `deriveMintMetadata`, `derivePositionAddress`, `createDammV1Program`, `getFirstCurve`, `getTwoCurve`, `isDefaultLockedVesting` and the `validate*` building blocks are no longer exported. * Construct the services through `DynamicBondingCurveClient`. `new PoolService(connection, commitment)` and the same constructor on the other services are no longer supported. * `CreateConfigParams`, `CreateConfig2Params` and `CreateConfigWithTransferHookParams` declare `config`, `feeClaimer`, `leftoverReceiver`, `quoteMint` and `payer` as required `PublicKey`s. * `getSwapQuoteTransferFees` takes an options object instead of a commitment string. Swap quotes for a Token-2022 quote mint require `quoteMint` and `currentEpoch`. * `getFeeOnAmount` and `splitFees` no longer take `poolFees`. `calculateBaseToQuoteFromAmountOut` and `calculateQuoteToBaseFromAmountOut` return `{ amountIn, nextSqrtPrice }`. * `getOrCreateATAInstruction(connection, mint, owner, payer, tokenProgram, commitment?)`: the `allowOwnerOffCurve` argument is gone and always on. `unwrapSOLInstruction` always returns an instruction. * `createDbcProgram` returns the `Program` instead of `{ program }`. `deriveEscrow` is `deriveLockerEscrowAddress`. * `getMigratedPoolFeeParams` throws for `MigrationFeeOption.Customizable` when `migratedPoolFee.poolFeeBps` is not set. * `swap`, `swap2`, `claimPartnerTradingFee`, `claimPartnerTradingFeeToReceiver`, `claimCreatorTradingFee` and `claimCreatorTradingFeeToReceiver` reject transfer-hook pools. Use `swap2WithTransferHook`, `claimPartnerTradingFee2` and `claimCreatorTradingFee2`. Standard pool creation rejects a transfer-hook config, and transfer-hook pool creation rejects a standard config. * `transferPoolCreator` rejects a `newCreator` equal to `creator`. * `tempWSolAcc` is gone from `claimPartnerTradingFee` and `claimCreatorTradingFee`. With a native SOL quote the fee is wrapped into the fee claimer's or creator's token account and unwrapped to `receiver`, so only the claimer signs. * `validateSwapAmount` returns nothing and throws `Amount is zero`. </Update> <Update label="dynamic-bonding-curve 0.2.1" description="Support for Stock Tokens in DBC + Deprecation of Rate Limiter and DAMM v1"> <Info> Mainnet deployment for Release 0.2.1 is planned for September 9, 2026, at 11:00 AM UTC+8 (Wednesday). </Info> ## Release summary | Component | Version | PR | | - | - | - | | Program | `0.2.1` | [dynamic-bonding-curve #202](https://github.com/MeteoraAg/dynamic-bonding-curve/pull/202) | | TypeScript SDK | `1.5.12` | [dynamic-bonding-curve-sdk #112](https://github.com/MeteoraAg/dynamic-bonding-curve-sdk/pull/112) | ## What We Shipped * Support for Stock Tokens in DBC via Token Badges * Deprecated `BaseFeeMode.RateLimiter` for new configs and new pools. Existing rate-limiter pools can still be quoted and swapped. * Deprecated `MigrationOption.MET_DAMM` (DAMM v1) for new configs and new pools. Existing DAMM v1 pools can still migrate. ## What To Do <div> <table> <thead> <tr> <th>Integrators</th> <th>What Changed</th> <th>What To Do</th> </tr> </thead> <tbody> <tr> <td><strong>Partners</strong></td> <td> <ul> <li>Support for Stock Tokens in DBC via Token Badges</li> <li>Deprecation of Rate Limiter and DAMM v1</li> </ul> </td> <td> <ul> <li>As the Rate Limiter is deprecated, you need to migrate to change your BaseFeeMode to other modes.</li> <li>As the DAMM v1 is deprecated, you need to migrate to change your MigrationOption to other modes.</li> <li>Bump your SDK version to <code>@meteora-ag/dynamic-bonding-curve-sdk\@1.5.11-rc.0</code> to start testing.</li> </ul> </td> </tr> </tbody> </table> </div> ## Program: `dynamic-bonding-curve` `0.2.1` Program ID (mainnet and devnet): `dbcij3LWUppWqq96dh6gJWwBifmcGfLSB5D4DuSMaqN` [Program PR #202](https://github.com/MeteoraAg/dynamic-bonding-curve/pull/202) ### Added * Added endpoints `create_token_badge` and `close_token_badge` for operators to whitelist quote mints with otherwise-unsupported token2022 extensions guarded by new `OperatorPermission::CreateTokenBadge` and `OperatorPermission::CloseTokenBadge`. * Note that a token badge does not allow a non-zero transfer fee: the current and any scheduled `transfer_fee_basis_points` must be 0. Expired historical `older_transfer_fee` transfer fees are ignored. This is enforced with `QuoteMintHasNonZeroTransferFee` at token badge creation, at config/pool creation and on every endpoint that transfers quote tokens. * Note that all DAMM v2 configs used by DBC have the `CreatePoolWithoutMintValidation` permission, so a pool with a quote mint that is not permissionless-supported by DAMM v2 can still migrate. ### Changed * The endpoints `create_config`, `create_config_with_transfer_hook`, `initialize_virtual_pool_with_spl_token`, `initialize_virtual_pool_with_token2022` and `initialize_virtual_pool_with_token2022_transfer_hook` now take the `token_badge` account as a remaining account at index 0. Required when the quote mint is not permissionless-supported. ### Deprecated * Deprecated `BaseFeeMode::RateLimiter`. New configs and new pools can no longer be created with `BaseFeeMode::RateLimiter`. Existing configs with `BaseFeeMode::RateLimiter` can no longer be used to create new pools. Existing pools with `BaseFeeMode::RateLimiter` are unaffected. * Deprecated `MigrationOption::MeteoraDamm`. New configs and new pools can no longer be created with `MigrationOption::MeteoraDamm`. Existing configs with `MigrationOption::MeteoraDamm` can no longer be used to create new pools. Existing pools with `MigrationOption::MeteoraDamm` are unaffected and can still migrate to DAMM v1. ### Removed * Removed deprecated endpoints `claim_protocol_fee` and `zap_protocol_fee`. ## TypeScript SDK: `@meteora-ag/dynamic-bonding-curve-sdk` `1.5.12` [SDK PR #112](https://github.com/MeteoraAg/dynamic-bonding-curve-sdk/pull/112) <Tip> Early testing: [`@meteora-ag/dynamic-bonding-curve-sdk@1.5.11-rc.0`](https://www.npmjs.com/package/@meteora-ag/dynamic-bonding-curve-sdk/v/1.5.11-rc.0).<br /> Production: [`@meteora-ag/dynamic-bonding-curve-sdk@1.5.12`](https://www.npmjs.com/package/@meteora-ag/dynamic-bonding-curve-sdk/v/1.5.12). </Tip> ### Added * Added optional `tokenBadge` remaining account support on config and pool creation. Required when the quote mint is not permissionless-supported. * Added `deriveTokenBadgeAddress` and `getTokenBadgeRemainingAccounts` helpers. * Added `TokenBadge` account type and `client.state.getTokenBadge`. ### Changed * Updated the DBC IDL to program version 0.2.1. * `getOrCreateATAInstruction` and `prepareTokenAccountTx` now accept an optional `commitment` (defaults to `confirmed`) and pass it through to the token account fetch. * Synced the DAMM v2 IDL and test-validator `cp_amm.so` fixture to cp\_amm 0.2.4. DAMM v2 configs now include a `permission` bitmask. Migration tests create a private DAMM v2 config with `CreatePoolWithoutMintValidation` so Token-2022 quote mints that need a DBC token badge can still migrate. Token-2022 wrapped SOL is still rejected. ### Deprecated * Deprecated `BaseFeeMode.RateLimiter` for new configs and new pools. Existing rate-limiter pools can still be quoted and swapped. * Deprecated `MigrationOption.MET_DAMM` (DAMM v1) for new configs and new pools. Existing DAMM v1 pools can still migrate. ### Breaking Changes * `createConfig`, `createPool`, and `buildCurve*` now reject `BaseFeeMode.RateLimiter` and `MigrationOption.MET_DAMM`. * `getMigratedPoolFeeParams` now rejects `MigrationOption.MET_DAMM`. * `getBaseFeeParams` no longer takes `tokenQuoteDecimal` or `activationType`. Those arguments were only used to encode RateLimiter params, which this helper now rejects. </Update> <Update label="dynamic-bonding-curve 0.2.0" description="Transfer Hook Support and Restricted Mint Authority"> <Info> Mainnet deployment for Release 0.2.0 is planned for June 3, 2026, at 11:00 AM UTC+8 (Wednesday). </Info> ## Release summary | Component | Version | PR | | - | - | - | | Program | `0.2.0` | [dynamic-bonding-curve #193](https://github.com/MeteoraAg/dynamic-bonding-curve/pull/193) | | TypeScript SDK | `1.5.8` | [dynamic-bonding-curve-sdk #103](https://github.com/MeteoraAg/dynamic-bonding-curve-sdk/pull/103) | ## What We Shipped * Transfer Hook Support * Restricted Mint Authority ## What To Do <div> <table> <thead> <tr> <th>Integrators</th> <th>What Changed</th> <th>What To Do</th> </tr> </thead> <tbody> <tr> <td><strong>Swap Routers</strong></td> <td> <ul> <li>Token-2022 transfer-hook pool support</li> <li>New transfer-hook swap endpoint: <code>swap2\_with\_transfer\_hook</code></li> </ul> </td> <td> <ul> <li>Use <code>swap2\_with\_transfer\_hook</code> for transfer-hook pools and pass the required <code>transfer\_hook\_accounts\_info: TransferHookAccountsInfo</code> remaining-account metadata.</li> <li>Keep using the original swap endpoints for non-transfer-hook pools.</li> <li>Update any direct pool account readers to handle the transfer-hook pool account and nested pool-state layout.</li> </ul> </td> </tr> <tr> <td><strong>Trading Terminals</strong></td> <td> <ul> <li>New transfer-hook event variants</li> <li>Restricted mint-authority behavior for non-transfer-hook pools</li> </ul> </td> <td> <ul> <li>Update event parsing for <code>EvtInitializePoolWithTransferHook</code>, <code>EvtSwap2WithTransferHook</code>, <code>EvtCurveCompleteWithTransferHook</code>, and <code>EvtCreateConfigV2WithTransferHook</code>.</li> <li>Display transfer-hook pools separately from non-transfer-hook pools where users need to understand additional token-transfer requirements.</li> <li>Do not assume creator or partner mint authority is available for non-transfer-hook pools. For those pools, <code>base\_mint</code> mint authority is always revoked at initialization.</li> </ul> </td> </tr> <tr> <td><strong>Partners</strong></td> <td> <ul> <li>New transfer-hook config and pool-creation flow</li> <li>Protocol-fee claim endpoint update</li> <li>Restricted mint-authority config options</li> </ul> </td> <td> <ul> <li>Bump your SDK version to at least <code>@meteora-ag/dynamic-bonding-curve-sdk\@1.5.8</code>. Use <code>1.5.9+</code> for the transfer-hook state-fetch fix.</li> <li>For Token-2022 transfer-hook launches, create configs with <code>create\_config\_with\_transfer\_hook</code> and initialize pools with <code>initialize\_virtual\_pool\_with\_token2022\_transfer\_hook</code>.</li> <li>Only use <code>CreatorUpdateAndMintAuthority</code> or <code>PartnerUpdateAndMintAuthority</code> with transfer-hook configs. <code>create\_config</code>, <code>initialize\_virtual\_pool\_with\_spl\_token</code>, and <code>initialize\_virtual\_pool\_with\_token2022</code> now reject those options.</li> </ul> </td> </tr> </tbody> </table> </div> ## Program: `dynamic-bonding-curve` `0.2.0` Program ID (mainnet and devnet): `dbcij3LWUppWqq96dh6gJWwBifmcGfLSB5D4DuSMaqN` [Program PR #193](https://github.com/MeteoraAg/dynamic-bonding-curve/pull/193) ### Added * Added an endpoint `claim_protocol_fee2` that requires `protocol_fee_authority` as the signer instead of an operator. Only one of the pool tokens can be claimed per instruction call. * Added endpoint `create_config_with_transfer_hook` that creates a `ConfigWithTransferHook` account storing the transfer hook program alongside the pool config. Only valid for `token_type: Token2022`. The transfer hook program must be executable and cannot be the DBC program, SPL Token program, Token 2022 program, or default pubkey. * Added endpoint `initialize_virtual_pool_with_token2022_transfer_hook` for creating virtual pools with token-2022 base mints that have transfer hooks. The transfer hook program is sourced from the `ConfigWithTransferHook` account and the transfer hook authority is set to the `pool_authority`. The transfer hook program and authority is revoked after the last swap when the curve completes. * Added endpoints with transfer hook support: `swap2_with_transfer_hook`, `claim_trading_fee2` and `claim_creator_trading_fee2`. These accept a `transfer_hook_accounts_info: TransferHookAccountsInfo` parameter for passing transfer hook extra accounts via remaining accounts. The original endpoints are unchanged for backwards compatibility with non-transfer-hook pools. * Added `WithTransferHook` event variants for events consumed by external indexers to differentiate between transfer-hook and non-transfer-hook pool operations: `EvtInitializePoolWithTransferHook`, `EvtSwap2WithTransferHook`, `EvtCurveCompleteWithTransferHook`, `EvtCreateConfigV2WithTransferHook`. * Re-enabled `TokenAuthorityOption::CreatorUpdateAndMintAuthority` and `TokenAuthorityOption::PartnerUpdateAndMintAuthority` for transfer-hook configs only. The mint authority is assigned to the creator or partner at pool initialization. ### Changed * Update anchor to 1.0.2 ### Deprecated * Deprecated `claim_protocol_fee` and `zap_protocol_fee` endpoints in favour of using `claim_protocol_fee2` through the `protocol_fee` wrapper program. * Deprecated `TokenAuthorityOption::CreatorUpdateAndMintAuthority` and `TokenAuthorityOption::PartnerUpdateAndMintAuthority` for non-transfer-hook configs. ### Removed * Removed unused events: `EvtPartnerWithdrawMigrationFee` and `EvtClaimProtocolLiquidityMigrationFee` ### Breaking Changes * `create_config` endpoint now rejects the configs with the following `token_update_authority`: `CreatorUpdateAndMintAuthority` and `PartnerUpdateAndMintAuthority` * `initialize_virtual_pool_with_spl_token` and `initialize_virtual_pool_with_token2022` endpoints now reject configs whose `token_update_authority` is `CreatorUpdateAndMintAuthority` or `PartnerUpdateAndMintAuthority`. Existing configs on-chain that used these variants can no longer initialize new pools. * For non-transfer-hook pools, `base_mint` mint authority can no longer be assigned to the creator or partner. It is always revoked at pool initialization. Transfer-hook pools may still assign mint authority to creator/partner. ## TypeScript SDK: `@meteora-ag/dynamic-bonding-curve-sdk` `1.5.8` [SDK PR #103](https://github.com/MeteoraAg/dynamic-bonding-curve-sdk/pull/103) <Tip> Early testing: [`@meteora-ag/dynamic-bonding-curve-sdk@1.5.7-rc.0`](https://www.npmjs.com/package/@meteora-ag/dynamic-bonding-curve-sdk/v/1.5.7-rc.0).<br /> Production: [`@meteora-ag/dynamic-bonding-curve-sdk@1.5.8`](https://www.npmjs.com/package/@meteora-ag/dynamic-bonding-curve-sdk/v/1.5.8). </Tip> ### Added * Added Token-2022 transfer-hook support for DBC pool configs and pools: * `client.partner.createConfigWithTransferHook` * `client.partner.createConfigAndPoolWithTransferHook` * `client.partner.createConfigAndPoolWithFirstBuyWithTransferHook` * `client.creator.createPoolWithTransferHook` * `client.creator.createPoolWithFirstBuyWithTransferHook` * `client.creator.createPoolWithPartnerAndCreatorFirstBuyWithTransferHook` * Added transfer-hook swap and fee claim endpoints: * `client.pool.swap2WithTransferHook` * `client.partner.claimPartnerTradingFee2` * `client.creator.claimCreatorTradingFee2` * Added transfer-hook account helper types: * `TransferHookAccountsInfo` * `TransferHookRemainingAccounts` * `FirstBuyWithTransferHookParams` * `PartnerFirstBuyWithTransferHookParams` * `CreatorFirstBuyWithTransferHookParams` * `AccountsType`
프로젝트로 돌아가기