From de3da5f1c224da62101739dc7604cf31d81e5a06 Mon Sep 17 00:00:00 2001
From: kkatusic
Date: Tue, 26 Nov 2024 21:31:04 +0100
Subject: [PATCH 1/7] Fix/Recurring donation for USDC
---
.../Recurring/RecurringDonationCard.tsx | 13 +++-
.../Recurring/RecurringDonationModal/Item.tsx | 8 ++-
.../RecurringDonationModal.tsx | 31 +++++++--
.../SelectTokenModal/SelectTokenModal.tsx | 67 ++++++++++---------
src/config/production.tsx | 45 ++++++++-----
5 files changed, 111 insertions(+), 53 deletions(-)
diff --git a/src/components/views/donate/Recurring/RecurringDonationCard.tsx b/src/components/views/donate/Recurring/RecurringDonationCard.tsx
index d40b596581..23d373f345 100644
--- a/src/components/views/donate/Recurring/RecurringDonationCard.tsx
+++ b/src/components/views/donate/Recurring/RecurringDonationCard.tsx
@@ -142,12 +142,20 @@ export const RecurringDonationCard = () => {
if (selectedRecurringToken.token.isSuperToken) {
setAmount(balance.value || 0n);
}
+ if (selectedRecurringToken.token.decimals === 6) {
+ setAmount(0n);
+ setPerMonthAmount(0n);
+ }
}, [selectedRecurringToken, balance]);
const underlyingToken = selectedRecurringToken?.token.underlyingToken;
+ // Introduce a scaling factor to handle tokens with different decimals
+ const scaleFactor =
+ selectedRecurringToken?.token.decimals === 6 ? 10000n : 1n;
+
// total means project + giveth
- const totalPerSec = perMonthAmount / ONE_MONTH_SECONDS;
+ const totalPerSec = perMonthAmount / (ONE_MONTH_SECONDS / scaleFactor);
const projectPerMonth =
(perMonthAmount * BigInt(100 - donationToGiveth)) / 100n;
const givethPerMonth = perMonthAmount - projectPerMonth;
@@ -168,7 +176,8 @@ export const RecurringDonationCard = () => {
0n,
) || 0n;
const totalStreamPerSec = totalPerSec + otherStreamsPerSec;
- const totalStreamPerMonth = totalStreamPerSec * ONE_MONTH_SECONDS;
+ const totalStreamPerMonth =
+ totalStreamPerSec * (ONE_MONTH_SECONDS / scaleFactor);
const streamRunOutInMonth =
totalStreamPerSec > 0 ? amount / totalStreamPerMonth : 0n;
const isTotalStreamExceed =
diff --git a/src/components/views/donate/Recurring/RecurringDonationModal/Item.tsx b/src/components/views/donate/Recurring/RecurringDonationModal/Item.tsx
index 2366a6de13..10f5225c3d 100644
--- a/src/components/views/donate/Recurring/RecurringDonationModal/Item.tsx
+++ b/src/components/views/donate/Recurring/RecurringDonationModal/Item.tsx
@@ -31,7 +31,9 @@ export const Item: FC = ({
{limitFraction(
formatUnits(
amount,
- token.underlyingToken?.decimals || 18,
+ token.underlyingToken?.decimals ||
+ token.decimals ||
+ 18,
),
)}
{token.symbol}
@@ -47,7 +49,9 @@ export const Item: FC = ({
.multipliedBy(amount.toString())
.toFixed(0),
),
- token.underlyingToken?.decimals || 18,
+ token.underlyingToken?.decimals ||
+ token.decimals ||
+ 18,
),
2,
)}
diff --git a/src/components/views/donate/Recurring/RecurringDonationModal/RecurringDonationModal.tsx b/src/components/views/donate/Recurring/RecurringDonationModal/RecurringDonationModal.tsx
index 76021e47e1..89863d004f 100644
--- a/src/components/views/donate/Recurring/RecurringDonationModal/RecurringDonationModal.tsx
+++ b/src/components/views/donate/Recurring/RecurringDonationModal/RecurringDonationModal.tsx
@@ -10,6 +10,7 @@ import { Framework, type Operation } from '@superfluid-finance/sdk-core';
import { useAccount } from 'wagmi';
import { useIntl } from 'react-intl';
import { formatUnits } from 'viem';
+import { ethers } from 'ethers';
import { Modal } from '@/components/modals/Modal';
import { useModalAnimation } from '@/hooks/useModalAnimation';
import { IModal } from '@/types/common';
@@ -227,10 +228,32 @@ const RecurringDonationInnerModal: FC = ({
const operations: Operation[] = [];
+ let newAmount = amount;
+ let newPerMonthAmount = perMonthAmount;
+
+ // This is a special case with tokens that have 6 decimals
+ // We need to convert the amount to 18 decimals for the upgrade operation
+ // And also for the flow rate calculation
+ if (selectedRecurringToken.token.decimals === 6) {
+ const divisor = BigInt(
+ 10 ** selectedRecurringToken.token.decimals,
+ );
+ const currentAmount = Number(amount) / Number(divisor);
+ newAmount = ethers.utils
+ .parseUnits(currentAmount.toString(), 18)
+ .toBigInt();
+
+ const currentPerMonth =
+ Number(perMonthAmount) / Number(divisor);
+ newPerMonthAmount = ethers.utils
+ .parseUnits(currentPerMonth.toString(), 18)
+ .toBigInt();
+ }
+
// Upgrade the token to super token
if (!isUpdating && !selectedRecurringToken.token.isSuperToken) {
const upgradeOperation = await superToken.upgrade({
- amount: amount.toString(),
+ amount: newAmount.toString(),
});
//Upgrading ETHx is a special case and can't be batched
@@ -245,8 +268,8 @@ const RecurringDonationInnerModal: FC = ({
throw new Error('Project wallet address not found');
}
- const _flowRate =
- (perMonthAmount * BigInt(100 - donationToGiveth)) /
+ let _flowRate =
+ (newPerMonthAmount * BigInt(100 - donationToGiveth)) /
100n /
ONE_MONTH_SECONDS;
@@ -279,7 +302,7 @@ const RecurringDonationInnerModal: FC = ({
}
const _newFlowRate =
- (perMonthAmount * BigInt(donationToGiveth)) /
+ (newPerMonthAmount * BigInt(donationToGiveth)) /
100n /
ONE_MONTH_SECONDS;
diff --git a/src/components/views/donate/Recurring/SelectTokenModal/SelectTokenModal.tsx b/src/components/views/donate/Recurring/SelectTokenModal/SelectTokenModal.tsx
index b6aa89e915..806ad772ca 100644
--- a/src/components/views/donate/Recurring/SelectTokenModal/SelectTokenModal.tsx
+++ b/src/components/views/donate/Recurring/SelectTokenModal/SelectTokenModal.tsx
@@ -51,6 +51,7 @@ const SelectTokenInnerModal: FC = ({
setShowModal,
}) => {
const [tokens, setTokens] = useState([]);
+ const [underlyingTokens, setUnderlyingTokens] = useState([]);
const [balances, setBalances] = useState({});
const { formatMessage } = useIntl();
@@ -84,11 +85,12 @@ const SelectTokenInnerModal: FC = ({
return acc;
}, {} as IBalances);
- const filteredTokens = superTokens.filter(
- token => !(newBalances[token.symbol] > 0n),
- );
+ const filteredTokens = superTokens.filter(token => {
+ return !(newBalances[token.underlyingToken.symbol] > 0n);
+ });
setTokens(filteredTokens);
+ setUnderlyingTokens(superTokens);
// Update the state with the new balances
setBalances(newBalances);
@@ -185,33 +187,38 @@ const SelectTokenInnerModal: FC = ({
id: 'label.superfluid_eligible_tokens_description',
})}
- {tokens.length > 0 ? (
- tokens.map(token => (
- {
- setSelectedRecurringToken({
- token: token.underlyingToken,
- balance:
- balances[
- token.underlyingToken.symbol
- ],
- });
- setShowModal(false);
- }}
- />
+ {underlyingTokens.length > 0 ? (
+ underlyingTokens.map(token => (
+ <>
+ {
+ setSelectedRecurringToken({
+ token: token.underlyingToken,
+ balance:
+ balances[
+ token.underlyingToken
+ .symbol
+ ],
+ });
+ setShowModal(false);
+ }}
+ />
+ >
))
) : (
diff --git a/src/config/production.tsx b/src/config/production.tsx
index d394f547a6..40c9d9d710 100644
--- a/src/config/production.tsx
+++ b/src/config/production.tsx
@@ -522,21 +522,36 @@ const config: EnvConfig = {
isSuperToken: true,
coingeckoId: 'dai',
},
- // {
- // underlyingToken: {
- // decimals: 6,
- // id: '0x7f5c764cbc14f9669b88837ca1490cca17c31607',
- // name: 'USD Coin',
- // symbol: 'USDC',
- // coingeckoId: 'usd-coin',
- // },
- // decimals: 18,
- // id: '0x8430f084b939208e2eded1584889c9a66b90562f',
- // name: 'Super USD Coin',
- // symbol: 'USDCx',
- // isSuperToken: true,
- // coingeckoId: 'usd-coin',
- // },
+ {
+ underlyingToken: {
+ decimals: 6,
+ id: '0x7f5c764cbc14f9669b88837ca1490cca17c31607',
+ name: 'USD Coin',
+ symbol: 'USDC.e',
+ coingeckoId: 'usd-coin',
+ },
+ decimals: 18,
+ id: '0x8430f084b939208e2eded1584889c9a66b90562f',
+ name: 'Super USD Coin',
+ symbol: 'USDC.ex',
+ isSuperToken: true,
+ coingeckoId: 'usd-coin',
+ },
+ {
+ underlyingToken: {
+ decimals: 6,
+ id: '0x0b2c639c533813f4aa9d7837caf62653d097ff85',
+ name: 'USD Coin',
+ symbol: 'USDC',
+ coingeckoId: 'usd-coin',
+ },
+ decimals: 18,
+ id: '0x35Adeb0638EB192755B6E52544650603Fe65A006',
+ name: 'Super USD Coin',
+ symbol: 'USDCx',
+ isSuperToken: true,
+ coingeckoId: 'usd-coin',
+ },
{
underlyingToken: {
decimals: 18,
From 2b943cf1afee527c25f7bcf7428f18fe9e54ee78 Mon Sep 17 00:00:00 2001
From: kkatusic
Date: Thu, 28 Nov 2024 20:05:47 +0100
Subject: [PATCH 2/7] started diagnostic
---
.../views/donate/Recurring/RecurringDonationCard.tsx | 3 +++
src/helpers/donate.ts | 1 +
2 files changed, 4 insertions(+)
diff --git a/src/components/views/donate/Recurring/RecurringDonationCard.tsx b/src/components/views/donate/Recurring/RecurringDonationCard.tsx
index 23d373f345..bd359cff9d 100644
--- a/src/components/views/donate/Recurring/RecurringDonationCard.tsx
+++ b/src/components/views/donate/Recurring/RecurringDonationCard.tsx
@@ -162,6 +162,8 @@ export const RecurringDonationCard = () => {
const tokenBalance = balance?.value;
const tokenStream = tokenStreams[selectedRecurringToken?.token.id || ''];
+ console.log({ tokenStreams });
+
const anchorContractAddress = useMemo(
() => findAnchorContractAddress(project.anchorContracts),
[project.anchorContracts],
@@ -533,6 +535,7 @@ export const RecurringDonationCard = () => {
)}
+ AAAA
{tokenStream?.length > 0 && (
<>
diff --git a/src/helpers/donate.ts b/src/helpers/donate.ts
index e45dc72ed4..e5615353a2 100644
--- a/src/helpers/donate.ts
+++ b/src/helpers/donate.ts
@@ -35,6 +35,7 @@ export const findUserActiveStreamOnSelectedToken = (
};
export const countActiveStreams = (tokenStreams: ISuperfluidStream[]) => {
+ console.log('tokenStreams', tokenStreams);
return (
tokenStreams.filter(stream => stream.currentFlowRate !== '0').length ||
0
From 7b1534aa6f78f58789060ed85e5c2bb571be002b Mon Sep 17 00:00:00 2001
From: kkatusic
Date: Thu, 28 Nov 2024 21:28:59 +0100
Subject: [PATCH 3/7] fixing missing streams
---
.../views/donate/Recurring/RecurringDonationCard.tsx | 3 ---
.../Recurring/SelectTokenModal/SelectTokenModal.tsx | 8 ++++++--
src/helpers/donate.ts | 1 -
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/components/views/donate/Recurring/RecurringDonationCard.tsx b/src/components/views/donate/Recurring/RecurringDonationCard.tsx
index bd359cff9d..23d373f345 100644
--- a/src/components/views/donate/Recurring/RecurringDonationCard.tsx
+++ b/src/components/views/donate/Recurring/RecurringDonationCard.tsx
@@ -162,8 +162,6 @@ export const RecurringDonationCard = () => {
const tokenBalance = balance?.value;
const tokenStream = tokenStreams[selectedRecurringToken?.token.id || ''];
- console.log({ tokenStreams });
-
const anchorContractAddress = useMemo(
() => findAnchorContractAddress(project.anchorContracts),
[project.anchorContracts],
@@ -535,7 +533,6 @@ export const RecurringDonationCard = () => {
)}
- AAAA
{tokenStream?.length > 0 && (
<>
diff --git a/src/components/views/donate/Recurring/SelectTokenModal/SelectTokenModal.tsx b/src/components/views/donate/Recurring/SelectTokenModal/SelectTokenModal.tsx
index 806ad772ca..203710aab5 100644
--- a/src/components/views/donate/Recurring/SelectTokenModal/SelectTokenModal.tsx
+++ b/src/components/views/donate/Recurring/SelectTokenModal/SelectTokenModal.tsx
@@ -128,8 +128,12 @@ const SelectTokenInnerModal: FC = ({
})}
{Object.keys(tokenStreams).map(tokenId => {
+ console.log(new Date());
+ console.log(tokenId);
const token = superTokens.find(
- token => token.id === tokenId,
+ token =>
+ token.id.toLowerCase() ===
+ tokenId.toLowerCase(),
) as IToken;
return token ? (
= ({
) : null;
})}
{superTokens.map(token =>
- tokenStreams[token.id] ||
+ tokenStreams[token.id.toLowerCase()] ||
balances[token.symbol] === 0n ? null : (
{
- console.log('tokenStreams', tokenStreams);
return (
tokenStreams.filter(stream => stream.currentFlowRate !== '0').length ||
0
From 0ce1b94a06d38a06975d82877fe7946c2548f050 Mon Sep 17 00:00:00 2001
From: kkatusic
Date: Thu, 28 Nov 2024 21:30:10 +0100
Subject: [PATCH 4/7] removing console logs
---
.../donate/Recurring/SelectTokenModal/SelectTokenModal.tsx | 2 --
1 file changed, 2 deletions(-)
diff --git a/src/components/views/donate/Recurring/SelectTokenModal/SelectTokenModal.tsx b/src/components/views/donate/Recurring/SelectTokenModal/SelectTokenModal.tsx
index 203710aab5..a6d05cc392 100644
--- a/src/components/views/donate/Recurring/SelectTokenModal/SelectTokenModal.tsx
+++ b/src/components/views/donate/Recurring/SelectTokenModal/SelectTokenModal.tsx
@@ -128,8 +128,6 @@ const SelectTokenInnerModal: FC = ({
})}
{Object.keys(tokenStreams).map(tokenId => {
- console.log(new Date());
- console.log(tokenId);
const token = superTokens.find(
token =>
token.id.toLowerCase() ===
From 664c79ac9de2c22245d43c67f53bcb035181fb5f Mon Sep 17 00:00:00 2001
From: kkatusic
Date: Thu, 28 Nov 2024 21:42:34 +0100
Subject: [PATCH 5/7] fixing modify stream balance
---
.../views/donate/Recurring/RecurringDonationCard.tsx | 7 +++++--
.../donate/Recurring/SelectTokenModal/SelectTokenModal.tsx | 2 +-
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/components/views/donate/Recurring/RecurringDonationCard.tsx b/src/components/views/donate/Recurring/RecurringDonationCard.tsx
index 23d373f345..8ad2737caf 100644
--- a/src/components/views/donate/Recurring/RecurringDonationCard.tsx
+++ b/src/components/views/donate/Recurring/RecurringDonationCard.tsx
@@ -160,7 +160,8 @@ export const RecurringDonationCard = () => {
(perMonthAmount * BigInt(100 - donationToGiveth)) / 100n;
const givethPerMonth = perMonthAmount - projectPerMonth;
const tokenBalance = balance?.value;
- const tokenStream = tokenStreams[selectedRecurringToken?.token.id || ''];
+ const tokenStream =
+ tokenStreams[selectedRecurringToken?.token.id.toLowerCase() || ''];
const anchorContractAddress = useMemo(
() => findAnchorContractAddress(project.anchorContracts),
@@ -776,7 +777,9 @@ export const RecurringDonationCard = () => {
{showTopUpModal && selectedRecurringToken && (
= ({
return token ? (
Date: Thu, 28 Nov 2024 17:04:55 -0600
Subject: [PATCH 6/7] fix token decimals and symbols on withdraw and summary
views
---
.../ModifySuperToken/WithDrawSuperToken.tsx | 2 +-
.../Recurring/RecurringDonationModal/Item.tsx | 13 +++--------
.../donationsTab/recurringTab/StreamRow.tsx | 22 ++++++++++++++-----
src/config/production.tsx | 10 ++++-----
4 files changed, 25 insertions(+), 22 deletions(-)
diff --git a/src/components/views/donate/Recurring/ModifySuperToken/WithDrawSuperToken.tsx b/src/components/views/donate/Recurring/ModifySuperToken/WithDrawSuperToken.tsx
index 4c9e2dbe3d..f0f1e5cd9e 100644
--- a/src/components/views/donate/Recurring/ModifySuperToken/WithDrawSuperToken.tsx
+++ b/src/components/views/donate/Recurring/ModifySuperToken/WithDrawSuperToken.tsx
@@ -187,7 +187,7 @@ export const WithDrawSuperToken: FC = ({
title='Withdraw from this stream balance'
amount={amount}
price={tokenPrice}
- token={token!}
+ token={superToken!}
/>
= ({
{limitFraction(
- formatUnits(
- amount,
- token.underlyingToken?.decimals ||
- token.decimals ||
- 18,
- ),
+ formatUnits(amount, token.decimals || 18),
)}
- {token.symbol}
+ {token.underlyingToken?.symbol || token.symbol}
{subtext}
@@ -49,9 +44,7 @@ export const Item: FC = ({
.multipliedBy(amount.toString())
.toFixed(0),
),
- token.underlyingToken?.decimals ||
- token.decimals ||
- 18,
+ token.decimals || 18,
),
2,
)}
diff --git a/src/components/views/userProfile/donationsTab/recurringTab/StreamRow.tsx b/src/components/views/userProfile/donationsTab/recurringTab/StreamRow.tsx
index 353678be1c..abd937afe3 100644
--- a/src/components/views/userProfile/donationsTab/recurringTab/StreamRow.tsx
+++ b/src/components/views/userProfile/donationsTab/recurringTab/StreamRow.tsx
@@ -1,4 +1,4 @@
-import { useState, type FC } from 'react';
+import { useState, useMemo, type FC } from 'react';
import styled from 'styled-components';
import { P, brandColors, semanticColors } from '@giveth/ui-design-system';
import { formatUnits } from 'viem';
@@ -8,7 +8,7 @@ import { TokenIcon } from '@/components/views/donate/TokenIcon/TokenIcon';
import { TableCell } from './ActiveStreamsSection';
import { ISuperfluidStream } from '@/types/superFluid';
import { ONE_MONTH_SECONDS } from '@/lib/constants/constants';
-import { limitFraction } from '@/helpers/number';
+import { limitFraction, formatDonation } from '@/helpers/number';
import config from '@/configuration';
import { countActiveStreams } from '@/helpers/donate';
import { findTokenByAddress } from '@/helpers/superfluid';
@@ -19,6 +19,16 @@ interface IStreamRowProps {
}
export const StreamRow: FC = ({ tokenStream }) => {
+ const superToken = useMemo(
+ () =>
+ config.OPTIMISM_CONFIG.SUPER_FLUID_TOKENS.find(
+ s => s.id === tokenStream[0].token.id,
+ ),
+ [tokenStream],
+ );
+ console.log('tokenStream', tokenStream);
+ console.log('config', config.OPTIMISM_CONFIG.SUPER_FLUID_TOKENS);
+ // console.log('superToken', superToken);
const [showModifyModal, setShowModifyModal] = useState(false);
const { address, chain } = useAccount();
const { switchChain } = useSwitchChain();
@@ -39,7 +49,7 @@ export const StreamRow: FC = ({ tokenStream }) => {
0n,
);
const monthlyFlowRate = totalFlowRate * ONE_MONTH_SECONDS;
- const { symbol, decimals } = tokenStream[0].token;
+ // const { symbol } = tokenStream[0].token;
const runOutMonth =
monthlyFlowRate > 0 && balance?.value
? balance?.value / monthlyFlowRate
@@ -57,12 +67,12 @@ export const StreamRow: FC = ({ tokenStream }) => {
)
: '0'}
- {symbol}
+ {superToken?.symbol}
- {limitFraction(
- formatUnits(monthlyFlowRate || 0n, decimals),
+ {formatDonation(
+ limitFraction(formatUnits(BigInt(monthlyFlowRate), 18)),
)}
{underlyingSymbol}
diff --git a/src/config/production.tsx b/src/config/production.tsx
index 40c9d9d710..3396524042 100644
--- a/src/config/production.tsx
+++ b/src/config/production.tsx
@@ -526,13 +526,13 @@ const config: EnvConfig = {
underlyingToken: {
decimals: 6,
id: '0x7f5c764cbc14f9669b88837ca1490cca17c31607',
- name: 'USD Coin',
+ name: 'Bridged USD Coin',
symbol: 'USDC.e',
coingeckoId: 'usd-coin',
},
decimals: 18,
id: '0x8430f084b939208e2eded1584889c9a66b90562f',
- name: 'Super USD Coin',
+ name: 'Super Bridged USD Coin',
symbol: 'USDC.ex',
isSuperToken: true,
coingeckoId: 'usd-coin',
@@ -546,7 +546,7 @@ const config: EnvConfig = {
coingeckoId: 'usd-coin',
},
decimals: 18,
- id: '0x35Adeb0638EB192755B6E52544650603Fe65A006',
+ id: '0x35adeb0638eb192755b6e52544650603fe65a006',
name: 'Super USD Coin',
symbol: 'USDCx',
isSuperToken: true,
@@ -555,13 +555,13 @@ const config: EnvConfig = {
{
underlyingToken: {
decimals: 18,
- id: '0x4F604735c1cF31399C6E711D5962b2B3E0225AD3',
+ id: '0x4f604735c1cf31399c6e711d5962b2b3e0225ad3',
name: 'Glo Dollar',
symbol: 'USDGLO',
coingeckoId: 'glo-dollar',
},
decimals: 18,
- id: '0x9F41d0AA24E599fd8D0c180Ee3C0F609dc41c622',
+ id: '0x9f41d0aa24e599fd8d0c180ee3c0f609dc41c622',
name: 'Super Glo Dollar',
symbol: 'USDGLOx',
isSuperToken: true,
From 058091c321c4c25a46b11fa05c0f71f7c8d0f09c Mon Sep 17 00:00:00 2001
From: Mitch Oz
Date: Sun, 1 Dec 2024 20:44:52 -0600
Subject: [PATCH 7/7] fix usdc & usdc.e deposit decimals logic on upgrade
---
.../ModifySuperToken/DepositSuperToken.tsx | 15 ++++++++++++---
.../ModifySuperToken/ModifySuperTokenModal.tsx | 2 +-
.../donationsTab/recurringTab/StreamRow.tsx | 7 ++-----
3 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/src/components/views/donate/Recurring/ModifySuperToken/DepositSuperToken.tsx b/src/components/views/donate/Recurring/ModifySuperToken/DepositSuperToken.tsx
index 7396e7cb30..fb79d0c5e0 100644
--- a/src/components/views/donate/Recurring/ModifySuperToken/DepositSuperToken.tsx
+++ b/src/components/views/donate/Recurring/ModifySuperToken/DepositSuperToken.tsx
@@ -2,6 +2,7 @@ import { useState, type FC, useEffect } from 'react';
import { Button, Flex } from '@giveth/ui-design-system';
import { useAccount, useBalance } from 'wagmi';
import { useIntl } from 'react-intl';
+import { ethers } from 'ethers';
import { Framework } from '@superfluid-finance/sdk-core';
import { ISuperToken, IToken } from '@/types/superFluid';
import { AddressZero } from '@/lib/constants/constants';
@@ -125,6 +126,7 @@ export const DepositSuperToken: FC = ({
// EThx is not a Wrapper Super Token and should load separately
let superTokenAsset;
+ let newAmount = amount;
if (superToken.symbol === 'ETHx') {
superTokenAsset = await sf.loadNativeAssetSuperToken(
superToken.id,
@@ -132,10 +134,18 @@ export const DepositSuperToken: FC = ({
} else {
superTokenAsset = await sf.loadWrapperSuperToken(superToken.id);
}
+ if (token && token.decimals === 6) {
+ const divisor = BigInt(10 ** token.decimals);
+ const currentAmount = Number(amount) / Number(divisor);
+ newAmount = ethers.utils
+ .parseUnits(currentAmount.toString(), 18)
+ .toBigInt();
+ }
+ console.log('token', token);
+ console.log('supertoken', superToken);
const upgradeOperation = await superTokenAsset.upgrade({
- amount: amount.toString(),
+ amount: newAmount.toString(),
});
-
const tx = await upgradeOperation.exec(signer);
const res = await tx.wait();
if (!res.status) {
@@ -165,7 +175,6 @@ export const DepositSuperToken: FC = ({
closeModal();
}
};
-
return (
{step === EModifySuperTokenSteps.MODIFY ? (
diff --git a/src/components/views/donate/Recurring/ModifySuperToken/ModifySuperTokenModal.tsx b/src/components/views/donate/Recurring/ModifySuperToken/ModifySuperTokenModal.tsx
index a5a02b3812..39bc665f41 100644
--- a/src/components/views/donate/Recurring/ModifySuperToken/ModifySuperTokenModal.tsx
+++ b/src/components/views/donate/Recurring/ModifySuperToken/ModifySuperTokenModal.tsx
@@ -13,7 +13,7 @@ import { EModifySuperTokenSteps } from './common';
import config from '@/configuration';
interface IModifySuperTokenModalProps extends IModal {
- selectedToken: IToken;
+ selectedToken: ISuperToken | IToken;
tokenStreams: ISuperfluidStream[];
refreshBalance: () => void;
}
diff --git a/src/components/views/userProfile/donationsTab/recurringTab/StreamRow.tsx b/src/components/views/userProfile/donationsTab/recurringTab/StreamRow.tsx
index abd937afe3..7df4fbd631 100644
--- a/src/components/views/userProfile/donationsTab/recurringTab/StreamRow.tsx
+++ b/src/components/views/userProfile/donationsTab/recurringTab/StreamRow.tsx
@@ -26,9 +26,6 @@ export const StreamRow: FC = ({ tokenStream }) => {
),
[tokenStream],
);
- console.log('tokenStream', tokenStream);
- console.log('config', config.OPTIMISM_CONFIG.SUPER_FLUID_TOKENS);
- // console.log('superToken', superToken);
const [showModifyModal, setShowModifyModal] = useState(false);
const { address, chain } = useAccount();
const { switchChain } = useSwitchChain();
@@ -119,11 +116,11 @@ export const StreamRow: FC = ({ tokenStream }) => {
Deposit/Withdraw
- {showModifyModal && (
+ {showModifyModal && superToken && (
)}