-
Notifications
You must be signed in to change notification settings - Fork 1
feat(m5): GraveVault salvage_pool execution path #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
c38bc94
fac3b19
1484952
5a7e9db
445b458
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,30 @@ | ||
| # Changelog | ||
|
|
||
| ## [Unreleased — m5: salvage_pool execution path] | ||
|
|
||
| ### Added | ||
| - **GraveVault salvage_pool execution path** end-to-end (m5): | ||
| - `cpi/raydium_v4.rs` — real Raydium V4 `withdraw` CPI (vault_authority PDA-signs `user_owner`; 18-account list; 9-byte data `[tag=4][amount_le]`; AMM authority constant validation; pre/post balance deltas). | ||
| - `cpi/jupiter.rs` — Jupiter v6 swap CPI helper (forwards salvor's pre-computed route data + accounts; vault_authority signs). | ||
| - `cpi/raydium_clmm.rs`, `cpi/orca_whirlpool.rs`, `cpi/pump_swap.rs` — honest-stub adapters; revert `AmmCpiUnimplemented` (7017). | ||
| - `cpi/mod.rs` — dispatcher by `pool.owner`. | ||
| - **salvage_pool handler** rewritten to wire: salvor→vault LP transfer, dispatched remove_liquidity CPI, Jupiter swap (or dust skip), WSOL→SOL unwrap via `close_account` to `vault_sol_holding_account`, 40/40/20 distribution via three `system_program::transfer` calls, PoolRegistry + SalvageReceipt population, `PoolSalvaged` + `SalvageCompleted` emit. | ||
| - **Five new error codes** (7015-7019): `AmmRedemptionFailed`, `JupiterSwapFailed`, `AmmCpiUnimplemented`, `InvalidSnapshotData`, `UnsupportedBaseToken`. Mirrored to `docs/error_codes.md` in lock-step per the sync convention. | ||
| - **New PDA seeds**: `VAULT_AUTHORITY_SEED` (singleton signer), `VAULT_SOL_HOLDING_SEED` (per-pool, transient native-SOL holding for unwrap). | ||
| - **New constants**: `WSOL_MINT`, `RAYDIUM_V4_PROGRAM_ID`, `RAYDIUM_V4_AMM_AUTHORITY` (`5Q544...`), `RAYDIUM_CLMM_PROGRAM_ID`, `ORCA_WHIRLPOOL_PROGRAM_ID`, `PUMP_SWAP_PROGRAM_ID`, `JUPITER_V6_PROGRAM_ID`, `RAYDIUM_V4_INSTRUCTION_TAG_WITHDRAW = 4`, `RAYDIUM_V4_WITHDRAW_REMAINING_ACCOUNTS_REQUIRED = 11`, `BPS_DENOMINATOR = 10_000`, `HARD_MAX_SLIPPAGE_BPS = 1_000`. | ||
| - **PRE_MAINNET_CHECKLIST**: new rows `CPI-006/007/008` (CLMM/Orca/PumpSwap stubs) + `CPI-009` (Raydium V4 account-ordering verification against a live mainnet pool — blocking row). | ||
|
|
||
| ### Changed | ||
| - `salvage_pool` instruction signature now takes `Context<'_, '_, '_, 'info, SalvagePool<'info>>` (explicit `'info` threading per Anchor 0.31+ lifetime invariance — see failure-pattern memory). | ||
| - `SalvagePoolParams` extended with `salvor_lp_amount`, `jupiter_route_data: Vec<u8>`, `max_slippage_bps_override: Option<u16>`, `jupiter_route_accounts_len: u8`. | ||
| - `SalvagePool` Accounts struct extended with `vault_authority`, `vault_sol_holding_account`, `salvor_lp_token_account`, `vault_lp_token_account`, `vault_base_token_account`, `vault_memecoin_token_account`, `lp_mint`, `memecoin_mint`, `wsol_mint` (pinned via `address` constraint), `token_program`, `associated_token_program`. | ||
|
|
||
| ### Unverified | ||
| - BPF compile via `anchor build` (deferred to CI on this PR). | ||
| - Live Raydium V4 fork test of the exact 18-account ordering. The `amm_authority` constant check provides one assertion; full integration is `CPI-009` in `PRE_MAINNET_CHECKLIST.md`. | ||
| - Real Jupiter v6 swap end-to-end. The CPI helper forwards what the salvor's bot quotes; verification is a localnet smoke test post-merge. | ||
| - Pool orientation: `base_is_coin_side` is currently hardcoded `true` (assumes WSOL is the pool's coin side). A SOL/X pool where WSOL is the PC side will need the bot to invert its submission ordering; a runtime parse of pool data to detect orientation is in `PRE-MAINNET-TODO(CPI)` comments in `salvage_pool.rs`. | ||
|
|
||
|
Comment on lines
+22
to
+27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win Pool orientation concern mentioned but not tracked in PRE_MAINNET_CHECKLIST. Line 26 documents a pool orientation hardcoding issue with "PRE-MAINNET-TODO(CPI) comments" in the source, but no corresponding CPI-010 (or similar) row appears in If the pool orientation assumption is a blocking or high-priority concern, add a numbered row (e.g., CPI-010) to the checklist with appropriate status (🟥/🟧) and verification criteria. If it's lower priority or addressed differently, clarify the relationship between this Unverified item and the checklist scope. 🤖 Prompt for AI Agents |
||
| All notable changes to the GraveYield protocol monorepo are documented here. | ||
| The format is loosely based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), | ||
| and the project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verify the platform-tools archive before extracting it.
This step untars an executable toolchain straight from a network download into the runner cache. Without checking the published checksum or signature first, a compromised release asset becomes code execution in CI.
Proposed fix
- name: Pin platform-tools v1.54 (edition2024 fix) run: | set -euo pipefail curl -sSL -o /tmp/platform-tools.tar.bz2 \ "https://github.com/anza-xyz/platform-tools/releases/download/v1.54/platform-tools-linux-x86_64.tar.bz2" + curl -sSL -o /tmp/platform-tools.tar.bz2.sha256 \ + "https://github.com/anza-xyz/platform-tools/releases/download/v1.54/platform-tools-linux-x86_64.tar.bz2.sha256" + sha256sum -c /tmp/platform-tools.tar.bz2.sha256 CACHE_DEST="$HOME/.cache/solana/v1.51/platform-tools" rm -rf "$CACHE_DEST" mkdir -p "$CACHE_DEST" tar xjf /tmp/platform-tools.tar.bz2 -C "$CACHE_DEST"📝 Committable suggestion
🤖 Prompt for AI Agents