State.init({ activePair: defaultPair, }); const sender = Ethers.send("eth_requestAccounts", [])[0]; 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(); }; 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> );