Skip to content

Push proceeds to users in FinalizeSettle#62

Open
fedgiac wants to merge 46 commits into
mainfrom
push-funds-to-user-processing-in-finalize-settle
Open

Push proceeds to users in FinalizeSettle#62
fedgiac wants to merge 46 commits into
mainfrom
push-funds-to-user-processing-in-finalize-settle

Conversation

@fedgiac

@fedgiac fedgiac commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Push each order's proceeds out of the buffers in FinalizeSettle.

This is the final part of the settlement push flow. The previous PR taught BeginSettle to pair each settled order with exactly one push and check the push pays the order's buy token account, but nothing moved yet. Here FinalizeSettle actually performs the transfers.

What push_funds does

BeginSettle already guarantees, for the paired finalize, that the push count matches the order count and that each push's destination is the right buy token account, and the counterpart check guarantees that begin ran.
So the only things left for FinalizeSettle to check is that:

  • each push draws from the canonical buffer for its destination's mint;
  • the buy token is a valid token account.

And naturally, it needs to actually send funds.

How to test

finalize_settle_pushes.rs moves from asserting that pushes merely parse to asserting they actually pay: single-order, several orders sharing one buffer, and several orders drawing from different buffers, each checking both the destinations' credited balances and the buffers' debited balances. It also covers new edge cases.

@fedgiac
fedgiac requested a review from a team as a code owner July 6, 2026 21:29
@fedgiac fedgiac mentioned this pull request Jul 6, 2026
Comment thread programs/settlement/src/settle/finalize.rs Outdated
Comment thread programs/settlement/src/settle/finalize.rs Outdated
Comment thread programs/settlement/tests/finalize_settle_pushes.rs
Comment thread programs/settlement/tests/finalize_settle_pushes.rs Outdated
Comment thread programs/settlement/tests/finalize_settle_pushes.rs
Comment thread programs/settlement/tests/finalize_settle_pushes.rs
Comment thread programs/settlement/tests/finalize_settle_pushes.rs
Comment thread programs/settlement/tests/finalize_settle_pushes.rs Outdated
Comment thread programs/settlement/tests/finalize_settle_pushes.rs Outdated
kaze-cow and others added 23 commits July 14, 2026 17:36
…h-funds-to-user-processing-in-finalize-settle
…h-funds-to-user-processing-in-finalize-settle
Base automatically changed from push-funds-to-user-processing-in-begin-settle to main July 15, 2026 15:06
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.

2 participants