Description
When the SDK places DEX offers as part of a split payment conversion strategy, it does not track whether those offers have been partially filled, fully consumed, or cancelled. Untracked open offers accumulate on accounts and can cause unexpected balance changes that confuse invoice reconciliation. An offer tracker should monitor outstanding offers, emit fill-progress events, and cancel stale offers automatically.
Technical Context
Add src/offerTracker.ts. Uses @stellar/stellar-sdk Server.offers() with for_account filter, and Server.trades() to detect fills. Operations built with Operation.manageBuyOffer() / Operation.manageSellOffer(). Emits offerFilled, offerPartiallyFilled, and offerCancelled events via src/events.ts. Adds OfferRecord to src/types.ts.
Acceptance Criteria
Description
When the SDK places DEX offers as part of a split payment conversion strategy, it does not track whether those offers have been partially filled, fully consumed, or cancelled. Untracked open offers accumulate on accounts and can cause unexpected balance changes that confuse invoice reconciliation. An offer tracker should monitor outstanding offers, emit fill-progress events, and cancel stale offers automatically.
Technical Context
Add
src/offerTracker.ts. Uses@stellar/stellar-sdkServer.offers()withfor_accountfilter, andServer.trades()to detect fills. Operations built withOperation.manageBuyOffer()/Operation.manageSellOffer(). EmitsofferFilled,offerPartiallyFilled, andofferCancelledevents viasrc/events.ts. AddsOfferRecordtosrc/types.ts.Acceptance Criteria
OfferTracker.track(offerId: string, accountId: string)registers an offer for monitoringServer.trades()at a configurable interval and computes cumulative fill percentageofferPartiallyFilledwith{ filledPercent, remaining }payload andofferFilledon 100% completionmanageSellOfferwith amount 0) for offers older than a configurable TTLlistActive(accountId: string): Promise<OfferRecord[]>returns all currently tracked open offers for an account