bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 75쪽 중 23쪽
ol_with_dynamic_config` will allow user to create pool with `collect_fee_mode == Compounding`, and config for `compounding_fee_bps`.
### Changed
* Related to event `EvtSwap2`, in `swap_result` field, `partner_fee` will be replaced by `compounding_fee`, now total\_trading\_fee will be calculated as `swap_result.claiming_fee + swap_result.compounding_fee`
### Removed
* Removed `partner` field from Pool struct
* Removed unused `partner_fee` feature and the `claim_partner_fee` endpoint
### Breaking Changes
* Quote function will be changed by the new fee mode
## TypeScript SDK: `@meteora-ag/cp-amm-sdk` `1.3.7`
[SDK PR #101](https://github.com/MeteoraAg/damm-v2-sdk/pull/101)
<Tip>
Early testing: [`@meteora-ag/cp-amm-sdk@1.3.6-rc.1`](https://www.npmjs.com/package/@meteora-ag/cp-amm-sdk/v/1.3.6-rc.1).<br /> Production: [`@meteora-ag/cp-amm-sdk@1.3.7`](https://www.npmjs.com/package/@meteora-ag/cp-amm-sdk/v/1.3.7).
</Tip>
### Added
* Added new `CollectFeeMode.Compounding` mode — a constant-product (x \* y = k) liquidity mode where a configurable percentage of trading fees are compounded back into pool liquidity (as token B), with the remaining fees available for claiming. Pools with compounding mode do not use price ranges.
* Added `LiquidityHandler` interface and two implementations: `CompoundingLiquidityHandler` and `ConcentratedLiquidityHandler`, with a `getLiquidityHandler` factory function that dispatches based on `collectFeeMode`.
* Added `compoundingFeeBps` field to `PoolFeesParams` for configuring the compounding fee split.
* Added `collectFeeMode` parameter to `getLiquidityDelta`, `getDepositQuote`, `getWithdrawQuote`, and `preparePoolCreationParams`.
* Added `tokenAAmount`, `tokenBAmount`, and `liquidity` parameters to `getDepositQuote` and `getWithdrawQuote` for compounding liquidity calculations.
### Changed
* Rewrote `swapQuote.ts` to use `LiquidityHandler` abstraction, supporting both concentrated and compounding liquidity modes.
* Fee structure: `tradingFee` split into `claimingFee` + `compoundingFee` in `SwapResult2`, `FeeOnAmountResult`, and `SplitFees` types.
* Renamed `PoolVersion` enum to `LayoutVersion`.
* `PoolFeesParams.padding` changed from `number[]` to `number`.
* `splitFees` and `getFeeOnAmount` no longer accept `hasPartner` parameter.
* `getQuote` `totalFee` now computed as `claimingFee + compoundingFee + protocolFee + referralFee`.
* `getQuote2` return type: `tradingFee` and `partnerFee` replaced with `claimingFee` and `compoundingFee`.
* `collectFeeMode` comment updated: `0: BothToken, 1: OnlyB, 2: Compounding`.
* Liquidity delta and amount functions (`getLiquidityDeltaFromAmountA`, `getLiquidityDeltaFromAmountB`, `getAmountAFromLiquidityDelta`, `getAmountBFromLiquidityDelta`) now accept `collectFeeMode` and dispatch to the appropriate handler.
### Removed
* Removed `claimPartnerFee` endpoint and `ClaimPartnerFeeParams` type.
* Removed `partnerFee` from fee result types (`FeeOnAmountResult`, `SplitFees`, `SwapResult2`).
* Removed `hasPartner` helper function.
* Removed `FEE_PADDING` constant.
</Update>
# DAMM v2 Go Integration Reference
Source: https://docs.meteora.ag/developer-guides/damm-v2/go-integration/reference
Learn how to use the DAMM v2 Go examples to read pools, positions, user position NFTs, and unclaimed rewards.
The public [`damm-v2-go`](https://github.com/MeteoraAg/damm-v2-go) repository provides Go examples for reading DAMM v2 state with `solana-go`. Treat it as example code for account reads, deserialization, and selected low-level instructions rather than a full transaction SDK.
## Setup
```bash theme={"system"}
git clone https://github.com/MeteoraAg/damm-v2-go.git
cd damm-v2-go
go mod tidy
```
Before running examples, set the RPC endpoint and addresses in the example file you are using. Some examples also require uncommenting the local `main()` function.
```bash theme={"system"}
go run examples/get_pool.go
```
## Available Examples
| Example | Use |
| - | - |
| `get_pool.go` | Fetch and deserialize a pool account |
| `get_position.go` | Fetch and deserialize a position account |
| `get_positions_by_user.go` | Resolve position NFTs and fetch positions for a wallet |
| `get_user_position_by_pool.go` | Filter a user's positions by pool |
| `get_all_position_nft_account_by_owner.go` | Read position NFT token accounts by owner |
| `get_unclaim_reward.go` | Calculate unclaimed reward information |
| `claim_position_fee.go` | Example transaction flow for claiming position fees |
The Go constants include the public DAMM v2 program ID:
```go theme={"system"}
const DammV2ProgramID = "cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG"
```
## Helpers And Validation
| Helper | Use |
| - | - |
| `DerivePoolAuthorityPDA()` | Derives the `pool_authority` PDA |
| `DeriveEventAuthorityPDA()` | Derives the `__event_authority` PDA used by event CPI instructions |
| `DerivePositionPDA(positionNft)` | Derives the `position` PDA from the position NFT mint |
| `GetPool(ctx, pool, rpcClient)` | Fetches and deserializes a pool after checking the Anchor discriminator |
| `GetPosition(ctx, position, rpcClient)` | Fetches and deserializes a position after checking the Anchor discriminator |
| `GetPositionsByUser(ctx, rpcClient, user)` | Resolves position NFTs, derives position PDAs, fetches positions, and sorts by total liquidity |
| `ClaimPositionFee(...)` | Builds a low-level claim-fee instruction including event CPI accounts |
## Integration Notes
| Topic | Guidance |
| - | - |
| Account validation | Example readers check Anchor discriminators before deserializing pool and position data. |
| Position ownership | User-position lookup starts from Token 2022 position NFT accounts owned by the wallet. |
| Transaction builders | Prefer the TypeScript SDK unless you are comfortable maintaining low-level Go instruction builders from the IDL. |
| Module path | The local `go.mod` currently uses a different module path than the public repository name. Check upstream before importing it as a library. |
| State freshness | Fetch pool accounts directly for transaction-critical reads; use the API for discovery and chart data. |
| Event CPI accounts | Low-level instructions that emit events need `event_authority` and the program account in the expected account order. |
For custom Go clients, generate from the public [cp\_amm IDL](https://github.com/MeteoraAg/damm-v2-sdk/blob/main/src/idl/cp_amm.json) and cross-check account layouts against [Accounts](/developer-guides/damm-v2/program/accounts).
# DAMM v2 Developer Guide
Source: https://docs.meteora.ag/developer-guides/damm-v2/index
Learn how to build DAMM v2 integrations with the cp-amm program, TypeScript SDK, Rust guides, Go readers, Data API, and release notes.
DAMM v2 is Meteora's configurable constant-product AMM on Solana. To learn more about DAMM v2, including fee behavior, formulas, Token 2022 support, NFT positions, liquidity mining, and LP strategy, read the following product documentations.
<CardGroup>
<Card title="Learn more about DAMM v2" icon="book-open" href="/core-products/damm-v2/what-is-damm-v2">
Overview of DAMM v2, fee behavior, Token 2022 support, NFT positions, liquidity mining, and LP strategy.
</Card>
<Card title="DAMM v2 Formulas" icon="calculator" href="/core-products/damm-v2/formulas">
Formulas and definitions for price, liquidity, fee, and impermanent loss concepts.
</Card>
</CardGroup>
## Integration
<CardGroup>
<Card title="Program Accounts" icon="table-cells" href="/developer-guides/damm-v2/program/accounts">
Account model for configs, pools, position NFTs, rewards, vesting, token badges, and operators.
</Card>
<Card title="Program Instructions" icon="list" href="/developer-guides/damm-v2/program/instructions">
Instruction families for pool creation, liquidity, swaps, rewards, locks, operator flows, and admin flows.
</Card>
<Card title="Program Events" icon="list" href="/developer-guides/damm-v2/program/events">
Event families for pool creation, liquidity, swaps, rewards, locks, operator flows, and admin flows.
</Card>
<Card title="Program Errors" icon="triangle-exclamation" href="/developer-guides/damm-v2/program/errors">
Anchor custom error codes, enum names, messages, and common integration causes.
</Card>
<Card title="TypeScript SDK" icon="code" href="/developer-guides/damm-v2/typescript-sdk/getting-started">
TypeScript SDK for interacting with all public DAMM v2 user flows.
</Card>
<Card title="Rust Integration" icon="terminal" href="/developer-guides/damm-v2/rust-integration/library">
Rust integration with DAMM v2 through CPI and the quote library.
</Card>
<Card title="Go Integration" icon="golang" href="/developer-guides/damm-v2/go-integration/reference">
Go examples for reading pools, positions, position NFTs, and unclaimed rewards.
</Card>
<Card title="DAMM v2 APIs" icon="database" href="/developer-guides/damm-v2/api-reference/overview">
Indexed read-only pool discovery, pool groups, OHLCV, volume, and protocol stats.
</Card>
</CardGroup>
## Program IDs
The `cp_amm` program ID is the same on mainnet and devnet:
| Network | Program ID |
| - | - |
| Mainnet Beta | `cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG` |
| Devnet | `cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG` |
The pool authority PDA used by the program is:
| Authority | Address |
| - | - |
| Pool Authority | `HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC` |
<CardGroup>
<Card title="DAMM v2 Program" icon="code" href="https://github.com/MeteoraAg/damm-v2/tree/main/programs/cp-amm">
Public Anchor program source for DAMM v2.
</Card>
<Card title="DAMM v2 IDL" icon="file-code" href="https://github.com/MeteoraAg/damm-v2-sdk/blob/main/src/idl/cp_amm.json">
Published Anchor IDL used by generated clients and the TypeScript SDK.
</Card>
<Card title="TypeScript SDK" icon="node-js" href="https://github.com/MeteoraAg/damm-v2-sdk">
Public SDK for transactions, quotes, PDA derivation, and account fetching.
</Card>
<Card title="Go Examples" icon="golang" href="https://github.com/MeteoraAg/damm-v2-go">
Public Go examples for reading DAMM v2 state.
</Card>
</CardGroup>
<CardGroup>
<Card title="Pool Fee Configs" icon="gear" href="/developer-guides/damm-v2/pool-fee-configs">
Static and dynamic config behavior, fee modes, collect fee modes, and published config keys.
</Card>
</CardGroup>
<Note>
The `cp-amm` source, IDL, TypeScript SDK, Rust quote SDK, and Go examples are public.
</Note>
## Commands
| Task | Command |
| - | - |
| Build TypeScript SDK | `cd damm-v2-sdk && pnpm install && pnpm run build` |
| Run TypeScript SDK tests | `cd damm-v2-sdk && pnpm test` |
| Run TypeScript type checks | `cd damm-v2-sdk && pnpm run check-types` |
| Run Rust quote SDK tests | `cd damm-v2 && cargo test -p rust-sdk` |
| Build `cp-amm` program | `cd damm-v2 && anchor build` |
| Run Go examples | `cd damm-v2-go && go mod tidy && go run examples/get_pool.go` |
## Stay Updated
<CardGroup>
<Card title="DAMM v2 Changelog" icon="newspaper" href="/developer-guides/damm-v2/changelog">
Program, SDK, event, and quote changes for integration planning.
</Card>
</CardGroup>
# DAMM v2 Pool Fee Configs
Source: https://docs.meteora.ag/developer-guides/damm-v2/pool-fee-configs
Explore DAMM v2 pool fee configs, including static and dynamic configs, pool PDA derivation, base fee modes, collect fee modes, dynamic fee parameters, activation behavior, and published config keys.
<Note>
* `initialize_pool` requires a static config key. The pool PDA is derived from `"pool"` + `staticConfig` + the sorted token mint pair.
* `initialize_pool_with_dynamic_config` requires a dynamic config key and the configured `pool_creator_authority` signer. The pool PDA is derived from `"pool"` + `dynamicConfig` + the sorted token mint pair.
* `initialize_customizable_pool` does not use a config key. The pool PDA is derived from `"customizable_pool"` + the sorted token mint pair.
</Note>
DAMM v2 configs define how pools are created and how pool fees are initialized. The `cp-amm` program currently supports two config account types:
* Static config: stores the pool fee parameters, collect fee mode, activation type, optional alpha vault config, price range, optional pool creator authority, and a `permission` bitmask.
* Dynamic config: stores the config index, `pool_creator_authority`, and `permission`; the pool creator supplies the pool-specific fee, activation, alpha vault, price range, and liquidity parameters when calling `initialize_pool_with_dynamic_config`.
The config account uses `config_type = 0` for static configs and `config_type = 1` for dynamic configs.
## Config Fields
| Field | Description |
| - | - |
| `index` | Operator-assigned config index used to derive the config PDA from `"config"` + `index`. |
| `config_type` | `0` for static configs, `1` for dynamic configs. |
| `pool_creator_authority` | Static configs are public when this is the default pubkey. Dynamic configs must set a non-default authority, and that signer is required during pool creation. |
| `pool_fees` | Stored fee configuration for static configs. Dynamic-config pools receive `pool_fees` during `initialize_pool_with_dynamic_config`. |
| `vault_config_key` | Optional alpha vault config key. The default pubkey means the pool has no whitelisted alpha vault. |
| `activation_type` | Activation point unit. `0` uses slot-based activation, and `1` uses timestamp-based activation. |
| `collect_fee_mode` | Determines which token receives fees and whether compounding mode is enabled. |
| `sqrt_min_price` / `sqrt_max_price` | Static-config price range. Compounding pools use the full range (`0` to `u128::MAX`) in the static config. |
| `permission` | `u128` bitmask. Only private configs, meaning those with a non-default `pool_creator_authority`, can hold a non-zero value. The only defined bit today is `CreatePoolWithoutMintValidation` (`1 << 0`). Public configs must use `0`. |
## Fee Parameters
`pool_fees` contains a base fee, optional dynamic fee, protocol fee percent, referral fee percent, and optional compounding fee bps.
| Parameter | Current behavior |
| - | - |
| `base_fee` | Encoded `BaseFeeParameters` with one of the supported base fee modes. The fee denominator is `1_000_000_000`. |
| `dynamic_fee` | Optional volatility-based fee. If present, the program validates `bin_step = 1`, `bin_step_u128 = 1844674407370955`, `filter_period < decay_period`, `reduction_factor <= 10_000`, and 24-bit limits for `variable_fee_control` and `max_volatility_accumulator`. |
| `protocol_fee_percent` | Fixed at `20%` when fee parameters are converted into pool fee config. |
| `referral_fee_percent` | Fixed at `20%` of the protocol fee. |
| `compounding_fee_bps` | Must be greater than `0` and no more than `10_000` only when `collect_fee_mode = 2`; otherwise it must be `0`. |
### Base Fee Modes
<Warning>
Rate limiter mode is deprecated for new configs and new pools. `create_config`, `initialize_pool`, `initialize_pool_with_dynamic_config`, and `initialize_customizable_pool` reject `BaseFeeMode::RateLimiter`. Existing rate-limiter pools can still be quoted and swapped.
</Warning>
| Value | Mode | Summary |
| - | - | - |
| `0` | `FeeTimeSchedulerLinear` | Starts from `cliff_fee_numerator` and decreases linearly by `reduction_factor` each period. |
| `1` | `FeeTimeSchedulerExponential` | Starts from `cliff_fee_numerator` and decreases exponentially by `reduction_factor` each period. |
| `2` | `RateLimiter` | Deprecated for new configs and new pools. Existing pools still apply an amount-based fee curve for quote-to-base swaps during the limiter window. This mode is valid only with `collect_fee_mode = 1`. |
| `3` | `FeeMarketCapSchedulerLinear` | Decreases linearly as price moves upward in `sqrt_price_step_bps` periods, until the scheduler expires. |
| `4` | `FeeMarketCapSchedulerExponential` | Decreases exponentially as price moves upward in `sqrt_price_step_bps` periods, until the scheduler expires. |
For the current pool version, base fees are bounded from `1` bps (`0.01%`) up to `9,900` bps (`99%`). Operator post-creation fee updates are capped at `10%`.
### Collect Fee Modes
| Value | Mode | Summary |
| - | - | - |
| `0` | `BothToken` | Fees are collected in the output token. |
| `1` | `OnlyB` | Fees are collected only in token B. |
| `2` | `Compounding` | A configured percentage of fees is compounded into liquidity, and remaining fees are claimable in token B. Compounding pools use constant-product liquidity without a custom price range. |
## Static Configs
Static configs can be used to create pools with `initialize_pool`. If `pool_creator_authority` is the default pubkey, any payer can create a pool with that static config. If it is non-default, only that authority can create pools with the config.
Static configs are useful when the token pair cannot be bought before launch time. Launchpads typically prefer dynamic configs when they need launch-specific fee curves or authority-gated pool creation.
To fetch static config key addresses, use the `getAllConfigs` function in the [TypeScript SDK](https://github.com/MeteoraAg/damm-v2-sdk/blob/main/src/CpAmm.ts).
<Note>Integrators cannot change the configuration for that particular static config key.</Note>
<AccordionGroup>
<Accordion title="View all static config key addresses (Mainnet)">
<Note>When `dynamicFee = true`, the pool includes the optional volatility-based dynamic fee. The total trading fee is the base fee plus the current dynamic fee, capped by the pool version's maximum fee.</Note>
```json theme={"system"}
[
{
"index": 0,
"baseFeeValue": 2500000,
"baseFee": {
"cliffFeeNumerator": 2500000,
"numberOfPeriod": 0,
"reductionFactor": 0,
"periodFrequency": 0,
"feeSchedulerMode": 0
},
"collectFeeMode": 0,
"dynamicFee": true,
"configAccount": "8CNy9goNQNLM4wtgRw528tUQGMKD3vSuFRZY2gLGLLvF"
},
{
"index": 1,
"baseFeeValue": 2500000,
"baseFee": {
"cliffFeeNumerator": 2500000,
"numberOfPeriod": 0,
"reductionFactor": 0,
"periodFrequency": 0,
"feeSchedulerMode": 0
},
"collectFeeMode": 1,
"dynamicFee": true,
"configAccount": "82p7sVzQWZfCrmStPhsG8BYKwheQkUiXSs2wiqdhwNxr"
},
{
"index": 2,
"baseFeeValue": 2500000,
"baseFee": {
"cliffFeeNumerator": 2500000,
"numberOfPeriod": 0,
"reductionFactor": 0,
"periodFrequency": 0,
"feeSchedulerMode": 0
},
"collectFeeMode": 0,
"dynamicFee": false,
"configAccount": "FzvMYBQ29z2J21QPsABpJYYxQBEKGsxA6w6J2HYceFj8"
},
{
"index": 3,
"baseFeeValue": 2500000,
"baseFee": {
"cliffFeeNumerator": 2500000,
"numberOfPeriod": 0,
"reductionFactor": 0,
"periodFrequency": 0,
"feeSchedulerMode": 0
},
"collectFeeMode": 1,
"dynamicFee": false,
"configAccount": "EQbqYxecZuJsVt6g5QbKTWpNWa3QyWQE5NWz5AZBAiNv"
},
{
"index": 4,
"baseFeeValue": 3000000,
"baseFee": {
"cliffFeeNumerator": 3000000,
"numberOfPeriod": 0,
"reductionFactor": 0,
"periodFrequency": 0,
"feeSchedulerMode": 0
},
"collectFeeMode": 0,
"dynamicFee": true,
"configAccount": "9RuAyDH81GB9dhks6MzHva2objQJxHvqRRfyKKdfmkxk"
},
{
"index": 5,
"baseFeeValue": 3000000,
"baseFee": {
"cliffFeeNumerator": 3000000,
"numberOfPeriod": 0,
"reductionFactor": 0,
"periodFrequency": 0,
"feeSchedulerMode": 0
},
"collectFeeMode": 1,
"dynamicFee": true,
"configAccount": "GqRo1PG5KZc4QqZn1RCcnEGC8E7yRscHaW1fQp9St9Lz"
},
{
"index": 6,
"baseFeeValue": 3000000,
"baseFee": {
"cliffFeeNumerator": 3000000,
"numberOfPeriod": 0,
"reductionFactor": 0,
"periodFrequency": 0,
"feeSchedulerMode": 0
},
"collectFeeMode": 0,
"dynamicFee": false,
"configAccount": "3KLdspUofc75aaEAJdBo1o6D6cyzXJVtGB8PgpWJEiaR"
},
{
"index": 7,
"baseFeeValue": 3000000,
"baseFee": {
"cliffFeeNumerator": 3000000,
"numberOfPeriod": 0,
"reductionFactor": 0,
"periodFrequency": 0,
"feeSchedulerMode": 0
},
"collectFeeMode": 1,
"dynamicFee": false,
"configAccount": "9xKsC프로젝트로 돌아가기