Skip to content

Commit

Permalink
use constant for usdc decimals
Browse files Browse the repository at this point in the history
  • Loading branch information
tinaszheng committed Jan 7, 2025
1 parent e2da4f9 commit 06689a4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/constants/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ export const USDC_ADDRESSES = {
[CosmosChainId.Osmosis]: 'ibc/498A0751C798A0D9A389AA3691123DADA57DAA4FE165D5C75894505B876BA6E4',
[CosmosChainId.Neutron]: 'ibc/B559A80D62249C8AA07A380E2A2BEA6E5CA9A6F079C912C3A9E9B494105E4F81',
};

export const USDC_DECIMALS = 6;
8 changes: 4 additions & 4 deletions src/views/dialogs/DepositDialog2/DepositDialog2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { DepositDialog2Props, DialogProps } from '@/constants/dialogs';
import { CosmosChainId } from '@/constants/graz';
import { STRING_KEYS } from '@/constants/localization';
import { SOLANA_MAINNET_ID } from '@/constants/solana';
import { USDC_ADDRESSES } from '@/constants/tokens';
import { USDC_ADDRESSES, USDC_DECIMALS } from '@/constants/tokens';
import { WalletNetworkType } from '@/constants/wallets';

import { useAccounts } from '@/hooks/useAccounts';
Expand All @@ -30,22 +30,22 @@ function getDefaultToken(sourceAccount: SourceAccount): DepositToken {
return {
chainId: mainnet.id.toString(),
denom: USDC_ADDRESSES[mainnet.id],
decimals: 6,
decimals: USDC_DECIMALS,
};
}

if (sourceAccount.chain === WalletNetworkType.Solana) {
return {
chainId: SOLANA_MAINNET_ID,
denom: USDC_ADDRESSES[SOLANA_MAINNET_ID],
decimals: 6,
decimals: USDC_DECIMALS,
};
}

return {
chainId: CosmosChainId.Osmosis,
denom: USDC_ADDRESSES[CosmosChainId.Osmosis],
decimals: 6, // TODO: confirm this
decimals: USDC_DECIMALS,
};
}

Expand Down
4 changes: 3 additions & 1 deletion src/views/dialogs/DepositDialog2/DepositForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { useStringGetter } from '@/hooks/useStringGetter';
import { Button } from '@/components/Button';
import { Output, OutputType } from '@/components/Output';

Check failure on line 13 in src/views/dialogs/DepositDialog2/DepositForm.tsx

View workflow job for this annotation

GitHub Actions / lint

Delete `⏎import·{·USDC_DECIMALS·}·from·'@/constants/tokens';`
import { USDC_DECIMALS } from '@/constants/tokens';
import { AmountInput } from './AmountInput';
import { RouteOptions } from './RouteOptions';
import { useRoutes } from './queries';
Expand Down Expand Up @@ -63,13 +64,14 @@ export const DepositForm = ({
{/* TODO(deposit2.0): Show difference between current and new balance here */}
{selectedRoute && (
<div tw="flex justify-between text-small">
{/* TODO(deposit2.0): localization */}
<div tw="text-color-text-0">Available balance</div>
<div>
+
<Output
tw="inline"
type={OutputType.Fiat}
value={formatUnits(BigInt(selectedRoute.amountOut), 6)}
value={formatUnits(BigInt(selectedRoute.amountOut), USDC_DECIMALS)}
/>
</div>
</div>
Expand Down

0 comments on commit 06689a4

Please sign in to comment.