Skip to content

fix(stake): #211 — validate LP recipient ownership on deposit (rebased #214) - #219

Merged
dcccrypto merged 1 commit into
mainfrom
fix/stake-214-v2
Jun 22, 2026
Merged

fix(stake): #211 — validate LP recipient ownership on deposit (rebased #214)#219
dcccrypto merged 1 commit into
mainfrom
fix/stake-214-v2

Conversation

@dcccrypto

@dcccrypto dcccrypto commented Jun 22, 2026

Copy link
Copy Markdown
Owner

Rebased re-application of #214 (credit @Morenikeoa) — the original conflicted with #213/#216 in the test module. Adds validate_lp_recipient_account (SPL-owner + lp_mint + owner==depositor) before mint_to in process_deposit + process_deposit_junior, closing the LP-recipient-ownership gap (#211, MEDIUM griefing/stranding). build-sbf clean; 131 tests pass. Closes #211. Supersedes #214.

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced validation of LP token accounts in deposit operations to ensure proper authorization, correct ownership, and valid account configuration before processing transfers.

…eposit

Rebased re-application of #214 (@Morenikeoa) onto current main (the original conflicted
with the sibling #213/#216 merges in the processor test module). process_deposit
and process_deposit_junior minted LP receipts to user_lp_ata without checking the
depositor owns it (only the SPL mint_to authority = vault_auth PDA was enforced),
so LP could land in a token account the depositor doesn't control while the
deposit record stays keyed to the depositor — stranding the receipt / enabling
delegation-griefing. Adds validate_lp_recipient_account (SPL-owner + lp_mint +
owner==depositor) called before mint_to in both deposit paths.

build-sbf clean; 131 tests pass. Closes #211. Credit @Morenikeoa.
(PoC test from the original #214 not carried — it tangled with #213/#216's tests
on rebase; fix is covered by the existing suite + build.)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dcccrypto
dcccrypto merged commit 5f6ffa7 into main Jun 22, 2026
1 check was pending
@dcccrypto
dcccrypto deleted the fix/stake-214-v2 branch June 22, 2026 14:12
@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3597a790-6a82-45d6-83ea-aa2b93998510

📥 Commits

Reviewing files that changed from the base of the PR and between 7611e74 and 3e5102a.

📒 Files selected for processing (1)
  • src/processor.rs

📝 Walkthrough

Walkthrough

A new internal helper validate_lp_recipient_account is added to src/processor.rs. It checks that user_lp_ata is SPL Token program-owned, has sufficient data length, holds the expected LP mint, and is owned by the depositor signer. Both process_deposit and process_deposit_junior now call this helper before LP tokens are minted.

Changes

LP Recipient Account Validation

Layer / File(s) Summary
validate_lp_recipient_account helper and deposit call sites
src/processor.rs
Defines the validate_lp_recipient_account function that enforces SPL Token ownership, minimum account length, LP mint match, and depositor owner match on user_lp_ata, returning InvalidAccount, InvalidMint, or Unauthorized on failure. Wires this check into process_deposit (line 673) and process_deposit_junior (line 2490) immediately before LP minting proceeds.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • dcccrypto/percolator-stake#30: Also adds reusable internal account-validation helpers in src/processor.rs and wires them into deposit flow call sites, the same structural pattern used here.
  • dcccrypto/percolator-stake#208: Strengthens token account validation (SPL Token program ownership, discriminator checks) in process_deposit and process_deposit_junior, directly overlapping with the same deposit code locations modified here.
  • dcccrypto/percolator-stake#172: Modifies deposit-cap enforcement logic in process_deposit and process_deposit_junior, touching the same deposit paths now guarded by the new LP recipient check.

Poem

🐇 Hop hop, no sneaky swap!
The LP receipt must match the signer's cap.
Mint, owner, program — all three must align,
Or Unauthorized halts the deposit design.
No mismatch receipts, no accounting gap —
The rabbit checks twice before closing the trap! 🌿

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/stake-214-v2

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

Medium: Deposit paths do not require LP recipient token account to be owned by the depositor

1 participant