Skip to content

Payout draft - #433

Open
elRaulito wants to merge 2 commits into
stagingfrom
payout-draft
Open

Payout draft#433
elRaulito wants to merge 2 commits into
stagingfrom
payout-draft

Conversation

@elRaulito

Copy link
Copy Markdown
Collaborator

As our last conversation with @keyan-m , this is the draft of the payout contract to fix the issues that were open about it

Please let me know once you review and any change you need to it

Raul

New file: validators/payout.ak
The payout accumulator contract with two validators:

mint — MintPayout couples to InitializePayout in withdrawal.ak (exactly 1 NFT minted, asset name = burnt withdrawal NFT). BurnPayout couples to ConcludeWithdrawal (NFT only burnable when fully funded).
spend — AddFunds collects one reserve UTxO at a time, enforces monotonic accumulation, same address in/out (prevents theft), NoDatum invariant, excess returns to reserve_addr. ConcludeWithdrawal recovers payout params from settlement Merkle tree via withdrawal_out_ref + proof (no datum needed), checks fully funded, releases exactly l2_value to l1_address.
Modified: lib/midgard/payout.ak
Removed Datum type (NoDatum design — no datum injection attack possible)
SpendRedeemer → proper sum type with all needed indices for AddFunds and ConcludeWithdrawal
MintRedeemer → proper sum type with MintPayout and BurnPayout variants
Modified: validators/user-events/withdrawal.ak
InitializePayout: replaced InlineDatum(payout.Datum { .. }) check with NoDatum — payout UTxOs start empty
Updated payout.MintRedeemer { .. } pattern to payout.MintPayout { .. } (new sum type)
Discarded unused withdrawal_body binding
Pre-existing bugs fixed (unrelated to payout):
validators/scheduler.ak — labeled args before <- continuation in one_to_one call
validators/settlement.ak (×2) — same issue
validators/operator-directory/active-operators.ak — same issue in spend_for_updating_elements_data
@elRaulito
elRaulito requested a review from keyan-m April 2, 2026 09:43
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.

1 participant