Skip to content
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

Merged
merged 5 commits into from Dec 6, 2023
Merged

feat: New Lp Interfaces #4313

merged 5 commits into from Dec 6, 2023

Conversation

AlastairHolmes
Copy link
Contributor

No description provided.

@AlastairHolmes AlastairHolmes requested review from jerryafr and acdibble and removed request for a team December 5, 2023 15:48
}

{
let initial_sqrt_price = match asset {
common::Side::Zero => MAX_SQRT_PRICE - 1,
Copy link
Contributor

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' ?

Copy link
Contributor Author

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)

Copy link
Contributor Author

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,
Copy link
Contributor

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() {
Copy link
Contributor

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)| {
Copy link
Collaborator

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,
Copy link
Collaborator

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OrderType?

Copy link
Collaborator

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.

Copy link
Collaborator

@dandanlen dandanlen Dec 6, 2023

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 {
Copy link
Collaborator

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...

Copy link
Collaborator

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?

Copy link
Contributor Author

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.

Copy link
Collaborator

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.

Copy link
Collaborator

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image

Copy link
Collaborator

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...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image

GitHUb decided to not show your comments

@AlastairHolmes AlastairHolmes merged commit 13abc6d into main Dec 6, 2023
40 checks passed
@AlastairHolmes AlastairHolmes deleted the feat/new-lp-interface-design branch December 6, 2023 14:27
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.

None yet

3 participants