From cebad38d3e2761e120361e30954840c94b520c78 Mon Sep 17 00:00:00 2001 From: Akeem813 Date: Wed, 29 Jul 2026 11:08:31 +0000 Subject: [PATCH] fix(market): track depositors in MarketParticipants list on deposit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: #495 --- contracts/market/src/deposit.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/contracts/market/src/deposit.rs b/contracts/market/src/deposit.rs index 5ef94d3..169b839 100644 --- a/contracts/market/src/deposit.rs +++ b/contracts/market/src/deposit.rs @@ -147,6 +147,13 @@ pub fn deposit_collateral( // Persist updated position storage::set_position(&env, market_id, &user, &position)?; + // Track first-time participants so the market can later be settled + // page-by-page via `settle_positions_page` (Issue #495) without + // requiring an off-chain index of every depositor. Idempotent — safe + // to call on every deposit; the helper only appends when the address + // is not already present. + storage::add_market_participant(&env, market_id, &user); + // Record deposit timestamp for cooldown enforcement on withdrawals (issue #413). storage::set_last_deposit_time(&env, market_id, &user, env.ledger().timestamp());