A quotation over a single currency holds a high price nothing reads #52

Closed
opened 2026-08-19 14:50:37 +00:00 by rosa · 0 comments
Owner

What to build

A currency priced against itself prices one direction, and holds one price for
it. two_way and flat refuse a pair whose base and quote are the same
currency, and identity prices one direction. No quotation over a single
currency holds a high price.

Today such a quotation builds and keeps a high price nothing reads. convert
tests the base currency first, so when both sides are the same the low price
answers and the high one is never reached. USD/USD 0.9/1.0 converts 100 USD to
90 USD, and the 1.0 is inert. The type docs say both prices apply to the one
direction, which is not what happens.

The domain agrees. A spread is what a quotation keeps on a round trip, and there
is no round trip over a single currency, so a low price and a high one have
nothing to be. A one-way quotation over a single currency stays: that is a
haircut on a same-currency amount, and it needs no second direction.

The shape, from a probe against the current code:

Quotation::identity(USD).high()             -> None    (today: Some(1))
Quotation::two_way((USD, USD), 0.9, 1.0)    -> Err
Quotation::flat((USD, USD), dec!(0.9))      -> Err
Quotation::one_way((USD, USD), dec!(0.99))  -> Ok      (unchanged)

Inverting a quotation over a single currency cannot reverse it: the pair is its
own reverse, so invert gives a quotation over the same pair at reciprocal
prices, turning a 0.99 haircut into a markup. That holds under any design here,
so it is documented rather than changed.

This is a breaking change. identity loses its high price and a flat quotation
over a single currency stops building, so it goes in its own !-marked commit.

Acceptance criteria

  • Quotation::two_way and Quotation::flat refuse a pair whose base and quote are the same currency, with an error that names the currency.
  • Quotation::identity prices one direction, so high() returns None.
  • Quotation::one_way still accepts a pair over a single currency, and converting at one is unchanged.
  • The type docs state what a quotation over a single currency prices, and that inverting one reprices the same direction rather than reversing it.
  • The exchange property suites assert on the pairs over a single currency they already draw, instead of passing over them.
  • An ADR recording the decision is proposed to the maintainer before it is written.

Blocked by

None — can start immediately.

## What to build A currency priced against itself prices one direction, and holds one price for it. `two_way` and `flat` refuse a pair whose base and quote are the same currency, and `identity` prices one direction. No quotation over a single currency holds a high price. Today such a quotation builds and keeps a high price nothing reads. `convert` tests the base currency first, so when both sides are the same the low price answers and the high one is never reached. `USD/USD 0.9/1.0` converts 100 USD to 90 USD, and the 1.0 is inert. The type docs say both prices apply to the one direction, which is not what happens. The domain agrees. A spread is what a quotation keeps on a round trip, and there is no round trip over a single currency, so a low price and a high one have nothing to be. A one-way quotation over a single currency stays: that is a haircut on a same-currency amount, and it needs no second direction. The shape, from a probe against the current code: ``` Quotation::identity(USD).high() -> None (today: Some(1)) Quotation::two_way((USD, USD), 0.9, 1.0) -> Err Quotation::flat((USD, USD), dec!(0.9)) -> Err Quotation::one_way((USD, USD), dec!(0.99)) -> Ok (unchanged) ``` Inverting a quotation over a single currency cannot reverse it: the pair is its own reverse, so `invert` gives a quotation over the same pair at reciprocal prices, turning a 0.99 haircut into a markup. That holds under any design here, so it is documented rather than changed. This is a breaking change. `identity` loses its high price and a flat quotation over a single currency stops building, so it goes in its own `!`-marked commit. ## Acceptance criteria - [ ] `Quotation::two_way` and `Quotation::flat` refuse a pair whose base and quote are the same currency, with an error that names the currency. - [ ] `Quotation::identity` prices one direction, so `high()` returns `None`. - [ ] `Quotation::one_way` still accepts a pair over a single currency, and converting at one is unchanged. - [ ] The type docs state what a quotation over a single currency prices, and that inverting one reprices the same direction rather than reversing it. - [ ] The exchange property suites assert on the pairs over a single currency they already draw, instead of passing over them. - [ ] An ADR recording the decision is proposed to the maintainer before it is written. ## Blocked by None — can start immediately.
rosa closed this issue 2026-08-20 20:25:39 +00:00
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
rosa/lucre#52
No description provided.