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: Limit Orders #3347

Closed
wants to merge 754 commits into from
Closed
Show file tree
Hide file tree
Changes from 219 commits
Commits
Show all changes
754 commits
Select commit Hold shift + click to select a range
bb69828
fix: removed query calls when parameters didn't exist for orderbooks
crnbarr93 Jul 19, 2024
54dfc5f
fix: improved and fixed selectable quote denoms
crnbarr93 Jul 19, 2024
979cdc3
feat: switch input to type text and condense value setters
fabryscript Jul 19, 2024
8246e8e
refactor: further improvements to useOrderbookSelectableDenoms
crnbarr93 Jul 19, 2024
3883bd5
feat: switch limit price selector inputs to text and handle validation
fabryscript Jul 19, 2024
307ca2c
feat: added disabled state for quote assets
crnbarr93 Jul 19, 2024
6352059
feat: persist base denom from swap tool to buy/sell tab
fabryscript Jul 19, 2024
2862289
fix: fix linting on transactions page
fabryscript Jul 19, 2024
7d32901
fix: add missing w-full attribute to ClientOnly component
fabryscript Jul 19, 2024
9da40bc
feat: update order filled percent color
fabryscript Jul 19, 2024
74784ff
fix: trim input on limit price input
fabryscript Jul 19, 2024
262f22b
fix: lint and update input logic on swap tool
fabryscript Jul 19, 2024
2a357e6
refactor: rewrote quote selection map
crnbarr93 Jul 19, 2024
70d7f0a
chore: translate new localisations
crnbarr93 Jul 19, 2024
075fa96
feat: unify from & base and fix equal denoms in swap tool
fabryscript Jul 19, 2024
427a4ed
fix: fix same from & quote edge case on place limit tool
fabryscript Jul 19, 2024
eb6db5f
chore: updated claim bounty
crnbarr93 Jul 19, 2024
034ece2
fix slippage
sunnya97 Jul 19, 2024
cfb264c
feat: vertically aligned fiat amounts in swap review
crnbarr93 Jul 20, 2024
7e8d0bd
feat: redesigned price input
crnbarr93 Jul 20, 2024
ffa37d2
feat: focus price input on swap
crnbarr93 Jul 20, 2024
20c75d0
refactor: refactored useLimitPrice
crnbarr93 Jul 20, 2024
97dcf0e
feat: added tab/type selection events for amplitude
crnbarr93 Jul 20, 2024
4c0bfd2
refactor: removed unused useMemo
crnbarr93 Jul 20, 2024
1ec29fa
Merge pull request #3558 from osmosis-labs/connor/amplitude-events
crnbarr93 Jul 20, 2024
8c6460c
Merge branch 'feat/implement-limit-orders' into connor/quote-denom-se…
crnbarr93 Jul 20, 2024
d5b4d1f
refactor: altered countDecimals export
crnbarr93 Jul 20, 2024
fc56f6b
Update packages/web/components/place-limit-tool/index.tsx
crnbarr93 Jul 20, 2024
8355353
refactor: readded scrollbar for quote denom selection
crnbarr93 Jul 21, 2024
67bbc62
Merge pull request #3562 from osmosis-labs/connor/price-input-fix
crnbarr93 Jul 22, 2024
6b66869
fix: fix some design & logic issues
fabryscript Jul 22, 2024
63fe05f
Merge branch 'feat/implement-limit-orders' into fabryscript/implement…
crnbarr93 Jul 22, 2024
27ab841
Merge pull request #3542 from osmosis-labs/fabryscript/implement-seco…
crnbarr93 Jul 22, 2024
43d4cbe
Merge feat/implement-limit-orders
crnbarr93 Jul 22, 2024
90cb83f
build: fix build errors
crnbarr93 Jul 22, 2024
2fabf3b
fix: price-selector query param change
crnbarr93 Jul 22, 2024
09482b5
fix: fix default from value & responsiveness issues
fabryscript Jul 22, 2024
d04a655
Merge branch 'feat/implement-limit-orders' into connor/quote-denom-se…
crnbarr93 Jul 22, 2024
dad8df5
Merge pull request #3566 from osmosis-labs/connor/quote-denom-selection
crnbarr93 Jul 22, 2024
086d35b
Merge branch 'feat/implement-limit-orders' into connor/price-input-ch…
crnbarr93 Jul 22, 2024
f6b977b
refactor: replaced several Boolean calls
crnbarr93 Jul 22, 2024
294e763
Merge branch 'feat/implement-limit-orders' into connor/conditional-or…
crnbarr93 Jul 22, 2024
4a96ea1
Merge pull request #3569 from osmosis-labs/sunny/fix-stuff-trade
fabryscript Jul 22, 2024
c082fae
refactor: readded enabled flag for several queries
crnbarr93 Jul 22, 2024
1617658
Merge pull request #3573 from osmosis-labs/connor/price-input-changes
crnbarr93 Jul 22, 2024
effb213
Merge branch 'feat/implement-limit-orders' into connor/fix-order-hist…
crnbarr93 Jul 22, 2024
1d3ede7
fix: simplify logic for getOrderbookState enabling
fabryscript Jul 22, 2024
a3f4c6b
Merge branch 'feat/implement-limit-orders' into connor/conditional-or…
fabryscript Jul 22, 2024
98cd94f
Merge pull request #3563 from osmosis-labs/connor/conditional-orderbo…
fabryscript Jul 22, 2024
446116d
Merge branch 'feat/implement-limit-orders' into connor/order-history-…
crnbarr93 Jul 22, 2024
921f944
Merge branch 'connor/fix-order-history-pagination' into connor/order-…
crnbarr93 Jul 22, 2024
72d2fd6
Merge branch 'feat/implement-limit-orders' into connor/order-history-…
crnbarr93 Jul 22, 2024
d39c718
fix: fix build errors
fabryscript Jul 22, 2024
46b75c8
Merge pull request #3560 from osmosis-labs/connor/order-history-bug-f…
crnbarr93 Jul 22, 2024
c17284b
feat: create generic disclaimer tooltip
fabryscript Jul 23, 2024
4d6011f
fix: enable propagation on generic disclaimer
fabryscript Jul 23, 2024
ee2f644
feat: re-arrange and update market trade details
fabryscript Jul 23, 2024
7b85b07
feat: add free state to trade details
fabryscript Jul 23, 2024
9617a83
feat: re-arrange limit order fees
fabryscript Jul 23, 2024
5ac9f98
feat: add gas icon
fabryscript Jul 23, 2024
67100bf
feat: move and update review-swap into review-order
fabryscript Jul 23, 2024
40c5b0b
feat: re-implement review-order modal
fabryscript Jul 23, 2024
52da424
feat: added gas fee esimate to place limit state
crnbarr93 Jul 23, 2024
72cf757
feat: reduced fee estimate calls
crnbarr93 Jul 23, 2024
784c059
Merge branch 'stage' into feat/implement-limit-orders
crnbarr93 Jul 23, 2024
5717447
feat: add button disabling on review modal
fabryscript Jul 23, 2024
60fc2af
fix: removed repeating asset price query
crnbarr93 Jul 23, 2024
06fc4b9
fix: adjusted placed quantity to be exact input
crnbarr93 Jul 23, 2024
5e9d988
fix: remove unused var
fabryscript Jul 23, 2024
5183f93
refactor: remove old limit order review modal and extract recap row
fabryscript Jul 23, 2024
06ab7a8
feat: add high slippage warning to review order
fabryscript Jul 23, 2024
0e5de26
feat: inject maxSlippage into usePlaceLimit hook
fabryscript Jul 23, 2024
f5f160c
chore: remove useless style from GenericDisclaimer
fabryscript Jul 23, 2024
a3c12fa
feat: add gas icon to limit trade details network fees recap row
fabryscript Jul 23, 2024
ad8e9fa
feat: add tooltips to trade details row
fabryscript Jul 23, 2024
f27ee96
Merge branch 'stage' into feat/implement-limit-orders
fabryscript Jul 24, 2024
fc3f688
Merge branch 'feat/implement-limit-orders' of github.com:osmosis-labs…
fabryscript Jul 24, 2024
bdad3f0
build: fixed translation json error
crnbarr93 Jul 24, 2024
ea8e400
Merge pull request #3585 from osmosis-labs/connor/placed-quantity
crnbarr93 Jul 24, 2024
14bb1c8
Merge branch 'stage' into feat/implement-limit-orders
crnbarr93 Jul 25, 2024
409b13a
Merge branch 'feat/implement-limit-orders' into connor/gas-fee-estimates
crnbarr93 Jul 25, 2024
31128bc
redesign swap widget (#3591)
sunnya97 Jul 25, 2024
6fd53c7
fix: fixed isTyping field for inAmountInput
crnbarr93 Jul 25, 2024
684ae0e
Improve rate info (#3588)
sunnya97 Jul 25, 2024
ef33052
Merge branch 'stage' of github.com:osmosis-labs/osmosis-frontend into…
fabryscript Jul 26, 2024
4670be1
Merge branch 'feat/implement-limit-orders' of github.com:osmosis-labs…
fabryscript Jul 26, 2024
2c6d3de
Merge branch 'feat/implement-limit-orders' of github.com:osmosis-labs…
fabryscript Jul 26, 2024
bdd7521
fix: fix missing attributes
fabryscript Jul 26, 2024
deb660b
Merge pull request #3605 from osmosis-labs/fabryscript/implement-fina…
fabryscript Jul 26, 2024
438020b
feat: redesign widget base layout & top selectors
fabryscript Jul 26, 2024
49150b8
chore: remove unused old commented code
fabryscript Jul 26, 2024
f1f71ea
chore: remove tab uqs
fabryscript Jul 26, 2024
17c16ac
feat: update token selection & input/output designs
fabryscript Jul 26, 2024
5d27e3e
feat: redesign quote selection
fabryscript Jul 26, 2024
9461630
feat: WIP redesign limit price selector and update page widget size
fabryscript Jul 26, 2024
a7e8b1f
Merge branch 'stage' of github.com:osmosis-labs/osmosis-frontend into…
fabryscript Jul 29, 2024
c412f04
Merge branch 'feat/implement-limit-orders' into fabryscript/feat-add-…
fabryscript Jul 29, 2024
0467185
fix: invert triangles direction and comment out unused code
fabryscript Jul 29, 2024
e283f4b
fix: fix button click disabled when tooltip open
fabryscript Jul 29, 2024
7dec55d
feat: re-implement open orders card
fabryscript Jul 29, 2024
e7d36c7
feat: WIP init implementing focus switching
fabryscript Jul 29, 2024
b8843c4
feat: add switching button UI
fabryscript Jul 29, 2024
11309f5
feat: change default percent adjustment and label render logic
fabryscript Jul 29, 2024
74dd987
feat: re-add trade details
fabryscript Jul 29, 2024
1562414
chore: remove unused code
fabryscript Jul 29, 2024
90a8ebf
refactor: extract AssetFieldset
fabryscript Jul 29, 2024
40cc6b5
chore: comment out unused code
fabryscript Jul 29, 2024
dc6000a
feat: wire-up trade details limit variant
fabryscript Jul 29, 2024
0f4c64d
feat: WIP implement new swap tool designs
fabryscript Jul 29, 2024
707891d
refactor: moved order mapping to caching function
crnbarr93 Jul 29, 2024
257ea3b
build: fixed build errors
crnbarr93 Jul 29, 2024
f5e740c
feat: added refetch to cancel/claim [WARNING DO NOT TEST]
crnbarr93 Jul 29, 2024
20289d0
fix: fixed refetching on order table
crnbarr93 Jul 29, 2024
ad12f9d
Merge branch 'fabryscript/feat-add-v3-designs' into connor/order-hist…
crnbarr93 Jul 29, 2024
4495569
feat: finish implementing swap tool redesign
fabryscript Jul 29, 2024
3c8e2ac
feat: add popover on limit order disabled & tweak GenericDisclaimer c…
fabryscript Jul 30, 2024
82413ab
feat: refetch orders on first load
crnbarr93 Jul 30, 2024
02dc2bc
feat: add "add funds" button to asset fieldset header balance
fabryscript Jul 30, 2024
a22eb70
feat: add no balance logics to place limit tool & swap tool
fabryscript Jul 30, 2024
0a345ea
fix: inputs adjust value of other input for limit orders
crnbarr93 Jul 30, 2024
780be4b
feat: change all site bg & fix earn page radio buttons opacity
fabryscript Jul 30, 2024
8cd430f
fix: removed unnecessary button disabled state
crnbarr93 Jul 30, 2024
eba4a19
fix: removed unnecessary button disabled state
crnbarr93 Jul 30, 2024
389b3ce
feat: add trade bg
fabryscript Jul 30, 2024
c8ae72d
chore: removed unused code
crnbarr93 Jul 30, 2024
f9b043d
fix: fixed price input error on 0 input
crnbarr93 Jul 30, 2024
167273f
fix: fixed rounding issue with max button
crnbarr93 Jul 30, 2024
b646aeb
Merge pull request #3629 from osmosis-labs/connor/v3-max-button
fabryscript Jul 30, 2024
6e0c425
fix: fix faulting overflow-hidden on alt swap tool
fabryscript Jul 30, 2024
1f5f54a
fix: fix bar width
fabryscript Jul 30, 2024
ad7e453
fix: fix alt swap tool labels
fabryscript Jul 30, 2024
07145e3
fix: fix scroll on home fixed container
fabryscript Jul 30, 2024
185e96a
fix: fix "add funds" display on wallet disconnected
fabryscript Jul 30, 2024
f12a07e
fix: fix alt headers and remove old code
fabryscript Jul 30, 2024
09a0ef9
fix: fix spacing on tool
fabryscript Jul 30, 2024
fd9ed43
fix: fix trade details bugged animation
fabryscript Jul 30, 2024
9dc0ba3
feat: add prefixes/suffixes empty states
fabryscript Jul 30, 2024
f9eba89
fix: disable ticker on sell tab balance
fabryscript Jul 30, 2024
4b05410
fix: fix sell balance precision & fieldset footer height
fabryscript Jul 30, 2024
5ca5441
fix: fix buy available usdc amount formatting
fabryscript Jul 30, 2024
ed2a5e0
feat: update selectableQuotes to cover wallet not connected case
fabryscript Jul 30, 2024
311da45
fix: hide add funds button when wallet is disconnected
fabryscript Jul 30, 2024
d75ad86
fix: hide add funds cta on price selector and fix lint
fabryscript Jul 30, 2024
b63f395
fix: filter in UI default quotes on defaultQuotesWithBalances
fabryscript Jul 31, 2024
fe52f29
feat: add empty states to swap widget footers
fabryscript Jul 31, 2024
3546c8c
feat: make "stablecoin" tooltip trigger underlined
fabryscript Jul 31, 2024
d8e55d7
Merge branch 'fabryscript/feat-add-v3-designs' into connor/gas-fee-es…
crnbarr93 Jul 31, 2024
087ff3f
fix: update decimal places and add "<$0.01" to trade details fees
fabryscript Jul 31, 2024
e36a1f7
build: fixed build errors
crnbarr93 Jul 31, 2024
494685a
fix: update display of gasUsdValueToPay
fabryscript Jul 31, 2024
4dffe1e
Merge branch 'fabryscript/feat-add-v3-designs' into connor/gas-fee-es…
fabryscript Jul 31, 2024
bce6afe
Merge pull request #3584 from osmosis-labs/connor/gas-fee-estimates
fabryscript Jul 31, 2024
35b8fce
feat: update rendering of gasAmount and wire it up on swap tool
fabryscript Jul 31, 2024
3f0bf9e
refactor: updated button disabled & loading states
crnbarr93 Jul 31, 2024
22b76e0
fix: update gas display on review modal
fabryscript Jul 31, 2024
b879790
chore: readded insufficient balance display to hidden error messages
crnbarr93 Jul 31, 2024
b2cd80f
fix: update chart icon size and variant display logic
fabryscript Jul 31, 2024
759ee2c
feat: remove triangle indicator when percentAdjusted is zero
fabryscript Jul 31, 2024
8f5d6a5
fix: update token-details-shadow color
fabryscript Jul 31, 2024
fc2c766
chore: sentence case adjustments
crnbarr93 Jul 31, 2024
7cda9fe
fix: fixed review modal changing price and incorrect values
crnbarr93 Jul 31, 2024
fc4fa94
feat: WIP add scaling to asset input
fabryscript Jul 31, 2024
234747a
Merge branch 'fabryscript/feat-add-v3-designs' of github.com:osmosis-…
fabryscript Jul 31, 2024
57bb5fe
Merge pull request #3637 from osmosis-labs/connor/buy-sell-button-state
fabryscript Jul 31, 2024
8324fa3
Merge pull request #3638 from osmosis-labs/connor/limit-review
fabryscript Jul 31, 2024
33f3e13
fix: fix rounding issues on order type selector and wrapping on paren…
fabryscript Jul 31, 2024
8658986
fix: move isValidNumericalRawInput validation to useLimitPrice
fabryscript Jul 31, 2024
3849bf9
refactor: move orderType prop computation to ReviewOrder and remove u…
fabryscript Jul 31, 2024
fc5fef1
fix: fixed low price value display in limit price selector
crnbarr93 Jul 31, 2024
7d847ff
feat: WIP add diffGteSlippage handling
fabryscript Jul 31, 2024
6d39361
fix: update isManualSlippageTooHigh treshold
fabryscript Jul 31, 2024
942122a
feat: truncate last slippage number if it's gt 50
fabryscript Jul 31, 2024
47299fd
feat: add isManualSlippageTooLow disclaimer and update designs
fabryscript Jul 31, 2024
6a64941
fix: fix max button spinner distortion
fabryscript Jul 31, 2024
12e278f
fix: fix sticky scroll bg color to thead
fabryscript Jul 31, 2024
ebafac3
feat: add tooltip on order history page
fabryscript Jul 31, 2024
d781312
feat: update order history columns
fabryscript Jul 31, 2024
af50e3f
fix: fixed overflow on trade details and insufficient funds not disab…
crnbarr93 Jul 31, 2024
c33df32
fix: added label for limit price input and fixed hover state for deno…
crnbarr93 Jul 31, 2024
36ee65a
feat: button hover states for price selection
crnbarr93 Jul 31, 2024
353cc0a
fix: removed place limit msg generation for market orders
crnbarr93 Jul 31, 2024
f242a65
build: fixed build error
crnbarr93 Jul 31, 2024
d6c30da
fix: adjusted text overflow for expected output
crnbarr93 Aug 1, 2024
e19e6a8
feat: :sparkles: add limit orders localizations
DavideSegullo Aug 1, 2024
3b6c3c8
feat: added no gas fee estimation state to trade details
crnbarr93 Aug 1, 2024
a483834
Merge pull request #3639 from osmosis-labs/connor/limit-price-decimals
crnbarr93 Aug 1, 2024
276eb54
feat: added gas estimate changes to review order
crnbarr93 Aug 1, 2024
9e14d30
chore: machine translate
crnbarr93 Aug 1, 2024
4c18118
Merge branch 'fabryscript/feat-add-v3-designs' into connor/gas-estima…
crnbarr93 Aug 1, 2024
ef571b3
chore: added more localisations
crnbarr93 Aug 1, 2024
949e0f8
feat: added refetchOnMount to all/claimable orders queries
crnbarr93 Aug 1, 2024
7eaa406
Merge branch 'fabryscript/feat-add-v3-designs' into connor/order-hist…
crnbarr93 Aug 1, 2024
9879bed
Merge pull request #3647 from osmosis-labs/connor/gas-estimate-failure
crnbarr93 Aug 1, 2024
567fe35
Merge pull request #3623 from osmosis-labs/connor/order-history-caching
crnbarr93 Aug 1, 2024
22f3792
Merge branch 'feat/implement-limit-orders' into fabryscript/feat-add-…
crnbarr93 Aug 1, 2024
e3d40f4
Merge pull request #3612 from osmosis-labs/fabryscript/feat-add-v3-de…
crnbarr93 Aug 1, 2024
aac1f50
fix: filtered unwanted quote assets
crnbarr93 Aug 1, 2024
adbc9b8
feat: added amount formatting for quote denom selection
crnbarr93 Aug 1, 2024
5a05846
refactor: refactored balance queries in placelimit hook
crnbarr93 Aug 1, 2024
263abdc
fix: :lipstick: fix order history table overflow (#3649)
DavideSegullo Aug 1, 2024
2252e21
fix: fixed modal not being attached to top of screen for denom selection
crnbarr93 Aug 1, 2024
d7abb8e
fix: :lipstick: fix trade widget overlap with sidebar
DavideSegullo Aug 1, 2024
97ec861
feat: clear denom selection on modal close
crnbarr93 Aug 1, 2024
2645c84
fix: undid regression
crnbarr93 Aug 1, 2024
6723212
feat: :sparkles: add missing translation and fix analytics event page
DavideSegullo Aug 1, 2024
0c313fa
fix: :bug: fix build error
DavideSegullo Aug 1, 2024
8c494a9
Merge pull request #3650 from osmosis-labs/connor/buy-sell-denom-sele…
crnbarr93 Aug 1, 2024
813384a
fix: removed limit price display in review modal on swap tab
crnbarr93 Aug 1, 2024
cfefbc8
fix: fixed available amount formatting for buy/sell tab
crnbarr93 Aug 1, 2024
ba7e396
feat: moved error display
crnbarr93 Aug 2, 2024
d13cdff
fix: disabled button on no funds
crnbarr93 Aug 2, 2024
a9f0dfc
fix: limited decimal input to 3 decimal places
crnbarr93 Aug 2, 2024
59d656a
fix: removed gas fee estimation from trade details
crnbarr93 Aug 2, 2024
c9905d8
feat: added state for no routes in trade details
crnbarr93 Aug 2, 2024
453dc97
feat: focus input on swap for buy/sell
crnbarr93 Aug 2, 2024
b285353
feat: automatically display base denom in trade details
crnbarr93 Aug 2, 2024
3ab1a47
fix: non-focused percentage 3 decimal places
crnbarr93 Aug 2, 2024
20bced0
refactor: altered trade details outAsBase state and added more locali…
crnbarr93 Aug 2, 2024
a2762af
Merge pull request #3654 from osmosis-labs/connor/qa-round-2
crnbarr93 Aug 2, 2024
968c822
[WIP] feat: price selection has default value
crnbarr93 Aug 2, 2024
5d51491
Merge branch 'stage' into feat/implement-limit-orders
crnbarr93 Aug 2, 2024
125f8c5
fix: hid routes chevron when no routes found
crnbarr93 Aug 2, 2024
9d69d0e
fix: fixed swap tool layout on pools page modal
crnbarr93 Aug 2, 2024
a3715fa
fix: background colors for pool page
crnbarr93 Aug 2, 2024
7b0e795
fix: background colour changes
crnbarr93 Aug 2, 2024
497f330
Merge pull request #3659 from osmosis-labs/connor/pool-trade-token
crnbarr93 Aug 2, 2024
72c2853
fix: review order terminology changes
crnbarr93 Aug 2, 2024
ec28773
fix: trade-tokens terminology and padding changes
crnbarr93 Aug 2, 2024
659570e
fix: adjusted ttl for all orders cache
crnbarr93 Aug 2, 2024
567cb3d
refactor: changed cache times for orders
crnbarr93 Aug 2, 2024
a1962c6
refactor: altered cache times and added logs for active orders query
crnbarr93 Aug 4, 2024
951ab61
feat: small improvement to all orders query
crnbarr93 Aug 4, 2024
670f993
chore: cleaned up logs
crnbarr93 Aug 4, 2024
7452f33
fix: active orders optimisation
crnbarr93 Aug 4, 2024
6f09a42
fix: fixed bug with input form not resetting
crnbarr93 Aug 4, 2024
5bdff10
fix: refetch orders when order placed
crnbarr93 Aug 4, 2024
1a9fd45
fix: readded claim all orders function
crnbarr93 Aug 5, 2024
c020cd6
Merge branch 'feat/implement-limit-orders' into connor/price-selectio…
crnbarr93 Aug 5, 2024
ab95012
refactor: refactored price input to be simpler
crnbarr93 Aug 5, 2024
5b5a7a1
fix: updating price while in percent mode for price selection
crnbarr93 Aug 5, 2024
42e5cca
feat: extreme value handling
crnbarr93 Aug 5, 2024
61d9056
feat: extreme value handling
crnbarr93 Aug 5, 2024
0e95d9c
fix: small bug fixes
crnbarr93 Aug 5, 2024
0b97b5a
fix: price adjustment as spot price changes in price selection, remov…
crnbarr93 Aug 5, 2024
1e1828e
Merge pull request #3673 from osmosis-labs/connor/price-selection-def…
crnbarr93 Aug 5, 2024
8598adb
feat: spinner/disabled look for claim & close button
crnbarr93 Aug 5, 2024
20ce7ad
fix: fixed above/below display for price selector
crnbarr93 Aug 5, 2024
97c9b88
fix: show order history link when user has any order history
crnbarr93 Aug 5, 2024
99b0ce9
fix: fixed font scaling for inputs
crnbarr93 Aug 5, 2024
538e49c
Merge pull request #3678 from osmosis-labs/connor/font-scaling
crnbarr93 Aug 5, 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
34 changes: 33 additions & 1 deletion packages/math/src/pool/concentrated/__tests__/tick.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Dec, Int } from "@keplr-wallet/unit";

import { approxSqrt } from "../../../utils";
import { maxSpotPrice, maxTick, minSpotPrice } from "../const";
import { priceToTick, tickToSqrtPrice } from "../tick";
import { priceToTick, tickToPrice, tickToSqrtPrice } from "../tick";
Copy link
Contributor

Choose a reason for hiding this comment

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

Optimize imports in test file.

The import tickToSqrtPrice is not used in the provided test cases. Consider removing it to keep the code clean and efficient.

- import { priceToTick, tickToPrice, tickToSqrtPrice } from "../tick";
+ import { priceToTick, tickToPrice } from "../tick";
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import { priceToTick, tickToPrice, tickToSqrtPrice } from "../tick";
import { priceToTick, tickToPrice } from "../tick";


// https://github.com/osmosis-labs/osmosis/blob/0f9eb3c1259078035445b3e3269659469b95fd9f/x/concentrated-liquidity/math/tick_test.go#L30
describe("tickToSqrtPrice", () => {
Expand Down Expand Up @@ -217,6 +217,38 @@ describe("priceToTick", () => {
});
});

describe("tickToPrice", () => {
const testCases: Record<string, { tick: Int; priceExpected: Dec }> = {
"Tick Zero": {
tick: new Int("0"),
priceExpected: new Dec("1"),
},
"Large Positive Tick": {
tick: new Int("1000000"),
priceExpected: new Dec("2"),
},
"Large Negative Tick": {
tick: new Int("-5000000"),
priceExpected: new Dec("0.5"),
},
"Max Tick": {
tick: new Int("182402823"),
priceExpected: new Dec("340282300000000000000"),
},
"Min Tick": {
tick: new Int("-108000000"),
priceExpected: new Dec("0.000000000001"),
},
};

Object.values(testCases).forEach(({ tick, priceExpected }, i) => {
it(Object.keys(testCases)[i], () => {
const price = tickToPrice(tick);
expect(price.toString()).toEqual(priceExpected.toString());
});
});
});

// TEMORARY: commenting out until we confirm adding a buffer around current tick avoids invalid queries
// describe("estimateInitialTickBound", () => {
// // src: https://github.com/osmosis-labs/osmosis/blob/0b199ee187fbff02f68c2dc503d60efe617a67b2/x/concentrated-liquidity/tick_test.go#L1865
Expand Down
47 changes: 47 additions & 0 deletions packages/math/src/pool/concentrated/tick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,53 @@ export function tickToSqrtPrice(tickIndex: Int): Dec {
return approxSqrt(price);
}

export function tickToPrice(tickIndex: Int): Dec {
if (tickIndex.isZero()) {
return new Dec(1);
}

const geometricExponentIncrementDistanceInTicks = nine.mul(
powTenBigDec(new Int(exponentAtPriceOne).neg()).toDec()
);

if (tickIndex.lt(minTick) || tickIndex.gt(maxTick)) {
throw new Error(
`tickIndex is out of range: ${tickIndex.toString()}, min: ${minTick.toString()}, max: ${maxTick.toString()}`
);
}

const geometricExponentDelta = new Dec(tickIndex)
.quoTruncate(new Dec(geometricExponentIncrementDistanceInTicks.truncate()))
.truncate();

let exponentAtCurTick = new Int(exponentAtPriceOne).add(
geometricExponentDelta
);
if (tickIndex.lt(new Int(0))) {
exponentAtCurTick = exponentAtCurTick.sub(new Int(1));
}

const currentAdditiveIncrementInTicks = powTenBigDec(exponentAtCurTick);

const numAdditiveTicks = tickIndex.sub(
geometricExponentDelta.mul(
geometricExponentIncrementDistanceInTicks.truncate()
)
);

const price = powTenBigDec(geometricExponentDelta)
.add(new BigDec(numAdditiveTicks).mul(currentAdditiveIncrementInTicks))
.toDec();

if (price.gt(maxSpotPrice) || price.lt(minSpotPrice)) {
throw new Error(
`price is out of range: ${price.toString()}, min: ${minSpotPrice.toString()}, max: ${maxSpotPrice.toString()}`
);
}

return price;
}
Comment on lines +69 to +114
Copy link
Contributor

Choose a reason for hiding this comment

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

Refactor suggestion: Consider modularizing repetitive code blocks in tickToPrice.

The tickToPrice function contains repetitive code blocks, especially in the calculations involving geometric exponents and price bounds checking. This could be abstracted into smaller, reusable functions to improve code maintainability and readability.

+ function calculateGeometricExponentDelta(tickIndex, geometricExponentIncrementDistanceInTicks) {
+   return new Dec(tickIndex)
+     .quoTruncate(new Dec(geometricExponentIncrementDistanceInTicks.truncate()))
+     .truncate();
+ }
+
+ function checkTickIndexBounds(tickIndex) {
+   if (tickIndex.lt(minTick) || tickIndex.gt(maxTick)) {
+     throw new Error(
+       `tickIndex is out of range: ${tickIndex.toString()}, min: ${minTick.toString()}, max: ${maxTick.toString()}`
+     );
+   }
+ }
+
+ function checkPriceBounds(price) {
+   if (price.gt(maxSpotPrice) || price.lt(minSpotPrice)) {
+     throw new Error(
+       `price is out of range: ${price.toString()}, min: ${minSpotPrice.toString()}, max: ${maxSpotPrice.toString()}`
+     );
+   }
+ }
-  if (tickIndex.lt(minTick) || tickIndex.gt(maxTick)) {
-    throw new Error(
-      `tickIndex is out of range: ${tickIndex.toString()}, min: ${minTick.toString()}, max: ${maxTick.toString()}`
-    );
-  }
-  if (price.gt(maxSpotPrice) || price.lt(minSpotPrice)) {
-    throw new Error(
-      `price is out of range: ${price.toString()}, min: ${minSpotPrice.toString()}, max: ${maxSpot

Committable suggestion was skipped due to low confidence.


/** PriceToTick takes a price and returns the corresponding tick index
* This function does not take into consideration tick spacing.
*/
Expand Down
1 change: 1 addition & 0 deletions packages/server/src/queries/complex/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export * from "./chains";
export * from "./concentrated-liquidity";
export * from "./earn";
export * from "./get-timeout-height";
export * from "./orderbooks";
export * from "./pools";
export * from "./staking";
export * from "./swap-routers";
Expand Down
32 changes: 32 additions & 0 deletions packages/server/src/queries/complex/orderbooks/active-orders.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Chain } from "@osmosis-labs/types";
import cachified, { CacheEntry } from "cachified";
import { LRUCache } from "lru-cache";

import { DEFAULT_LRU_OPTIONS } from "../../../utils/cache";
import { LimitOrder, queryOrderbookActiveOrders } from "../../osmosis";

const activeOrdersCache = new LRUCache<string, CacheEntry>(DEFAULT_LRU_OPTIONS);

export function getOrderbookActiveOrders({
orderbookAddress,
userOsmoAddress,
chainList,
}: {
orderbookAddress: string;
userOsmoAddress: string;
chainList: Chain[];
}) {
return cachified({
cache: activeOrdersCache,
key: `orderbookActiveOrders-${orderbookAddress}-${userOsmoAddress}`,
ttl: 1000 * 60 * 2, // 2 minutes
getFreshValue: () =>
queryOrderbookActiveOrders({
orderbookAddress,
userAddress: userOsmoAddress,
chainList,
}).then(
({ data }: { data: { count: number; orders: LimitOrder[] } }) => data
),
});
}
4 changes: 4 additions & 0 deletions packages/server/src/queries/complex/orderbooks/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from "./active-orders";
export * from "./maker-fee";
export * from "./spot-price";
export * from "./tick-state";
27 changes: 27 additions & 0 deletions packages/server/src/queries/complex/orderbooks/maker-fee.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Dec } from "@keplr-wallet/unit";
import { Chain } from "@osmosis-labs/types";
import cachified, { CacheEntry } from "cachified";
import { LRUCache } from "lru-cache";

import { DEFAULT_LRU_OPTIONS } from "../../../utils/cache";
import { queryOrderbookMakerFee } from "../../osmosis";

const makerFeeCache = new LRUCache<string, CacheEntry>(DEFAULT_LRU_OPTIONS);

export function getOrderbookMakerFee({
orderbookAddress,
chainList,
}: {
orderbookAddress: string;
chainList: Chain[];
}) {
return cachified({
cache: makerFeeCache,
key: `orderbookMakerFee-${orderbookAddress}`,
ttl: 1000 * 60 * 60 * 4, // 4 hours
getFreshValue: () =>
queryOrderbookMakerFee({ orderbookAddress, chainList }).then(
({ data }: { data: string }) => new Dec(data)
),
});
}
36 changes: 36 additions & 0 deletions packages/server/src/queries/complex/orderbooks/spot-price.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Dec } from "@keplr-wallet/unit";
import { Chain } from "@osmosis-labs/types";
import cachified, { CacheEntry } from "cachified";
import { LRUCache } from "lru-cache";

import { DEFAULT_LRU_OPTIONS } from "../../../utils/cache";
import { queryOrderbookSpotPrice } from "../../osmosis";

const orderbookSpotPriceCache = new LRUCache<string, CacheEntry>(
DEFAULT_LRU_OPTIONS
);

export function getOrderbookSpotPrice({
orderbookAddress,
chainList,
quoteAssetDenom,
baseAssetDenom,
}: {
orderbookAddress: string;
quoteAssetDenom: string;
baseAssetDenom: string;
chainList: Chain[];
}) {
return cachified({
cache: orderbookSpotPriceCache,
key: `orderbookSpotPrice-${orderbookAddress}-${quoteAssetDenom}-${baseAssetDenom}`,
ttl: 1000 * 60 * 2, // 2 minutes
getFreshValue: () =>
queryOrderbookSpotPrice({
orderbookAddress,
chainList,
quoteAssetDenom,
baseAssetDenom,
}).then(({ data }) => new Dec(data.spot_price)),
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure proper error handling in getOrderbookSpotPrice function.

The function getOrderbookSpotPrice fetches data using queryOrderbookSpotPrice and transforms it using then. However, there is no error handling for cases where queryOrderbookSpotPrice might fail or return an unexpected result. This could lead to runtime errors if the promise is rejected.

+      }).catch(error => {
+        console.error('Failed to fetch spot price:', error);
+        throw error; // Rethrow or handle as needed
+      })
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export function getOrderbookSpotPrice({
orderbookAddress,
chainList,
quoteAssetDenom,
baseAssetDenom,
}: {
orderbookAddress: string;
quoteAssetDenom: string;
baseAssetDenom: string;
chainList: Chain[];
}) {
return cachified({
cache: orderbookSpotPriceCache,
key: `orderbookSpotPrice-${orderbookAddress}-${quoteAssetDenom}-${baseAssetDenom}`,
ttl: 1000 * 60 * 2, // 2 minutes
getFreshValue: () =>
queryOrderbookSpotPrice({
orderbookAddress,
chainList,
quoteAssetDenom,
baseAssetDenom,
}).then(({ data }) => new Dec(data.spot_price)),
export function getOrderbookSpotPrice({
orderbookAddress,
chainList,
quoteAssetDenom,
baseAssetDenom,
}: {
orderbookAddress: string;
quoteAssetDenom: string;
baseAssetDenom: string;
chainList: Chain[];
}) {
return cachified({
cache: orderbookSpotPriceCache,
key: `orderbookSpotPrice-${orderbookAddress}-${quoteAssetDenom}-${baseAssetDenom}`,
ttl: 1000 * 60 * 2, // 2 minutes
getFreshValue: () =>
queryOrderbookSpotPrice({
orderbookAddress,
chainList,
quoteAssetDenom,
baseAssetDenom,
}).then(({ data }) => new Dec(data.spot_price))
.catch(error => {
console.error('Failed to fetch spot price:', error);
throw error; // Rethrow or handle as needed
}),

});
}
57 changes: 57 additions & 0 deletions packages/server/src/queries/complex/orderbooks/tick-state.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { Chain } from "@osmosis-labs/types";
import cachified, { CacheEntry } from "cachified";
import { LRUCache } from "lru-cache";

import { DEFAULT_LRU_OPTIONS } from "../../../utils/cache";
import {
queryOrderbookTicks,
queryOrderbookTickUnrealizedCancelsById,
} from "../../osmosis";

const tickInfoCache = new LRUCache<string, CacheEntry>(DEFAULT_LRU_OPTIONS);

export function getOrderbookTickState({
orderbookAddress,
chainList,
tickIds,
}: {
orderbookAddress: string;
chainList: Chain[];
tickIds: number[];
}) {
return cachified({
cache: tickInfoCache,
key: `orderbookTickInfo-${orderbookAddress}-${tickIds
.sort((a, b) => a - b)
.join(",")}`,
ttl: 1000 * 60 * 2, // 2 minutes
getFreshValue: () =>
queryOrderbookTicks({ orderbookAddress, chainList, tickIds }).then(
({ data }) => data.ticks
),
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure consistent caching and error handling in tick state retrieval functions.

Both getOrderbookTickState and getOrderbookTickUnrealizedCancels functions use a similar pattern for caching and fetching data. It's crucial to ensure that the caching keys are constructed consistently and that errors during data fetching are handled appropriately to prevent runtime crashes.

+      }).catch(error => {
+        console.error('Failed to fetch tick information:', error);
+        throw error; // Rethrow or handle as needed
+      })

Also applies to: 35-55

});
}

export function getOrderbookTickUnrealizedCancels({
orderbookAddress,
chainList,
tickIds,
}: {
orderbookAddress: string;
chainList: Chain[];
tickIds: number[];
}) {
return cachified({
cache: tickInfoCache,
key: `orderbookTickUnrealizedCancels-${orderbookAddress}-${tickIds
.sort((a, b) => a - b)
.join(",")}`,
ttl: 1000 * 60 * 2, // 2 minutes
getFreshValue: () =>
queryOrderbookTickUnrealizedCancelsById({
orderbookAddress,
chainList,
tickIds,
}).then(({ data }) => data.ticks),
});
}
1 change: 1 addition & 0 deletions packages/server/src/queries/osmosis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export * from "./icns";
export * from "./incentives";
export * from "./lockup";
export * from "./mint";
export * from "./orderbooks";
export * from "./poolmanager";
export * from "./superfluid";
export * from "./txfees";
Loading
Loading