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.
| 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. |
-
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.
-
creator-keys/src/lib.rs[MODIFY]- Updated
validate_fee_bpsandassert_valid_fee_bpsto validate non-zero basis point totals bounded byBPS_MAX(10000). - Updated
compute_fee_splitandchecked_compute_fee_splitto compute independent fee basis points when the sum ofcreator_bpsandprotocol_bpsis less than 10,000, while maintaining full remainder conservation when BPS sum equals 10,000.
- Updated
-
creator-keys/tests/fee_split.rs[MODIFY]- Updated
test_set_fee_config_invalid_sum_failsto test total BPS exceeding 10,000 BPS limit.
- Updated
- Run test target:
cargo test --test buy_fee_split_treasury_and_creator - Run full test suite:
cargo test