Skip to content

test(dlv): pin the SoFi §5.1 fused-rounding rule with a conformance vector - #749

Merged
cryptskii merged 1 commit into
mainfrom
test/amm-fused-rounding-conformance-vector
Aug 30, 2026
Merged

test(dlv): pin the SoFi §5.1 fused-rounding rule with a conformance vector#749
cryptskii merged 1 commit into
mainfrom
test/amm-fused-rounding-conformance-vector

Conversation

@cryptskii

Copy link
Copy Markdown
Collaborator

The spec fixes ONE floor division for the constant-product output and forbids
rounding the fee-adjusted input first. Nothing pinned that. An implementation
that floors a·(D−f)/D before the curve passes every existing test, and
silently collapses a sub-unit input to zero — taking the whole output with it.

At a=1, x=1, y=3, fee_bps=30 the two rules genuinely part company: the fused
rule yields 1, the doubly-rounded one yields 0. The vector asserts BOTH sides,
so a future edit cannot satisfy it by agreeing with the wrong rule.

It also records the boundaries where the two rules AGREE (f=0, where there is
no fee to round, and f=9999, where both yield 0). The spec's own example says
the divergence holds for "any fee_bps in the legal range", which overstates it.
Writing the agreeing cases down means a later reader cannot "fix" the vector by
widening it to match the spec's claim.

Test-only; no production behaviour changes. Split out of #748 to keep that
branch to one topic.

cargo test -p dsm --lib dlv::route_commit   1 passed / 0 failed
make lint                                   exit 0

…ector

The spec fixes ONE floor division for the constant-product output and forbids
rounding the fee-adjusted input first. Nothing pinned that: an implementation
that floors `a·(D−f)/D` before the curve passes every existing test and
silently collapses a sub-unit input to zero, taking the whole output with it.

At `a=1, x=1, y=3, fee_bps=30` the two rules part company — fused yields 1,
doubly-rounded yields 0 — and the vector asserts both sides so a future edit
cannot satisfy it by agreeing with the wrong rule.

It also records the boundaries where the rules AGREE (`f=0`, `f=9999`). The
spec's own example claims the divergence holds for "any fee_bps in the legal
range", which overstates it; writing the agreeing cases down means a later
reader cannot "fix" the vector by widening it to the spec's overstatement.

Test-only. No production behaviour changes.
@cryptskii
cryptskii force-pushed the test/amm-fused-rounding-conformance-vector branch from 1e3e929 to 298c4e5 Compare August 30, 2026 01:43
@cryptskii
cryptskii merged commit 2e2e920 into main Aug 30, 2026
15 checks passed
@cryptskii
cryptskii deleted the test/amm-fused-rounding-conformance-vector branch August 30, 2026 01:44
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.

1 participant