Draft
Conversation
| /// - Note can be partially or fully filled by consumers | ||
| /// - Unfilled portions create remainder notes | ||
| /// - Creator receives requested assets via P2ID notes | ||
| pub struct PswapNote; |
Contributor
There was a problem hiding this comment.
Since we're adding this as a completely new note, it would be great if we could immediately set it up with the structure we want to end up with, i.e. the one described in #2283.
So roughly:
pub struct PswapNoteStorage {
requested_key: Word,
requested_value: Word,
swapp_tag: NoteTag,
p2id_tag: NoteTag,
swap_count: u64,
creator_account_id: AccountId,
}
impl PswapNoteStorage {
pub fn into_recipient(self, serial_num: Word) -> NoteRecipient {
todo!()
}
}
impl From<PswapNoteStorage> for NoteStorage {
fn from(pswap_storage: PswapNoteStorage) -> Self {
todo!()
}
}
#[derive(Debug, Clone, bon::Builder)]
#[builder(finish_fn(vis = "", name = build_internal))]
pub struct PswapNote {
sender: AccountId,
storage: PswapNoteStorage,
serial_number: Word,
#[builder(default = NoteType::Private)]
note_type: NoteType,
#[builder(default)]
assets: NoteAssets,
#[builder(default)]
attachment: NoteAttachment,
}
impl PswapNote {
pub fn execute(
&self,
consumer_account_id: AccountId,
input_amount: u64,
inflight_amount: u64,
) -> Result<(Note, Option<PswapNote>), NoteError> {
todo!("what create_output_notes does now")
}
}This would result in a more natural API, i.e. execute takes &self instead of create_output_notes taking an arbitrary &Note.
What do you think?
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.
Add PSWAP (partially-fillable swap) note to miden-standards — a new note script that enables partial
fills, creator reclaim, and inflight cross-swaps for decentralized asset exchange
1e5 precision factor, and an early-return optimization for full fills to avoid integer truncation
remainder), storage parsing, and calculate_offered_for_requested convenience method
reclaim, invalid input rejection, multiple fill amounts, non-exact ratios, fuzz cases, and chained
partial fills
Test plan
calculation, storage parsing)
reclaim, fuzz, chained fills)