Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/stage' into jose/fe-535-ui-layou…
Browse files Browse the repository at this point in the history
…t-depositwidthdraw-amount-screen
  • Loading branch information
JoseRFelix committed Jun 12, 2024
2 parents f5794de + c67f6eb commit 2196ec3
Show file tree
Hide file tree
Showing 87 changed files with 1,268 additions and 1,472 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/frontend-e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Install Playwright
run: |
yarn --cwd packages/web install --frozen-lockfile && npx playwright install --with-deps chromium
- name: Run Select Swap Pair tests on Master
- name: Run Swap Pair tests on Master
env:
BASE_URL: "https://app.osmosis.zone"
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
Expand Down Expand Up @@ -63,7 +63,7 @@ jobs:
- name: Install Playwright
run: |
yarn --cwd packages/web install --frozen-lockfile && npx playwright install --with-deps chromium
- name: Run Select Swap Pair tests on Stage
- name: Run Swap Pair tests on Stage
env:
BASE_URL: ${{ github.event.deployment_status.environment_url }}
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
Expand Down
23 changes: 11 additions & 12 deletions packages/bridge/src/axelar/__tests__/axelar-bridge-provider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,14 @@ import { NativeEVMTokenConstantAddress } from "../../ethereum";
import { BridgeProviderContext } from "../../interface";
import { AxelarBridgeProvider } from "../index";

jest.mock("viem", () => {
const originalModule = jest.requireActual("viem");
return {
...originalModule,
createPublicClient: jest.fn().mockImplementation(() => ({
estimateGas: jest.fn().mockResolvedValue(BigInt("21000")),
getGasPrice: jest.fn().mockResolvedValue(BigInt("0x4a817c800")),
})),
http: jest.fn(),
};
});
jest.mock("viem", () => ({
...jest.requireActual("viem"),
createPublicClient: jest.fn().mockImplementation(() => ({
estimateGas: jest.fn().mockResolvedValue(BigInt("21000")),
getGasPrice: jest.fn().mockResolvedValue(BigInt("0x4a817c800")),
})),
http: jest.fn(),
}));

beforeEach(() => {
server.use(
Expand Down Expand Up @@ -118,7 +115,9 @@ describe("AxelarBridgeProvider", () => {
},
toAddress: "0x456",
})
).rejects.toThrow("Unsupported chain");
).rejects.toThrow(
"Unsupported chain: Chain ID 989898989898 is not supported."
);
});

it("should estimate gas cost for EVM transactions", async () => {
Expand Down
6 changes: 5 additions & 1 deletion packages/bridge/src/axelar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,11 @@ export class AxelarBridgeProvider implements BridgeProvider {
const toChainAxelarId = this.getAxelarChainId(toChain);

if (!fromChainAxelarId || !toChainAxelarId) {
throw new Error("Unsupported chain");
throw new Error(
`Unsupported chain: Chain ID ${
!fromChainAxelarId ? fromChain.chainId : toChain.chainId
} is not supported.`
);
}

return cachified({
Expand Down
27 changes: 12 additions & 15 deletions packages/bridge/src/skip/__tests__/skip-bridge-provider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,18 @@ import {
import { SkipBridgeProvider } from "..";
import { SkipMsg } from "../types";

jest.mock("viem", () => {
const originalModule = jest.requireActual("viem");
return {
...originalModule,
createPublicClient: jest.fn().mockImplementation(() => ({
estimateGas: jest.fn().mockResolvedValue(BigInt("21000")),
request: jest.fn().mockResolvedValue("0x4a817c800"),
getGasPrice: jest.fn().mockResolvedValue(BigInt("20000000000")),
readContract: jest.fn().mockResolvedValue(BigInt("100")),
})),
encodeFunctionData: jest.fn().mockReturnValue("0xabcdef"),
encodePacked: jest.fn().mockReturnValue("0xabcdef"),
keccak256: jest.fn().mockReturnValue("0xabcdef"),
};
});
jest.mock("viem", () => ({
...jest.requireActual("viem"),
createPublicClient: jest.fn().mockImplementation(() => ({
estimateGas: jest.fn().mockResolvedValue(BigInt("21000")),
request: jest.fn().mockResolvedValue("0x4a817c800"),
getGasPrice: jest.fn().mockResolvedValue(BigInt("20000000000")),
readContract: jest.fn().mockResolvedValue(BigInt("100")),
})),
encodeFunctionData: jest.fn().mockReturnValue("0xabcdef"),
encodePacked: jest.fn().mockReturnValue("0xabcdef"),
keccak256: jest.fn().mockReturnValue("0xabcdef"),
}));

beforeEach(() => {
server.use(
Expand Down
29 changes: 13 additions & 16 deletions packages/bridge/src/squid/__tests__/squid-bridge-provider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,19 @@ import { BridgeQuoteError } from "../../errors";
import { BridgeProviderContext } from "../../interface";
import { SquidBridgeProvider } from "../index";

jest.mock("viem", () => {
const originalModule = jest.requireActual("viem");
return {
...originalModule,
createPublicClient: jest.fn().mockImplementation(() => ({
readContract: jest.fn().mockImplementation(({ functionName }) => {
if (functionName === "allowance") {
return Promise.resolve(BigInt("100"));
}
return Promise.reject(new Error("Unknown function"));
}),
})),
encodeFunctionData: jest.fn().mockImplementation(() => "0xabcdef"),
http: jest.fn().mockImplementation(() => ({})),
};
});
jest.mock("viem", () => ({
...jest.requireActual("viem"),
createPublicClient: jest.fn().mockImplementation(() => ({
readContract: jest.fn().mockImplementation(({ functionName }) => {
if (functionName === "allowance") {
return Promise.resolve(BigInt("100"));
}
return Promise.reject(new Error("Unknown function"));
}),
})),
encodeFunctionData: jest.fn().mockImplementation(() => "0xabcdef"),
http: jest.fn().mockImplementation(() => ({})),
}));

beforeEach(() => {
server.use(
Expand Down
7 changes: 6 additions & 1 deletion packages/server/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,15 @@ export const TIMESERIES_DATA_URL =
export const INDEXER_DATA_URL =
process.env.NEXT_PUBLIC_INDEXER_DATA_URL ??
"https://stage-proxy-data-indexer.osmosis-labs.workers.dev";
export const NUMIA_BASE_URL =
process.env.NEXT_PUBLIC_NUMIA_BASE_URL ??
"https://public-osmosis-api.numia.xyz";

// 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 NUMIA_BASE_URL = "https://public-osmosis-api.numia.xyz";

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;
Expand Down
80 changes: 43 additions & 37 deletions packages/server/src/queries/complex/concentrated-liquidity/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,28 +255,27 @@ export async function mapGetUserPositionDetails({
...params,
bech32Address: userOsmoAddress,
});
const stakeCurrencyPromise = getAsset({
...params,
anyDenom: params.chainList[0].staking.staking_tokens[0].denom,
});
const superfluidPoolIdsPromise = getSuperfluidPoolIds(params);

const [
positions,
userUnbondingPositions,
delegatedPositions,
undelegatingPositions,
stakeCurrency,
superfluidPoolIds,
] = await Promise.all([
positionsPromise,
userUnbondingPositionsPromise,
delegatedPositionsPromise,
undelegatingPositionsPromise,
stakeCurrencyPromise,
superfluidPoolIdsPromise,
]);

const stakeCurrency = getAsset({
...params,
anyDenom: params.chainList[0].staking.staking_tokens[0].denom,
});

const lockableDurations = getLockableDurations();
const longestLockDuration = lockableDurations[lockableDurations.length - 1];

Expand Down Expand Up @@ -585,23 +584,28 @@ export type PositionHistoricalPerformance = Awaited<

/** Gets a breakdown of current and reward coins, with fiat values, for a single CL position. */
export async function getPositionHistoricalPerformance({
positionId,
position: givenPosition,
...params
}: {
assetLists: AssetList[];
chainList: Chain[];
positionId: string;
/** Position by ID or the returned position object. */
position: string | LiquidityPosition;
}) {
const [{ position }, performance] = await Promise.all([
queryPositionById({ ...params, id: positionId }),
queryPositionPerformance({
positionId,
}),
]);
const { position } =
typeof givenPosition === "string"
? await queryPositionById({ ...params, id: givenPosition })
: { position: givenPosition };

const performance = await queryPositionPerformance({
positionId: position.position.position_id,
});

// There is no performance data for this position
if (performance.message) {
console.error(`No performance data for position ${positionId}`);
console.error(
`No performance data for position ${position.position.position_id}`
);
}

// get all user CL coins, including claimable rewards
Expand Down Expand Up @@ -651,31 +655,33 @@ export async function getPositionHistoricalPerformance({

// calculate fiat values

const currentValue = new PricePretty(
DEFAULT_VS_CURRENCY,
await calcSumCoinsValue({ ...params, coins: currentCoins }).catch((e) =>
captureErrorAndReturn(e, new Dec(0))
)
);
const currentCoinsValues = (
await Promise.all(
const [
currentValue,
currentCoinsValues,
principalValue,
claimableRewardsValue,
totalEarnedValue,
] = await Promise.all([
calcSumCoinsValue({ ...params, coins: currentCoins })
.then((value) => new PricePretty(DEFAULT_VS_CURRENCY, value))
.catch(() => new PricePretty(DEFAULT_VS_CURRENCY, new Dec(0))),
Promise.all(
currentCoins
.map((coin) => calcCoinValue({ ...params, coin }))
.map((p) => p.catch((e) => captureErrorAndReturn(e, 0)))
)
).map((p) => new PricePretty(DEFAULT_VS_CURRENCY, p));
const principalValue = new PricePretty(
DEFAULT_VS_CURRENCY,
await calcSumCoinsValue({ ...params, coins: principalCoins })
);
const claimableRewardsValue = new PricePretty(
DEFAULT_VS_CURRENCY,
await calcSumCoinsValue({ ...params, coins: claimableRewardCoins })
);
const totalEarnedValue = new PricePretty(
DEFAULT_VS_CURRENCY,
await calcSumCoinsValue({ ...params, coins: totalRewardCoins })
);
).then((values) =>
values.map((p) => new PricePretty(DEFAULT_VS_CURRENCY, p))
),
calcSumCoinsValue({ ...params, coins: principalCoins }).then(
(value) => new PricePretty(DEFAULT_VS_CURRENCY, value)
),
calcSumCoinsValue({ ...params, coins: claimableRewardCoins }).then(
(value) => new PricePretty(DEFAULT_VS_CURRENCY, value)
),
calcSumCoinsValue({ ...params, coins: totalRewardCoins }).then(
(value) => new PricePretty(DEFAULT_VS_CURRENCY, value)
),
]);

const principalValueDec = principalValue.toDec();

Expand Down
7 changes: 5 additions & 2 deletions packages/server/src/queries/complex/pools/bonding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,11 @@ export async function getSharePoolBondDurations({
userLockedLocks.forEach((userDurationLock) => {
userDurationLock.coins.forEach((coin) => {
if (getShareDenomPoolId(coin.denom) === poolId) {
userShares = userShares.add(
new CoinPretty(userShares.currency, coin.amount)
const lockedShares = new CoinPretty(
userShares.currency,
coin.amount
);
userShares = userShares.add(lockedShares);
}
});
userLockedLockIds.push(userDurationLock.ID);
Expand Down Expand Up @@ -334,6 +336,7 @@ export async function getSharePoolBondDurations({
return {
duration: dayjs.duration(durationMs),
bondable: isSuperfluid ? isLongestDuration : Boolean(durationGauges),
/** Locked shares */
userShares,
userLockedShareValue,
userLocks: userLockedLockIds.map((lockId) => ({
Expand Down
Loading

0 comments on commit 2196ec3

Please sign in to comment.