From ae101f1a54248a3f2f93dc1d4bdf1588bb2b42c9 Mon Sep 17 00:00:00 2001 From: uncoolzero <107518216+uncoolzero@users.noreply.github.com> Date: Tue, 10 Sep 2024 14:37:13 -0300 Subject: [PATCH 01/17] migration preview page --- projects/ui/src/components/App/index.tsx | 3 + projects/ui/src/pages/preview.tsx | 657 +++++++++++++++++++++++ 2 files changed, 660 insertions(+) create mode 100644 projects/ui/src/pages/preview.tsx diff --git a/projects/ui/src/components/App/index.tsx b/projects/ui/src/components/App/index.tsx index 480fb7ddba..aec49264f9 100644 --- a/projects/ui/src/components/App/index.tsx +++ b/projects/ui/src/components/App/index.tsx @@ -62,6 +62,7 @@ import VotingPowerPage from '~/pages/governance/votingPower'; import MorningUpdater from '~/state/beanstalk/sun/morning'; import MorningFieldUpdater from '~/state/beanstalk/field/morning'; import BeanstalkCaseUpdater from '~/state/beanstalk/case/updater'; +import MigrationPreview from '../../pages/preview'; // import Snowflakes from './theme/winter/Snowflakes'; BigNumber.set({ EXPONENTIAL_AT: [-12, 20] }); @@ -203,6 +204,8 @@ export default function App() { } /> } /> } /> + } /> + } /> } /> } /> } /> diff --git a/projects/ui/src/pages/preview.tsx b/projects/ui/src/pages/preview.tsx new file mode 100644 index 0000000000..d82486e789 --- /dev/null +++ b/projects/ui/src/pages/preview.tsx @@ -0,0 +1,657 @@ +import React, { useEffect, useState } from 'react'; +import { + Accordion, + AccordionDetails, + AccordionSummary, + Box, + Button, + Card, + Container, + Divider, + InputAdornment, + Stack, + Table, + TableBody, + TableCell, + TableContainer, + TableHead, + TableRow, + TextField, + Typography, + useMediaQuery, +} from '@mui/material'; +import { useTheme } from '@mui/material/styles'; +import CheckIcon from '@mui/icons-material/Check'; +import CloseIcon from '@mui/icons-material/Close'; +import ArrowForwardIcon from '@mui/icons-material/ArrowForward'; +import ExpandMoreIcon from '@mui/icons-material/ExpandMore'; +import useAccount from '../hooks/ledger/useAccount'; +import PageHeader from '~/components/Common/PageHeader'; +import GuideButton from '~/components/Common/Guide/GuideButton'; +import { HOW_TO_MINT_BEANFTS } from '~/util/Guides'; +import Row from '~/components/Common/Row'; +import { FC } from '~/types'; +import { useParams } from 'react-router-dom'; +import { ethers } from 'ethers'; +import { TokenValue } from '@beanstalk/sdk-core'; +import useSdk from '~/hooks/sdk'; +import { BeanstalkPalette, IconSize } from '~/components/App/muiTheme'; + +const MigrationPreview: FC<{}> = () => { + const connectedAccount = useAccount(); + const { address: accountUrl } = useParams(); + const theme = useTheme(); + const [isAccountValid, setIsAccountValid] = useState(false); + const [account, setAccount] = useState(); + const [data, setData] = useState(); + + const sdk = useSdk(); + + const BEAN = sdk.tokens.BEAN; + + useEffect(() => { + if (accountUrl) { + validateAddress(accountUrl); + getMigrationData(); + } + }, []); + + function validateAddress(address: string) { + setAccount(address); + if (address) { + const isValid = ethers.utils.isAddress(address); + setIsAccountValid(isValid); + } else { + setIsAccountValid(false); + } + } + + function useConnectedWallet() { + if (!connectedAccount) return; + validateAddress(connectedAccount); + getMigrationData(); + } + + async function getMigrationData() { + const _account = account || accountUrl; + const _isValid = account + ? isAccountValid + : ethers.utils.isAddress(accountUrl || ''); + if (!_account || !_isValid) return; + try { + const migrationData = await fetch( + `https://api.bean.money/dev/migration?account=${_account}` + ).then((response) => response.json()); + if (migrationData) { + setData(migrationData); + } + } catch (e) { + console.log('Migration Preview - Error Fetching Data'); + } + } + + return ( + + + + } + /> + + + + Enter Address + + {account && !isAccountValid && ( + + )} + {account && isAccountValid && ( + + )} + + ), + }} + value={account} + onChange={(e) => { + validateAddress(e.target.value); + }} + /> + + + + + + + + {data && ( + <> + + Silo + + + + Earned Beans + + {TokenValue.fromBlockchain( + data.silo.earnedBeans, + BEAN.decimals + ).toHuman('short')} + + + + + Current Stalk + + {TokenValue.fromBlockchain( + data.silo.currentStalk, + 16 + ).toHuman('short')} + + + + + Stalk After Mow + + {TokenValue.fromBlockchain( + data.silo.stalkAfterMow, + 16 + ).toHuman('short')} + + + + {data.silo.deposits.length > 0 && ( + + + } + > + View Deposits + + + + + + + Token + Amount + Recorded BDV + Current Stalk + + Stalk After Mow + + + + + {data.silo.deposits.map( + (deposit: any, i: number) => { + const _currStalk = TokenValue.fromBlockchain( + deposit.currentStalk, + 16 + ); + const _stalkAfterMow = + TokenValue.fromBlockchain( + deposit.stalkAfterMow, + 16 + ); + const stalkIncrease = + _stalkAfterMow.gt(_currStalk); + const token = Array.from( + sdk.tokens.getMap(), + ([key, value]) => value + ).find( + (token) => + token.displayName.toLowerCase() === + deposit.token.toLowerCase() + ); + return ( + + + {deposit.token} + + + {TokenValue.fromBlockchain( + deposit.amount, + token?.decimals || 6 + ).toHuman('short')} + + + {TokenValue.fromBlockchain( + deposit.recordedBdv, + token?.decimals || 6 + ).toHuman('short')} + + + {_currStalk.toHuman('short')} + + + + {_stalkAfterMow.toHuman('short')} + + + + ); + } + )} + +
+
+
+
+ )} +
+
+ + Field + + + + Total Pods + + {TokenValue.fromBlockchain( + data.field.totalPods, + BEAN.decimals + ).toHuman('short')} + + + + {data.field.plots.length > 0 && ( + + + } + > + View Plots + + + + + + + Index + Amount + + + + {data.field.plots.map((plot: any, i: number) => ( + + + {TokenValue.fromBlockchain( + plot.index, + 6 + ).toHuman('short')} + + + {TokenValue.fromBlockchain( + plot.amount, + 6 + ).toHuman('short')} + + + ))} + +
+
+
+
+ )} +
+
+ + Barn + + + + Total Fertilizer + + {TokenValue.fromBlockchain( + data.barn.totalFert, + 0 + ).toHuman()} + + + + Rinsable Sprouts + + {TokenValue.fromBlockchain( + data.barn.totalRinsable, + BEAN.decimals + ).toHuman('short')} + + + + Unrinsable Sprouts + + {TokenValue.fromBlockchain( + data.barn.totalUnrinsable, + BEAN.decimals + ).toHuman('short')} + + + + {data.barn.fert.length > 0 && ( + + + } + > + View Fertilizer + + + + + + + ID + Amount + + Rinsable Sprouts + + + Unrinsable Sprouts + + Humidity + + + + {data.barn.fert.map((fert: any, i: number) => ( + + + {Number(fert.fertilizerId)} + + + {TokenValue.fromBlockchain( + fert.amount, + 0 + ).toHuman('short')} + + + {TokenValue.fromBlockchain( + fert.rinsableSprouts, + 6 + ).toHuman('short')} + + + {TokenValue.fromBlockchain( + fert.unrinsableSprouts, + 6 + ).toHuman('short')} + + {`${fert.humidity * 100}%`} + + ))} + +
+
+
+
+ )} +
+
+ + Farm + + {data.farm.length > 0 ? ( + + + + + Token + Internal Balance + Withdrawn + Unpicked + Rinsable + Total + + + + {data.farm.map((token: any, i: number) => { + const _token = Array.from( + sdk.tokens.getMap(), + ([key, value]) => value + ).find( + (tokenData) => + tokenData.displayName.toLowerCase() === + token.token.toLowerCase() + ); + + return ( + + + {token.token} + + + {TokenValue.fromBlockchain( + token.currentInternal, + _token?.decimals || 6 + ).toHuman('short')} + + + {TokenValue.fromBlockchain( + token.withdrawn, + _token?.decimals || 6 + ).toHuman('short')} + + + {TokenValue.fromBlockchain( + token.unpicked, + _token?.decimals || 6 + ).toHuman('short')} + + + {TokenValue.fromBlockchain( + token.rinsable, + _token?.decimals || 6 + ).toHuman('short')} + + + {TokenValue.fromBlockchain( + token.total, + _token?.decimals || 6 + ).toHuman('short')} + + + ); + })} + +
+
+ ) : ( + This Farm is empty. + )} +
+
+ + )} +
+
+ ); +}; + +export default MigrationPreview; From 883e6c48e80c5205b916077c100479cac3937fd6 Mon Sep 17 00:00:00 2001 From: uncoolzero <107518216+uncoolzero@users.noreply.github.com> Date: Tue, 10 Sep 2024 14:50:08 -0300 Subject: [PATCH 02/17] add nav link --- projects/ui/src/components/Nav/routes.ts | 7 +++++++ projects/ui/src/img/beanstalk/interface/nav/migration.svg | 1 + 2 files changed, 8 insertions(+) create mode 100644 projects/ui/src/img/beanstalk/interface/nav/migration.svg diff --git a/projects/ui/src/components/Nav/routes.ts b/projects/ui/src/components/Nav/routes.ts index 9a763bd232..985bda2f47 100644 --- a/projects/ui/src/components/Nav/routes.ts +++ b/projects/ui/src/components/Nav/routes.ts @@ -11,6 +11,7 @@ import disclosuresIcon from '~/img/beanstalk/interface/nav/disclosures.svg'; import analyticsIcon from '~/img/beanstalk/interface/nav/stats.svg'; import basinIcon from '~/img/beanstalk/interface/nav/basin.svg'; import pipelineIcon from '~/img/beanstalk/interface/nav/pipeline.svg'; +import migrationIcon from '~/img/beanstalk/interface/nav/migration.svg'; export type RouteData = { /** Nav item title */ @@ -83,6 +84,12 @@ const ROUTES: { [key in RouteKeys]: RouteData[] } = { icon: governanceIcon, small: true, }, + { + path: '/preview', + title: 'Migration Preview', + icon: migrationIcon, + small: true, + }, { path: 'docs', href: 'https://docs.bean.money/almanac', diff --git a/projects/ui/src/img/beanstalk/interface/nav/migration.svg b/projects/ui/src/img/beanstalk/interface/nav/migration.svg new file mode 100644 index 0000000000..9c3f921974 --- /dev/null +++ b/projects/ui/src/img/beanstalk/interface/nav/migration.svg @@ -0,0 +1 @@ +migrate \ No newline at end of file From 78b059cb8cd9417caa4c01f00b293cdf6e9830bc Mon Sep 17 00:00:00 2001 From: uncoolzero <107518216+uncoolzero@users.noreply.github.com> Date: Tue, 10 Sep 2024 15:24:08 -0300 Subject: [PATCH 03/17] remove links --- projects/ui/src/pages/preview.tsx | 7 ------- 1 file changed, 7 deletions(-) diff --git a/projects/ui/src/pages/preview.tsx b/projects/ui/src/pages/preview.tsx index d82486e789..fd646c225f 100644 --- a/projects/ui/src/pages/preview.tsx +++ b/projects/ui/src/pages/preview.tsx @@ -96,13 +96,6 @@ const MigrationPreview: FC<{}> = () => { - } /> From e8a97bbc54d00dc73448ce6eeffa971d6af93c6b Mon Sep 17 00:00:00 2001 From: uncoolzero <107518216+uncoolzero@users.noreply.github.com> Date: Tue, 10 Sep 2024 16:47:45 -0300 Subject: [PATCH 04/17] switch to prod endpoint --- projects/ui/src/pages/preview.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/ui/src/pages/preview.tsx b/projects/ui/src/pages/preview.tsx index fd646c225f..bc213ce078 100644 --- a/projects/ui/src/pages/preview.tsx +++ b/projects/ui/src/pages/preview.tsx @@ -80,7 +80,7 @@ const MigrationPreview: FC<{}> = () => { if (!_account || !_isValid) return; try { const migrationData = await fetch( - `https://api.bean.money/dev/migration?account=${_account}` + `https://api.bean.money/migration?account=${_account}` ).then((response) => response.json()); if (migrationData) { setData(migrationData); From 2d2aec1f554582866c08133d66f31299e50e4717 Mon Sep 17 00:00:00 2001 From: uncoolzero <107518216+uncoolzero@users.noreply.github.com> Date: Tue, 10 Sep 2024 18:07:41 -0300 Subject: [PATCH 05/17] update copy --- projects/ui/src/pages/preview.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/ui/src/pages/preview.tsx b/projects/ui/src/pages/preview.tsx index bc213ce078..51ab717337 100644 --- a/projects/ui/src/pages/preview.tsx +++ b/projects/ui/src/pages/preview.tsx @@ -636,7 +636,7 @@ const MigrationPreview: FC<{}> = () => { ) : ( - This Farm is empty. + This account has no Farm Balances. )} From d3ac5e26f2fd4d6de6eb007594b8656e1859d1e6 Mon Sep 17 00:00:00 2001 From: uncoolzero <107518216+uncoolzero@users.noreply.github.com> Date: Tue, 10 Sep 2024 18:26:02 -0300 Subject: [PATCH 06/17] clean imports --- projects/ui/src/pages/preview.tsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/projects/ui/src/pages/preview.tsx b/projects/ui/src/pages/preview.tsx index 51ab717337..137d31a5c5 100644 --- a/projects/ui/src/pages/preview.tsx +++ b/projects/ui/src/pages/preview.tsx @@ -18,7 +18,6 @@ import { TableRow, TextField, Typography, - useMediaQuery, } from '@mui/material'; import { useTheme } from '@mui/material/styles'; import CheckIcon from '@mui/icons-material/Check'; @@ -27,8 +26,6 @@ import ArrowForwardIcon from '@mui/icons-material/ArrowForward'; import ExpandMoreIcon from '@mui/icons-material/ExpandMore'; import useAccount from '../hooks/ledger/useAccount'; import PageHeader from '~/components/Common/PageHeader'; -import GuideButton from '~/components/Common/Guide/GuideButton'; -import { HOW_TO_MINT_BEANFTS } from '~/util/Guides'; import Row from '~/components/Common/Row'; import { FC } from '~/types'; import { useParams } from 'react-router-dom'; From cc7332278ad3435f7eef8dccfcce06912fa9bced Mon Sep 17 00:00:00 2001 From: uncoolzero <107518216+uncoolzero@users.noreply.github.com> Date: Tue, 10 Sep 2024 18:43:38 -0300 Subject: [PATCH 07/17] tooltips, copy --- projects/ui/src/pages/preview.tsx | 43 ++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/projects/ui/src/pages/preview.tsx b/projects/ui/src/pages/preview.tsx index 137d31a5c5..44f552fb7a 100644 --- a/projects/ui/src/pages/preview.tsx +++ b/projects/ui/src/pages/preview.tsx @@ -17,11 +17,13 @@ import { TableHead, TableRow, TextField, + Tooltip, Typography, } from '@mui/material'; import { useTheme } from '@mui/material/styles'; import CheckIcon from '@mui/icons-material/Check'; import CloseIcon from '@mui/icons-material/Close'; +import HelpOutlineIcon from '@mui/icons-material/HelpOutline'; import ArrowForwardIcon from '@mui/icons-material/ArrowForward'; import ExpandMoreIcon from '@mui/icons-material/ExpandMore'; import useAccount from '../hooks/ledger/useAccount'; @@ -91,7 +93,7 @@ const MigrationPreview: FC<{}> = () => { @@ -175,7 +177,24 @@ const MigrationPreview: FC<{}> = () => { }} > - Earned Beans + + Earned Beans + + + + {TokenValue.fromBlockchain( data.silo.earnedBeans, @@ -437,7 +456,25 @@ const MigrationPreview: FC<{}> = () => { - Rinsable Sprouts + + Rinsable Sprouts + + + + + {TokenValue.fromBlockchain( data.barn.totalRinsable, From a8753f715bd2964c1f8295e637f865754b542da9 Mon Sep 17 00:00:00 2001 From: uncoolzero <107518216+uncoolzero@users.noreply.github.com> Date: Tue, 10 Sep 2024 19:28:14 -0300 Subject: [PATCH 08/17] about page dialog --- projects/ui/src/pages/preview.tsx | 63 +++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/projects/ui/src/pages/preview.tsx b/projects/ui/src/pages/preview.tsx index 44f552fb7a..170d2c30a2 100644 --- a/projects/ui/src/pages/preview.tsx +++ b/projects/ui/src/pages/preview.tsx @@ -7,6 +7,7 @@ import { Button, Card, Container, + Dialog, Divider, InputAdornment, Stack, @@ -35,6 +36,10 @@ import { ethers } from 'ethers'; import { TokenValue } from '@beanstalk/sdk-core'; import useSdk from '~/hooks/sdk'; import { BeanstalkPalette, IconSize } from '~/components/App/muiTheme'; +import { + StyledDialogContent, + StyledDialogTitle, +} from '~/components/Common/Dialog'; const MigrationPreview: FC<{}> = () => { const connectedAccount = useAccount(); @@ -43,6 +48,7 @@ const MigrationPreview: FC<{}> = () => { const [isAccountValid, setIsAccountValid] = useState(false); const [account, setAccount] = useState(); const [data, setData] = useState(); + const [openDialog, setOpenDialog] = useState(false); const sdk = useSdk(); @@ -165,6 +171,63 @@ const MigrationPreview: FC<{}> = () => { {data && ( <> + + setOpenDialog(false)} open={openDialog}> + setOpenDialog(false)}> + Verify BIP-50 Migrated Balances + + +
+ BIP-50 proposes to migrate Beanstalk state to Arbitrum. In + doing so, all Deposits, Plots, Fertilizer and + Beanstalk-related Farm Balances (Beans, BEANWETH, BEAN3CRV + (migrated to BEANUSDC), BEANwstETH, urBEAN and urBEANwstETH) + are migrated. +
+
+ As part of the migration process: +
    +
  • Grown Stalk is Mown;
  • +
  • Earned Beans are Planted; and
  • +
  • + Rinsable Sprouts, Unpicked Unripe assets and unclaimed + Silo V2 Withdrawals are put into the respective accounts' + Farm Balances. +
  • +
+
+
+ The following balances show the state of the selected Farmer + as a result of the migration, assuming the migration was + executed based on balances at block {data.meta.block} (i.e., + roughly + {` ${new Date(data.meta.timestamp * 1000).toLocaleString()}`} + ). You should cross reference this with your balances in the + rest of the Beanstalk UI (assuming your balances haven't + changed since block {data.meta.block}). +
+
+ Note that Circulating Balances and smart contract account + balances are not migrated automatically. See{' '} + Discord +  and{' '} + + BIP-50 + {' '} + for more information. +
+
+
Silo From b9b91becefddb8719f93c058e564222521aef2df Mon Sep 17 00:00:00 2001 From: uncoolzero <107518216+uncoolzero@users.noreply.github.com> Date: Tue, 10 Sep 2024 19:29:52 -0300 Subject: [PATCH 09/17] total fert format --- projects/ui/src/pages/preview.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/ui/src/pages/preview.tsx b/projects/ui/src/pages/preview.tsx index 170d2c30a2..039318f793 100644 --- a/projects/ui/src/pages/preview.tsx +++ b/projects/ui/src/pages/preview.tsx @@ -515,7 +515,7 @@ const MigrationPreview: FC<{}> = () => { {TokenValue.fromBlockchain( data.barn.totalFert, 0 - ).toHuman()} + ).toHuman('short')} From 0a3a4716913a18b230c314f6b00d9fa7a3a3f02d Mon Sep 17 00:00:00 2001 From: uncoolzero <107518216+uncoolzero@users.noreply.github.com> Date: Tue, 10 Sep 2024 19:37:13 -0300 Subject: [PATCH 10/17] add timestamps to card titles --- projects/ui/src/pages/preview.tsx | 60 ++++++++++++++++++++++++++++--- 1 file changed, 56 insertions(+), 4 deletions(-) diff --git a/projects/ui/src/pages/preview.tsx b/projects/ui/src/pages/preview.tsx index 039318f793..f8c7c756bc 100644 --- a/projects/ui/src/pages/preview.tsx +++ b/projects/ui/src/pages/preview.tsx @@ -229,7 +229,20 @@ const MigrationPreview: FC<{}> = () => { - Silo + + Silo + {`(as of ${new Date(data.meta.timestamp * 1000).toLocaleString()})`} + = () => { - Field + + Field + {`(as of ${new Date(data.meta.timestamp * 1000).toLocaleString()})`} + = () => { - Barn + + Barn + {`(as of ${new Date(data.meta.timestamp * 1000).toLocaleString()})`} + = () => { - Farm + + Farm + {`(as of ${new Date(data.meta.timestamp * 1000).toLocaleString()})`} + {data.farm.length > 0 ? ( From 70dbb8c7686157eb2d530dca02dbebf9059d56de Mon Sep 17 00:00:00 2001 From: uncoolzero <107518216+uncoolzero@users.noreply.github.com> Date: Tue, 10 Sep 2024 19:44:25 -0300 Subject: [PATCH 11/17] update copy --- projects/ui/src/pages/preview.tsx | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/projects/ui/src/pages/preview.tsx b/projects/ui/src/pages/preview.tsx index f8c7c756bc..f1695111ef 100644 --- a/projects/ui/src/pages/preview.tsx +++ b/projects/ui/src/pages/preview.tsx @@ -188,37 +188,37 @@ const MigrationPreview: FC<{}> = () => { }} >
- BIP-50 proposes to migrate Beanstalk state to Arbitrum. In - doing so, all Deposits, Plots, Fertilizer and - Beanstalk-related Farm Balances (Beans, BEANWETH, BEAN3CRV + BIP-50 proposes to migrate Beanstalk state to Arbitrum. In + doing so, all Deposits, Plots, Fertilizer and + Beanstalk-related Farm Balances (Beans, BEANWETH, BEAN3CRV (migrated to BEANUSDC), BEANwstETH, urBEAN and urBEANwstETH) - are migrated. + {' '}are migrated.
- As part of the migration process: + As part of the migration process:
    -
  • Grown Stalk is Mown;
  • -
  • Earned Beans are Planted; and
  • +
  • Grown Stalk is Mown;
  • +
  • Earned Beans are Planted; and
  • - Rinsable Sprouts, Unpicked Unripe assets and unclaimed - Silo V2 Withdrawals are put into the respective accounts' - Farm Balances. + Rinsable Sprouts, Unpicked Unripe assets and unclaimed + Silo V2 Withdrawals are put into the respective accounts' + Farm Balances.
The following balances show the state of the selected Farmer - as a result of the migration, assuming the migration was + as a result of the migration, assuming the migration was executed based on balances at block {data.meta.block} (i.e., roughly {` ${new Date(data.meta.timestamp * 1000).toLocaleString()}`} - ). You should cross reference this with your balances in the + ). You should cross reference this with your balances in the rest of the Beanstalk UI (assuming your balances haven't changed since block {data.meta.block}).
- Note that Circulating Balances and smart contract account - balances are not migrated automatically. See{' '} + Note that Circulating Balances and smart contract account + balances are not migrated automatically. See{' '} Discord  and{' '} From a720097610f0ae603e0be4e0094ce1d9ca147198 Mon Sep 17 00:00:00 2001 From: uncoolzero <107518216+uncoolzero@users.noreply.github.com> Date: Tue, 10 Sep 2024 19:45:41 -0300 Subject: [PATCH 12/17] update copy --- projects/ui/src/pages/preview.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/ui/src/pages/preview.tsx b/projects/ui/src/pages/preview.tsx index f1695111ef..8df670006f 100644 --- a/projects/ui/src/pages/preview.tsx +++ b/projects/ui/src/pages/preview.tsx @@ -176,7 +176,7 @@ const MigrationPreview: FC<{}> = () => { setOpenDialog(false)} open={openDialog}> setOpenDialog(false)}> - Verify BIP-50 Migrated Balances + BIP-50 Balance Migration Date: Tue, 10 Sep 2024 23:49:51 -0300 Subject: [PATCH 13/17] add token icons --- projects/ui/src/pages/preview.tsx | 230 +++++++++++++++++++----------- 1 file changed, 147 insertions(+), 83 deletions(-) diff --git a/projects/ui/src/pages/preview.tsx b/projects/ui/src/pages/preview.tsx index 8df670006f..a3dd1c5227 100644 --- a/projects/ui/src/pages/preview.tsx +++ b/projects/ui/src/pages/preview.tsx @@ -40,6 +40,7 @@ import { StyledDialogContent, StyledDialogTitle, } from '~/components/Common/Dialog'; +import TokenIcon from '~/components/Common/TokenIcon'; const MigrationPreview: FC<{}> = () => { const connectedAccount = useAccount(); @@ -88,10 +89,83 @@ const MigrationPreview: FC<{}> = () => { `https://api.bean.money/migration?account=${_account}` ).then((response) => response.json()); if (migrationData) { + migrationData.silo.deposits.forEach( + (deposit: any, index: number, deposits: any[]) => { + const _token = Array.from( + sdk.tokens.getMap(), + ([key, value]) => value + ).find( + (token) => + token.displayName.toLowerCase() === deposit.token.toLowerCase() + ); + const _amount = TokenValue.fromBlockchain( + deposit.amount, + _token?.decimals || 6 + ); + const _recordedBdv = TokenValue.fromBlockchain( + deposit.recordedBdv, + BEAN.decimals + ); + const _currentStalk = TokenValue.fromBlockchain( + deposit.currentStalk, + 16 + ); + const _stalkAfterMow = TokenValue.fromBlockchain( + deposit.stalkAfterMow, + 16 + ); + const _deposit = { + token: _token, + amount: _amount, + recordedBdv: _recordedBdv, + currentStalk: _currentStalk, + stalkAfterMow: _stalkAfterMow, + }; + deposits[index] = _deposit; + } + ); + migrationData.farm.forEach((token: any, index: number, farm: any[]) => { + const _token = Array.from( + sdk.tokens.getMap(), + ([key, value]) => value + ).find( + (tokenMap) => + tokenMap.displayName.toLowerCase() === token.token.toLowerCase() + ); + const _currentInternal = TokenValue.fromBlockchain( + token.currentInternal, + _token?.decimals || 6 + ); + const _withdrawn = TokenValue.fromBlockchain( + token.withdrawn, + _token?.decimals || 6 + ); + const _unpicked = TokenValue.fromBlockchain( + token.unpicked, + _token?.decimals || 6 + ); + const _rinsable = TokenValue.fromBlockchain( + token.rinsable, + _token?.decimals || 6 + ); + const _total = TokenValue.fromBlockchain( + token.total, + _token?.decimals || 6 + ); + const farmData = { + token: _token, + currentInternal: _currentInternal, + withdrawn: _withdrawn, + unpicked: _unpicked, + rinsable: _rinsable, + total: _total, + }; + farm[index] = farmData; + }); setData(migrationData); } } catch (e) { - console.log('Migration Preview - Error Fetching Data'); + console.error('Migration Preview - Error Fetching Data'); } } @@ -188,38 +262,54 @@ const MigrationPreview: FC<{}> = () => { }} >
- BIP-50 proposes to migrate Beanstalk state to Arbitrum. In - doing so, all Deposits, Plots, Fertilizer and - Beanstalk-related Farm Balances (Beans, BEANWETH, BEAN3CRV - (migrated to BEANUSDC), BEANwstETH, urBEAN and urBEANwstETH) - {' '}are migrated. + BIP-50 proposes to migrate Beanstalk state to Arbitrum.{' '} + In doing so,{' '} + + all Deposits, Plots, Fertilizer and Beanstalk-related Farm + Balances + {' '} + (Beans, BEANWETH, BEAN3CRV (migrated to BEANUSDC), BEANwstETH, + urBEAN and urBEANwstETH) are migrated.
As part of the migration process:
    -
  • Grown Stalk is Mown;
  • -
  • Earned Beans are Planted; and
  • - Rinsable Sprouts, Unpicked Unripe assets and unclaimed - Silo V2 Withdrawals are put into the respective accounts' - Farm Balances. + Grown Stalk is Mown; +
  • +
  • + Earned Beans are Planted; and +
  • +
  • + + Rinsable Sprouts, Unpicked Unripe assets and unclaimed + Silo V2 Withdrawals + {' '} + are put into the respective{' '} + accounts' Farm Balances.
The following balances show the state of the selected Farmer - as a result of the migration, assuming the migration was - executed based on balances at block {data.meta.block} (i.e., - roughly - {` ${new Date(data.meta.timestamp * 1000).toLocaleString()}`} - ). You should cross reference this with your balances in the - rest of the Beanstalk UI (assuming your balances haven't - changed since block {data.meta.block}). + as a result of the migration,{' '} + + assuming the migration was executed based on balances at + block {data.meta.block} (i.e., roughly + {` ${new Date(data.meta.timestamp * 1000).toLocaleString()}`} + ).{' '} + + You should cross reference this with your balances in the rest + of the Beanstalk UI (assuming your balances haven't changed + since block {data.meta.block}).
- Note that Circulating Balances and smart contract account - balances are not migrated automatically. See{' '} - Discord + Note that{' '} + + Circulating Balances and smart contract account balances are + not migrated automatically. + {' '} + See Discord  and{' '} BIP-50 @@ -345,24 +435,8 @@ const MigrationPreview: FC<{}> = () => { {data.silo.deposits.map( (deposit: any, i: number) => { - const _currStalk = TokenValue.fromBlockchain( - deposit.currentStalk, - 16 - ); - const _stalkAfterMow = - TokenValue.fromBlockchain( - deposit.stalkAfterMow, - 16 - ); - const stalkIncrease = - _stalkAfterMow.gt(_currStalk); - const token = Array.from( - sdk.tokens.getMap(), - ([key, value]) => value - ).find( - (token) => - token.displayName.toLowerCase() === - deposit.token.toLowerCase() + const stalkIncrease = deposit.stalkAfterMow.gt( + deposit.currentStalk ); return ( = () => { }, }} > - - {deposit.token} + + +
{deposit.token.displayName}
- {TokenValue.fromBlockchain( - deposit.amount, - token?.decimals || 6 - ).toHuman('short')} + {deposit.amount.toHuman('short')} - {TokenValue.fromBlockchain( - deposit.recordedBdv, - token?.decimals || 6 - ).toHuman('short')} + {deposit.recordedBdv.toHuman('short')} - {_currStalk.toHuman('short')} + {deposit.currentStalk.toHuman('short')} = () => { stalkIncrease ? 'primary' : undefined } > - {_stalkAfterMow.toHuman('short')} + {deposit.stalkAfterMow.toHuman('short')}
@@ -722,16 +800,7 @@ const MigrationPreview: FC<{}> = () => { - {data.farm.map((token: any, i: number) => { - const _token = Array.from( - sdk.tokens.getMap(), - ([key, value]) => value - ).find( - (tokenData) => - tokenData.displayName.toLowerCase() === - token.token.toLowerCase() - ); - + {data.farm.map((farmData: any, i: number) => { return ( = () => { }, }} > - - {token.token} + + +
{farmData.token.displayName}
- {TokenValue.fromBlockchain( - token.currentInternal, - _token?.decimals || 6 - ).toHuman('short')} + {farmData.currentInternal.toHuman('short')} - {TokenValue.fromBlockchain( - token.withdrawn, - _token?.decimals || 6 - ).toHuman('short')} + {farmData.withdrawn.toHuman('short')} - {TokenValue.fromBlockchain( - token.unpicked, - _token?.decimals || 6 - ).toHuman('short')} + {farmData.unpicked.toHuman('short')} - {TokenValue.fromBlockchain( - token.rinsable, - _token?.decimals || 6 - ).toHuman('short')} + {farmData.rinsable.toHuman('short')} - {TokenValue.fromBlockchain( - token.total, - _token?.decimals || 6 - ).toHuman('short')} + {farmData.total.toHuman('short')}
); From 09ddb7723aff770b6aa56e9caa80125640d3f595 Mon Sep 17 00:00:00 2001 From: uncoolzero <107518216+uncoolzero@users.noreply.github.com> Date: Wed, 11 Sep 2024 00:41:25 -0300 Subject: [PATCH 14/17] add amount of each deposited asset --- projects/ui/src/pages/preview.tsx | 101 ++++++++++++++++++++++++++---- 1 file changed, 88 insertions(+), 13 deletions(-) diff --git a/projects/ui/src/pages/preview.tsx b/projects/ui/src/pages/preview.tsx index a3dd1c5227..aceaeb0642 100644 --- a/projects/ui/src/pages/preview.tsx +++ b/projects/ui/src/pages/preview.tsx @@ -89,6 +89,7 @@ const MigrationPreview: FC<{}> = () => { `https://api.bean.money/migration?account=${_account}` ).then((response) => response.json()); if (migrationData) { + const totalPerToken: any[] = []; migrationData.silo.deposits.forEach( (deposit: any, index: number, deposits: any[]) => { const _token = Array.from( @@ -122,8 +123,35 @@ const MigrationPreview: FC<{}> = () => { stalkAfterMow: _stalkAfterMow, }; deposits[index] = _deposit; + const totalIndex = totalPerToken.findIndex( + (token) => token.token.displayName === _token?.displayName + ); + if (totalIndex === -1) { + const total = { + token: _token, + amount: _amount, + }; + totalPerToken.push(total); + } else { + totalPerToken[totalIndex].amount = _amount.add( + totalPerToken[totalIndex].amount + ); + } } ); + migrationData.silo.currentStalk = TokenValue.fromBlockchain( + migrationData.silo.currentStalk, + 16 + ); + migrationData.silo.earnedBeans = TokenValue.fromBlockchain( + migrationData.silo.earnedBeans, + BEAN.decimals + ); + migrationData.silo.stalkAfterMow = TokenValue.fromBlockchain( + migrationData.silo.stalkAfterMow, + 16 + ); + migrationData.silo.totalPerToken = totalPerToken; migrationData.farm.forEach((token: any, index: number, farm: any[]) => { const _token = Array.from( sdk.tokens.getMap(), @@ -362,33 +390,80 @@ const MigrationPreview: FC<{}> = () => { - {TokenValue.fromBlockchain( - data.silo.earnedBeans, - BEAN.decimals - ).toHuman('short')} + {data.silo.earnedBeans.toHuman('short')} Current Stalk - {TokenValue.fromBlockchain( - data.silo.currentStalk, - 16 - ).toHuman('short')} + {data.silo.currentStalk.toHuman('short')} Stalk After Mow - - {TokenValue.fromBlockchain( - data.silo.stalkAfterMow, - 16 - ).toHuman('short')} + + {data.silo.stalkAfterMow.toHuman('short')} + + + + Deposited Tokens + + + {data.silo.totalPerToken && + data.silo.totalPerToken.map( + (tokenData: any, index: number, array: any[]) => ( + <> + + + + + {tokenData.token.displayName} + + + + {tokenData.amount.toHuman('short')} + + + {index !== array.length - 1 && } + + ) + )} + + + {data.silo.deposits.length > 0 && ( Date: Wed, 11 Sep 2024 01:15:56 -0300 Subject: [PATCH 15/17] input field/buttons alignment --- projects/ui/src/pages/preview.tsx | 126 +++++++++++++++--------------- 1 file changed, 63 insertions(+), 63 deletions(-) diff --git a/projects/ui/src/pages/preview.tsx b/projects/ui/src/pages/preview.tsx index aceaeb0642..715ec3fb70 100644 --- a/projects/ui/src/pages/preview.tsx +++ b/projects/ui/src/pages/preview.tsx @@ -205,71 +205,71 @@ const MigrationPreview: FC<{}> = () => { description="Preview an account's assets after migration" /> - - - Enter Address - - {account && !isAccountValid && ( - - )} - {account && isAccountValid && ( - - )} - - ), - }} - value={account} - onChange={(e) => { - validateAddress(e.target.value); - }} - /> - - - - - - + + + + + {data && ( <> From 4314f1eb73fb7e7fb849358a18bbd3cecfff63d5 Mon Sep 17 00:00:00 2001 From: uncoolzero <107518216+uncoolzero@users.noreply.github.com> Date: Wed, 11 Sep 2024 01:46:43 -0300 Subject: [PATCH 16/17] add empty silo/field/barn messages --- projects/ui/src/pages/preview.tsx | 855 ++++++++++++++++-------------- 1 file changed, 452 insertions(+), 403 deletions(-) diff --git a/projects/ui/src/pages/preview.tsx b/projects/ui/src/pages/preview.tsx index 715ec3fb70..93f2078ad7 100644 --- a/projects/ui/src/pages/preview.tsx +++ b/projects/ui/src/pages/preview.tsx @@ -152,6 +152,22 @@ const MigrationPreview: FC<{}> = () => { 16 ); migrationData.silo.totalPerToken = totalPerToken; + migrationData.field.totalPods = TokenValue.fromBlockchain( + migrationData.field.totalPods, + BEAN.decimals + ); + migrationData.barn.totalFert = TokenValue.fromBlockchain( + migrationData.barn.totalFert, + 0 + ); + migrationData.barn.totalRinsable = TokenValue.fromBlockchain( + migrationData.barn.totalRinsable, + BEAN.decimals + ); + migrationData.barn.totalUnrinsable = TokenValue.fromBlockchain( + migrationData.barn.totalUnrinsable, + BEAN.decimals + ); migrationData.farm.forEach((token: any, index: number, farm: any[]) => { const _token = Array.from( sdk.tokens.getMap(), @@ -206,7 +222,7 @@ const MigrationPreview: FC<{}> = () => { /> - + = () => { fontSize={16} >{`(as of ${new Date(data.meta.timestamp * 1000).toLocaleString()})`} - - - - - Earned Beans - 0) ? ( + + + + - - + Earned Beans + + + + + + {data.silo.earnedBeans.toHuman('short')} + - - {data.silo.earnedBeans.toHuman('short')} - - - - - Current Stalk - - {data.silo.currentStalk.toHuman('short')} - - - - - Stalk After Mow - - {data.silo.stalkAfterMow.toHuman('short')} - - - - - - - Deposited Tokens - - - {data.silo.totalPerToken && - data.silo.totalPerToken.map( - (tokenData: any, index: number, array: any[]) => ( - <> - - - - - {tokenData.token.displayName} - - - - {tokenData.amount.toHuman('short')} - - - {index !== array.length - 1 && } - - ) - )} + + + Current Stalk + + {data.silo.currentStalk.toHuman('short')} + + + + + Stalk After Mow + + {data.silo.stalkAfterMow.toHuman('short')} + - - {data.silo.deposits.length > 0 && ( - - - } - > - View Deposits - - - - - - - Token - Amount - Recorded BDV - Current Stalk - - Stalk After Mow - - - - - {data.silo.deposits.map( - (deposit: any, i: number) => { - const stalkIncrease = deposit.stalkAfterMow.gt( - deposit.currentStalk - ); - return ( - + + Deposited Tokens + + + {data.silo.totalPerToken && + data.silo.totalPerToken.map( + (tokenData: any, index: number, array: any[]) => ( + <> + + - + + {tokenData.token.displayName} + + + + {tokenData.amount.toHuman('short')} + + + {index !== array.length - 1 && } + + ) + )} + + + + {data.silo.deposits.length > 0 && ( + + + } + > + View Deposits + + + +
+ + + Token + Amount + + Recorded BDV + + + Current Stalk + + + Stalk After Mow + + + + + {data.silo.deposits.map( + (deposit: any, i: number) => { + const stalkIncrease = + deposit.stalkAfterMow.gt( + deposit.currentStalk + ); + return ( + - -
{deposit.token.displayName}
- - - {deposit.amount.toHuman('short')} - - - {deposit.recordedBdv.toHuman('short')} - - - {deposit.currentStalk.toHuman('short')} - - - - {deposit.stalkAfterMow.toHuman('short')} - - -
- ); - } - )} -
-
-
-
-
- )} -
+ +
{deposit.token.displayName}
+ + + {deposit.amount.toHuman('short')} + + + {deposit.recordedBdv.toHuman('short')} + + + {deposit.currentStalk.toHuman('short')} + + + + {deposit.stalkAfterMow.toHuman( + 'short' + )} + + + + ); + } + )} +
+ + + + + )} + + ) : ( + + This account has no assets in the Silo. + + )} = () => { fontSize={16} >{`(as of ${new Date(data.meta.timestamp * 1000).toLocaleString()})`} - - - - Total Pods - - {TokenValue.fromBlockchain( - data.field.totalPods, - BEAN.decimals - ).toHuman('short')} - - - - {data.field.plots.length > 0 && ( - 0) ? ( + + - - } + + Total Pods + + {data.field.totalPods.toHuman('short')} + + + + {data.field.plots.length > 0 && ( + - View Plots - - - - - - - Index - Amount - - - - {data.field.plots.map((plot: any, i: number) => ( + + } + > + View Plots + + + +
+ - - {TokenValue.fromBlockchain( - plot.index, - 6 - ).toHuman('short')} - - - {TokenValue.fromBlockchain( - plot.amount, - 6 - ).toHuman('short')} - + Index + Amount - ))} - -
-
-
-
- )} -
+ + + {data.field.plots.map((plot: any, i: number) => ( + + + {TokenValue.fromBlockchain( + plot.index, + 6 + ).toHuman('short')} + + + {TokenValue.fromBlockchain( + plot.amount, + 6 + ).toHuman('short')} + + + ))} + + + + +
+ )} +
+ ) : ( + + This account has no assets in the Field. + + )}
= () => { fontSize={16} >{`(as of ${new Date(data.meta.timestamp * 1000).toLocaleString()})`} - - - - Total Fertilizer - - {TokenValue.fromBlockchain( - data.barn.totalFert, - 0 - ).toHuman('short')} - - - - - Rinsable Sprouts - - - - - - - {TokenValue.fromBlockchain( - data.barn.totalRinsable, - BEAN.decimals - ).toHuman('short')} - - - - Unrinsable Sprouts - - {TokenValue.fromBlockchain( - data.barn.totalUnrinsable, - BEAN.decimals - ).toHuman('short')} - - - - {data.barn.fert.length > 0 && ( - 0) ? ( + + - - } + + Total Fertilizer + + {data.barn.totalFert.toHuman('short')} + + + + + Rinsable Sprouts + + + + + + + {data.barn.totalRinsable.toHuman('short')} + + + + Unrinsable Sprouts + + {data.barn.totalUnrinsable.toHuman('short')} + + + + {data.barn.fert.length > 0 && ( + - View Fertilizer - - - - - - - ID - Amount - - Rinsable Sprouts - - - Unrinsable Sprouts - - Humidity - - - - {data.barn.fert.map((fert: any, i: number) => ( + + } + > + View Fertilizer + + + +
+ - - {Number(fert.fertilizerId)} - + ID + Amount - {TokenValue.fromBlockchain( - fert.amount, - 0 - ).toHuman('short')} + Rinsable Sprouts - {TokenValue.fromBlockchain( - fert.rinsableSprouts, - 6 - ).toHuman('short')} + Unrinsable Sprouts - - {TokenValue.fromBlockchain( - fert.unrinsableSprouts, - 6 - ).toHuman('short')} - - {`${fert.humidity * 100}%`} + Humidity - ))} - -
-
-
-
- )} -
+ + + {data.barn.fert.map((fert: any, i: number) => ( + + + {Number(fert.fertilizerId)} + + + {TokenValue.fromBlockchain( + fert.amount, + 0 + ).toHuman('short')} + + + {TokenValue.fromBlockchain( + fert.rinsableSprouts, + 6 + ).toHuman('short')} + + + {TokenValue.fromBlockchain( + fert.unrinsableSprouts, + 6 + ).toHuman('short')} + + {`${fert.humidity * 100}%`} + + ))} + + + + +
+ )} +
+ ) : ( + + This account has no assets in the Barn. + + )}
Date: Wed, 11 Sep 2024 14:19:41 -0300 Subject: [PATCH 17/17] farm table tweaks --- projects/ui/src/pages/preview.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/ui/src/pages/preview.tsx b/projects/ui/src/pages/preview.tsx index 93f2078ad7..5294165dd1 100644 --- a/projects/ui/src/pages/preview.tsx +++ b/projects/ui/src/pages/preview.tsx @@ -958,10 +958,10 @@ const MigrationPreview: FC<{}> = () => { {farmData.withdrawn.toHuman('short')} - {farmData.unpicked.toHuman('short')} + {farmData.token.isUnripe ? farmData.unpicked.toHuman('short') : '-'} - {farmData.rinsable.toHuman('short')} + {farmData.token.displayName === "Bean" ? farmData.rinsable.toHuman('short') : '-'} {farmData.total.toHuman('short')}