Skip to content

Neg Risk Resolution even when neg_risk=False argument supplied #138

@Maxim-Mazurok

Description

@Maxim-Mazurok

TLDR, the client will try to auto-resolve neg_risk if we pass neg_risk=False, but will not do that (as expected) if we pass neg_risk=True


If you check #87 - you will see a bug:

neg_risk = (
  options.neg_risk
  if options and options.neg_risk
  else self.get_neg_risk(order_args.token_id)
)

The intention of this code: if user passed neg_risk option - don't auto-resolve neg_risk and use whatever they passed in.
However, the "edge" case here is that when neg_risk is passed as False, options and options.neg_risk will evaluate to False, and so neg_risk will be auto-resolved.

This is why python code with neg_risk=False was placing orders like a champ: https://gist.github.com/Maxim-Mazurok/d2516fbc5a18741602102d6042163abd
But exactly the same nodejs code, also with neg_risk=False was giving signature error: https://gist.github.com/Maxim-Mazurok/11107d8f66cd78df2bed076f8504cccb

Now, the reason why the error message is so far from the actual reason the error was thrown, is because NegRisk contracts use different exchange, and this exchange is part of the signature:

CONFIG = {
137: ContractConfig(
exchange="0x4bFb41d5B3570DeFd03C39a9A4D8dE6Bd8B8982E",
collateral="0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
conditional_tokens="0x4D97DCd97eC945f40cF65F87097ACe5EA0476045",
),
80002: ContractConfig(
exchange="0xdFE02Eb6733538f8Ea35D585af8DE5958AD99E40",
collateral="0x9c4e1703476e875070ee25b56a58b008cfb8fa78",
conditional_tokens="0x69308FB512518e39F9b16112fA8d994F4e2Bf8bB",
),
}
NEG_RISK_CONFIG = {
137: ContractConfig(
exchange="0xC5d563A36AE78145C45a50134d48A1215220f80a",
collateral="0x2791bca1f2de4661ed88a30c99a7a9449aa84174",
conditional_tokens="0x4D97DCd97eC945f40cF65F87097ACe5EA0476045",
),
80002: ContractConfig(
exchange="0xd91E80cF2E7be2e162c6513ceD06f1dD0dA35296",
collateral="0x9c4e1703476e875070ee25b56a58b008cfb8fa78",
conditional_tokens="0x69308FB512518e39F9b16112fA8d994F4e2Bf8bB",
),
}

Only took me a few days to figure all this out :)

Based on https://discord.com/channels/710897173927297116/782024576275447848/1389927973049598022

If this was helpful - I'm accepting donations at https://polymarket.com/profile/0xFCD2fDE8e69005fb6Ef78537a2646ad030B26535 to recover lost funds from the testing :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions