diff --git a/package-lock.json b/package-lock.json index 6a341f01d..2e1dced17 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,6 +21,7 @@ "@vercel/speed-insights": "^1.0.1", "alchemy-sdk": "^3.1.0", "axios": "^1.2.2", + "chart.js": "^4.4.1", "class-variance-authority": "^0.7.0", "clsx": "^2.1.0", "ethers": "^5.7.2", @@ -35,6 +36,7 @@ "next-themes": "^0.2.1", "rc-toastr": "^1.3.4", "react": "18.2.0", + "react-chartjs-2": "^5.2.0", "react-device-detect": "^2.2.3", "react-dom": "18.2.0", "react-router-dom": "^6.6.1", @@ -2610,6 +2612,11 @@ "@pedrouid/environment": "^1.0.1" } }, + "node_modules/@kurkle/color": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@kurkle/color/-/color-0.3.2.tgz", + "integrity": "sha512-fuscdXJ9G1qb7W8VdHi+IwRqij3lBkosAm4ydQtEmbY58OzHXqQhvlxqEkoz0yssNVn38bcpRWgA9PP+OGoisw==" + }, "node_modules/@ledgerhq/connect-kit-loader": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@ledgerhq/connect-kit-loader/-/connect-kit-loader-1.1.2.tgz", @@ -6098,6 +6105,17 @@ "node": ">=10" } }, + "node_modules/chart.js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/chart.js/-/chart.js-4.4.1.tgz", + "integrity": "sha512-C74QN1bxwV1v2PEujhmKjOZ7iUM4w6BWs23Md/6aOZZSlwMzeCIDGuZay++rBgChYru7/+QFeoQW0fQoP534Dg==", + "dependencies": { + "@kurkle/color": "^0.3.0" + }, + "engines": { + "pnpm": ">=7" + } + }, "node_modules/chokidar": { "version": "3.5.3", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", @@ -10920,6 +10938,15 @@ "node": ">=0.10.0" } }, + "node_modules/react-chartjs-2": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/react-chartjs-2/-/react-chartjs-2-5.2.0.tgz", + "integrity": "sha512-98iN5aguJyVSxp5U3CblRLH67J8gkfyGNbiK3c+l1QI/G4irHMPQw44aEPmjVag+YKTyQ260NcF82GTQ3bdscA==", + "peerDependencies": { + "chart.js": "^4.1.1", + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" + } + }, "node_modules/react-device-detect": { "version": "2.2.3", "resolved": "https://registry.npmjs.org/react-device-detect/-/react-device-detect-2.2.3.tgz", diff --git a/package.json b/package.json index ce2d54d0a..8f7609341 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "@vercel/speed-insights": "^1.0.1", "alchemy-sdk": "^3.1.0", "axios": "^1.2.2", + "chart.js": "^4.4.1", "class-variance-authority": "^0.7.0", "clsx": "^2.1.0", "ethers": "^5.7.2", @@ -36,6 +37,7 @@ "next-themes": "^0.2.1", "rc-toastr": "^1.3.4", "react": "18.2.0", + "react-chartjs-2": "^5.2.0", "react-device-detect": "^2.2.3", "react-dom": "18.2.0", "react-router-dom": "^6.6.1", diff --git a/src/components/Charts/TVLChart.tsx b/src/components/Charts/TVLChart.tsx new file mode 100644 index 000000000..3e52eac75 --- /dev/null +++ b/src/components/Charts/TVLChart.tsx @@ -0,0 +1,41 @@ +import React from 'react'; +import { Line } from 'react-chartjs-2'; +import 'chart.js/auto'; + +const TVLChart = () => { + const data = { + labels: ['January', 'February', 'March', 'April', 'May', 'June'], + datasets: [ + { + label: 'TVL', + data: [65, 59, 80, 81, 56, 80, 40], + fill: false, + backgroundColor: 'rgb(75, 192, 192)', + borderColor: '#227BED', + pointRadius: 0, + tension: 0.1, + }, + ], + }; + + const options = { + + scales: { + y: { + display: false, + }, + x: { + display: false, + }, + }, + plugins: { + legend: { + display: false, + }, + }, + }; + + return ; +}; + +export default TVLChart diff --git a/src/components/Modals/Range/Analytics.tsx b/src/components/Modals/Range/Analytics.tsx new file mode 100644 index 000000000..d1e028ead --- /dev/null +++ b/src/components/Modals/Range/Analytics.tsx @@ -0,0 +1,83 @@ +import { Transition, Dialog } from "@headlessui/react"; +import { Fragment, useEffect, useState } from "react"; +import { XMarkIcon } from "@heroicons/react/20/solid"; +import { LineChart } from "lucide-react"; +import TVLChart from "../../Charts/TVLChart"; + +export default function Analytics({ isOpen, setIsOpen }) { + return ( + + setIsOpen(false)} + > + +
+ + +
+
+ + +
+

+ + + + + + Analytics - (All Chains) +

+ setIsOpen(false)} + className="w-7 cursor-pointer" + /> +
+
+
+
+ TVL + $200.3k +
+ +
+
+
+ VOLUME + + $25k + +
+
+ FEES + + $2.5k + +
+
+
+
+
+
+
+
+
+ ); +} diff --git a/src/components/Modals/Range/PoolAnalytics.tsx b/src/components/Modals/Range/PoolAnalytics.tsx new file mode 100644 index 000000000..4f42b1a0a --- /dev/null +++ b/src/components/Modals/Range/PoolAnalytics.tsx @@ -0,0 +1,137 @@ +import { Transition, Dialog } from "@headlessui/react"; +import { Fragment, useEffect, useState } from "react"; +import { XMarkIcon } from "@heroicons/react/20/solid"; +import { LineChart } from "lucide-react"; +import TVLChart from "../../Charts/TVLChart"; +import { logoMapKey } from "../../../utils/tokens"; + +export default function PoolAnalytics({ + isOpen, + setIsOpen, + logoMap, + rangePoolData, + tokenIn, + tokenOut, +}) { + return ( + + setIsOpen(false)} + > + +
+ + +
+
+ + +
+

+ + + + + + + Analytics + +
+
+ + +
+ + {tokenIn.symbol} - {tokenOut.symbol} + + + {( + (!isNaN(rangePoolData.feeTier?.feeAmount) + ? rangePoolData.feeTier?.feeAmount + : 0) / 10000 + ).toFixed(2)} + % + +
+

+ setIsOpen(false)} + className="w-7 cursor-pointer" + /> +
+
+
+
+ TVL + $200.3k +
+ +
+
+
+ VOLUME + + $25k + +
+
+ FEES + + $2.5k + +
+
+
+
+
+
+
+
+
+ ); +} diff --git a/src/pages/range/add-liquidity.tsx b/src/pages/range/add-liquidity.tsx index d920cfd25..d500be5aa 100644 --- a/src/pages/range/add-liquidity.tsx +++ b/src/pages/range/add-liquidity.tsx @@ -44,6 +44,7 @@ import { } from "../../components/ui/tooltip"; import { Checkbox } from "../../components/ui/checkbox"; import { isAddress } from "ethers/lib/utils.js"; +import PoolAnalytics from "../../components/Modals/Range/PoolAnalytics"; import { ArrowTopRightOnSquareIcon, SparklesIcon, @@ -157,7 +158,8 @@ export default function AddLiquidity({}) { const [amountInSetLast, setAmountInSetLast] = useState(true); const [amountInDisabled, setAmountInDisabled] = useState(false); const [amountOutDisabled, setAmountOutDisabled] = useState(false); - const [isLoading, setIsLoading] = useState(true); + const [isLoading, setIsLoading] = useState(true) + const [isOpen, setIsOpen] = useState(false); ////////////////////////////////Pools @@ -822,7 +824,8 @@ export default function AddLiquidity({}) {

RANGE POOL

-
+
+
{isLoading ? (
) : ( @@ -831,7 +834,7 @@ export default function AddLiquidity({}) { target="_blank" rel="noreferrer" > -
+
)}
+ + +

ADD LIQUIDITY

diff --git a/src/pages/range/index.tsx b/src/pages/range/index.tsx index aad816a2a..96e3de84c 100644 --- a/src/pages/range/index.tsx +++ b/src/pages/range/index.tsx @@ -16,6 +16,7 @@ import { useConfigStore } from "../../hooks/useConfigStore"; import { chainProperties } from "../../utils/chains"; import { Checkbox } from "../../components/ui/checkbox"; import { isWhitelistedPool } from "../../utils/config"; +import Analytics from "../../components/Modals/Range/Analytics"; import { ChevronDownIcon, ChevronUpIcon } from "@heroicons/react/20/solid"; import { limitPoolTypeIds } from "../../utils/pools"; @@ -28,6 +29,7 @@ export default function Range() { const [isPositionsLoading, setIsPositionsLoading] = useState(false); const [isPoolsLoading, setIsPoolsLoading] = useState(false); const [lowTVLHidden, setLowTVLHidden] = useState(true); + const [isOpen, setIsOpen] = useState(false); const [sort, setSort] = useState("TVL"); const [poolType, setPoolType] = useState("Current"); @@ -236,6 +238,39 @@ export default function Range() { Read More + +
diff --git a/yarn.lock b/yarn.lock index ab7f33a36..0017f1b6f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1486,6 +1486,11 @@ "@json-rpc-tools/types" "^1.7.6" "@pedrouid/environment" "^1.0.1" +"@kurkle/color@^0.3.0": + version "0.3.2" + resolved "https://registry.npmjs.org/@kurkle/color/-/color-0.3.2.tgz" + integrity sha512-fuscdXJ9G1qb7W8VdHi+IwRqij3lBkosAm4ydQtEmbY58OzHXqQhvlxqEkoz0yssNVn38bcpRWgA9PP+OGoisw== + "@ledgerhq/connect-kit-loader@^1.0.1": version "1.1.2" resolved "https://registry.npmjs.org/@ledgerhq/connect-kit-loader/-/connect-kit-loader-1.1.2.tgz" @@ -3515,6 +3520,13 @@ char-regex@^1.0.2: resolved "https://registry.npmjs.org/char-regex/-/char-regex-1.0.2.tgz" integrity sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw== +chart.js@^4.1.1, chart.js@^4.4.1: + version "4.4.1" + resolved "https://registry.npmjs.org/chart.js/-/chart.js-4.4.1.tgz" + integrity sha512-C74QN1bxwV1v2PEujhmKjOZ7iUM4w6BWs23Md/6aOZZSlwMzeCIDGuZay++rBgChYru7/+QFeoQW0fQoP534Dg== + dependencies: + "@kurkle/color" "^0.3.0" + chokidar@^3.5.3: version "3.5.3" resolved "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz" @@ -6569,6 +6581,11 @@ rc-toastr@^1.3.4: resolved "https://registry.npmjs.org/rc-toastr/-/rc-toastr-1.3.4.tgz" integrity sha512-ZmNZ24jr4xP76+VdUymGrSMUWv66/j8OZjZoDElKZFDnsnoQABXEB3PRUULxtaB66igGO54N0FGdJxBqv+Za5w== +react-chartjs-2@^5.2.0: + version "5.2.0" + resolved "https://registry.npmjs.org/react-chartjs-2/-/react-chartjs-2-5.2.0.tgz" + integrity sha512-98iN5aguJyVSxp5U3CblRLH67J8gkfyGNbiK3c+l1QI/G4irHMPQw44aEPmjVag+YKTyQ260NcF82GTQ3bdscA== + react-device-detect@^2.2.3: version "2.2.3" resolved "https://registry.npmjs.org/react-device-detect/-/react-device-detect-2.2.3.tgz"