Skip to content

feat: resolve issues #195, #197, #203, #205 (Xhristin3)#243

Merged
elizabetheonoja-art merged 2 commits into
Utility-Drip:mainfrom
Xhristin3:feature/xhristin3-issues-195-197-203-205
Apr 26, 2026
Merged

feat: resolve issues #195, #197, #203, #205 (Xhristin3)#243
elizabetheonoja-art merged 2 commits into
Utility-Drip:mainfrom
Xhristin3:feature/xhristin3-issues-195-197-203-205

Conversation

@Xhristin3
Copy link
Copy Markdown
Contributor

Summary

Resolves all 4 issues assigned to @Xhristin3 in a single PR.


Issue #195 — Create Minimum Yield-Routing Gas Thresholds

  • Added DEFAULT_MIN_ROUTE_THRESHOLD constant (10,000,000 stroops = 1 XLM)
  • Added DataKey::MinRouteThreshold for DAO governance updates
  • Added set_min_route_threshold(), get_min_route_threshold(), route_to_yield()
  • route_to_yield() panics with BelowMinRouteThreshold if capital is below threshold, protecting the protocol from gas-negative micro-deposits

Issue #197 — Develop Treasury "Streaming-Fee" Collector

  • Added DataKey::PlatformFeeBps, ProtocolFeeVault, StreamingFeeAccrued(u64)
  • Added MAX_PLATFORM_FEE_BPS constant (1000 bps = 10% ceiling)
  • Platform fee deducted inside update_continuous_flow(): fee = floor(gross * bps / 10000) — truncation never favors the attacker
  • Added set_platform_fee_bps(), set_protocol_fee_vault(), collect_streaming_fees()
  • Vault address is admin-controlled (DAO multi-sig compatible)

Issue #203 — Formal Verification of Streaming Invariant

New file: src/streaming_invariant_tests.rs

Proves Total_Deposited == Total_Streamed + Total_Remaining + Fees across:

  • Zero-fee full depletion
  • Non-zero fee partial stream
  • 8 edge-case inputs (zero deposit, max values, non-divisible amounts, over-depletion)
  • 1,000,000-tick simulation
  • Contract-level tests with and without platform fee

Issue #205 — Fuzz Test: 1-Stroop Micro-Deductions

New file: src/stroop_fuzz_tests.rs

Covers all 3 acceptance criteria:

  • AC-1: Truncation never favors attacker — fee + net == gross for all inputs
  • AC-2: Fractional remains go to dust sweeper — verified via is_dust_amount and update_dust_aggregation
  • AC-3: 10,000-tick high-frequency simulation with 1-stroop/sec rate, no panics, no negative balances, correct depletion

Pre-existing bugs also fixed

The lib.rs had several structural issues that prevented compilation:

  • disable_privacy_mode missing closing brace
  • Broken duplicate create_continuous_stream / withdraw_continuous function bodies
  • Duplicate get_meter_or_panic, pause_stream, resume_stream definitions
  • Broken allocate_to_maintenance_fund body
  • Incomplete apply_provider_withdrawal_limit stub
  • Duplicate UsageReport / SignedUsageData struct definitions

Closes #195
Closes #197
Closes #203
Closes #205

…#203, Utility-Drip#205 (Xhristin3)

Issue Utility-Drip#195 - Minimum Yield-Routing Gas Thresholds:
- Add DEFAULT_MIN_ROUTE_THRESHOLD constant (10_000_000 stroops / 1 XLM)
- Add DataKey::MinRouteThreshold for DAO-updatable governance
- Add set_min_route_threshold(), get_min_route_threshold(), route_to_yield()
- route_to_yield() panics with BelowMinRouteThreshold if amount < threshold

Issue Utility-Drip#197 - Treasury Streaming-Fee Collector:
- Add DataKey::PlatformFeeBps, ProtocolFeeVault, StreamingFeeAccrued(u64)
- Add MAX_PLATFORM_FEE_BPS constant (1000 bps = 10%)
- Deduct platform fee from gross flow accumulation in update_continuous_flow()
- Fee = floor(accumulation * bps / 10000) — truncation never favors attacker
- Add set_platform_fee_bps(), set_protocol_fee_vault(), collect_streaming_fees()
- Add get_platform_fee_bps(), get_accrued_streaming_fees()

Issue Utility-Drip#203 - Formal Verification of Streaming Invariant:
- Add streaming_invariant_tests.rs proving Total_Deposited == Total_Streamed + Total_Remaining + Fees
- Tests cover: zero-fee, with-fee, edge cases, 1M-tick simulation, contract-level

Issue Utility-Drip#205 - Fuzz Test: 1-Stroop Micro-Deductions:
- Add stroop_fuzz_tests.rs with AC-1/AC-2/AC-3 acceptance criteria
- Proves truncation never favors attacker, fractional remains go to dust sweeper
- High-frequency 10k-tick simulation with 1-stroop/sec rate

Also fix pre-existing structural bugs in lib.rs:
- disable_privacy_mode missing closing brace
- Broken duplicate create_continuous_stream / withdraw_continuous bodies
- Duplicate get_meter_or_panic, pause_stream, resume_stream definitions
- Broken allocate_to_maintenance_fund body
- Incomplete apply_provider_withdrawal_limit stub
- Duplicate UsageReport / SignedUsageData struct definitions

Closes Utility-Drip#195, Utility-Drip#197, Utility-Drip#203, Utility-Drip#205
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 26, 2026

@Xhristin3 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@elizabetheonoja-art elizabetheonoja-art merged commit fa0a7f8 into Utility-Drip:main Apr 26, 2026
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants