Skip to content

Commit

Permalink
Bug/display decimals fix (#145)
Browse files Browse the repository at this point in the history
* fix display decimals in strat page
  • Loading branch information
akiraonstarknet authored Sep 24, 2024
1 parent 5baa336 commit e9f234a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
9 changes: 6 additions & 3 deletions src/app/strategy/[strategyId]/_components/Strategy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,13 @@ const Strategy = ({ params }: StrategyParams) => {
<Text color="cyan">
{address
? Number(
balData.data.amount.toEtherToFixedDecimals(4),
balData.data.amount.toEtherToFixedDecimals(
balData.data.tokenInfo?.displayDecimals ||
2,
),
) == 0
? '-'
: `${balData.data.amount.toEtherToFixedDecimals(4)} ${balData.data.tokenInfo?.name}`
: `${balData.data.amount.toEtherToFixedDecimals(balData.data.tokenInfo?.displayDecimals || 2)} ${balData.data.tokenInfo?.name}`
: isMobile
? CONSTANTS.MOBILE_MSG
: 'Connect wallet'}
Expand All @@ -278,7 +281,7 @@ const Strategy = ({ params }: StrategyParams) => {
color={profit >= 0 ? 'cyan' : 'red'}
>
{address && profit != 0
? `${profit?.toFixed(4)} ${balData.data.tokenInfo?.name}`
? `${profit?.toFixed(balData.data.tokenInfo?.displayDecimals || 2)} ${balData.data.tokenInfo?.name}`
: '-'}
</Text>
</Box>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Deposit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ export default function Deposit(props: DepositProps) {
<TxButton
txInfo={txInfo}
buttonText={props.buttonText}
text={`${props.buttonText}: ${amount.toEtherToFixedDecimals(2)} ${selectedMarket.name}`}
text={`${props.buttonText}: ${amount.toEtherToFixedDecimals(selectedMarket.displayDecimals)} ${selectedMarket.name}`}
calls={calls}
buttonProps={{
isDisabled:
Expand Down
4 changes: 2 additions & 2 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const TOKENS: TokenInfo[] = [
token: '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7',
name: 'ETH',
decimals: 18,
displayDecimals: 2,
displayDecimals: 4,
logo: CONSTANTS.LOGOS.ETH,
minAmount: MyNumber.fromEther('10', 18),
maxAmount: MyNumber.fromEther('10000', 18),
Expand Down Expand Up @@ -100,7 +100,7 @@ export const TOKENS: TokenInfo[] = [
token: '0x1b5bd713e72fdc5d63ffd83762f81297f6175a5e0a4771cdadbc1dd5fe72cb1',
name: 'zETH',
decimals: 18,
displayDecimals: 2,
displayDecimals: 4,
logo: CONSTANTS.LOGOS.ETH,
minAmount: MyNumber.fromEther('0.001', 18),
maxAmount: MyNumber.fromEther('10000', 18),
Expand Down

0 comments on commit e9f234a

Please sign in to comment.