fix: handle neg_risk market in sellPosition#58
Open
WrBug wants to merge 1 commit into
Open
Conversation
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.
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.
Summary
Fixes #38 - 无法卖出仓位
The
sellPositionmethod inAccountServicewas 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
marketService.getNegRiskByConditionId()and passes the correctexchangeContracttoorderSigningService.createAndSignOrder()Testing
MarketService.getNegRiskByConditionId()is already available and used in other parts ofAccountService(redeem flow)OrderSigningService.createAndSignOrder()already accepts an optionalexchangeContractparameterCopyOrderTrackingServicelines 568-570Fixes #38