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 and Swap Flow Redesign #3683

Merged
merged 807 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
807 commits
Select commit Hold shift + click to select a range
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
1586be0
fix: caching trade tool active orders query to orders history page
crnbarr93 Aug 5, 2024
1a9fd45
fix: readded claim all orders function
crnbarr93 Aug 5, 2024
0718555
Merge branch 'feat/implement-limit-orders' into connor/order-history-…
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
2e40533
Merge branch 'feat/implement-limit-orders' into connor/order-history-…
crnbarr93 Aug 6, 2024
e7a4fd1
fix: reworked order history page
crnbarr93 Aug 6, 2024
0015437
chore: removed old order history page
crnbarr93 Aug 6, 2024
4acb471
build: fixed build error
crnbarr93 Aug 6, 2024
1e18c8e
Merge pull request #3682 from osmosis-labs/connor/order-history-blinking
crnbarr93 Aug 6, 2024
b17e6dc
Merge branch 'stage' into feat/implement-limit-orders
crnbarr93 Aug 6, 2024
3f45c69
fix: small changes to order history
crnbarr93 Aug 6, 2024
903e54f
build: fix build errors
crnbarr93 Aug 6, 2024
2ede390
feat: moved orderbook denom query to sqs pools
crnbarr93 Aug 6, 2024
8aa362e
fix: more active orders query changes
crnbarr93 Aug 6, 2024
4391e2a
feat: added no wallet state for order history
crnbarr93 Aug 6, 2024
ee15586
fix: wallet loading state order history page
crnbarr93 Aug 6, 2024
8415720
feat: limits can now be placed on opposite side of market price
crnbarr93 Aug 6, 2024
76b319f
chore: localisations
crnbarr93 Aug 6, 2024
37001d7
Merge pull request #3685 from osmosis-labs/connor/disable-auto-market…
crnbarr93 Aug 6, 2024
a1f0a61
fix: fixed error on high price amount inputs
crnbarr93 Aug 7, 2024
c966823
fix: small percentage adjustments for price input
crnbarr93 Aug 7, 2024
15ad5bb
chore: removed logs, small formatting adjustment
crnbarr93 Aug 7, 2024
06afea3
fix: toggle background colours for limit order ff
crnbarr93 Aug 7, 2024
2755002
fix: percent fill rounding
crnbarr93 Aug 7, 2024
84615e0
feat: added geolocation based feature flags for limit orders
crnbarr93 Aug 7, 2024
301db38
Merge pull request #3691 from osmosis-labs/connor/price-bug-fixes
crnbarr93 Aug 7, 2024
6b04db0
Merge pull request #3692 from osmosis-labs/connor/limit-feat-flag
crnbarr93 Aug 7, 2024
30e74e6
Merge pull request #3693 from osmosis-labs/connor/geolocation-limit-o…
crnbarr93 Aug 7, 2024
fcb2120
fix: improved feel of cancel/claim buttons
crnbarr93 Aug 7, 2024
14cf4f8
fix: correct swap tool depending on feature flags
crnbarr93 Aug 7, 2024
f5298a8
fix: missed backgrounds for feature flags
crnbarr93 Aug 7, 2024
029543c
build: fix build errors
crnbarr93 Aug 7, 2024
6f78856
fix: remove swr and invalidate orderbook queries on tx
crnbarr93 Aug 7, 2024
6c05934
refactor: moved historical orders query, fixed schema issue
crnbarr93 Aug 7, 2024
f2fabb1
chore: removed unused code
crnbarr93 Aug 7, 2024
c63e968
chore: reduced use of useMemo where possible
crnbarr93 Aug 7, 2024
41d3f9c
chore: remove unused code
crnbarr93 Aug 7, 2024
027692b
test: moved tickToPrice to jest in case
crnbarr93 Aug 7, 2024
cbe4014
chore: added debug logs for claim/cancel buttons when no wallet found
crnbarr93 Aug 7, 2024
4ab9b38
feat: added intersection component to orders history
crnbarr93 Aug 7, 2024
fbac764
feat: valid/default limit quote denoms uses MainnetAssetSymbols
crnbarr93 Aug 7, 2024
a1cd836
fix: feature flag bg colour in main
crnbarr93 Aug 7, 2024
1f42a20
feat: added placeholder prop to ScaledCurrencyInput
crnbarr93 Aug 7, 2024
c1166b9
build: fixed build errors
crnbarr93 Aug 7, 2024
94ba78a
feat: undid order history first column changes from yesterday
crnbarr93 Aug 7, 2024
d371327
Merge branch 'stage' into feat/implement-limit-orders
crnbarr93 Aug 7, 2024
f85a860
test: added unit tests for new formatter functions
crnbarr93 Aug 7, 2024
9f7e79d
refactor: moved countDecimals test to correct file
crnbarr93 Aug 7, 2024
8dae53a
refactor: :recycle: add useKeyboardNavigation instead of custom imple…
DavideSegullo Aug 7, 2024
4885675
chore: added comments to disabled hooks in various places
crnbarr93 Aug 7, 2024
a1ac48e
Merge pull request #3694 from osmosis-labs/connor/swap-tools-feature-…
crnbarr93 Aug 7, 2024
3d23628
fix: :bug: fix build error
DavideSegullo Aug 7, 2024
e26728a
lint
jonator Aug 7, 2024
2e74661
clean up unused localizations
jonator Aug 7, 2024
47a69d4
remove tests for old swap tool (deprecated)
jonator Aug 7, 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";

// 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());
});
});
});
crnbarr93 marked this conversation as resolved.
Show resolved Hide resolved

// 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;
}

/** 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 "./osmosis";
export * from "./pools";
export * from "./portfolio";
Expand Down
158 changes: 158 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,158 @@
import { Dec, Int } from "@keplr-wallet/unit";
import { tickToPrice } from "@osmosis-labs/math";
import { Chain } from "@osmosis-labs/types";
import { getAssetFromAssetList } from "@osmosis-labs/utils";
import cachified, { CacheEntry } from "cachified";
import dayjs from "dayjs";
import { LRUCache } from "lru-cache";

import { DEFAULT_LRU_OPTIONS } from "../../../utils/cache";
import { LimitOrder, queryOrderbookActiveOrders } from "../../osmosis";
import {
getOrderbookTickState,
getOrderbookTickUnrealizedCancels,
} from "./tick-state";
import type { MappedLimitOrder, OrderStatus } from "./types";

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

export function getOrderbookActiveOrders({
orderbookAddress,
userOsmoAddress,
chainList,
baseAsset,
quoteAsset,
}: {
orderbookAddress: string;
userOsmoAddress: string;
chainList: Chain[];
baseAsset: ReturnType<typeof getAssetFromAssetList>;
quoteAsset: ReturnType<typeof getAssetFromAssetList>;
}) {
return cachified({
cache: activeOrdersCache,
key: `orderbookActiveOrders-${orderbookAddress}-${userOsmoAddress}`,
ttl: 500, // 2 seconds
getFreshValue: () =>
queryOrderbookActiveOrders({
orderbookAddress,
userAddress: userOsmoAddress,
chainList,
}).then(
async ({ data }: { data: { count: number; orders: LimitOrder[] } }) => {
const resp = await getTickInfoAndTransformOrders(
orderbookAddress,
data.orders,
chainList,
quoteAsset,
baseAsset
);
return resp;
}
),
});
}

function mapOrderStatus(order: LimitOrder, percentFilled: Dec): OrderStatus {
const quantInt = parseInt(order.quantity);
if (quantInt === 0 || percentFilled.equals(new Dec(1))) return "filled";
if (percentFilled.isZero()) return "open";
if (percentFilled.lt(new Dec(1))) return "partiallyFilled";

return "open";
}

async function getTickInfoAndTransformOrders(
orderbookAddress: string,
orders: LimitOrder[],
chainList: Chain[],
quoteAsset: ReturnType<typeof getAssetFromAssetList>,
baseAsset: ReturnType<typeof getAssetFromAssetList>
): Promise<MappedLimitOrder[]> {
if (orders.length === 0) return [];

const tickIds = [...new Set(orders.map((o) => o.tick_id))];

const [tickStates, unrealizedTickCancels] = await Promise.all([
getOrderbookTickState({
orderbookAddress,
chainList,
tickIds,
}),
getOrderbookTickUnrealizedCancels({
orderbookAddress,
chainList,
tickIds,
}),
]);

const fullTickState = tickStates.map(({ tick_id, tick_state }) => ({
tickId: tick_id,
tickState: tick_state,
unrealizedCancels: unrealizedTickCancels.find((c) => c.tick_id === tick_id),
}));

return orders.map((o) => {
const { tickState, unrealizedCancels } = fullTickState.find(
({ tickId }) => tickId === o.tick_id
) ?? { tickState: undefined, unrealizedCancels: undefined };

const quantity = parseInt(o.quantity);
const placedQuantity = parseInt(o.placed_quantity);

const percentClaimed = new Dec(
(placedQuantity - quantity) / placedQuantity
);

const normalizationFactor = new Dec(10).pow(
new Int((quoteAsset?.decimals ?? 0) - (baseAsset?.decimals ?? 0))
);
const [tickEtas, tickUnrealizedCancelled] =
o.order_direction === "bid"
? [
parseInt(
tickState?.bid_values.effective_total_amount_swapped ?? "0"
),
parseInt(
unrealizedCancels?.unrealized_cancels.bid_unrealized_cancels ??
"0"
),
]
: [
parseInt(
tickState?.ask_values.effective_total_amount_swapped ?? "0"
),
parseInt(
unrealizedCancels?.unrealized_cancels.ask_unrealized_cancels ??
"0"
),
];
const tickTotalEtas = tickEtas + tickUnrealizedCancelled;
const totalFilled = Math.max(
tickTotalEtas - (parseInt(o.etas) - (placedQuantity - quantity)),
0
);
const percentFilled = new Dec(Math.min(totalFilled / placedQuantity, 1));
const price = tickToPrice(new Int(o.tick_id));
const status = mapOrderStatus(o, percentFilled);
const output =
o.order_direction === "bid"
? new Dec(placedQuantity).quo(price)
: new Dec(placedQuantity).mul(price);
return {
...o,
price: price.quo(normalizationFactor),
quantity,
placed_quantity: placedQuantity,
percentClaimed,
totalFilled,
percentFilled,
orderbookAddress,
status,
output,
quoteAsset,
baseAsset,
placed_at: dayjs(parseInt(o.placed_at) / 1_000).unix(),
};
});
}
47 changes: 47 additions & 0 deletions packages/server/src/queries/complex/orderbooks/denoms.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { AssetList, Chain } from "@osmosis-labs/types";
import { getAssetFromAssetList } from "@osmosis-labs/utils";
import cachified, { CacheEntry } from "cachified";
import { LRUCache } from "lru-cache";

import { DEFAULT_LRU_OPTIONS } from "../../../utils/cache";
import { getOrderbookPools } from "./pools";

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

export function getOrderbookDenoms({
orderbookAddress,
assetLists,
}: {
orderbookAddress: string;
chainList: Chain[];
assetLists: AssetList[];
}) {
return cachified({
cache: orderbookDenomsCache,
key: `orderbookDenoms-${orderbookAddress}`,
ttl: 1000 * 60 * 60 * 24 * 30, // 30 days
swr: 1000 * 60 * 60 * 24 * 30, // 30 days
crnbarr93 marked this conversation as resolved.
Show resolved Hide resolved
staleRefreshTimeout: 1000 * 60 * 60 * 24 * 30, // 30 days
getFreshValue: () =>
getOrderbookPools().then((pools) => {
const pool = pools.find((p) => p.contractAddress === orderbookAddress);
if (!pool)
return {
quoteAsset: undefined,
baseAsset: undefined,
};
const quoteAsset = getAssetFromAssetList({
coinMinimalDenom: pool.quoteDenom,
assetLists,
});
const baseAsset = getAssetFromAssetList({
coinMinimalDenom: pool.baseDenom,
assetLists,
});

return { quoteAsset, baseAsset };
}),
});
}
Loading
Loading