Skip to content

Fix/sendtip fee minimum 242#279

Merged
Mosas2000 merged 31 commits intomainfrom
fix/sendtip-fee-minimum-242
Mar 16, 2026
Merged

Fix/sendtip fee minimum 242#279
Mosas2000 merged 31 commits intomainfrom
fix/sendtip-fee-minimum-242

Conversation

@Mosas2000
Copy link
Copy Markdown
Owner

Closes #242

The tipstream.clar contract defines (define-constant min-fee u1) which
enforces a minimum platform fee of 1 uSTX whenever fee basis points
are greater than zero. The frontend needs this constant to mirror that
rule in its fee calculations.
When fee basis points are greater than zero, the contract guarantees a
minimum fee of 1 uSTX even if the raw calculation rounds to zero. This
brings feeForTip in line with the contract calculate-fee function so
the fee preview in SendTip accurately reflects on-chain behavior.
The contract deducts max(raw-fee, 1) from the tip amount when fee basis
points are positive. recipientReceives now mirrors this so the Recipient
receives line in the fee preview matches what actually lands on-chain.
The post-condition ceiling must account for the minimum fee guarantee.
Without this, sub-threshold tips could set a ceiling that is too low,
causing the transaction to be rejected by the post-condition check.
Needed for the upcoming minimum fee enforcement tests.
Verifies feeForTip(1) returns MIN_FEE_USTX when the raw calculation
would round to less than the contract minimum.
100 * 50 / 10000 = 0.5 which ceils to 1, matching the minimum.
199 is the last amount before the raw ceil crosses above 1.
At exactly 200 uSTX, raw fee is 1.0 which ceils to 1. This is the
exact threshold where the calculated fee equals the minimum.
First amount where the raw ceil exceeds MIN_FEE_USTX.
Sweeps across multiple sub-threshold amounts to confirm the minimum
fee guarantee holds for all of them.
The minimum fee only applies when fee basis points are positive. When
the fee is disabled (bps=0) the result should always be 0.
A 10 uSTX tip should deduct 11 uSTX total (10 + 1 min fee).
A 10 uSTX tip should yield 9 uSTX to the recipient after the 1 uSTX
minimum fee is applied.
The entire tip is consumed by the minimum fee at this extreme.
No minimum fee applies when bps is zero.
Verifies the post-condition ceiling accounts for the minimum fee
even at the smallest possible tip amount.
Verify that totalDeduction = amount + feeForTip holds at the minimum
fee boundary.
No minimum fee should apply and all calculations should be consistent
with zero fee deduction.
Restoring test that was lost during linter reformatting.
Restoring the five cross-function tests that validate fee calculation
agreement across feeForTip, totalDeduction, recipientReceives, and
maxTransferForTip at the minimum fee boundary.
@Mosas2000 Mosas2000 merged commit 9347b0b into main Mar 16, 2026
4 of 8 checks passed
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.

SendTip fee breakdown does not mirror contract minimum fee enforcement

1 participant