guardian icon indicating copy to clipboard operation
guardian copied to clipboard

Configurable rounding strategy for the token minting process

Open Neurone opened this issue 1 year ago • 0 comments

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 .5 rounded down to 0. Examples: 0.3 -> 0, 0.5 -> 0, 0.51 -> 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.

Neurone avatar Aug 21 '24 17:08 Neurone