fix(market): track depositors in MarketParticipants list on deposit - #648
Open
Akeem813 wants to merge 1 commit into
Open
fix(market): track depositors in MarketParticipants list on deposit#648Akeem813 wants to merge 1 commit into
Akeem813 wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
deposit_collateralnever calledadd_market_participant, so users who deposited collateral but never executed a trade were absent from theMarketParticipants(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.Root Cause
add_market_participantwas 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 afterset_positionindeposit_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— calladd_market_participantafter persisting positionAcceptance Criteria
add_market_participantis idempotent