hylo-quotes refactor - add SimulatedOperation, remove SimulatePrice#35
hylo-quotes refactor - add SimulatedOperation, remove SimulatePrice#35
Conversation
CLAUDE.md
Outdated
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
| 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()?; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
noticed this earlier, but forgot to comment. * 3 has magic number vibes.
would probably be better to add a new constant for this tx
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)
Closes #30
Closes #37