Skip to content

fix(market): track depositors in MarketParticipants list on deposit - #648

Open
Akeem813 wants to merge 1 commit into
Vatix-Protocol:devfrom
Akeem813:fix/issue-495-deposit-market-participants
Open

fix(market): track depositors in MarketParticipants list on deposit#648
Akeem813 wants to merge 1 commit into
Vatix-Protocol:devfrom
Akeem813:fix/issue-495-deposit-market-participants

Conversation

@Akeem813

Copy link
Copy Markdown
Contributor

Problem

deposit_collateral never called add_market_participant, so users who deposited collateral but never executed a trade were absent from the MarketParticipants(market_id) list. This breaks:

  • settle_positions_page: the paginated partial-settlement path enumerates participants from this list — a depositor-only user would never be settled.
  • Off-chain tooling (indexers, admin scripts) that relies on the list to enumerate all market participants.

Root Cause

add_market_participant was introduced in #495 and wired into the trade path (update_position), but was never added to the deposit path (deposit_collateral).

Fix

Call storage::add_market_participant(&env, market_id, &user) immediately after set_position in deposit_collateral.

The helper is idempotent: it performs a linear search before appending, so repeated deposits by the same user produce no duplicate entries. The uniqueness invariant is upheld by the existing implementation.

Files Changed

  • contracts/market/src/deposit.rs — call add_market_participant after persisting position

Acceptance Criteria

  • Participants list stays unique — add_market_participant is idempotent
  • Depositor-only users included in partial settlement path

deposit_collateral now calls add_market_participant after persisting the
position, ensuring every address that deposits collateral — even if they
never execute a trade — is recorded in the MarketParticipants(market_id)
list.

Previously, add_market_participant was only called from update_position
(the trade path). A user who deposited collateral but never traded would
be absent from the participants list, causing them to be skipped by the
paginated settlement helper (settle_positions_page) and any off-chain
tooling that relies on the list to enumerate all market participants.

add_market_participant is idempotent: it performs a linear scan before
appending, so duplicate deposits do not produce duplicate entries.

Fixes: Vatix-Protocol#495
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