Skip to content

fix(market): reject deposits at exactly end_time (>= instead of >) - #651

Open
Akeem813 wants to merge 1 commit into
Vatix-Protocol:devfrom
Akeem813:fix/issue-344-expiry-boundary-deposit
Open

fix(market): reject deposits at exactly end_time (>= instead of >)#651
Akeem813 wants to merge 1 commit into
Vatix-Protocol:devfrom
Akeem813:fix/issue-344-expiry-boundary-deposit

Conversation

@Akeem813

@Akeem813 Akeem813 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

close 548

The expiry guard in deposit_collateral used strict greater-than (>):

if env.ledger().timestamp() > market.end_time {
    return Err(ContractError::MarketExpired);
}

This admitted a deposit whose ledger timestamp equals end_time exactly. end_time is the market's expiry instant — a deposit that lands in the same ledger second is a deposit into an expired market and must be rejected.

Fix

Change the comparison to greater-than-or-equal (>=):

if env.ledger().timestamp() >= market.end_time {
    return Err(ContractError::MarketExpired);
}

Boundary Behaviour

Ledger timestamp Before fix After fix
< end_time ✅ accepted ✅ accepted
== end_time ✅ accepted (bug) MarketExpired (fixed)
> end_time MarketExpired MarketExpired

Files Changed

  • contracts/market/src/deposit.rs — change > to >= in the expiry check

Acceptance Criteria

  • Expired market (timestamp > end_time) rejects deposit with MarketExpired
  • Market at exactly end_time rejects deposit with MarketExpired (fixed)
  • Active market (timestamp < end_time) accepts deposit

The expiry guard in deposit_collateral used a strict greater-than
comparison:

    if env.ledger().timestamp() > market.end_time { … }

This allowed a deposit to land in the same ledger second as the market's
end_time, which is incorrect: end_time is the expiry instant, not the
last valid second. A deposit at timestamp == end_time is a deposit into
an expired market and must be rejected.

Change the comparison to >= so the guard fires at end_time itself:

    if env.ledger().timestamp() >= market.end_time { … }

Acceptance criteria:
  - deposit at timestamp  < end_time  → accepted  (unchanged)
  - deposit at timestamp == end_time  → rejected with MarketExpired (fixed)
  - deposit at timestamp  > end_time  → rejected with MarketExpired (unchanged)
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