mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
* add top * copy, section move * asset teaser prototyping * more moving elements around * copy * allocated on asset details stats area * ve networks "hacks" * fix type * added hacks to display top allocation * fixed chainIds * remove comment * add ve in asset stats * remove console * added formating and totals * update total allocated * update allocation * fixed numbers * fix build * added teaser warn when no price * number formatting Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
46 lines
1.1 KiB
TypeScript
46 lines
1.1 KiB
TypeScript
import { AllLocked } from 'src/@types/subgraph/AllLocked'
|
|
import { gql, OperationResult } from 'urql'
|
|
import { fetchData, getQueryContext } from './subgraph'
|
|
import axios from 'axios'
|
|
|
|
const AllLocked = gql`
|
|
query AllLocked {
|
|
veOCEANs(first: 1000) {
|
|
lockedAmount
|
|
}
|
|
}
|
|
`
|
|
|
|
interface TotalVe {
|
|
totalLocked: number
|
|
totalAllocated: number
|
|
}
|
|
|
|
export async function getTotalAllocatedAndLocked(): Promise<TotalVe> {
|
|
const totals = {
|
|
totalLocked: 0,
|
|
totalAllocated: 0
|
|
}
|
|
|
|
const queryContext = getQueryContext(1)
|
|
|
|
const response = await axios.post(`https://df-sql.oceandao.org/nftinfo`)
|
|
totals.totalAllocated = response.data?.reduce(
|
|
(previousValue: number, currentValue: { ve_allocated: any }) =>
|
|
previousValue + Number(currentValue.ve_allocated),
|
|
0
|
|
)
|
|
|
|
const fetchedLocked: OperationResult<AllLocked, any> = await fetchData(
|
|
AllLocked,
|
|
null,
|
|
queryContext
|
|
)
|
|
totals.totalLocked = fetchedLocked.data?.veOCEANs.reduce(
|
|
(previousValue, currentValue) =>
|
|
previousValue + Number(currentValue.lockedAmount),
|
|
0
|
|
)
|
|
return totals
|
|
}
|