-
Notifications
You must be signed in to change notification settings - Fork 2
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
Limit Orders #181
Limit Orders #181
Conversation
src/shared/math/position.ts
Outdated
price: number, | ||
pExponent: number, | ||
qExponent: number, | ||
): { p: Amount; q: Amount } => { |
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.
Let's prefer using
src/shared/math/position.ts
Outdated
), | ||
qExponent, | ||
).toAmount(); | ||
|
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.
Do we need scale
at all?
// Pseudo code
const p_1 = round(quoteAssetExponent * price);
const p_2 = baseAssetExponent;
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 understand the exponent shift.
src/shared/math/position.ts
Outdated
|
||
// const r1 = pnum(plan.baseReserves, plan.baseAsset.exponent).toAmount(); | ||
// const r2 = pnum(plan.quoteReserves, plan.quoteAsset.exponent).toAmount(); | ||
const r1 = pnum(plan.baseReserves).toAmount(); |
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 we need to make sure that base is asset_1 and quote is asset_2 and flip everything if it's not.
Ideally, there's a Position
constructor that does this on your behalf so that you don't have to worry about it.
e51bd9c
to
e3a7fe4
Compare
7f8124a
to
ae3c1fc
Compare
Some things I tested but couldn't get working:
USDY/USDC limit orders are a good test case because they exercise different denoms and also unlock a market-based solution to the USDC transfer issue. |
aacd3c4
to
f52dc65
Compare
I refactored the stores to all have a much more consistent set of transitions and a reduced set of truth, and everything now seems to be working correctly. I clobbered some work in the process, which is backed up in https://github.com/penumbra-zone/dex-explorer/tree/limitorders-archive just in case. There were a handful of bugs not even reported in slack across the various forms, but now it should all work. I tested it buy working on the testnet, using TestUSD and UM, which have 1e18 and 1e6 as the exponent Range Liquidity: Some testing on mainnet would be appreciated |
10da38e
to
6604a85
Compare
This should handle cases where they're out of range by losing only the necessary precision, and it should handle cases where the price gets flattened to 0
6604a85
to
b29b48e
Compare
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.
Great job (everyone)! Given the number of devs that have contributed to this PR, think we should feel confident to ship and iterate as needed in follow ups 👍
No description provided.