Skip to content

Conditional numberInString. Allow passing number | string to order endpoints #226

Description

@felds

Currently, the values in NewSpotOrderParams only accept numbers. Since all numbers in JS are floats, this leads to some numbers having recurring decimals when converting to base 10, tripping the filter "Precision is over the maximum defined for this asset." even after normalizing the number (with Math.floor(qty / precision) * precision).

Allowing passing numberInString or simply string (as numberInString | number) would allow the user to trim the passed value with Number.toFixed.

eg:

const qty = 10/3; //  => 3.3333333333333335
const precision = 0.0001;
const normalized = Math.floor(qty / precision) * precision; //  => 3.3333000000000004 (rejected)
const trimmed = normalized.toFixed(4) //  => "3.3333" (accepted)

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