use latest mango client for risk dashboard

This commit is contained in:
tjs 2023-06-07 20:49:10 -04:00
parent 655662bf05
commit 93e3fca34a
3 changed files with 26 additions and 18 deletions

View File

@ -19,7 +19,7 @@
},
"dependencies": {
"@blockworks-foundation/mango-feeds": "0.1.6",
"@blockworks-foundation/mango-v4": "^0.15.12",
"@blockworks-foundation/mango-v4": "^0.15.13",
"@headlessui/react": "1.6.6",
"@heroicons/react": "2.0.10",
"@metaplex-foundation/js": "0.18.3",

View File

@ -22,13 +22,18 @@ export async function getStaticProps({ locale }: { locale: string }) {
}
}
type TableRow = {
val: string | number | PublicKey
highlight: boolean
}
type TableData = {
title: string
data: Array<Record<string, string | number | PublicKey>>
data: Array<Record<string, TableRow>>
}
const formatValue = (val: string | number | PublicKey) => {
if (val instanceof PublicKey) {
if (val instanceof PublicKey || typeof val === 'object') {
return val.toString()
}
if (typeof val === 'string') {
@ -41,7 +46,7 @@ const formatValue = (val: string | number | PublicKey) => {
const RiskDashboard: NextPage = () => {
const { group } = useMangoGroup()
const { data, isLoading, isFetching } = useQuery(
const { data } = useQuery(
['risks'],
() => {
const provider = new AnchorProvider(
@ -64,13 +69,13 @@ const RiskDashboard: NextPage = () => {
{
cacheTime: 1000 * 60 * 5,
staleTime: 1000 * 60 * 5,
retry: 1,
retry: 0,
refetchOnWindowFocus: false,
enabled: !!group,
}
)
console.log('resp', isLoading, isFetching, data)
console.log('resp', data)
return (
<div className="grid grid-cols-12">
@ -82,6 +87,8 @@ const RiskDashboard: NextPage = () => {
<div className="mt-4">
{Object.entries(data).map(
([tableType, table]: [string, TableData]) => {
console.log('table', table)
if (!table?.data?.length) return null
return (
<div className="mt-12" key={tableType}>
<div className="mb-4">
@ -118,18 +125,19 @@ const RiskDashboard: NextPage = () => {
</thead>
<tbody>
{table.data.map((rowData, index: number) => {
console.log('rowData', Object.values(rowData))
return (
<TrBody key={index}>
{Object.values(rowData).map(
(
val: string | number | PublicKey,
idx: number
) => {
(val, idx: number) => {
return (
<Td xBorder className={''} key={idx}>
{formatValue(val)}
<Td
xBorder
className={`${
val?.highlight ? 'bg-th-bkg-2' : ''
}`}
key={idx}
>
{formatValue(val?.val)}
</Td>
)
}

View File

@ -21,10 +21,10 @@
dependencies:
ws "^8.13.0"
"@blockworks-foundation/mango-v4@^0.15.12":
version "0.15.12"
resolved "https://registry.yarnpkg.com/@blockworks-foundation/mango-v4/-/mango-v4-0.15.12.tgz#c870dbf31e188b4884fd716468db546861f06bd9"
integrity sha512-k0Bn9VmdwFyAF+G5dYS2aSZJ4MWH7RtTHz9ZZNgUKKTaLR+N2WhA7oH6d4O1k4KCIIVudvsN6burMgMpzm4zXg==
"@blockworks-foundation/mango-v4@^0.15.13":
version "0.15.13"
resolved "https://registry.yarnpkg.com/@blockworks-foundation/mango-v4/-/mango-v4-0.15.13.tgz#adbfb63a69fc94ddaed9a7d65733e881335d092d"
integrity sha512-akqs0LYK7sjD5mqxwGWBaN7AaPIgDhdUswRWjFRCRXJy1B9la2pmJv9iWjXFU9DDWPORrpu5psFZ0NZ8hYKpnA==
dependencies:
"@coral-xyz/anchor" "^0.26.0"
"@project-serum/serum" "0.13.65"