Skip to content

Commit

Permalink
Merge branch 'master' into bean-ui-stacked-liq-chart
Browse files Browse the repository at this point in the history
  • Loading branch information
uncoolzero authored Dec 15, 2023
2 parents 5ed3088 + b79b4f1 commit 4647479
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 29 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

[![Discord][discord-badge]][discord-url]

Code Version: `2.6.0` <br>
Whitepaper Version: `2.6.0`
Code Version: `2.7.3` <br>
Whitepaper Version: `2.7.0`

## About

Expand Down
Binary file modified beanstalk.pdf
Binary file not shown.
20 changes: 20 additions & 0 deletions projects/dex-ui/src/components/ActionWalletButtonWrapper.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from "react";
import { ConnectKitButton } from "connectkit";
import { Button } from "src/components/Swap/Button";
import { useAccount } from "wagmi";

type ActionWalletButtonProps = { children: JSX.Element };

export const ActionWalletButtonWrapper = ({ children }: ActionWalletButtonProps) => {
const { address } = useAccount();

return !address ? (
<ConnectKitButton.Custom>
{({ show }) => {
return <Button onClick={show} label="Connect Wallet" />;
}}
</ConnectKitButton.Custom>
) : (
children
);
};
15 changes: 9 additions & 6 deletions projects/dex-ui/src/components/Liquidity/AddLiquidity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { useWellReserves } from "src/wells/useWellReserves";
import { Checkbox } from "../Checkbox";
import { size } from "src/breakpoints";
import { LoadingTemplate } from "src/components/LoadingTemplate";
import { ActionWalletButtonWrapper } from "src/components/ActionWalletButtonWrapper";

type BaseAddLiquidityProps = {
slippage: number;
Expand Down Expand Up @@ -403,12 +404,14 @@ const AddLiquidityContent = ({ well, slippage, slippageSettingsClickHandler, han
return null;
})}
<ButtonWrapper>
<AddLiquidityButton
disabled={!addLiquidityButtonEnabled}
loading={false}
label={`${buttonLabel} →`}
onClick={addLiquidityButtonClickHandler}
/>
<ActionWalletButtonWrapper>
<AddLiquidityButton
disabled={!addLiquidityButtonEnabled}
loading={false}
label={`${buttonLabel} →`}
onClick={addLiquidityButtonClickHandler}
/>
</ActionWalletButtonWrapper>
</ButtonWrapper>
</MediumGapContainer>
</LargeGapContainer>
Expand Down
16 changes: 9 additions & 7 deletions projects/dex-ui/src/components/Liquidity/RemoveLiquidity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { size } from "src/breakpoints";
import { displayTokenSymbol } from "src/utils/format";
import { LoadingTemplate } from "../LoadingTemplate";
import { useLPPositionSummary } from "src/tokens/useLPPositionSummary";
import { ActionWalletButtonWrapper } from "../ActionWalletButtonWrapper";

type BaseRemoveLiquidityProps = {
slippage: number;
Expand Down Expand Up @@ -416,14 +417,15 @@ const RemoveLiquidityContent = ({ well, slippage, slippageSettingsClickHandler,
/>
</ButtonWrapper>
)}

<ButtonWrapper>
<Button
disabled={!removeLiquidityButtonEnabled}
label={buttonLabel}
onClick={removeLiquidityButtonClickHandler}
loading={false}
/>
<ActionWalletButtonWrapper>
<Button
disabled={!removeLiquidityButtonEnabled}
label={buttonLabel}
onClick={removeLiquidityButtonClickHandler}
loading={false}
/>
</ActionWalletButtonWrapper>
</ButtonWrapper>
</LargeGapContainer>
)}
Expand Down
10 changes: 6 additions & 4 deletions projects/dex-ui/src/components/Swap/SwapRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ import { useAllTokensBalance } from "src/tokens/useAllTokenBalance";
import { useSwapBuilder } from "./useSwapBuilder";
import { useAccount } from "wagmi";
import { Quote, QuoteResult } from "@beanstalk/sdk/Wells";
import { Button } from "./Button";
import { Log } from "src/utils/logger";
import { useSearchParams } from "react-router-dom";
import { TransactionToast } from "../TxnToast/TransactionToast";
import QuoteDetails from "../Liquidity/QuoteDetails";
import { getPrice } from "src/utils/price/usePrice";
import useSdk from "src/utils/sdk/useSdk";
import { size } from "src/breakpoints";
import { ActionWalletButtonWrapper } from "src/components/ActionWalletButtonWrapper";
import { Button } from "./Button";

const NULL_ADDRESS = "0x0000000000000000000000000000000000000000";

Expand Down Expand Up @@ -320,15 +321,14 @@ export const SwapRoot = () => {
};

const getLabel = useCallback(() => {
if (!account) return "Connect Wallet";
if (!inAmount && !outAmount) return "Enter Amount";
if (inToken.address === outToken.address) return "Select different output token";
if (inAmount?.eq(TokenValue.ZERO) && outAmount?.eq(TokenValue.ZERO)) return "Enter Amount";
if (!hasEnoughBalance) return "Insufficient Balance";
if (needsApproval) return "Approve";

return "Swap";
}, [account, hasEnoughBalance, inAmount, needsApproval, outAmount, inToken, outToken]);
}, [hasEnoughBalance, inAmount, needsApproval, outAmount, inToken, outToken]);

if (Object.keys(tokens).length === 0)
return <Container>There are no tokens. Please check you are connected to the right network.</Container>;
Expand Down Expand Up @@ -375,7 +375,9 @@ export const SwapRoot = () => {
tokenPrices={prices}
/>
<SwapButtonContainer data-trace="true">
<Button label={getLabel()} disabled={!buttonEnabled} onClick={handleButtonClick} loading={txLoading} />
<ActionWalletButtonWrapper>
<Button label={getLabel()} disabled={!buttonEnabled} onClick={handleButtonClick} loading={txLoading} />
</ActionWalletButtonWrapper>
</SwapButtonContainer>
</Container>
);
Expand Down
6 changes: 5 additions & 1 deletion projects/dex-ui/src/pages/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ const InfoContainer = styled.div`
gap: 8px;
box-sizing: border-box;
height: 100%;
${mediaQuery.sm.up} {
padding-top: min(25%, 185px);
justify-content: flex-start
Expand Down Expand Up @@ -292,6 +292,10 @@ const AccordionContainer = styled.div`
gap: 24px;
width: 100%;
${mediaQuery.sm.up} {
padding-bottom: 150px;
}
/// Tablet
${mediaQuery.md.only} {
width: 100%;
Expand Down
20 changes: 13 additions & 7 deletions projects/subgraph-bean/src/utils/Bean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,16 +159,22 @@ export function getBeanTokenAddress(blockNumber: BigInt): string {
export function updateBeanSupplyPegPercent(blockNumber: BigInt): void {
if (blockNumber < BigInt.fromString("15278082")) {
let bean = loadBean(BEAN_ERC20_V1.toHexString());
let lpSupply = ZERO_BD;

let pool = loadOrCreatePool(BEAN_WETH_V1.toHexString(), blockNumber);

let lpSupply = toDecimal(pool.reserves[1]);
let pool = Pool.load(BEAN_WETH_V1.toHexString());
if (pool != null) {
lpSupply = lpSupply.plus(toDecimal(pool.reserves[1]));
}

pool = loadOrCreatePool(BEAN_3CRV_V1.toHexString(), blockNumber);
lpSupply = lpSupply.plus(toDecimal(pool.reserves[0]));
pool = Pool.load(BEAN_3CRV_V1.toHexString());
if (pool != null) {
lpSupply = lpSupply.plus(toDecimal(pool.reserves[0]));
}

pool = loadOrCreatePool(BEAN_LUSD_V1.toHexString(), blockNumber);
lpSupply = lpSupply.plus(toDecimal(pool.reserves[0]));
pool = Pool.load(BEAN_LUSD_V1.toHexString());
if (pool != null) {
lpSupply = lpSupply.plus(toDecimal(pool.reserves[0]));
}

bean.supplyInPegLP = lpSupply.div(toDecimal(bean.supply));
bean.save();
Expand Down
4 changes: 2 additions & 2 deletions projects/subgraph-bean/src/utils/Cross.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ export function checkPoolCross(pool: string, timestamp: BigInt, blockNumber: Big
let poolInfo = loadOrCreatePool(pool, blockNumber);
let token = poolInfo.bean;
let bean = loadBean(token);
let poolHourly = loadOrCreatePoolHourlySnapshot(token, timestamp, BigInt.fromI32(bean.lastSeason));
let poolDaily = loadOrCreatePoolDailySnapshot(token, timestamp, blockNumber);
let poolHourly = loadOrCreatePoolHourlySnapshot(pool, timestamp, BigInt.fromI32(bean.lastSeason));
let poolDaily = loadOrCreatePoolDailySnapshot(pool, timestamp, blockNumber);

if (oldPrice >= ONE_BD && newPrice < ONE_BD) {
let cross = loadOrCreatePoolCross(poolInfo.crosses, pool, timestamp);
Expand Down

0 comments on commit 4647479

Please sign in to comment.