Skip to content

Issue 170: optimization: Pack multiple state booleans into a single u64 bitmask #107

@AlAfiz

Description

@AlAfiz

Description

Storing multiple boolean flags (like is_paused, is_deprecated, flash_loans_active) as separate entries in Soroban's instance storage is highly inefficient.
Every individual storage key costs network rent. We can drastically reduce our storage footprint by packing all protocol configuration flags into a single u64 bitmask.
This means we only pay rent for one variable, but we can track up to 64 different true/false states.
It demonstrates an elite level of smart contract optimization to the hackathon judges.

Requirements

  • Replace the individual boolean state variables with a single protocol_flags: u64 variable.
  • Define bitwise constants (e.g., PAUSED_FLAG = 1 << 0, DEPRECATED_FLAG = 1 << 1).
  • Create an internal helper set_flag(flag, value) that uses bitwise OR/AND to flip the specific bit without altering the others.
  • Create a has_flag(flag) read-only helper to check states during the swap execution flow.

Metadata

Metadata

Assignees

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