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
feat: New Lp Interfaces #4313
feat: New Lp Interfaces #4313
Conversation
0a3efde
to
06fb77c
Compare
} | ||
|
||
{ | ||
let initial_sqrt_price = match asset { | ||
common::Side::Zero => MAX_SQRT_PRICE - 1, |
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.
did we want to remove the '-1' ?
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.
yes (should have been done before in previous pr, saw I hadn't before)
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 changed the valid sqrt_prices to include the MAX_SQRT_PRICE in all cases, previously, so some of internal functions were safer to use. As a result MAX_SQRT_PRICE is a valid starting price. Where it wasn't before.
let initial_sqrt_price = match asset { | ||
Side::Zero => MAX_SQRT_PRICE - 1, | ||
let initial_sqrt_price = match order.to_sold_side() { | ||
Side::Zero => MAX_SQRT_PRICE, |
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.
same here
) | ||
); | ||
} | ||
|
||
{ | ||
let initial_sqrt_price = match asset { | ||
Side::Zero => MAX_SQRT_PRICE - 1, | ||
let initial_sqrt_price = match order.to_sold_side() { |
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.
and here
pool_state: old_pool.pool_state.into(), | ||
}) | ||
}); | ||
for (key, pool) in old::Pools::<T>::iter().filter_map(|(old_key, old_pool)| { |
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 think this should use drain
otherwise it won't remove the old pools (they will remain stored under the old key).
@@ -1894,25 +1863,37 @@ impl<T: Config> Pallet<T> { | |||
pool: &mut Pool<T>, | |||
asset_pair: &AssetPair, | |||
lp: &T::AccountId, | |||
side: Side, | |||
order: OrderId, | |||
order: Order, |
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.
nit: I think Side was a better name. Order suggests it's the actual order. (but I can see Side
already has another meaning).
How about OrderSide or BuyOrSell or something less ambiguous?
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.
OrderType?
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.
Order types are generally used to refer to things like limit order / market order / fill or kill etc. Ie. it's a collection of attributes or criteria.
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.
We could just name the argument side
in the LpApi? I don't think the type name is the main issue.
Deserialize, | ||
Serialize, | ||
)] | ||
pub enum Assets { |
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 also kind of a confusing name...
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.
We have have OrderSide (buy/sell), PoolSide (base/quote), AmmSide (one,zero) to disambiguate all of this a bit more clearly?
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 one isn't exposed externally, so as I said I do intend to a cleanup. Unless you can give a better name, I'll leave it for now.
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 did give some better names 😅
But ok to leave it if it's not exposed. What about order? This is one is in the Api.
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 know we want to get this out but once we settle on external-facing terminology it will be harder to change it.
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.
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.
Not sure what you're suggesting 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.
No description provided.