2021-06-25 09:50:56 +02:00
|
|
|
import { gql, OperationResult, TypedDocumentNode, OperationContext } from 'urql'
|
2022-01-11 20:45:14 +01:00
|
|
|
import { Asset, LoggerInstance } from '@oceanprotocol/lib'
|
2021-10-13 18:48:59 +02:00
|
|
|
import { getUrqlClientInstance } from '@context/UrqlProvider'
|
2021-06-25 09:50:56 +02:00
|
|
|
import { getOceanConfig } from './ocean'
|
2022-02-07 15:58:47 +01:00
|
|
|
import { AssetPoolPrice } from '../@types/subgraph/AssetPoolPrice'
|
2022-01-14 00:48:05 +01:00
|
|
|
import { AssetPreviousOrder } from '../@types/subgraph/AssetPreviousOrder'
|
2021-07-15 17:25:53 +02:00
|
|
|
import {
|
2021-09-01 17:48:54 +02:00
|
|
|
HighestLiquidityAssets_pools as HighestLiquidityAssetsPool,
|
2021-07-15 17:25:53 +02:00
|
|
|
HighestLiquidityAssets as HighestLiquidityGraphAssets
|
2022-01-14 00:48:05 +01:00
|
|
|
} from '../@types/subgraph/HighestLiquidityAssets'
|
Account metadata header (#776)
* get all neded data for the header from 3box, aqua and subgraph
* fix tvl display error
* WIP metadata header styling
* added more styling for the header
* make page title optional so we can remove it on account page
* stroke change for svg images and default values
* more styling added to the header
* fixed linter
* added ocean balance to tvl
* update styling for statistcs
* fixed eror for go to my account from another account page
* updated styling for mobile use
* wip show more on explorer links and description
* properly display read more for explorer links and description
* replaced show more with 3box redirect on description
* change accounts default picture and check links length before display element
* use optional on links
* grid cleanup, new number unit, split up stats
* rename all the things, more profile header styling
* visual hierarchy, improve image loading experience
* layout flow & visual tweaks
* more description
* replaced account route with profile when accesing a profile by the eth address
* use account id from url if exists when fetching data
* bump @oceanprotocol/art to v3.2.0
* styling, fallbacks, edge case fixes
* clean up Publisher atom, link to profile page
* fixed issue when switching to my profile from another profile
* output accountId, make it copyable, remove stats icons
* render tweaks, markup cleanup
* add 3box reference
* mobile tabs spacing tweaks
* text flow and spacing tweaks
Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2021-09-01 13:56:34 +02:00
|
|
|
import {
|
|
|
|
PoolShares as PoolSharesList,
|
|
|
|
PoolShares_poolShares as PoolShare
|
2022-01-14 00:48:05 +01:00
|
|
|
} from '../@types/subgraph/PoolShares'
|
2022-03-09 13:58:54 +01:00
|
|
|
import { OrdersData_orders as OrdersData } from '../@types/subgraph/OrdersData'
|
2022-01-14 00:48:05 +01:00
|
|
|
import { UserSalesQuery as UsersSalesList } from '../@types/subgraph/UserSalesQuery'
|
2022-02-24 16:21:45 +01:00
|
|
|
import { OpcFeesQuery as OpcFeesData } from '../@types/subgraph/OpcFeesQuery'
|
2022-04-22 02:38:35 +02:00
|
|
|
import { calcSingleOutGivenPoolIn, getLiquidityByShares } from './pool'
|
2022-03-09 13:58:54 +01:00
|
|
|
import Decimal from 'decimal.js'
|
|
|
|
import { MAX_DECIMALS } from './constants'
|
Account metadata header (#776)
* get all neded data for the header from 3box, aqua and subgraph
* fix tvl display error
* WIP metadata header styling
* added more styling for the header
* make page title optional so we can remove it on account page
* stroke change for svg images and default values
* more styling added to the header
* fixed linter
* added ocean balance to tvl
* update styling for statistcs
* fixed eror for go to my account from another account page
* updated styling for mobile use
* wip show more on explorer links and description
* properly display read more for explorer links and description
* replaced show more with 3box redirect on description
* change accounts default picture and check links length before display element
* use optional on links
* grid cleanup, new number unit, split up stats
* rename all the things, more profile header styling
* visual hierarchy, improve image loading experience
* layout flow & visual tweaks
* more description
* replaced account route with profile when accesing a profile by the eth address
* use account id from url if exists when fetching data
* bump @oceanprotocol/art to v3.2.0
* styling, fallbacks, edge case fixes
* clean up Publisher atom, link to profile page
* fixed issue when switching to my profile from another profile
* output accountId, make it copyable, remove stats icons
* render tweaks, markup cleanup
* add 3box reference
* mobile tabs spacing tweaks
* text flow and spacing tweaks
Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2021-09-01 13:56:34 +02:00
|
|
|
|
2021-09-13 16:39:32 +02:00
|
|
|
export interface UserLiquidity {
|
Account metadata header (#776)
* get all neded data for the header from 3box, aqua and subgraph
* fix tvl display error
* WIP metadata header styling
* added more styling for the header
* make page title optional so we can remove it on account page
* stroke change for svg images and default values
* more styling added to the header
* fixed linter
* added ocean balance to tvl
* update styling for statistcs
* fixed eror for go to my account from another account page
* updated styling for mobile use
* wip show more on explorer links and description
* properly display read more for explorer links and description
* replaced show more with 3box redirect on description
* change accounts default picture and check links length before display element
* use optional on links
* grid cleanup, new number unit, split up stats
* rename all the things, more profile header styling
* visual hierarchy, improve image loading experience
* layout flow & visual tweaks
* more description
* replaced account route with profile when accesing a profile by the eth address
* use account id from url if exists when fetching data
* bump @oceanprotocol/art to v3.2.0
* styling, fallbacks, edge case fixes
* clean up Publisher atom, link to profile page
* fixed issue when switching to my profile from another profile
* output accountId, make it copyable, remove stats icons
* render tweaks, markup cleanup
* add 3box reference
* mobile tabs spacing tweaks
* text flow and spacing tweaks
Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2021-09-01 13:56:34 +02:00
|
|
|
price: string
|
|
|
|
oceanBalance: string
|
|
|
|
}
|
2021-04-09 11:55:18 +02:00
|
|
|
|
2021-04-14 13:41:17 +02:00
|
|
|
export interface PriceList {
|
|
|
|
[key: string]: string
|
|
|
|
}
|
|
|
|
|
2021-09-01 17:48:54 +02:00
|
|
|
const AssetPoolPriceQuery = gql`
|
2021-04-20 08:44:18 +02:00
|
|
|
query AssetPoolPrice($datatokenAddress: String) {
|
2022-01-13 22:24:06 +01:00
|
|
|
pools(where: { datatoken: $datatokenAddress }) {
|
2021-04-09 11:55:18 +02:00
|
|
|
id
|
2021-04-20 08:44:18 +02:00
|
|
|
spotPrice
|
2022-01-13 22:24:06 +01:00
|
|
|
datatoken {
|
|
|
|
address
|
|
|
|
symbol
|
|
|
|
}
|
|
|
|
baseToken {
|
2021-09-01 16:05:59 +02:00
|
|
|
symbol
|
|
|
|
}
|
2022-01-13 22:24:06 +01:00
|
|
|
datatokenLiquidity
|
|
|
|
baseTokenLiquidity
|
2021-04-09 11:55:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
2021-04-20 08:44:18 +02:00
|
|
|
const PreviousOrderQuery = gql`
|
2021-04-11 01:13:43 +02:00
|
|
|
query AssetPreviousOrder($id: String!, $account: String!) {
|
2022-01-13 22:24:06 +01:00
|
|
|
orders(
|
2021-04-11 01:13:43 +02:00
|
|
|
first: 1
|
2022-01-31 13:41:58 +01:00
|
|
|
where: { datatoken: $id, payer: $account }
|
2022-01-13 22:24:06 +01:00
|
|
|
orderBy: createdTimestamp
|
2021-04-11 01:13:43 +02:00
|
|
|
orderDirection: desc
|
|
|
|
) {
|
2022-01-13 22:24:06 +01:00
|
|
|
createdTimestamp
|
2021-04-11 01:13:43 +02:00
|
|
|
tx
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`
|
2021-06-02 11:14:54 +02:00
|
|
|
const HighestLiquidityAssets = gql`
|
2021-07-15 17:25:53 +02:00
|
|
|
query HighestLiquidityAssets {
|
2021-06-04 13:23:18 +02:00
|
|
|
pools(
|
2022-01-13 22:24:06 +01:00
|
|
|
where: { datatokenLiquidity_gte: 1 }
|
|
|
|
orderBy: baseTokenLiquidity
|
2021-06-04 13:23:18 +02:00
|
|
|
orderDirection: desc
|
|
|
|
first: 15
|
|
|
|
) {
|
2021-06-02 11:14:54 +02:00
|
|
|
id
|
2022-01-13 22:24:06 +01:00
|
|
|
datatoken {
|
|
|
|
address
|
|
|
|
}
|
2022-01-13 22:41:19 +01:00
|
|
|
baseToken {
|
|
|
|
symbol
|
|
|
|
}
|
2022-01-13 22:24:06 +01:00
|
|
|
baseTokenLiquidity
|
2022-02-10 15:41:07 +01:00
|
|
|
datatokenLiquidity
|
2021-06-02 11:14:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
`
|
2021-04-11 01:13:43 +02:00
|
|
|
|
Account metadata header (#776)
* get all neded data for the header from 3box, aqua and subgraph
* fix tvl display error
* WIP metadata header styling
* added more styling for the header
* make page title optional so we can remove it on account page
* stroke change for svg images and default values
* more styling added to the header
* fixed linter
* added ocean balance to tvl
* update styling for statistcs
* fixed eror for go to my account from another account page
* updated styling for mobile use
* wip show more on explorer links and description
* properly display read more for explorer links and description
* replaced show more with 3box redirect on description
* change accounts default picture and check links length before display element
* use optional on links
* grid cleanup, new number unit, split up stats
* rename all the things, more profile header styling
* visual hierarchy, improve image loading experience
* layout flow & visual tweaks
* more description
* replaced account route with profile when accesing a profile by the eth address
* use account id from url if exists when fetching data
* bump @oceanprotocol/art to v3.2.0
* styling, fallbacks, edge case fixes
* clean up Publisher atom, link to profile page
* fixed issue when switching to my profile from another profile
* output accountId, make it copyable, remove stats icons
* render tweaks, markup cleanup
* add 3box reference
* mobile tabs spacing tweaks
* text flow and spacing tweaks
Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2021-09-01 13:56:34 +02:00
|
|
|
const UserSharesQuery = gql`
|
|
|
|
query UserSharesQuery($user: String, $pools: [String!]) {
|
2022-01-13 22:24:06 +01:00
|
|
|
poolShares(where: { user: $user, pool_in: $pools }) {
|
Account metadata header (#776)
* get all neded data for the header from 3box, aqua and subgraph
* fix tvl display error
* WIP metadata header styling
* added more styling for the header
* make page title optional so we can remove it on account page
* stroke change for svg images and default values
* more styling added to the header
* fixed linter
* added ocean balance to tvl
* update styling for statistcs
* fixed eror for go to my account from another account page
* updated styling for mobile use
* wip show more on explorer links and description
* properly display read more for explorer links and description
* replaced show more with 3box redirect on description
* change accounts default picture and check links length before display element
* use optional on links
* grid cleanup, new number unit, split up stats
* rename all the things, more profile header styling
* visual hierarchy, improve image loading experience
* layout flow & visual tweaks
* more description
* replaced account route with profile when accesing a profile by the eth address
* use account id from url if exists when fetching data
* bump @oceanprotocol/art to v3.2.0
* styling, fallbacks, edge case fixes
* clean up Publisher atom, link to profile page
* fixed issue when switching to my profile from another profile
* output accountId, make it copyable, remove stats icons
* render tweaks, markup cleanup
* add 3box reference
* mobile tabs spacing tweaks
* text flow and spacing tweaks
Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2021-09-01 13:56:34 +02:00
|
|
|
id
|
2022-01-13 22:24:06 +01:00
|
|
|
shares
|
|
|
|
user {
|
Account metadata header (#776)
* get all neded data for the header from 3box, aqua and subgraph
* fix tvl display error
* WIP metadata header styling
* added more styling for the header
* make page title optional so we can remove it on account page
* stroke change for svg images and default values
* more styling added to the header
* fixed linter
* added ocean balance to tvl
* update styling for statistcs
* fixed eror for go to my account from another account page
* updated styling for mobile use
* wip show more on explorer links and description
* properly display read more for explorer links and description
* replaced show more with 3box redirect on description
* change accounts default picture and check links length before display element
* use optional on links
* grid cleanup, new number unit, split up stats
* rename all the things, more profile header styling
* visual hierarchy, improve image loading experience
* layout flow & visual tweaks
* more description
* replaced account route with profile when accesing a profile by the eth address
* use account id from url if exists when fetching data
* bump @oceanprotocol/art to v3.2.0
* styling, fallbacks, edge case fixes
* clean up Publisher atom, link to profile page
* fixed issue when switching to my profile from another profile
* output accountId, make it copyable, remove stats icons
* render tweaks, markup cleanup
* add 3box reference
* mobile tabs spacing tweaks
* text flow and spacing tweaks
Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2021-09-01 13:56:34 +02:00
|
|
|
id
|
|
|
|
}
|
2022-01-13 22:24:06 +01:00
|
|
|
pool {
|
Account metadata header (#776)
* get all neded data for the header from 3box, aqua and subgraph
* fix tvl display error
* WIP metadata header styling
* added more styling for the header
* make page title optional so we can remove it on account page
* stroke change for svg images and default values
* more styling added to the header
* fixed linter
* added ocean balance to tvl
* update styling for statistcs
* fixed eror for go to my account from another account page
* updated styling for mobile use
* wip show more on explorer links and description
* properly display read more for explorer links and description
* replaced show more with 3box redirect on description
* change accounts default picture and check links length before display element
* use optional on links
* grid cleanup, new number unit, split up stats
* rename all the things, more profile header styling
* visual hierarchy, improve image loading experience
* layout flow & visual tweaks
* more description
* replaced account route with profile when accesing a profile by the eth address
* use account id from url if exists when fetching data
* bump @oceanprotocol/art to v3.2.0
* styling, fallbacks, edge case fixes
* clean up Publisher atom, link to profile page
* fixed issue when switching to my profile from another profile
* output accountId, make it copyable, remove stats icons
* render tweaks, markup cleanup
* add 3box reference
* mobile tabs spacing tweaks
* text flow and spacing tweaks
Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2021-09-01 13:56:34 +02:00
|
|
|
id
|
2022-01-13 22:24:06 +01:00
|
|
|
datatoken {
|
|
|
|
address
|
|
|
|
symbol
|
|
|
|
}
|
|
|
|
baseToken {
|
|
|
|
address
|
|
|
|
symbol
|
Account metadata header (#776)
* get all neded data for the header from 3box, aqua and subgraph
* fix tvl display error
* WIP metadata header styling
* added more styling for the header
* make page title optional so we can remove it on account page
* stroke change for svg images and default values
* more styling added to the header
* fixed linter
* added ocean balance to tvl
* update styling for statistcs
* fixed eror for go to my account from another account page
* updated styling for mobile use
* wip show more on explorer links and description
* properly display read more for explorer links and description
* replaced show more with 3box redirect on description
* change accounts default picture and check links length before display element
* use optional on links
* grid cleanup, new number unit, split up stats
* rename all the things, more profile header styling
* visual hierarchy, improve image loading experience
* layout flow & visual tweaks
* more description
* replaced account route with profile when accesing a profile by the eth address
* use account id from url if exists when fetching data
* bump @oceanprotocol/art to v3.2.0
* styling, fallbacks, edge case fixes
* clean up Publisher atom, link to profile page
* fixed issue when switching to my profile from another profile
* output accountId, make it copyable, remove stats icons
* render tweaks, markup cleanup
* add 3box reference
* mobile tabs spacing tweaks
* text flow and spacing tweaks
Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2021-09-01 13:56:34 +02:00
|
|
|
}
|
2022-01-13 22:24:06 +01:00
|
|
|
datatokenLiquidity
|
|
|
|
baseTokenLiquidity
|
Account metadata header (#776)
* get all neded data for the header from 3box, aqua and subgraph
* fix tvl display error
* WIP metadata header styling
* added more styling for the header
* make page title optional so we can remove it on account page
* stroke change for svg images and default values
* more styling added to the header
* fixed linter
* added ocean balance to tvl
* update styling for statistcs
* fixed eror for go to my account from another account page
* updated styling for mobile use
* wip show more on explorer links and description
* properly display read more for explorer links and description
* replaced show more with 3box redirect on description
* change accounts default picture and check links length before display element
* use optional on links
* grid cleanup, new number unit, split up stats
* rename all the things, more profile header styling
* visual hierarchy, improve image loading experience
* layout flow & visual tweaks
* more description
* replaced account route with profile when accesing a profile by the eth address
* use account id from url if exists when fetching data
* bump @oceanprotocol/art to v3.2.0
* styling, fallbacks, edge case fixes
* clean up Publisher atom, link to profile page
* fixed issue when switching to my profile from another profile
* output accountId, make it copyable, remove stats icons
* render tweaks, markup cleanup
* add 3box reference
* mobile tabs spacing tweaks
* text flow and spacing tweaks
Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2021-09-01 13:56:34 +02:00
|
|
|
totalShares
|
|
|
|
spotPrice
|
2022-01-13 22:24:06 +01:00
|
|
|
createdTimestamp
|
Account metadata header (#776)
* get all neded data for the header from 3box, aqua and subgraph
* fix tvl display error
* WIP metadata header styling
* added more styling for the header
* make page title optional so we can remove it on account page
* stroke change for svg images and default values
* more styling added to the header
* fixed linter
* added ocean balance to tvl
* update styling for statistcs
* fixed eror for go to my account from another account page
* updated styling for mobile use
* wip show more on explorer links and description
* properly display read more for explorer links and description
* replaced show more with 3box redirect on description
* change accounts default picture and check links length before display element
* use optional on links
* grid cleanup, new number unit, split up stats
* rename all the things, more profile header styling
* visual hierarchy, improve image loading experience
* layout flow & visual tweaks
* more description
* replaced account route with profile when accesing a profile by the eth address
* use account id from url if exists when fetching data
* bump @oceanprotocol/art to v3.2.0
* styling, fallbacks, edge case fixes
* clean up Publisher atom, link to profile page
* fixed issue when switching to my profile from another profile
* output accountId, make it copyable, remove stats icons
* render tweaks, markup cleanup
* add 3box reference
* mobile tabs spacing tweaks
* text flow and spacing tweaks
Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2021-09-01 13:56:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`
|
2021-09-13 16:39:32 +02:00
|
|
|
|
|
|
|
const userPoolSharesQuery = gql`
|
|
|
|
query PoolShares($user: String) {
|
2022-01-13 22:24:06 +01:00
|
|
|
poolShares(where: { user: $user, shares_gt: 0.001 }, first: 1000) {
|
2021-09-13 16:39:32 +02:00
|
|
|
id
|
2022-01-13 22:24:06 +01:00
|
|
|
shares
|
|
|
|
user {
|
2021-09-13 16:39:32 +02:00
|
|
|
id
|
|
|
|
}
|
2022-01-13 22:24:06 +01:00
|
|
|
pool {
|
2021-09-13 16:39:32 +02:00
|
|
|
id
|
2022-01-13 22:24:06 +01:00
|
|
|
datatoken {
|
2021-09-13 16:39:32 +02:00
|
|
|
id
|
2022-01-13 22:24:06 +01:00
|
|
|
address
|
2021-09-13 16:39:32 +02:00
|
|
|
symbol
|
|
|
|
}
|
2022-01-13 22:24:06 +01:00
|
|
|
baseToken {
|
|
|
|
id
|
|
|
|
address
|
|
|
|
symbol
|
|
|
|
}
|
|
|
|
baseTokenLiquidity
|
|
|
|
datatokenLiquidity
|
2021-09-13 16:39:32 +02:00
|
|
|
totalShares
|
|
|
|
spotPrice
|
2022-01-13 22:24:06 +01:00
|
|
|
createdTimestamp
|
2021-09-13 16:39:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
|
|
|
const UserTokenOrders = gql`
|
|
|
|
query OrdersData($user: String!) {
|
2022-01-13 22:24:06 +01:00
|
|
|
orders(
|
|
|
|
orderBy: createdTimestamp
|
2021-09-13 16:39:32 +02:00
|
|
|
orderDirection: desc
|
|
|
|
where: { consumer: $user }
|
|
|
|
) {
|
2022-02-21 16:15:33 +01:00
|
|
|
consumer {
|
|
|
|
id
|
|
|
|
}
|
2022-01-31 13:41:58 +01:00
|
|
|
datatoken {
|
2022-02-21 16:15:33 +01:00
|
|
|
id
|
2022-01-31 13:41:58 +01:00
|
|
|
address
|
|
|
|
symbol
|
|
|
|
}
|
|
|
|
consumerMarketToken {
|
2021-09-13 16:39:32 +02:00
|
|
|
address
|
|
|
|
symbol
|
|
|
|
}
|
2022-01-13 22:24:06 +01:00
|
|
|
createdTimestamp
|
2021-09-13 16:39:32 +02:00
|
|
|
tx
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`
|
2022-01-13 22:24:06 +01:00
|
|
|
|
2021-10-18 16:43:32 +02:00
|
|
|
const UserSalesQuery = gql`
|
2022-03-09 13:58:54 +01:00
|
|
|
query UserSalesQuery($user: ID!) {
|
2022-02-21 16:15:33 +01:00
|
|
|
users(where: { id: $user }) {
|
2021-10-18 16:43:32 +02:00
|
|
|
id
|
2022-02-21 16:15:33 +01:00
|
|
|
totalSales
|
2021-10-18 16:43:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
`
|
2021-09-13 16:39:32 +02:00
|
|
|
|
2022-01-13 22:24:06 +01:00
|
|
|
// TODO: figure out some way to get this
|
2021-12-10 10:50:00 +01:00
|
|
|
const TopSalesQuery = gql`
|
|
|
|
query TopSalesQuery {
|
|
|
|
users(
|
|
|
|
first: 20
|
2022-03-09 13:58:54 +01:00
|
|
|
orderBy: sharesOwned
|
2021-12-10 10:50:00 +01:00
|
|
|
orderDirection: desc
|
2022-01-13 22:24:06 +01:00
|
|
|
where: { tokenBalancesOwned_not: "0" }
|
2021-12-10 10:50:00 +01:00
|
|
|
) {
|
|
|
|
id
|
2022-01-13 22:24:06 +01:00
|
|
|
tokenBalancesOwned {
|
|
|
|
value
|
|
|
|
}
|
2021-12-10 10:50:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
2022-02-24 16:21:45 +01:00
|
|
|
const OpcFeesQuery = gql`
|
|
|
|
query OpcFeesQuery($id: ID!) {
|
|
|
|
opc(id: $id) {
|
|
|
|
swapOceanFee
|
|
|
|
swapNonOceanFee
|
|
|
|
consumeFee
|
|
|
|
providerFee
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
2021-08-17 11:46:51 +02:00
|
|
|
export function getSubgraphUri(chainId: number): string {
|
2021-06-25 09:50:56 +02:00
|
|
|
const config = getOceanConfig(chainId)
|
|
|
|
return config.subgraphUri
|
|
|
|
}
|
|
|
|
|
2021-07-22 14:01:30 +02:00
|
|
|
export function getQueryContext(chainId: number): OperationContext {
|
2022-03-09 13:58:54 +01:00
|
|
|
try {
|
|
|
|
const queryContext: OperationContext = {
|
|
|
|
url: `${getSubgraphUri(
|
|
|
|
Number(chainId)
|
|
|
|
)}/subgraphs/name/oceanprotocol/ocean-subgraph`,
|
2022-03-29 15:32:45 +02:00
|
|
|
requestPolicy: 'network-only'
|
2022-03-09 13:58:54 +01:00
|
|
|
}
|
|
|
|
return queryContext
|
|
|
|
} catch (error) {
|
|
|
|
LoggerInstance.error('Get query context error: ', error.message)
|
2021-07-22 14:01:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-22 13:02:32 +02:00
|
|
|
export async function fetchData(
|
2021-06-22 07:52:49 +02:00
|
|
|
query: TypedDocumentNode,
|
2021-06-25 09:50:56 +02:00
|
|
|
variables: any,
|
|
|
|
context: OperationContext
|
2021-07-22 13:07:52 +02:00
|
|
|
): Promise<any> {
|
2021-04-09 11:55:18 +02:00
|
|
|
try {
|
2021-06-22 07:52:49 +02:00
|
|
|
const client = getUrqlClientInstance()
|
2022-03-09 13:58:54 +01:00
|
|
|
|
2021-06-25 09:50:56 +02:00
|
|
|
const response = await client.query(query, variables, context).toPromise()
|
2021-04-09 11:55:18 +02:00
|
|
|
return response
|
|
|
|
} catch (error) {
|
2022-03-09 13:58:54 +01:00
|
|
|
LoggerInstance.error('Error fetchData: ', error.message)
|
2021-04-11 01:13:43 +02:00
|
|
|
}
|
2022-03-09 13:58:54 +01:00
|
|
|
return null
|
2021-04-11 01:13:43 +02:00
|
|
|
}
|
|
|
|
|
2021-07-23 14:46:25 +02:00
|
|
|
export async function fetchDataForMultipleChains(
|
|
|
|
query: TypedDocumentNode,
|
|
|
|
variables: any,
|
|
|
|
chainIds: number[]
|
|
|
|
): Promise<any[]> {
|
|
|
|
let datas: any[] = []
|
2022-03-09 13:58:54 +01:00
|
|
|
try {
|
|
|
|
for (const chainId of chainIds) {
|
|
|
|
const context: OperationContext = getQueryContext(chainId)
|
2021-07-23 14:46:25 +02:00
|
|
|
const response = await fetchData(query, variables, context)
|
2022-03-09 13:58:54 +01:00
|
|
|
if (!response || response.error) continue
|
|
|
|
datas = datas.concat(response?.data)
|
2021-07-23 14:46:25 +02:00
|
|
|
}
|
2022-03-09 13:58:54 +01:00
|
|
|
return datas
|
|
|
|
} catch (error) {
|
|
|
|
LoggerInstance.error('Error fetchDataForMultipleChains: ', error.message)
|
2021-07-23 14:46:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-24 16:21:45 +01:00
|
|
|
export async function getOpcFees(chainId: number) {
|
|
|
|
let opcFees
|
|
|
|
const variables = {
|
|
|
|
id: 1
|
|
|
|
}
|
|
|
|
const context = getQueryContext(chainId)
|
|
|
|
try {
|
|
|
|
const response: OperationResult<OpcFeesData> = await fetchData(
|
|
|
|
OpcFeesQuery,
|
|
|
|
variables,
|
|
|
|
context
|
|
|
|
)
|
|
|
|
opcFees = response?.data?.opc
|
|
|
|
} catch (error) {
|
2022-03-09 13:58:54 +01:00
|
|
|
LoggerInstance.error('Error getOpcFees: ', error.message)
|
2022-02-24 16:21:45 +01:00
|
|
|
throw Error(error.message)
|
|
|
|
}
|
|
|
|
return opcFees
|
|
|
|
}
|
|
|
|
|
2021-04-11 01:13:43 +02:00
|
|
|
export async function getPreviousOrders(
|
|
|
|
id: string,
|
|
|
|
account: string,
|
|
|
|
assetTimeout: string
|
|
|
|
): Promise<string> {
|
2022-05-12 12:35:07 +02:00
|
|
|
const variables = { id, account }
|
2021-06-22 07:52:49 +02:00
|
|
|
const fetchedPreviousOrders: OperationResult<AssetPreviousOrder> =
|
2021-06-25 09:50:56 +02:00
|
|
|
await fetchData(PreviousOrderQuery, variables, null)
|
2022-01-13 22:41:19 +01:00
|
|
|
if (fetchedPreviousOrders.data?.orders?.length === 0) return null
|
2021-04-12 16:09:41 +02:00
|
|
|
if (assetTimeout === '0') {
|
2022-01-13 22:41:19 +01:00
|
|
|
return fetchedPreviousOrders?.data?.orders[0]?.tx
|
2021-04-11 01:13:43 +02:00
|
|
|
} else {
|
2021-05-07 15:00:40 +02:00
|
|
|
const expiry =
|
2022-01-13 22:41:19 +01:00
|
|
|
fetchedPreviousOrders?.data?.orders[0]?.createdTimestamp * 1000 +
|
2021-05-07 15:00:40 +02:00
|
|
|
Number(assetTimeout) * 1000
|
|
|
|
if (Date.now() <= expiry) {
|
2022-01-13 22:41:19 +01:00
|
|
|
return fetchedPreviousOrders?.data?.orders[0]?.tx
|
2021-04-11 01:13:43 +02:00
|
|
|
} else {
|
|
|
|
return null
|
|
|
|
}
|
2021-04-09 11:55:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-11 08:51:13 +01:00
|
|
|
export async function getSpotPrice(asset: Asset): Promise<number> {
|
2021-08-18 11:46:27 +02:00
|
|
|
const poolVariables = {
|
2021-11-11 08:51:13 +01:00
|
|
|
datatokenAddress: asset?.services[0].datatokenAddress.toLowerCase()
|
2021-08-18 11:46:27 +02:00
|
|
|
}
|
|
|
|
const queryContext = getQueryContext(Number(asset.chainId))
|
|
|
|
|
2022-02-07 15:58:47 +01:00
|
|
|
const poolPriceResponse: OperationResult<AssetPoolPrice> = await fetchData(
|
2021-09-01 17:48:54 +02:00
|
|
|
AssetPoolPriceQuery,
|
2021-08-18 11:46:27 +02:00
|
|
|
poolVariables,
|
|
|
|
queryContext
|
|
|
|
)
|
|
|
|
|
|
|
|
return poolPriceResponse.data.pools[0].spotPrice
|
|
|
|
}
|
|
|
|
|
2021-10-21 09:24:00 +02:00
|
|
|
export async function getHighestLiquidityDatatokens(
|
2021-07-08 00:07:12 +02:00
|
|
|
chainIds: number[]
|
2021-10-21 09:24:00 +02:00
|
|
|
): Promise<string[]> {
|
|
|
|
const dtList: string[] = []
|
2021-09-01 17:48:54 +02:00
|
|
|
let highestLiquidityAssets: HighestLiquidityAssetsPool[] = []
|
2022-03-09 13:58:54 +01:00
|
|
|
|
2021-07-08 00:07:12 +02:00
|
|
|
for (const chain of chainIds) {
|
2021-07-22 14:01:30 +02:00
|
|
|
const queryContext = getQueryContext(Number(chain))
|
2021-07-15 17:25:53 +02:00
|
|
|
const fetchedPools: OperationResult<HighestLiquidityGraphAssets, any> =
|
|
|
|
await fetchData(HighestLiquidityAssets, null, queryContext)
|
2021-09-01 17:48:54 +02:00
|
|
|
highestLiquidityAssets = highestLiquidityAssets.concat(
|
2022-02-07 15:58:47 +01:00
|
|
|
fetchedPools?.data?.pools
|
2021-07-08 00:07:12 +02:00
|
|
|
)
|
2021-07-15 17:25:53 +02:00
|
|
|
}
|
2022-01-13 22:41:19 +01:00
|
|
|
highestLiquidityAssets.sort(
|
|
|
|
(a, b) => b.baseTokenLiquidity - a.baseTokenLiquidity
|
|
|
|
)
|
2022-02-10 15:41:07 +01:00
|
|
|
|
2021-09-01 17:48:54 +02:00
|
|
|
for (let i = 0; i < highestLiquidityAssets.length; i++) {
|
2022-02-07 15:58:47 +01:00
|
|
|
if (!highestLiquidityAssets[i]?.datatoken?.address) continue
|
2022-01-13 22:41:19 +01:00
|
|
|
dtList.push(highestLiquidityAssets[i].datatoken.address)
|
2021-10-21 09:24:00 +02:00
|
|
|
}
|
|
|
|
return dtList
|
2021-06-02 11:14:54 +02:00
|
|
|
}
|
Account metadata header (#776)
* get all neded data for the header from 3box, aqua and subgraph
* fix tvl display error
* WIP metadata header styling
* added more styling for the header
* make page title optional so we can remove it on account page
* stroke change for svg images and default values
* more styling added to the header
* fixed linter
* added ocean balance to tvl
* update styling for statistcs
* fixed eror for go to my account from another account page
* updated styling for mobile use
* wip show more on explorer links and description
* properly display read more for explorer links and description
* replaced show more with 3box redirect on description
* change accounts default picture and check links length before display element
* use optional on links
* grid cleanup, new number unit, split up stats
* rename all the things, more profile header styling
* visual hierarchy, improve image loading experience
* layout flow & visual tweaks
* more description
* replaced account route with profile when accesing a profile by the eth address
* use account id from url if exists when fetching data
* bump @oceanprotocol/art to v3.2.0
* styling, fallbacks, edge case fixes
* clean up Publisher atom, link to profile page
* fixed issue when switching to my profile from another profile
* output accountId, make it copyable, remove stats icons
* render tweaks, markup cleanup
* add 3box reference
* mobile tabs spacing tweaks
* text flow and spacing tweaks
Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2021-09-01 13:56:34 +02:00
|
|
|
|
2022-04-22 02:38:35 +02:00
|
|
|
export async function getAccountLiquidityInOwnAssets(
|
Account metadata header (#776)
* get all neded data for the header from 3box, aqua and subgraph
* fix tvl display error
* WIP metadata header styling
* added more styling for the header
* make page title optional so we can remove it on account page
* stroke change for svg images and default values
* more styling added to the header
* fixed linter
* added ocean balance to tvl
* update styling for statistcs
* fixed eror for go to my account from another account page
* updated styling for mobile use
* wip show more on explorer links and description
* properly display read more for explorer links and description
* replaced show more with 3box redirect on description
* change accounts default picture and check links length before display element
* use optional on links
* grid cleanup, new number unit, split up stats
* rename all the things, more profile header styling
* visual hierarchy, improve image loading experience
* layout flow & visual tweaks
* more description
* replaced account route with profile when accesing a profile by the eth address
* use account id from url if exists when fetching data
* bump @oceanprotocol/art to v3.2.0
* styling, fallbacks, edge case fixes
* clean up Publisher atom, link to profile page
* fixed issue when switching to my profile from another profile
* output accountId, make it copyable, remove stats icons
* render tweaks, markup cleanup
* add 3box reference
* mobile tabs spacing tweaks
* text flow and spacing tweaks
Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2021-09-01 13:56:34 +02:00
|
|
|
accountId: string,
|
|
|
|
chainIds: number[],
|
|
|
|
pools: string[]
|
2022-03-09 13:58:54 +01:00
|
|
|
): Promise<string> {
|
Account metadata header (#776)
* get all neded data for the header from 3box, aqua and subgraph
* fix tvl display error
* WIP metadata header styling
* added more styling for the header
* make page title optional so we can remove it on account page
* stroke change for svg images and default values
* more styling added to the header
* fixed linter
* added ocean balance to tvl
* update styling for statistcs
* fixed eror for go to my account from another account page
* updated styling for mobile use
* wip show more on explorer links and description
* properly display read more for explorer links and description
* replaced show more with 3box redirect on description
* change accounts default picture and check links length before display element
* use optional on links
* grid cleanup, new number unit, split up stats
* rename all the things, more profile header styling
* visual hierarchy, improve image loading experience
* layout flow & visual tweaks
* more description
* replaced account route with profile when accesing a profile by the eth address
* use account id from url if exists when fetching data
* bump @oceanprotocol/art to v3.2.0
* styling, fallbacks, edge case fixes
* clean up Publisher atom, link to profile page
* fixed issue when switching to my profile from another profile
* output accountId, make it copyable, remove stats icons
* render tweaks, markup cleanup
* add 3box reference
* mobile tabs spacing tweaks
* text flow and spacing tweaks
Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2021-09-01 13:56:34 +02:00
|
|
|
const queryVariables = {
|
|
|
|
user: accountId.toLowerCase(),
|
2022-05-12 12:35:07 +02:00
|
|
|
pools
|
Account metadata header (#776)
* get all neded data for the header from 3box, aqua and subgraph
* fix tvl display error
* WIP metadata header styling
* added more styling for the header
* make page title optional so we can remove it on account page
* stroke change for svg images and default values
* more styling added to the header
* fixed linter
* added ocean balance to tvl
* update styling for statistcs
* fixed eror for go to my account from another account page
* updated styling for mobile use
* wip show more on explorer links and description
* properly display read more for explorer links and description
* replaced show more with 3box redirect on description
* change accounts default picture and check links length before display element
* use optional on links
* grid cleanup, new number unit, split up stats
* rename all the things, more profile header styling
* visual hierarchy, improve image loading experience
* layout flow & visual tweaks
* more description
* replaced account route with profile when accesing a profile by the eth address
* use account id from url if exists when fetching data
* bump @oceanprotocol/art to v3.2.0
* styling, fallbacks, edge case fixes
* clean up Publisher atom, link to profile page
* fixed issue when switching to my profile from another profile
* output accountId, make it copyable, remove stats icons
* render tweaks, markup cleanup
* add 3box reference
* mobile tabs spacing tweaks
* text flow and spacing tweaks
Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2021-09-01 13:56:34 +02:00
|
|
|
}
|
|
|
|
const results: PoolSharesList[] = await fetchDataForMultipleChains(
|
|
|
|
UserSharesQuery,
|
|
|
|
queryVariables,
|
|
|
|
chainIds
|
|
|
|
)
|
2022-04-22 02:38:35 +02:00
|
|
|
let totalLiquidity = new Decimal(0)
|
2021-10-21 09:24:00 +02:00
|
|
|
|
Account metadata header (#776)
* get all neded data for the header from 3box, aqua and subgraph
* fix tvl display error
* WIP metadata header styling
* added more styling for the header
* make page title optional so we can remove it on account page
* stroke change for svg images and default values
* more styling added to the header
* fixed linter
* added ocean balance to tvl
* update styling for statistcs
* fixed eror for go to my account from another account page
* updated styling for mobile use
* wip show more on explorer links and description
* properly display read more for explorer links and description
* replaced show more with 3box redirect on description
* change accounts default picture and check links length before display element
* use optional on links
* grid cleanup, new number unit, split up stats
* rename all the things, more profile header styling
* visual hierarchy, improve image loading experience
* layout flow & visual tweaks
* more description
* replaced account route with profile when accesing a profile by the eth address
* use account id from url if exists when fetching data
* bump @oceanprotocol/art to v3.2.0
* styling, fallbacks, edge case fixes
* clean up Publisher atom, link to profile page
* fixed issue when switching to my profile from another profile
* output accountId, make it copyable, remove stats icons
* render tweaks, markup cleanup
* add 3box reference
* mobile tabs spacing tweaks
* text flow and spacing tweaks
Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2021-09-01 13:56:34 +02:00
|
|
|
for (const result of results) {
|
|
|
|
for (const poolShare of result.poolShares) {
|
2022-04-22 02:38:35 +02:00
|
|
|
const poolUserLiquidity = calcSingleOutGivenPoolIn(
|
|
|
|
poolShare.pool.baseTokenLiquidity,
|
2022-03-09 13:58:54 +01:00
|
|
|
poolShare.pool.totalShares,
|
2022-04-22 02:38:35 +02:00
|
|
|
poolShare.shares
|
2022-03-09 13:58:54 +01:00
|
|
|
)
|
2022-04-22 02:38:35 +02:00
|
|
|
|
|
|
|
totalLiquidity = totalLiquidity.add(new Decimal(poolUserLiquidity))
|
Account metadata header (#776)
* get all neded data for the header from 3box, aqua and subgraph
* fix tvl display error
* WIP metadata header styling
* added more styling for the header
* make page title optional so we can remove it on account page
* stroke change for svg images and default values
* more styling added to the header
* fixed linter
* added ocean balance to tvl
* update styling for statistcs
* fixed eror for go to my account from another account page
* updated styling for mobile use
* wip show more on explorer links and description
* properly display read more for explorer links and description
* replaced show more with 3box redirect on description
* change accounts default picture and check links length before display element
* use optional on links
* grid cleanup, new number unit, split up stats
* rename all the things, more profile header styling
* visual hierarchy, improve image loading experience
* layout flow & visual tweaks
* more description
* replaced account route with profile when accesing a profile by the eth address
* use account id from url if exists when fetching data
* bump @oceanprotocol/art to v3.2.0
* styling, fallbacks, edge case fixes
* clean up Publisher atom, link to profile page
* fixed issue when switching to my profile from another profile
* output accountId, make it copyable, remove stats icons
* render tweaks, markup cleanup
* add 3box reference
* mobile tabs spacing tweaks
* text flow and spacing tweaks
Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2021-09-01 13:56:34 +02:00
|
|
|
}
|
|
|
|
}
|
2022-04-22 02:38:35 +02:00
|
|
|
return totalLiquidity.toDecimalPlaces(MAX_DECIMALS).toString()
|
Account metadata header (#776)
* get all neded data for the header from 3box, aqua and subgraph
* fix tvl display error
* WIP metadata header styling
* added more styling for the header
* make page title optional so we can remove it on account page
* stroke change for svg images and default values
* more styling added to the header
* fixed linter
* added ocean balance to tvl
* update styling for statistcs
* fixed eror for go to my account from another account page
* updated styling for mobile use
* wip show more on explorer links and description
* properly display read more for explorer links and description
* replaced show more with 3box redirect on description
* change accounts default picture and check links length before display element
* use optional on links
* grid cleanup, new number unit, split up stats
* rename all the things, more profile header styling
* visual hierarchy, improve image loading experience
* layout flow & visual tweaks
* more description
* replaced account route with profile when accesing a profile by the eth address
* use account id from url if exists when fetching data
* bump @oceanprotocol/art to v3.2.0
* styling, fallbacks, edge case fixes
* clean up Publisher atom, link to profile page
* fixed issue when switching to my profile from another profile
* output accountId, make it copyable, remove stats icons
* render tweaks, markup cleanup
* add 3box reference
* mobile tabs spacing tweaks
* text flow and spacing tweaks
Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2021-09-01 13:56:34 +02:00
|
|
|
}
|
2021-09-13 16:39:32 +02:00
|
|
|
|
|
|
|
export async function getPoolSharesData(
|
|
|
|
accountId: string,
|
|
|
|
chainIds: number[]
|
|
|
|
): Promise<PoolShare[]> {
|
|
|
|
const variables = { user: accountId?.toLowerCase() }
|
|
|
|
const data: PoolShare[] = []
|
2022-03-09 13:58:54 +01:00
|
|
|
try {
|
|
|
|
const result = await fetchDataForMultipleChains(
|
|
|
|
userPoolSharesQuery,
|
|
|
|
variables,
|
|
|
|
chainIds
|
|
|
|
)
|
|
|
|
for (let i = 0; i < result.length; i++) {
|
|
|
|
result[i].poolShares.forEach((poolShare: PoolShare) => {
|
|
|
|
data.push(poolShare)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
return data
|
|
|
|
} catch (error) {
|
|
|
|
LoggerInstance.error('Error getPoolSharesData: ', error.message)
|
2021-09-13 16:39:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function getUserTokenOrders(
|
|
|
|
accountId: string,
|
|
|
|
chainIds: number[]
|
|
|
|
): Promise<OrdersData[]> {
|
|
|
|
const data: OrdersData[] = []
|
|
|
|
const variables = { user: accountId?.toLowerCase() }
|
|
|
|
|
|
|
|
try {
|
|
|
|
const tokenOrders = await fetchDataForMultipleChains(
|
|
|
|
UserTokenOrders,
|
|
|
|
variables,
|
|
|
|
chainIds
|
|
|
|
)
|
|
|
|
for (let i = 0; i < tokenOrders?.length; i++) {
|
2022-02-21 16:15:33 +01:00
|
|
|
tokenOrders[i].orders.forEach((tokenOrder: OrdersData) => {
|
2021-09-13 16:39:32 +02:00
|
|
|
data.push(tokenOrder)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
return data
|
|
|
|
} catch (error) {
|
2022-03-09 13:58:54 +01:00
|
|
|
LoggerInstance.error('Error getUserTokenOrders', error.message)
|
2021-09-13 16:39:32 +02:00
|
|
|
}
|
|
|
|
}
|
2021-10-18 16:43:32 +02:00
|
|
|
|
|
|
|
export async function getUserSales(
|
|
|
|
accountId: string,
|
|
|
|
chainIds: number[]
|
|
|
|
): Promise<number> {
|
2022-02-21 16:15:33 +01:00
|
|
|
const variables = { user: accountId?.toLowerCase() }
|
2021-10-18 16:43:32 +02:00
|
|
|
try {
|
|
|
|
const userSales = await fetchDataForMultipleChains(
|
|
|
|
UserSalesQuery,
|
|
|
|
variables,
|
|
|
|
chainIds
|
|
|
|
)
|
|
|
|
let salesSum = 0
|
|
|
|
for (let i = 0; i < userSales.length; i++) {
|
|
|
|
if (userSales[i].users.length > 0) {
|
2022-02-21 16:15:33 +01:00
|
|
|
salesSum += parseInt(userSales[i].users[0].totalSales)
|
2021-10-18 16:43:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return salesSum
|
|
|
|
} catch (error) {
|
2022-03-09 13:58:54 +01:00
|
|
|
LoggerInstance.error('Error getUserSales', error.message)
|
2021-10-18 16:43:32 +02:00
|
|
|
}
|
|
|
|
}
|
2021-12-10 10:50:00 +01:00
|
|
|
|
|
|
|
export async function getTopAssetsPublishers(
|
|
|
|
chainIds: number[],
|
|
|
|
nrItems = 9
|
|
|
|
): Promise<AccountTeaserVM[]> {
|
|
|
|
const publisherSales: AccountTeaserVM[] = []
|
|
|
|
|
|
|
|
for (const chain of chainIds) {
|
|
|
|
const queryContext = getQueryContext(Number(chain))
|
|
|
|
const fetchedUsers: OperationResult<UsersSalesList> = await fetchData(
|
|
|
|
TopSalesQuery,
|
|
|
|
null,
|
|
|
|
queryContext
|
|
|
|
)
|
|
|
|
for (let i = 0; i < fetchedUsers.data.users.length; i++) {
|
|
|
|
const publishersIndex = publisherSales.findIndex(
|
|
|
|
(user) => fetchedUsers.data.users[i].id === user.address
|
|
|
|
)
|
|
|
|
if (publishersIndex === -1) {
|
|
|
|
const publisher: AccountTeaserVM = {
|
|
|
|
address: fetchedUsers.data.users[i].id,
|
2022-02-21 16:15:33 +01:00
|
|
|
nrSales: fetchedUsers.data.users[i].totalSales
|
2021-12-10 10:50:00 +01:00
|
|
|
}
|
|
|
|
publisherSales.push(publisher)
|
|
|
|
} else {
|
|
|
|
publisherSales[publishersIndex].nrSales +=
|
|
|
|
publisherSales[publishersIndex].nrSales
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
publisherSales.sort((a, b) => b.nrSales - a.nrSales)
|
|
|
|
|
|
|
|
return publisherSales.slice(0, nrItems)
|
|
|
|
}
|