Meteora 백서

Meteora

원문

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

ude: * Standard SPL Token mints. * Token 2022 mints with supported extensions. For Token 2022, the program accepts mints whose extension list contains only: * `TransferFeeConfig` * `MetadataPointer` * `TokenMetadata` If a Token 2022 mint uses any other extension, initialization fails with `InvalidMint`. <Info> If a project wants to split fees for multiple token mints, it should create one fee vault per token mint. </Info> ## Vault Types Dynamic Fee Sharing supports two fee vault types. | Vault Type | Compatible With | Best For | | - | - | - | | Non-PDA fee vault | Manual fee funding | Standalone fee-sharing agreements. | | PDA fee vault | Manual fee funding and supported claim-by-integration funding | Protocol-integrated fee sharing tied to a base account. | ## Funding Paths Dynamic Fee Sharing supports two funding paths. ### Manual Funding Manual funding works for both Non-PDA and PDA fee vaults. A funder signs for the source token account. The program transfers `min(max_amount, source_balance)` into the token vault, records the net amount for supported transfer-fee mints, and updates fee-per-share accounting. ### Funding by Claiming Fees Funding by claiming fees works for PDA fee vaults and only for whitelisted source-program actions. The vault calls a supported fee-claim action, receives claimed tokens into its token vault, and then adds the token-vault balance increase to fee-sharing accounting. Additional requirements: * The `source_program` and instruction discriminator must match a whitelisted action. * The whitelisted token-vault account index must point to the fee vault's token vault. * The signer must be one of the configured share-holder addresses. * The fee vault must be a PDA vault. <Warning> A fee vault is designed to support a single token mint and a single token vault, and `fund_by_claiming_fee` credits only the balance increase of that one token vault. The source pool's `CollectFeeMode` must therefore be configured to collect fees only in the fee vault's token mint: `OnlyB` or `Compounding` for DAMM v2 and `QuoteToken` for DBC. </Warning> ## Compatible Source Programs and Actions Dynamic Fee Sharing currently whitelists supported actions from DAMM v2 and DBC. ### DAMM v2 Supported DAMM v2 claim actions include: | Whitelisted Action | Token Vault Account Index | Product Meaning | | - | - | - | | `ClaimPositionFee` | `4` | Claim trading fees from a DAMM v2 position into the fee vault. | | `ClaimReward` | `5` | Claim DAMM v2 reward emissions into the fee vault. | ### Dynamic Bonding Curve (DBC) Supported DBC claim and withdrawal actions include: | Whitelisted Action | Token Vault Account Index | Product Meaning | | - | - | - | | `CreatorWithdrawSurplus` | `3` | Route creator surplus into the fee vault. | | `ClaimCreatorTradingFee` | `3` | Route creator trading fees into the fee vault. | | `PartnerWithdrawSurplus` | `3` | Route partner surplus into the fee vault. | | `ClaimTradingFee` | `4` | Route eligible DBC trading fees into the fee vault. | | `WithdrawMigrationFee` | `3` | Route eligible migration fees into the fee vault. | <Note> The token-vault index is part of the program's whitelist check. If an integration changes account ordering, Dynamic Fee Sharing must whitelist the matching action and account index before that claim path works. </Note> ## What Is Not a Fit Dynamic Fee Sharing may not be the right product when: * The recipient set changes frequently. * There are more than 5 recipients. * The token mint uses unsupported Token 2022 extensions. * The fee source requires an unsupported cross-program claim action. * The payout requires complex conditional logic instead of fixed shares. * The setup needs owner-managed edits, admin withdrawals, or vault closure through the current program. For those cases, teams should either use manual operational flows or build a custom distribution layer around their requirements. # Dynamic Fee Sharing Design Guide Source: https://docs.meteora.ag/helper-products/dynamic-fee-sharing/design-guide Choose Dynamic Fee Sharing recipients, shares, token mint, vault type, and funding method before initializing a fee vault. Dynamic Fee Sharing is simple after initialization, so most design work happens before a vault is created. Use this page to turn a fee-sharing agreement into a vault configuration. ## Start With the Revenue Stream Before configuring a vault, identify the fee stream you want to split. Answer these questions first: * What product or campaign generates the fees? * Which token mint will the fees be paid in? * Who should receive the fees? * Are there 2 to 5 stable recipient entries? * Will fees be manually funded or claimed from a compatible Meteora product? A clear revenue stream makes the vault easier to design and easier for recipients to understand. ## Choose the Vault Type | Vault Type | Choose This When | | - | - | | Non-PDA fee vault | The vault is standalone and will be manually funded. | | PDA fee vault | The vault should be deterministic from `base` and `token_mint`, or it needs supported claim-by-integration funding. | <Info> If you are unsure and only need to transfer tokens into the vault manually, a Non-PDA fee vault is usually simpler. </Info> ## Choose the Token Mint A fee vault distributes one token mint. If your revenue stream has multiple tokens, create separate vaults. For example: * One vault for USDC fees. * One vault for SOL fees. * One vault for a reward token. This keeps each vault's accounting clear and avoids mixing assets with different decimals, transfer behavior, or recipient expectations. ## Choose Recipients Dynamic Fee Sharing supports 2 to 5 recipients. Good recipient entries include: * Creator wallet * Launchpad wallet * Treasury wallet * Strategy operator wallet * Campaign partner wallet * Contributor multisig Because the recipient list is fixed at creation, use durable wallets. For teams, a multisig or treasury-controlled wallet is usually better than a personal hot wallet. The program rejects the default public key, but it does not reject duplicate recipient addresses. Unless duplicate entries are intentional, check for duplicates before initialization. ## Choose Shares Shares are relative weights. They do not need to add up to 100, but percent-style totals are easier to communicate. Common share patterns: | Split | Share Setup | | - | - | | 50/50 | 50 and 50 | | 70/30 | 70 and 30 | | 80/15/5 | 80, 15, and 5 | | Basis points style | Total shares add to 10,000 | Use basis-points style shares when you want more precise allocations, such as 12.5% or 2.75%. ```text theme={"system"} 12.5% = 1,250 shares out of 10,000 2.75% = 275 shares out of 10,000 ``` <Note> The program stores each share and total shares as `u32` values. Choose a share scale that is precise enough for the agreement but still easy for humans to audit. </Note> ## Choose the Funding Method ### Manual Funding Manual funding is best when fees are collected outside the Dynamic Fee Sharing program or need to be batched before distribution. Use manual funding for: * Treasury distributions. * Partner payouts. * Revenue that arrives from off-chain operations. * Unsupported fee sources. * Campaign budgets. ### Funding by Claiming Fees Funding by claiming fees is best when a PDA fee vault is integrated with a supported Meteora product action. Use this path for: * Supported DAMM v2 fee or reward claims. * Supported DBC fee, surplus, or migration-fee claims. * Product-native revenue sharing where the fee vault should receive claimable fees directly. Because a fee vault supports a single token mint and a single token vault, the source pool's `CollectFeeMode` must collect fees only in the fee vault's token mint: `OnlyB` or `Compounding` for DAMM v2 and `QuoteToken` for DBC. See [Compatibilities](/helper-products/dynamic-fee-sharing/compatibilities) for the exact whitelisted actions and signer requirements. ## Communicate the Vault Clearly Before recipients rely on a fee vault, share the key details: ```text theme={"system"} Fee vault address: Token mint: Vault type: Non-PDA / PDA Base account, if PDA: Recipient list: Recipient shares: Funding method: Manual / supported claim action Recipient index for each recipient: Expected funding cadence: ``` For public or partner-facing setups, a simple table of recipients and shares is usually enough. If funding amounts are very small relative to total shares, tell recipients to claim only when their displayed claimable amount is greater than zero. The program advances a recipient checkpoint even when the rounded claim amount is zero. ## Avoid Common Mistakes <AccordionGroup> <Accordion title="Using one vault for multiple tokens"> A fee vault is tied to one token mint. Create separate vaults for separate fee tokens. </Accordion> <Accordion title="Choosing personal wallets for long-term splits"> Recipient addresses are fixed. Prefer durable wallets such as treasuries or multisigs for long-lived revenue streams. </Accordion> <Accordion title="Accidentally duplicating a recipient address"> The program does not reject duplicate recipient addresses. Check the recipient list before initialization so dashboards, claims, and expectations are clear. </Accordion> <Accordion title="Using too many recipients"> Dynamic Fee Sharing supports up to 5 recipients. If your payout design needs a large recipient set, use a different distribution approach. </Accordion> <Accordion title="Assuming all Token 2022 mints are supported"> The program supports a limited set of Token 2022 extensions. Check compatibility before creating the vault. </Accordion> <Accordion title="Expecting unsupported products to claim directly"> Claim-by-integration funding only works for whitelisted actions. Other revenue can still use manual funding. </Accordion> <Accordion title="Pairing a fee vault with a pool that collects fees in both tokens"> A fee vault tracks a single token mint and a single token vault. Keep the source pool on the default quote-token-only `CollectFeeMode` (`OnlyB` for DAMM v2, `QuoteToken` for DBC) so all claimed fees arrive in the fee vault's token mint. Fees collected in a second token are not tracked by the fee vault. </Accordion> <Accordion title="Treating owner as an admin"> The fee vault stores an `owner` field, but the current instructions do not use it for editing recipients, changing shares, withdrawing funds, or closing the vault. </Accordion> </AccordionGroup> ## Recommended Designs | Scenario | Recommended Design | | - | - | | Simple partner split | Non-PDA vault, 2 recipients, manual funding. | | Creator and launchpad revenue | PDA vault if integrated with DBC, otherwise Non-PDA vault with manual funding. | | DAMM v2 fee sharing | PDA vault tied to the relevant base account and token mint. | | Reward token sharing | Separate vault for the reward token mint. | ## Pre-Launch Checklist Before creating a fee vault, confirm: * The token mint is correct. * The token standard is supported. * There are 2 to 5 recipients. * Every recipient wallet is correct. * Recipient addresses are unique unless duplicates are intentional. * Every share is non-zero. * The share split matches the agreement. * The vault type matches the funding method. * The `base` account can sign initialization if this is a PDA vault. * A configured share-holder can sign claim-by-integration funding if needed. * Recipients know how and when to claim. Once those are true, the vault can become the on-chain source of truth for that fee split. # Dynamic Fee Sharing Formulas Source: https://docs.meteora.ag/helper-products/dynamic-fee-sharing/formulas Understand Dynamic Fee Sharing share math, fixed-point fee-per-share accounting, claimable amounts, rounding, and transfer-fee behavior. Dynamic Fee Sharing uses cumulative share accounting. Funding increases the value of each share, and each recipient stores a checkpoint for the share value they have already claimed. <Note>The program performs integer arithmetic. This page shows the same formulas in product terms, with the important units and rounding behavior called out.</Note> ## Units | Value | Program Unit | | - | - | | `share` | `u32` relative weight for one user entry. Must be greater than `0`. | | `total_share` | `u32` sum of all configured shares. | | `funded_amount` | `u64` amount added to vault accounting. | | `fee_per_share` | `u128` cumulative Q64.64-style value. | | `PRECISION_SCALE` | `64`, meaning calculations scale by `2^64`. | | `fee_claimed` | `u64` gross amount claimed by one user entry. | ## Total Shares The vault adds all recipient shares together. ```math theme={"system"} \text{Total Share} = \sum_i \text{Recipient Share}_i ``` Each recipient's expected proportion is: ```math theme={"system"} \text{Recipient Proportion} = \frac{\text{Recipient Share}}{\text{Total Share}} ``` Example: | Recipient | Share | Percentage | | - | - | - | | Creator | 50 | 50% | | Partner | 30 | 30% | | Treasury | 20 | 20% | The total share is 100, so the shares map directly to percentages. The same split could also be represented as 5, 3, and 2 shares. ## Manual Funding Amount Manual funding takes `max_amount`, but the program never transfers more than the source token account currently holds: ```math theme={"system"} \text{Transfer Amount} = \min(\text{max\_amount}, \text{source token account balance}) ``` If `Transfer Amount = 0`, the instruction fails. For standard SPL Token mints, the funded amount is the transfer amount: ```math theme={"system"} \text{Funded Amount} = \text{Transfer Amount} ``` For supported Token 2022 transfer-fee mints, the program calculates the transfer fee for the current epoch and accounts for the amount excluding that fee: ```math theme={"system"} \text{Funded Amount} = \text{Transfer Amount} - \text{Transfer Fee} ``` This prevents funding accounting from crediting more tokens than the token vault receives. ## Claim-By-Integration Funding When a PDA vault funds itself through `fund_by_claiming_fee`, the program measures the token vault balance before and after the whitelisted CPI. ```math theme={"system"} \text{Claimed Amount} = \text{Token Vault Balance After} - \text{Token Vault Balance Before} ``` If `Claimed Amount > 0`, the vault adds that amount to fee accounting: ```math theme={"system"} \text{Funded Amount} = \text{Claimed Amount} ``` If the balance does not increase, the program does not update fee accounting or emit a fund event. ## Fee Per Share Each time new fees enter the vault, the vault increases the cumulative fee-per-share value. Conceptually: ```math theme={"system"} \text{Fee Per Share Increase} = \frac{\text{Funded Amount}}{\text{Total Share}} ``` In the program: ```math theme={"system"} \text{Fee Per Share Increase} = \left\lfloor \frac{\text{Funded Amount} \times 2^{64}}{\text{Total Share}} \right\rfloor ``` Then it updates the cumulative value: ```math theme={"system"} \text{New Fee Per Share} = \text{Previous Fee Per Share} + \text{Fee Per Share Increase} ``` The vault also increases `total_funded_fee`: ```math theme={"system"} \text{Total Funded Fee}_{new} = \text{Total Funded Fee}_{old} + \text{Funded Amount} ``` ## Claimable Fee Each recipient stores a checkpoint: the fee-per-share value they had already claimed up to. When the recipient claims, the vault calculates the difference between the current fee-per-share and that recipient's checkpoint. ```math theme={"system"} \text{Unclaimed Fee Per Share} = \text{Current Fee Per Share} - \text{Recipient Checkpoint} ``` Then the vault multiplies that delta by the recipient's share: ```math theme={"system"} \text{Claimable Fee} = \left\lfloor \frac{\text{Recipient Share} \times \text{Unclaimed Fee Per Share}}{2^{64}} \right\rfloor ``` After the claim, the recipient's checkpoint and total claimed amount are updated: ```math theme={"system"} \text{Recipient Checkpoint} = \text{Current Fee Per Share} ``` ```math theme={"system"} \text{Fee Claimed}_{new} = \text{Fee Claimed}_{old} + \text{Claimable Fee} ``` This is how the vault prevents double-claiming while still allowing recipients to claim independently. <Warning> The checkpoint updates even when `Claimable Fee` rounds down to `0`. For very small funding amounts or very large total-share values, claiming too early can round the user's current entitlement to zero and advance their checkpoint. </Warning> ## Worked Example Assume a vault has three recipients: | Recipient | Share | | - | - | | Creator | 50 | | Partner | 30 | | Treasury | 20 | Total share: ```math theme={"system"} 50 + 30 + 20 = 100 ``` A funder adds 1,000 USDC into the vault. The expected distribution is: ```math theme={"system"} \text{Creator} = 1{,}000 \times \frac{50}{100} = 500 ``` ```math theme={"system"} \text{Partner} = 1{,}000 \times \frac{30}{100} = 300 ``` ```math theme={"system"} \text{Treasury} = 1{,}000 \times \frac{20}{100} = 200 ``` If the creator claims first, the creator receives 500 USDC and the creator's checkpoint updates. The partner and treasury can claim later; their balances remain claimable because their checkpoints have not moved. ## Multiple Funding Events Dynamic Fee Sharing supports repeated funding. Example: | Event | Net Funded Amount | | - | - | | Funding 1 | 1,000 USDC | | Funding 2 | 500 USDC | | Funding 3 | 250 USDC | Total funded fee: ```math theme={"system"} \text{Total Funded Fee} = 1,000 + 500 + 250 = 1,750 ``` A 30% recipient would be entitled to: ```math theme={"system"} 1{,}750 \times 30\% = 525 \text{ USDC} ``` If that recipient already claimed 300 USDC after the first funding event, the next claim would be around 225 USDC, subject to integer rounding. ## Remaining Vault Balance For standard SPL Token mints, the token vault balance usually represents funded fees that have not yet been claimed, plus small rounding dust. Simplified formula: ```math theme={"system"} \text{Remaining Vault Balance} = \text{Total Funded Fee} - \sum_i \text{Total Claimed By Recipient}_i ``` Because token amounts are integers and `fee_per_share` increments are floored, small dust can remain when funded amounts do not divide evenly across shares. ## Transfer-Fee Token Claims For supported Token 2022 transfer-fee mints, manual funding credits the net amount received by the token vault. Claims are different: the program calculates a gross `Claimable Fee` and transfers that amount from the token vault to the recipient token account. If the mint charges a transfer fee on that outgoing transfer, the recipient token account may receive less than the gross claimed amount. ```math theme={"system"} \text{Net Received By Recipient} = \text{Claimable Fee} - \text{Outgoing Transfer Fee} ``` The program's `fee_claimed` field tracks the gross claimed amount. ## Rounding and Precision The program uses high-precision fee-per-share accounting by scaling calculations with `2^64`. This helps preserve precision for small funding amounts and large total-share values. The program includes a property test that checks small funded amounts still produce a non-zero `fee_per_share` even when `total_share` is `u32::MAX`. Even with high precision, final claim amounts are integer token amounts. If a funded amount cannot be split perfectly between recipients, dust can remain in the vault. <Note> For product planning, choose share weights that are easy to communicate. Percent-style totals such as 100, 1,000, or 10,000 are usually easier for teams and recipients to reason about. </Note> # What is Dynamic Fee Sharing? Source: https://docs.meteora.ag/helper-products/dynamic-fee-sharing/what-is-dynamic-fee-sharing Learn how Meteora Dynamic Fee Sharing lets teams fund a token vault and split claimable fees across a small fixed recipient set. ## Overview Dynamic Fee Sharing is Meteora's on-chain fee distribution program. It lets a team cre
프로젝트로 돌아가기