added tooltip
This commit is contained in:
parent
c95841863e
commit
aea44939b6
|
@ -15,6 +15,7 @@ import {
|
|||
} from '@blockworks-foundation/mango-v4'
|
||||
import useBankRates from 'hooks/useBankRates'
|
||||
import usePositions from 'hooks/usePositions'
|
||||
import Tooltip from './shared/Tooltip'
|
||||
|
||||
const set = mangoStore.getState().set
|
||||
|
||||
|
@ -55,9 +56,8 @@ const Positions = ({
|
|||
return (
|
||||
<>
|
||||
<div className="mb-2 flex items-center justify-between rounded-lg border-2 border-th-fgd-1 bg-th-bkg-1 px-6 py-3.5">
|
||||
<p className="font-medium">{`You have ${numberOfPositions} active position${
|
||||
numberOfPositions !== 1 ? 's' : ''
|
||||
}`}</p>
|
||||
<p className="font-medium">{`You have ${numberOfPositions} active position${numberOfPositions !== 1 ? 's' : ''
|
||||
}`}</p>
|
||||
<Switch
|
||||
checked={showInactivePositions}
|
||||
onChange={(checked) => setShowInactivePositions(checked)}
|
||||
|
@ -136,11 +136,12 @@ const PositionItem = ({
|
|||
return [liqRatio, liqPriceChangePercentage.toFixed(2)]
|
||||
}, [bank, borrowBalance, borrowBank, stakeBalance])
|
||||
|
||||
const { financialMetrics, stakeBankDepositRate } = useBankRates(
|
||||
const { financialMetrics, stakeBankDepositRate, borrowBankBorrowRate } = useBankRates(
|
||||
bank.name,
|
||||
leverage,
|
||||
)
|
||||
|
||||
|
||||
const APY_Daily_Compound = Math.pow(1 + Number(stakeBankDepositRate) / 365, 365) - 1;
|
||||
const uiRate = bank.name == 'USDC' ? APY_Daily_Compound * 100 : financialMetrics.APY
|
||||
|
||||
|
@ -187,20 +188,93 @@ const PositionItem = ({
|
|||
</div>
|
||||
<div>
|
||||
<p className="mb-1 text-th-fgd-4">Est. APY</p>
|
||||
<span className="text-xl font-bold text-th-fgd-1">
|
||||
<FormatNumericValue value={Number(uiRate)} decimals={2} />%
|
||||
</span>
|
||||
{bank.name !== 'USDC' ?
|
||||
<Tooltip content={
|
||||
<div className='rounded-2xl border-2 border-th-fgd-1 bg-th-bkg-1 p-6 '>
|
||||
<h4 className="mb-4 border-b border-th-bkg-3 pb-2 text-sm">
|
||||
Rates and Fees
|
||||
</h4>
|
||||
<div className="space-y-2 md:px-3">
|
||||
<div className="flex justify-between">
|
||||
<p className="text-th-fgd-4">
|
||||
{formatTokenSymbol(bank.name)} Yield APY
|
||||
</p>
|
||||
<span className="font-bold text-th-success">
|
||||
{financialMetrics.collectedReturnsAPY > 0.01
|
||||
? '+'
|
||||
: ''}
|
||||
<FormatNumericValue
|
||||
value={financialMetrics.collectedReturnsAPY}
|
||||
decimals={2}
|
||||
/>
|
||||
%
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex justify-between">
|
||||
<p className="text-th-fgd-4 mr-10">
|
||||
{formatTokenSymbol(bank.name)} Collateral Fee
|
||||
APY
|
||||
</p>
|
||||
<span
|
||||
className={`font-bold ${financialMetrics?.collateralFeeAPY > 0.01
|
||||
? 'text-th-error'
|
||||
: 'text-th-bkg-4'
|
||||
}`}
|
||||
>
|
||||
{financialMetrics?.collateralFeeAPY > 0.01
|
||||
? '-'
|
||||
: ''}
|
||||
<FormatNumericValue
|
||||
value={financialMetrics?.collateralFeeAPY?.toString()}
|
||||
decimals={2}
|
||||
/>
|
||||
%
|
||||
</span>
|
||||
</div>
|
||||
{borrowBank ? (
|
||||
<>
|
||||
<div className="flex justify-between">
|
||||
<p className="text-th-fgd-4">{`${borrowBank?.name} Borrow APY`}</p>
|
||||
<span
|
||||
className={`font-bold ${borrowBankBorrowRate > 0.01
|
||||
? 'text-th-error'
|
||||
: 'text-th-bkg-4'
|
||||
}`}
|
||||
>
|
||||
-
|
||||
<FormatNumericValue
|
||||
value={financialMetrics.borrowsAPY}
|
||||
decimals={2}
|
||||
/>
|
||||
%
|
||||
</span>
|
||||
</div>
|
||||
</>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
</div>}>
|
||||
<span className="tooltip-underline text-xl font-bold text-th-fgd-1">
|
||||
<FormatNumericValue value={Number(uiRate)} decimals={2} />%
|
||||
</span>
|
||||
</Tooltip>
|
||||
:
|
||||
<>
|
||||
<span className="text-xl font-bold text-th-fgd-1">
|
||||
<FormatNumericValue value={Number(uiRate)} decimals={2} />%
|
||||
</span>
|
||||
</>
|
||||
}
|
||||
</div>
|
||||
<div>
|
||||
<p className="mb-1 text-th-fgd-4">Total Earned</p>
|
||||
<span
|
||||
className={`text-xl font-bold ${
|
||||
!stakeBalance
|
||||
? 'text-th-fgd-4'
|
||||
: pnl >= 0
|
||||
className={`text-xl font-bold ${!stakeBalance
|
||||
? 'text-th-fgd-4'
|
||||
: pnl >= 0
|
||||
? 'text-th-success'
|
||||
: 'text-th-error'
|
||||
}`}
|
||||
}`}
|
||||
>
|
||||
{stakeBalance || pnl ? (
|
||||
<FormatNumericValue value={pnl} decimals={2} isUsd />
|
||||
|
|
|
@ -35,8 +35,8 @@ const Tooltip = ({
|
|||
content={
|
||||
content ? (
|
||||
<div
|
||||
className={`${themeData.fonts.body.variable} ${themeData.fonts.display.variable} font-sans font-sans rounded-md bg-th-bkg-2 p-3 font-body text-xs leading-4 text-th-fgd-3 outline-none focus:outline-none ${className}`}
|
||||
style={{ boxShadow: '0px 0px 8px 0px rgba(0,0,0,0.25)' }}
|
||||
className={`${themeData.fonts.body.variable} ${themeData.fonts.display.variable} font-sans font-sans font-body text-xs leading-4 text-th-fgd-3 outline-none focus:outline-none ${className}`}
|
||||
style={{ boxShadow: '0px 0px 0px 0px rgba(0,0,0,0)' }}
|
||||
>
|
||||
{content}
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue