Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove legacy farm #525

Merged
merged 4 commits into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion projects/ui/src/components/Barn/Actions/Buy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
ERC20Token,
NativeToken,
BeanstalkSDK,
FarmFromMode,
FarmToMode,
} from '@beanstalk/sdk';
import { useSelector } from 'react-redux';
Expand All @@ -33,7 +34,6 @@ import useFarmerBalances from '~/hooks/farmer/useFarmerBalances';
import usePreferredToken, {
PreferredToken,
} from '~/hooks/farmer/usePreferredToken';
import { FarmFromMode } from '~/lib/Beanstalk/Farm';
import {
displayFullBN,
getTokenIndex,
Expand Down
4 changes: 2 additions & 2 deletions projects/ui/src/components/Barn/Actions/Rinse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useCallback, useMemo } from 'react';
import { Box, Stack, Typography } from '@mui/material';
import BigNumber from 'bignumber.js';
import { Form, Formik, FormikHelpers, FormikProps } from 'formik';
import { Token, TokenValue } from '@beanstalk/sdk';
import { Token, TokenValue, FarmToMode } from '@beanstalk/sdk';
import {
FormTxnsFormState,
SmartSubmitButton,
Expand All @@ -15,7 +15,7 @@ import TxnAccordion from '~/components/Common/TxnAccordion';
import FarmModeField from '~/components/Common/Form/FarmModeField';
import TransactionToast from '~/components/Common/TxnToast';
import useFarmerFertilizer from '~/hooks/farmer/useFarmerFertilizer';
import { FarmToMode } from '~/lib/Beanstalk/Farm';

import { displayFullBN } from '~/util';
import { ZERO_BN } from '~/constants';
import { ActionType } from '~/util/Actions';
Expand Down
2 changes: 1 addition & 1 deletion projects/ui/src/components/Chop/Actions/Chop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import BigNumber from 'bignumber.js';
import { Form, Formik, FormikHelpers, FormikProps } from 'formik';
import React, { useCallback, useMemo } from 'react';
import { useSelector } from 'react-redux';
import { FarmToMode } from '@beanstalk/sdk';
import {
FormState,
SmartSubmitButton,
Expand All @@ -35,7 +36,6 @@ import useAccount from '~/hooks/ledger/useAccount';
import usePreferredToken, {
PreferredToken,
} from '~/hooks/farmer/usePreferredToken';
import { FarmToMode } from '~/lib/Beanstalk/Farm';
import { ActionType } from '~/util/Actions';
import {
displayBN,
Expand Down
2 changes: 1 addition & 1 deletion projects/ui/src/components/Common/Form/FarmModeField.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useMemo } from 'react';
import { Typography, TypographyProps } from '@mui/material';
import { FarmFromMode, FarmToMode } from '~/lib/Beanstalk/Farm';
import { FarmFromMode, FarmToMode } from '@beanstalk/sdk';
import copy from '~/constants/copy';
import AddressIcon from '../AddressIcon';
import PillSelectField, { PillSelectFieldProps } from './PillSelectField';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ const TokenQuoteProvider: FC<TokenQuoteProviderProps> = ({
);
setFieldValue(`${name}.amountOut`, result?.amountOut); // calculated amountOut
setFieldValue(`${name}.value`, result?.value); // ether value used
setFieldValue(`${name}.steps`, result?.steps); // steps
}, [name, setFieldValue, result]);
useEffect(() => {
console.debug(`[TokenQuoteProvider] update ${name}.quoting =>`, quoting);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ export default function TokenQuoteProviderWithParams<T>({
);
setFieldValue(`${name}.amountOut`, result?.amountOut); // calculated amountOut
setFieldValue(`${name}.value`, result?.value); // ether value used
setFieldValue(`${name}.steps`, result?.steps); // workflow
}, [name, setFieldValue, result]);
useEffect(() => {
console.debug(`[TokenQuoteProvider] update ${name}.quoting =>`, quoting);
Expand Down
2 changes: 1 addition & 1 deletion projects/ui/src/components/Common/Form/TxnPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useMemo, useState } from 'react';
import { Box, Stack, Typography } from '@mui/material';
import groupBy from 'lodash/groupBy';
import DoubleArrowIcon from '@mui/icons-material/DoubleArrow';
import { FarmFromMode, FarmToMode } from '@beanstalk/sdk';
import TokenIcon from '~/components/Common/TokenIcon';
import { FERTILIZER_ICONS } from '~/components/Barn/FertilizerImage';
import siloIcon from '~/img/beanstalk/silo-icon.svg';
Expand All @@ -19,7 +20,6 @@ import {
} from '~/util/Actions';
import { SupportedChainId } from '~/constants/chains';
import { BEAN, PODS, SEEDS, SPROUTS, STALK, USDC } from '~/constants/tokens';
import { FarmFromMode, FarmToMode } from '~/lib/Beanstalk/Farm';
import AddressIcon from '~/components/Common/AddressIcon';
import Row from '~/components/Common/Row';
import { FC } from '~/types';
Expand Down
9 changes: 1 addition & 8 deletions projects/ui/src/components/Common/Form/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import BigNumber from 'bignumber.js';
import {
FarmToMode,
ERC20Token as ERC20TokenNew,
NativeToken as NativeTokenNew,
} from '@beanstalk/sdk';
import { ERC20Token, NativeToken } from '~/classes/Token';
import { QuoteHandlerResult } from '~/hooks/ledger/useQuote';
import { FarmToMode } from '~/lib/Beanstalk/Farm';
import { BalanceFrom } from './BalanceFromRow';
import { QuoteHandlerResultNew } from '~/hooks/ledger/useQuoteWithParams';
import { FormTxnBundlerInterface } from '~/lib/Txn';
Expand Down Expand Up @@ -59,13 +59,6 @@ export type FormTokenStateNew = {
quoting?: boolean;
} & Partial<QuoteHandlerResultNew>;

// /** Some `amountOut` received for inputting `amount` of this token into a function. */
// amountOut?: BigNumber;
// /** Amount of ETH used in the transaction; applied to the `value` override. */
// value?: ethers.BigNumber;
// /** The steps needed to convert `amount` -> `amountOut`. */
// steps?: ChainableFunctionResult[];

export type FormApprovingState = {
/** */
contract: string;
Expand Down
2 changes: 1 addition & 1 deletion projects/ui/src/components/Farmer/Unripe/PickDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
} from '@mui/material';
import { useTheme } from '@mui/material/styles';
import { LoadingButton } from '@mui/lab';
import { FarmFromMode, FarmToMode } from '@beanstalk/sdk';
import unripeBeanIcon from '~/img/tokens/unripe-bean-logo-circled.svg';
import brownLPIcon from '~/img/tokens/unripe-lp-logo-circled.svg';
import { BeanstalkPalette } from '~/components/App/muiTheme';
Expand Down Expand Up @@ -39,7 +40,6 @@ import { ZERO_BN } from '~/constants';
import { displayFullBN, toTokenUnitsBN } from '~/util';
import { useBeanstalkContract } from '~/hooks/ledger/useContract';
import useGetChainToken from '~/hooks/chain/useGetChainToken';
import { FarmFromMode, FarmToMode } from '~/lib/Beanstalk/Farm';
import useAccount from '~/hooks/ledger/useAccount';
import { useFetchFarmerSilo } from '~/state/farmer/silo/updater';
import UnripeTokenRow from './UnripeTokenRow';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import BigNumber from 'bignumber.js';
import { Form, Formik, FormikHelpers, FormikProps } from 'formik';
import React, { useCallback, useMemo } from 'react';
import { useSelector } from 'react-redux';
import { useProvider } from 'wagmi';
import { ERC20Token, FarmFromMode, NativeToken, Token } from '@beanstalk/sdk';
import TransactionToast from '~/components/Common/TxnToast';
import TxnAccordion from '~/components/Common/TxnAccordion';
import { TokenSelectMode } from '~/components/Common/Form/TokenSelectDialog';
Expand All @@ -17,7 +17,6 @@ import {
TxnSeparator,
TxnSettings,
} from '~/components/Common/Form';
import { ERC20Token, FarmFromMode, NativeToken, Token } from '@beanstalk/sdk';
import useChainConstant from '~/hooks/chain/useChainConstant';
import useFarmerBalances from '~/hooks/farmer/useFarmerBalances';
import useTokenMap from '~/hooks/chain/useTokenMap';
Expand All @@ -28,13 +27,14 @@ import { useSigner } from '~/hooks/ledger/useSigner';
import { useFetchFarmerBalances } from '~/state/farmer/balances/updater';
import { useFetchFarmerMarket } from '~/state/farmer/market/updater';
import { ActionType } from '~/util/Actions';
import Farm from '~/lib/Beanstalk/Farm';
import { optimizeFromMode } from '~/util/Farm';
import {
displayFullBN,
toStringBaseUnitBN,
displayTokenAmount,
displayBN,
bnToTokenValue,
tokenValueToBN,
} from '~/util';
import { AppState } from '~/state';
import { BEAN, ETH, PODS } from '~/constants/tokens';
Expand All @@ -45,16 +45,15 @@ import useFormMiddleware from '~/hooks/ledger/useFormMiddleware';
import { FC } from '~/types';
import { useFetchFarmerMarketItems } from '~/hooks/farmer/market/useFarmerMarket2';
import TokenOutput from '~/components/Common/Form/TokenOutput';
import useSdk from '~/hooks/sdk';
import { bnToTokenValue } from '~/util';
import useSdk, { getNewToOldToken } from '~/hooks/sdk';

import { BuyPlotsFarmStep } from '~/lib/Txn/FarmSteps/market/BuyPlotsFarmStep';
import TokenQuoteProviderWithParams from '~/components/Common/Form/TokenQuoteProviderWithParams';
import TokenSelectDialogNew from '~/components/Common/Form/TokenSelectDialogNew';
import usePreferredToken from '~/hooks/farmer/usePreferredToken';
import useAccount from '~/hooks/ledger/useAccount';
import { QuoteHandlerWithParams } from '~/hooks/ledger/useQuoteWithParams';
import { getNewToOldToken } from '~/hooks/sdk';
import { tokenValueToBN } from '~/util';

import FormTxnProvider from '~/components/Common/Form/FormTxnProvider';
import useFormTxnContext from '~/hooks/sdk/useFormTxnContext';

Expand Down Expand Up @@ -221,7 +220,7 @@ const CreateOrderV2Form: FC<
tokenOut={Bean}
balance={
state.token.address === ''
? balances['eth']
? balances.eth
: balances[state.token.address] || ZERO_BN
}
state={state}
Expand Down Expand Up @@ -334,12 +333,8 @@ const CreateOrderProvider: FC<{}> = () => {

/// Ledger
const { data: signer } = useSigner();
const provider = useProvider();
const beanstalk = useBeanstalkContract(signer);

/// Farm
const farm = useMemo(() => new Farm(provider), [provider]);

/// Beanstalk
const beanstalkField = useSelector<AppState, AppState['_beanstalk']['field']>(
(state) => state._beanstalk.field
Expand Down Expand Up @@ -372,7 +367,7 @@ const CreateOrderProvider: FC<{}> = () => {
slippage: 0.1,
},
}),
[Eth]
[baseToken]
);

/// Handlers
Expand All @@ -392,7 +387,7 @@ const CreateOrderProvider: FC<{}> = () => {
tokenValue: amountOut,
};
},
[Weth, farm]
[account, sdk]
);

const onSubmit = useCallback(
Expand Down Expand Up @@ -503,7 +498,10 @@ const CreateOrderProvider: FC<{}> = () => {
fetchFarmerMarketItems,
beanstalk,
balances,
Eth,
handleQuote,
sdk,
account,
txnBundler,
]
);

Expand Down
Loading