Meteora 백서

Meteora

원문

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

, to, tokenProgramId)` | Builds a token-account authority transfer transaction, used for DAMM v2 position NFT account ownership handoff. | | `convertToLamportsBN(amount, tokenDecimal)` | Converts a UI amount string or number to a raw `BN` token amount. | | `checkPositionOwnership(connection, commitment, positionNftAccount, feeVault, tokenProgram?)` | Verifies that a DAMM v2 position NFT account is owned by the fee vault. | | `checkFeeVaultTokenMint(feeVaultTokenMint, tokenAMint, tokenBMint)` | Validates that the fee vault mint matches one of a pool's token mints. | ## Constants | Export | Value or use | | - | - | | `DYNAMIC_FEE_SHARING_PROGRAM_ID` | `dfsdo2UqvwfN8DuUVrMRNfQe11VaiNoKcMqLHVvDPzh` | | `FEE_VAULT_PREFIX` | `fee_vault` | | `FEE_VAULT_AUTHORITY_PREFIX` | `fee_vault_authority` | | `TOKEN_VAULT_PREFIX` | `token_vault` | ## Enums And Types | Export | Values or fields | | - | - | | `TokenType` | `SPL = 0`, `Token2022 = 1`. | | `FeeVault` | Generated IDL account type for `feeVault`. | | `InitializeFeeVaultParameters` | `padding`, `users`. | | `UserShare` | `address`, `share`. | | `CreateFeeVaultParams` | Keypair fee vault creation params. | | `CreateFeeVaultPdaParams` | PDA fee vault creation params. | | `FundFeeVaultParams` | Direct funding params, with optional cached `feeVaultState`. | | `ClaimUserFeeParams` | `feeVault`, `user`, `payer`. | | `ClaimUserFee2Params` | `feeVault`, `user`, `payer`, `receiver`. | | Source funding params | DAMM v2 and DBC wrapper parameter types listed in the funding API table. | # Dynamic Vault Data API Overview Source: https://docs.meteora.ag/developer-guides/dynamic-vault/api-reference/overview Learn how the Dynamic Vault Data API exposes indexed vault state, vault addresses, APY history, strategy allocation, and virtual price data. The Dynamic Vault Data API exposes read-only indexed data for supported vaults, including vault addresses, APY snapshots, strategy allocation, LP supply, total amount, fee amount, virtual price, and timestamps. <Tip> The checked-in Dynamic Vault OpenAPI file does not declare a rate limit. Treat the API as a read-only data source for discovery and dashboards, and use on-chain vault accounts as the source of truth for transaction-critical execution. </Tip> ## Base URL | Environment | Base URL | Notes | | - | - | - | | Production | `https://merv2-api.meteora.ag` | Verified live for Dynamic Vault routes such as `/vault_info` and `/vault_addresses`. | The `@meteora-ag/vault-sdk` source also includes older keeper URL constants. Prefer the documented production host above for new Dynamic Vault API integrations. ## Vaults <CardGroup> <Card title="Vault Info" icon="file-code" href="/api-reference/dynamic-vault/vaults/get_vault_info"> Returns all monitored vault states using `GET` `/vault_info` </Card> <Card title="Vault Addresses" icon="file-code" href="/api-reference/dynamic-vault/vaults/get_vault_addresses"> Returns vault, LP mint, and fee account addresses using `GET` `/vault_addresses` </Card> <Card title="Vault State" icon="file-code" href="/api-reference/dynamic-vault/vaults/get_vault_state"> Returns one vault state by token mint using `GET` `/vault_state/{token_mint}` </Card> </CardGroup> ## APY <CardGroup> <Card title="APY State" icon="file-code" href="/api-reference/dynamic-vault/apy/get_apy_state"> Returns current APY values for a token mint using `GET` `/apy_state/{token_mint}` </Card> <Card title="APY By Time Range" icon="file-code" href="/api-reference/dynamic-vault/apy/get_apy_by_time_range"> Returns APY data within a Unix timestamp range using `GET` `/apy_filter/{token_mint}/{start_timestamp}/{end_timestamp}` </Card> </CardGroup> ## Virtual Price <CardGroup> <Card title="Virtual Price" icon="file-code" href="/api-reference/dynamic-vault/virtual-price/get_virtual_price"> Returns virtual price records for a token mint and strategy using `GET` `/virtual_price/{token_mint}/{strategy}` </Card> </CardGroup> ## Common Response Fields `VaultState` responses include these fields: | Field | Meaning | | - | - | | `symbol` | Display symbol for the vault token. | | `token_address` | Underlying token mint. | | `pubkey` | Vault account address. | | `lp_mint` | Vault LP mint. | | `fee_pubkey` | Fee vault token account. | | `enabled` | Current vault enabled flag from indexed state. | | `total_amount` | Total vault amount in base token units. | | `total_amount_with_profit` | Total amount including indexed profit accounting. | | `token_amount` | Amount currently held in the vault reserve token account. | | `fee_amount` | Indexed fee amount. | | `lp_supply` | Current LP mint supply. | | `virtual_price` | String virtual price derived from vault accounting. | | `usd_rate` | Indexed USD rate for the vault token. | | `closest_apy`, `average_apy`, `long_apy` | Short, 24-hour, and longer-window APY values from the API schema. | | `earned_amount`, `earned_usd_amount` | Indexed earned amount in token units and USD terms. | | `strategies` | Strategy allocation array. | | `timestamp` | API snapshot timestamp. | ## Strategy Fields | Field | Meaning | | - | - | | `pubkey` | Strategy account address. | | `reserve` | Strategy reserve account. | | `strategy_type` | Program strategy enum string. | | `strategy_name` | Display name for the strategy. | | `liquidity` | Strategy liquidity in base token units. | | `max_allocation` | Configured maximum allocation percent. | | `isolated` | Whether the strategy is isolated in the API's risk model. | | `disabled` | Whether the API marks the strategy disabled. | | `safe_utilization_threshold` | API utilization threshold for strategy safety. | ## Query Parameters | Endpoint | Parameter | Meaning | | - | - | - | | `/vault_state/{token_mint}` | `token_mint` | Underlying token mint public key. | | `/apy_state/{token_mint}` | `token_mint` | Underlying token mint public key. | | `/apy_filter/{token_mint}/{start_timestamp}/{end_timestamp}` | `start_timestamp`, `end_timestamp` | Unix timestamps in seconds. `end_timestamp` must be greater than `start_timestamp`. | | `/virtual_price/{token_mint}/{strategy}` | `strategy` | Strategy identifier expected by the API. | ## API Or On-Chain Data | Need | Use | | - | - | | Vault discovery | Data API `/vault_info` or `/vault_addresses`. | | Dashboard APY and strategy allocation | Data API APY and vault-state endpoints. | | Transaction construction | On-chain vault, LP mint, token vault, and strategy accounts. | | Deposit/withdraw execution | TypeScript SDK or CPI with fresh on-chain state and simulation. | | Virtual price display | Data API for display, on-chain calculation for execution-sensitive flows. | ## Source Note The production URL `https://damm-api.meteora.ag/swagger-ui/` serves the Dynamic AMM keeper OpenAPI spec, not the Dynamic Vault routes listed above. The Dynamic Vault routes in this guide are backed by the checked-in `developer-guides/dynamic-vault/api-reference/openapi.json` file and live `merv2-api` route checks. # Dynamic Vault Changelog Source: https://docs.meteora.ag/developer-guides/dynamic-vault/changelog Track Dynamic Vault release notes, source snapshots, SDK changes, IDL notes, and upgrade guidance. <Tip> Track Dynamic Vault integration changes here. This page is initialized from the local `vault-sdk/CHANGELOG.md` and the inspected local program and Rust client sources. </Tip> <Update label="Source snapshot" description="Program and client sources referenced for this documentation pass"> ## Components | Component | Local source | Notes | | - | - | - | | Program | `mercurial-vault/programs/vault` | Anchor program crate version `0.9.4`; Anchor toolchain `0.31.1`; public program ID `24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi`. | | TypeScript SDK | `vault-sdk/ts-client` | Package `@meteora-ag/vault-sdk` version `2.3.1`; web3.js v1 transaction model. | | Rust client | `vault-sdk/rust-client` | CLI helper for show, get-unlocked-amount, deposit, and withdraw flows. | | Data API | `developer-guides/dynamic-vault/api-reference/openapi.json` | OpenAPI `0.6.0` for Dynamic Vault keeper routes. | ## Integration Notes * The current program source includes `initialize_idle_vault`, `transfer_fee_vault`, `remove_strategy2`, `InvalidPrecisionLoss`, `UndeterminedError`, and `JupLend` strategy support. * The checked-in TypeScript IDL in `vault-sdk` is older than the current program source in a few areas. Decode errors by numeric code first when source and IDL names differ. * The TypeScript SDK `withdraw` parameter named `baseTokenAmount` is passed to the program as LP `unmint_amount`; callers should pass LP token units. </Update> <Update label="@meteora-ag/vault-sdk 2.3.1" description="Removed token registry dependency"> ## Changed | Area | Change | | - | - | | Dependencies | Removed `@solana/spl-token-registry`. | ## Upgrade Note Pass token mint `PublicKey` values directly to `VaultImpl.create`, `createMultiple`, and related helpers. Do not rely on token registry `TokenInfo` objects for SDK initialization. </Update> <Update label="@meteora-ag/vault-sdk 2.3.0" description="Moved package ownership to Meteora"> ## Changed | Area | Change | | - | - | | Package | Moved to the `meteora-ag` organization. | ## Upgrade Note Use the package name `@meteora-ag/vault-sdk` for new integrations. </Update> <Update label="@mercurial-finance/vault-sdk 2.2.x" description="Batch loading and mint parsing updates"> ## Added | Version | Change | | - | - | | `2.2.1` | Added `deserializeMint` utility. | ## Changed | Version | Change | | - | - | | `2.2.0` | Fixed `tokenMint` and `tokenLpMint`. | | `2.1.1` | Optimized `createMultiple` and `createMultiplePda` RPC usage. | | `2.1.0` | Updated `createMultiple` to take fewer parameters. | ## Removed | Version | Change | | - | - | | `2.2.0` | Removed `lpMintPda` field. | </Update> <Update label="@mercurial-finance/vault-sdk 2.0.x" description="Dependency updates and withdrawal logic change"> ## Changed | Version | Change | | - | - | | `2.0.0` | Updated `@solana/spl-token` to `0.4.6` and related packages. | ## Fixed | Version | Change | | - | - | | `2.0.1` | Fixed `refreshVaultState`. | ## Removed | Version | Change | | - | - | | `2.0.0` | Removed older direct-strategy withdrawal logic from the package. | </Update> ## Source Gaps | Gap | Impact | | - | - | | No local program changelog was found in `mercurial-vault`. | Program changes are documented here as a source snapshot, not as versioned release notes. | | Public TS IDL is older than the current program source. | Low-level integrators should compare against current source or regenerated IDL before manual instruction construction. | | The provided production Swagger URL serves Dynamic AMM keeper routes. | Dynamic Vault API docs use the checked-in Dynamic Vault OpenAPI file and live `merv2-api` route checks. | # Dynamic Vault Developer Guide Source: https://docs.meteora.ag/developer-guides/dynamic-vault/index Learn how to build Dynamic Vault integrations with the vault program, TypeScript SDK, Rust helpers, Data API, and release notes. Dynamic Vault is Meteora's yield vault layer on Solana. Integrators deposit a supported token into a vault, receive vault LP tokens, and withdraw by burning LP tokens against the vault's unlocked amount. To learn more about the product model, read the product documentation. <CardGroup> <Card title="Learn more about Dynamic Vault" icon="book-open" href="/legacy-products/dynamic-vault/what-is-dynamic-vault"> Overview of vault behavior, yield routing, access rules, and product concepts. </Card> <Card title="Dynamic Vault Formulas" icon="calculator" href="/legacy-products/dynamic-vault/formulas"> Formulas for virtual price, locked profit, LP share, and withdrawal accounting. </Card> </CardGroup> ## Integration <CardGroup> <Card title="Program Accounts" icon="table-cells" href="/developer-guides/dynamic-vault/program/accounts"> Account model for vaults, strategies, locked profit, bumps, PDA seeds, and constants. </Card> <Card title="Program Instructions" icon="list" href="/developer-guides/dynamic-vault/program/instructions"> Instruction families for user deposits, withdrawals, strategy rebalancing, rewards, operators, and admin flows. </Card> <Card title="Program Events" icon="list" href="/developer-guides/dynamic-vault/program/events"> Anchor events emitted by liquidity, strategy, reward, performance fee, loss, and simulation flows. </Card> <Card title="Program Errors" icon="triangle-exclamation" href="/developer-guides/dynamic-vault/program/errors"> Anchor custom errors, messages, likely causes, and source/IDL naming notes. </Card> <Card title="TypeScript SDK" icon="code" href="/developer-guides/dynamic-vault/typescript-sdk/getting-started"> Official TypeScript SDK for creating vault clients, deposits, withdrawals, state reads, helpers, and affiliate flows. </Card> <Card title="Rust Integration" icon="terminal" href="/developer-guides/dynamic-vault/rust-integration/library"> Rust account readers, CLI helpers, and CPI account planning for the vault program. </Card> </CardGroup> <CardGroup> <Card title="Dynamic Vault APIs" icon="database" href="/developer-guides/dynamic-vault/api-reference/overview"> Indexed read-only vault, APY, virtual price, vault address, and strategy allocation data. </Card> </CardGroup> ## Program IDs The public `vault` program ID is the same on mainnet and devnet: | Network | Program ID | | - | - | | Mainnet Beta | `24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi` | | Devnet | `24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi` | The TypeScript SDK also exposes the affiliate program ID: | Program | Address | | - | - | | Affiliate vault program | `GacY9YuN16HNRTy7ZWwULPccwvfFSBeNLuAQP7y38Du3` | ## Constants | Constant | Value | Use | | - | - | - | | `VAULT_BASE_KEY` / `get_base_address()` | `HWzXGcGHy4tcpYfaRDCyLNzXqBTv3E6BttpCH2vJxArv` | Base key used in rebalance vault PDA seeds. | | `get_base_address_for_idle_vault()` | `11111111111111111111111111111111` | Base key used in idle vault PDA seeds. | | `get_treasury_address()` | `9kZeN47U2dubGbbzMrzzoRAUvpuxVLRcjW9XiFpYjUo4` | Owner required for fee vault and reward destination token accounts. | | `MAX_STRATEGY` | `30` | Maximum strategy addresses stored on a vault. | | `MAX_BUMPS` | `10` | Maximum bump bytes stored on a strategy. | | `LOCKED_PROFIT_DEGRADATION_DENOMINATOR` | `1_000_000_000_000` | Denominator for locked-profit drip calculations. | | Performance fee | `500 / 10000` | 5% performance fee minted as vault LP tokens when rebalance reports profit. | ## Source Repositories <CardGroup> <Card title="Vault Program" icon="code" href="https://github.com/MeteoraAg/mercurial-vault/tree/main/programs/vault"> Anchor source for the current vault program handlers, accounts, events, and errors. </Card> <Card title="Vault SDK" icon="github" href="https://github.com/MeteoraAg/vault-sdk"> Public TypeScript SDK, Anchor IDL, vendored program crate, tests, and Rust client helper. </Card> <Card title="TypeScript SDK Package" icon="npm" href="https://www.npmjs.com/package/@meteora-ag/vault-sdk"> Published package for transaction builders, state reads, helper functions, and affiliate support. </Card> <Card title="Rust Client" icon="rust" href="https://github.com/MeteoraAg/vault-sdk/tree/main/rust-client"> CLI-style Rust examples for showing vault state, simulating unlocked amount, deposits, and withdrawals. </Card> </CardGroup> <Note> The current program source in `mercurial-vault/programs/vault` is newer than the TypeScript SDK's checked-in IDL in a few areas. These docs call out source-backed behavior and avoid documenting older IDL-only entries as current program handlers. </Note> ## Commands | Task | Command | | - | - | | Build TypeScript SDK | `cd vault-sdk/ts-client && pnpm install && pnpm run build` | | Run TypeScript SDK tests | `cd vault-sdk/ts-client && pnpm test` | | Run affiliate SDK tests | `cd vault-sdk/ts-client && pnpm run test-affiliate` | | Build Rust client | `cd vault-sdk/rust-client && cargo build` | | Inspect Rust client commands | `cd vault-sdk/rust-client && ../target/debug/rust-client --help` | | Build current vault program | `cd mercurial-vault && NO_DNA=1 anchor build` | | Run current vault program tests | `cd mercurial-vault && NO_DNA=1 anchor test` | ## Stay Updated <CardGroup> <Card title="Dynamic Vault Changelog" icon="newspaper" href="/developer-guides/dynamic-vault/changelog"> Program, SDK, IDL, Rust helper, and API notes for integration planning. </Card> </CardGroup> # Dynamic Vault Program Accounts Source: https://docs.meteora.ag/developer-guides/dynamic-vault/program/accounts Understand Dynamic Vault program accounts, including vaults, strategies, locked profit, PDA seeds, constants, and strategy enums. <Note> This page is based on `mercurial-vault/programs/vault` for the current on-chain program account model and `vault-sdk/ts-client` for public TypeScript helper names. </Note> ## PDA Map | Account | SDK helper | Seeds | | - | - | - | | Rebalance vault | `getVaultPdas(tokenMint, programId)` | `vault`, token mint, `VAULT_BASE_KEY` | | Idle vault | custom derivation | `vault`, token mint, `11111111111111111111111111111111` | | Token vault | `getVaultPdas(tokenMint, programId)` | `token_vault`, vault | | LP mint | `getVaultPdas(tokenMint, programId)` | `lp_mint`, vault | | Strategy | direct derivation | vault, reserve, `strategy_index` byte | | Collateral vault | direct derivation | `collateral_vault`, strategy | | Affiliate partner PDA | SDK internal affiliate helper | vault, partner token ATA | | Affiliate user PDA | SDK internal affiliate helper | partner PDA, user wallet | The vault signs token transfers and LP minting with the rebalance or idle vault seeds stored in `Vault.bumps`. ## Constants | Constant | Value | Use | | - | - | - | | `PROGRAM_ID` | `24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi` | Public vault program ID. | | `AFFILIATE_PROGRAM_ID` | `GacY9YuN16HNRTy7ZWwULPccwvfFSBeNLuAQP7y38Du3` | Public affiliate wrapper program used by the SDK when `affiliateId` is configured. | | `VAULT_BASE_KEY` | `HWzXGcGHy4tcpYfaRDCyLNzXqBTv3E6BttpCH2vJxArv` | Base key for rebalance vault PDA derivation. | | Treasury | `9kZeN47U2dubGbbzMrzzoRAUvpuxVLRcjW9XiFpYjUo4` | Required owner for `fee_vault` and reward token destination accounts. | | `MAX_STRATEGY` | `30` | Number of strategy pubkeys stored in each vault. | | `MAX_BUMPS` | `10` | Number of stored bump bytes in each strategy. | | `LOCKED_PROFIT_DEGRADATION_DENOMINATOR` | `1_000_000_000_000` | Denominator for locked-profit release math. | ## Vault `Vault` stores the accounting state for one token mint. | Field | Type | Meaning | | - | - | - | | `enabled` | `u8` | `1` allows deposits and withdrawals. `0` blocks deposits; withdrawals still use normal withdrawal handlers. | | `bumps` | `VaultBumps` | Vault and token-vault bump bytes used for PDA signer seeds. | | `total_amount` | `u64` | Total vault liquidity, including reserve tokens and strategy liquidity. | | `token_vault` | `Pubkey` | SPL token account holding vault reserves. | | `fee_vault` | `Pubkey` | LP token account owned by treasury that receives performance fee LP. | | `token_mint` | `Pubkey` | Underlying token mint accepted by the vault. | | `lp_mint` | `Pubkey` | Vault LP mint. Deposits mint LP; withdrawals burn LP. | | `strategies` | `[Pubkey; 30]` | Strategy accounts active for the vault. Empty slots are the default pubkey. | | `base` | `Pubkey` | Base seed key. Matches rebalance or idle vault base. | | `admin` | `Pubkey` | Admin authority for vault configuration and strategy management. | | `operator` | `Pubkey` | Operator authority allowed to rebalance and claim strategy rewards. | | `locked_profit_tracker` | `LockedProfitTracker` | Tracks profit that unlocks over time after a rebalance rep
프로젝트로 돌아가기