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

Publish Stage #3831

Merged
merged 12 commits into from
Sep 10, 2024
Merged
20 changes: 20 additions & 0 deletions .github/workflows/pr-notification.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: PR Notification
on:
pull_request:
types: [opened, reopened]
branches:
- master
jobs:
slack-notification:
runs-on: ubuntu-latest
steps:
- name: Slack Notification
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
text: New PR opened to master branch
author_name: GitHub Action
fields: repo,message,commit,author,action,eventName,ref,workflow
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_ANNOUNCEMENT_WEBHOOK_URL }}
6 changes: 3 additions & 3 deletions packages/bridge/src/__tests__/mock-asset-lists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1445,7 +1445,7 @@ export const MockAssetLists: AssetList[] = [
sourceDenom: "wmatic-wei",
coinMinimalDenom:
"ibc/AB589511ED0DD5FA56171A39978AFBF1371DB986EC1C3526CE138A16377E39BB",
symbol: "MATIC",
symbol: "POL",
decimals: 18,
logoURIs: {
png: "https://raw.githubusercontent.com/cosmos/chain-registry/master/_non-cosmos/polygon/images/matic-purple.png",
Expand Down Expand Up @@ -1506,15 +1506,15 @@ export const MockAssetLists: AssetList[] = [
chainType: "evm",
chainId: 137,
address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
symbol: "MATIC",
symbol: "POL",
decimals: 18,
logoURIs: {
png: "https://raw.githubusercontent.com/cosmos/chain-registry/master/_non-cosmos/polygon/images/matic-purple.png",
svg: "https://raw.githubusercontent.com/cosmos/chain-registry/master/_non-cosmos/polygon/images/matic-purple.svg",
},
},
],
variantGroupKey: "MATIC",
variantGroupKey: "POL",
name: "Polygon",
isAlloyed: false,
verified: true,
Expand Down
2 changes: 1 addition & 1 deletion packages/bridge/src/squid/__tests__/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1977,7 +1977,7 @@ export const MockChains = [
chainId: 137,
nativeCurrency: {
name: "Polygon",
symbol: "MATIC",
symbol: "POL",
decimals: 18,
icon: "https://raw.githubusercontent.com/axelarnetwork/axelar-docs/main/public/images/chains/polygon.svg",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ describe("SquidBridgeProvider", () => {
chainId: 137,
nativeCurrency: {
name: "Polygon",
symbol: "MATIC",
symbol: "POL",
decimals: 18,
icon: "https://raw.githubusercontent.com/axelarnetwork/axelar-docs/main/public/images/chains/polygon.svg",
},
Expand Down
8 changes: 4 additions & 4 deletions packages/server/src/queries/__tests__/mock-asset-lists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1447,7 +1447,7 @@ export const AssetLists: AssetList[] = [
sourceDenom: "wmatic-wei",
coinMinimalDenom:
"ibc/AB589511ED0DD5FA56171A39978AFBF1371DB986EC1C3526CE138A16377E39BB",
symbol: "MATIC",
symbol: "POL",
decimals: 18,
logoURIs: {
png: "https://raw.githubusercontent.com/cosmos/chain-registry/master/_non-cosmos/polygon/images/matic-purple.png",
Expand Down Expand Up @@ -1508,22 +1508,22 @@ export const AssetLists: AssetList[] = [
chainType: "evm",
chainId: 137,
address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
symbol: "MATIC",
symbol: "POL",
decimals: 18,
logoURIs: {
png: "https://raw.githubusercontent.com/cosmos/chain-registry/master/_non-cosmos/polygon/images/matic-purple.png",
svg: "https://raw.githubusercontent.com/cosmos/chain-registry/master/_non-cosmos/polygon/images/matic-purple.svg",
},
},
],
variantGroupKey: "MATIC",
variantGroupKey: "POL",
name: "Polygon",
isAlloyed: false,
verified: true,
unstable: false,
disabled: false,
preview: false,
relative_image_url: "/tokens/generated/matic.png",
relative_image_url: "/tokens/generated/pol.png",
},
{
chainName: "axelar",
Expand Down
47 changes: 44 additions & 3 deletions packages/server/src/queries/complex/orderbooks/active-orders.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { Dec, Int } from "@keplr-wallet/unit";
import { tickToPrice } from "@osmosis-labs/math";
import { Chain } from "@osmosis-labs/types";
import { AssetList, Chain } from "@osmosis-labs/types";
import { getAssetFromAssetList } from "@osmosis-labs/utils";
import cachified, { CacheEntry } from "cachified";
import dayjs from "dayjs";
import { LRUCache } from "lru-cache";

import { DEFAULT_LRU_OPTIONS } from "../../../utils/cache";
import { LimitOrder, queryOrderbookActiveOrders } from "../../osmosis";
import { queryActiveOrdersSQS } from "../../sidecar/orderbooks";
import {
getOrderbookTickState,
getOrderbookTickUnrealizedCancels,
Expand All @@ -16,6 +17,46 @@ import type { MappedLimitOrder, OrderStatus } from "./types";

const activeOrdersCache = new LRUCache<string, CacheEntry>(DEFAULT_LRU_OPTIONS);

export function getOrderbookActiveOrdersSQS({
userOsmoAddress,
assetList,
}: {
userOsmoAddress: string;
assetList: AssetList[];
}) {
return cachified({
cache: activeOrdersCache,
key: `orderbookActiveOrders-sqs-${userOsmoAddress}`,
ttl: 5000, // 5 seconds
getFreshValue: () =>
queryActiveOrdersSQS({
userOsmoAddress,
}).then(async ({ orders }) => {
const mappedOrders: MappedLimitOrder[] = orders.map((o) => {
return {
...o,
price: new Dec(o.price),
quantity: parseInt(o.quantity),
placed_quantity: parseInt(o.placed_quantity),
percentClaimed: new Dec(o.percentClaimed),
totalFilled: parseInt(o.totalFilled),
percentFilled: new Dec(o.percentFilled),
quoteAsset: getAssetFromAssetList({
coinMinimalDenom: o.quote_asset.symbol,
assetLists: assetList,
}),
baseAsset: getAssetFromAssetList({
coinMinimalDenom: o.base_asset.symbol,
assetLists: assetList,
}),
output: new Dec(o.output),
};
});
return mappedOrders;
}),
});
}

export function getOrderbookActiveOrders({
orderbookAddress,
userOsmoAddress,
Expand All @@ -32,7 +73,7 @@ export function getOrderbookActiveOrders({
return cachified({
cache: activeOrdersCache,
key: `orderbookActiveOrders-${orderbookAddress}-${userOsmoAddress}`,
ttl: 2000, // 2 seconds
ttl: 10000, // 10 seconds
getFreshValue: () =>
queryOrderbookActiveOrders({
orderbookAddress,
Expand Down Expand Up @@ -152,7 +193,7 @@ async function getTickInfoAndTransformOrders(
output,
quoteAsset,
baseAsset,
placed_at: dayjs(parseInt(o.placed_at) / 1_000).unix(),
placed_at: dayjs(o.placed_at / 1000).unix(),
};
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,11 @@ async function mapHistoricalToMapped(
order_direction: o.order_direction,
order_id: parseInt(o.order_id),
owner: userAddress,
placed_at:
dayjs(
o.place_timestamp && o.place_timestamp.length > 0
? o.place_timestamp
: 0
).unix() * 1000,
placed_at: dayjs(
o.place_timestamp && o.place_timestamp.length > 0
? o.place_timestamp
: 0
).unix(),
placed_quantity: parseInt(o.quantity),
placedQuantityMin,
quantityMin,
Expand Down
18 changes: 8 additions & 10 deletions packages/server/src/queries/complex/orderbooks/pools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,14 @@ export function getOrderbookPools() {
ttl: 1000 * 60 * 60, // 1 hour
getFreshValue: () =>
queryCanonicalOrderbooks().then(async (data) => {
return data
.filter((o) => o.pool_id < 2065)
.map((orderbook) => {
return {
baseDenom: orderbook.base,
quoteDenom: orderbook.quote,
contractAddress: orderbook.contract_address,
poolId: orderbook.pool_id.toString(),
};
}) as Orderbook[];
return data.map((orderbook) => {
return {
baseDenom: orderbook.base,
quoteDenom: orderbook.quote,
contractAddress: orderbook.contract_address,
poolId: orderbook.pool_id.toString(),
};
}) as Orderbook[];
}),
});
}
4 changes: 2 additions & 2 deletions packages/server/src/queries/complex/orderbooks/tick-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function getOrderbookTickState({
key: `orderbookTickInfo-${orderbookAddress}-${tickIds
.sort((a, b) => a - b)
.join(",")}`,
ttl: 1000 * 6, // 6 seconds
ttl: 1000 * 10, // 6 seconds
getFreshValue: () =>
queryOrderbookTicks({ orderbookAddress, chainList, tickIds }).then(
({ data }) => data.ticks
Expand All @@ -46,7 +46,7 @@ export function getOrderbookTickUnrealizedCancels({
key: `orderbookTickUnrealizedCancels-${orderbookAddress}-${tickIds
.sort((a, b) => a - b)
.join(",")}`,
ttl: 1000 * 6, // 6 seconds
ttl: 1000 * 10, // 10 seconds
getFreshValue: () =>
queryOrderbookTickUnrealizedCancelsById({
orderbookAddress,
Expand Down
2 changes: 1 addition & 1 deletion packages/server/src/queries/osmosis/orderbooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export interface LimitOrder {
etas: string;
claim_bounty?: string;
placed_quantity: string;
placed_at: string;
placed_at: number;
}

interface OrderbookActiveOrdersResponse {
Expand Down
40 changes: 40 additions & 0 deletions packages/server/src/queries/sidecar/orderbooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,47 @@ export type CanonicalOrderbooksResponse = {
contract_address: string;
}[];

export interface SQSActiveOrder {
tick_id: number;
order_id: number;
order_direction: "bid" | "ask";
owner: string;
quantity: string;
etas: string;
placed_quantity: string;
placed_at: number;
price: string;
percentClaimed: string;
totalFilled: string;
percentFilled: string;
orderbookAddress: string;
status: "open" | "partiallyFilled";
output: string;
quote_asset: {
symbol: string;
};
base_asset: {
symbol: string;
};
}

export type ActiveOrdersResponse = {
orders: SQSActiveOrder[];
};

export async function queryCanonicalOrderbooks() {
const url = new URL("/pools/canonical-orderbooks", SIDECAR_BASE_URL);
return await apiClient<CanonicalOrderbooksResponse>(url.toString());
}

export async function queryActiveOrdersSQS({
userOsmoAddress,
}: {
userOsmoAddress: string;
}) {
const url = new URL(
`/passthrough/active-orders?userOsmoAddress=${userOsmoAddress}`,
SIDECAR_BASE_URL
);
return await apiClient<ActiveOrdersResponse>(url.toString());
}
8 changes: 4 additions & 4 deletions packages/stores/src/tests/mock-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2401,7 +2401,7 @@ export const MockAssetList: AssetList[] = [
sourceDenom: "wmatic-wei",
coinMinimalDenom:
"ibc/AB589511ED0DD5FA56171A39978AFBF1371DB986EC1C3526CE138A16377E39BB",
symbol: "MATIC",
symbol: "POL",
decimals: 18,
logoURIs: {
png: "https://raw.githubusercontent.com/cosmos/chain-registry/master/_non-cosmos/polygon/images/matic-purple.png",
Expand Down Expand Up @@ -2462,22 +2462,22 @@ export const MockAssetList: AssetList[] = [
chainType: "evm",
chainId: 137,
address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
symbol: "MATIC",
symbol: "POL",
decimals: 18,
logoURIs: {
png: "https://raw.githubusercontent.com/cosmos/chain-registry/master/_non-cosmos/polygon/images/matic-purple.png",
svg: "https://raw.githubusercontent.com/cosmos/chain-registry/master/_non-cosmos/polygon/images/matic-purple.svg",
},
},
],
variantGroupKey: "MATIC",
variantGroupKey: "POL",
name: "Polygon",
isAlloyed: false,
verified: true,
unstable: false,
disabled: false,
preview: false,
relative_image_url: "/tokens/generated/matic.png",
relative_image_url: "/tokens/generated/pol.png",
},
{
chainName: "axelar",
Expand Down
8 changes: 4 additions & 4 deletions packages/trpc/src/__tests_e2e__/mock-asset-lists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1447,7 +1447,7 @@ export const AssetLists: AssetList[] = [
sourceDenom: "wmatic-wei",
coinMinimalDenom:
"ibc/AB589511ED0DD5FA56171A39978AFBF1371DB986EC1C3526CE138A16377E39BB",
symbol: "MATIC",
symbol: "POL",
decimals: 18,
logoURIs: {
png: "https://raw.githubusercontent.com/cosmos/chain-registry/master/_non-cosmos/polygon/images/matic-purple.png",
Expand Down Expand Up @@ -1508,22 +1508,22 @@ export const AssetLists: AssetList[] = [
chainType: "evm",
chainId: 137,
address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
symbol: "MATIC",
symbol: "POL",
decimals: 18,
logoURIs: {
png: "https://raw.githubusercontent.com/cosmos/chain-registry/master/_non-cosmos/polygon/images/matic-purple.png",
svg: "https://raw.githubusercontent.com/cosmos/chain-registry/master/_non-cosmos/polygon/images/matic-purple.svg",
},
},
],
variantGroupKey: "MATIC",
variantGroupKey: "POL",
name: "Polygon",
isAlloyed: false,
verified: true,
unstable: false,
disabled: false,
preview: false,
relative_image_url: "/tokens/generated/matic.png",
relative_image_url: "/tokens/generated/pol.png",
},
{
chainName: "axelar",
Expand Down
Loading
Loading