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