Chart fixes (#470)

* 🐛add pools back

* 🐛fetch latest prices + fix decimal issue
This commit is contained in:
Bob van der Helm 2023-09-14 11:58:31 +02:00 committed by GitHub
parent 976d76a7f4
commit 6802008f75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 17 deletions

View File

@ -189,18 +189,22 @@ export class OsmosisTheGraphDataFeed implements IDatafeedChartApi {
const query = `
{
candles(
first: ${this.batchSize},
first: ${this.batchSize},
orderBy: "timestamp",
orderDirection: "desc",
where: {
interval: "${interval}",
quote: "${quote}",
base: "${base}"
}) {
timestamp
open
high
low
close
volume
interval: "${interval}",
quote: "${quote}",
base: "${base}"
poolId_in: ${JSON.stringify(this.supportedPools)}
}
) {
timestamp
open
high
low
close
volume
}
}
`
@ -212,7 +216,7 @@ export class OsmosisTheGraphDataFeed implements IDatafeedChartApi {
})
.then((res) => res.json())
.then((json: { data?: { candles: BarQueryData[] } }) => {
return this.resolveBarData(json.data?.candles || [], base)
return this.resolveBarData(json.data?.candles.reverse() || [], base, quote)
})
.catch((err) => {
if (this.debug) console.error(err)
@ -220,9 +224,10 @@ export class OsmosisTheGraphDataFeed implements IDatafeedChartApi {
})
}
resolveBarData(bars: BarQueryData[], base: string) {
const assetDecimals = getAssetByDenom(base)?.decimals || 6
const additionalDecimals = assetDecimals - this.baseDecimals
resolveBarData(bars: BarQueryData[], toDenom: string, fromDenom: string) {
const toDecimals = getAssetByDenom(toDenom)?.decimals || 6
const fromDecimals = getAssetByDenom(fromDenom)?.decimals || 6
const additionalDecimals = toDecimals - fromDecimals
return bars.map((bar) => ({
time: BN(bar.timestamp).multipliedBy(1000).toNumber(),
@ -264,4 +269,4 @@ export class OsmosisTheGraphDataFeed implements IDatafeedChartApi {
unsubscribeBars(listenerGuid: string): void {
// TheGraph doesn't support websockets yet
}
}
}

View File

@ -37,6 +37,7 @@ export const ASSETS: Asset[] = [
isDisplayCurrency: true,
isAutoLendEnabled: true,
pythPriceFeedId: 'b00b60f88b03a6a625a8d1c048c3f66653edf217439983d037e7222c4e612819',
poolId: 1,
},
{
symbol: 'stATOM',
@ -52,6 +53,7 @@ export const ASSETS: Asset[] = [
isMarket: !IS_TESTNET,
isDisplayCurrency: !IS_TESTNET,
isAutoLendEnabled: true,
poolId: 803,
},
{
symbol: 'WBTC.axl',
@ -68,6 +70,7 @@ export const ASSETS: Asset[] = [
isDisplayCurrency: !IS_TESTNET,
isAutoLendEnabled: true,
pythPriceFeedId: 'e62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43',
poolId: 712,
},
{
symbol: 'WETH.axl',
@ -84,6 +87,7 @@ export const ASSETS: Asset[] = [
isDisplayCurrency: !IS_TESTNET,
isAutoLendEnabled: true,
pythPriceFeedId: 'ff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace',
poolId: 704,
},
{
symbol: 'MARS',
@ -120,6 +124,7 @@ export const ASSETS: Asset[] = [
isStable: true,
isAutoLendEnabled: true,
pythPriceFeedId: 'eaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a',
poolId: 678,
},
{
symbol: 'AXL',
@ -136,6 +141,7 @@ export const ASSETS: Asset[] = [
isDisplayCurrency: !IS_TESTNET,
isAutoLendEnabled: true,
pythPriceFeedId: '60144b1d5c9e9851732ad1d9760e3485ef80be39b984f6bf60f82b28a2b7f126',
poolId: 812,
},
{
symbol: '$',
@ -223,4 +229,4 @@ export const ASSETS: Asset[] = [
hasOraclePrice: !IS_TESTNET,
forceFetchPrice: !IS_TESTNET,
},
]
]