fix(standards): price PSWAP fills against the note's initial offered asset - #3652
Merged
Conversation
…asset The PSWAP note script priced a fill against the offered asset *remaining* in the note at consumption time rather than the amount the creator funded. A consumer whose own account exposes an indexed-removal procedure could, via an earlier helper note in the same transaction, drain most of the offered asset out of the PSWAP note into their own vault before the PSWAP script ran; the single-asset assert still passed on the partially-removed slot, so the fill was priced against the residue and the creator's remainder note absorbed the loss. Bind the offered amount to the note's initial assets, which the prologue records at note creation and which removals never affect. `load_offered_asset` now fetches the note's initial assets, asserts exactly one, and asserts the single remaining offered asset equals the single initial one word-for-word (asset ID and value), aborting with the new ERR_PSWAP_OFFERED_ASSET_ALTERED otherwise. Any pre-removal from a PSWAP note thus aborts the whole transaction. Both the fill (execute_pswap) and reclaim (handle_reclaim) paths go through this procedure. This changes the compiled PSWAP note-script MAST root and therefore PSWAP note recipients/IDs. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Reduce the inline comments added with the offered-asset binding to match the surrounding file, and drop the counterfactual/pre-fix narration from the doc comments and the regression test. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
mmagician
commented
Aug 20, 2026
Co-authored-by: Marti <marcin.gorny.94@protonmail.com>
Replace the bare locaddr.0 / locaddr.8 in load_offered_asset with named OFFERED_REMAINING_ASSET_PTR / OFFERED_INITIAL_ASSET_PTR constants, matching the per-proc local-offset convention used elsewhere in the file. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
mmagician
commented
Aug 20, 2026
mmagician
marked this pull request as ready for review
August 20, 2026 20:32
mmagician
requested review from
PhilippGackstatter,
bobbinth,
partylikeits1983 and
zeapoz
August 20, 2026 20:32
zeapoz
approved these changes
Aug 21, 2026
PhilippGackstatter
approved these changes
Aug 21, 2026
Co-authored-by: zeapoz <zeapo@pm.me> Co-authored-by: Philipp Gackstatter <PhilippGackstatter@users.noreply.github.com>
…to mmagician-claude/fix-pswap-offered-amount-binding
…n PSWAP drain test
mmagician
deleted the
mmagician-claude/fix-pswap-offered-amount-binding
branch
August 21, 2026 14:02
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.
The PSWAP note script priced a fill against the offered asset remaining in the note at consumption time, not the amount the creator funded, which was exploitable as described in #3601
Fix
Bind the offered amount to the note's initial assets.