Skip to content

Commit

Permalink
Merge branch 'beanstalk3-codehawks-remediations' into bs-3-pizza-reme…
Browse files Browse the repository at this point in the history
…diations
  • Loading branch information
pizzaman1337 committed Aug 7, 2024
2 parents 49d3769 + f76f05a commit f922dca
Show file tree
Hide file tree
Showing 105 changed files with 3,051 additions and 4,620 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/ci.protocol.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: "18"
- run: yarn add prettier
- run: yarn add prettier
- run: yarn add prettier-plugin-solidity
# - run: shopt -s globstar; yarn dlx -p prettier prettier --write --config .prettierrc --plugin=prettier-plugin-solidity protocol/**/*.sol || true
- run: shopt -s globstar; yarn prettier --write --config .prettierrc --plugin=prettier-plugin-solidity protocol/**/*.sol || true
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
Expand Down
6 changes: 0 additions & 6 deletions PROPOSALS.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,10 @@ You can read more about BIPs [here](https://docs.bean.money/almanac/governance/p
* [BIP-41](https://bean.money/bip-41): Immunefi Program Update
* [BIP-42](https://bean.money/bip-42): Seed Gauge System
* [BIP-43](https://bean.money/bip-43): Hypernative
<<<<<<< HEAD
=======
* [BIP-44](https://bean.money/bip-44): Seed Gauge System
* [BIP-45](https://bean.money/bip-45): Seed Gauge System
* [BIP-46](https://bean.money/bip-46): Hypernative
* [BIP-47](https://bean.money/bip-47): Adjust Quorum
>>>>>>> master

## Emergency Beanstalk Improvement Proposal (EBIP)

Expand All @@ -81,11 +78,8 @@ You can read about the BCM's Emergency Response Procedures [here](https://docs.b
* [EBIP-12](https://bean.money/ebip-12): Remove Convert
* [EBIP-13](https://bean.money/ebip-13): Re-Add Convert
* [EBIP-14](https://bean.money/ebip-14): Remove Vesting Period
<<<<<<< HEAD
=======
* [EBIP-15](https://bean.money/ebip-15): Seed Gauge System Fixes
* [EBIP-16](https://bean.money/ebip-16): Fix Germinating Earned Bean Deposits
>>>>>>> master

## Beanstalk Operations Proposal (BOP)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"jest": "29.2.2",
"jest-serial-runner": "1.2.1",
"lint-staged": "13.3.0",
"prettier": "3.2.5",
"prettier": "3.3.3",
"ts-jest": "29.1.2",
"ts-node": "10.9.2",
"typescript": "5.3.3"
Expand Down
3 changes: 3 additions & 0 deletions projects/dex-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@
},
"dependencies": {
"@beanstalk/sdk": "workspace:*",
"@radix-ui/react-dialog": "1.0.5",
"@radix-ui/react-dropdown-menu": "2.1.1",
"@tanstack/react-query": "5.28.4",
"@tanstack/react-query-devtools": "5.28.4",
"@typechain/ethers-v5": "10.2.1",
"alchemy-sdk": "3.3.1",
"connectkit": "1.7.2",
"ethers": "^5.7.2",
"graphql-request": "5.2.0",
Expand Down
6 changes: 3 additions & 3 deletions projects/dex-ui/src/components/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ const Dropdown = ({ open, children, trigger, offset, setOpen }: DropdownProps) =
<TriggerContainer ref={ref}>
<DropdownMenu.Trigger
asChild
onMouseDown={(e) => e.preventDefault()}
onClick={(e) => e.preventDefault()}
onMouseDown={(e: any) => e.preventDefault()}
onClick={(e: any) => e.preventDefault()}
>
{trigger}
</DropdownMenu.Trigger>
Expand All @@ -31,7 +31,7 @@ const Dropdown = ({ open, children, trigger, offset, setOpen }: DropdownProps) =
<StyledContent
$width={dimensions.width}
sideOffset={offset}
onFocus={(e) => e.preventDefault()}
onFocus={(e: any) => e.preventDefault()}
>
<>{children}</>
</StyledContent>
Expand Down
10 changes: 0 additions & 10 deletions projects/dex-ui/src/components/Frame/Frame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ import swapIcon from "src/assets/images/navbar/swap.svg";
import wellsIcon from "src/assets/images/navbar/wells.svg";
import { LinksNav } from "../Typography";
import { BurgerMenuIcon, Discord, Github, Logo, Twitter, X, BeanstalkLogoBlack } from "../Icons";
<<<<<<< HEAD
import { size } from "src/breakpoints";
import { useAccount } from "wagmi";
import { Title } from "../PageComponents/Title";
=======
>>>>>>> master
import { TokenMarquee } from "./TokenMarquee";
import { WalletButton } from "src/components/Wallet";
import { theme } from "src/utils/ui/theme";
Expand All @@ -25,11 +19,7 @@ import { useChainId } from "wagmi";
export const Frame: FC<{}> = ({ children }) => {
const isNotProd = !Settings.PRODUCTION;
const [mobileMenuOpen, setMobileMenuOpen] = useState(false);
<<<<<<< HEAD
const { chain } = useAccount();
=======
const chain = useChainId();
>>>>>>> master

return (
<Container id="frame">
Expand Down
8 changes: 0 additions & 8 deletions projects/dex-ui/src/components/Liquidity/AddLiquidity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,16 +211,8 @@ const AddLiquidityContent = ({
const { data: quote } = useQuery({
queryKey: ["wells", "quote", "addliquidity", address, amounts, allTokensHaveMinAllowance],

<<<<<<< HEAD
const { data: quote } = useQuery({
queryKey: ["wells", "quote", "addliquidity", address, amounts, allTokensHaveMinAllowance],

queryFn: async () => {
if (!atLeastOneAmountNonZero) {
=======
queryFn: async () => {
if ((someWellReservesEmpty && areSomeInputsZero) || !atLeastOneAmountNonZero) {
>>>>>>> master
setShowQuoteDetails(false);
return null;
}
Expand Down
7 changes: 0 additions & 7 deletions projects/dex-ui/src/components/Well/Table/WellDetailRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,7 @@ export const WellDetailRow: FC<{
<Amount>${liquidity ? liquidity.toHuman("short") : "-.--"}</Amount>
</DesktopContainer>
<DesktopContainer align="right">
<<<<<<< HEAD
<Amount>${price ? price.toHuman("short") : "-.--"}</Amount>
=======
<Amount>${price && price.gt(0) ? price.toHuman("short") : "-.--"}</Amount>
>>>>>>> master
</DesktopContainer>
<DesktopContainer align="right">
<Amount>${volume ? volume.toHuman("short") : "-.--"}</Amount>
Expand Down Expand Up @@ -168,16 +164,13 @@ const DesktopContainer = styled(Td)`
display: none;
}
}
<<<<<<< HEAD
=======
:nth-child(3) {
@media (max-width: ${size.tablet}) {
display: none;
}
}
>>>>>>> master
@media (max-width: ${size.mobile}) {
display: none;
}
Expand Down
4 changes: 0 additions & 4 deletions projects/dex-ui/src/pages/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,11 @@ export const Home = () => {
used by the BEAN:WETH Well.
</div>
</MevInfo>
<<<<<<< HEAD
<GetStartedContainer href={links.multiFlowPump} target="_blank" rel="noopener noreferrer">
=======
<GetStartedContainer
href={links.multiFlowPump}
target="_blank"
rel="noopener noreferrer"
>
>>>>>>> master
<GetStarted>Read the whitepaper →</GetStarted>
</GetStartedContainer>
</MevBannerBG>
Expand Down
84 changes: 0 additions & 84 deletions projects/dex-ui/src/pages/Wells.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,6 @@ import {
import { useBeanstalkSiloAPYs } from "src/wells/useBeanstalkSiloAPYs";
import { useLagLoading } from "src/utils/ui/useLagLoading";
import useBasinStats from "src/wells/useBasinStats";
<<<<<<< HEAD

export const Wells = () => {
const { data: wells, isLoading, error } = useWells();
const { data: wellStats } = useBasinStats();
const sdk = useSdk();

const [wellLiquidity, setWellLiquidity] = useState<(TokenValue | undefined)[]>([]);
const [wellFunctionNames, setWellFunctionNames] = useState<string[]>([]);
const [wellTokenPrices, setWellTokenPrices] = useState<(TokenValue | null)[][]>([]);
=======
import { useTokenPrices } from "src/utils/price/useTokenPrices";
import { useWellFunctionNames } from "src/wells/wellFunction/useWellFunctionNames";
import { BasinAPIResponse } from "src/types";
Expand All @@ -44,47 +33,11 @@ export const Wells = () => {
const { data: wellStats = [] } = useBasinStats();
const sdk = useSdk();

>>>>>>> master
const [tab, showTab] = useState<number>(0);

const { data: lpTokenPrices, isLoading: lpTokenPricesLoading } = useWellLPTokenPrice(wells);
const { hasPositions, getPositionWithWell, isLoading: positionsLoading } = useLPPositionSummary();
const { isLoading: apysLoading } = useBeanstalkSiloAPYs();
<<<<<<< HEAD
// const [isLoadingWellData, setIsLoadingWellData] = useState<boolean>(true);

useMemo(() => {
const run = async () => {
if (!wells || !wells.length) return;
let _wellsLiquidityUSD = [];
let _wellsTokenPrices = [];
for (let i = 0; i < wells.length; i++) {
if (!wells[i].tokens) return;
const _tokenPrices = await Promise.all(wells[i].tokens!.map((token) => getPrice(token, sdk)));
_wellsTokenPrices[i] = _tokenPrices;
const _reserveValues = wells[i].reserves?.map((tokenReserve, index) =>
tokenReserve.mul((_tokenPrices[index] as TokenValue) || TokenValue.ZERO)
);
let initialValue = TokenValue.ZERO;
const _totalWellLiquidity = _reserveValues?.reduce((accumulator, currentValue) => currentValue.add(accumulator), initialValue);
_wellsLiquidityUSD[i] = _totalWellLiquidity;
}
setWellLiquidity(_wellsLiquidityUSD);
setWellTokenPrices(_wellsTokenPrices);

let _wellsFunctionNames = [];
for (let i = 0; i < wells.length; i++) {
if (!wells[i].wellFunction) return;
const _wellName = await wells[i].wellFunction!.contract.name();
_wellsFunctionNames[i] = _wellName;
}
setWellFunctionNames(_wellsFunctionNames);
// setIsLoadingWellData(false);
};

run();
}, [sdk, wells]);
=======
const { data: tokenPrices, isLoading: tokenPricesLoading } = useTokenPrices(wells);
const { data: wellFnNames, isLoading: wellNamesLoading } = useWellFunctionNames(wells);

Expand All @@ -101,9 +54,6 @@ export const Wells = () => {
tokenPricesLoading ||
wellNamesLoading
);
>>>>>>> master

const loading = useLagLoading(isLoading || apysLoading || positionsLoading);

if (error) {
return <Error message={error?.message} errorOnly />;
Expand Down Expand Up @@ -174,25 +124,6 @@ export const Wells = () => {
</NoLPRowMobile>
</>
) : (
<<<<<<< HEAD
wells?.map((well, index) => {
let price = undefined;
let volume = undefined;
if (wellStats && well.tokens && wellTokenPrices[index]) {
price = well.tokens[1].fromHuman(wellStats[index].last_price).mul(wellTokenPrices[index][1] as TokenValue);
volume = well.tokens[1].fromHuman(wellStats[index].target_volume).mul(wellTokenPrices[index][1] as TokenValue);
};
return tab === 0 ? (
<WellDetailRow
well={well}
liquidity={wellLiquidity?.[index]}
functionName={wellFunctionNames?.[index]}
price={price}
volume={volume}
key={`well-detail-row-${well.address}-${index}`}
/>
) : (
=======
tableData?.map(({ well, baseTokenPrice, liquidityUSD, targetVolume }, index) => {
if (tab === 0) {
const priceFnName =
Expand All @@ -211,7 +142,6 @@ export const Wells = () => {
}

return (
>>>>>>> master
<MyWellPositionRow
well={well}
position={getPositionWithWell(well)}
Expand Down Expand Up @@ -357,16 +287,6 @@ const MobileHeader = styled(Th)`

const DesktopHeader = styled(Th)`
:nth-child(1) {
<<<<<<< HEAD
width: 12em
}
:nth-child(2) {
width: 12em
}
:nth-child(3) {
width: 12em
}
=======
width: 10em;
}
:nth-child(2) {
Expand All @@ -376,7 +296,6 @@ const DesktopHeader = styled(Th)`
width: 12em;
}
>>>>>>> master
:nth-child(5) {
@media (max-width: ${size.desktop}) {
display: none;
Expand All @@ -387,15 +306,12 @@ const DesktopHeader = styled(Th)`
display: none;
}
}
<<<<<<< HEAD
=======
:nth-child(3) {
@media (max-width: ${size.tablet}) {
display: none;
}
}
>>>>>>> master
@media (max-width: ${size.mobile}) {
display: none;
}
Expand Down
4 changes: 0 additions & 4 deletions projects/dex-ui/src/settings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ export type DexSettings = {
NETLIFY_BUILD_ID?: string;
};

<<<<<<< HEAD
const temp = netlifyContext === "production" || "deploy-preview" ? ProdSettings : DevSettings;
=======
const temp = netlifyContext === "production" || netlifyContext === "deploy-preview" ? ProdSettings : DevSettings;
>>>>>>> master

export const Settings = {
...temp,
Expand Down
31 changes: 0 additions & 31 deletions projects/dex-ui/src/tokens/useAllTokenBalance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@ import { useAccount } from "wagmi";
import { useTokens } from "./TokenProvider";
import { Log } from "src/utils/logger";
import { config } from "src/utils/wagmi/config";
<<<<<<< HEAD
=======
import { ContractFunctionParameters } from "viem";
import { queryKeys } from "src/utils/query/queryKeys";
>>>>>>> master

const TokenBalanceABI = [
{
Expand Down Expand Up @@ -61,16 +58,6 @@ export const useAllTokensBalance = () => {
}, [address, tokensToLoad.map((t) => t.symbol).join()]);

const { data, isLoading, error, refetch, isFetching } = useQuery({
<<<<<<< HEAD
queryKey: ["token", "balance"],

queryFn: async () => {
if (!address) return {};
const res = (await multicall(config, {
contracts: calls,
allowFailure: false
})) as unknown as BigNumber[];
=======
queryKey: queryKeys.tokenBalancesAll,
queryFn: async () => {
if (!address) return {};
Expand All @@ -85,7 +72,6 @@ export const useAllTokensBalance = () => {
]);

const res = results.flat();
>>>>>>> master
const balances: Record<string, TokenValue> = {};

if (ethBalance) {
Expand All @@ -100,31 +86,14 @@ export const useAllTokensBalance = () => {
balances[token.symbol] = token.fromBlockchain(value);

// set the balance in the query cache too
<<<<<<< HEAD
queryClient.setQueryData(["token", "balance", token.symbol], { [token.symbol]: balances[token.symbol] });

}

const ETH = tokens.ETH;
if (ETH) {
const ethBalance = await ETH.getBalance(address);
Log.module("app").debug(`ETH balance: `, ethBalance.toHuman());
queryClient.setQueryData(["token", "balance", "ETH"], { ETH: ethBalance });
balances.ETH = ethBalance;
=======
queryClient.setQueryData(queryKeys.tokenBalance(token.symbol), {
[token.symbol]: balances[token.symbol]
});
>>>>>>> master
}

return balances;
},
<<<<<<< HEAD

=======
enabled: !!address && !!tokensToLoad.length,
>>>>>>> master
staleTime: 1000 * 30,
refetchInterval: 1000 * 30
});
Expand Down
Loading

0 comments on commit f922dca

Please sign in to comment.