- Withdrawing from {withdrawResult.crates.length} Deposit
+ Transferring from {withdrawResult.crates.length} Deposit
{withdrawResult.crates.length === 1 ? '' : 's'}:
- Season {_crate.stem.toString()}:{' '}
+ Stem {_crate.stem.toString()}:{' '}
{displayFullBN(_crate.bdv, whitelistedToken.displayDecimals)}{' '}
BDV,{' '}
{displayFullBN(_crate.stalk.total, STALK.displayDecimals)}{' '}
diff --git a/projects/ui/src/components/Silo/Actions/Withdraw.tsx b/projects/ui/src/components/Silo/Actions/Withdraw.tsx
index 9c0a85bac7..b431269d47 100644
--- a/projects/ui/src/components/Silo/Actions/Withdraw.tsx
+++ b/projects/ui/src/components/Silo/Actions/Withdraw.tsx
@@ -297,7 +297,7 @@ const WithdrawForm: FC<
{withdrawResult.crates.map((_crate, i) => (
// FIXME: same as convert
- Season {_crate.stem.toString()}:{' '}
+ Stem {_crate.stem.toString()}:{' '}
{displayFullBN(
_crate.bdv,
whitelistedToken.displayDecimals
From 60d17f072afe9b99d1df5cc281263206baba7884 Mon Sep 17 00:00:00 2001
From: uncoolzero <107518216+uncoolzero@users.noreply.github.com>
Date: Tue, 21 Nov 2023 21:30:10 -0300
Subject: [PATCH 49/52] Even better handling of numbers under max decimals
---
projects/ui/src/util/Tokens.ts | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/projects/ui/src/util/Tokens.ts b/projects/ui/src/util/Tokens.ts
index 457c6a18af..5b517abc77 100644
--- a/projects/ui/src/util/Tokens.ts
+++ b/projects/ui/src/util/Tokens.ts
@@ -115,13 +115,11 @@ export function displayTokenAmount(
? _amount
: tokenValueToBN(_amount);
- return `${(config.allowNegative ? amount : amount.abs())
- .toNumber()
- .toLocaleString('en-US', {
- maximumFractionDigits: token.displayDecimals,
- })} ${config.modifier ? `${config.modifier} ` : ''}${
- config.showName ? token.name : ''
- }`;
+ const outputValue = config.allowNegative
+ ? displayFullBN(amount, token.displayDecimals)
+ : displayFullBN(amount.abs(), token.displayDecimals);
+
+ return `${outputValue} ${config.modifier ? `${config.modifier}` : ''} ${config.showName ? token.name : ''}`;
}
/**
From 90639365019275482aa91309e3155e41b9496109 Mon Sep 17 00:00:00 2001
From: uncoolzero <107518216+uncoolzero@users.noreply.github.com>
Date: Tue, 21 Nov 2023 21:44:36 -0300
Subject: [PATCH 50/52] Updated "Amount of Fert received" display
---
projects/ui/src/components/Barn/Actions/Buy.tsx | 10 ++++++----
projects/ui/src/util/Tokens.ts | 10 +++++++++-
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/projects/ui/src/components/Barn/Actions/Buy.tsx b/projects/ui/src/components/Barn/Actions/Buy.tsx
index b00702154e..53e1c7f233 100644
--- a/projects/ui/src/components/Barn/Actions/Buy.tsx
+++ b/projects/ui/src/components/Barn/Actions/Buy.tsx
@@ -43,7 +43,7 @@ import useFarmerBalances from '~/hooks/farmer/useFarmerBalances';
import usePreferredToken, {
PreferredToken,
} from '~/hooks/farmer/usePreferredToken';
-import { getTokenIndex, normaliseTV, tokenValueToBN } from '~/util';
+import { displayTokenAmount, getTokenIndex, normaliseTV, tokenValueToBN } from '~/util';
import { useFetchFarmerAllowances } from '~/state/farmer/allowances/updater';
import { FarmerBalances } from '~/state/farmer/balances';
import FertilizerItem from '../FertilizerItem';
@@ -229,10 +229,12 @@ const BuyForm: FC<
The amount of Fertilizer received is:
- {values.tokens[0].amount?.toFixed(2)}{' '}
- {values.tokens[0].token.symbol}
+ {displayTokenAmount(values.tokens[0].amount || BigNumber(0), values.tokens[0].token, { showName: false, showSymbol: true })}
+ {values.claimableBeans.amount?.gt(0) && (
+ <> + {displayTokenAmount(values.claimableBeans.amount, sdk.tokens.BEAN, { showName: false, showSymbol: true })}>
+ )}
{values.tokens[0].token.symbol !== 'WETH' && (
- <> → {values.tokens[0].amountOut?.toFixed(2)} WETH >
+ <> → {displayTokenAmount(values.tokens[0].amount || BigNumber(0), sdk.tokens.WETH, { showName: false, showSymbol: true })}>
)}{' '}
* ${ethPrice.toHuman('short')} = {fert.toFixed(0)} Fertilizer
diff --git a/projects/ui/src/util/Tokens.ts b/projects/ui/src/util/Tokens.ts
index 5b517abc77..b195ec2a9c 100644
--- a/projects/ui/src/util/Tokens.ts
+++ b/projects/ui/src/util/Tokens.ts
@@ -105,10 +105,12 @@ export function displayTokenAmount(
config: {
allowNegative?: boolean;
showName?: boolean;
+ showSymbol?: boolean;
modifier?: string;
} = {
allowNegative: false,
showName: true,
+ showSymbol: false,
}
) {
const amount = BigNumber.isBigNumber(_amount)
@@ -118,8 +120,14 @@ export function displayTokenAmount(
const outputValue = config.allowNegative
? displayFullBN(amount, token.displayDecimals)
: displayFullBN(amount.abs(), token.displayDecimals);
+
+ const modifier = config.modifier || '';
- return `${outputValue} ${config.modifier ? `${config.modifier}` : ''} ${config.showName ? token.name : ''}`;
+ const name = config.showName ? token.name : '';
+
+ const symbol = config.showSymbol ? token.symbol : '';
+
+ return `${outputValue} ${modifier} ${name}${symbol}`;
}
/**
From ce3eac82db89e395b035244f68ea0486a206736c Mon Sep 17 00:00:00 2001
From: uncoolzero <107518216+uncoolzero@users.noreply.github.com>
Date: Tue, 21 Nov 2023 21:56:53 -0300
Subject: [PATCH 51/52] Cleanup + added claimable beans output
---
.../ui/src/components/Barn/Actions/Buy.tsx | 30 ++++++++++++++++---
1 file changed, 26 insertions(+), 4 deletions(-)
diff --git a/projects/ui/src/components/Barn/Actions/Buy.tsx b/projects/ui/src/components/Barn/Actions/Buy.tsx
index 53e1c7f233..d2f6a0f69b 100644
--- a/projects/ui/src/components/Barn/Actions/Buy.tsx
+++ b/projects/ui/src/components/Barn/Actions/Buy.tsx
@@ -229,12 +229,34 @@ const BuyForm: FC<
The amount of Fertilizer received is:
- {displayTokenAmount(values.tokens[0].amount || BigNumber(0), values.tokens[0].token, { showName: false, showSymbol: true })}
+ {values.tokens[0].amount?.gt(0) && (
+ <>
+ {displayTokenAmount(
+ values.tokens[0].amount || BigNumber(0),
+ values.tokens[0].token,
+ { showName: false, showSymbol: true }
+ )}
+ >
+ )}{' '}
{values.claimableBeans.amount?.gt(0) && (
- <> + {displayTokenAmount(values.claimableBeans.amount, sdk.tokens.BEAN, { showName: false, showSymbol: true })}>
- )}
+ <>
+ {values.tokens[0].amount?.gt(0) && (<>+ >)}
+ {displayTokenAmount(
+ values.claimableBeans.amount,
+ sdk.tokens.BEAN,
+ { showName: false, showSymbol: true }
+ )}
+ >
+ )}{' '}
{values.tokens[0].token.symbol !== 'WETH' && (
- <> → {displayTokenAmount(values.tokens[0].amount || BigNumber(0), sdk.tokens.WETH, { showName: false, showSymbol: true })}>
+ <>
+ →{' '}
+ {displayTokenAmount(
+ values.tokens[0].amountOut?.plus(values.claimableBeans.amountOut || BigNumber(0)) || BigNumber(0),
+ sdk.tokens.WETH,
+ { showName: false, showSymbol: true }
+ )}
+ >
)}{' '}
* ${ethPrice.toHuman('short')} = {fert.toFixed(0)} Fertilizer
From 5e5ec86e3f8ba63cceb32d9229ca49aadf677582 Mon Sep 17 00:00:00 2001
From: uncoolzero <107518216+uncoolzero@users.noreply.github.com>
Date: Tue, 21 Nov 2023 22:18:12 -0300
Subject: [PATCH 52/52] Updated Buy Fert, Sow actions
---
projects/sdk/src/constants/actions.ts | 2 +-
.../src/components/Common/Form/TxnPreview.tsx | 4 ++--
.../ui/src/components/Field/Actions/Sow.tsx | 2 +-
.../ui/src/hooks/farmer/useFertilizerSummary.ts | 3 ++-
projects/ui/src/util/Actions.ts | 17 +++++++++--------
5 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/projects/sdk/src/constants/actions.ts b/projects/sdk/src/constants/actions.ts
index 332f8e22f8..bc239605cf 100644
--- a/projects/sdk/src/constants/actions.ts
+++ b/projects/sdk/src/constants/actions.ts
@@ -16,7 +16,7 @@ export enum ActionType {
/// FIELD
BUY_BEANS,
- BURN_BEANS,
+ SOW_BEANS,
RECEIVE_PODS,
HARVEST,
RECEIVE_BEANS,
diff --git a/projects/ui/src/components/Common/Form/TxnPreview.tsx b/projects/ui/src/components/Common/Form/TxnPreview.tsx
index ed407c3677..05789bd309 100644
--- a/projects/ui/src/components/Common/Form/TxnPreview.tsx
+++ b/projects/ui/src/components/Common/Form/TxnPreview.tsx
@@ -213,7 +213,7 @@ const TxnStep: FC<{
);
break;
- case ActionType.BURN_BEANS:
+ case ActionType.SOW_BEANS:
step = (
@@ -386,7 +386,7 @@ const EXECUTION_STEPS = [
ActionType.CREATE_ORDER,
ActionType.TRANSFER,
ActionType.BUY_BEANS,
- ActionType.BURN_BEANS,
+ ActionType.SOW_BEANS,
ActionType.TRANSFER_PODS,
ActionType.TRANSFER_MULTIPLE_PLOTS,
ActionType.SELL_PODS,
diff --git a/projects/ui/src/components/Field/Actions/Sow.tsx b/projects/ui/src/components/Field/Actions/Sow.tsx
index 35a94b9491..a1cf600c58 100644
--- a/projects/ui/src/components/Field/Actions/Sow.tsx
+++ b/projects/ui/src/components/Field/Actions/Sow.tsx
@@ -314,7 +314,7 @@ const SowForm: FC<
tokenAmount: amountIn || ZERO_BN,
},
{
- type: ActionType.BURN_BEANS,
+ type: ActionType.SOW_BEANS,
amount: totalBeansAmount,
},
{
diff --git a/projects/ui/src/hooks/farmer/useFertilizerSummary.ts b/projects/ui/src/hooks/farmer/useFertilizerSummary.ts
index cb248a7061..fc3c81e164 100644
--- a/projects/ui/src/hooks/farmer/useFertilizerSummary.ts
+++ b/projects/ui/src/hooks/farmer/useFertilizerSummary.ts
@@ -89,7 +89,8 @@ export default function useFertilizerSummary(
data.actions.push({
type: ActionType.BUY_FERTILIZER,
- amountIn: data.fert,
+ amountIn: data.weth,
+ amountOut: data.fert,
humidity,
});
data.actions.push({
diff --git a/projects/ui/src/util/Actions.ts b/projects/ui/src/util/Actions.ts
index 84308ec67c..41be4cb7eb 100644
--- a/projects/ui/src/util/Actions.ts
+++ b/projects/ui/src/util/Actions.ts
@@ -25,7 +25,7 @@ export enum ActionType {
/// FIELD
BUY_BEANS,
- BURN_BEANS,
+ SOW_BEANS,
RECEIVE_PODS,
HARVEST,
RECEIVE_BEANS,
@@ -158,8 +158,8 @@ export type BuyBeansAction = {
tokenAmount: BigNumber;
};
-export type BurnBeansAction = FieldAction & {
- type: ActionType.BURN_BEANS;
+export type SowBeansAction = FieldAction & {
+ type: ActionType.SOW_BEANS;
amount: BigNumber;
};
@@ -227,6 +227,7 @@ export type RinseAction = {
export type FertilizerBuyAction = {
type: ActionType.BUY_FERTILIZER;
amountIn: BigNumber;
+ amountOut: BigNumber;
humidity: BigNumber;
};
@@ -256,7 +257,7 @@ export type Action =
| PlantAction
| MowAction
/// FIELD
- | BurnBeansAction
+ | SowBeansAction
| ReceivePodsAction
| FieldHarvestAction
| ReceiveBeansAction
@@ -371,8 +372,8 @@ export const parseActionMessage = (a: Action) => {
)} Beans with ${displayFullBN(a.tokenAmount, a.token.displayDecimals)} ${
a.token.name
} for ~$${displayFullBN(a.beanPrice, BEAN[1].displayDecimals)} each.`;
- case ActionType.BURN_BEANS:
- return `Burn ${displayFullBN(a.amount, BEAN[1].displayDecimals)} ${
+ case ActionType.SOW_BEANS:
+ return `Sow ${displayFullBN(a.amount, BEAN[1].displayDecimals)} ${
a.amount.eq(new BigNumber(1)) ? 'Bean' : 'Beans'
}.`;
case ActionType.RECEIVE_PODS:
@@ -403,10 +404,10 @@ export const parseActionMessage = (a: Action) => {
SPROUTS.displayDecimals
)} Sprouts${a.destination ? ` and send to your ${copy.MODES[a.destination]}.` : `.`}`;
case ActionType.BUY_FERTILIZER:
- return `Buy ${displayFullBN(a.amountIn, 2)} Fertilizer at ${displayFullBN(
+ return `Buy ${displayFullBN(a.amountOut, 2)} Fertilizer at ${displayFullBN(
a.humidity.multipliedBy(100),
1
- )}% Humidity.`;
+ )}% Humidity with ${displayFullBN(a.amountIn, 2)} Wrapped Ether.`;
case ActionType.RECEIVE_FERT_REWARDS:
return `Receive ${displayFullBN(a.amountOut, 2)} Sprouts.`;