Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions intent_settlement/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,13 +437,15 @@ pub struct IntentRecord {

/// Destination (always Stellar)
pub dst_token: Address, // SAC/SEP-41 token on Stellar
pub min_dst_amount: i128, // minimum acceptable output per fill (floor per partial)
pub min_dst_amount: i128, // minimum acceptable output per fill (#348: per src_portion)

pub solver: Option<Address>, // assigned solver
pub state: IntentState,

pub created_at: u64,
pub deadline: u64,
/// #347: user's original deadline; separate from fill-window deadline which gets reset
pub user_deadline: u64,
pub deadline: u64, // effective deadline (fill window or user deadline)
pub filled_at: Option<u64>,
pub fill_amount: Option<i128>, // cumulative dst tokens received across all fills

Expand Down Expand Up @@ -2163,10 +2165,11 @@ impl IntentSettlement {
/// Solver fills the intent by sending dst_token to the user.
///
/// Partial fills are supported: `fill_amount` must be > 0 but may be less
/// than `min_dst_amount`. The intent transitions to `PartiallyFilled` after
/// than `min_dst_amount * src_portion / src_amount`. The intent transitions to `PartiallyFilled` after
/// each sub-fill and is re-opened so another solver (or the same one) can
/// accept and deliver the remainder. Once the cumulative `total_filled`
/// reaches or exceeds `min_dst_amount` the intent transitions to `Filled`.
/// reaches or exceeds `min_dst_amount * src_amount / src_amount` (when src_filled == src_amount),
/// the intent transitions to `Filled`.
///
/// The protocol fee is taken on each individual fill so the fee accounting
/// stays consistent regardless of how many fills it takes.
Expand Down
3 changes: 3 additions & 0 deletions intent_settlement/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2212,6 +2212,7 @@ fn two_partial_fills_complete_intent() {

// First partial fill: half of MIN_DST.
let half = MIN_DST / 2;
let half_src = SRC_AMT / 2;
let fee1 = half * 5 / 10_000;
ctx.dst_admin().mint(&ctx.solver, &(half + fee1));
c.accept_intent(&ctx.solver, &id);
Expand All @@ -2228,6 +2229,7 @@ fn two_partial_fills_complete_intent() {

// Second fill: the remainder — brings total to MIN_DST.
let remainder = MIN_DST - half;
let remainder_src = SRC_AMT - half_src;
let fee2 = remainder * 5 / 10_000;
ctx.dst_admin().mint(&ctx.solver, &(remainder + fee2));
c.accept_intent(&ctx.solver, &id);
Expand Down Expand Up @@ -2257,6 +2259,7 @@ fn partial_fill_left_incomplete_past_deadline_can_be_expired() {

// Deliver a partial fill (less than MIN_DST).
let partial = MIN_DST / 3;
let partial_src = SRC_AMT / 3;
let fee = partial * 5 / 10_000;
ctx.dst_admin().mint(&ctx.solver, &(partial + fee));
c.accept_intent(&ctx.solver, &id);
Expand Down
Loading