Skip to content

Commit 4ff761c

Browse files
linkielinkPatricie29dependabot[bot]StefChatz
authored
v3.0.8 (#1749)
Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Patricie <99055449+Patricie29@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Patricie29 <patricie@marsprotocol.foundation> Co-authored-by: Monkmansteve <sxatzakis@yahoo.gr> Co-authored-by: Monkmansteve <47855432+StefChatz@users.noreply.github.com>
1 parent 3af1c3b commit 4ff761c

File tree

5 files changed

+88
-37
lines changed

5 files changed

+88
-37
lines changed

src/components/borrow/Table/Columns/BorrowButton.tsx

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useCallback } from 'react'
1+
import { useCallback, useMemo } from 'react'
22

33
import ActionButton from 'components/common/Button/ActionButton'
44
import { Plus } from 'components/common/Icons'
@@ -22,6 +22,23 @@ export default function BorrowButton(props: Props) {
2222
const address = useStore((s) => s.address)
2323
const hasNoDeposits = !account?.deposits?.length && !account?.lends?.length
2424

25+
const isUSDC = useMemo(
26+
() => props.data.asset?.symbol?.toUpperCase().includes('USDC'),
27+
[props.data.asset?.symbol],
28+
)
29+
30+
const isDisabled = hasNoDeposits || isUSDC
31+
32+
const tooltipContent = useMemo(() => {
33+
if (isUSDC) {
34+
return 'USDC borrowing is temporarily disabled.'
35+
}
36+
if (hasNoDeposits) {
37+
return `You don't have any collateral. Please first deposit into your Credit Account before borrowing.`
38+
}
39+
return null
40+
}, [isUSDC, hasNoDeposits])
41+
2542
const borrowHandler = useCallback(() => {
2643
if (!props.data.asset) return null
2744
useStore.setState({ borrowModal: { asset: props.data.asset, marketData: props.data } })
@@ -30,14 +47,11 @@ export default function BorrowButton(props: Props) {
3047
return (
3148
<div className='flex justify-end'>
3249
<ConditionalWrapper
33-
condition={hasNoDeposits && !!address}
50+
condition={isDisabled && !!address}
3451
wrapper={(children) => (
3552
<Tooltip
3653
type='warning'
37-
content={
38-
<Text size='sm'>{`You don’t have any collateral.
39-
Please first deposit into your Credit Account before borrowing.`}</Text>
40-
}
54+
content={<Text size='sm'>{tooltipContent}</Text>}
4155
contentClassName='max-w-[200px]'
4256
className='ml-auto'
4357
>
@@ -47,7 +61,7 @@ export default function BorrowButton(props: Props) {
4761
>
4862
<ActionButton
4963
leftIcon={<Plus />}
50-
disabled={hasNoDeposits}
64+
disabled={isDisabled}
5165
color='tertiary'
5266
onClick={(e) => {
5367
borrowHandler()

src/components/borrow/Table/Columns/Manage.tsx

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ interface Props {
1717
export default function Manage(props: Props) {
1818
const address = useStore((s) => s.address)
1919

20+
const isUSDC = useMemo(
21+
() => props.data.asset?.symbol?.toUpperCase().includes('USDC'),
22+
[props.data.asset?.symbol],
23+
)
24+
2025
const borrowHandler = useCallback(() => {
2126
if (!props.data.asset) return null
2227
useStore.setState({ borrowModal: { asset: props.data.asset, marketData: props.data } })
@@ -30,6 +35,7 @@ export default function Manage(props: Props) {
3035
}, [props.data])
3136

3237
const isDeprecatedAsset = props.data.asset.isDeprecated
38+
const isBorrowDisabled = isDeprecatedAsset || isUSDC
3339

3440
const ITEMS: DropDownItem[] = useMemo(
3541
() => [
@@ -38,20 +44,24 @@ export default function Manage(props: Props) {
3844
text: 'Repay',
3945
onClick: repayHandler,
4046
},
41-
{
42-
icon: <Plus />,
43-
text: 'Borrow more',
44-
onClick: borrowHandler,
45-
},
47+
...(!isUSDC
48+
? [
49+
{
50+
icon: <Plus />,
51+
text: 'Borrow more',
52+
onClick: borrowHandler,
53+
},
54+
]
55+
: []),
4656
],
47-
[borrowHandler, repayHandler],
57+
[borrowHandler, repayHandler, isUSDC],
4858
)
4959

5060
if (!address) return null
5161

5262
return (
5363
<div className='z-10 flex justify-end'>
54-
{isDeprecatedAsset ? (
64+
{isBorrowDisabled ? (
5565
<ActionButton
5666
leftIcon={<HandCoins />}
5767
color='tertiary'

src/components/perps/Module/PerpsModule.tsx

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -272,27 +272,30 @@ export function PerpsModule() {
272272
])
273273

274274
const renderDeprecatedMarketContent = () => (
275-
<>
276-
<div className='flex flex-col gap-2'>
277-
<Text size='sm' uppercase>
275+
<div className='flex flex-col gap-6'>
276+
<div className='flex flex-col gap-4'>
277+
<Text size='lg' uppercase className='font-bold'>
278278
Disabled Market
279279
</Text>
280-
<Text size='xs'>
280+
<Text size='sm' className='text-white/70'>
281281
The selected market is currently disabled, and opening new positions is unavailable.
282282
</Text>
283-
<Text size='xs'>
284-
You have an active position in this market. To manage your exposure, you may still close
285-
your existing position by using the button below.
286-
</Text>
287-
<Text size='xs'>Click the button below to close your position.</Text>
288-
</div>
289-
<div className='flex flex-col gap-2'>
290-
<ActionButton text='Close Position' onClick={closePosition} />
291-
<Callout type={CalloutType.INFO}>
292-
Please note: no new positions can be opened until the market is re-enabled.
293-
</Callout>
283+
{currentPerpPosition && (
284+
<Text size='sm' className='text-white/70'>
285+
You have an active position in this market. To manage your exposure, you may still close
286+
your existing position by using the button below.
287+
</Text>
288+
)}
294289
</div>
295-
</>
290+
{currentPerpPosition && (
291+
<div className='flex flex-col gap-4'>
292+
<ActionButton text='Close Position' onClick={closePosition} color='secondary' />
293+
</div>
294+
)}
295+
<Callout type={CalloutType.INFO}>
296+
No new positions can be opened until the market is re-enabled.
297+
</Callout>
298+
</div>
296299
)
297300

298301
const renderPriceInputs = () => (

src/components/v1/Table/borrowings/Columns/BorrowButton.tsx

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { useMemo } from 'react'
2+
13
import ActionButton from 'components/common/Button/ActionButton'
24
import { Plus } from 'components/common/Icons'
35
import Text from 'components/common/Text'
@@ -15,16 +17,31 @@ export default function BorrowButton(props: Props) {
1517

1618
const hasCollateral = account?.lends?.length ?? 0 > 0
1719

20+
const isUSDC = useMemo(
21+
() => props.data.asset?.symbol?.toUpperCase().includes('USDC'),
22+
[props.data.asset?.symbol],
23+
)
24+
25+
const isDisabled = !hasCollateral || isUSDC
26+
27+
const tooltipContent = useMemo(() => {
28+
if (isUSDC) {
29+
return 'USDC borrowing is temporarily disabled.'
30+
}
31+
if (!hasCollateral) {
32+
return `You don't have assets deposited in the Red Bank. Please deposit assets before you borrow.`
33+
}
34+
return null
35+
}, [isUSDC, hasCollateral])
36+
1837
return (
1938
<div className='flex justify-end'>
2039
<ConditionalWrapper
21-
condition={!hasCollateral && !!address}
40+
condition={isDisabled && !!address}
2241
wrapper={(children) => (
2342
<Tooltip
2443
type='warning'
25-
content={
26-
<Text size='sm'>{`You don’t have assets deposited in the Red Bank. Please deposit assets before you borrow.`}</Text>
27-
}
44+
content={<Text size='sm'>{tooltipContent}</Text>}
2845
contentClassName='max-w-[200px]'
2946
className='ml-auto'
3047
>
@@ -34,7 +51,7 @@ export default function BorrowButton(props: Props) {
3451
>
3552
<ActionButton
3653
leftIcon={<Plus />}
37-
disabled={!hasCollateral}
54+
disabled={isDisabled}
3855
color='tertiary'
3956
onClick={(e) => {
4057
useStore.setState({

src/components/v1/Table/borrowings/Columns/Manage.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ export default function Manage(props: Props) {
1515
const { data: balances } = useWalletBalances(address)
1616
const hasBalance = !!balances.find(byDenom(props.data.asset.denom))
1717

18+
const isUSDC = useMemo(
19+
() => props.data.asset?.symbol?.toUpperCase().includes('USDC'),
20+
[props.data.asset?.symbol],
21+
)
22+
1823
const ITEMS: DropDownItem[] = useMemo(
1924
() => [
2025
{
@@ -24,6 +29,8 @@ export default function Manage(props: Props) {
2429
useStore.setState({
2530
v1BorrowAndRepayModal: { type: 'borrow', data: props.data },
2631
}),
32+
disabled: isUSDC,
33+
disabledTooltip: isUSDC ? 'USDC borrowing is temporarily disabled.' : undefined,
2734
},
2835
{
2936
icon: <HandCoins />,
@@ -33,10 +40,10 @@ export default function Manage(props: Props) {
3340
v1BorrowAndRepayModal: { type: 'repay', data: props.data },
3441
}),
3542
disabled: !hasBalance,
36-
disabledTooltip: `You dont have any ${props.data.asset.symbol} in your Wallet.`,
43+
disabledTooltip: `You don't have any ${props.data.asset.symbol} in your Wallet.`,
3744
},
3845
],
39-
[hasBalance, props.data],
46+
[hasBalance, props.data, isUSDC],
4047
)
4148

4249
return (

0 commit comments

Comments
 (0)