Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check for nil response data in numia tokens endpoint #3847

Merged
merged 5 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/server/src/queries/complex/assets/market.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,14 +231,14 @@ function makeMarketActivityFromTokenData(tokenData: TokenData) {
: undefined,
denom: tokenData.denom,
symbol: tokenData.symbol,
liquidity: new PricePretty(DEFAULT_VS_CURRENCY, tokenData.liquidity),
liquidity: new PricePretty(DEFAULT_VS_CURRENCY, tokenData.liquidity ?? 0),
liquidity24hChange:
tokenData.liquidity_24h_change !== null
? new RatePretty(
new Dec(tokenData.liquidity_24h_change).quo(new Dec(100))
)
: undefined,
volume24h: new PricePretty(DEFAULT_VS_CURRENCY, tokenData.volume_24h),
volume24h: new PricePretty(DEFAULT_VS_CURRENCY, tokenData.volume_24h ?? 0),
volume24hChange:
tokenData.volume_24h_change !== null
? new RatePretty(new Dec(tokenData.volume_24h_change).quo(new Dec(100)))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Dec } from "@keplr-wallet/unit";
import { Asset } from "@osmosis-labs/types";
import { isNil } from "@osmosis-labs/utils";
import cachified, { CacheEntry } from "cachified";
import { LRUCache } from "lru-cache";

Expand Down Expand Up @@ -30,8 +31,8 @@ function getBatchLoader() {
ttl: 1000 * 60 * 10, // 10 minutes
getFreshValue: () =>
new EdgeDataLoader(
(coinMinimalDenoms: readonly string[]) => {
return queryPrices(coinMinimalDenoms as string[]).then((priceMap) =>
(coinMinimalDenoms: readonly string[]) =>
queryPrices(coinMinimalDenoms as string[]).then((priceMap) =>
coinMinimalDenoms.map((baseCoinMinimalDenom) => {
try {
const price =
Expand All @@ -40,6 +41,12 @@ function getBatchLoader() {
// trim to 18 decimals to silence Dec warnings
const p = price.replace(/(\.\d{18})\d*/, "$1");

if (isNil(p)) {
return new Error(
`No SQS price result for ${baseCoinMinimalDenom} and USDC`
);
}

if (new Dec(p).isZero())
return new Error(
`No SQS price result for ${baseCoinMinimalDenom} and USDC`
Expand All @@ -51,8 +58,7 @@ function getBatchLoader() {
);
}
})
);
},
),
{
// SQS imposes a limit on URI length from its Nginx configuration, so we impose a limit to avoid hitting that limit.
maxBatchSize: 100,
Expand Down
4 changes: 2 additions & 2 deletions packages/server/src/queries/data-services/token-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ export interface TokenData {
denom: string;
symbol: string;
main: boolean;
liquidity: number;
liquidity: number | null;
jonator marked this conversation as resolved.
Show resolved Hide resolved
liquidity_24h_change: number | null;
volume_24h: number;
volume_24h: number | null;
volume_24h_change: number | null;
name: string;
price_1h_change: number | null;
Expand Down
1 change: 0 additions & 1 deletion packages/stores/src/queries-external/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export * from "./pool-fees";
export * from "./pool-rewards";
export * from "./pools";
export * from "./store";
export * from "./token-data";
export * from "./token-historical-chart";

export const IMPERATOR_TIMESERIES_DEFAULT_BASEURL =
Expand Down
7 changes: 0 additions & 7 deletions packages/stores/src/queries-external/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { ObservableQueryPoolAprs } from "./numia";
import { ObservableQueryPoolFeesMetrics } from "./pool-fees";
import { ObservableQueryAccountsPoolRewards } from "./pool-rewards";
import { ObservableQueryPositionsPerformanceMetrics } from "./position-performance";
import { ObservableQueryTokensData } from "./token-data";
import { ObservableQueryTokensHistoricalChart } from "./token-historical-chart";
import { ObservableQueryMarketCap } from "./token-market-cap";

Expand All @@ -35,7 +34,6 @@ export class QueriesExternalStore {
public readonly queryChainStatus: DeepReadonly<ObservableQueryIbcChainsStatus>;
public readonly queryMarketCaps: DeepReadonly<ObservableQueryMarketCaps>;
public readonly queryTokenHistoricalChart: DeepReadonly<ObservableQueryTokensHistoricalChart>;
public readonly queryTokenData: DeepReadonly<ObservableQueryTokensData>;
public readonly queryActiveGauges: DeepReadonly<ObservableQueryActiveGauges>;
public readonly queryICNSNames: DeepReadonly<ObservableQueryICNSNames>;
public readonly queryPositionsPerformaceMetrics: DeepReadonly<ObservableQueryPositionsPerformanceMetrics>;
Expand Down Expand Up @@ -90,11 +88,6 @@ export class QueriesExternalStore {
kvStore,
indexerDataBaseUrl
);
this.queryTokenData = new ObservableQueryTokensData(
kvStore,
priceStore,
timeseriesDataBaseUrl
);
this.queryActiveGauges = new ObservableQueryActiveGauges(
kvStore,
webApiBaseUrl,
Expand Down
74 changes: 0 additions & 74 deletions packages/stores/src/queries-external/token-data/index.ts

This file was deleted.

14 changes: 0 additions & 14 deletions packages/stores/src/queries-external/token-data/types.ts

This file was deleted.

Loading