Skip to content

validate_limit_order_params: off-by-one between GTD expiration check and error message #44

@Nexory

Description

@Nexory

In src/polymarket/_internal/actions/orders/limit.py:66-70, the GTD expiration check uses <= against now + 60:

minimum = int(time.time()) + _MIN_EXPIRATION_BUFFER_S  # = now + 60
if expiration <= minimum:
    raise UserInputError(
        f"expiration must be at least {_MIN_EXPIRATION_BUFFER_S} seconds in the future."
    )

The condition rejects expiration == now + 60, so the actual required value is expiration > now + 60 (strictly more than 60 seconds). The error message says "at least 60 seconds in the future", which suggests expiration >= now + 60 is acceptable.

A user passing expiration = int(time.time()) + 60 (literally matching the documented contract) hits a UserInputError.

Suggested fix

Either tighten the comparison to < (accept the boundary value):

if expiration < minimum:

or update the message to "more than 60 seconds in the future". Aligning the condition with the documented contract is probably preferable.

Happy to send a small PR.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions