Skip to content

Commit

Permalink
add mainnet contract to config and fix USDC dusting issue
Browse files Browse the repository at this point in the history
  • Loading branch information
bcjgit committed Feb 7, 2023
1 parent 5d3b057 commit 1901c70
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,12 @@ const StreamWithdrawModalOverlay: React.FC<{

const humanUnitsStreamRemaningBalance = parseFloat(
isUSDC
? contract2humanUSDCFormat(withdrawableBalance?.toString() ?? '')
? contract2humanUSDCFormat(withdrawableBalance?.toString() ?? '', true)
: ethers.utils.formatUnits(withdrawableBalance?.toString() ?? '').toString(),
);



return (
<>
<ModalTitle>
Expand Down Expand Up @@ -169,7 +171,7 @@ const StreamWithdrawModalOverlay: React.FC<{
setWidthdrawAmount(
parseFloat(
isUSDC
? contract2humanUSDCFormat(withdrawableBalance?.toString() ?? '')
? contract2humanUSDCFormat(withdrawableBalance?.toString() ?? '', true)
: ethers.utils.formatUnits(withdrawableBalance?.toString() ?? '').toString(),
),
)
Expand Down
2 changes: 1 addition & 1 deletion packages/nouns-webapp/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const externalAddresses: Record<SupportedChains, ExternalContractAddresses> = {
payerContract: '0xd97Bcd9f47cEe35c0a9ec1dc40C1269afc9E8E1D',
tokenBuyer: '0x4f2aCdc74f6941390d9b1804faBc3E780388cfe5',
weth: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
nounsStreamFactory: undefined,
nounsStreamFactory: '0x0fd206FC7A7dBcD5661157eDCb1FFDD0D02A61ff',
},
[ChainId.Hardhat]: {
lidoToken: undefined,
Expand Down
7 changes: 6 additions & 1 deletion packages/nouns-webapp/src/utils/usdcUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ export const human2ContractUSDCFormat = (humanReadableUSDCAmt: string | number)
return Math.round(parseFloat(humanReadableUSDCAmt.toString()) * 1_000_000).toString();
};

export const contract2humanUSDCFormat = (contractUSCDAmt: string | number) => {
export const contract2humanUSDCFormat = (contractUSCDAmt: string | number, allDecimals?: boolean) => {

if (allDecimals === true) {
return (parseFloat(contractUSCDAmt.toString()) / 1_000_000).toString();
}

return (parseFloat(contractUSCDAmt.toString()) / 1_000_000).toFixed(3).toString();
};

0 comments on commit 1901c70

Please sign in to comment.