Skip to content

Configurable rounding strategy for the token minting process #4065

@Neurone

Description

@Neurone

Problem description

When the number of FT/NFTs to be minted has decimal parts (due to complex calculation based on project values), the rounding seems to use a nearest integer rounding strategy (round down up to 0.5, round up over 0.5).

This may not necessarily be what the policy developers want to implement.

Requirements

Developers can choose the rounding behavior for the token minting process when defining the policy.

The rounding option can be set to:

  • nearest (default): round up to the nearest integer, with up to 0.5 (excluded) rounded down to 0. Examples: 0.3 -> 0, 0.49 -> 0, 0.5 -> 1
  • floor: Round down to integer only, decimal part is stripped. Examples: 0.3 -> 0, 0.9 -> 0
  • ceiling: Round up to the next integer value. Examples: 0.3 -> 1, 0.9 -> 1

The rounding behaviors apply only to positive numbers. Negative numbers are always considered invalid.

Definition of done

Policy developers have the option of configuring the rounding behavior in the mintDocumentBlock block.
The mintDocumentBlock will always follow the selected rounding option and apply nearest strategy by default if no selection is present.

Acceptance criteria

The mintDocumentBlock will follow the selected rounding option.

Metadata

Metadata

Assignees

No one assigned
    No fields configured for Feature.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions