-
Notifications
You must be signed in to change notification settings - Fork 39
feat: new position details on crvusd/lend #1097
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
Open
OnlyJousting
wants to merge
91
commits into
main
Choose a base branch
from
feat/new-lending-position-details
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,910
−264
Open
Changes from all commits
Commits
Show all changes
91 commits
Select commit
Hold shift + click to select a range
62ea26d
refactor: integrate i18n for PegKeeperStatistics labels
OnlyJousting 49a1627
Merge branch 'main' into feat/new-lending-position-details
OnlyJousting e4b7725
Merge branch 'main' into feat/new-lending-position-details
OnlyJousting a7efca0
feat: init position details
OnlyJousting eb972d7
feat: add support for number[] in Metric
OnlyJousting cf8bed1
feat: set up borrow information for crvUSD
OnlyJousting b9055d0
refactor: assemble position details in own wrapper
OnlyJousting d5bdbd7
feat: init position details on lend
OnlyJousting 8962392
Merge branch 'main' into feat/new-lending-position-details
OnlyJousting 965d509
styling: tweak healthbar
OnlyJousting 6595129
fix: lend average rate calculation
OnlyJousting 9bc2e3f
feat: add soft-liquidation warning
OnlyJousting bfc190d
feat: add the option to hide the metric components tooltip
OnlyJousting e33bdb9
feat: init collateral metric tooltip
OnlyJousting 4c7e9ac
feat: collateral metric tooltip
OnlyJousting 7817109
refactor: remove 'liquidation-range' metric
OnlyJousting f96f0f8
refactor: revert changes to Metric component to support an array of v…
OnlyJousting a5b14ba
Merge branch 'main' into feat/new-lending-position-details
OnlyJousting a23db23
refactor: update metric component usage according to Metric changes
OnlyJousting d402ab0
fix: enable copy on click when hideTooltip is true
OnlyJousting 1ac700e
refactor: handle custom metric tooltips
OnlyJousting 866a1cf
feat: added liquidation threshold metric tooltip
OnlyJousting 0bc6a82
feat: add pnl tooltip
OnlyJousting c9a4feb
feat: set up rate
OnlyJousting c72eb46
Merge branch 'main' into feat/new-lending-position-details
OnlyJousting 3054c48
feat: set crvusd rate loading state
OnlyJousting 554d954
Merge branch 'main' into feat/new-lending-position-details
OnlyJousting 70fa6d6
Merge branch 'main' into feat/new-lending-position-details
OnlyJousting 46fc2ec
feat: add range to liquidation
OnlyJousting 7e8f442
feat: only show new position details on beta
OnlyJousting d181804
refactor: set PositionDetails props in hooks
OnlyJousting d449413
refactor: move lending snapshots hook to ui-kit
OnlyJousting 52d3c33
fix: remove unintended changes to Metric
OnlyJousting f23a6a0
refactor: apply review comments
OnlyJousting 0e9758e
fix: update market and llamma props to allow null values
OnlyJousting aa6b83b
fix: update import path for getSnapshots in useLendingSnapshots and a…
OnlyJousting da58a5a
refactor: remove app switches
OnlyJousting 49885ff
Merge branch 'main' into feat/new-lending-position-details
OnlyJousting 02dcede
refactor: adopt changes to metric component
OnlyJousting a61d4f2
feat: set health value color based on current health
OnlyJousting ba61d43
fix: remove redundant abbreviation setting in BorrowInformation compo…
OnlyJousting 48f40ca
refactor: rename borrowRate to borrowAPR for consistency across compo…
OnlyJousting a4b6049
refactor: update BorrowInformation Metric labels capitalization
OnlyJousting 6b45b1c
feat: new market details for loan
OnlyJousting 136b85e
Merge branch 'main' into feat/new-lending-position-details
OnlyJousting 3e3a6c5
refactor: use lending-snapshots from llamalend directory
OnlyJousting 91d417d
Revert "refactor: use lending-snapshots from llamalend directory"
OnlyJousting 1867f98
refactor: move lend and crvusd snapshots queries to ui-kit
OnlyJousting 3db86e9
feat: init new lend market details
OnlyJousting 0e59dde
refactor: stop using default import and rename to BorrowPositionDetails
OnlyJousting c21391c
feat: init lendPositionDetails
OnlyJousting e8913c0
Merge branch 'main' into feat/new-lending-position-details
OnlyJousting e724f5d
feat: finalise lendPositionDetails
OnlyJousting fd504c7
feat: init new market position and details section layout
OnlyJousting 94eacaf
feat: init beta layout
OnlyJousting 58ea2d2
Merge branch 'main' into feat/new-lending-position-details
OnlyJousting b0548c9
feat: prepare new lend market information section
OnlyJousting 58d0d18
Merge branch 'main' into feat/new-lending-position-details
OnlyJousting cacf408
feat: add menu to toggle between position and market bands
OnlyJousting 7690cfe
feat: match health value color with bar colors
OnlyJousting 88755cb
feat: wire up /create, /manage, /vault on lend
OnlyJousting f6fdfb3
fix: use apy rather then apr when displaying supply rates
OnlyJousting 93006b5
fix: lend chart expanded view
OnlyJousting c9c6c06
Merge branch 'main' into feat/new-lending-position-details
OnlyJousting 4eac47c
feat: add userLoanDetails and capAndAvailable queries
OnlyJousting d18cb21
Merge branch 'feat/new-lending-position-details' of https://github.co…
OnlyJousting e652997
fix: remove removed MarketDetails prop from vault
OnlyJousting faefa21
fix: pnl tooltip values
OnlyJousting 8780baa
feat: add user-market-balances query and invalidate queries on vault …
OnlyJousting 7517ba3
Merge branch 'main' into feat/new-lending-position-details
OnlyJousting 5ebd9bf
feat: invalidate queries after create or manage actions
OnlyJousting bcd8e67
refactor: aggregate invalidate user queries on actions
OnlyJousting 5af4ee3
refactor: consolidate market-related queries into market-details enti…
OnlyJousting a1c5b4f
Merge branch 'main' into feat/new-lending-position-details
OnlyJousting 257610f
feat: implement new layout for crvusd on /create and /manage in beta
OnlyJousting af34847
Merge branch 'main' into feat/new-lending-position-details
OnlyJousting 239c14c
refactor: add userAddress to user-loan-details query params
OnlyJousting c36d407
Merge branch 'feat/new-lending-position-details' of https://github.co…
OnlyJousting 75a136e
styling: set up small screen breakpoints
OnlyJousting 4299624
Merge branch 'main' into feat/new-lending-position-details
OnlyJousting 56385d3
refactor: set unavailable notation in variables
OnlyJousting f177fe0
Merge branch 'feat/new-lending-position-details' of https://github.co…
OnlyJousting 00c110d
feat: add "no position" component
OnlyJousting b680f4c
styling: update text color
OnlyJousting 98e478d
styling: loan app media queries
OnlyJousting 65fd65a
feat: add max leverage query to loan
OnlyJousting 059dd70
styling: borrow position wrapper div in loan
OnlyJousting dabb533
Merge branch 'main' into feat/new-lending-position-details
OnlyJousting 9fd3258
refactor: review comments
OnlyJousting f6ba383
refactor: use two decimals for percentage metrics
OnlyJousting 74db851
feat: add hard liquidation alert
OnlyJousting File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { useState } from 'react' | ||
import { styled } from 'styled-components' | ||
import DetailsLoanChartBalances from '@/lend/components/DetailsMarket/components/DetailsLoanChartBalances' | ||
import DetailsUserLoanChartBandBalances from '@/lend/components/DetailsUser/components/DetailsUserLoanChartBandBalances' | ||
import { PageContentProps } from '@/lend/types/lend.types' | ||
import { Stack } from '@mui/material' | ||
import Button from '@ui/Button' | ||
import { t } from '@ui-kit/lib/i18n' | ||
|
||
type BandsCompProps = { | ||
pageProps: PageContentProps | ||
page: 'create' | 'manage' | ||
loanExists: boolean | ||
} | ||
|
||
export const BandsComp = ({ pageProps, page, loanExists }: BandsCompProps) => { | ||
const { rChainId, rOwmId, market } = pageProps | ||
const [selectedBand, setSelectedBand] = useState<'user' | 'market'>(page === 'create' ? 'market' : 'user') | ||
|
||
const SelectorMenu = | ||
page === 'create' ? null : ( | ||
<SelectorRow> | ||
<SelectorButton | ||
variant="text" | ||
className={selectedBand === 'user' ? 'active' : ''} | ||
onClick={() => setSelectedBand('user')} | ||
> | ||
{t`Position Bands`} | ||
</SelectorButton> | ||
<SelectorButton | ||
variant="text" | ||
className={selectedBand === 'market' ? 'active' : ''} | ||
onClick={() => setSelectedBand('market')} | ||
> | ||
{t`Market Bands`} | ||
</SelectorButton> | ||
</SelectorRow> | ||
) | ||
|
||
return ( | ||
<Stack> | ||
{selectedBand === 'user' && loanExists && ( | ||
<DetailsUserLoanChartBandBalances {...pageProps} selectorMenu={SelectorMenu} /> | ||
)} | ||
{(selectedBand === 'market' || !loanExists) && ( | ||
<DetailsLoanChartBalances | ||
rChainId={rChainId} | ||
rOwmId={rOwmId} | ||
market={market} | ||
selectorMenu={loanExists ? SelectorMenu : undefined} | ||
/> | ||
)} | ||
</Stack> | ||
) | ||
} | ||
|
||
const SelectorRow = styled.div` | ||
OnlyJousting marked this conversation as resolved.
Show resolved
Hide resolved
|
||
display: flex; | ||
flex-direction: row; | ||
margin-bottom: var(--spacing-2); | ||
` | ||
|
||
const SelectorButton = styled(Button)` | ||
color: inherit; | ||
font: var(--font); | ||
font-size: var(--font-size-2); | ||
font-weight: bold; | ||
text-transform: none; | ||
opacity: 0.7; | ||
&.active { | ||
opacity: 1; | ||
border-bottom: 2px solid var(--page--text-color); | ||
} | ||
` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import { BandsComp } from '@/lend/components/BandsComp' | ||
import ChartOhlcWrapper from '@/lend/components/ChartOhlcWrapper' | ||
import DetailsContracts from '@/lend/components/DetailsMarket/components/DetailsContracts' | ||
import MarketParameters from '@/lend/components/DetailsMarket/components/MarketParameters' | ||
import { SubTitle } from '@/lend/components/DetailsMarket/styles' | ||
import networks from '@/lend/networks' | ||
import { PageContentProps } from '@/lend/types/lend.types' | ||
import { Stack, useTheme } from '@mui/material' | ||
import { useUserProfileStore } from '@ui-kit/features/user-profile' | ||
import { t } from '@ui-kit/lib/i18n' | ||
import { SizesAndSpaces } from '@ui-kit/themes/design/1_sizes_spaces' | ||
|
||
const { Spacing } = SizesAndSpaces | ||
|
||
type MarketInformationCompProps = { | ||
pageProps: PageContentProps | ||
chartExpanded: boolean | ||
loanExists?: boolean | ||
userActiveKey: string | ||
type: 'borrow' | 'supply' | ||
page?: 'create' | 'manage' | ||
} | ||
|
||
/** | ||
* Reusable component for OHLC charts, Bands (if applicable), and market parameters. For /create, /manage, /vault pages. | ||
*/ | ||
export const MarketInformationComp = ({ | ||
pageProps, | ||
chartExpanded, | ||
loanExists = false, | ||
userActiveKey, | ||
type, | ||
page = 'manage', | ||
}: MarketInformationCompProps) => { | ||
const { rChainId, rOwmId, market } = pageProps | ||
const theme = useTheme() | ||
const isAdvancedMode = useUserProfileStore((state) => state.isAdvancedMode) | ||
|
||
return ( | ||
<> | ||
{networks[rChainId]?.pricesData && !chartExpanded && ( | ||
<Stack sx={{ backgroundColor: (t) => t.design.Layer[1].Fill, gap: Spacing.md, padding: Spacing.md }}> | ||
<ChartOhlcWrapper | ||
rChainId={rChainId} | ||
rOwmId={rOwmId} | ||
userActiveKey={userActiveKey} | ||
betaBackgroundColor={theme.design.Layer[1].Fill} | ||
/> | ||
</Stack> | ||
)} | ||
{type === 'borrow' && isAdvancedMode && ( | ||
<Stack sx={{ backgroundColor: (t) => t.design.Layer[1].Fill, gap: Spacing.md, padding: Spacing.md }}> | ||
OnlyJousting marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<BandsComp pageProps={pageProps} page={page} loanExists={loanExists} /> | ||
</Stack> | ||
)} | ||
{market && isAdvancedMode && ( | ||
<Stack | ||
sx={{ | ||
backgroundColor: (t) => t.design.Layer[1].Fill, | ||
flexDirection: 'column', | ||
// 1100px | ||
'@media (min-width: 68.75rem)': { | ||
OnlyJousting marked this conversation as resolved.
Show resolved
Hide resolved
|
||
flexDirection: 'row', | ||
}, | ||
}} | ||
> | ||
<Stack sx={{ flexGrow: 1, padding: Spacing.md }}> | ||
<DetailsContracts rChainId={rChainId} market={market} type={type} /> | ||
</Stack> | ||
<Stack sx={{ backgroundColor: (t) => t.design.Layer[2].Fill, padding: Spacing.md, minWidth: '18.75rem' }}> | ||
<SubTitle>{t`Parameters`}</SubTitle> | ||
<MarketParameters rChainId={rChainId} rOwmId={rOwmId} type={type} /> | ||
</Stack> | ||
</Stack> | ||
)} | ||
</> | ||
) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { ReactNode, useState } from 'react' | ||
import { Box } from '@mui/material' | ||
import { t } from '@ui-kit/lib/i18n' | ||
import { TabsSwitcher } from '@ui-kit/shared/ui/TabsSwitcher' | ||
|
||
type TabValue = 'borrow' | 'lend' | ||
|
||
type MarketInformationTabsProps = { | ||
currentTab: TabValue | ||
hrefs: { | ||
borrow: string | ||
lend: string | ||
} | ||
children: ReactNode | ||
} | ||
|
||
/** | ||
* Used in Lend markets to compose with PositionDetails if there is a user position (borrow or supply) | ||
* for this market or with MarketDetails if there is no user position. | ||
*/ | ||
export const MarketInformationTabs = ({ currentTab, hrefs, children }: MarketInformationTabsProps) => { | ||
const TABS: { value: TabValue; label: string; href: string }[] = [ | ||
{ value: 'borrow', label: t`Borrow`, href: hrefs.borrow }, | ||
{ value: 'lend', label: t`Lend`, href: hrefs.lend }, | ||
] | ||
const [tab, setTab] = useState<TabValue>(currentTab) | ||
|
||
return ( | ||
<Box> | ||
<TabsSwitcher value={tab} onChange={setTab} variant="contained" size="small" options={TABS} /> | ||
<Box sx={{ backgroundColor: (t) => t.design.Layer[1].Fill }}>{children}</Box> | ||
OnlyJousting marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</Box> | ||
) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.