Skip to content

Feat/umbrella final #2406

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"test:coverage": "jest --coverage"
},
"dependencies": {
"@aave/contract-helpers": "1.33.0",
"@aave/contract-helpers": "1.33.1-07752485b0e3b6582efa1c636fad5c267b2c6d04.0",
"@aave/math-utils": "1.33.0",
"@bgd-labs/aave-address-book": "^4.17.1",
"@emotion/cache": "11.10.3",
Expand Down
2 changes: 1 addition & 1 deletion src/locales/el/messages.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/locales/en/messages.js

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions src/locales/en/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -2089,10 +2089,6 @@ msgstr "Addresses"
msgid "The requested amount is greater than the max loan size in stable rate mode"
msgstr "The requested amount is greater than the max loan size in stable rate mode"

#: src/modules/umbrella/UnstakeModalContent.tsx
msgid "Redeem as {0}"
msgstr "Redeem as {0}"

#: pages/index.page.tsx
#: src/components/transactions/Supply/SupplyModal.tsx
#: src/modules/dashboard/lists/SuppliedPositionsList/SuppliedPositionsListItem.tsx
Expand Down
2 changes: 1 addition & 1 deletion src/locales/es/messages.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/locales/fr/messages.js

Large diffs are not rendered by default.

23 changes: 1 addition & 22 deletions src/modules/umbrella/AvailableToStakeItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Box, Stack, Typography } from '@mui/material';
import { FormattedNumber } from 'src/components/primitives/FormattedNumber';
import { TokenIcon } from 'src/components/primitives/TokenIcon';
import { MergedStakeData } from 'src/hooks/stake/useUmbrellaSummary';
import { useRootStore } from 'src/store/root';

import { AmountAvailableItem } from './helpers/AmountAvailableItem';
import { MultiIconWithTooltip } from './helpers/MultiIcon';
Expand All @@ -21,15 +20,7 @@ export const AvailableToStakeItem = ({
underlyingTokenBalance,
} = stakeData.formattedBalances;

const currentNetworkConfig = useRootStore((store) => store.currentNetworkConfig);

const icons = [];
if (stakeData.stataTokenData.isUnderlyingWrappedBaseToken) {
icons.push({
src: currentNetworkConfig.baseAssetSymbol,
aToken: false,
});
}
if (underlyingTokenBalance) {
icons.push({
src: stakeData.stataTokenData.assetSymbol,
Expand All @@ -50,15 +41,11 @@ export const AvailableToStakeItem = ({
});
}

let totalAvailableToStake =
const totalAvailableToStake =
Number(underlyingTokenBalance) +
Number(underlyingWaTokenBalance) +
Number(aTokenBalanceAvailableToStake);

if (stakeData.stataTokenData.isUnderlyingWrappedBaseToken) {
totalAvailableToStake += Number(stakeData.formattedBalances.nativeTokenBalance);
}

return (
<Stack
direction={isMobile ? 'row' : 'column'}
Expand Down Expand Up @@ -92,21 +79,13 @@ export const AvailableToStakeTooltipContent = ({ stakeData }: { stakeData: Merge
} = stakeData.formattedBalances;

const { assetSymbol } = stakeData.stataTokenData;
const currentNetworkConfig = useRootStore((store) => store.currentNetworkConfig);

return (
<Stack direction="column" alignItems="center" justifyContent="center" minWidth={160}>
<Typography variant="caption" color="text.secondary" mb={3}>
<Trans>Your balance of assets that are available to stake</Trans>
</Typography>
<Box sx={{ width: '100%' }}>
{stakeData.stataTokenData.isUnderlyingWrappedBaseToken && (
<AmountAvailableItem
symbol={currentNetworkConfig.baseAssetSymbol}
name={currentNetworkConfig.baseAssetSymbol}
value={stakeData.formattedBalances.nativeTokenBalance}
/>
)}
{underlyingWaTokenBalance && (
<AmountAvailableItem
symbol={assetSymbol}
Expand Down
19 changes: 3 additions & 16 deletions src/modules/umbrella/UmbrellaModalContent.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { API_ETH_MOCK_ADDRESS } from '@aave/contract-helpers';
import { USD_DECIMALS, valueToBigNumber } from '@aave/math-utils';
import { Trans } from '@lingui/macro';
import { Box, Checkbox, Skeleton, Stack, Typography } from '@mui/material';
Expand Down Expand Up @@ -26,7 +25,6 @@ import { MergedStakeData } from 'src/hooks/stake/useUmbrellaSummary';
import { useIsWrongNetwork } from 'src/hooks/useIsWrongNetwork';
import { useModalContext } from 'src/hooks/useModal';
import { useRootStore } from 'src/store/root';
import { NetworkConfig } from 'src/ui-config/networksConfig';
import { calculateHFAfterWithdraw } from 'src/utils/hfUtils';
import { STAKE } from 'src/utils/mixPanelEvents';
import { roundToTokenDecimals } from 'src/utils/utils';
Expand Down Expand Up @@ -54,10 +52,7 @@ export interface StakeInputAsset {
balance: string;
}

const getInputTokens = (
stakeData: MergedStakeData,
networkConfig: NetworkConfig
): StakeInputAsset[] => {
const getInputTokens = (stakeData: MergedStakeData): StakeInputAsset[] => {
const assets = stakeData.underlyingIsStataToken
? [
// stata token
Expand All @@ -84,14 +79,6 @@ const getInputTokens = (
balance: stakeData.formattedBalances.underlyingTokenBalance,
},
];
if (stakeData.stataTokenData.isUnderlyingWrappedBaseToken) {
assets.push({
address: API_ETH_MOCK_ADDRESS,
symbol: networkConfig.baseAssetSymbol,
iconSymbol: networkConfig.baseAssetSymbol,
balance: stakeData.formattedBalances.nativeTokenBalance,
});
}
assets.sort((a, b) => +b.balance - +a.balance);
return assets;
};
Expand All @@ -103,11 +90,11 @@ export const UmbrellaModalContent = ({ stakeData, user, userReserve, poolReserve
// states
const [_amount, setAmount] = useState('');

const [currentChainId, currentNetworkConfig] = useRootStore(
const [currentChainId] = useRootStore(
useShallow((store) => [store.currentChainId, store.currentNetworkConfig])
);

const assets = getInputTokens(stakeData, currentNetworkConfig);
const assets = getInputTokens(stakeData);

const [inputToken, setInputToken] = useState<StakeInputAsset>(assets[0]);

Expand Down
15 changes: 0 additions & 15 deletions src/modules/umbrella/UnstakeModalContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,6 @@ export const UnStakeModalContent = ({ stakeData }: { stakeData: MergedStakeData
setRedeemType(value ? RedeemType.ATOKEN : RedeemType.NORMAL);
};

const setRedeemNativeTokens = (value: boolean) => {
setRedeemType(value ? RedeemType.NATIVE : RedeemType.NORMAL);
};

const symbolFormatted = stakeData.underlyingIsStataToken
? stakeData.stataTokenData.assetSymbol
: stakeData.underlyingTokenSymbol;
Expand Down Expand Up @@ -169,17 +165,6 @@ export const UnStakeModalContent = ({ stakeData }: { stakeData: MergedStakeData
}
/>
)}
{stakeData.stataTokenData.isUnderlyingWrappedBaseToken && (
<DetailsUnwrapSwitch
unwrapped={redeemType === RedeemType.NATIVE}
setUnWrapped={setRedeemNativeTokens}
label={
<Typography>
<Trans>{`Redeem as ${currentNetworkConfig.baseAssetSymbol}`}</Trans>
</Typography>
}
/>
)}

{stakeData.underlyingIsStataToken ? (
<TxModalDetails gasLimit={gasLimit} chainId={currentChainId}>
Expand Down
6 changes: 3 additions & 3 deletions src/services/UmbrellaStakeDataService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ interface StakeUmbrellaConfig {
export const stakeUmbrellaConfig: StakeUmbrellaConfig = {
// [ChainId.mainnet]: {}, // TODO: Mainnet addresses
[ChainId.base_sepolia]: {
stakeDataProvider: '0x4d6f6e98d262ba7eebcd811ffae904cb46a5d344',
batchHelper: '0xAaA87d031d991B6faAb8076AAea518072Fc8E6F2',
stakeRewardsController: '0x8dd1E13fe050C6319eD74d540ACF2a9603C08Fe8',
stakeDataProvider: '0xD80c9F7C6d5359558E2F3F32Faa4a48D8224F4c6',
batchHelper: '0xcDfb3f2d924b02A78a51F43BC34610dC62ADCEC3',
stakeRewardsController: '0x412f8957f9A42FFe47B634AB73f89Ff4E0a29026',
},
};

Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# yarn lockfile v1


"@aave/[email protected]":
version "1.33.0"
resolved "https://registry.yarnpkg.com/@aave/contract-helpers/-/contract-helpers-1.33.0.tgz#d58f44c83737dfe3ab04b3776f1133064e08ebc6"
integrity sha512-hwOG+B6LYv8/oZIW3OYPZqr2OwEVYLWXO230h3LfUpG9P4+MhknZeyuJHRA7uGNpj2dpP/KYuLrYYfx4G9D0aQ==
"@aave/[email protected].1-07752485b0e3b6582efa1c636fad5c267b2c6d04.0":
version "1.33.1-07752485b0e3b6582efa1c636fad5c267b2c6d04.0"
resolved "https://registry.yarnpkg.com/@aave/contract-helpers/-/contract-helpers-1.33.1-07752485b0e3b6582efa1c636fad5c267b2c6d04.0.tgz#494631939065178079b13f063b253bf5af1e9850"
integrity sha512-RQVEZfyQSUdRgI+dbiNDYg3ph5WesCNcVepNKaR/QTruwOBwKhzRkXPgq2fe0DEpKCwpBUUtw6Kj3V6gJgWhjQ==
dependencies:
isomorphic-unfetch "^3.1.0"

Expand Down