State.init({ activePair: defaultPair, }); const sender = Ethers.send("eth_requestAccounts", [])[0]; const { chainId } = Ethers.getNetwork(); const chainIdToSwitch = "0x44D"; const switchChain = () => { const zkevmChain = { chainId: "0x44D", // The chain ID for Aurora (1313161554 in hexadecimal) chainName: "Polygon zkEVM", // The name of the Aurora chain nativeCurrency: { name: "Ethereum", symbol: "ETH", decimals: 18, }, rpcUrls: ["https://zkevm-rpc.com"], // The RPC endpoint for the Aurora chain blockExplorerUrls: ["https://zkevm.polygonscan.com"], // The block explorer URL for Aurora }; Ethers.send("wallet_addEthereumChain", [zkevmChain]); }; if (chainId !== 1101) { return ( <div style={{ margin: "auto", textAlign: "center" }}> <h2>Please switch to Polygon zkEVM</h2> <br /> <button onClick={switchChain}>Switch to Polygon zkEVM</button> <br /> <br /> <p>**Please refresh once after switch chain**</p> </div> ); } const fetchPoolsData = () => { asyncFetch( "https://wire2.gamma.xyz/quickswap/polygon-zkevm/hypervisors/allData" ).then((res) => { if (!res.ok) return; State.update({ poolsData: res.body, }); }); }; const fetchUserData = () => { asyncFetch( `https://wire2.gamma.xyz/quickswap/polygon-zkevm/user/${sender}` ).then((res) => { if (!res.ok) return; State.update({ userPositions: res.body[sender], }); }); }; if (state.poolsData === undefined) { fetchPoolsData(); } if (sender && state.userPositions === undefined) { fetchUserData(); } const refetch = () => { fetchPoolsData(); fetchUserData(); console.log("refetching"); }; const defaultPair = { id: "N WETH-USDC", token0: "WETH", token1: "USDC", decimals0: 18, decimals1: 6, }; const Wrapper = styled.div` display:flex; align-items: start; gap: 24px; `; if (!sender) return <Web3Connect connectLabel="Connect with Web3" />; const handlePairClick = (pair) => { State.update({ activePair: pair, }); }; const { activePair, poolsData, userPositions } = state; return ( <Wrapper> <Widget src="james-cordova423.near/widget/gamma-zkevm-table" props={{ handlePairClick, poolsData, userPositions }} /> <Widget src="james-cordova423.near/widget/gamma-zkevm-vault" props={{ pair: activePair, refetch }} /> </Wrapper> );