Skip to content

[Contract] Treasury Allocation Percentages (Basis Points) #361

@gabito1451

Description

@gabito1451

Independence Note: Execute solely using Rust native i128 logic matrices locally.

Context:
Guild treasuries often allocate funds to different sub-pools (e.g., 10% to community, 90% to development). Using basis points (BPS) is the standard for precision.

Objective:
Implement a utility to compute shares based on BPS.

Acceptance Criteria:

  • Define 10000 as the maximum BPS (100%).
  • Create a function calculate_share(total_amount, bps) -> i128.
  • Ensure it uses checked multiplication to avoid overflows.
  • Write unit tests for common values (e.g., 500 BPS = 5%, 1000 BPS = 10%).
  • Ensure that for a total of 100 XLM, 10 BPS correctly results in 0.1 XLM represented in stroops.

Technical Pointers:

  • BPS is preferred over percentages in finance to avoid rounding errors when dealing with small amounts.

Metadata

Metadata

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