Merge changes from production (#364)

This commit is contained in:
Riordan Panayides 2022-07-17 16:58:15 +01:00 committed by Maximilian Schneider
parent 20f54be2ad
commit dd1c0fab1d
4 changed files with 15 additions and 50 deletions

View File

@ -26,7 +26,7 @@ import {
} from '../TableElements'
import { LinkButton } from '../Button'
import { useSortableData } from '../../hooks/useSortableData'
import { formatUsdValue, getDelistedMarketKey } from '../../utils'
import { formatUsdValue } from '../../utils'
import Tooltip from '../Tooltip'
import { exportDataToCSV } from '../../utils/export'
import { notify } from '../../utils/notifications'
@ -332,7 +332,7 @@ const LiquidationHistoryTable = ({ history, view }) => {
let perpMarket: PerpMarket | null = null
if (activity_type.includes('perp')) {
const symbol = activity_details.perp_market.split('-')[0]
const marketConfig = getMarketByBaseSymbolAndKind(
groupConfig,
symbol,
@ -344,7 +344,9 @@ const LiquidationHistoryTable = ({ history, view }) => {
marketConfig.publicKey.toString()
] as PerpMarket
} else {
perpMarket = markets[getDelistedMarketKey(symbol)] as PerpMarket
perpMarket = markets[
marketConfig.publicKey.toBase58()
] as PerpMarket
}
}

View File

@ -88,11 +88,7 @@ const AccountInterest = () => {
const token = useMemo(() => {
if (selectedAsset) {
try {
return getTokenBySymbol(groupConfig, selectedAsset)
} catch {
return { decimals: 6 }
}
return getTokenBySymbol(groupConfig, selectedAsset)
}
}, [selectedAsset])
@ -171,13 +167,8 @@ const AccountInterest = () => {
} else {
const stats = Object.entries(parsedResponse)
const filterMicroBalances = stats.filter(([symbol, stats]) => {
let decimals = 6
try {
decimals = getTokenBySymbol(groupConfig, symbol).decimals
} catch {
/* Use default value */
}
const decimals = getTokenBySymbol(groupConfig, symbol).decimals
const smallestValue = Math.pow(10, (decimals + 1) * -1)
return (
stats.total_borrow_interest > smallestValue ||
@ -209,12 +200,7 @@ const AccountInterest = () => {
const stats = {}
for (const asset of assets) {
const x: any = Object.entries(parsedResponse[asset])
let decimals = 6
try {
decimals = getTokenBySymbol(groupConfig, asset).decimals
} catch {
/* Use default value */
}
const decimals = getTokenBySymbol(groupConfig, asset).decimals
stats[asset] = x
.map(([key, value, price]) => {
@ -344,12 +330,10 @@ const AccountInterest = () => {
</TrBody>
) : (
interestStats.map(([symbol, stats]) => {
let decimals = 6
try {
decimals = getTokenBySymbol(groupConfig, symbol).decimals
} catch {
/* Use default value */
}
const decimals = getTokenBySymbol(
groupConfig,
symbol
).decimals
return (
<TrBody key={symbol}>
@ -398,12 +382,7 @@ const AccountInterest = () => {
colTwoHeader={t('net')}
/>
{interestStats.map(([symbol, stats], index) => {
let decimals = 6
try {
decimals = getTokenBySymbol(groupConfig, symbol).decimals
} catch {
/* Use default value */
}
const decimals = getTokenBySymbol(groupConfig, symbol).decimals
return (
<ExpandableRow

View File

@ -9,7 +9,7 @@ import {
marketConfigSelector,
} from '../stores/selectors'
import useMangoStore from '../stores/useMangoStore'
import { getDelistedMarketName, perpContractPrecision } from '../utils'
import { perpContractPrecision } from '../utils'
const byTimestamp = (a, b) => {
return (
@ -27,8 +27,6 @@ function getMarketName(event) {
const marketInfo = getMarketByPublicKey(mangoGroupConfig, event.address)
if (marketInfo) {
marketName = marketInfo.name
} else {
marketName = getDelistedMarketName(event.address)
}
}
return event.marketName || marketName

View File

@ -349,17 +349,3 @@ export const isValidSolanaAddress = (address: string) => {
return false
}
}
export const delistedMarkets = [
{ key: 'BCJrpvsB2BJtqiDgKVC4N6gyX1y24Jz96C6wMraYmXss', name: 'LUNA-PERP', decimals: 6 },
{ key: 'HBTu8hNaoT3VyiSSzJYa8jwt9sDGKtJviSwFa11iXdmE', name: 'LUNA/USDC', decimals: 6 },
{ key: '6fc7v3PmjZG9Lk2XTot6BywGyYLkBQuzuFKd4FpCsPxk', name: 'COPE/USDC', decimals: 6 },
];
export const getDelistedMarketKey = (name: string) => {
return (delistedMarkets.find(x => x.name == name)?.key ?? '');
}
export const getDelistedMarketName = (key: string) => {
return (delistedMarkets.find(x => x.key == key)?.name ?? '');
}