Skip to content

DEX Offer Order Tracker #501

Description

@Kingsman-99

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

  • OfferTracker.track(offerId: string, accountId: string) registers an offer for monitoring
  • Polls Server.trades() at a configurable interval and computes cumulative fill percentage
  • Emits offerPartiallyFilled with { filledPercent, remaining } payload and offerFilled on 100% completion
  • Automatically submits a cancel (manageSellOffer with amount 0) for offers older than a configurable TTL
  • listActive(accountId: string): Promise<OfferRecord[]> returns all currently tracked open offers for an account
  • All CI checks (npm test, npm run build, ESLint/TypeScript) pass and the branch has no merge conflicts

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions