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

Bean UI - Migration Preview Updates #1082

Merged
merged 4 commits into from
Sep 12, 2024
Merged
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
33 changes: 24 additions & 9 deletions projects/ui/src/pages/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import {
StyledDialogTitle,
} from '~/components/Common/Dialog';
import TokenIcon from '~/components/Common/TokenIcon';
import useHarvestableIndex from '~/hooks/beanstalk/useHarvestableIndex';

const MigrationPreview: FC<{}> = () => {
const connectedAccount = useAccount();
Expand All @@ -54,6 +55,12 @@ const MigrationPreview: FC<{}> = () => {
const sdk = useSdk();

const BEAN = sdk.tokens.BEAN;
const PODS = sdk.tokens.PODS;

const harvestableIndex = TokenValue.fromHuman(
useHarvestableIndex()?.toString() || '0',
PODS.decimals
);

useEffect(() => {
if (accountUrl) {
Expand Down Expand Up @@ -156,6 +163,11 @@ const MigrationPreview: FC<{}> = () => {
migrationData.field.totalPods,
BEAN.decimals
);
if (migrationData.field.plots.length > 1) {
migrationData.field.plots.sort(
(a: any, b: any) => Number(a.index) - Number(b.index)
);
}
migrationData.barn.totalFert = TokenValue.fromBlockchain(
migrationData.barn.totalFert,
0
Expand Down Expand Up @@ -209,7 +221,7 @@ const MigrationPreview: FC<{}> = () => {
setData(migrationData);
}
} catch (e) {
console.error('Migration Preview - Error Fetching Data');
console.error('Migration Preview - Error Fetching Data', e);
}
}

Expand Down Expand Up @@ -675,7 +687,7 @@ const MigrationPreview: FC<{}> = () => {
},
}}
>
<TableCell>Index</TableCell>
<TableCell>Place In Line</TableCell>
<TableCell align="right">Amount</TableCell>
</TableRow>
</TableHead>
Expand All @@ -694,10 +706,9 @@ const MigrationPreview: FC<{}> = () => {
}}
>
<TableCell component="th" scope="row">
{TokenValue.fromBlockchain(
plot.index,
6
).toHuman('short')}
{TokenValue.fromBlockchain(plot.index, 6)
.sub(harvestableIndex)
.toHuman('short')}
</TableCell>
<TableCell align="right">
{TokenValue.fromBlockchain(
Expand Down Expand Up @@ -958,10 +969,14 @@ const MigrationPreview: FC<{}> = () => {
{farmData.withdrawn.toHuman('short')}
</TableCell>
<TableCell align="right">
{farmData.token.isUnripe ? farmData.unpicked.toHuman('short') : '-'}
{farmData.token.isUnripe
? farmData.unpicked.toHuman('short')
: '-'}
</TableCell>
<TableCell align="right">
{farmData.token.displayName === "Bean" ? farmData.rinsable.toHuman('short') : '-'}
{farmData.token.displayName === 'Bean'
? farmData.rinsable.toHuman('short')
: '-'}
</TableCell>
<TableCell align="right">
{farmData.total.toHuman('short')}
Expand All @@ -973,7 +988,7 @@ const MigrationPreview: FC<{}> = () => {
</Table>
</TableContainer>
) : (
<Box>This account has no Farm Balances.</Box>
<Box>This account has no Farm Balances to be migrated.</Box>
)}
</Box>
</Card>
Expand Down
Loading