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

Limit Orders #181

Merged
merged 45 commits into from
Dec 16, 2024
Merged
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
de0be08
Add limit order form
JasonMHasperhoven Dec 3, 2024
a5e2b31
Construct limit order position
JasonMHasperhoven Dec 3, 2024
a9117e7
Refactor order form stores & introduce pnum util
JasonMHasperhoven Dec 4, 2024
74782f0
Update pnum description
JasonMHasperhoven Dec 4, 2024
2df6924
Use remote pnum
JasonMHasperhoven Dec 5, 2024
aae366e
Fix lint issues
JasonMHasperhoven Dec 5, 2024
8d54da7
Fix handling of input fields numbers
JasonMHasperhoven Dec 6, 2024
178013f
tmp commit
JasonMHasperhoven Dec 9, 2024
ffcdd28
Convert to base units
JasonMHasperhoven Dec 9, 2024
925091f
Start fleshing out shared position logic
cronokirby Dec 10, 2024
6cec7ed
Add tests for position math
cronokirby Dec 10, 2024
0da213e
Integrate position logic into range liquidity form
cronokirby Dec 10, 2024
c2f5f8d
Define limit order position function
cronokirby Dec 10, 2024
77d2c33
Add some documentation to position math
cronokirby Dec 10, 2024
a85105d
Wire up limit position form
cronokirby Dec 10, 2024
707034a
Remove slider from limit order form
JasonMHasperhoven Dec 10, 2024
f1f15e3
Remove key error
JasonMHasperhoven Dec 10, 2024
c943e9c
Apply same p,q,r1,r2 values as rust code
JasonMHasperhoven Dec 10, 2024
4538e10
Construct positions taking into account asset order
cronokirby Dec 10, 2024
f812cdf
Have position plans take in display units for reserves
cronokirby Dec 10, 2024
2187663
Fix limit order amount handling + gas fee calc
JasonMHasperhoven Dec 10, 2024
cc83543
Fix display amounts for range liquidity form
JasonMHasperhoven Dec 10, 2024
05b8d16
Bug: don't display weird text in order input
cronokirby Dec 11, 2024
62868fb
Define PriceLinkedInputs store
cronokirby Dec 11, 2024
ea5dcf5
Define new store for MarketOrderForm
cronokirby Dec 11, 2024
15e2e33
Move AssetInfo to separate file
cronokirby Dec 12, 2024
9e6e637
Add store for limit order position
cronokirby Dec 12, 2024
a55dcd8
Add RangeOrderFormStore
cronokirby Dec 12, 2024
ca51fa1
Basic wiring of form refactor
cronokirby Dec 12, 2024
58c0096
Implement order submission
cronokirby Dec 12, 2024
df756fc
Fix range liquidity fee tier selection
cronokirby Dec 12, 2024
4a9c90f
Correct range liquidity
cronokirby Dec 12, 2024
b3dc667
Gas fee calculation, remove unused stuff
cronokirby Dec 12, 2024
228196c
Fix remaining lints
cronokirby Dec 12, 2024
238d24a
Correct order of p and q in position construction
cronokirby Dec 12, 2024
b29b48e
Use a more robust method of getting p and q in range
cronokirby Dec 12, 2024
86d6027
Remove wheel input changes
JasonMHasperhoven Dec 13, 2024
cfc3256
Fix market slider input change
JasonMHasperhoven Dec 13, 2024
e82eb3a
Refactor setter methods for mobx strict mode, fix rerenders
JasonMHasperhoven Dec 13, 2024
c19a322
Fix hydration issue caused by connectionStore.connected
JasonMHasperhoven Dec 13, 2024
be9c496
Fix inputs disappearing
JasonMHasperhoven Dec 16, 2024
a95d19c
Add active states to select groups
JasonMHasperhoven Dec 16, 2024
790e21a
Merge branch 'main' into limitorders
JasonMHasperhoven Dec 16, 2024
8d38dcc
Remove setup connection hoc
JasonMHasperhoven Dec 16, 2024
72ca46c
Wrapp app with observer
JasonMHasperhoven Dec 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Correct order of p and q in position construction
cronokirby committed Dec 12, 2024

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
commit 238d24a0a3843cca0f3e869767b0fb3beb6736a4
2 changes: 1 addition & 1 deletion src/shared/math/position.test.ts
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ const ASSET_A = new AssetId({ inner: new Uint8Array(Array(32).fill(0xaa)) });
const ASSET_B = new AssetId({ inner: new Uint8Array(Array(32).fill(0xbb)) });

const getPrice = (position: Position): number => {
return pnum(position.phi?.component?.q).toNumber() / pnum(position.phi?.component?.p).toNumber();
return pnum(position.phi?.component?.p).toNumber() / pnum(position.phi?.component?.q).toNumber();
};

describe('planToPosition', () => {
5 changes: 3 additions & 2 deletions src/shared/math/position.ts
Original file line number Diff line number Diff line change
@@ -73,8 +73,9 @@ const priceToPQ = (
// = X * 10 ** qExponent * 10 ** -pExponent
const basePrice = new BigNumber(price).times(new BigNumber(10).pow(qExponent - pExponent));

// USD / UM -> [USD, UM], with a given precision
const [q, p] = basePrice.toFraction(10 ** PRECISION_DECIMALS);
// USD / UM -> [USD, UM], with a given precision.
// Then, we want the invariant that p * UM + q * USD = constant, so
const [p, q] = basePrice.toFraction(10 ** PRECISION_DECIMALS);
return { p: pnum(BigInt(p.toFixed(0))).toAmount(), q: pnum(BigInt(q.toFixed(0))).toAmount() };
};