chore: move-pool-v1-to-v4.mjs — operator-authorized 20 SOL reserve top-up#316
Open
magpiecapital wants to merge 2 commits into
Open
chore: move-pool-v1-to-v4.mjs — operator-authorized 20 SOL reserve top-up#316magpiecapital wants to merge 2 commits into
magpiecapital wants to merge 2 commits into
Conversation
Operator-authorized 2026-06-16 PM transfer of 20 SOL from V1 LP
position to V4 to top up V4 reserves. Script clones move-pool-v2-to-
v4.mjs (which handles the V1/V2 withdraw u64 overflow by chunked
share withdrawals) and swaps every V2 reference for V1.
Hybrid path:
1. admin_withdraw V1 vault drift (single tx)
2. share-based withdraw loop for remainder (chunks of 0.1 SOL to
dodge the u64 overflow on shares * total_deposits / total_shares)
3. unwrap wSOL → native SOL → re-wrap → V4 deposit in one tx
Safety rails:
- Pool PDAs re-derived + asserted against operator-stated addresses
(V1: EynWtuRMUKU3zHzfLv7Y5Qu6MWpwqG17X91QAuHSww9u, V4: env)
- Pre-flight: lender has ≥ 1 SOL for fees; V1 vault has ≥ requested
- --dry-run prints the plan without sending
- Idempotent: re-running resumes from current wSOL ATA balance
Usage on Railway:
railway run --service magpie-bot -- \\
node scripts/move-pool-v1-to-v4.mjs --dry-run --amount-sol 20
Then after verifying the plan:
railway run --service magpie-bot -- \\
node scripts/move-pool-v1-to-v4.mjs --amount-sol 20
- PROGRAM_ID is the V1 program env (V1 was the original, suffix-less).
Falls back through PROGRAM_ID_V1 first for future-proofing.
- V4_POOL_STATED default anchored to 7My1o9Jfm2D5wM2xfpfy67NPvTPVUTSzWyz7ZxjwPjT4
(derived from lender 4JSSSaG3...zPAx + PROGRAM_ID_V4) so the safety-
assertion fails closed without per-env config.
Dry-run validated against prod state:
V1 totalDeposits=116.91 SOL, totalBorrowed=54.34 SOL, vault=64.47 SOL
Plan: admin_withdraw 1.90 SOL drift + 182×0.1 SOL share-withdrawals
→ deposit 20 SOL into V4
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
magpiecapital
force-pushed
the
chore/move-v1-to-v4-script
branch
from
June 24, 2026 17:59
5e8baff to
501924e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Operator-authorized 2026-06-16 PM. Clones move-pool-v2-to-v4.mjs and swaps V2 references for V1. Hybrid path: admin_withdraw drift + chunked share-withdraw + V4 deposit. Safety rails preserved.