Skip to content

fix: handle neg_risk market in sellPosition#58

Open
WrBug wants to merge 1 commit into
mainfrom
fix/issue-38
Open

fix: handle neg_risk market in sellPosition#58
WrBug wants to merge 1 commit into
mainfrom
fix/issue-38

Conversation

@WrBug

@WrBug WrBug commented Apr 29, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes #38 - 无法卖出仓位

The sellPosition method in AccountService was not checking whether the market uses the Neg Risk Exchange contract. For neg_risk markets, the order must be signed with the Neg Risk Exchange address (0xe2222d279d744050d28e00520010520000310F59) instead of the standard CTF Exchange (0xE111180000d2663C0091e4f400237545B87B996B). Otherwise, Polymarket rejects the order.

The copy trading service (CopyOrderTrackingService) already handles this correctly, but the manual sell position flow was missing this check.

Changes

  • AccountService.sellPosition: Added neg_risk detection via marketService.getNegRiskByConditionId() and passes the correct exchangeContract to orderSigningService.createAndSignOrder()

Testing

  • Verified that MarketService.getNegRiskByConditionId() is already available and used in other parts of AccountService (redeem flow)
  • Verified that OrderSigningService.createAndSignOrder() already accepts an optional exchangeContract parameter
  • Followed the same pattern used in CopyOrderTrackingService lines 568-570

Fixes #38

Fixes #38

The sellPosition method was not checking if the market uses Neg Risk
Exchange contract. For neg_risk markets, the order signing must use the
Neg Risk Exchange address, otherwise the order will be rejected by
Polymarket.

The copy trading service already handles this correctly, but the manual
sell position flow was missing this check.
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