Skip to content

Latest commit

 

History

History
31 lines (23 loc) · 2.32 KB

File metadata and controls

31 lines (23 loc) · 2.32 KB

Pull Request Documentation: Issue #680

Executive Summary

This PR addresses Issue #680 by implementing an integration test suite and supporting core contract logic for buy transactions that split fees between the protocol treasury and the creator's fee recipient according to configured basis points.

Issue #680 Requirements & Fulfillment

Requirement / Criterion Status Implementation Details
Configure protocol fee at 500 bps (5%) and creator fee at 200 bps (2%) ✅ PASSED Configured via client.set_fee_config(&admin, &200u32, &500u32).
Execute buy transaction & record XLM balance changes ✅ PASSED Executed buy transaction with exact total payment and tracked get_treasury_balance() and get_creator_fee_balance() balance deltas.
Treasury receives exactly 5% of gross cost ✅ PASSED Asserted treasury_delta == gross_cost * 500 / 10000.
Creator recipient receives exactly 2% of gross cost ✅ PASSED Asserted creator_delta == gross_cost * 200 / 10000.
Buyer charged gross cost plus both fees ✅ PASSED Asserted buyer_charge == gross_cost + protocol_fee + creator_fee.
No stroop rounding error — sum of credits equals total buyer charge ✅ PASSED Verified gross_cost + treasury_delta + creator_delta == buyer_charge with zero stroop discrepancy.

Files Modified & Created

  1. creator-keys/tests/buy_fee_split_treasury_and_creator.rs [NEW]

    • Integration tests covering 500 bps (5%) protocol fee and 200 bps (2%) creator fee splitting on buy, balance accumulation across multiple buyers, and zero stroop rounding error tests.
  2. creator-keys/src/lib.rs [MODIFY]

    • Updated validate_fee_bps and assert_valid_fee_bps to validate non-zero basis point totals bounded by BPS_MAX (10000).
    • Updated compute_fee_split and checked_compute_fee_split to compute independent fee basis points when the sum of creator_bps and protocol_bps is less than 10,000, while maintaining full remainder conservation when BPS sum equals 10,000.
  3. creator-keys/tests/fee_split.rs [MODIFY]

    • Updated test_set_fee_config_invalid_sum_fails to test total BPS exceeding 10,000 BPS limit.

Verification

  • Run test target: cargo test --test buy_fee_split_treasury_and_creator
  • Run full test suite: cargo test