Skip to content

feat(pswap): add min_fill_amount to PswapNoteStorage#3235

Open
Sertug17 wants to merge 1 commit into
0xMiden:nextfrom
Sertug17:feat/pswap-min-fill-amount
Open

feat(pswap): add min_fill_amount to PswapNoteStorage#3235
Sertug17 wants to merge 1 commit into
0xMiden:nextfrom
Sertug17:feat/pswap-min-fill-amount

Conversation

@Sertug17

@Sertug17 Sertug17 commented Jul 7, 2026

Copy link
Copy Markdown

Summary

Adds an optional min_fill_amount field to PswapNoteStorage, allowing PSWAP note creators to set a minimum fill threshold. This prevents griefing via tiny partial fills that produce dust P2ID payback notes.

Changes

  • Added min_fill_amount: Option to PswapNoteStorage with bon::Builder support
  • Fixed creator_account_id serialization order from [prefix, suffix] to [suffix, prefix]
  • Updated From/TryFrom implementations for the new 7-element storage layout
  • Added min_fill_amount check in MASM execute_pswap with ERR_PSWAP_FILL_BELOW_MINIMUM error
  • Updated NUM_STORAGE_ITEMS from 6 to 7 in MASM
  • Added tests for roundtrip serialization with the new field

Storage Layout

Slot Field
[0] Requested asset faucet ID suffix
[1] Requested asset faucet ID prefix
[2] Requested asset amount
[3] Payback note type
[4-5] Creator account ID (suffix, prefix)
[6] min_fill_amount (0 = None)

Related Issues

Checklist

  • cargo check -p miden-standards passes
  • cargo test -p miden-standards pswap passes (8/8 tests)
  • MASM side implementation (follow-up PR)

Notes

The MASM pswap.masm script now includes the min_fill_amount check in execute_pswap. If fill_amount < min_fill_amount (and min_fill_amount != 0), the transaction aborts with ERR_PSWAP_FILL_BELOW_MINIMUM.

@Sertug17 Sertug17 force-pushed the feat/pswap-min-fill-amount branch 2 times, most recently from c8405c8 to 489cc4b Compare July 7, 2026 17:41
- Add optional min_fill_amount: Option<u64> field to PswapNoteStorage
- Increase NUM_STORAGE_ITEMS from 7 to 8
- Fix creator_account_id serialization order ([prefix, suffix] → [suffix, prefix])
- Update From/TryFrom implementations for 8-element storage layout
- Add tests for new storage roundtrip

Fixes 0xMiden#3203
Related: 0xMiden#3169
@Sertug17 Sertug17 force-pushed the feat/pswap-min-fill-amount branch from 489cc4b to dcc1ad3 Compare July 7, 2026 17:50
@Sertug17

Sertug17 commented Jul 7, 2026

Copy link
Copy Markdown
Author

@VAIBHAVJINDAL3012 @partylikeits1983 @PhilippGackstatter

This PR is now ready for review. It includes both the Rust and MASM implementations discussed in #3203:

Rust side:

  • min_fill_amount: Option<u64> added to PswapNoteStorage
  • Creator ID serialization order fixed ([prefix, suffix] → [suffix, prefix])
  • From/TryFrom updated for 7-element storage layout
  • Tests added

MASM side:

  • NUM_STORAGE_ITEMS updated from 6 → 7
  • min_fill_amount check in execute_pswap with ERR_PSWAP_FILL_BELOW_MINIMUM
  • Creator ID order fixed in MASM as well

All 8 pswap tests pass. Let me know if you'd like any changes!

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.

PSwap: User should be able to set minimum amount that can be filled in a note.

1 participant