diff --git a/package.json b/package.json index a07087e4..e311b9b7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mars-v2-frontend", - "version": "2.1.0", + "version": "2.1.1", "private": true, "scripts": { "build": "yarn validate-env && next build", diff --git a/src/components/Account/AccountDetails/index.tsx b/src/components/Account/AccountDetails/index.tsx index a21cdbb6..cadf4de6 100644 --- a/src/components/Account/AccountDetails/index.tsx +++ b/src/components/Account/AccountDetails/index.tsx @@ -39,7 +39,7 @@ export default function AccountDetailsController() { const address = useStore((s) => s.address) const isHLS = useStore((s) => s.isHLS) const { data: accounts, isLoading } = useAccounts('default', address) - const { data: accountIds } = useAccountIds(address, false) + const { data: accountIds } = useAccountIds(address, false, true) const accountId = useAccountId() const account = useCurrentAccount() diff --git a/src/components/Account/AccountMenuContent.tsx b/src/components/Account/AccountMenuContent.tsx index d1efcffe..ad63b4fe 100644 --- a/src/components/Account/AccountMenuContent.tsx +++ b/src/components/Account/AccountMenuContent.tsx @@ -31,7 +31,7 @@ export default function AccountMenuContent() { const navigate = useNavigate() const { pathname } = useLocation() const address = useStore((s) => s.address) - const { data: accountIds } = useAccountIds(address) + const { data: accountIds } = useAccountIds(address, true, true) const accountId = useAccountId() const createAccount = useStore((s) => s.createAccount) diff --git a/src/components/Borrow/Table/Columns/BorrowRate.tsx b/src/components/Borrow/Table/Columns/BorrowRate.tsx index 4aaff79a..9652c4e2 100644 --- a/src/components/Borrow/Table/Columns/BorrowRate.tsx +++ b/src/components/Borrow/Table/Columns/BorrowRate.tsx @@ -1,7 +1,11 @@ import { FormattedNumber } from 'components/FormattedNumber' import Loading from 'components/Loading' -export const BORROW_RATE_META = { accessorKey: 'borrowRate', header: 'Borrow Rate APY' } +export const BORROW_RATE_META = { + accessorKey: 'borrowRate', + header: 'Borrow Rate APY', + meta: { className: 'w-40' }, +} interface Props { borrowRate: number | null diff --git a/src/components/Borrow/Table/Columns/Liquidity.tsx b/src/components/Borrow/Table/Columns/Liquidity.tsx index 64854b87..0f057909 100644 --- a/src/components/Borrow/Table/Columns/Liquidity.tsx +++ b/src/components/Borrow/Table/Columns/Liquidity.tsx @@ -11,6 +11,7 @@ export const LIQUIDITY_META = { accessorKey: 'liquidity', header: 'Liquidity Available', id: 'liquidity', + meta: { className: 'w-40' }, } export const liquiditySortingFn = ( diff --git a/src/components/Borrow/Table/Columns/Manage.tsx b/src/components/Borrow/Table/Columns/Manage.tsx index 58c95820..8af2ea79 100644 --- a/src/components/Borrow/Table/Columns/Manage.tsx +++ b/src/components/Borrow/Table/Columns/Manage.tsx @@ -1,8 +1,11 @@ -import React from 'react' - import { ChevronDown, ChevronUp } from 'components/Icons' -export const MANAGE_META = { accessorKey: 'manage', enableSorting: false, header: 'Manage' } +export const MANAGE_META = { + accessorKey: 'manage', + enableSorting: false, + header: 'Manage', + meta: { className: 'w-30' }, +} interface Props { isExpanded: boolean diff --git a/src/components/DisplayCurrency.tsx b/src/components/DisplayCurrency.tsx index b19ee332..d1ce5031 100644 --- a/src/components/DisplayCurrency.tsx +++ b/src/components/DisplayCurrency.tsx @@ -18,6 +18,7 @@ interface Props { isApproximation?: boolean parentheses?: boolean showZero?: boolean + options?: FormatOptions } export default function DisplayCurrency(props: Props) { @@ -73,6 +74,7 @@ export default function DisplayCurrency(props: Props) { abbreviated: true, prefix, suffix, + ...props.options, }} animate /> diff --git a/src/components/Earn/Lend/Table/Columns/Apy.tsx b/src/components/Earn/Lend/Table/Columns/Apy.tsx index 483a36f6..9525d895 100644 --- a/src/components/Earn/Lend/Table/Columns/Apy.tsx +++ b/src/components/Earn/Lend/Table/Columns/Apy.tsx @@ -1,7 +1,7 @@ import AssetRate from 'components/Asset/AssetRate' import Loading from 'components/Loading' -export const APY_META = { accessorKey: 'apy.deposit', header: 'APY' } +export const APY_META = { accessorKey: 'apy.deposit', header: 'APY', meta: { className: 'w-40' } } interface Props { apy: number diff --git a/src/components/Earn/Lend/Table/Columns/DepositCap.tsx b/src/components/Earn/Lend/Table/Columns/DepositCap.tsx index 2e351933..896c6048 100644 --- a/src/components/Earn/Lend/Table/Columns/DepositCap.tsx +++ b/src/components/Earn/Lend/Table/Columns/DepositCap.tsx @@ -9,6 +9,7 @@ export const DEPOSIT_CAP_META = { accessorKey: 'marketDepositCap', header: 'Deposit Cap', id: 'marketDepositCap', + meta: { className: 'w-40' }, } export const marketDepositCapSortingFn = ( diff --git a/src/components/Earn/Lend/Table/Columns/Manage.tsx b/src/components/Earn/Lend/Table/Columns/Manage.tsx index 3db5df17..7da716f0 100644 --- a/src/components/Earn/Lend/Table/Columns/Manage.tsx +++ b/src/components/Earn/Lend/Table/Columns/Manage.tsx @@ -1,8 +1,13 @@ -import React from 'react' - import { ChevronDown, ChevronUp } from 'components/Icons' -export const MANAGE_META = { accessorKey: 'manage', enableSorting: false, header: 'Manage' } +export const MANAGE_META = { + accessorKey: 'manage', + enableSorting: false, + header: 'Manage', + meta: { + className: 'w-30', + }, +} interface Props { isExpanded: boolean diff --git a/src/components/HLS/Staking/Table/Columns/ApyRange.tsx b/src/components/HLS/Staking/Table/Columns/ApyRange.tsx index 75cc3a98..c6d1b73f 100644 --- a/src/components/HLS/Staking/Table/Columns/ApyRange.tsx +++ b/src/components/HLS/Staking/Table/Columns/ApyRange.tsx @@ -1,5 +1,4 @@ import { Row } from '@tanstack/react-table' -import React from 'react' import { FormattedNumber } from 'components/FormattedNumber' import Loading from 'components/Loading' @@ -35,13 +34,13 @@ export default function ApyRange(props: Props) { - + } sub={ <> - + ) : ( diff --git a/src/components/HLS/Staking/Table/Columns/useDepositedColumns.tsx b/src/components/HLS/Staking/Table/Columns/useDepositedColumns.tsx index 866fb39d..bf8b874b 100644 --- a/src/components/HLS/Staking/Table/Columns/useDepositedColumns.tsx +++ b/src/components/HLS/Staking/Table/Columns/useDepositedColumns.tsx @@ -1,15 +1,11 @@ import { ColumnDef } from '@tanstack/react-table' -import React, { useMemo } from 'react' +import { useMemo } from 'react' import Account, { ACCOUNT_META } from 'components/HLS/Staking/Table/Columns/Account' import ActiveApy, { ACTIVE_APY_META, activeApySortingFn, } from 'components/HLS/Staking/Table/Columns/ActiveApy' -import DebtValue, { - DEBT_VAL_META, - debtValueSorting, -} from 'components/HLS/Staking/Table/Columns/DebtValue' import DepositCap, { CAP_META, depositCapSortingFn, @@ -59,11 +55,6 @@ export default function useDepositedColumns(props: Props) { cell: ({ row }) => , sortingFn: netValueSorting, }, - { - ...DEBT_VAL_META, - cell: ({ row }) => , - sortingFn: debtValueSorting, - }, { ...CAP_META, cell: ({ row }) => , diff --git a/src/components/Modals/BorrowModal.tsx b/src/components/Modals/BorrowModal.tsx index c6efea4b..338d0a04 100644 --- a/src/components/Modals/BorrowModal.tsx +++ b/src/components/Modals/BorrowModal.tsx @@ -21,6 +21,7 @@ import useHealthComputer from 'hooks/useHealthComputer' import useToggle from 'hooks/useToggle' import { useUpdatedAccount } from 'hooks/useUpdatedAccount' import { getDepositAndLendCoinsToSpend } from 'hooks/useUpdatedAccount/functions' +import useWalletBalances from 'hooks/useWalletBalances' import useStore from 'store' import { BNCoin } from 'types/classes/BNCoin' import { byDenom } from 'utils/array' @@ -42,17 +43,18 @@ function getAssetLogo(modal: BorrowModal) { return } -function RepayNotAvailable(props: { asset: Asset }) { +function RepayNotAvailable(props: { asset: Asset; repayFromWallet: boolean }) { return (
- -
+ +
No funds for repay - {`Unfortunately you don't have any ${props.asset.symbol} in your Credit Account to repay the debt.`} + {`Unfortunately you don't have any ${ + props.asset.symbol + } in your ${ + props.repayFromWallet ? 'Wallet' : 'Credit Account' + } to repay the debt.`}
@@ -74,6 +76,9 @@ function BorrowModal(props: Props) { const { modal, account } = props const [amount, setAmount] = useState(BN_ZERO) const [borrowToWallet, setBorrowToWallet] = useToggle() + const [repayFromWallet, setRepayFromWallet] = useToggle() + const walletAddress = useStore((s) => s.address) + const { data: walletBalances } = useWalletBalances(walletAddress) const borrow = useStore((s) => s.borrow) const repay = useStore((s) => s.repay) const asset = modal.asset @@ -100,9 +105,19 @@ function BorrowModal(props: Props) { ) const maxRepayAmount = useMemo(() => { - const maxBalance = depositBalance.plus(lendBalance) + const maxBalance = repayFromWallet + ? BN(walletBalances.find(byDenom(asset.denom))?.amount ?? 0) + : depositBalance.plus(lendBalance) return isRepay ? BigNumber.min(maxBalance, totalDebtRepayAmount) : BN_ZERO - }, [depositBalance, lendBalance, isRepay, totalDebtRepayAmount]) + }, [ + depositBalance, + lendBalance, + isRepay, + totalDebtRepayAmount, + walletBalances, + asset.denom, + repayFromWallet, + ]) function resetState() { setAmount(BN_ZERO) @@ -119,7 +134,8 @@ function BorrowModal(props: Props) { accountId: account.id, coin: BNCoin.fromDenomAndBigNumber(asset.denom, amount), accountBalance: amount.isEqualTo(totalDebtRepayAmount), - lend, + lend: repayFromWallet ? BNCoin.fromDenomAndBigNumber(asset.denom, BN_ZERO) : lend, + fromWallet: repayFromWallet, }) } else { borrow({ @@ -146,9 +162,9 @@ function BorrowModal(props: Props) { const repayCoin = coin.amount.isGreaterThan(totalDebt) ? BNCoin.fromDenomAndBigNumber(asset.denom, totalDebt) : coin - simulateRepay(repayCoin) + simulateRepay(repayCoin, repayFromWallet) }, - [amount, asset.denom, isRepay, simulateRepay, totalDebt], + [amount, asset.denom, isRepay, simulateRepay, totalDebt, repayFromWallet], ) const maxBorrow = useMemo(() => { @@ -269,8 +285,27 @@ function BorrowModal(props: Props) { maxText='Max' warningMessages={[]} /> - {isRepay && maxRepayAmount.isZero() && } - {!isRepay && ( + {isRepay && maxRepayAmount.isZero() && ( + + )} + {isRepay ? ( + <> + +
+ Repay from Wallet + + Repay your debt directly from your wallet + +
+
+ +
+ + ) : ( <>
diff --git a/src/components/Table/Row.tsx b/src/components/Table/Row.tsx index 7a396291..ae0e35ca 100644 --- a/src/components/Table/Row.tsx +++ b/src/components/Table/Row.tsx @@ -9,6 +9,7 @@ interface Props { rowClickHandler?: () => void spacingClassName?: string isBalancesTable?: boolean + className?: string } function getBorderColor(row: AccountBalanceRow) { @@ -17,7 +18,6 @@ function getBorderColor(row: AccountBalanceRow) { export default function Row(props: Props) { const canExpand = !!props.renderExpanded - return ( <> (props: Props) { isSymbolOrName ? 'text-left' : 'text-right', props.spacingClassName ?? 'px-3 py-4', borderClasses, + cell.column.columnDef.meta?.className, )} > {flexRender(cell.column.columnDef.cell, cell.getContext())} diff --git a/src/components/Table/index.tsx b/src/components/Table/index.tsx index c278f4b1..2502f372 100644 --- a/src/components/Table/index.tsx +++ b/src/components/Table/index.tsx @@ -68,6 +68,7 @@ export default function Table(props: Props) { props.spacingClassName ?? 'px-4 py-3', header.column.getCanSort() && 'hover:cursor-pointer', header.id === 'symbol' || header.id === 'name' ? 'text-left' : 'text-right', + header.column.columnDef.meta?.className, )} >
typeof poolId === 'string') as string[] } - getDescription(pairName: string) { - const denom1 = pairName.split(PAIR_SEPARATOR)[0] - const denom2 = pairName.split(PAIR_SEPARATOR)[1] + getDescription(pairName: string, inverted: boolean) { + const [denom1, denom2] = pairName.split(PAIR_SEPARATOR) const asset1 = ASSETS.find(byDenom(denom1)) const asset2 = ASSETS.find(byDenom(denom2)) - return `${asset2?.symbol}/${asset1?.symbol}` + return inverted ? `${asset2?.symbol}/${asset1?.symbol}` : `${asset1?.symbol}/${asset2?.symbol}` } async getPairsWithData() { @@ -111,9 +112,10 @@ export class DataFeed implements IDatafeedChartApi { .then((res) => res.json()) .then((json) => { this.pairs = json.data.pairs + this.pairsWithData = json.data.pairs.map( (pair: { baseAsset: string; quoteAsset: string }) => { - return `${pair.baseAsset}${PAIR_SEPARATOR}${pair.quoteAsset}` + return `${pair.quoteAsset}${PAIR_SEPARATOR}${pair.baseAsset}` }, ) }) @@ -139,14 +141,14 @@ export class DataFeed implements IDatafeedChartApi { setTimeout(() => { const info: LibrarySymbolInfo = { ...defaultSymbolInfo, - name: this.getDescription(pairName), - full_name: this.getDescription(pairName), - description: this.getDescription(pairName), - ticker: this.getDescription(pairName), + name: this.getDescription(pairName, false), + full_name: this.getDescription(pairName, true), + description: this.getDescription(pairName, true), + ticker: this.getDescription(pairName, false), exchange: this.getExchangeName(pairName), listed_exchange: this.getExchangeName(pairName), supported_resolutions: this.supportedResolutions, - base_name: [this.getDescription(pairName)], + base_name: [this.getDescription(pairName, false)], pricescale: this.getPriceScale(pairName), } as LibrarySymbolInfo onResolve(info) @@ -470,7 +472,13 @@ export class DataFeed implements IDatafeedChartApi { } getPythFeedIds(name: string) { - if (name.includes(PAIR_SEPARATOR)) return [] + if (name.includes(PAIR_SEPARATOR)) { + const [denom1, denom2] = name.split(PAIR_SEPARATOR) + const denomFeedId1 = ASSETS.find((asset) => asset.denom === denom1)?.pythHistoryFeedId + const denomFeedId2 = ASSETS.find((asset) => asset.denom === denom2)?.pythHistoryFeedId + return [denomFeedId1, denomFeedId2] + } + const [symbol1, symbol2] = name.split('/') const feedId1 = ASSETS.find((asset) => asset.symbol === symbol1)?.pythHistoryFeedId const feedId2 = ASSETS.find((asset) => asset.symbol === symbol2)?.pythHistoryFeedId diff --git a/src/components/Trade/TradeChart/TVChartContainer.tsx b/src/components/Trade/TradeChart/TVChartContainer.tsx index 45abea40..cd759137 100644 --- a/src/components/Trade/TradeChart/TVChartContainer.tsx +++ b/src/components/Trade/TradeChart/TVChartContainer.tsx @@ -1,9 +1,17 @@ import { useEffect, useMemo, useRef } from 'react' import Card from 'components/Card' -import { disabledFeatures, enabledFeatures, overrides } from 'components/Trade/TradeChart/constants' +import DisplayCurrency from 'components/DisplayCurrency' +import { FormattedNumber } from 'components/FormattedNumber' +import Loading from 'components/Loading' +import Text from 'components/Text' import { DataFeed, PAIR_SEPARATOR } from 'components/Trade/TradeChart/DataFeed' +import { disabledFeatures, enabledFeatures, overrides } from 'components/Trade/TradeChart/constants' +import { BN_ZERO } from 'constants/math' +import usePrices from 'hooks/usePrices' import useStore from 'store' +import { BNCoin } from 'types/classes/BNCoin' +import { byDenom } from 'utils/array' import { ChartingLibraryWidgetOptions, IChartingLibraryWidget, @@ -11,6 +19,7 @@ import { Timezone, widget, } from 'utils/charting_library' +import { magnify } from 'utils/formatters' interface Props { buyAsset: Asset @@ -28,6 +37,14 @@ export const TVChartContainer = (props: Props) => { () => new DataFeed(false, baseCurrency.decimals, baseCurrency.denom), [baseCurrency], ) + const { data: prices, isLoading } = usePrices() + const ratio = useMemo(() => { + const priceBuyAsset = prices.find(byDenom(props.buyAsset.denom))?.amount + const priceSellAsset = prices.find(byDenom(props.sellAsset.denom))?.amount + + if (!priceBuyAsset || !priceSellAsset) return BN_ZERO + return priceBuyAsset.dividedBy(priceSellAsset) + }, [prices, props.buyAsset.denom, props.sellAsset.denom]) useEffect(() => { const widgetOptions: ChartingLibraryWidgetOptions = { @@ -102,7 +119,45 @@ export const TVChartContainer = (props: Props) => { }, [props.buyAsset.denom, props.sellAsset.denom]) return ( - + + + Trading Chart + + {ratio.isZero() || isLoading ? ( + + ) : ( +
+ 1 {props.buyAsset.symbol} + +
+ )} +
+ } + contentClassName='px-0.5 pb-0.5 h-full' + className='min-h-[55vh]' + >
) diff --git a/src/components/Trade/TradeChart/index.tsx b/src/components/Trade/TradeChart/index.tsx index 4f3c9798..237aa691 100644 --- a/src/components/Trade/TradeChart/index.tsx +++ b/src/components/Trade/TradeChart/index.tsx @@ -4,6 +4,8 @@ import { useState } from 'react' import Card from 'components/Card' import { CircularProgress } from 'components/CircularProgress' +import Loading from 'components/Loading' +import Text from 'components/Text' const TVChartContainer = dynamic( () => import('components/Trade/TradeChart/TVChartContainer').then((mod) => mod.TVChartContainer), @@ -33,7 +35,18 @@ export default function TradeChart(props: Props) { {isScriptReady ? ( ) : ( - + + + Trading Chart + + +
+ } + contentClassName='px-0.5 pb-0.5 h-full' + className='min-h-[55vh]' + >
diff --git a/src/components/Trade/TradeModule/SwapForm/TradeSummary.tsx b/src/components/Trade/TradeModule/SwapForm/TradeSummary.tsx index 188d3b03..67810ccb 100644 --- a/src/components/Trade/TradeModule/SwapForm/TradeSummary.tsx +++ b/src/components/Trade/TradeModule/SwapForm/TradeSummary.tsx @@ -7,11 +7,14 @@ import { CircularProgress } from 'components/CircularProgress' import DisplayCurrency from 'components/DisplayCurrency' import Divider from 'components/Divider' import { FormattedNumber } from 'components/FormattedNumber' +import { ChevronDown } from 'components/Icons' +import Text from 'components/Text' import { DEFAULT_SETTINGS } from 'constants/defaultSettings' import { LocalStorageKeys } from 'constants/localStorageKeys' import useLocalStorage from 'hooks/useLocalStorage' import usePrice from 'hooks/usePrice' import useSwapFee from 'hooks/useSwapFee' +import useToggle from 'hooks/useToggle' import { BNCoin } from 'types/classes/BNCoin' import { getAssetByDenom } from 'utils/assets' import { formatAmountWithSymbol, formatPercent } from 'utils/formatters' @@ -55,6 +58,7 @@ export default function TradeSummary(props: Props) { const sellAssetPrice = usePrice(sellAsset.denom) const swapFee = useSwapFee(route.map((r) => r.pool_id)) + const [showSummary, setShowSummary] = useToggle() const [liquidationPrice, setLiquidationPrice] = useState(null) const [isUpdatingLiquidationPrice, setIsUpdatingLiquidationPrice] = useState(false) const debouncedSetLiqPrice = useMemo( @@ -99,7 +103,22 @@ export default function TradeSummary(props: Props) { )} >
- Summary + +
+ {isUpdatingLiquidationPrice ? ( + + ) : liquidationPrice === null || liquidationPrice === 0 ? ( + '-' + ) : ( + + )} +
+
+ {isMargin && ( <> @@ -122,38 +141,45 @@ export default function TradeSummary(props: Props) { )} - <> - -
- {isUpdatingLiquidationPrice ? ( - - ) : liquidationPrice === null || liquidationPrice === 0 ? ( - '-' - ) : ( - - )} -
-
- - - - - - - {formatAmountWithSymbol(estimatedFee.amount[0])} - - - - - - {parsedRoutes} +
setShowSummary(!showSummary)} + > + + Summary + +
+ +
+
+ {showSummary && ( + <> + + + + + {formatAmountWithSymbol(estimatedFee.amount[0])} + + + + + + {parsedRoutes} + + )}
+
{props.label} {props.children}
diff --git a/src/components/Trade/TradeModule/SwapForm/index.tsx b/src/components/Trade/TradeModule/SwapForm/index.tsx index a98ef094..c48fc172 100644 --- a/src/components/Trade/TradeModule/SwapForm/index.tsx +++ b/src/components/Trade/TradeModule/SwapForm/index.tsx @@ -187,7 +187,7 @@ export default function SwapForm(props: Props) { removeCoin, addCoin, debtCoin, - isAutoLendEnabled ? 'lend' : 'deposit', + isAutoLendEnabled && !isAutoRepayChecked ? 'lend' : 'deposit', isAutoRepayChecked, ) }, 100), @@ -223,7 +223,7 @@ export default function SwapForm(props: Props) { BNCoin.fromDenomAndBigNumber(buyAsset.denom, BN_ZERO), BNCoin.fromDenomAndBigNumber(sellAsset.denom, BN_ZERO), BNCoin.fromDenomAndBigNumber(sellAsset.denom, BN_ZERO), - isAutoLendEnabled ? 'lend' : 'deposit', + isAutoLendEnabled && !isAutoRepayChecked ? 'lend' : 'deposit', isAutoRepayChecked, ) }, [ diff --git a/src/components/Trade/TradeModule/index.tsx b/src/components/Trade/TradeModule/index.tsx index 4b5e7008..7f74b3b6 100644 --- a/src/components/Trade/TradeModule/index.tsx +++ b/src/components/Trade/TradeModule/index.tsx @@ -12,15 +12,16 @@ export default function TradeModule(props: Props) { const { buyAsset, sellAsset } = props return ( -
- - +
+
+ + +
) } diff --git a/src/components/Wallet/WalletFetchBalancesAndAccounts.tsx b/src/components/Wallet/WalletFetchBalancesAndAccounts.tsx index 63916312..426a19dc 100644 --- a/src/components/Wallet/WalletFetchBalancesAndAccounts.tsx +++ b/src/components/Wallet/WalletFetchBalancesAndAccounts.tsx @@ -32,7 +32,11 @@ function Content() { const urlAccountId = useAccountId() const navigate = useNavigate() const { pathname } = useLocation() - const { data: accountIds, isLoading: isLoadingAccounts } = useAccountIds(address || '') + const { data: accountIds, isLoading: isLoadingAccounts } = useAccountIds( + address || '', + true, + true, + ) const { data: walletBalances, isLoading: isLoadingBalances } = useWalletBalances(address) const baseAsset = getBaseAsset() @@ -54,7 +58,9 @@ function Content() { accountIds.length !== 0 && BN(baseBalance).isGreaterThanOrEqualTo(defaultFee.amount[0].amount) ) { - navigate(getRoute(page, address, urlAccountId ?? accountIds[0])) + const currentAccountIsHLS = urlAccountId && !accountIds.includes(urlAccountId) + const currentAccount = currentAccountIsHLS || !urlAccountId ? accountIds[0] : urlAccountId + navigate(getRoute(page, address, currentAccount)) useStore.setState({ balances: walletBalances, focusComponent: null }) } }, [ diff --git a/src/constants/assets.ts b/src/constants/assets.ts index 387946c0..709a3dd4 100644 --- a/src/constants/assets.ts +++ b/src/constants/assets.ts @@ -83,8 +83,8 @@ export const ASSETS: Asset[] = [ isDisplayCurrency: true, isAutoLendEnabled: true, isBorrowEnabled: true, - pythPriceFeedId: 'e62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43', - pythHistoryFeedId: 'Crypto.BTC/USD', + pythPriceFeedId: 'c9d8b075a5c69303365ae23633d4e085199bf5c520a3b90fed1322a0342ffc33', + pythHistoryFeedId: 'Crypto.WBTC/USD', poolId: 712, }, { diff --git a/src/hooks/useAccountIds.tsx b/src/hooks/useAccountIds.tsx index c5168685..3acde859 100644 --- a/src/hooks/useAccountIds.tsx +++ b/src/hooks/useAccountIds.tsx @@ -4,7 +4,7 @@ import getAccountIds from 'api/wallets/getAccountIds' export default function useAccountIdsAndKinds(address?: string, suspense = true, noHls = false) { return useSWR( - `wallets/${address}/account-ids`, + `wallets/${address}/account-ids${noHls && '-without-hls'}`, () => getAccountIds(address).then((accountIdsAndKinds) => { if (noHls) { diff --git a/src/hooks/useHealthComputer.tsx b/src/hooks/useHealthComputer.tsx index bd1a1feb..22b4432e 100644 --- a/src/hooks/useHealthComputer.tsx +++ b/src/hooks/useHealthComputer.tsx @@ -216,8 +216,9 @@ export default function useHealthComputer(account?: Account) { ) const health = useMemo(() => { + const slope = account?.kind === 'high_levered_strategy' ? 1.2 : 3.5 const convertedHealth = BN(Math.log(healthFactor)) - .dividedBy(Math.log(3.5)) + .dividedBy(Math.log(slope)) .multipliedBy(100) .integerValue() .toNumber() @@ -226,7 +227,7 @@ export default function useHealthComputer(account?: Account) { if (convertedHealth === 0 && healthFactor > 1) return 1 if (convertedHealth < 0) return 0 return convertedHealth - }, [healthFactor]) + }, [healthFactor, account?.kind]) return { health, diff --git a/src/hooks/useUpdatedAccount/index.ts b/src/hooks/useUpdatedAccount/index.ts index a3a9bbf1..6fdcdc39 100644 --- a/src/hooks/useUpdatedAccount/index.ts +++ b/src/hooks/useUpdatedAccount/index.ts @@ -96,12 +96,12 @@ export function useUpdatedAccount(account?: Account) { ) const simulateRepay = useCallback( - (coin: BNCoin) => { + (coin: BNCoin, repayFromWallet: boolean) => { if (!account) return const { deposit, lend } = getDepositAndLendCoinsToSpend(coin, account) removeDebts([coin]) - removeDeposits([deposit]) - removeLends([lend]) + removeDeposits(repayFromWallet ? [] : [deposit]) + removeLends(repayFromWallet ? [] : [lend]) }, [account, removeDebts, removeDeposits, removeLends], ) diff --git a/src/pages/TradePage.tsx b/src/pages/TradePage.tsx index 45b22a81..9f878560 100644 --- a/src/pages/TradePage.tsx +++ b/src/pages/TradePage.tsx @@ -34,7 +34,6 @@ export default function TradePage() {
-
{assetOverlayState !== 'closed' && ( diff --git a/src/store/slices/broadcast.ts b/src/store/slices/broadcast.ts index 8ef29f88..4559d984 100644 --- a/src/store/slices/broadcast.ts +++ b/src/store/slices/broadcast.ts @@ -721,7 +721,8 @@ export default function createBroadcastSlice( if ( checkAutoLendEnabled(options.accountId) && - getAssetByDenom(options.denomOut)?.isAutoLendEnabled + getAssetByDenom(options.denomOut)?.isAutoLendEnabled && + !options.repay ) { msg.update_credit_account.actions.push({ lend: { denom: options.denomOut, amount: 'account_balance' }, diff --git a/src/types/custom.d.ts b/src/types/custom.d.ts index 2e323377..9326ab51 100644 --- a/src/types/custom.d.ts +++ b/src/types/custom.d.ts @@ -1,4 +1,12 @@ +import '@tanstack/react-table' + declare module '*.svg' { const content: React.FunctionComponent> export default content } + +declare module '@tanstack/table-core' { + interface ColumnMeta { + className?: string + } +} diff --git a/src/utils/constants.ts b/src/utils/constants.ts index f106b65f..937895be 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -22,4 +22,4 @@ export const DEFAULT_PORTFOLIO_STATS = [ export const ENABLE_HLS = true export const ENABLE_PERPS = false -export const ENABLE_AUTO_REPAY = false +export const ENABLE_AUTO_REPAY = true