Skip to content
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
9b423a6
refactor: remove unnecessary advance mode check
0xAlunara Nov 25, 2025
8c2ef57
refactor: remove unnecessary isRow differentiation
0xAlunara Nov 25, 2025
2d5c563
refactor: replace box and subtitle for mui stack and typography
0xAlunara Nov 25, 2025
f21ff13
refactor: convert loan parameters to actioninfos
0xAlunara Nov 25, 2025
fe4c898
refactor: convert lend parameters to actioninfos
0xAlunara Nov 25, 2025
9bf274e
refactor: add shared marketprices parameters component
0xAlunara Nov 25, 2025
185f56f
refactor: replace store with zustand for lend price per share
0xAlunara Nov 25, 2025
40a752b
refactor: remove unused market parameter
0xAlunara Nov 25, 2025
0936f22
refactor: inline query functions for readability
0xAlunara Nov 25, 2025
28b96a0
refactor: replace store with zustand for lend market parameters
0xAlunara Nov 25, 2025
79e7cb9
refactor: make MarketParameters more generic and move to llamalend
0xAlunara Nov 26, 2025
190ed51
refactor: remove all stacks from market parameter collections
0xAlunara Nov 26, 2025
6b2d166
feat: add back in price per share for lend market supply params
0xAlunara Nov 26, 2025
17c2bdf
feat: add market misc with id for devs
0xAlunara Nov 26, 2025
69750a2
Merge branch 'main' into refactor/market-advanced-details-prework
0xAlunara Nov 26, 2025
75a146d
Merge branch 'main' into refactor/market-advanced-details-prework
0xAlunara Nov 27, 2025
faa54bf
refactor: shorten code with ternary
0xAlunara Nov 27, 2025
b6d165c
feat: remove '?' as error value
0xAlunara Nov 27, 2025
fe55dbc
feat: action infos with error dont show value at all
0xAlunara Nov 27, 2025
c5ef672
feat: action info won't show error icon when it's (re)loading
0xAlunara Nov 27, 2025
c10f9db
refactor: inline MarketMisc
0xAlunara Nov 27, 2025
dcdc36a
refactor: create shared MarketParameters component for both mint and …
0xAlunara Nov 27, 2025
a19fd58
refactor: inline action infos for market loan parameters
0xAlunara Nov 27, 2025
542afdf
refactor: rename market-parameters to market-parameters.query
0xAlunara Nov 27, 2025
276d883
fix: forgot to update MarketParameters component in legacy borrow cre…
0xAlunara Nov 27, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@ import { ReactNode } from 'react'
import { zeroAddress } from 'viem'
import ChipInactive from '@/lend/components/ChipInactive'
import DetailInfoAddressLookup from '@/lend/components/DetailsMarket/components/DetailInfoAddressLookup'
import { SubTitle } from '@/lend/components/DetailsMarket/styles'
import TokenLabel from '@/lend/components/TokenLabel'
import { PageContentProps } from '@/lend/types/lend.types'
import Stack from '@mui/material/Stack'
import Typography from '@mui/material/Typography'
import Box from '@ui/Box'
import Chip from '@ui/Typography/Chip'
import { t } from '@ui-kit/lib/i18n'
import { SizesAndSpaces } from '@ui-kit/themes/design/1_sizes_spaces'

const { Spacing } = SizesAndSpaces

type ContractItems = { label: ReactNode; address: string | undefined; invalidText?: string }[]

Expand All @@ -31,8 +35,8 @@ const DetailsContracts = ({ rChainId, market }: Pick<PageContentProps, 'rChainId
]

return (
<>
<SubTitle>{t`Contracts`}</SubTitle>
<Stack gap={Spacing.xs}>
<Typography variant="headingXsBold">{t`Contracts`}</Typography>
<Box grid gridRowGap={3}>
{contracts.map((contracts, idx) => (
<div key={`contracts-${idx}`}>
Expand Down Expand Up @@ -61,7 +65,7 @@ const DetailsContracts = ({ rChainId, market }: Pick<PageContentProps, 'rChainId
</div>
))}
</Box>
</>
</Stack>
)
}

Expand Down

This file was deleted.

5 changes: 0 additions & 5 deletions apps/main/src/lend/components/DetailsMarket/styles.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import { styled } from 'styled-components'
import Box from '@ui/Box'

export const SubTitle = styled.h3`
font-size: var(--font-size-3);
margin-bottom: var(--spacing-1);
`

export type StatsProps = {
isBorderBottom?: boolean
isMultiLine?: boolean
Expand Down
13 changes: 5 additions & 8 deletions apps/main/src/lend/components/MarketInformationComp.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
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 { BandsChart } from '@/llamalend/features/bands-chart/BandsChart'
import { useBandsData } from '@/llamalend/features/bands-chart/hooks/useBandsData'
import { getBandsChartToken } from '@/llamalend/features/bands-chart/utils'
import { Stack, useTheme } from '@mui/material'
import { MarketParameters } from '@/llamalend/features/market-parameters/MarketParameters'
import { useTheme } from '@mui/material'
import Stack from '@mui/material/Stack'
import { getLib } from '@ui-kit/features/connect-wallet'
import { useUserProfileStore } from '@ui-kit/features/user-profile'
import { useNewBandsChart } from '@ui-kit/hooks/useFeatureFlags'
import { t } from '@ui-kit/lib/i18n'
import { SizesAndSpaces } from '@ui-kit/themes/design/1_sizes_spaces'

const { Spacing } = SizesAndSpaces
Expand Down Expand Up @@ -108,10 +107,8 @@ export const MarketInformationComp = ({
<Stack sx={{ flexGrow: 1, padding: Spacing.md }}>
<DetailsContracts rChainId={rChainId} market={market} />
</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>

<MarketParameters chainId={rChainId} marketId={rOwmId} marketType="lend" action={type} />
</Stack>
)}
</>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ReactNode, useCallback, useEffect, useRef, useState } from 'react'
import AlertFormError from '@/lend/components/AlertFormError'
import AlertLoanSummary from '@/lend/components/AlertLoanSummary'
import MarketParameters from '@/lend/components/DetailsMarket/components/MarketParameters'
import DialogFormWarning from '@/lend/components/DialogFormWarning'
import InpToken from '@/lend/components/InpToken'
import InpTokenBorrow from '@/lend/components/InpTokenBorrow'
Expand All @@ -20,8 +19,10 @@ import useStore from '@/lend/store/useStore'
import { Api, type MarketUrlParams, OneWayMarketTemplate, PageContentProps } from '@/lend/types/lend.types'
import { getLoanManagePathname } from '@/lend/utils/utilsRouter'
import { DEFAULT_HEALTH_MODE } from '@/llamalend/constants'
import { MarketParameters } from '@/llamalend/features/market-parameters/MarketParameters'
import type { HealthMode } from '@/llamalend/llamalend.types'
import { useLoanExists } from '@/llamalend/queries/loan-exists'
import Stack from '@mui/material/Stack'
import Accordion from '@ui/Accordion'
import AlertBox from '@ui/AlertBox'
import Box from '@ui/Box'
Expand Down Expand Up @@ -440,7 +441,9 @@ const LoanCreate = ({

{!isAdvancedMode && (
<Accordion btnLabel={<TextCaption isCaps isBold>{t`Market details`}</TextCaption>}>
<MarketParameters rChainId={rChainId} rOwmId={rOwmId} type="borrow" />
<Stack>
<MarketParameters chainId={rChainId} marketId={rOwmId} />
</Stack>
</Accordion>
)}
</>
Expand Down
97 changes: 30 additions & 67 deletions apps/main/src/lend/entities/market-details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,103 +8,66 @@ import type { MarketQuery, MarketParams } from '@ui-kit/lib/model/query/root-key

const getLendMarket = (marketId: string) => requireLib('llamaApi').getLendMarket(marketId)

type MarketCapAndAvailable = {
cap: number
available: number
}
type MarketMaxLeverage = {
maxLeverage: string | null
}
type MarketCollateralAmounts = {
collateralAmount: number
borrowedAmount: number
}

/**
* The purpose of this query is to allow fetching market collateral amounts on chain
* in order to display the most current data when a wallet is connected.
* */
const _getMarketCapAndAvailable = async ({ marketId }: MarketQuery): Promise<MarketCapAndAvailable> => {
const market = getLendMarket(marketId)
const capAndAvailable = await market.stats.capAndAvailable(false, USE_API)
return {
cap: +capAndAvailable.cap,
available: +capAndAvailable.available,
}
}

export const { useQuery: useMarketCapAndAvailable, invalidate: invalidateMarketCapAndAvailable } = queryFactory({
queryKey: (params: MarketParams) => [...rootKeys.market(params), 'marketCapAndAvailable', 'v1'] as const,
queryFn: _getMarketCapAndAvailable,
queryFn: async ({ marketId }: MarketQuery) => {
const market = getLendMarket(marketId)
const capAndAvailable = await market.stats.capAndAvailable(false, USE_API)
return {
cap: +capAndAvailable.cap,
available: +capAndAvailable.available,
}
},
refetchInterval: '1m',
validationSuite: marketIdValidationSuite,
})

/**
* The purpose of this query is to allow fetching market max leverage on chain
* in order to display the most current data when a wallet is connected.
* */
const _getMarketMaxLeverage = async ({ marketId }: MarketQuery): Promise<MarketMaxLeverage> => {
const market = getLendMarket(marketId)
const maxLeverage = market.leverage.hasLeverage() ? await market.leverage.maxLeverage(market?.minBands) : null
return { maxLeverage }
}

export const { useQuery: useMarketMaxLeverage } = queryFactory({
queryKey: (params: MarketParams) => [...rootKeys.market(params), 'marketMaxLeverage', 'v1'] as const,
queryFn: _getMarketMaxLeverage,
queryFn: async ({ marketId }: MarketQuery) => {
const market = getLendMarket(marketId)
const maxLeverage = market.leverage.hasLeverage() ? await market.leverage.maxLeverage(market?.minBands) : null
return { maxLeverage }
},
validationSuite: marketIdValidationSuite,
})

/**
* The purpose of this query is to allow fetching market collateral amounts on chain
* in order to display the most current data when a wallet is connected.
* */
const _getMarketCollateralAmounts = async ({ marketId }: MarketQuery): Promise<MarketCollateralAmounts> => {
const market = getLendMarket(marketId)
const ammBalance = await market.stats.ammBalances(false, USE_API)
return {
collateralAmount: +ammBalance.collateral,
borrowedAmount: +ammBalance.borrowed,
}
}

export const { useQuery: useMarketCollateralAmounts, invalidate: invalidateMarketCollateralAmounts } = queryFactory({
queryKey: (params: MarketParams) => [...rootKeys.market(params), 'marketCollateralAmounts', 'v1'] as const,
queryFn: _getMarketCollateralAmounts,
queryFn: async ({ marketId }: MarketQuery) => {
const market = getLendMarket(marketId)
const ammBalance = await market.stats.ammBalances(false, USE_API)
return {
collateralAmount: +ammBalance.collateral,
borrowedAmount: +ammBalance.borrowed,
}
},
refetchInterval: '1m',
validationSuite: marketIdValidationSuite,
})

const _fetchOnChainMarketRate = async ({ marketId }: MarketQuery) => ({
rates: await getLendMarket(marketId).stats.rates(false, false),
rewardsApr: await getLendMarket(marketId).vault.rewardsApr(false),
crvRates: await getLendMarket(marketId).vault.crvApr(false),
})

/**
* The purpose of this query is to allow fetching market parameters on chain
* in order to display the most current data when a wallet is connected.
* The api data can have a few minutes delay.
* */
export const { useQuery: useMarketOnChainRates, invalidate: invalidateMarketOnChainRates } = queryFactory({
queryKey: (params: MarketParams) => [...rootKeys.market(params), 'marketOnchainData', 'v1'] as const,
queryFn: _fetchOnChainMarketRate,
queryFn: async ({ marketId }: MarketQuery) => ({
rates: await getLendMarket(marketId).stats.rates(false, false),
rewardsApr: await getLendMarket(marketId).vault.rewardsApr(false),
crvRates: await getLendMarket(marketId).vault.crvApr(false),
}),
refetchInterval: '1m',
validationSuite: marketIdValidationSuite,
})

const _fetchMarketPricePerShare = async ({ marketId }: MarketQuery) => {
const market = getLendMarket(marketId)
return await market.vault.previewRedeem(1)
}

/**
* Fetches the price per share of a market on chain
*/
export const { useQuery: useMarketPricePerShare, invalidate: invalidateMarketPricePerShare } = queryFactory({
queryKey: (params: MarketParams) => [...rootKeys.market(params), 'marketPricePerShare', 'v1'] as const,
queryFn: _fetchMarketPricePerShare,
queryFn: async ({ marketId }: MarketQuery) => {
const market = getLendMarket(marketId)
return await market.vault.previewRedeem(1)
},
refetchInterval: '1m',
validationSuite: marketIdValidationSuite,
})
Expand Down
Loading
Loading