diff --git a/.vscode/settings.json b/.vscode/settings.json index a1720b45..c64bbfa1 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,54 +1,54 @@ { "typescript.tsdk": "node_modules/typescript/lib", "files.exclude": { - "renovate.json": true, - "tsconfig.json": true, - "vercel.json": true, - "postcss.config.js": true, - "next-env.d.ts": true, - "CHANGELOG.md": true, - ".releaserc.json": true, - ".next": true, - ".github": true, - "node_modules": true, - ".eslintrc.json": true, - "package.json": true, - ".gitignore": true, - "next.config.mjs": true, - ".env.local": true, - ".env.local.template": true, - "README.md": true, - "LICENSE": true, - "hardhat.config.ts": true, - ".prettierrc.js": true, - "typechain-types": true, - "hardhat/artifacts": true, - "hardhat/cache": true, - ".graphclient": true, - ".graphclientrc.yml": true, - "wagmi.config.ts": true, - "tailwind.config.js": true, - "hardhat/abis": true, - "build": true, - "foundry.toml": true, - ".gitmodules": true, - "slither.config.json": true, - "slither.db.json": true, - "solc.json": true, - "contracts/foundry/cache": true, - "contracts/foundry/out": true, - "contracts/hardhat/artifacts": true, - "contracts/hardhat/cache": true, - "secrets.json": true, - ".env": true, - "report.md": true, - "postcss.config.cjs": true, - "hardhat.config.cts": true, - "bun.lockb": true, - ".prettierrc.cjs": true, - "env.mjs": true, - "docs/": true, - "scripts/": true + "renovate.json": false, + "tsconfig.json": false, + "vercel.json": false, + "postcss.config.js": false, + "next-env.d.ts": false, + "CHANGELOG.md": false, + ".releaserc.json": false, + ".next": false, + ".github": false, + "node_modules": false, + ".eslintrc.json": false, + "package.json": false, + ".gitignore": false, + "next.config.mjs": false, + ".env.local": false, + ".env.local.template": false, + "README.md": false, + "LICENSE": false, + "hardhat.config.ts": false, + ".prettierrc.js": false, + "typechain-types": false, + "hardhat/artifacts": false, + "hardhat/cache": false, + ".graphclient": false, + ".graphclientrc.yml": false, + "wagmi.config.ts": false, + "tailwind.config.js": false, + "hardhat/abis": false, + "build": false, + "foundry.toml": false, + ".gitmodules": false, + "slither.config.json": false, + "slither.db.json": false, + "solc.json": false, + "contracts/foundry/cache": false, + "contracts/foundry/out": false, + "contracts/hardhat/artifacts": false, + "contracts/hardhat/cache": false, + "secrets.json": false, + ".env": false, + "report.md": false, + "postcss.config.cjs": false, + "hardhat.config.cts": false, + "bun.lockb": false, + ".prettierrc.cjs": false, + "env.mjs": false, + "docs/": false, + "scripts/": false }, // Required because of a bug with pnpm and prettier plugins. // See: https://github.com/prettier-solidity/prettier-plugin-solidity#pnpm diff --git a/bun.lockb b/bun.lockb index fc53d003..bce1f961 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 6f489942..68771b45 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "@auth/prisma-adapter": "^1.0.11", "@graphprotocol/client-add-source-name": "2.0.0", "@graphprotocol/graph-cli": "^0.68.0", + "@graphql-mesh/transform-prefix": "^0.97.0", "@graphql-tools/utils": "9.2.1", "@prisma/client": "^5.7.0", "@radix-ui/react-alert-dialog": "^1.0.5", diff --git a/src/components/admin/ltokens/AdminLTokenWithdrawalRequests.tsx b/src/components/admin/ltokens/AdminLTokenWithdrawalRequests.tsx index 16b925bf..f4733e93 100644 --- a/src/components/admin/ltokens/AdminLTokenWithdrawalRequests.tsx +++ b/src/components/admin/ltokens/AdminLTokenWithdrawalRequests.tsx @@ -1,4 +1,12 @@ -import { Address, AllowanceTxButton, Amount, Card, Spinner, TxButton } from "@/components/ui"; +import { + Address, + AllowanceTxButton, + Amount, + Button, + Card, + Spinner, + TxButton, +} from "@/components/ui"; import { useContractAddress } from "@/hooks/useContractAddress"; import { FC, useEffect, useState } from "react"; import { AdminBrick } from "../AdminBrick"; @@ -22,6 +30,9 @@ import { useSimulateLTokenProcessBigQueuedRequest, useSimulateLTokenProcessQueuedRequests, useSimulateLTokenRepatriate, + useWriteLTokenProcessBigQueuedRequest, + writeGenericErc20Approve, + writeLTokenProcessBigQueuedRequest, } from "@/generated"; import clsx from "clsx"; import { UseSimulateContractReturnType, useBlockNumber } from "wagmi"; @@ -37,10 +48,15 @@ const ProcessBigRequestButton: FC = ({ lTokenAddress, requestId, }) => { - const preparation = useSimulateLTokenProcessBigQueuedRequest({ - address: lTokenAddress, - args: [requestId], - }); + console.log("rendered"); + // const preparation = useSimulateLTokenProcessBigQueuedRequest({ + // address: lTokenAddress, + // args: [requestId], + // }); + + // const { writeContract } = useWriteLTokenProcessBigQueuedRequest({ + // mutation: {}, + // }); const { data: underlyingAddress } = useReadLTokenUnderlying({ address: lTokenAddress }); const { data: requestData } = useReadLTokenWithdrawalQueue({ address: lTokenAddress, @@ -48,16 +64,40 @@ const ProcessBigRequestButton: FC = ({ }); return ( - - Process - +
+ + +
+ // + // Process + // ); }; @@ -84,13 +124,12 @@ export const AdminLTokenWithdrawalRequests: FC = ({ lTokenSymbol }) => { const columnHelper = createColumnHelper(); const [requestsData, setRequestsData] = useState([]); const [isLoading, setIsLoading] = useState(false); - const { data: queueCursor, queryKey: queueCursorQueryKey } = useReadLTokenWithdrawalQueueCursor({ + const { data: queueCursor } = useReadLTokenWithdrawalQueueCursor({ + address: lTokenAddress, + }); + const { data: expectedRetained } = useReadLTokenGetExpectedRetained({ address: lTokenAddress, }); - const { data: expectedRetained, queryKey: expectedRetainedQueryKey } = - useReadLTokenGetExpectedRetained({ - address: lTokenAddress, - }); const { data: usableUnderlyings } = useReadLTokenUsableUnderlyings({ address: lTokenAddress, }); @@ -106,29 +145,16 @@ export const AdminLTokenWithdrawalRequests: FC = ({ lTokenSymbol }) => { }); const { data: underlyingAddress } = useReadLTokenUnderlying({ address: lTokenAddress }); - // Refresh some data every 5 blocks - const queryKeys = [queueCursorQueryKey, expectedRetainedQueryKey]; - const { data: blockNumber } = useBlockNumber({ watch: true }); - const queryClient = useQueryClient(); - useEffect(() => { - if (blockNumber && blockNumber % 5n === 0n) - queryKeys.forEach((k) => queryClient.invalidateQueries({ queryKey: k })); - }, [blockNumber, ...queryKeys]); - - // const computeRequestsData = async () => { - setIsLoading(true); - + // setIsLoading(true); // If queue cursor is available if (typeof queueCursor === "bigint") { let endOfQueueEncountered = false; const newRequestsData: WithdrawalRequest[] = []; let readQueueCursor = queueCursor; - // Until we reach the end of the queue while (!endOfQueueEncountered) { const proms: Promise[] = []; - // Retrieve batch of 50 queued requests data for (let i = readQueueCursor; i < readQueueCursor + 50n; i++) { proms.push( @@ -139,20 +165,17 @@ export const AdminLTokenWithdrawalRequests: FC = ({ lTokenSymbol }) => { }), ); } - // Wait for all data requests to settle - const requestsData = await Promise.allSettled(proms); - + const _requestsData = await Promise.allSettled(proms); // Add requests data to the new data array for (let i = readQueueCursor; i < readQueueCursor + 50n; i++) { - const requestData = requestsData[Number(i - readQueueCursor)]; - if (requestData.status === "fulfilled") { - const [account, amount] = requestData.value; - + const _requestData = _requestsData[Number(i - readQueueCursor)]; + if (_requestData.status === "fulfilled") { + const [account, amount] = _requestData.value; // Skip already processed requests if (Number(account) == 0) continue; - // Else, add request data to the new data array + console.log(typeof expectedRetained); newRequestsData.push({ id: i, account: account, @@ -160,22 +183,18 @@ export const AdminLTokenWithdrawalRequests: FC = ({ lTokenSymbol }) => { isBig: amount > expectedRetained! / 2n, }); } - // If an error occurred, we reached the end of the queue else { endOfQueueEncountered = true; } } - // Increment queue cursor for next batch readQueueCursor += 50n; } - // Set new data setRequestsData(newRequestsData); } - - setIsLoading(false); + // setIsLoading(false); }; useEffect(() => { diff --git a/src/components/ui/AllowanceTxButton.tsx b/src/components/ui/AllowanceTxButton.tsx index 93cfe87e..aae4c942 100644 --- a/src/components/ui/AllowanceTxButton.tsx +++ b/src/components/ui/AllowanceTxButton.tsx @@ -81,13 +81,13 @@ export const AllowanceTxButton: FC = ({ }, [allowance]); // Refresh some data every 5 blocks - const queryKeys = [allowanceQueryKey, balanceQueryKey]; - const { data: blockNumber } = useBlockNumber({ watch: true }); - const queryClient = useQueryClient(); - useEffect(() => { - if (blockNumber && blockNumber % 5n === 0n) - queryKeys.forEach((k) => queryClient.invalidateQueries({ queryKey: k })); - }, [blockNumber, ...queryKeys]); + // const queryKeys = [allowanceQueryKey, balanceQueryKey]; + // const { data: blockNumber } = useBlockNumber({ watch: true }); + // const queryClient = useQueryClient(); + // useEffect(() => { + // if (blockNumber && blockNumber % 5n === 0n) + // queryKeys.forEach((k) => queryClient.invalidateQueries({ queryKey: k })); + // }, [blockNumber, ...queryKeys]); const hasEnoughAllowance = Boolean(allowance !== undefined && allowance >= amount); diff --git a/src/lib/dapp/config.ts b/src/lib/dapp/config.ts index d62fa7ef..2769cc10 100644 --- a/src/lib/dapp/config.ts +++ b/src/lib/dapp/config.ts @@ -1,7 +1,4 @@ -import { http } from "@wagmi/core"; import { chains } from "./chains"; -import { createClient } from "viem"; -// import { getDefaultConfig } from "@rainbow-me/rainbowkit"; import { env } from "../../../env.mjs"; import { wallets } from "./wallets"; import { getDefaultConfig } from "@rainbow-me/rainbowkit"; @@ -9,11 +6,7 @@ import { getDefaultConfig } from "@rainbow-me/rainbowkit"; export const config = getDefaultConfig({ appName: "Ledgity Yield", projectId: env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID, - ssr: true, + // ssr: true, chains, wallets, - // @ts-ignore - client({ chain }) { - return createClient({ chain, transport: http() }); - }, });