Skip to content

Commit e967724

Browse files
v3.0.8 (#1769)
Co-authored-by: Monkmansteve <47855432+StefChatz@users.noreply.github.com>
1 parent 2b46d39 commit e967724

File tree

5 files changed

+45
-125
lines changed

5 files changed

+45
-125
lines changed

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

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

33
import ActionButton from 'components/common/Button/ActionButton'
44
import { Plus } from 'components/common/Icons'
@@ -25,23 +25,6 @@ export default function BorrowButton(props: Props) {
2525
const chainConfig = useChainConfig()
2626
const isOsmosis = chainConfig.isOsmosis
2727

28-
const isUSDC = useMemo(
29-
() => !isOsmosis && props.data.asset?.symbol?.toUpperCase().includes('USDC'),
30-
[props.data.asset?.symbol, isOsmosis],
31-
)
32-
33-
const isDisabled = hasNoDeposits || isUSDC
34-
35-
const tooltipContent = useMemo(() => {
36-
if (isUSDC) {
37-
return 'USDC borrowing is temporarily disabled.'
38-
}
39-
if (hasNoDeposits) {
40-
return `You don't have any collateral. Please first deposit into your Credit Account before borrowing.`
41-
}
42-
return null
43-
}, [isUSDC, hasNoDeposits])
44-
4528
const borrowHandler = useCallback(() => {
4629
if (!props.data.asset) return null
4730
useStore.setState({ borrowModal: { asset: props.data.asset, marketData: props.data } })
@@ -50,11 +33,16 @@ export default function BorrowButton(props: Props) {
5033
return (
5134
<div className='flex justify-end'>
5235
<ConditionalWrapper
53-
condition={isDisabled && !!address}
36+
condition={hasNoDeposits && !!address}
5437
wrapper={(children) => (
5538
<Tooltip
5639
type='warning'
57-
content={<Text size='sm'>{tooltipContent}</Text>}
40+
content={
41+
<Text size='sm'>
42+
You don't have any collateral. Please first deposit into your Credit Account before
43+
borrowing.
44+
</Text>
45+
}
5846
contentClassName='max-w-[200px]'
5947
className='ml-auto'
6048
>
@@ -64,7 +52,7 @@ export default function BorrowButton(props: Props) {
6452
>
6553
<ActionButton
6654
leftIcon={<Plus />}
67-
disabled={isDisabled}
55+
disabled={hasNoDeposits}
6856
color='tertiary'
6957
onClick={(e) => {
7058
borrowHandler()

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@ export default function Manage(props: Props) {
2020
const chainConfig = useChainConfig()
2121
const isOsmosis = chainConfig.isOsmosis
2222

23-
const isUSDC = useMemo(
24-
() => !isOsmosis && props.data.asset?.symbol?.toUpperCase().includes('USDC'),
25-
[props.data.asset?.symbol, isOsmosis],
26-
)
27-
2823
const borrowHandler = useCallback(() => {
2924
if (!props.data.asset) return null
3025
useStore.setState({ borrowModal: { asset: props.data.asset, marketData: props.data } })
@@ -39,8 +34,7 @@ export default function Manage(props: Props) {
3934

4035
const isDeprecatedAsset = props.data.asset.isDeprecated
4136
const isBorrowEnabled = props.data.asset.isBorrowEnabled
42-
const canBorrowMore = isBorrowEnabled && !isUSDC
43-
const isBorrowDisabled = isDeprecatedAsset || isUSDC || !isBorrowEnabled
37+
const isBorrowDisabled = isDeprecatedAsset || !isBorrowEnabled
4438

4539
const ITEMS: DropDownItem[] = useMemo(
4640
() => [
@@ -49,7 +43,7 @@ export default function Manage(props: Props) {
4943
text: 'Repay',
5044
onClick: repayHandler,
5145
},
52-
...(canBorrowMore
46+
...(isBorrowEnabled
5347
? [
5448
{
5549
icon: <Plus />,
@@ -59,7 +53,7 @@ export default function Manage(props: Props) {
5953
]
6054
: []),
6155
],
62-
[borrowHandler, repayHandler, canBorrowMore],
56+
[borrowHandler, repayHandler, isBorrowEnabled],
6357
)
6458

6559
if (!address) return null

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

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { useMemo } from 'react'
2-
31
import ActionButton from 'components/common/Button/ActionButton'
42
import { Plus } from 'components/common/Icons'
53
import Text from 'components/common/Text'
@@ -20,31 +18,19 @@ export default function BorrowButton(props: Props) {
2018

2119
const hasCollateral = account?.lends?.length ?? 0 > 0
2220

23-
const isUSDC = useMemo(
24-
() => !isOsmosis && props.data.asset?.symbol?.toUpperCase().includes('USDC'),
25-
[props.data.asset?.symbol, isOsmosis],
26-
)
27-
28-
const isDisabled = !hasCollateral || isUSDC
29-
30-
const tooltipContent = useMemo(() => {
31-
if (isUSDC) {
32-
return 'USDC borrowing is temporarily disabled.'
33-
}
34-
if (!hasCollateral) {
35-
return `You don't have assets deposited in the Red Bank. Please deposit assets before you borrow.`
36-
}
37-
return null
38-
}, [isUSDC, hasCollateral])
39-
4021
return (
4122
<div className='flex justify-end'>
4223
<ConditionalWrapper
43-
condition={isDisabled && !!address}
24+
condition={!hasCollateral && !!address}
4425
wrapper={(children) => (
4526
<Tooltip
4627
type='warning'
47-
content={<Text size='sm'>{tooltipContent}</Text>}
28+
content={
29+
<Text size='sm'>
30+
You don't have assets deposited in the Red Bank. Please deposit assets before you
31+
borrow.
32+
</Text>
33+
}
4834
contentClassName='max-w-[200px]'
4935
className='ml-auto'
5036
>
@@ -54,7 +40,7 @@ export default function BorrowButton(props: Props) {
5440
>
5541
<ActionButton
5642
leftIcon={<Plus />}
57-
disabled={isDisabled}
43+
disabled={!hasCollateral}
5844
color='tertiary'
5945
onClick={(e) => {
6046
useStore.setState({

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,11 @@ export default function Manage(props: Props) {
1818
const chainConfig = useChainConfig()
1919
const isOsmosis = chainConfig.isOsmosis
2020

21-
const isUSDC = useMemo(
22-
() => !isOsmosis && props.data.asset?.symbol?.toUpperCase().includes('USDC'),
23-
[props.data.asset?.symbol, isOsmosis],
24-
)
25-
2621
const isBorrowEnabled = props.data.asset.isBorrowEnabled
27-
const canBorrowMore = isBorrowEnabled && !isUSDC
2822

2923
const ITEMS: DropDownItem[] = useMemo(
3024
() => [
31-
...(canBorrowMore
25+
...(isBorrowEnabled
3226
? [
3327
{
3428
icon: <Plus />,
@@ -51,7 +45,7 @@ export default function Manage(props: Props) {
5145
disabledTooltip: `You don't have any ${props.data.asset.symbol} in your Wallet.`,
5246
},
5347
],
54-
[hasBalance, props.data, canBorrowMore],
48+
[hasBalance, props.data, isBorrowEnabled],
5549
)
5650

5751
return (

src/store/slices/broadcast.ts

Lines changed: 23 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -108,20 +108,6 @@ export default function createBroadcastSlice(
108108
})
109109
}
110110

111-
// USDC lending is being disabled. Auto-lend should never append a `lend` action for USDC.
112-
// We intentionally key off chainConfig.stables (stable denoms) to avoid matching LP tokens
113-
// whose symbols may contain "USDC" but are not the USDC stable itself.
114-
const isUsdcDenom = (denom: string): boolean => {
115-
const stables = get().chainConfig.stables
116-
if (!stables.includes(denom)) return false
117-
118-
const symbol = get().assets.find(byDenom(denom))?.symbol
119-
if (symbol) return symbol.toUpperCase().includes('USDC')
120-
121-
// Fallback: if assets aren't loaded yet, assume the primary stable is USDC.
122-
return denom === stables[0]
123-
}
124-
125111
return {
126112
toast: null,
127113
addToStakingStrategy: async (options: {
@@ -290,8 +276,7 @@ export default function createBroadcastSlice(
290276
if (
291277
!options.borrowToWallet &&
292278
checkAutoLendEnabled(options.accountId, get().chainConfig.id) &&
293-
get().assets.find(byDenom(options.coin.denom))?.isAutoLendEnabled &&
294-
(isOsmosis || !isUsdcDenom(options.coin.denom))
279+
get().assets.find(byDenom(options.coin.denom))?.isAutoLendEnabled
295280
) {
296281
msg.update_credit_account.actions.push({
297282
lend: { denom: options.coin.denom, amount: 'account_balance' },
@@ -432,11 +417,7 @@ export default function createBroadcastSlice(
432417
for (const reward of stakedAstroLpRewards) {
433418
for (const coin of reward.rewards) {
434419
const asset = assets.find(byDenom(coin.denom))
435-
if (
436-
asset?.isAutoLendEnabled &&
437-
(isOsmosis || !isUsdcDenom(coin.denom)) &&
438-
!lendCoins.find(byDenom(coin.denom))
439-
) {
420+
if (asset?.isAutoLendEnabled && !lendCoins.find(byDenom(coin.denom))) {
440421
lendCoins.push(coin)
441422
actions.push({
442423
lend: {
@@ -452,11 +433,7 @@ export default function createBroadcastSlice(
452433
if (!isV1 && options.lend && redBankRewards.length) {
453434
for (const coin of redBankRewards) {
454435
const asset = assets.find(byDenom(coin.denom))
455-
if (
456-
asset?.isAutoLendEnabled &&
457-
(isOsmosis || !isUsdcDenom(coin.denom)) &&
458-
!lendCoins.find(byDenom(coin.denom))
459-
) {
436+
if (asset?.isAutoLendEnabled && !lendCoins.find(byDenom(coin.denom))) {
460437
actions.push({
461438
lend: {
462439
denom: coin.denom,
@@ -515,11 +492,7 @@ export default function createBroadcastSlice(
515492
const isOsmosis = get().chainConfig.isOsmosis
516493
msg.update_credit_account.actions.push(
517494
...options.coins
518-
.filter(
519-
(coin) =>
520-
get().assets.find(byDenom(coin.denom))?.isAutoLendEnabled &&
521-
(isOsmosis || !isUsdcDenom(coin.denom)),
522-
)
495+
.filter((coin) => get().assets.find(byDenom(coin.denom))?.isAutoLendEnabled)
523496
.map((coin) => ({ lend: coin.toActionCoin() })),
524497
)
525498
}
@@ -591,11 +564,7 @@ export default function createBroadcastSlice(
591564
actions.push({
592565
withdraw_from_perp_vault: {},
593566
})
594-
const isOsmosis = get().chainConfig.isOsmosis
595-
if (
596-
checkAutoLendEnabled(options.accountId, get().chainConfig.id) &&
597-
(isOsmosis || !isUsdcDenom(vault.denoms.lp))
598-
) {
567+
if (checkAutoLendEnabled(options.accountId, get().chainConfig.id)) {
599568
actions.push({
600569
lend: { denom: vault.denoms.lp, amount: 'account_balance' },
601570
})
@@ -614,7 +583,7 @@ export default function createBroadcastSlice(
614583
for (const vault of options.vaults) {
615584
for (const symbol of Object.values(vault.symbols)) {
616585
const asset = get().assets.find(bySymbol(symbol))
617-
if (asset?.isAutoLendEnabled && (isOsmosis || !isUsdcDenom(asset.denom))) {
586+
if (asset?.isAutoLendEnabled) {
618587
msg.update_credit_account.actions.push({
619588
lend: { denom: asset.denom, amount: 'account_balance' },
620589
})
@@ -713,7 +682,7 @@ export default function createBroadcastSlice(
713682
for (const astroLp of options.astroLps) {
714683
for (const symbol of Object.values(astroLp.symbols)) {
715684
const asset = get().assets.find(bySymbol(symbol))
716-
if (asset?.isAutoLendEnabled && (isOsmosis || !isUsdcDenom(asset.denom))) {
685+
if (asset?.isAutoLendEnabled) {
717686
msg.update_credit_account.actions.push({
718687
lend: { denom: asset.denom, amount: 'account_balance' },
719688
})
@@ -940,9 +909,7 @@ export default function createBroadcastSlice(
940909
},
941910
depositAndLend: async (options: { accountId: string; coin: BNCoin }) => {
942911
const asset = get().assets.find(byDenom(options.coin.denom))
943-
const isOsmosis = get().chainConfig.isOsmosis
944-
if ((!isOsmosis && isUsdcDenom(options.coin.denom)) || !asset?.isAutoLendEnabled) {
945-
// USDC lending is disabled on Neutron (or asset is deposit-only/unknown) - fall back to deposit without lending.
912+
if (!asset?.isAutoLendEnabled) {
946913
return get().depositSingle(options)
947914
}
948915

@@ -1041,7 +1008,6 @@ export default function createBroadcastSlice(
10411008
if (
10421009
checkAutoLendEnabled(options.accountId, get().chainConfig.id) &&
10431010
get().assets.find(byDenom(options.denomOut))?.isAutoLendEnabled &&
1044-
(isOsmosis || !isUsdcDenom(options.denomOut)) &&
10451011
!options.repay
10461012
) {
10471013
msg.update_credit_account.actions.push({
@@ -1125,8 +1091,7 @@ export default function createBroadcastSlice(
11251091
},
11261092
},
11271093
]
1128-
const isOsmosis = get().chainConfig.isOsmosis
1129-
if (options.autolend && (isOsmosis || !isUsdcDenom(options.keeperFee.denom)))
1094+
if (options.autolend)
11301095
triggerActions.push({
11311096
lend: {
11321097
denom: options.keeperFee.denom,
@@ -1237,7 +1202,7 @@ export default function createBroadcastSlice(
12371202
},
12381203
},
12391204
]
1240-
if (order.autolend && (isOsmosis || !isUsdcDenom(order.keeperFee.denom)))
1205+
if (order.autolend)
12411206
triggerActions.push({
12421207
lend: {
12431208
denom: order.keeperFee.denom,
@@ -1303,8 +1268,7 @@ export default function createBroadcastSlice(
13031268
conditionalTriggers?: { sl: string | null; tp: string | null }
13041269
keeperFee?: BNCoin
13051270
}) => {
1306-
const isOsmosis = get().chainConfig.isOsmosis
1307-
const autoLend = options.autolend && (isOsmosis || !isUsdcDenom(options.baseDenom))
1271+
const autoLend = options.autolend
13081272
const actions: Action[] = [
13091273
{
13101274
execute_perp_order: {
@@ -1445,8 +1409,7 @@ export default function createBroadcastSlice(
14451409
})
14461410
}
14471411

1448-
const isOsmosis = get().chainConfig.isOsmosis
1449-
if (options.autolend && (isOsmosis || !isUsdcDenom(options.baseDenom))) {
1412+
if (options.autolend) {
14501413
actions.push({
14511414
lend: {
14521415
denom: options.baseDenom,
@@ -1600,8 +1563,7 @@ export default function createBroadcastSlice(
16001563
}
16011564
}
16021565

1603-
const isOsmosis = get().chainConfig.isOsmosis
1604-
if (options.autolend && (isOsmosis || !isUsdcDenom(options.baseDenom))) {
1566+
if (options.autolend) {
16051567
actions.push({
16061568
lend: {
16071569
denom: options.baseDenom,
@@ -1640,8 +1602,7 @@ export default function createBroadcastSlice(
16401602
},
16411603
},
16421604
]
1643-
const isOsmosis = get().chainConfig.isOsmosis
1644-
if (options.autolend && (isOsmosis || !isUsdcDenom(options.baseDenom)))
1605+
if (options.autolend)
16451606
actions.push({
16461607
lend: {
16471608
denom: options.baseDenom,
@@ -1875,19 +1836,16 @@ export default function createBroadcastSlice(
18751836
{
18761837
withdraw_from_perp_vault: {},
18771838
},
1878-
...(() => {
1879-
const isOsmosis = get().chainConfig.isOsmosis
1880-
return options.isAutoLend && (isOsmosis || !isUsdcDenom(options.vaultDenom))
1881-
? [
1882-
{
1883-
lend: {
1884-
denom: options.vaultDenom,
1885-
amount: 'account_balance' as ActionAmount,
1886-
},
1839+
...(options.isAutoLend
1840+
? [
1841+
{
1842+
lend: {
1843+
denom: options.vaultDenom,
1844+
amount: 'account_balance' as ActionAmount,
18871845
},
1888-
]
1889-
: []
1890-
})(),
1846+
},
1847+
]
1848+
: []),
18911849
],
18921850
},
18931851
}

0 commit comments

Comments
 (0)