From 1901c705e0c30b124dd3dbfee22dc6dd20e640aa Mon Sep 17 00:00:00 2001 From: pbrianandj Date: Tue, 7 Feb 2023 13:07:30 -0800 Subject: [PATCH] add mainnet contract to config and fix USDC dusting issue --- .../src/components/StreamWithdrawModal/index.tsx | 6 ++++-- packages/nouns-webapp/src/config.ts | 2 +- packages/nouns-webapp/src/utils/usdcUtils.ts | 7 ++++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/nouns-webapp/src/components/StreamWithdrawModal/index.tsx b/packages/nouns-webapp/src/components/StreamWithdrawModal/index.tsx index dbb8e965d5..305de7bb55 100644 --- a/packages/nouns-webapp/src/components/StreamWithdrawModal/index.tsx +++ b/packages/nouns-webapp/src/components/StreamWithdrawModal/index.tsx @@ -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 ( <> @@ -169,7 +171,7 @@ const StreamWithdrawModalOverlay: React.FC<{ setWidthdrawAmount( parseFloat( isUSDC - ? contract2humanUSDCFormat(withdrawableBalance?.toString() ?? '') + ? contract2humanUSDCFormat(withdrawableBalance?.toString() ?? '', true) : ethers.utils.formatUnits(withdrawableBalance?.toString() ?? '').toString(), ), ) diff --git a/packages/nouns-webapp/src/config.ts b/packages/nouns-webapp/src/config.ts index 87536ccd8f..3cee188fa5 100644 --- a/packages/nouns-webapp/src/config.ts +++ b/packages/nouns-webapp/src/config.ts @@ -101,7 +101,7 @@ const externalAddresses: Record = { payerContract: '0xd97Bcd9f47cEe35c0a9ec1dc40C1269afc9E8E1D', tokenBuyer: '0x4f2aCdc74f6941390d9b1804faBc3E780388cfe5', weth: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', - nounsStreamFactory: undefined, + nounsStreamFactory: '0x0fd206FC7A7dBcD5661157eDCb1FFDD0D02A61ff', }, [ChainId.Hardhat]: { lidoToken: undefined, diff --git a/packages/nouns-webapp/src/utils/usdcUtils.ts b/packages/nouns-webapp/src/utils/usdcUtils.ts index 383945b104..1e7c876a01 100644 --- a/packages/nouns-webapp/src/utils/usdcUtils.ts +++ b/packages/nouns-webapp/src/utils/usdcUtils.ts @@ -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(); };