-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Liquidity pools: Add UTs to for update_token_price()
#1890
base: main
Are you sure you want to change the base?
Conversation
/// A trait that can be used to retrieve the current price for a currency | ||
pub struct CurrencyPair<CurrencyId> { | ||
pub base: CurrencyId, | ||
pub quote: CurrencyId, | ||
} | ||
|
||
pub struct PriceValue<CurrencyId, Rate, Moment> { | ||
pub pair: CurrencyPair<CurrencyId>, | ||
pub price: Rate, | ||
pub last_updated: Moment, | ||
} | ||
|
||
pub trait CurrencyPrice<CurrencyId> { | ||
type Rate; | ||
type Moment; | ||
|
||
/// Retrieve the latest price of `base` currency, denominated in the `quote` | ||
/// currency If `quote` currency is not passed, then the default `quote` | ||
/// currency is used (when possible) | ||
fn get_latest( | ||
base: CurrencyId, | ||
quote: Option<CurrencyId>, | ||
) -> Option<PriceValue<CurrencyId, Self::Rate, Self::Moment>>; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not used, but if it's intended to be used very soon, I can revert this. Otherwise, I would left removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1890 +/- ##
==========================================
+ Coverage 47.38% 47.49% +0.11%
==========================================
Files 176 176
Lines 13305 13304 -1
==========================================
+ Hits 6304 6319 +15
+ Misses 7001 6985 -16 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not merge until hieronx answered. I also would like to close the conversion in the same run too
let price = prices.get(tranche_index).cloned()?; | ||
|
||
Some(PriceValue { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hieronx you added this change. Why did you wanted to have the TrancheCurrency
and the PoolCurrency
named here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't fully remember. I think we just set up the PriceValue
for some other purpose, and then used that here.
@@ -426,7 +426,7 @@ pub mod pallet { | |||
// TODO(future): Once we diverge from 1-to-1 conversions for foreign and pool | |||
// currencies, this price must be first converted into the currency_id and then | |||
// re-denominated to 18 decimals (i.e. `Ratio` precision) | |||
let price_value = T::TrancheTokenPrice::get(pool_id, tranche_id) | |||
let (price, computed_at) = T::TrancheTokenPrice::get_price(pool_id, tranche_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lemunozm can we in the same run also close this todo and computed the conversion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if it's super straightforward. Do we need to add the order-book dependency to know the market price used for foreign/pool currencies?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree it isn't. But we are not only touching the UTs here but also chaning the return types, naming etc. Then we could also close the todo IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done here: 15424a8 @mustermeiszer
Description
UTs for
update_token_price()
NOTE: It's not directly related to LPv2
Changes and Descriptions