feat: implement batch payout refund on partial execution failure - #871
Merged
ONEONUORA merged 1 commit intoAug 29, 2026
Merged
Conversation
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
|
@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! 🚀 |
Contributor
|
@benedictworks-home |
ONEONUORA
approved these changes
Aug 29, 2026
ONEONUORA
left a comment
Contributor
There was a problem hiding this comment.
Great job @benedictworks-home
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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