mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
typings & typos
This commit is contained in:
parent
7965b74302
commit
6e0902f5d3
@ -5,11 +5,11 @@ import { getOceanConfig } from './ocean'
|
|||||||
import web3 from 'web3'
|
import web3 from 'web3'
|
||||||
import {
|
import {
|
||||||
AssetsPoolPrice,
|
AssetsPoolPrice,
|
||||||
AssetsPoolPrice_pools as AssetsPoolPricePools
|
AssetsPoolPrice_pools as AssetsPoolPricePool
|
||||||
} from '../@types/apollo/AssetsPoolPrice'
|
} from '../@types/apollo/AssetsPoolPrice'
|
||||||
import {
|
import {
|
||||||
AssetsFrePrice,
|
AssetsFrePrice,
|
||||||
AssetsFrePrice_fixedRateExchanges as AssetsFrePriceFixedRateExchanges
|
AssetsFrePrice_fixedRateExchanges as AssetsFrePriceFixedRateExchange
|
||||||
} from '../@types/apollo/AssetsFrePrice'
|
} from '../@types/apollo/AssetsFrePrice'
|
||||||
import {
|
import {
|
||||||
AssetsFreePrice,
|
AssetsFreePrice,
|
||||||
@ -17,7 +17,7 @@ import {
|
|||||||
} from '../@types/apollo/AssetsFreePrice'
|
} from '../@types/apollo/AssetsFreePrice'
|
||||||
import { AssetPreviousOrder } from '../@types/apollo/AssetPreviousOrder'
|
import { AssetPreviousOrder } from '../@types/apollo/AssetPreviousOrder'
|
||||||
import {
|
import {
|
||||||
HighestLiquidityAssets_pools as HighestLiquidityAssetsPools,
|
HighestLiquidityAssets_pools as HighestLiquidityAssetsPool,
|
||||||
HighestLiquidityAssets as HighestLiquidityGraphAssets
|
HighestLiquidityAssets as HighestLiquidityGraphAssets
|
||||||
} from '../@types/apollo/HighestLiquidityAssets'
|
} from '../@types/apollo/HighestLiquidityAssets'
|
||||||
import {
|
import {
|
||||||
@ -113,7 +113,7 @@ const PoolQuery = gql`
|
|||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
const AssetPoolPriceQuerry = gql`
|
const AssetPoolPriceQuery = gql`
|
||||||
query AssetPoolPrice($datatokenAddress: String) {
|
query AssetPoolPrice($datatokenAddress: String) {
|
||||||
pools(where: { datatokenAddress: $datatokenAddress }) {
|
pools(where: { datatokenAddress: $datatokenAddress }) {
|
||||||
id
|
id
|
||||||
@ -276,8 +276,8 @@ export async function getPreviousOrders(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function transformPriceToBestPrice(
|
function transformPriceToBestPrice(
|
||||||
frePrice: AssetsFrePriceFixedRateExchanges[],
|
frePrice: AssetsFrePriceFixedRateExchange[],
|
||||||
poolPrice: AssetsPoolPricePools[],
|
poolPrice: AssetsPoolPricePool[],
|
||||||
freePrice: AssetFreePriceDispenser[]
|
freePrice: AssetFreePriceDispenser[]
|
||||||
) {
|
) {
|
||||||
if (poolPrice?.length > 0) {
|
if (poolPrice?.length > 0) {
|
||||||
@ -340,8 +340,8 @@ async function getAssetsPoolsExchangesAndDatatokenMap(
|
|||||||
assets: DDO[]
|
assets: DDO[]
|
||||||
): Promise<
|
): Promise<
|
||||||
[
|
[
|
||||||
AssetsPoolPricePools[],
|
AssetsPoolPricePool[],
|
||||||
AssetsFrePriceFixedRateExchanges[],
|
AssetsFrePriceFixedRateExchange[],
|
||||||
AssetFreePriceDispenser[],
|
AssetFreePriceDispenser[],
|
||||||
DidAndDatatokenMap
|
DidAndDatatokenMap
|
||||||
]
|
]
|
||||||
@ -359,8 +359,8 @@ async function getAssetsPoolsExchangesAndDatatokenMap(
|
|||||||
chainAssetLists[ddo.chainId].push(ddo?.dataToken.toLowerCase())
|
chainAssetLists[ddo.chainId].push(ddo?.dataToken.toLowerCase())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let poolPriceResponse: AssetsPoolPricePools[] = []
|
let poolPriceResponse: AssetsPoolPricePool[] = []
|
||||||
let frePriceResponse: AssetsFrePriceFixedRateExchanges[] = []
|
let frePriceResponse: AssetsFrePriceFixedRateExchange[] = []
|
||||||
let freePriceResponse: AssetFreePriceDispenser[] = []
|
let freePriceResponse: AssetFreePriceDispenser[] = []
|
||||||
|
|
||||||
for (const chainKey in chainAssetLists) {
|
for (const chainKey in chainAssetLists) {
|
||||||
@ -403,8 +403,8 @@ export async function getAssetsPriceList(assets: DDO[]): Promise<PriceList> {
|
|||||||
const priceList: PriceList = {}
|
const priceList: PriceList = {}
|
||||||
|
|
||||||
const values: [
|
const values: [
|
||||||
AssetsPoolPricePools[],
|
AssetsPoolPricePool[],
|
||||||
AssetsFrePriceFixedRateExchanges[],
|
AssetsFrePriceFixedRateExchange[],
|
||||||
AssetFreePriceDispenser[],
|
AssetFreePriceDispenser[],
|
||||||
DidAndDatatokenMap
|
DidAndDatatokenMap
|
||||||
] = await getAssetsPoolsExchangesAndDatatokenMap(assets)
|
] = await getAssetsPoolsExchangesAndDatatokenMap(assets)
|
||||||
@ -441,7 +441,7 @@ export async function getPrice(asset: DDO): Promise<BestPrice> {
|
|||||||
const queryContext = getQueryContext(Number(asset.chainId))
|
const queryContext = getQueryContext(Number(asset.chainId))
|
||||||
|
|
||||||
const poolPriceResponse: OperationResult<AssetsPoolPrice> = await fetchData(
|
const poolPriceResponse: OperationResult<AssetsPoolPrice> = await fetchData(
|
||||||
AssetPoolPriceQuerry,
|
AssetPoolPriceQuery,
|
||||||
poolVariables,
|
poolVariables,
|
||||||
queryContext
|
queryContext
|
||||||
)
|
)
|
||||||
@ -472,7 +472,7 @@ export async function getSpotPrice(asset: DDO): Promise<number> {
|
|||||||
const queryContext = getQueryContext(Number(asset.chainId))
|
const queryContext = getQueryContext(Number(asset.chainId))
|
||||||
|
|
||||||
const poolPriceResponse: OperationResult<AssetsPoolPrice> = await fetchData(
|
const poolPriceResponse: OperationResult<AssetsPoolPrice> = await fetchData(
|
||||||
AssetPoolPriceQuerry,
|
AssetPoolPriceQuery,
|
||||||
poolVariables,
|
poolVariables,
|
||||||
queryContext
|
queryContext
|
||||||
)
|
)
|
||||||
@ -486,8 +486,8 @@ export async function getAssetsBestPrices(
|
|||||||
const assetsWithPrice: AssetListPrices[] = []
|
const assetsWithPrice: AssetListPrices[] = []
|
||||||
|
|
||||||
const values: [
|
const values: [
|
||||||
AssetsPoolPricePools[],
|
AssetsPoolPricePool[],
|
||||||
AssetsFrePriceFixedRateExchanges[],
|
AssetsFrePriceFixedRateExchange[],
|
||||||
AssetFreePriceDispenser[],
|
AssetFreePriceDispenser[],
|
||||||
DidAndDatatokenMap
|
DidAndDatatokenMap
|
||||||
] = await getAssetsPoolsExchangesAndDatatokenMap(assets)
|
] = await getAssetsPoolsExchangesAndDatatokenMap(assets)
|
||||||
@ -497,19 +497,20 @@ export async function getAssetsBestPrices(
|
|||||||
const freePriceResponse = values[2]
|
const freePriceResponse = values[2]
|
||||||
for (const ddo of assets) {
|
for (const ddo of assets) {
|
||||||
const dataToken = ddo.dataToken.toLowerCase()
|
const dataToken = ddo.dataToken.toLowerCase()
|
||||||
const poolPrice: AssetsPoolPricePools[] = []
|
const poolPrice: AssetsPoolPricePool[] = []
|
||||||
const frePrice: AssetsFrePriceFixedRateExchanges[] = []
|
const frePrice: AssetsFrePriceFixedRateExchange[] = []
|
||||||
const freePrice: AssetFreePriceDispenser[] = []
|
const freePrice: AssetFreePriceDispenser[] = []
|
||||||
const pool = poolPriceResponse.find(
|
const pool = poolPriceResponse.find(
|
||||||
(pool: any) => pool.datatokenAddress === dataToken
|
(pool: AssetsPoolPricePool) => pool.datatokenAddress === dataToken
|
||||||
)
|
)
|
||||||
pool && poolPrice.push(pool)
|
pool && poolPrice.push(pool)
|
||||||
const fre = frePriceResponse.find(
|
const fre = frePriceResponse.find(
|
||||||
(fre: any) => fre.datatoken.address === dataToken
|
(fre: AssetsFrePriceFixedRateExchange) =>
|
||||||
|
fre.datatoken.address === dataToken
|
||||||
)
|
)
|
||||||
fre && frePrice.push(fre)
|
fre && frePrice.push(fre)
|
||||||
const free = freePriceResponse.find(
|
const free = freePriceResponse.find(
|
||||||
(free: any) => free.datatoken.address === dataToken
|
(free: AssetFreePriceDispenser) => free.datatoken.address === dataToken
|
||||||
)
|
)
|
||||||
free && freePrice.push(free)
|
free && freePrice.push(free)
|
||||||
const bestPrice = transformPriceToBestPrice(frePrice, poolPrice, freePrice)
|
const bestPrice = transformPriceToBestPrice(frePrice, poolPrice, freePrice)
|
||||||
@ -526,22 +527,22 @@ export async function getHighestLiquidityDIDs(
|
|||||||
chainIds: number[]
|
chainIds: number[]
|
||||||
): Promise<[string, number]> {
|
): Promise<[string, number]> {
|
||||||
const didList: string[] = []
|
const didList: string[] = []
|
||||||
let highestLiquidiyAssets: HighestLiquidityAssetsPools[] = []
|
let highestLiquidityAssets: HighestLiquidityAssetsPool[] = []
|
||||||
for (const chain of chainIds) {
|
for (const chain of chainIds) {
|
||||||
const queryContext = getQueryContext(Number(chain))
|
const queryContext = getQueryContext(Number(chain))
|
||||||
const fetchedPools: OperationResult<HighestLiquidityGraphAssets, any> =
|
const fetchedPools: OperationResult<HighestLiquidityGraphAssets, any> =
|
||||||
await fetchData(HighestLiquidityAssets, null, queryContext)
|
await fetchData(HighestLiquidityAssets, null, queryContext)
|
||||||
highestLiquidiyAssets = highestLiquidiyAssets.concat(
|
highestLiquidityAssets = highestLiquidityAssets.concat(
|
||||||
fetchedPools.data.pools
|
fetchedPools.data.pools
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
highestLiquidiyAssets
|
highestLiquidityAssets
|
||||||
.sort((a, b) => a.oceanReserve - b.oceanReserve)
|
.sort((a, b) => a.oceanReserve - b.oceanReserve)
|
||||||
.reverse()
|
.reverse()
|
||||||
for (let i = 0; i < highestLiquidiyAssets.length; i++) {
|
for (let i = 0; i < highestLiquidityAssets.length; i++) {
|
||||||
if (!highestLiquidiyAssets[i].datatokenAddress) continue
|
if (!highestLiquidityAssets[i].datatokenAddress) continue
|
||||||
const did = web3.utils
|
const did = web3.utils
|
||||||
.toChecksumAddress(highestLiquidiyAssets[i].datatokenAddress)
|
.toChecksumAddress(highestLiquidityAssets[i].datatokenAddress)
|
||||||
.replace('0x', 'did:op:')
|
.replace('0x', 'did:op:')
|
||||||
didList.push(did)
|
didList.push(did)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user