Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion apps/main/src/lend/hooks/useBorrowPositionDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export const useBorrowPositionDetails = ({
},
borrowAPY: {
rate: borrowApy == null ? null : Number(borrowApy),
averageRate: averageRate,
averageRate,
averageRateLabel: averageMultiplierString,
rebasingYield: rebasingYield ?? null,
averageRebasingYield: averageRebasingYield ?? null,
Expand Down
7 changes: 5 additions & 2 deletions apps/main/src/llamalend/entities/llama-markets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ export type LlamaMarket = {
lendTotalApyMaxBoosted: number | null // supply rate + rebasing yield + total extra incentives + max boosted yield
borrowApy: number // base borrow APY %
borrowTotalApy: number // borrow - yield from collateral
// extra lending incentives, like OP rewards (so non CRV)
incentives: ExtraIncentive[]
borrowFutureRate: number | null
incentives: ExtraIncentive[] // extra lending incentives, like OP rewards (so non CRV)
}
type: LlamaMarketType
url: string
Expand Down Expand Up @@ -159,6 +159,7 @@ const convertLendingVault = (
lendTotalApyMaxBoosted:
lendApr + (borrowedToken?.rebasingYield ?? 0) + totalExtraRewardApr + (lendCrvAprBoosted ?? 0),
borrowApy: apyBorrow,
borrowFutureRate: null, // not available for lend markets
// as confusing as it may be, `borrow` is used in the table, but the total borrow is only in the tooltip
borrowTotalApy: apyBorrow - (collateralToken?.rebasingYield ?? 0),
incentives: extraRewardApr
Expand Down Expand Up @@ -203,6 +204,7 @@ const convertMintMarket = (
stablecoinToken,
llamma,
rate,
futureRate,
borrowed,
borrowedUsd,
borrowable,
Expand Down Expand Up @@ -250,6 +252,7 @@ const convertMintMarket = (
totalCollateralUsd: collateralAmountUsd,
rates: {
borrowApy: rate * 100,
borrowFutureRate: futureRate * 100,
lendApr: null,
lendCrvAprBoosted: null,
lendCrvAprUnboosted: null,
Expand Down
2 changes: 2 additions & 0 deletions apps/main/src/llamalend/features/market-details/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type BorrowToken = {
}
type BorrowAPY = {
rate: number | undefined | null
futureRate?: number | null
averageRate: number | undefined | null
averageRateLabel: string
rebasingYield: number | null
Expand Down Expand Up @@ -155,6 +156,7 @@ export const MarketDetails = ({
<MarketBorrowRateTooltipContent
marketType={marketType}
borrowRate={borrowAPY?.rate}
borrowFutureRate={borrowAPY?.futureRate}
totalBorrowRate={borrowAPY?.totalBorrowRate}
totalAverageBorrowRate={borrowAPY?.totalAverageBorrowRate}
averageRate={borrowAPY?.averageRate}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { LlamaMarket } from '@/llamalend/entities/llama-markets'
import ArrowForwardIcon from '@mui/icons-material/ArrowForward'
import Box from '@mui/material/Box'
import Stack from '@mui/material/Stack'
import Typography from '@mui/material/Typography'
Expand All @@ -12,7 +13,7 @@ import { RewardsIcons } from './RewardsIcons'
import { SupplyRateLendTooltip } from './SupplyRateLendTooltip'
import { SupplyRateMintTooltip } from './SupplyRateMintTooltip'

const { Spacing } = SizesAndSpaces
const { Spacing, IconSize } = SizesAndSpaces

const RateTypes = {
[LlamaMarketColumnId.LendRate]: MarketRateType.Supply,
Expand Down Expand Up @@ -47,6 +48,18 @@ export const RateCell = ({
<Stack gap={Spacing.xs} alignItems="end">
<Typography variant="tableCellMBold" color="textPrimary">
{rate == null ? '—' : formatPercent(rate)}
{id === LlamaMarketColumnId.BorrowRate && market.rates.borrowFutureRate && (
<>
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd make this a <Stack direction="row" alignItems='center' gap={Spacing.xs}> (I guessed the spacing, maybe more or less looks better)

Looks kinda funky without
Image

<ArrowForwardIcon
sx={{
width: IconSize.sm,
height: IconSize.sm,
color: (t) => t.palette.text.tertiary,
}}
/>
{formatPercent(market.rates.borrowFutureRate)}
</>
)}
</Typography>

<RewardsIcons market={market} rateType={rateType} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export type Pnl = {
export type Health = { value: number | undefined | null; loading: boolean }
export type BorrowAPY = {
rate: number | undefined | null
futureRate?: number | null
averageRate: number | undefined | null
averageRateLabel: string
rebasingYield: number | null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { RewardsTooltipItems } from './RewardTooltipItems'
export type MarketBorrowRateTooltipContentProps = {
marketType: LlamaMarketType
borrowRate: number | null | undefined
borrowFutureRate?: number | null
totalBorrowRate: number | null | undefined
totalAverageBorrowRate: number | null | undefined
averageRate: number | null | undefined
Expand All @@ -32,6 +33,7 @@ const messages: Record<LlamaMarketType, string> = {
export const MarketBorrowRateTooltipContent = ({
marketType,
borrowRate,
borrowFutureRate,
totalBorrowRate,
totalAverageBorrowRate,
averageRate,
Expand All @@ -56,11 +58,17 @@ export const MarketBorrowRateTooltipContent = ({
</TooltipItem>
</TooltipItems>

{borrowFutureRate && (
<TooltipItems secondary>
<TooltipItem title={t`Future borrow rate`}>{formatPercent(borrowFutureRate)}</TooltipItem>
</TooltipItems>
)}

{extraRewards.length > 0 && (
<TooltipItems secondary>
<RewardsTooltipItems
title={t`Borrowing incentives`}
tooltipType={'borrow'}
tooltipType="borrow"
extraRewards={extraRewards}
extraIncentives={[]}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const MarketBorrowRateTooltipWrapper = ({ market }: MarketBorrowRateToolt
const {
rewards,
type: marketType,
rates: { borrowApy: borrowRate, borrowTotalApy },
rates: { borrowApy: borrowRate, borrowTotalApy, borrowFutureRate },
assets: {
collateral: { rebasingYield, symbol: collateralSymbol },
},
Expand All @@ -24,6 +24,7 @@ export const MarketBorrowRateTooltipWrapper = ({ market }: MarketBorrowRateToolt
<MarketBorrowRateTooltipContent
marketType={marketType}
borrowRate={borrowRate}
borrowFutureRate={borrowFutureRate}
averageRate={averageRate}
periodLabel={period}
totalBorrowRate={borrowTotalApy}
Expand Down
16 changes: 7 additions & 9 deletions apps/main/src/loan/components/PageLoanCreate/Page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,13 @@ const Page = () => {
)}
<Stack>
<MarketDetails {...marketDetails} />
{
<MarketInformationComp
llamma={market ?? null}
llammaId={marketId}
chainId={rChainId}
chartExpanded={chartExpanded}
page="create"
/>
}
<MarketInformationComp
llamma={market ?? null}
llammaId={marketId}
chainId={rChainId}
chartExpanded={chartExpanded}
page="create"
/>
</Stack>
</Stack>
</DetailPageStack>
Expand Down
1 change: 1 addition & 0 deletions apps/main/src/loan/hooks/useLoanPositionDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export const useLoanPositionDetails = ({
},
borrowAPY: {
rate: loanDetails?.parameters?.rate ? Number(loanDetails?.parameters?.rate) : null,
futureRate: loanDetails?.parameters?.future_rate ? Number(loanDetails?.parameters?.future_rate) : null,
rebasingYield: collateralRebasingYield ?? null,
averageRate: averageRate,
averageRebasingYield: averageRebasingYield ?? null,
Expand Down
7 changes: 4 additions & 3 deletions apps/main/src/loan/hooks/useMarketDetails.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { last } from 'lodash'
import { useMemo } from 'react'
import type { MarketDetailsProps } from '@/llamalend/features/market-details'
import { CRVUSD_ADDRESS } from '@/loan/constants'
Expand Down Expand Up @@ -78,15 +79,15 @@ export const useMarketDetails = ({ chainId, llamma, llammaId }: UseMarketDetails
},
borrowAPY: {
rate: loanDetails?.parameters?.rate ? Number(loanDetails?.parameters?.rate) : null,
futureRate: loanDetails?.parameters?.future_rate ? Number(loanDetails?.parameters?.future_rate) : null,
averageRate: averageRate,
averageRateLabel: averageMultiplierString,
rebasingYield: crvUsdSnapshots?.[crvUsdSnapshots.length - 1]?.collateralToken.rebasingYield ?? null,
rebasingYield: last(crvUsdSnapshots)?.collateralToken.rebasingYield ?? null,
Copy link
Collaborator

Choose a reason for hiding this comment

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

May I introduce you to our lord and savior crvUsdSnapshots.at(-1)

averageRebasingYield: averageRebasingYield ?? null,
totalAverageBorrowRate,
extraRewards: campaigns,
totalBorrowRate: loanDetails?.parameters?.rate
? Number(loanDetails?.parameters?.rate) -
(crvUsdSnapshots?.[crvUsdSnapshots.length - 1]?.collateralToken.rebasingYield ?? 0)
? Number(loanDetails?.parameters?.rate) - (last(crvUsdSnapshots)?.collateralToken.rebasingYield ?? 0)
: null,
loading: isSnapshotsLoading || (loanDetails?.loading ?? true),
},
Expand Down
1 change: 1 addition & 0 deletions packages/prices-api/src/crvusd/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export type Market = {
factoryAddress: Address
llamma: Address
rate: number
futureRate: number
borrowed: number
borrowedUsd: number
borrowable: number
Expand Down
1 change: 1 addition & 0 deletions packages/prices-api/src/crvusd/parsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const parseMarket = (x: Responses.GetMarketsResponse['data'][number]): Mo
factoryAddress: x.factory_address,
llamma: x.llamma,
rate: x.rate,
futureRate: x.future_rate,
borrowed: x.total_debt,
borrowedUsd: x.total_debt_usd,
borrowable: x.borrowable,
Expand Down
1 change: 1 addition & 0 deletions packages/prices-api/src/crvusd/responses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export type GetMarketsResponse = {
factory_address: Address
llamma: Address
rate: number
future_rate: number
total_debt: number
total_debt_usd: number
n_loans: number
Expand Down