Skip to content

hylo-quotes refactor - add SimulatedOperation, remove SimulatePrice#35

Merged
hylevi merged 29 commits intomainfrom
fix/hylo-quotes-publish
Jan 29, 2026
Merged

hylo-quotes refactor - add SimulatedOperation, remove SimulatePrice#35
hylevi merged 29 commits intomainfrom
fix/hylo-quotes-publish

Conversation

@0xPlish
Copy link
Contributor

@0xPlish 0xPlish commented Jan 21, 2026

  • Add publish details to hylo-quotes
  • Drop SimulatePrice. Move protocol_state and token_operation hylo-quotes.
  • Update CLAUDE.md
  • Fix lint

Closes #30
Closes #37

CLAUDE.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be quote

noting that the rename is a breaking change too. i don't think any 3rd parties were calling compute_quote so should be fine overall.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this should be quote, but I'm also generally struggling with naming things in this crate. We can def cut a major version and fix the nomenclature.

I believe this specific method is on TokenOperation but the extension calls it quote

Comment on lines +49 to +51
let in_amount: UFix64<N6> = event.redeemed.try_into()?;
let out_amount: UFix64<N9> = event.collateral_withdrawn.try_into()?;
let fee_amount: UFix64<N9> = event.fees_deposited.try_into()?;
Copy link
Contributor

@hylevi hylevi Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I review blocks like these, I'm noticing they require a fair amount of "tribal knowledge" & it feels error prone.

Now that we have Exp on the system, I think we should consider doing something like this:

let in_amount: UFix64<HYUSD::Exp> = event.redeemed.try_into()?;
let out_amount: UFix64<L::Exp> = event.collateral_withdrawn.try_into()?;

For the generic SimulatedOperation<IN, OUT> implementations, this would be:

let in_amount: UFix64<IN::Exp> = ...;let out_amount: UFix64<OUT::Exp> = ...;

It doesn't prevent you from using IN::Exp when you meant OUT::Exp, but it's much harder to make that mistake when the pattern is consistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically, it wouldn't compile if we got the numbers wrong since the OperationOutput type is parametrized by input, fee, and output exponents. But agreed can be more consistent with usage.

Ok(Quote {
amount_in,
amount_out: op.out_amount.bits,
compute_units: DEFAULT_CUS_WITH_BUFFER * 3,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

noticed this earlier, but forgot to comment. * 3 has magic number vibes.

would probably be better to add a new constant for this tx

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted that's easy

  Addresses nomenclature issues in hylo-quotes where "quote" was overloaded.

  Struct changes:
  - Quote → ExecutableQuote<InExp, OutExp, FeeExp> with UFix64 fields
  - Add ExecutableQuoteValue with UFixValue64 for runtime dispatch

  Method renames to clarify "output" vs "quote":
  - compute_quote() → compute_output()
  - quote::<IN, OUT>() → output::<IN, OUT>()
  - quote_from_event() → extract_output()
  - simulate_quote() → simulate_output()

  Trait updates:
  - QuoteStrategy gains FeeExp associated type, returns typed ExecutableQuote
  - RuntimeQuoteStrategy returns ExecutableQuoteValue (type-erased)
  Addresses nomenclature issues in hylo-quotes where "quote" was overloaded.

  Struct changes:
  - Quote → ExecutableQuote<InExp, OutExp, FeeExp> with UFix64 fields
  - Add ExecutableQuoteValue with UFixValue64 for runtime dispatch

  Method renames to clarify "output" vs "quote":
  - compute_quote() → compute_output()
  - quote::<IN, OUT>() → output::<IN, OUT>()
  - quote_from_event() → extract_output()
  - simulate_quote() → simulate_output()

  Trait updates:
  - QuoteStrategy gains FeeExp associated type, returns typed ExecutableQuote
  - RuntimeQuoteStrategy returns ExecutableQuoteValue (type-erased)
@hylevi hylevi self-requested a review January 29, 2026 14:47
@hylevi hylevi merged commit 75e319d into main Jan 29, 2026
3 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.

Finalize hylo-quotes API Improve and clean up integration tests for hylo-quotes

2 participants