+
+ table.getColumn(searchID)?.setFilterValue(event.target.value)}
+ className="border border-border border-opacity-60 pl-12 h-12 max-w-80 md:w-64 lg:w-80 focus:border-opacity-100 rounded-xl"
+ />
+
+
+
+ -
+
+
+ -
+
+
+
+
+
+ {
+ const column = table.getColumn("plugins");
+ if (column?.getFilterValue() === undefined) column?.setFilterValue(true);
+ else column?.setFilterValue(undefined);
+ }}
+ />
+
+
+ )}
diff --git a/src/graphql/queries/farmings.ts b/src/graphql/queries/farmings.ts
index f9f7532..8beecf5 100644
--- a/src/graphql/queries/farmings.ts
+++ b/src/graphql/queries/farmings.ts
@@ -1,4 +1,4 @@
-import { gql } from '@apollo/client';
+import { gql } from "@apollo/client";
export const ETERNAL_FARMINGS = gql`
query EternalFarmings($pool: Bytes) {
@@ -31,3 +31,12 @@ export const DEPOSITS = gql`
}
}
`;
+
+export const ACTIVE_FARMINGS = gql`
+ query ActiveFarmings {
+ eternalFarmings(where: { isDeactivated: false }) {
+ pool
+ id
+ }
+ }
+`;
diff --git a/src/graphql/queries/pools.ts b/src/graphql/queries/pools.ts
index f9fd719..3d3c6d9 100644
--- a/src/graphql/queries/pools.ts
+++ b/src/graphql/queries/pools.ts
@@ -1,4 +1,4 @@
-import { gql } from '@apollo/client';
+import { gql } from "@apollo/client";
export const POOL_FRAGMENT = gql`
fragment PoolFields on Pool {
@@ -21,7 +21,7 @@ export const POOL_FRAGMENT = gql`
token0Price
token1Price
}
-`
+`;
export const TICK_FRAGMENT = gql`
fragment TickFields on Tick {
tickIdx
@@ -30,25 +30,31 @@ export const TICK_FRAGMENT = gql`
price0
price1
}
-`
+`;
export const POOL_FEE_DATA_FRAGMENT = gql`
- fragment PoolFeeDataFields on PoolFeeData {
- fee
- timestamp
+ fragment PoolFeeDataFields on PoolDayData {
+ feesUSD
}
-`
+`;
export const POOL_DAY_DATA_FRAGMENT = gql`
fragment PoolDayDataFields on PoolDayData {
feesUSD
+ tvlUSD
+ volumeUSD
+ id
+ date
}
-`
+`;
export const POOLS_LIST = gql`
query PoolsList {
pools {
...PoolFields
+ poolDayData(first: 1, orderBy: date, orderDirection: desc) {
+ ...PoolDayDataFields
+ }
}
}
`;
@@ -59,7 +65,7 @@ export const ALL_TICKS = gql`
...TickFields
}
}
-`
+`;
export const SINGLE_POOL = gql`
query SinglePool($poolId: ID!) {
@@ -67,7 +73,7 @@ export const SINGLE_POOL = gql`
...PoolFields
}
}
-`
+`;
export const MULTIPLE_POOLS = gql`
query MultiplePools($poolIds: [ID!]) {
@@ -75,24 +81,25 @@ export const MULTIPLE_POOLS = gql`
...PoolFields
}
}
-`
+`;
export const POOL_FEE_DATA = gql`
query PoolFeeData($poolId: String) {
poolDayDatas(where: { pool: $poolId }, orderBy: date, orderDirection: desc) {
- ...PoolDayDataFields
+ ...PoolFeeDataFields
}
}
-`
+`;
-export const POOLS_VOLUME_DATA = gql`
- query PoolsVolumeData {
- poolDayDatas(orderBy: date, orderDirection: desc) {
- date
- volumeUSD
- pool {
- id
- }
- }
- }
-`;
\ No newline at end of file
+// export const POOLS_DAY_DATAS = gql`
+// query PoolsVolumeData {
+// poolDayDatas(orderBy: date, orderDirection: desc) {
+// date
+// pool {
+// id
+// }
+// volumeUSD
+// ...PoolDayDataFields
+// }
+// }
+// `;
diff --git a/src/pages/Pool/index.tsx b/src/pages/Pool/index.tsx
index 4866693..f300ad2 100644
--- a/src/pages/Pool/index.tsx
+++ b/src/pages/Pool/index.tsx
@@ -18,6 +18,7 @@ import { usePositions } from '@/hooks/positions/usePositions';
import { FormattedPosition } from '@/types/formatted-position';
import { getPositionAPR } from '@/utils/positions/getPositionAPR';
import { getPositionFees } from '@/utils/positions/getPositionFees';
+import { formatAmount } from '@/utils/common/formatAmount';
import { Position, ZERO } from '@cryptoalgebra/integral-sdk';
import { useWeb3Modal } from '@web3modal/wagmi/react';
import { MoveRightIcon } from 'lucide-react';
@@ -169,7 +170,7 @@ const PoolPage = () => {
outOfRange:
poolEntity.tickCurrent < position.tickLower ||
poolEntity.tickCurrent > position.tickUpper,
- range: `${position.token0PriceLower.toFixed()} — ${position.token0PriceUpper.toFixed()}`,
+ range: `${formatAmount(position.token0PriceLower.toFixed(6), 6)} — ${formatAmount(position.token0PriceUpper.toFixed(6), 6)}`,
liquidityUSD: formatLiquidityUSD(position),
feesUSD: formatFeesUSD(idx),
apr: formatAPR(idx),
diff --git a/src/utils/common/formatAmount.ts b/src/utils/common/formatAmount.ts
new file mode 100644
index 0000000..f6726ec
--- /dev/null
+++ b/src/utils/common/formatAmount.ts
@@ -0,0 +1,39 @@
+import { formatCurrency } from "./formatCurrency";
+
+export function formatAmount(amount: string, decimals = 3): string {
+ const amountNum = Number(amount);
+ const minAmount = 1 / 10 ** (decimals || 3);
+
+ if (amountNum === 0) return "0";
+ if (amountNum < minAmount) return `< ${minAmount}`;
+ if (amountNum < 1) return (Math.floor(amountNum / minAmount) * minAmount).toFixed(decimals);
+ if (amountNum < 100) return (Math.floor(amountNum * 100) / 100).toString();
+ if (amountNum < 10000) return Math.floor(amountNum).toString();
+
+ if (amountNum < 1000000000000000) return formatCurrency.format(Math.floor(amountNum * 100) / 100);
+
+ return "∞";
+}
+
+export function reverseFormatAmount(formattedNumber: string): number {
+ const suffixes: { [key: string]: number } = {
+ K: 1e3,
+ M: 1e6,
+ B: 1e9,
+ T: 1e12,
+ };
+
+ const suffix = formattedNumber.slice(-1);
+ const value = parseFloat(formattedNumber.slice(0, -1));
+
+ if (formattedNumber.startsWith("< ") || formattedNumber.startsWith("> ")) {
+ const value = parseFloat(formattedNumber.slice(2));
+ return value > 0 ? value : 0;
+ }
+
+ if (suffixes[suffix]) {
+ return value * suffixes[suffix];
+ } else {
+ return parseFloat(formattedNumber);
+ }
+}
diff --git a/src/utils/positions/getPositionAPR.ts b/src/utils/positions/getPositionAPR.ts
index 3057c62..05b656a 100644
--- a/src/utils/positions/getPositionAPR.ts
+++ b/src/utils/positions/getPositionAPR.ts
@@ -1,13 +1,13 @@
import { getAlgebraPool } from "@/generated"
import { Position } from "@cryptoalgebra/integral-sdk"
-import { PoolDayDataFieldsFragment, PoolFieldsFragment } from "@/graphql/generated/graphql"
+import { PoolFeeDataFieldsFragment, PoolFieldsFragment } from "@/graphql/generated/graphql"
import { Address } from "wagmi"
export async function getPositionAPR(
poolId: Address,
position: Position,
pool: PoolFieldsFragment | undefined | null,
- poolFeeData: PoolDayDataFieldsFragment[] | undefined,
+ poolFeeData: PoolFeeDataFieldsFragment[] | undefined,
nativePrice: string | undefined
) {