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

Cleanup env #3996

Merged
merged 6 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
10 changes: 2 additions & 8 deletions packages/server/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ export const GITHUB_RAW_DEFAULT_BASEURL = "https://raw.githubusercontent.com";
export const ASSET_LIST_COMMIT_HASH = process.env.ASSET_LIST_COMMIT_HASH;

// data services
export const TIMESERIES_DATA_URL =
process.env.NEXT_PUBLIC_TIMESERIES_DATA_URL ??
export const HISTORICAL_DATA_URL =
process.env.NEXT_PUBLIC_HISTORICAL_DATA_URL ??
jonator marked this conversation as resolved.
Show resolved Hide resolved
"https://data.stage.osmosis.zone";
export const INDEXER_DATA_URL =
process.env.NEXT_PUBLIC_INDEXER_DATA_URL ?? "https://data.stage.osmosis.zone";
export const NUMIA_BASE_URL =
process.env.NEXT_PUBLIC_NUMIA_BASE_URL ??
"https://public-osmosis-api.numia.xyz";
Expand All @@ -29,15 +27,11 @@ export const NUMIA_API_KEY = process.env.NUMIA_API_KEY;
// sqs
export const SIDECAR_BASE_URL =
process.env.NEXT_PUBLIC_SIDECAR_BASE_URL ?? "https://sqs.osmosis.zone/";
export const TFM_BASE_URL = process.env.NEXT_PUBLIC_TFM_API_BASE_URL;

export const KEYBASE_BASE_URL = "https://keybase.io/";
export const KV_STORE_REST_API_URL = process.env.KV_STORE_REST_API_URL;
export const KV_STORE_REST_API_TOKEN = process.env.KV_STORE_REST_API_TOKEN;

export const BLOCKAID_BASE_URL = process.env.BLOCKAID_BASE_URL;
export const BLOCKAID_API_KEY = process.env.BLOCKAID_API_KEY;

// flags
export const EXCLUDED_EXTERNAL_BOOSTS_POOL_IDS =
process.env.NEXT_PUBLIC_EXCLUDED_EXTERNAL_BOOSTS_POOL_IDS;
9 changes: 0 additions & 9 deletions packages/server/src/queries/blockaid/index.ts

This file was deleted.

77 changes: 0 additions & 77 deletions packages/server/src/queries/blockaid/transaction.ts

This file was deleted.

27 changes: 17 additions & 10 deletions packages/server/src/queries/complex/pools/incentives.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Chain } from "@osmosis-labs/types";
import type { Chain } from "@osmosis-labs/types";
import { Dec, RatePretty } from "@osmosis-labs/unit";
import cachified, { CacheEntry } from "cachified";
import cachified, { type CacheEntry } from "cachified";
import dayjs from "dayjs";
import duration from "dayjs/plugin/duration";
import relativeTime from "dayjs/plugin/relativeTime";
Expand All @@ -11,13 +11,13 @@ import { EXCLUDED_EXTERNAL_BOOSTS_POOL_IDS } from "../../../env";
import { queryPriceRangeApr } from "../../../queries/data-services";
import { DEFAULT_LRU_OPTIONS } from "../../../utils/cache";
import {
PoolDataRange,
type PoolDataRange,
queryPoolAprsRange,
} from "../../data-services/pool-aprs";
import { Gauge, queryGauges } from "../../osmosis";
import { type Gauge, queryGauges } from "../../osmosis";
import { queryIncentivizedPools } from "../../osmosis/incentives/incentivized-pools";
import { getEpochs } from "../osmosis";
import { Epoch } from "../osmosis/epochs";
import type { Epoch } from "../osmosis/epochs";

/**
* Pools that are excluded from showing external boost incentives APRs.
Expand Down Expand Up @@ -234,7 +234,9 @@ export function getLockableDurations() {

return lockable_durations
.map((durationStr: string) => {
return dayjs.duration(parseInt(durationStr.replace("s", "")) * 1000);
return dayjs.duration(
Number.parseInt(durationStr.replace("s", "")) * 1000
);
})
.sort((v1, v2) => {
return v1.asMilliseconds() > v2.asMilliseconds() ? 1 : -1;
Expand All @@ -255,7 +257,7 @@ export function getIncentivizedPools({ chainList }: { chainList: Chain[] }) {
return incentivized_pools.map((pool) => ({
pool_id: pool.pool_id,
lockable_duration: dayjs.duration(
parseInt(pool.lockable_duration.replace("s", "")) * 1000
Number.parseInt(pool.lockable_duration.replace("s", "")) * 1000
),
gauge_id: pool.gauge_id,
}));
Expand All @@ -282,15 +284,20 @@ export function getActiveGauges({ chainList }: { chainList: Chain[] }) {
coin.denom.match(/gamm\/pool\/[0-9]+/m)
) && // no gamm share rewards
gauge.filled_epochs != gauge.num_epochs_paid_over && // no completed gauges
checkForStaleness(gauge, parseInt(data[data.length - 1].id), epochs)
checkForStaleness(
gauge,
Number.parseInt(data[data.length - 1].id),
epochs
)
)
.map((gauge) => ({
...gauge,
start_time: new Date(gauge.start_time),
distribute_to: {
...gauge.distribute_to,
duration: dayjs.duration(
parseInt(gauge.distribute_to.duration.replace("s", "")) * 1000
Number.parseInt(gauge.distribute_to.duration.replace("s", "")) *
1000
),
},
}));
Expand All @@ -312,6 +319,6 @@ function checkForStaleness(gauge: Gauge, lastGaugeId: number, epochs: Epoch[]) {
(parsedGaugeStartTime > NOW - DURATION_1_DAY &&
parsedGaugeStartTime < CURRENT_EPOCH_START_TIME + DURATION_1_DAY) ||
(parsedGaugeStartTime < NOW &&
parseInt(gauge.id) > lastGaugeId - MAX_NEW_GAUGES_PER_DAY)
Number.parseInt(gauge.id) > lastGaugeId - MAX_NEW_GAUGES_PER_DAY)
);
}
4 changes: 2 additions & 2 deletions packages/server/src/queries/data-services/filtered-pools.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { apiClient } from "@osmosis-labs/utils";

import { TIMESERIES_DATA_URL } from "../../env";
import { HISTORICAL_DATA_URL } from "../../env";

export type PoolToken = {
name: string;
Expand Down Expand Up @@ -81,7 +81,7 @@ export async function queryFilteredPools(
pagination?: Partial<Pagination>
): Promise<FilteredPoolsResponse> {
// collect params
const url = new URL("/stream/pool/v1/all", TIMESERIES_DATA_URL);
const url = new URL("/stream/pool/v1/all", HISTORICAL_DATA_URL);
const queryParams = new URLSearchParams();
if (filters)
Object.entries(filters).forEach(([key, value]) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/server/src/queries/data-services/pools-fees.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { apiClient } from "@osmosis-labs/utils";

import { TIMESERIES_DATA_URL } from "../../env";
import { HISTORICAL_DATA_URL } from "../../env";

export interface PoolFees {
last_update_at: number;
Expand All @@ -15,6 +15,6 @@ export interface PoolFees {
}

export function queryPoolsFees(): Promise<PoolFees> {
const url = new URL("/fees/v1/pools", TIMESERIES_DATA_URL);
const url = new URL("/fees/v1/pools", HISTORICAL_DATA_URL);
return apiClient<PoolFees>(url.toString());
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { apiClient } from "@osmosis-labs/utils";

import { INDEXER_DATA_URL } from "../../env";
import { HISTORICAL_DATA_URL } from "../../env";

interface Asset {
denom: string;
Expand Down Expand Up @@ -46,7 +46,7 @@ export async function queryPositionPerformance({
}): Promise<PositionPerformance> {
const url = new URL(
`/cl/v1/position/last/id/${positionId}`,
INDEXER_DATA_URL
HISTORICAL_DATA_URL
);

return await apiClient<PositionPerformance>(url.toString());
Expand Down
4 changes: 2 additions & 2 deletions packages/server/src/queries/data-services/price-range-apr.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { apiClient } from "@osmosis-labs/utils";

import { INDEXER_DATA_URL } from "../../env";
import { HISTORICAL_DATA_URL } from "../../env";

interface PriceRangeAPR {
APR: number;
Expand All @@ -17,7 +17,7 @@ export async function queryPriceRangeApr({
}): Promise<PriceRangeAPR> {
const url = new URL(
`/cl/v1/apr/rewards/${poolId}?lower_tick=${lowerTickIndex}&upper_tick=${upperTickIndex}`,
INDEXER_DATA_URL
HISTORICAL_DATA_URL
);

return await apiClient<PriceRangeAPR>(url.toString());
Expand Down
6 changes: 3 additions & 3 deletions packages/server/src/queries/data-services/token-data.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { apiClient } from "@osmosis-labs/utils";

import { TIMESERIES_DATA_URL } from "../../env";
import { HISTORICAL_DATA_URL } from "../../env";

export interface TokenData {
price: number | null;
Expand All @@ -27,14 +27,14 @@ export async function queryTokenData({
coinDenom: string;
}): Promise<TokenData> {
// collect params
const url = new URL(`/tokens/v2/${coinDenom}`, TIMESERIES_DATA_URL);
const url = new URL(`/tokens/v2/${coinDenom}`, HISTORICAL_DATA_URL);

// for some reason it returns in an array format, but let's return the first item
return (await apiClient<TokenData[]>(url.toString()))?.[0];
}

export async function queryAllTokenData(): Promise<TokenData[]> {
// collect params
const url = new URL("/tokens/v2/all", TIMESERIES_DATA_URL);
const url = new URL("/tokens/v2/all", HISTORICAL_DATA_URL);
return await apiClient<TokenData[]>(url.toString());
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { apiClient } from "@osmosis-labs/utils";

import { TIMESERIES_DATA_URL } from "../../env";
import { HISTORICAL_DATA_URL } from "../../env";

/**
* Time frame represents the amount of minutes per bar, basically price every
Expand Down Expand Up @@ -56,7 +56,7 @@ export async function queryTokenHistoricalChart({
`/tokens/v2/historical/${encodeURIComponent(
coinMinimalDenom
)}/chart?tf=${timeFrameMinutes}`,
TIMESERIES_DATA_URL
HISTORICAL_DATA_URL
);
try {
const response = await apiClient<
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { apiClient } from "@osmosis-labs/utils";

import { TIMESERIES_DATA_URL } from "../../env";
import { HISTORICAL_DATA_URL } from "../../env";

export interface TokenPairHistoricalPrice {
close: number;
Expand Down Expand Up @@ -33,7 +33,7 @@ export async function queryTokenPairHistoricalChart(
// collect params
const url = new URL(
`/pairs/v1/historical/${poolId}/chart?asset_in=${quoteCoinMinimalDenom}&asset_out=${baseCoinMinimalDenom}&range=${priceRange}&asset_type=denom`,
TIMESERIES_DATA_URL
HISTORICAL_DATA_URL
);
try {
const response = await apiClient<
Expand Down
1 change: 0 additions & 1 deletion packages/server/src/queries/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export * from "./blockaid";
export * from "./coingecko";
export * from "./complex";
export * from "./contracts";
Expand Down
14 changes: 7 additions & 7 deletions packages/web/.env
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@

GITHUB_URL=https://raw.githubusercontent.com/osmosis-labs/
CMS_REPOSITORY_PATH=assetlists/main/osmosis-1/generated/asset_detail
NEXT_PUBLIC_TFM_API_BASE_URL=https://api.tfm.com

# Bridge providers
NEXT_PUBLIC_SQUID_INTEGRATOR_ID=osmosis-api
# SKIP_API_KEY=

jonator marked this conversation as resolved.
Show resolved Hide resolved
# Data services URLs
NEXT_PUBLIC_SIDECAR_BASE_URL=https://sqs.osmosis.zone
NEXT_PUBLIC_HISTORICAL_DATA_URL=https://data.app.osmosis.zone


# Feature Flags
# NEXT_PUBLIC_LAUNCH_DARKLY_CLIENT_SIDE_ID=""
Expand All @@ -23,8 +29,6 @@ NEXT_PUBLIC_SIDECAR_BASE_URL=https://sqs.osmosis.zone
# NEXT_PUBLIC_OSMOSIS_CHAIN_NAME_OVERWRITE=Osmosis (Testnet v13.X latest)
# NEXT_PUBLIC_WALLETCONNECT_PROJECT_KEY=YOUR_WALLETCONNECT_PROJECT_KEY
# NEXT_PUBLIC_WALLETCONNECT_RELAY_URL=wss://relay.walletconnect.com
# NEXT_PUBLIC_TIMESERIES_DATA_URL=https://data.stage.osmosis.zone
# NEXT_PUBLIC_INDEXER_DATA_URL=https://data.stage.osmosis.zone

# Twitter api config, it's only used on server
TWITTER_API_URL=https://api.twitter.com/
Expand All @@ -44,10 +48,6 @@ TWITTER_API_URL=https://api.twitter.com/
# Pools that are excluded from showing external boost incentives APRs.
# NEXT_PUBLIC_EXCLUDED_EXTERNAL_BOOSTS_POOL_IDS=

# Blockaid API
BLOCKAID_BASE_URL=http://api.blockaid.io:80
# BLOCKAID_API_KEY=

NEXT_PUBLIC_SPEND_LIMIT_CONTRACT_ADDRESS=osmo10xqv8rlpkflywm92k5wdmplzy7khtasl9c2c08psmvlu543k724sy94k74

# Disable TRPC logs in development
Expand Down
3 changes: 1 addition & 2 deletions packages/web/config/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ export const WALLETCONNECT_PROJECT_KEY =
export const WALLETCONNECT_RELAY_URL =
process.env.NEXT_PUBLIC_WALLETCONNECT_RELAY_URL;

export const TIMESERIES_DATA_URL = process.env.NEXT_PUBLIC_TIMESERIES_DATA_URL;
export const INDEXER_DATA_URL = process.env.NEXT_PUBLIC_INDEXER_DATA_URL;
export const HISTORICAL_DATA_URL = process.env.NEXT_PUBLIC_HISTORICAL_DATA_URL;

export const TWITTER_PUBLIC_URL = "https://x.com";
export const COINGECKO_PUBLIC_URL = "https://www.coingecko.com";
Expand Down
Loading
Loading