Skip to content

chore: move-pool-v1-to-v4.mjs — operator-authorized 20 SOL reserve top-up#316

Open
magpiecapital wants to merge 2 commits into
mainfrom
chore/move-v1-to-v4-script
Open

chore: move-pool-v1-to-v4.mjs — operator-authorized 20 SOL reserve top-up#316
magpiecapital wants to merge 2 commits into
mainfrom
chore/move-v1-to-v4-script

Conversation

@magpiecapital

Copy link
Copy Markdown
Owner

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.

magpiecapital and others added 2 commits June 16, 2026 14:46
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant