Skip to content

Commit

Permalink
Turkish Language Added
Browse files Browse the repository at this point in the history
Turkish crypto community is one of the largest in crypto. We felt the need to add Turkish as a language to Osmosis.
  • Loading branch information
HuginnAcademy committed Nov 5, 2022
1 parent f95cd19 commit 31bf8ad
Show file tree
Hide file tree
Showing 248 changed files with 14,085 additions and 6,142 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ dist
prod
build
yarn-error.log
.yarn

src/styles/index.scss
.vercel
1 change: 0 additions & 1 deletion CODEOWNERS

This file was deleted.

20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM node:14.19.1 as build

WORKDIR /usr/src/app

COPY . .

RUN npm install -g npm@8.10.0

RUN yarn
RUN yarn build

FROM node:14.19.1-alpine

WORKDIR /usr/src/app

COPY --from=build /usr/src/app .

EXPOSE 3000

CMD [ "yarn", "start" ]
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ Otherwise the non-frontier commands can be used with the env var set to true.

### Testnet

Testnet version of the frontend uses `NEXT_PUBLIC_IS_TESTNET=true`.

Dev:

```bash
Expand Down
9 changes: 9 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: '3.5'

services:
app:
build:
context: .
dockerfile: ./Dockerfile
ports:
- '3000:3000'
4 changes: 3 additions & 1 deletion packages/stores/src/price/pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ export class PoolFallbackPriceStore
protected readonly queryPool: ObservableQueryPools,
intermidiateRoutes: IntermediateRoute[]
) {
super(kvStore, supportedVsCurrencies, defaultVsCurrency);
super(kvStore, supportedVsCurrencies, defaultVsCurrency, {
baseURL: "https://prices.osmosis.zone/api/v3",
});

this._intermidiateRoutes = intermidiateRoutes;

Expand Down
13 changes: 13 additions & 0 deletions packages/stores/src/queries-external/base.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Axios from "axios";
import { ObservableQuery } from "@keplr-wallet/stores";
import { KVStore } from "@keplr-wallet/common";
export class ObservableQueryExternalBase<
T = unknown,
E = unknown
> extends ObservableQuery<T, E> {
constructor(kvStore: KVStore, baseURL: string, urlPath: string) {
const instance = Axios.create({ baseURL });

super(kvStore, instance, urlPath);
}
}
6 changes: 6 additions & 0 deletions packages/stores/src/queries-external/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
export * from "./pool-fees";
export * from "./pool-rewards";
export * from "./store";

export const IMPERATOR_HISTORICAL_DATA_BASEURL =
"https://api-osmosis.imperator.co";
export const IMPERATOR_TX_REWARD_BASEURL =
"https://api-osmosis-chain.imperator.co";
63 changes: 15 additions & 48 deletions packages/stores/src/queries-external/pool-fees/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,19 @@ import { makeObservable } from "mobx";
import { computedFn } from "mobx-utils";
import { KVStore } from "@keplr-wallet/common";
import { Dec, PricePretty, RatePretty } from "@keplr-wallet/unit";
import { pow } from "@osmosis-labs/math";
import { IPriceStore } from "../../price";
import { ObservableQueryPool } from "../../queries/pools";
import { ObservableQueryExternal } from "../store";
import {
ObservablePoolWithFeeMetrics,
PoolFeesMetrics,
PoolFees,
} from "./types";
import { ObservableQueryExternalBase } from "../base";
import { PoolFeesMetrics, PoolFees } from "./types";

/** Queries Imperator pool fee history data. */
export class ObservableQueryPoolFeesMetrics extends ObservableQueryExternal<PoolFees> {
export class ObservableQueryPoolFeesMetrics extends ObservableQueryExternalBase<PoolFees> {
constructor(kvStore: KVStore, baseURL: string) {
super(kvStore, baseURL, "/fees/v1/pools");

makeObservable(this);
}

readonly makePoolWithFeeMetrics = computedFn(
(
pool: ObservableQueryPool,
priceStore: IPriceStore
): ObservablePoolWithFeeMetrics => {
const poolFeesMetrics = this.getPoolFeesMetrics(pool.id, priceStore);
const liquidity = pool.computeTotalValueLocked(priceStore);

return {
pool,
liquidity,
...poolFeesMetrics,
};
}
);

readonly getPoolFeesMetrics = computedFn(
(poolId: string, priceStore: IPriceStore): PoolFeesMetrics => {
const fiatCurrency = priceStore.getFiatCurrency(
Expand Down Expand Up @@ -89,32 +68,20 @@ export class ObservableQueryPoolFeesMetrics extends ObservableQueryExternal<Pool
}
);

/** Get pool non-incentivized return from fees based on past 7d of activity, compounded. */
readonly get7dPoolFeeApy = computedFn(
(
pool: ObservablePoolWithFeeMetrics,
priceStore: IPriceStore
): RatePretty => {
const avgDayFeeRevenue = new Dec(
pool.feesSpent7d.toDec().toString(),
6
).quo(new Dec(7));
const poolTVL = pool.pool.computeTotalValueLocked(priceStore).toDec();

if (poolTVL.equals(new Dec(0))) {
return new RatePretty(0).ready(false);
}
const percentRevenue = avgDayFeeRevenue.quo(poolTVL);
const dailyRate = new Dec(1).add(percentRevenue);

if (!dailyRate.lt(new Dec(2))) return new RatePretty(0);
/** Get pool non-incentivized return from fees based on past 7d of activity. */
readonly get7dPoolFeeApr = computedFn(
(pool: ObservableQueryPool, priceStore: IPriceStore): RatePretty => {
const { feesSpent7d } = this.getPoolFeesMetrics(pool.id, priceStore);
const avgDayFeeRevenue = new Dec(feesSpent7d.toDec().toString(), 6).quo(
new Dec(7)
);
const poolTVL = pool.computeTotalValueLocked(priceStore).toDec();
const revenuePerYear = avgDayFeeRevenue.mul(new Dec(365));

const rate = pow(dailyRate, new Dec(365));
if (poolTVL.equals(new Dec(0)) || revenuePerYear.equals(new Dec(0)))
return new RatePretty(0);

return new RatePretty(rate)
.sub(new Dec(1))
.mul(new Dec(2))
.moveDecimalPointLeft(2);
return new RatePretty(revenuePerYear.quo(poolTVL));
}
);
}
Expand Down
11 changes: 1 addition & 10 deletions packages/stores/src/queries-external/pool-fees/types.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
import { PricePretty, RatePretty } from "@keplr-wallet/unit";
import { ObservableQueryPool } from "../../queries/pools";

export interface ObservablePoolWithFeeMetrics extends PoolFeesMetrics {
pool: ObservableQueryPool;
liquidity: PricePretty;
myLiquidity?: PricePretty;
epochsRemaining?: number;
apr?: RatePretty;
}
import { PricePretty } from "@keplr-wallet/unit";

export interface PoolFeesMetrics {
volume24h: PricePretty;
Expand Down
70 changes: 70 additions & 0 deletions packages/stores/src/queries-external/pool-rewards/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { makeObservable } from "mobx";
import { computedFn } from "mobx-utils";
import { KVStore } from "@keplr-wallet/common";
import { HasMapStore } from "@keplr-wallet/stores";
import { Dec, PricePretty } from "@keplr-wallet/unit";
import { IPriceStore } from "../../price";
import { ObservableQueryExternalBase } from "../base";
import { PoolsRewards, PoolRewards } from "./types";

/** Queries Imperator pool fee history data. */
export class ObservableQueryAccountPoolRewards extends ObservableQueryExternalBase<PoolsRewards> {
constructor(
kvStore: KVStore,
baseURL: string,
protected readonly priceStore: IPriceStore,
protected readonly bech32Address: string
) {
super(kvStore, baseURL, `/lp/v1/rewards/estimation/${bech32Address}`);

makeObservable(this);
}

protected canFetch(): boolean {
return this.bech32Address !== "";
}

readonly getUsdRewardsForPool = computedFn(
(poolId: string): PoolRewards | undefined => {
const fiat = this.priceStore.getFiatCurrency("usd");

if (!this.response || !fiat) return undefined;

const poolRewards = this.response.data.pools[poolId] as
| PoolsRewards["pools"][0]
| undefined;

if (!poolRewards) return undefined;

return {
day: new PricePretty(fiat, new Dec(poolRewards.day_usd)),
month: new PricePretty(fiat, new Dec(poolRewards.month_usd)),
year: new PricePretty(fiat, new Dec(poolRewards.year_usd)),
};
}
);
}

export class ObservableQueryAccountsPoolRewards extends HasMapStore<ObservableQueryAccountPoolRewards> {
constructor(
kvStore: KVStore,
priceStore: IPriceStore,
poolRewardsBaseUrl = "https://api-osmosis-chain.imperator.co"
) {
super(
(bech32Address) =>
new ObservableQueryAccountPoolRewards(
kvStore,
poolRewardsBaseUrl,
priceStore,
bech32Address
)
);
}

get(bech32Address: string) {
return super.get(bech32Address) as ObservableQueryAccountPoolRewards;
}
}

export * from "./types";
20 changes: 20 additions & 0 deletions packages/stores/src/queries-external/pool-rewards/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { PricePretty } from "@keplr-wallet/unit";

export interface PoolsRewards {
pools: {
[id: string]: {
day_usd: number;
month_usd: number;
year_usd: number;
};
};
total_day_usd: number;
total_month_usd: number;
total_year_usd: number;
}

export interface PoolRewards {
day: PricePretty;
month: PricePretty;
year: PricePretty;
}
41 changes: 16 additions & 25 deletions packages/stores/src/queries-external/store.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,32 @@
import { KVStore } from "@keplr-wallet/common";
import { HasMapStore, ObservableQuery } from "@keplr-wallet/stores";
import { DeepReadonly } from "utility-types";
import { IPriceStore } from "../price";
import { ObservableQueryPoolFeesMetrics } from "./pool-fees";
import Axios from "axios";

export class QueriesExternalStore extends HasMapStore<QueriesExternal> {
constructor(protected readonly kvStore: KVStore, feeMetricsBaseURL?: string) {
super(() => new QueriesExternal(this.kvStore, feeMetricsBaseURL));
}

get(): QueriesExternal {
return super.get("external");
}
}
import { ObservableQueryAccountsPoolRewards } from "./pool-rewards";
import {
IMPERATOR_HISTORICAL_DATA_BASEURL,
IMPERATOR_TX_REWARD_BASEURL,
} from ".";

/** Root store for queries external to any chain. */
export class QueriesExternal {
export class QueriesExternalStore {
public readonly queryGammPoolFeeMetrics: DeepReadonly<ObservableQueryPoolFeesMetrics>;
public readonly queryAccountsPoolRewards: DeepReadonly<ObservableQueryAccountsPoolRewards>;

constructor(
kvStore: KVStore,
feeMetricsBaseURL = "https://api-osmosis.imperator.co"
priceStore: IPriceStore,
feeMetricsBaseURL = IMPERATOR_HISTORICAL_DATA_BASEURL,
poolRewardsBaseUrl = IMPERATOR_TX_REWARD_BASEURL
) {
this.queryGammPoolFeeMetrics = new ObservableQueryPoolFeesMetrics(
kvStore,
feeMetricsBaseURL
);
}
}

export class ObservableQueryExternal<
T = unknown,
E = unknown
> extends ObservableQuery<T, E> {
constructor(kvStore: KVStore, baseURL: string, urlPath: string) {
const instance = Axios.create({ baseURL });

super(kvStore, instance, urlPath);
this.queryAccountsPoolRewards = new ObservableQueryAccountsPoolRewards(
kvStore,
priceStore,
poolRewardsBaseUrl
);
}
}

0 comments on commit 31bf8ad

Please sign in to comment.