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

@ -190,11 +190,15 @@ export class OsmosisTheGraphDataFeed implements IDatafeedChartApi {
{ {
candles( candles(
first: ${this.batchSize}, first: ${this.batchSize},
orderBy: "timestamp",
orderDirection: "desc",
where: { where: {
interval: "${interval}", interval: "${interval}",
quote: "${quote}", quote: "${quote}",
base: "${base}" base: "${base}"
}) { poolId_in: ${JSON.stringify(this.supportedPools)}
}
) {
timestamp timestamp
open open
high high
@ -212,7 +216,7 @@ export class OsmosisTheGraphDataFeed implements IDatafeedChartApi {
}) })
.then((res) => res.json()) .then((res) => res.json())
.then((json: { data?: { candles: BarQueryData[] } }) => { .then((json: { data?: { candles: BarQueryData[] } }) => {
return this.resolveBarData(json.data?.candles || [], base) return this.resolveBarData(json.data?.candles.reverse() || [], base, quote)
}) })
.catch((err) => { .catch((err) => {
if (this.debug) console.error(err) if (this.debug) console.error(err)
@ -220,9 +224,10 @@ export class OsmosisTheGraphDataFeed implements IDatafeedChartApi {
}) })
} }
resolveBarData(bars: BarQueryData[], base: string) { resolveBarData(bars: BarQueryData[], toDenom: string, fromDenom: string) {
const assetDecimals = getAssetByDenom(base)?.decimals || 6 const toDecimals = getAssetByDenom(toDenom)?.decimals || 6
const additionalDecimals = assetDecimals - this.baseDecimals const fromDecimals = getAssetByDenom(fromDenom)?.decimals || 6
const additionalDecimals = toDecimals - fromDecimals
return bars.map((bar) => ({ return bars.map((bar) => ({
time: BN(bar.timestamp).multipliedBy(1000).toNumber(), time: BN(bar.timestamp).multipliedBy(1000).toNumber(),

View File

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