Skip to content

Commit

Permalink
fix: Fix build errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jinoosss committed Dec 1, 2023
1 parent 6dc9eec commit 568c206
Show file tree
Hide file tree
Showing 15 changed files with 55 additions and 66 deletions.
2 changes: 1 addition & 1 deletion packages/swap-router/.ultra.cache.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"files":{".vscode":"1700971955685.2515","build":"1701256570289.2512","node_modules":"1700891704503.8325",".eslintignore":"7de3bd702df2dee92c033c49abbedd0b0f7452e6",".eslintrc.js":"ca4815a5cf5cffa1d3fb4a014c8c602f852b002a",".gitignore":"c87c9b392c0200d9c9dafc444386ad3e15a85c64",".prettierignore":"47bb4656eb55860a075be7799cba7fa955b68141",".prettierrc":"fe5f744c7a08b128c935d1e1aed3e8a577e74507","jest.config.json":"2e496ee6bd64eb237161dcd69a6957eff2df584d","package.json":"4dda70ca76fb6022f6cb20852ecd8d2d95d638d2","src/common/array.util.ts":"9482ab121d34cc7e08a0cd33b49173b0b85823d8","src/common/bigint.util.ts":"343f4c85ca1f6c840ade68c259ed82bf5b159fb0","src/common/index.ts":"861a3167cddfc93e9eb1b6a4ae8229bb9dc2f8fd","src/common/mapper.ts":"f7d7b491dff443911a978b34e4cb378bee46c2b7","src/common/queue.ts":"ad096fefbe1c5a7339b536b0b8d39dba661b520e","src/common/test.util.ts":"3e500df6ec27ba98606acbfcaec9243e22862e43","src/constants/index.ts":"9605b149deb525c25f6e93420bbc433ff1c75cd0","src/constants/math.constant.ts":"b617851527cabcc9c3bce2c8e39208001d379ad6","src/constants/swap.constant.ts":"53e280147c68acfba490bc1f9a0b7bb1580e7280","src/index.ts":"691efb21a28bd3f0e6437edcb16192789dbbb7f6","src/swap-router/index.ts":"effaf28a826bdf1441437643e8343e7fbd8026b1","src/swap-router/swap-router-default.spec.ts":"f980bc94753df130c950eb80d8709b62ec3276fa","src/swap-router/swap-router-multi-higher-range-position-pool.spec.ts":"683ce3a82d73e915018e772723700905c3ff7c92","src/swap-router/swap-router-multi-lower-range-position-pool.spec.ts":"93bfd18d0a297f3c66743cddcf2fe10c3764e250","src/swap-router/swap-router-multi-pair-pools.spec.ts":"5fbd55be39012d46adbdc91a1111dca2aafd314d","src/swap-router/swap-router-multi-route.spec.ts":"771df497876b6bc027dc7b65d03e53209538bf2e","src/swap-router/swap-router-single-pair-pools.spec.ts":"3954e9057ef9534a3724dc960c291281d1a4ef52","src/swap-router/swap-router.ts":"606de3d518665d58f5cbafb55f45d92c30dab77d","src/swap-router/swap-router.types.ts":"2a48987217df238256a0721d227952142a37ce08","src/swap-router/utility/index.ts":"4973874904dd9d77d037d72b1ec8aed397716a38","src/swap-router/utility/route.util.ts":"d492418c9184e42d3ef29d7760eb18fa013f54c6","src/swap-simulator/index.ts":"ef493c5977bdf1123d1197b804f2344ee463870c","src/swap-simulator/swap-simulator-default.spec.ts":"867788b12ccc70abe676010aeed5d6b2b58e8036","src/swap-simulator/swap-simulator.ts":"48cc4c90a2622d806659fa2f8c4f48d600a2b2db","src/swap-simulator/swap-simulator.types.ts":"2b03d7e389ab8875852330c8fddf5a9bfe96f1c6","src/swap-simulator/utility/cache.util.ts":"c5af86d350610a80a6690846657a35635bbc752a","src/swap-simulator/utility/index.ts":"7272f5d23dfa7af2895fca9bb0b17985234ab6e1","src/swap-simulator/utility/math.util.ts":"96fbe38cbabe344f6f58220f46c20103e6df4225","src/swap-simulator/utility/swap-util.spec.ts":"b7fe082f3fef7e5a912959925924f56f8c36e020","src/swap-simulator/utility/swap.util.ts":"f49236f0d22f72b9283244e870d34401d42fe009","src/swap-simulator/utility/tick.util.ts":"4d9bf8ed782f07587c71009ad13cd249b5e3a840","tsconfig.json":"55467bd5c5eb1b501abe50b952d5f2d9fa0a0d69"},"deps":{}}
{"files":{".vscode":"1700971955685.2515","build":"1701412916671.3086","node_modules":"1700891704503.8325",".eslintignore":"7de3bd702df2dee92c033c49abbedd0b0f7452e6",".eslintrc.js":"ca4815a5cf5cffa1d3fb4a014c8c602f852b002a",".gitignore":"c87c9b392c0200d9c9dafc444386ad3e15a85c64",".prettierignore":"47bb4656eb55860a075be7799cba7fa955b68141",".prettierrc":"fe5f744c7a08b128c935d1e1aed3e8a577e74507","jest.config.json":"2e496ee6bd64eb237161dcd69a6957eff2df584d","package.json":"4dda70ca76fb6022f6cb20852ecd8d2d95d638d2","src/common/array.util.ts":"9482ab121d34cc7e08a0cd33b49173b0b85823d8","src/common/bigint.util.ts":"343f4c85ca1f6c840ade68c259ed82bf5b159fb0","src/common/index.ts":"861a3167cddfc93e9eb1b6a4ae8229bb9dc2f8fd","src/common/mapper.ts":"f7d7b491dff443911a978b34e4cb378bee46c2b7","src/common/queue.ts":"ad096fefbe1c5a7339b536b0b8d39dba661b520e","src/common/test.util.ts":"3e500df6ec27ba98606acbfcaec9243e22862e43","src/constants/index.ts":"9605b149deb525c25f6e93420bbc433ff1c75cd0","src/constants/math.constant.ts":"b617851527cabcc9c3bce2c8e39208001d379ad6","src/constants/swap.constant.ts":"53e280147c68acfba490bc1f9a0b7bb1580e7280","src/index.ts":"691efb21a28bd3f0e6437edcb16192789dbbb7f6","src/swap-router/index.ts":"effaf28a826bdf1441437643e8343e7fbd8026b1","src/swap-router/swap-router-default.spec.ts":"f980bc94753df130c950eb80d8709b62ec3276fa","src/swap-router/swap-router-multi-higher-range-position-pool.spec.ts":"683ce3a82d73e915018e772723700905c3ff7c92","src/swap-router/swap-router-multi-lower-range-position-pool.spec.ts":"93bfd18d0a297f3c66743cddcf2fe10c3764e250","src/swap-router/swap-router-multi-pair-pools.spec.ts":"5fbd55be39012d46adbdc91a1111dca2aafd314d","src/swap-router/swap-router-multi-route.spec.ts":"771df497876b6bc027dc7b65d03e53209538bf2e","src/swap-router/swap-router-single-pair-pools.spec.ts":"3954e9057ef9534a3724dc960c291281d1a4ef52","src/swap-router/swap-router.ts":"606de3d518665d58f5cbafb55f45d92c30dab77d","src/swap-router/swap-router.types.ts":"2a48987217df238256a0721d227952142a37ce08","src/swap-router/utility/index.ts":"4973874904dd9d77d037d72b1ec8aed397716a38","src/swap-router/utility/route.util.ts":"d492418c9184e42d3ef29d7760eb18fa013f54c6","src/swap-simulator/index.ts":"ef493c5977bdf1123d1197b804f2344ee463870c","src/swap-simulator/swap-simulator-default.spec.ts":"867788b12ccc70abe676010aeed5d6b2b58e8036","src/swap-simulator/swap-simulator.ts":"48cc4c90a2622d806659fa2f8c4f48d600a2b2db","src/swap-simulator/swap-simulator.types.ts":"2b03d7e389ab8875852330c8fddf5a9bfe96f1c6","src/swap-simulator/utility/cache.util.ts":"c5af86d350610a80a6690846657a35635bbc752a","src/swap-simulator/utility/index.ts":"7272f5d23dfa7af2895fca9bb0b17985234ab6e1","src/swap-simulator/utility/math.util.ts":"96fbe38cbabe344f6f58220f46c20103e6df4225","src/swap-simulator/utility/swap-util.spec.ts":"b7fe082f3fef7e5a912959925924f56f8c36e020","src/swap-simulator/utility/swap.util.ts":"f49236f0d22f72b9283244e870d34401d42fe009","src/swap-simulator/utility/tick.util.ts":"4d9bf8ed782f07587c71009ad13cd249b5e3a840","tsconfig.json":"55467bd5c5eb1b501abe50b952d5f2d9fa0a0d69"},"deps":{}}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import PoolGraph, { type PoolGraphProps } from "./PoolGraph";
import { Meta, StoryObj } from "@storybook/react";
import POOLS from "@repositories/pool/mock/pools.json";
import { PoolModel } from "@models/pool/pool-model";

const pool = POOLS.pools[0];
const pool = POOLS.pools[0] as PoolModel;

export default {
title: "common/PoolGraph",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import PoolSelectionGraph, { type PoolSelectionGraphProps } from "./PoolSelectio
import { ComponentStory, Meta, StoryObj } from "@storybook/react";
import POOLS from "@repositories/pool/mock/pools.json";
import { tickToPrice } from "@utils/swap-utils";
import { PoolModel } from "@models/pool/pool-model";


const test = [
Expand Down Expand Up @@ -1832,7 +1833,7 @@ const test = [
}
];

const pool = POOLS.pools[0];
const pool = POOLS.pools[0] as PoolModel;

export default {
title: "common/PoolSelectionGraph",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import IncentivizedPoolCardList from "../incentivized-pool-card-list/Incentivize
import POOLS from "@repositories/pool/mock/pools.json";
import { PoolMapper } from "@models/pool/mapper/pool-mapper";
import { action } from "@storybook/addon-actions";
import { PoolModel } from "@models/pool/pool-model";

const pool = POOLS.pools[0];
const pool = POOLS.pools[0] as PoolModel;

const cardInfo = PoolMapper.toCardInfo(pool);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import IncentivizedPoolCardList from "./IncentivizedPoolCardList";
import { action } from "@storybook/addon-actions";
import POOLS from "@repositories/pool/mock/pools.json";
import { PoolMapper } from "@models/pool/mapper/pool-mapper";
import { PoolModel } from "@models/pool/pool-model";

const pool = POOLS.pools[0];
const pool = POOLS.pools[0] as PoolModel;

const cardInfo = PoolMapper.toCardInfo(pool);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import IncentivizedPoolCard from "./IncentivizedPoolCard";
import { action } from "@storybook/addon-actions";
import POOLS from "@repositories/pool/mock/pools.json";
import { PoolMapper } from "@models/pool/mapper/pool-mapper";
import { PoolModel } from "@models/pool/pool-model";

const pool = POOLS.pools[0];
const pool = POOLS.pools[0] as PoolModel;

const cardInfo = PoolMapper.toCardInfo(pool);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const pool: PoolCardInfo = {
amount: 10
}
],
incentiveType: "Incentivized",
incentivizedType: "INCENTIVIZED",
currentTick: 0,
price: 0,
bins: []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import PoolListTable from "./PoolListTable";
import { action } from "@storybook/addon-actions";
import POOLS from "@repositories/pool/mock/pools.json";
import { PoolMapper } from "@models/pool/mapper/pool-mapper";
import { PoolModel } from "@models/pool/pool-model";

const pool = POOLS.pools[0];
const pool = POOLS.pools[0] as PoolModel;

const listInfo = PoolMapper.toListInfo(pool);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { useWallet } from "@hooks/wallet/use-wallet";
export const dummyDisclaimer =
"This feature enables you to provide incentives as staking rewards for a specific liquidity pool. Before you proceed, ensure that you understand the mechanics of external incentives and acknowledge that you cannot withdraw the rewards once you complete this step.<br /><br />The incentives you add will be automatically distributed by the contract and may draw more liquidity providers.";

const pools: PoolModel[] = POOLS.pools;
const pools = POOLS.pools as PoolModel[];
const tokenBalances: TokenBalanceInfo[] = [];
const periods = [90, 180, 365];

Expand All @@ -34,7 +34,7 @@ const PoolAddIncentivizeContainer: React.FC = () => {
const [token, setToken] = useState<TokenModel | null>(null);
const tokenAmountInput = useTokenAmountInput(token);
const { updateTokenPrices } = useTokenData();

useEffect(() => {
setPool(pools[0]);
}, []);
Expand All @@ -54,7 +54,7 @@ const PoolAddIncentivizeContainer: React.FC = () => {
}, []);

useEffect(() => {
setPoolDetail(PoolDetailData.pool);
setPoolDetail(PoolDetailData.pool as PoolDetailModel);
}, []);

const selectPool = useCallback((poolId: string) => {
Expand All @@ -63,7 +63,7 @@ const PoolAddIncentivizeContainer: React.FC = () => {
setCurrentPool(pool);
}
}, [setCurrentPool]);

const selectToken = useCallback((path: string) => {
const token = tokenBalances.find(token => token.path === path);
if (token) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { useWallet } from "@hooks/wallet/use-wallet";
export const dummyDisclaimer =
"This feature enables you to provide incentives as staking rewards for a specific liquidity pool. Before you proceed, ensure that you understand the mechanics of external incentives and acknowledge that you cannot withdraw the rewards once you complete this step.<br /><br />The incentives you add will be automatically distributed by the contract and may draw more liquidity providers.";

const pools: PoolModel[] = POOLS.pools;
const pools: PoolModel[] = POOLS.pools as PoolModel[];
const tokenBalances: TokenBalanceInfo[] = [];
const periods = [90, 180, 365];

Expand All @@ -33,7 +33,7 @@ const PoolIncentivizeContainer: React.FC = () => {
const [token, setToken] = useState<TokenModel | null>(null);
const tokenAmountInput = useTokenAmountInput(token);
const { updateTokenPrices } = useTokenData();

useEffect(() => {
setDataModal(tokenAmountInput);
}, [tokenAmountInput.amount, token]);
Expand All @@ -50,7 +50,7 @@ const PoolIncentivizeContainer: React.FC = () => {
}, []);

useEffect(() => {
setPoolDetail(PoolDetailData.pool);
setPoolDetail(PoolDetailData.pool as PoolDetailModel);
}, []);

const selectPool = useCallback((poolId: string) => {
Expand All @@ -59,7 +59,7 @@ const PoolIncentivizeContainer: React.FC = () => {
setCurrentPool(pool);
}
}, [setCurrentPool]);

const selectToken = useCallback((path: string) => {
const token = tokenBalances.find(token => token.path === path);
if (token) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useCallback, useEffect, useMemo, useState } from "react";
import { type FeeOptions } from "@common/values/data-constant";
import { IncentivizedOptions, type FeeOptions } from "@common/values/data-constant";
import PoolList from "@components/earn/pool-list/PoolList";
import { type TokenPairInfo } from "@models/token/token-pair-info";
import { ValuesType } from "utility-types";
Expand Down Expand Up @@ -50,34 +50,6 @@ export const POOL_TYPE = {

export type POOL_TYPE = ValuesType<typeof POOL_TYPE>;

// const SORT_PARAMS: { [key in TABLE_HEAD]: string } = {
// "Pool Name": "name",
// Liquidity: "liquidity",
// "Volume (24h)": "volume",
// "Fees (24h)": "fees",
// APR: "apr",
// Rewards: "rewards",
// "Liquidity Plot": "liquidity_plot",
// };

// async function fetchPools(
// type: POOL_TYPE, // eslint-disable-line
// page: number, // eslint-disable-line
// keyword: string, // eslint-disable-line
// sortKey?: string, // eslint-disable-line
// direction?: string, // eslint-disable-line
// ): Promise<Pool[]> {
// return new Promise(resolve => setTimeout(resolve, 2000)).then(() =>
// Promise.resolve([
// ...dummyPoolList,
// ...dummyPoolList,
// ...dummyPoolList,
// ...dummyPoolList,
// ...dummyPoolList,
// ]),
// );
// }

const PoolListContainer: React.FC = () => {
const [poolType, setPoolType] = useState<POOL_TYPE>(POOL_TYPE.ALL);
const [page, setPage] = useState(0);
Expand All @@ -104,19 +76,29 @@ const PoolListContainer: React.FC = () => {
}, [isClickOutside, keyword]);

const sortedPoolListInfos = useMemo(() => {
return poolListInfos.filter(info => {
if (poolType !== "All") {
return info.incentiveType === poolType;
function filteredPoolType(poolType: POOL_TYPE, incentivizedType: IncentivizedOptions) {
switch (poolType) {
case "Incentivized":
return incentivizedType !== "INCENTIVIZED";
case "Non-Incentivized":
return incentivizedType === "NON_INCENTIVIZED";
default:
break;
}
return true;
}

return poolListInfos.filter(info => {
if (keyword !== "") {
return info.tokenA.name.toLowerCase().includes(keyword.toLowerCase()) ||
info.tokenB.name.toLowerCase().includes(keyword.toLowerCase()) ||
info.tokenA.symbol.toLowerCase().includes(keyword.toLowerCase()) ||
info.tokenB.symbol.toLowerCase().includes(keyword.toLowerCase());
}
return true;

return filteredPoolType(poolType, info.incentivizedType);
});
}, [keyword, poolListInfos, poolType, sortOption]);
}, [keyword, poolListInfos, poolType]);

const totalPage = useMemo(() => {
return Math.floor(sortedPoolListInfos.length / 20) + 1;
Expand Down Expand Up @@ -176,7 +158,7 @@ const PoolListContainer: React.FC = () => {
const disableItems = ["Rewards", "Liquidity Plot"];
return !disableItems.includes(head);
}, []);

return (
<PoolList
pools={sortedPoolListInfos}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const MOCK_DATA = {
"nftId": "0x7a8",
"pool": {
"name": "ETH-swETH",
"incentivizedType": "INCENTIVIZED",
"tokenA": {
"name": "Ether",
"address": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
Expand Down Expand Up @@ -99,7 +100,7 @@ const LIST_DATA: LPPositionModel[] = [1, 2, 3, 4].map((item) => {
...MOCK_DATA,
lpRewardId: (Number(MOCK_DATA.lpRewardId) + item).toString(),
position: item > 2 ? { ...MOCK_DATA.position, balance: 0 } : MOCK_DATA.position,
};
} as LPPositionModel;
});

const RemoveLiquidityContainer: React.FC = () => {
Expand Down
1 change: 1 addition & 0 deletions packages/web/src/repositories/pool/mock/pools.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"logoURI": "https://s2.coinmarketcap.com/static/img/coins/64x64/5994.png",
"priceId": "gno.land/r/foo"
},
"incentivizedType": "INCENTIVIZED",
"tvl": 1182782.0,
"tvlChange": 118278200.0,
"volume": 1182797.0,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PoolRPCResponse } from "./pool-info-response";
import { PoolRPCResponse } from "./pool-rpc-response";

export interface PoolListRPCResponse {
stat: {
Expand Down
25 changes: 12 additions & 13 deletions packages/web/src/utils/swap-utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,19 @@ describe("tick convert to price", () => {
expect(tickToPrice(tick)).toBe(1);
});

test("10000 to 1.6486800559310761", () => {
test("10000 to 1.6486800559311758", () => {
const tick = 10000;
expect(tickToPrice(tick)).toBe(1.6486800559310761);
expect(tickToPrice(tick)).toBe(1.6486800559311758);
});

test("10001 to 1.6487624878731255", () => {
test("10001 to 1.6487624878732252", () => {
const tick = 10001;
expect(tickToPrice(tick)).toBe(1.6487624878731255);
expect(tickToPrice(tick)).toBe(1.6487624878732252);
});

test("100000 to 148.37606292298494", () => {
test("100000 to 148.3760629230746", () => {
const tick = 100000;
console.log(tickToPrice(tick));
expect(tickToPrice(tick)).toBe(148.37606292298494);
expect(tickToPrice(tick)).toBe(148.3760629230746);
});
});

Expand All @@ -33,20 +32,20 @@ describe("tick convert to sqrtPriceX96", () => {
);
});

test("10000 to 1.6486800559310761", () => {
test("10000 to 1.6486800559311758", () => {
const tick = 10000;
expect(tickToPrice(tick)).toBe(1.6486800559310761);
expect(tickToPrice(tick)).toBe(1.6486800559311758);
});

test("10001 to 1.6487624878731255", () => {
test("10001 to 1.6487624878732252", () => {
const tick = 10001;
expect(tickToPrice(tick)).toBe(1.6487624878731255);
expect(tickToPrice(tick)).toBe(1.6487624878732252);
});

test("100000 to 148.37606292298494", () => {
test("100000 to 148.3760629230746", () => {
const tick = 100000;
console.log(tickToPrice(tick));
expect(tickToPrice(tick)).toBe(148.37606292298494);
expect(tickToPrice(tick)).toBe(148.3760629230746);
});

test("100000 to 148.3760629230746", () => {
Expand Down

0 comments on commit 568c206

Please sign in to comment.