diff --git a/package.json b/package.json index 13947ef8b..7a5385152 100644 --- a/package.json +++ b/package.json @@ -48,8 +48,8 @@ "ui:test": "yarn workspace ui test", "test:browser": "yarn workspace tests test:browser", "ex": "yarn workspace @beanstalk/examples x", - "anvil-arbitrum": "yarn cli:anvil-arbitrum --fork-block-number 250704543 --code-size-limit 50000", - "anvil-mainnet": "yarn cli:anvil-mainnet", + "anvil-arbitrum": "yarn cli:anvil-arbitrum --code-size-limit 50000 --fork-block-number 250704543", + "anvil-eth-mainnet": "yarn cli:anvil-eth-mainnet", "anvil": "anvil --fork-url https://eth-mainnet.g.alchemy.com/v2/5ubn94zT7v7DnB5bNW1VOnoIbX5-AG2N --chain-id 1337", "anvil4tests": "anvil --fork-url https://eth-mainnet.g.alchemy.com/v2/Kk7ktCQL5wz4v4AG8bR2Gun8TAASQ-qi --chain-id 1337 --fork-block-number 18629000" }, diff --git a/projects/cli/anvil.sh b/projects/cli/anvil.sh index 1c70db4f1..da688875a 100644 --- a/projects/cli/anvil.sh +++ b/projects/cli/anvil.sh @@ -19,7 +19,7 @@ else fi # Determine which chain ID to use. Defaults to arbitrum local host -if [ "$chainIdType" = "mainnet-local" ]; then +if [ "$chainIdType" = "eth-mainnet" ]; then chainId=$mainnet_local_chain_id prefix="eth" port=9545 diff --git a/projects/cli/package.json b/projects/cli/package.json index 6fd04d140..f06eaa79e 100644 --- a/projects/cli/package.json +++ b/projects/cli/package.json @@ -1,6 +1,6 @@ { "name": "@beanstalk/cli", - "version": "0.0.10", + "version": "0.0.20", "description": "Beanstalk protocol development cli tool", "license": "MIT", "repository": { @@ -17,10 +17,10 @@ "cli:publish": "yarn cli:build && yarn npm publish --access public", "cli:build": "rimraf build && tsc && chmod u+x build/cli.js", "g:bean": "yarn ts-node-esm src/cli.ts", - "cli:anvil-mainnet": "bash anvil.sh dev mainnet-local", - "cli:anvil-arbitrum": "bash anvil.sh dev arbitrum-local", - "cli:anvil4tests-mainnet": "bash anvil.sh test mainnet-local --fork-block-number 18629000", - "cli:anvil4tests-arbitrum": "bash anvil.sh test arbitrum-local --fork-block-number 18629000" + "cli:anvil-eth-mainnet": "bash anvil.sh dev eth-mainnet", + "cli:anvil-arbitrum": "bash anvil.sh dev arbitrum-mainnet", + "cli:anvil4tests-mainnet": "bash anvil.sh test eth-mainnet --fork-block-number 18629000", + "cli:anvil4tests-arbitrum": "bash anvil.sh test arbitrum-mainnet --fork-block-number 18629000" }, "devDependencies": { "@types/command-line-args": "^5.2.3", diff --git a/projects/examples/src/setup-ethMainnet.ts b/projects/examples/src/setup-ethMainnet.ts new file mode 100644 index 000000000..2b288262b --- /dev/null +++ b/projects/examples/src/setup-ethMainnet.ts @@ -0,0 +1,52 @@ +// import { BeanstalkSDK, DataSource, TestUtils } from "@beanstalk/sdk"; +// import { ChainId } from "@beanstalk/sdk-core"; +// import { Provider } from "@beanstalk/sdk-wells/dist/types/lib/WellsSDK"; +// import { ethers } from "ethers"; + +// keeping these in the same file as ./setup for some reasons causes issues + +// const RPC_URL = "http://127.0.0.1:9545"; + +// const network = { +// name: "local-eth-mainnet", +// chainId: ChainId.LOCALHOST_ETH, +// _defaultProvider: () => new ethers.providers.JsonRpcProvider(RPC_URL, network) +// }; + +// const provider = new ethers.providers.StaticJsonRpcProvider(RPC_URL, network); + +// const connection = TestUtils.setupConnection(provider); + +// const { signer, account } = connection; + +// const sdk = new BeanstalkSDK({ +// signer: signer, +// rpcUrl: RPC_URL, +// DEBUG: true +// }); + +// const chain = new TestUtils.BlockchainUtils(sdk); + +// const impersonate = async (account) => { +// const stop = await chain.impersonate(account); +// const provider = ethers.getDefaultProvider(network) as Provider; +// const signer = await provider.getSigner(account); +// const sdk = new BeanstalkSDK({ +// signer, +// source: DataSource.LEDGER, +// DEBUG: true +// }); + +// return { sdk, stop }; +// }; + +// const ethMainnetUtils = { +// signer, +// account, +// provider, +// sdk, +// impersonate, +// chain +// }; + +// export default ethMainnetUtils; diff --git a/projects/examples/src/setup.ts b/projects/examples/src/setup.ts index b12238a35..3152dba95 100644 --- a/projects/examples/src/setup.ts +++ b/projects/examples/src/setup.ts @@ -3,42 +3,20 @@ import { Provider } from "@beanstalk/sdk/dist/types/lib/BeanstalkSDK"; import { ethers } from "ethers"; const RPC_URL = "http://127.0.0.1:8545"; -const LOCALHOST_ETH_RPC_URL = "http://127.0.0.1:9545"; const network = { name: "local", chainId: ChainId.LOCALHOST, - _defaultProvider: () => new ethers.providers.JsonRpcProvider(RPC_URL) -}; - -const ethMainnetNetwork = { - name: "local-eth-mainnet", - chainId: ChainId.LOCALHOST_ETH, - _defaultProvider: () => new ethers.providers.JsonRpcProvider(LOCALHOST_ETH_RPC_URL) + _defaultProvider: () => new ethers.providers.JsonRpcProvider(RPC_URL, network) }; export const provider = new ethers.providers.StaticJsonRpcProvider(RPC_URL, network); -export const { signer, account } = TestUtils.setupConnection(provider); -export const localhostEthProvider = new ethers.providers.JsonRpcProvider( - LOCALHOST_ETH_RPC_URL, - ethMainnetNetwork -); -export const { signer: localhostEthSigner, account: localhostEthAccount } = - TestUtils.setupConnection(localhostEthProvider); +export const { signer, account } = TestUtils.setupConnection(provider); export const sdk = new BeanstalkSDK({ signer, rpcUrl: RPC_URL, - provider: provider, - source: DataSource.LEDGER, - DEBUG: true -}); - -export const ethSdk = new BeanstalkSDK({ - signer: localhostEthSigner, - rpcUrl: LOCALHOST_ETH_RPC_URL, - provider: localhostEthProvider, source: DataSource.LEDGER, DEBUG: true }); diff --git a/projects/sdk/src/classes/Pool/BasinWell.ts b/projects/sdk/src/classes/Pool/BasinWell.ts index 082f0d16a..6aa2c4059 100644 --- a/projects/sdk/src/classes/Pool/BasinWell.ts +++ b/projects/sdk/src/classes/Pool/BasinWell.ts @@ -1,17 +1,122 @@ -import { BasinWell__factory } from "src/constants/generated"; +import { BasinWell__factory, BasinWell as BasinWellContract } from "src/constants/generated"; import { TokenValue } from "src/TokenValue"; import Pool, { Reserves } from "./Pool"; +import { ERC20Token } from "../Token"; +import { BeanstalkSDK } from "src/lib/BeanstalkSDK"; export class BasinWell extends Pool { + public readonly contract: BasinWellContract; + + constructor( + sdk: BeanstalkSDK, + address: string, + lpToken: ERC20Token, + tokens: ERC20Token[], + metadata: { + name: string; + symbol: string; + logo: string; + color: string; + } + ) { + super(sdk, address, lpToken, tokens, metadata); + this.contract = BasinWell__factory.connect(address, sdk.providerOrSigner); + } + public getContract() { - return BasinWell__factory.connect(this.address, Pool.sdk.providerOrSigner); + return this.contract; } public getReserves() { - Pool.sdk.debug(`BasinWell.getReserves(): ${this.address} ${this.name} on chain ${this.chainId}`); + Pool.sdk.debug( + `BasinWell.getReserves(): ${this.address} ${this.name} on chain ${this.chainId}` + ); return this.getContract() .getReserves() - .then((result) => [TokenValue.fromBlockchain(result[0], 0), TokenValue.fromBlockchain(result[1], 0)] as Reserves); + .then( + (result) => + [ + TokenValue.fromBlockchain(result[0], 0), + TokenValue.fromBlockchain(result[1], 0) + ] as Reserves + ); + } + + async getAddLiquidityOut(amounts: TokenValue[]) { + return this.contract + .getAddLiquidityOut(amounts.map((a) => a.toBigNumber())) + .then((result) => this.lpToken.fromBlockchain(result)); + } + + async getRemoveLiquidityOutEqual(amount: TokenValue) { + return this.contract + .getRemoveLiquidityOut(amount.toBigNumber()) + .then((result) => this.tokens.map((token, i) => token.fromBlockchain(result[i]))); + } + + async getRemoveLiquidityOutOneToken(lpAmountIn: TokenValue, tokenOut: ERC20Token) { + return this.contract + .getRemoveLiquidityOneTokenOut(lpAmountIn.toBigNumber(), tokenOut.address) + .then((result) => tokenOut.fromBlockchain(result)); + } + + /** + * Get the @wagmi/core multicall params for removing liquidity + * @param lpAmountIn The amount of LP tokens to remove + * @returns @wagmi/core multicall calls for + * - removing equal amounts of liquidity + * - removing single sided liquidity as well.tokens[0] + * - removing single sided liquidity as well.tokens[1] + */ + static getRemoveLiquidityOutMulticallParams(well: BasinWell, lpAmountIn: TokenValue) { + const contract = { + address: well.address as `0x${string}`, + abi: removeLiquidityPartialABI + }; + + const removeEqual = { + ...contract, + method: "getRemoveLiquidityOut", + args: [lpAmountIn.toBigNumber()] + }; + + const removeSingleSided0 = { + ...contract, + method: "getRemoveLiquidityOneTokenOut", + args: [lpAmountIn.toBigNumber(), well.tokens[0].address as `0x${string}`] + }; + + const removeSingleSided1 = { + ...contract, + method: "getRemoveLiquidityOneTokenOut", + args: [lpAmountIn.toBigNumber(), well.tokens[1].address as `0x${string}`] + }; + + return { + equal: removeEqual, + side0: removeSingleSided0, + side1: removeSingleSided1 + }; } } + +const removeLiquidityPartialABI = [ + { + inputs: [ + { internalType: "uint256", name: "lpAmountIn", type: "uint256" }, + { internalType: "contract IERC20", name: "tokenOut", type: "address" } + ], + name: "getRemoveLiquidityOneTokenOut", + outputs: [{ internalType: "uint256", name: "tokenAmountOut", type: "uint256" }], + stateMutability: "view", + type: "function" + }, + { + inputs: [{ internalType: "uint256", name: "lpAmountIn", type: "uint256" }], + name: "getRemoveLiquidityOut", + outputs: [{ internalType: "uint256[]", name: "tokenAmountsOut", type: "uint256[]" }], + stateMutability: "view", + type: "function" + } +] as const; diff --git a/projects/sdk/src/constants/abi/Ecosystem/BeanstalkPrice.json b/projects/sdk/src/constants/abi/Ecosystem/BeanstalkPrice.json index 47043575f..be8fad428 100644 --- a/projects/sdk/src/constants/abi/Ecosystem/BeanstalkPrice.json +++ b/projects/sdk/src/constants/abi/Ecosystem/BeanstalkPrice.json @@ -18,7 +18,7 @@ "type": "address" } ], - "name": "getConstantProductWell", + "name": "getWell", "outputs": [ { "components": [ diff --git a/projects/sdk/src/lib/silo.ts b/projects/sdk/src/lib/silo.ts index a208ccd85..46995eced 100644 --- a/projects/sdk/src/lib/silo.ts +++ b/projects/sdk/src/lib/silo.ts @@ -194,19 +194,6 @@ export class Silo { return this.siloConvert.convertEstimate(fromToken, toToken, fromAmount); } - public async getDeposits(_account: string) { - const deposits = await Silo.sdk.contracts.beanstalk.getDepositsForAccount(_account); - } - - public async getTokenDeposits(_account: string, token: Token) { - const tokenDeposits = Silo.sdk.contracts.beanstalk.getTokenDepositsForAccount( - _account, - token.address - ); - - const dict = {}; - } - /** * * Return the Farmer's balance of a single whitelisted token. @@ -236,7 +223,7 @@ export class Silo { account, _token.address ); - const depositsByToken = utils.parseDepositsByToken(Silo.sdk, farmerDeposits); + const depositsByToken = utils.parseDepositsByToken(Silo.sdk, [farmerDeposits]); // The processor's return schema assumes we might have wanted to grab // multiple tokens, so we have to grab the one we want diff --git a/projects/sdk/src/lib/silo/Withdraw.ts b/projects/sdk/src/lib/silo/Withdraw.ts index ae95bcc75..1389d21b6 100644 --- a/projects/sdk/src/lib/silo/Withdraw.ts +++ b/projects/sdk/src/lib/silo/Withdraw.ts @@ -36,36 +36,36 @@ export class Withdraw { const withdrawData = this.calculateWithdraw(token, amount, balance.deposits, season); Withdraw.sdk.debug("silo.withdraw(): withdrawData", { withdrawData }); - const seasons = withdrawData.crates.map((crate) => crate.stem.toString()); + const stems = withdrawData.crates.map((crate) => crate.stem.toString()); const amounts = withdrawData.crates.map((crate) => crate.amount.toBlockchain()); let contractCall; - if (seasons.length === 0) { + if (stems.length === 0) { throw new Error("Malformatted crates"); } - if (seasons.length === 1) { + if (stems.length === 1) { Withdraw.sdk.debug("silo.withdraw(): withdrawDeposit()", { address: token.address, - season: seasons[0], + stem: stems[0], amount: amounts[0] }); contractCall = Withdraw.sdk.contracts.beanstalk.withdrawDeposit( token.address, - seasons[0], + stems[0], amounts[0], toMode ); } else { Withdraw.sdk.debug("silo.withdraw(): withdrawDeposits()", { address: token.address, - seasons: seasons, + stems: stems, amounts: amounts }); contractCall = Withdraw.sdk.contracts.beanstalk.withdrawDeposits( token.address, - seasons, + stems, amounts, toMode ); @@ -89,4 +89,4 @@ export class Withdraw { crates: pickedCrates.crates }; } -} \ No newline at end of file +} diff --git a/projects/sdk/src/lib/silo/utils.ts b/projects/sdk/src/lib/silo/utils.ts index dee9d4f56..6e1804d6b 100644 --- a/projects/sdk/src/lib/silo/utils.ts +++ b/projects/sdk/src/lib/silo/utils.ts @@ -6,8 +6,6 @@ import { TokenValue } from "@beanstalk/sdk-core"; import { TokenSiloBalance, Deposit } from "./types"; import { assert } from "src/utils"; import { SiloGettersFacet } from "src/constants/generated/protocol/abi/Beanstalk"; -import { MayArray } from "src/types"; -import { isArray } from "src/utils/common"; export function sortCrates(state: TokenSiloBalance) { state.deposits = state.deposits.sort( @@ -42,8 +40,10 @@ export function sortCratesByBDVRatio(crates: Deposit[], direction: "asc" | "desc export function pickCrates( deposits: Deposit[], amount: TokenValue, - token: Token, - currentSeason: number + // TODO: remove these + _token: Token, + // TODO: remove these + _currentSeason: number ) { let totalAmount = TokenValue.ZERO; let totalBDV = TokenValue.ZERO; @@ -159,11 +159,10 @@ type TokenDepositsByStem = { export function parseDepositsByToken( sdk: BeanstalkSDK, - data: MayArray + data: SiloGettersFacet.TokenDepositIdStructOutput[] ) { const depositsByToken: Map = new Map(); - const datas = isArray(data) ? data : [data]; - datas.forEach(({ token: tokenAddr, depositIds, tokenDeposits }) => { + data.forEach(({ token: tokenAddr, depositIds, tokenDeposits }) => { const token = sdk.tokens.findByAddress(tokenAddr); if (!token) return; diff --git a/projects/sdk/src/lib/tokens.ts b/projects/sdk/src/lib/tokens.ts index 8053af586..c572caf44 100644 --- a/projects/sdk/src/lib/tokens.ts +++ b/projects/sdk/src/lib/tokens.ts @@ -577,6 +577,7 @@ export class Tokens { this.siloWhitelistAddresses = siloWhitelist.map((t) => t.address); this.unripeTokens = new Set(unripeTokens); + // make sure the underlying tokens are in the same indexing order as unripeTokens this.unripeUnderlyingTokens = new Set([this.BEAN, this.WSTETH]); this.erc20Tokens = new Set([ ...this.siloWhitelist, diff --git a/projects/ui/src/components/App/SdkProvider.tsx b/projects/ui/src/components/App/SdkProvider.tsx index 7f94102f1..dc7d64070 100644 --- a/projects/ui/src/components/App/SdkProvider.tsx +++ b/projects/ui/src/components/App/SdkProvider.tsx @@ -117,11 +117,14 @@ const useBeanstalkSdkContext = () => { function BeanstalkSDKProvider({ children }: { children: React.ReactNode }) { const sdk = useBeanstalkSdkContext(); - const { isEthereum } = useChainState(); + const { isArbitrum, isTestnet } = useChainState(); - const ready = useDynamicSeeds(sdk, !isEthereum); + // only run this on arbitrum dev + const ready = useDynamicSeeds(sdk, !!(isArbitrum && isTestnet)); - if (!ready) return null; + if (isArbitrum && isTestnet && !ready) { + return null; + } return ( <> diff --git a/projects/ui/src/components/App/index.tsx b/projects/ui/src/components/App/index.tsx index 82433e347..a5dd6965b 100644 --- a/projects/ui/src/components/App/index.tsx +++ b/projects/ui/src/components/App/index.tsx @@ -32,7 +32,7 @@ import GovernancePage from '~/pages/governance'; import ProposalPage from '~/pages/governance/proposal'; import FarmerDelegatePage from '~/pages/governance/delegate'; import TransactionHistoryPage from '~/pages/history'; -import NFTPage from '~/pages/nft'; +// import NFTPage from '~/pages/nft'; import SiloPage from '~/pages/silo'; import SiloTokenPage from '~/pages/silo/token'; import SwapPage from '~/pages/swap'; @@ -102,6 +102,7 @@ const CustomToaster: FC<{ navHeight: number }> = ({ navHeight }) => ( function Mainnet() { const banner = useBanner(); const navHeight = useNavHeight(!!banner); + const { isArbitrum } = useChainState(); return ( <> {null} @@ -125,7 +126,7 @@ function Mainnet() { justifyContent: 'center', }} > - + {/* } /> */} @@ -150,8 +151,8 @@ function Arbitrum() { * Bean Updaters * ----------------------- */} {/* price contract not working */} - {false && } - {false && } + + {/* ----------------------- * Beanstalk Updaters @@ -245,7 +246,7 @@ function Arbitrum() { element={} /> - } /> + {/* } /> */} } /> ; } diff --git a/projects/ui/src/components/Balances/SiloBalancesHistory.tsx b/projects/ui/src/components/Balances/SiloBalancesHistory.tsx index c1d54fe73..2e00fc459 100644 --- a/projects/ui/src/components/Balances/SiloBalancesHistory.tsx +++ b/projects/ui/src/components/Balances/SiloBalancesHistory.tsx @@ -11,7 +11,7 @@ import { SeasonRange, } from '~/hooks/beanstalk/useSeasonsQuery'; import useFarmerSiloHistory from '~/hooks/farmer/useFarmerSiloHistory'; -import { L1_SILO_WHITELIST } from '~/constants/tokens'; +import { useWhitelistedTokens } from '~/hooks/beanstalk/useTokens'; import MockPlot from '../Silo/MockPlot'; import BlurComponent from '../Common/ZeroState/BlurComponent'; import WalletButton from '../Common/Connection/WalletButton'; @@ -21,9 +21,10 @@ const SiloBalancesHistory: React.FC<{}> = () => { const account = useAccount(); const timeTabParams = useTimeTabState(); const { data, loading } = useFarmerSiloHistory(account, true, false); + const { whitelist } = useWhitelistedTokens(); const formatValue = (value: number) => - `$${value.toLocaleString('en-US', { maximumFractionDigits: 2 })}`; + `$${value?.toLocaleString('en-US', { maximumFractionDigits: 2 })}`; const getStatValue = (v?: T[]) => { if (!v?.length) return 0; @@ -48,7 +49,7 @@ const SiloBalancesHistory: React.FC<{}> = () => { const queryData: QueryData = { data: filteredSeries as BaseDataPoint[][], loading: loading, - keys: L1_SILO_WHITELIST.map((t) => t[1].address), + keys: whitelist.map((t) => t.address), error: undefined, }; diff --git a/projects/ui/src/components/Common/Charts/ChartPropProvider.tsx b/projects/ui/src/components/Common/Charts/ChartPropProvider.tsx index 626640ba3..931aec4cf 100644 --- a/projects/ui/src/components/Common/Charts/ChartPropProvider.tsx +++ b/projects/ui/src/components/Common/Charts/ChartPropProvider.tsx @@ -32,13 +32,15 @@ export type BaseDataPoint = { [key: string]: number; }; +type BaseChartMultiStyle = { + stroke: string; // stroke color + fillPrimary: string; // gradient 'to' color + fillSecondary?: string; // gradient 'from' color + strokeWidth?: number; +}; + export type ChartMultiStyles = { - [key: string]: { - stroke: string; // stroke color - fillPrimary: string; // gradient 'to' color - fillSecondary?: string; // gradient 'from' color - strokeWidth?: number; - }; + [key: string]: BaseChartMultiStyle; }; type ChartStyleConfig = { @@ -75,8 +77,8 @@ type Scales = { }; export type Scale = { - xScale: ReturnType; - yScale: ReturnType; + xScale: ReturnType<(typeof SCALES)[keyof typeof SCALES]>; + yScale: ReturnType<(typeof SCALES)[keyof typeof SCALES]>; }; type ChartAccessorProps = { @@ -120,6 +122,7 @@ type UtilProps = { }; export type DataRegion = { yTop: number; yBottom: number }; +// eslint-disable-next-line react/no-unused-prop-types export type BaseGraphProps = { width: number; height: number }; export type ProviderChartProps = { @@ -142,7 +145,7 @@ export type BaseChartProps = { isTWAP?: boolean; useCustomTokenList?: ERC20Token[]; useCustomTooltipNames?: { [key: string]: string }; - tokenPerSeasonFilter?: { [key: string]: { from: number, to: number } }; + tokenPerSeasonFilter?: { [key: string]: { from: number; to: number } }; horizontalLineNumber?: number; stylesConfig?: ChartMultiStyles; stackedArea?: boolean; @@ -184,33 +187,47 @@ const chartPadding = { }; const chartColors = BeanstalkPalette.theme.spring.chart; -const defaultChartStyles: ChartMultiStyles = { - 0: { - stroke: BeanstalkPalette.theme.spring.beanstalkGreen, - fillPrimary: chartColors.primaryLight, - strokeWidth: 2, - }, - 1: { - stroke: chartColors.purple, - fillPrimary: chartColors.purpleLight, - strokeWidth: 2, - }, - 2: { - stroke: chartColors.green, - fillPrimary: chartColors.greenLight, - strokeWidth: 2, - }, - 3: { - stroke: chartColors.yellow, - fillPrimary: chartColors.yellowLight, - strokeWidth: 2, - }, - 4: { - stroke: chartColors.blue, - fillPrimary: chartColors.blueLight, - strokeWidth: 2, - }, + +const chartStylePrimary: BaseChartMultiStyle = { + stroke: BeanstalkPalette.theme.spring.beanstalkGreen, + fillPrimary: chartColors.primaryLight, + strokeWidth: 2, +}; +const chartStylePurple: BaseChartMultiStyle = { + stroke: chartColors.purple, + fillPrimary: chartColors.purpleLight, + strokeWidth: 2, +}; +const chartStyleGreen: BaseChartMultiStyle = { + stroke: chartColors.green, + fillPrimary: chartColors.greenLight, + strokeWidth: 2, }; +const chartStyleYellow: BaseChartMultiStyle = { + stroke: chartColors.yellow, + fillPrimary: chartColors.yellowLight, + strokeWidth: 2, +}; +const chartStyleBlue: BaseChartMultiStyle = { + stroke: chartColors.blue, + fillPrimary: chartColors.blueLight, + strokeWidth: 2, +}; + +const chartStyleArr = [ + chartStylePrimary, + chartStylePurple, + chartStyleGreen, + chartStyleYellow, + chartStyleBlue, +]; + +const defaultChartStyles: ChartMultiStyles = Object.fromEntries( + [...chartStyleArr, ...chartStyleArr].map((chartStyle, i) => [ + i.toString(), + chartStyle, + ]) +); /** * get chart styles for given key diff --git a/projects/ui/src/components/Nav/NavBar.tsx b/projects/ui/src/components/Nav/NavBar.tsx index b7a8d6702..fcd3e25d0 100644 --- a/projects/ui/src/components/Nav/NavBar.tsx +++ b/projects/ui/src/components/Nav/NavBar.tsx @@ -18,6 +18,7 @@ import ROUTES from './routes'; import HoverMenu from './HoverMenu'; import { PAGE_BORDER_COLOR } from '../App/muiTheme'; +import BeanProgressIcon from '../Common/BeanProgressIcon'; const L1NavBar = () => ( <> @@ -31,21 +32,31 @@ const L1NavBar = () => ( }} > {/* Desktop: Right Side */} - - - + + + - - + + + + + + + ); const NavBar: FC<{}> = ({ children }) => { - const { isEthereum } = useChainState(); + const { isArbitrum, isArbMainnet } = useChainState(); - if (isEthereum) { + if (!isArbitrum || isArbMainnet) { return ; } diff --git a/projects/ui/src/components/Nav/routes.ts b/projects/ui/src/components/Nav/routes.ts index 9a763bd23..a9f9d277d 100644 --- a/projects/ui/src/components/Nav/routes.ts +++ b/projects/ui/src/components/Nav/routes.ts @@ -1,5 +1,5 @@ import aboutIcon from '~/img/beanstalk/interface/nav/about.svg'; -import beanNFTIcon from '~/img/beanstalk/interface/nav/bean-nft.svg'; +// import beanNFTIcon from '~/img/beanstalk/interface/nav/bean-nft.svg'; import discordIcon from '~/img/beanstalk/interface/nav/discord.svg'; import githubIcon from '~/img/beanstalk/interface/nav/github.svg'; import governanceIcon from '~/img/beanstalk/interface/nav/governance.svg'; @@ -59,12 +59,12 @@ const ROUTES: { [key in RouteKeys]: RouteData[] } = { ], // More Menu more: [ - { - path: 'nft', - title: 'BeaNFTs', - icon: beanNFTIcon, - small: true, - }, + // { + // path: 'nft', + // title: 'BeaNFTs', + // icon: beanNFTIcon, + // small: true, + // }, { path: 'swap', title: 'Swap', diff --git a/projects/ui/src/components/Silo/Actions/Deposit.tsx b/projects/ui/src/components/Silo/Actions/Deposit.tsx index 383eb479e..1577c98aa 100644 --- a/projects/ui/src/components/Silo/Actions/Deposit.tsx +++ b/projects/ui/src/components/Silo/Actions/Deposit.tsx @@ -590,6 +590,24 @@ const Deposit: FC<{ export default Deposit; +// leaving as reference for any deposit w/o claim & do x +// const farmDeposit = sdk.silo.buildDeposit(target, account); +// farmDeposit.setInputToken(tokenIn); +// const aFarm = sdk.farm.createAdvancedFarm(); + +// aFarm.add([...farmDeposit.workflow.generators] as any[]); +// await aFarm.estimate(amountIn); + +// await farmDeposit.estimate(amountIn); + +// const farmDepositTx = await aFarm.execute(amountIn, { +// slippage: values.settings.slippage, +// }); +// const farmDepositReceipt = await farmDepositTx.wait(); + +// txToast.success(farmDepositReceipt); +// formActions.resetForm(); + // const initTokenList = useMemo(() => { // const tokens = sdk.tokens; // if (tokens.BEAN.equals(whitelistedToken)) { diff --git a/projects/ui/src/components/Silo/Overview.tsx b/projects/ui/src/components/Silo/Overview.tsx index 60f843f09..bf77ce754 100644 --- a/projects/ui/src/components/Silo/Overview.tsx +++ b/projects/ui/src/components/Silo/Overview.tsx @@ -33,9 +33,6 @@ const Overview: FC<{ const { data, loading } = useFarmerSiloHistory(account, false, true); // const [tab, handleChange] = useTabs(SLUGS, 'view'); - - console.log('data', data); - // const ownership = farmerSilo.stalk.active?.gt(0) && beanstalkSilo.stalk.total?.gt(0) diff --git a/projects/ui/src/components/Silo/RewardItem.tsx b/projects/ui/src/components/Silo/RewardItem.tsx index d036450fe..1a3103fb8 100644 --- a/projects/ui/src/components/Silo/RewardItem.tsx +++ b/projects/ui/src/components/Silo/RewardItem.tsx @@ -2,10 +2,10 @@ import { Typography, Tooltip, Box } from '@mui/material'; import HelpOutlineIcon from '@mui/icons-material/HelpOutline'; import React from 'react'; import BigNumber from 'bignumber.js'; -import { displayFullBN } from '../../util'; import Row from '~/components/Common/Row'; import { FC } from '~/types'; +import { displayFullBN } from '../../util'; export type RewardItemProps = { title: string; diff --git a/projects/ui/src/components/Silo/SeedGauge/SeedGaugeTable.tsx b/projects/ui/src/components/Silo/SeedGauge/SeedGaugeTable.tsx index 5ca15130e..5c1deaab4 100644 --- a/projects/ui/src/components/Silo/SeedGauge/SeedGaugeTable.tsx +++ b/projects/ui/src/components/Silo/SeedGauge/SeedGaugeTable.tsx @@ -377,6 +377,8 @@ const SeedGaugeTable = ({ data: ReturnType['data']; onToggleAdvancedMode: (v: boolean) => void; }) => { + + console.log('data', data); const [isAdvanced, setIsAdvanced] = useState(false); const rows = useTableConfig(isAdvanced, data); const cols = isAdvanced ? advancedViewColumns : basicViewColumns; diff --git a/projects/ui/src/constants/abi/Beanstalk/abiSnippets.ts b/projects/ui/src/constants/abi/Beanstalk/abiSnippets.ts index bc1fba6f9..a9c39e4dc 100644 --- a/projects/ui/src/constants/abi/Beanstalk/abiSnippets.ts +++ b/projects/ui/src/constants/abi/Beanstalk/abiSnippets.ts @@ -61,6 +61,16 @@ const tokenSettings = [ }, ] as const; +const totalDeltaB = [ + { + inputs: [], + name: 'totalDeltaB', + outputs: [{ internalType: 'int256', name: 'deltaB', type: 'int256' }], + stateMutability: 'view', + type: 'function', + }, +] as const; + const poolDeltaB = [ { inputs: [{ internalType: 'address', name: 'pool', type: 'address' }], @@ -203,11 +213,57 @@ const siloGetters = [ }, ] as const; +const price = [ + { + inputs: [], + name: 'price', + outputs: [ + { + components: [ + { internalType: 'uint256', name: 'price', type: 'uint256' }, + { internalType: 'uint256', name: 'liquidity', type: 'uint256' }, + { internalType: 'int256', name: 'deltaB', type: 'int256' }, + { + components: [ + { internalType: 'address', name: 'pool', type: 'address' }, + { + internalType: 'address[2]', + name: 'tokens', + type: 'address[2]', + }, + { + internalType: 'uint256[2]', + name: 'balances', + type: 'uint256[2]', + }, + { internalType: 'uint256', name: 'price', type: 'uint256' }, + { internalType: 'uint256', name: 'liquidity', type: 'uint256' }, + { internalType: 'int256', name: 'deltaB', type: 'int256' }, + { internalType: 'uint256', name: 'lpUsd', type: 'uint256' }, + { internalType: 'uint256', name: 'lpBdv', type: 'uint256' }, + ], + internalType: 'struct P.Pool[]', + name: 'ps', + type: 'tuple[]', + }, + ], + internalType: 'struct BeanstalkPrice.Prices', + name: 'p', + type: 'tuple', + }, + ], + stateMutability: 'view', + type: 'function', + }, +] as const; + const BEANSTALK_ABI_SNIPPETS = { getGaugePointsPerBdvForToken: getGaugePointsPerBdvForToken, tokenSettings: tokenSettings, poolDeltaB: poolDeltaB, siloGetters: siloGetters, + price: price, + totalDeltaB: totalDeltaB, } as const; export default BEANSTALK_ABI_SNIPPETS; diff --git a/projects/ui/src/constants/tokens.ts b/projects/ui/src/constants/tokens.ts index fbfdfe5fe..2a635650c 100644 --- a/projects/ui/src/constants/tokens.ts +++ b/projects/ui/src/constants/tokens.ts @@ -395,12 +395,12 @@ export const UNRIPE_UNDERLYING_TOKENS: ChainConstant[] = [ WSTETH, ]; -export const L1_SILO_WHITELIST: ChainConstant[] = [ - BEAN, - BEAN_WSTETH_WELL_LP, - BEAN_ETH_WELL_LP, - UNRIPE_BEAN, - UNRIPE_BEAN_WSTETH, +export const L1_SILO_WHITELIST: ERC20Token[] = [ + BEAN[1], + BEAN_WSTETH_WELL_LP[1], + BEAN_ETH_WELL_LP[1], + UNRIPE_BEAN[1], + UNRIPE_BEAN_WSTETH[1], ]; // Show these tokens as whitelisted in the Silo. diff --git a/projects/ui/src/graph/graphql.schema.json b/projects/ui/src/graph/graphql.schema.json index 9cb71a519..8b9f59fcb 100644 --- a/projects/ui/src/graph/graphql.schema.json +++ b/projects/ui/src/graph/graphql.schema.json @@ -128579,6 +128579,18 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "cover", + "description": null, + "args": [], + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "created", "description": null, diff --git a/projects/ui/src/graph/schema-snapshot1.graphql b/projects/ui/src/graph/schema-snapshot1.graphql index 16074926c..01ac8ca08 100644 --- a/projects/ui/src/graph/schema-snapshot1.graphql +++ b/projects/ui/src/graph/schema-snapshot1.graphql @@ -296,6 +296,7 @@ type Space { categories: [String] children: [Space] coingecko: String + cover: String created: Int! delegationPortal: DelegationPortal domain: String diff --git a/projects/ui/src/hooks/beanstalk/useAvgSeedsPerBDV.ts b/projects/ui/src/hooks/beanstalk/useAvgSeedsPerBDV.ts index b11219e62..347a0fd45 100644 --- a/projects/ui/src/hooks/beanstalk/useAvgSeedsPerBDV.ts +++ b/projects/ui/src/hooks/beanstalk/useAvgSeedsPerBDV.ts @@ -55,6 +55,7 @@ const apolloFetch = async ( notifyOnNetworkStatusChange: true, }); +// BS3TODO: Fix me to include L1 silo whitelist // Main hook with improved error handling and performance const useAvgSeedsPerBDV = ( range: Range