Skip to content

feat: implement batch payout refund on partial execution failure - #871

Merged
ONEONUORA merged 1 commit into
Fracverse:masterfrom
benedictworks-home:feat/batch-payout-refund
Aug 29, 2026
Merged

feat: implement batch payout refund on partial execution failure#871
ONEONUORA merged 1 commit into
Fracverse:masterfrom
benedictworks-home:feat/batch-payout-refund

Conversation

@benedictworks-home

Copy link
Copy Markdown
Contributor

Problem

When batch_payout encounters a transfer that would fail due to insufficient balance, the entire batch reverts. This blocks payouts to all other valid recipients and wastes the sender's fee.

Solution
Skip failed transfers and continue processing the rest of the batch. Refund skipped amounts to the sender and emit an event for off-chain reconciliation.

Changes
contracts/contracts/social_payment/src/lib.rs

Deferred fee: Fee reserved upfront but recalculated on successful_volume only after all transfers complete.
Predictive skip: Each transfer checks remaining_balance >= payout.amount before executing. Insufficient balance → skip and track as skipped_volume.
BatchPayoutRefunded event: Emitted with (sender, skipped_volume) when any transfers are skipped.
MassPayoutExecuted event: Always emitted with actual fee_charged based on successful volume.
Fixed pre-existing bug: Added missing use soroban_sdk::xdr::ToXdr; import.
Behavior Change
Previously, batch_payout was atomic — if any transfer failed, all reverted. Now, failed transfers are skipped and the rest proceed. Clients should listen for BatchPayoutRefunded events to detect partial failures.

Tests
test_batch_payout_defers_fee_to_successful_volume
test_batch_payout_minimum_fee_applied
All 33 tests pass.

Closes #774

When individual transfers in batch_payout fail due to insufficient balance,
skip failed transfers instead of reverting the whole batch.

- Fee is deferred and charged on successful volume only
- BatchPayoutRefunded event emitted for off-chain reconciliation
- Fixed pre-existing to_xdr import bug
- Added tests for fee deferral and minimum fee
@drips-wave

drips-wave Bot commented Aug 29, 2026

Copy link
Copy Markdown

@benedictworks-home 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

@ONEONUORA

Copy link
Copy Markdown
Contributor

@benedictworks-home
PLs make your implementation to pass CI checks

@ONEONUORA ONEONUORA left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ONEONUORA
ONEONUORA merged commit f4cfc1a into Fracverse:master Aug 29, 2026
8 of 11 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

Development

Successfully merging this pull request may close these issues.

smart contract: Implement batch payout refund on partial execution failure

2 participants