Skip to content

fix: restore investment_vault compilation and repair deposit-lock (Closes #310, #311, #314) - #356

Open
laurentketterle-hub wants to merge 2 commits into
Heliobond:mainfrom
laurentketterle-hub:fix/issue-314-deposit-lock
Open

fix: restore investment_vault compilation and repair deposit-lock (Closes #310, #311, #314)#356
laurentketterle-hub wants to merge 2 commits into
Heliobond:mainfrom
laurentketterle-hub:fix/issue-314-deposit-lock

Conversation

@laurentketterle-hub

Copy link
Copy Markdown

Summary

The withdrawal-window feature merge (#36) left the investment-vault crate non-compiling on main. This PR restores compilation and repairs the deposit-lock logic.

Root cause

A botched merge introduced several defects at once:

  1. Missing closing braces (Fix compile failure: four missing closing braces in investment_vault/src/lib.rs #310): get_withdrawal_window and get_volume_fee_tier in lib.rs, and the withdrawal_window_set / funding_round_ended event functions in events.rs, each lost their closing brace before the next section header.
  2. Duplicate enum discriminants (VaultError enum has three variants sharing discriminant 41 (EmptyBatchDeposit, FundingRoundActive, InvestmentCapExceeded) #311): EmptyBatchDeposit, FundingRoundActive, and InvestmentCapExceeded all declared = 41, a hard E0081 compile error.
  3. Undefined last_seq and merged lock models (check_deposit_lock references undefined last_seq and merges two incompatible lock mechanisms #314): check_deposit_lock referenced a last_seq variable that was never declared and compared the stored deposit timestamp against a ledger-sequence window.

Fix

  • Add a LastDepositSeq(Address) persistent key, recorded by lock_deposit (deposits, share transfers, and bridge mints) alongside the existing timestamp.
  • Rewrite check_deposit_lock to enforce a single, well-defined rule: the ledger-sequence sliding window (WithdrawalWindowLedgers, default 1 = blocks same-ledger exit). The legacy timestamp MIN_LOCK_PERIOD cooldown remains exposed via get_deposit_lock_expiry.
  • Renumber FundingRoundActive = 42 and InvestmentCapExceeded = 43.
  • Restore the four missing closing braces.

Verification

cargo build -p investment-vault compiles cleanly. The existing test_withdrawal_window_blocks_early_exit / test_withdrawal_window_allows_exit_after_window tests exercise exactly this sliding-window behavior.

Closes #310
Closes #311
Closes #314

noreply and others added 2 commits August 12, 2026 23:06
…oses Heliobond#310, Heliobond#311, Heliobond#314)

The withdrawal-window merge (Heliobond#36) left the crate non-compiling: get_withdrawal_window and get_volume_fee_tier were missing closing braces, the withdrawal_window_set and funding_round_ended event functions were missing closing braces, check_deposit_lock referenced an undefined last_seq and merged two incompatible lock models, and VaultError had three variants sharing discriminant 41.

This change adds a LastDepositSeq(Address) storage key recorded by lock_deposit, rewrites check_deposit_lock to enforce the ledger-sequence sliding window (Heliobond#36), renumbers FundingRoundActive to 42 and InvestmentCapExceeded to 43, and restores all missing closing braces.

Signed-off-by: laurentketterle-hub <laurentketterle-hub@users.noreply.github.com>
…-cap and carbon-credits (Heliobond#314, Heliobond#319, Heliobond#321, Heliobond#318)

Signed-off-by: laurentketterle-hub <laurentketterle-hub@users.noreply.github.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

2 participants