User feedback (#575)
* feat: added debt indicator and adjusted the borrowModal * fix: wallet interaction fix
This commit is contained in:
parent
29169f14f9
commit
d0d87e75e2
@ -64,6 +64,7 @@ export default function Index(props: Props) {
|
|||||||
return (
|
return (
|
||||||
<Text size='xs'>
|
<Text size='xs'>
|
||||||
{row.original.symbol}
|
{row.original.symbol}
|
||||||
|
{row.original.type === 'borrowing' && <span className='ml-1 text-loss'>(debt)</span>}
|
||||||
{row.original.type === 'lending' && <span className='ml-1 text-profit'>(lent)</span>}
|
{row.original.type === 'lending' && <span className='ml-1 text-profit'>(lent)</span>}
|
||||||
{row.original.type === 'vault' && <span className='ml-1 text-profit'>(farm)</span>}
|
{row.original.type === 'vault' && <span className='ml-1 text-profit'>(farm)</span>}
|
||||||
</Text>
|
</Text>
|
||||||
|
@ -24,7 +24,7 @@ import { getDepositAndLendCoinsToSpend } from 'hooks/useUpdatedAccount/functions
|
|||||||
import useStore from 'store'
|
import useStore from 'store'
|
||||||
import { BNCoin } from 'types/classes/BNCoin'
|
import { BNCoin } from 'types/classes/BNCoin'
|
||||||
import { byDenom } from 'utils/array'
|
import { byDenom } from 'utils/array'
|
||||||
import { formatPercent, formatValue } from 'utils/formatters'
|
import { formatPercent } from 'utils/formatters'
|
||||||
import { BN } from 'utils/helpers'
|
import { BN } from 'utils/helpers'
|
||||||
import { getDebtAmountWithInterest } from 'utils/tokens'
|
import { getDebtAmountWithInterest } from 'utils/tokens'
|
||||||
|
|
||||||
@ -204,15 +204,32 @@ function BorrowModal(props: Props) {
|
|||||||
title={formatPercent(modal.marketData.borrowRate || '0')}
|
title={formatPercent(modal.marketData.borrowRate || '0')}
|
||||||
sub={'Borrow rate'}
|
sub={'Borrow rate'}
|
||||||
/>
|
/>
|
||||||
|
{totalDebt.isGreaterThan(0) && (
|
||||||
|
<>
|
||||||
<div className='h-100 w-[1px] bg-white/10' />
|
<div className='h-100 w-[1px] bg-white/10' />
|
||||||
<TitleAndSubCell
|
<div className='flex flex-col gap-0.5'>
|
||||||
title={formatValue(getDebtAmount(modal), {
|
<div className='flex gap-2'>
|
||||||
abbreviated: false,
|
<FormattedNumber
|
||||||
|
className='text-xs'
|
||||||
|
amount={totalDebt.toNumber()}
|
||||||
|
options={{
|
||||||
decimals: asset.decimals,
|
decimals: asset.decimals,
|
||||||
maxDecimals: asset.decimals,
|
abbreviated: false,
|
||||||
})}
|
suffix: ` ${asset.symbol}`,
|
||||||
sub={'Borrowed'}
|
}}
|
||||||
/>
|
/>
|
||||||
|
<DisplayCurrency
|
||||||
|
className='text-xs'
|
||||||
|
coin={BNCoin.fromDenomAndBigNumber(asset.denom, totalDebt)}
|
||||||
|
parentheses
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<Text size='xs' className='text-white/50' tag='span'>
|
||||||
|
Borrowed
|
||||||
|
</Text>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
<div className='h-100 w-[1px] bg-white/10' />
|
<div className='h-100 w-[1px] bg-white/10' />
|
||||||
<div className='flex flex-col gap-0.5'>
|
<div className='flex flex-col gap-0.5'>
|
||||||
<div className='flex gap-2'>
|
<div className='flex gap-2'>
|
||||||
|
@ -61,9 +61,15 @@ export default function WalletConnectedButton() {
|
|||||||
}, [network, address])
|
}, [network, address])
|
||||||
|
|
||||||
const onDisconnectWallet = () => {
|
const onDisconnectWallet = () => {
|
||||||
if (!currentWallet) return
|
if (currentWallet) disconnectWallet(currentWallet)
|
||||||
disconnectWallet(currentWallet)
|
|
||||||
useStore.setState({ client: undefined, address: undefined, accounts: null, balances: [] })
|
useStore.setState({
|
||||||
|
client: undefined,
|
||||||
|
address: undefined,
|
||||||
|
accounts: null,
|
||||||
|
balances: [],
|
||||||
|
focusComponent: null,
|
||||||
|
})
|
||||||
|
|
||||||
if (focusComponent) {
|
if (focusComponent) {
|
||||||
useStore.setState({
|
useStore.setState({
|
||||||
|
@ -11,11 +11,10 @@ export default function Wallet() {
|
|||||||
const { disconnectWallet } = useShuttle()
|
const { disconnectWallet } = useShuttle()
|
||||||
const currentWallet = useCurrentWallet()
|
const currentWallet = useCurrentWallet()
|
||||||
const address = useStore((s) => s.address)
|
const address = useStore((s) => s.address)
|
||||||
const focusComponent = useStore((s) => s.focusComponent)
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!currentWallet) return
|
if (!currentWallet) return
|
||||||
if (currentWallet.account.address === address || focusComponent) return
|
if (currentWallet.account.address === address) return
|
||||||
useStore.setState({
|
useStore.setState({
|
||||||
address: undefined,
|
address: undefined,
|
||||||
client: undefined,
|
client: undefined,
|
||||||
@ -33,7 +32,7 @@ export default function Wallet() {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}, [currentWallet, address, focusComponent, disconnectWallet])
|
}, [currentWallet, address, disconnectWallet])
|
||||||
|
|
||||||
return address ? <WalletConnectedButton /> : <WalletConnectButton />
|
return address ? <WalletConnectedButton /> : <WalletConnectButton />
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user