Skip to content
Open
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
9 changes: 7 additions & 2 deletions src/components/AddressBlocked.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@ export const AddressBlocked = ({ children }: { children: ReactNode }) => {
const { currentAccount, readOnlyMode } = useWeb3Context();
const { disconnect } = useDisconnect();
const screenAddress = readOnlyMode || ENABLE_TESTNET ? '' : currentAccount;
const { isAllowed } = useAddressAllowed(screenAddress);
const { isAllowed, message } = useAddressAllowed(screenAddress);

if (!isAllowed) {
return (
<MainLayout>
<AddressBlockedModal address={currentAccount} onDisconnectWallet={() => disconnect()} />;
<AddressBlockedModal
address={currentAccount}
onDisconnectWallet={() => disconnect()}
message={message}
/>
;
</MainLayout>
);
}
Expand Down
32 changes: 21 additions & 11 deletions src/components/AddressBlockedModal.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import { ExclamationCircleIcon, LogoutIcon } from '@heroicons/react/outline';
import { Trans } from '@lingui/macro';
import { Box, Button, SvgIcon, Typography } from '@mui/material';
import { Box, Button, Link, SvgIcon, Typography } from '@mui/material';

import { BasicModal } from './primitives/BasicModal';
import { Link } from './primitives/Link';

export interface AddressBlockedProps {
address: string;
onDisconnectWallet: () => void;
message?: string;
}

export const AddressBlockedModal = ({ address, onDisconnectWallet }: AddressBlockedProps) => {
export const AddressBlockedModal = ({
address,
onDisconnectWallet,
message,
}: AddressBlockedProps) => {
// eslint-disable-next-line @typescript-eslint/no-empty-function, @typescript-eslint/no-unused-vars
const setOpen = (_value: boolean) => {}; // ignore, we want the modal to not be dismissable

Expand All @@ -28,19 +32,25 @@ export const AddressBlockedModal = ({ address, onDisconnectWallet }: AddressBloc
<ExclamationCircleIcon />
</SvgIcon>
<Typography variant="h2">
<Trans>Blocked Address</Trans>
{message ? <Trans>Connection Failed</Trans> : <Trans>Blocked Address</Trans>}
</Typography>
<Typography variant="helperText" sx={{ my: 4 }}>
{address}
</Typography>
<Typography variant="description" sx={{ textAlign: 'center', mb: 4 }}>
<Trans>
This address is blocked on app.aave.com because it is associated with one or more
</Trans>{' '}
<Link href="https://docs.aave.com/faq/#address-screening" underline="always">
<Trans>blocked activities</Trans>
</Link>
{'.'}
{message ? (
message
) : (
<>
<Trans>
This address is blocked on app.aave.com because it is associated with one or more
</Trans>{' '}
<Link href="https://docs.aave.com/faq/#address-screening" underline="always">
<Trans>blocked activities</Trans>
</Link>
{'.'}
</>
)}
</Typography>
<Button variant="contained" onClick={onDisconnectWallet}>
<SvgIcon fontSize="small" sx={{ mx: 1 }}>
Expand Down
7 changes: 5 additions & 2 deletions src/components/TransactionEventHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import { useEffect, useRef } from 'react';
import { useRootStore } from 'src/store/root';
import { GENERAL } from 'src/utils/events';
import { getNetworkConfig } from 'src/utils/marketsAndNetworksConfig';
import { useShallow } from 'zustand/react/shallow';

export const TransactionEventHandler = () => {
const postedTransactionsRef = useRef<{ [chainId: string]: string[] }>({});

const trackEvent = useRootStore((store) => store.trackEvent);
const transactions = useRootStore((store) => store.transactions);
const [trackEvent, transactions, walletType] = useRootStore(
useShallow((store) => [store.trackEvent, store.transactions, store.walletType])
);

//tx's currently tracked: supply, borrow, withdraw, repay, repay with coll, collateral switch

Expand Down Expand Up @@ -42,6 +44,7 @@ export const TransactionEventHandler = () => {
outAmountUsd: tx.outAmountUsd,
chainId: chainIdNumber,
chainName: networkConfig.displayName || networkConfig.name,
walletType,
});

// update ref
Expand Down
28 changes: 24 additions & 4 deletions src/components/incentives/MeritIncentivesTooltipContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ interface CampaignConfig {
hasSpecialContent: boolean;
}

const ENABLE_SAFE_CAMPAIGN = true;

const isCeloAction = (action: MeritAction): boolean => {
return [
MeritAction.CELO_SUPPLY_CELO,
Expand All @@ -36,8 +38,25 @@ const isCeloAction = (action: MeritAction): boolean => {
MeritAction.CELO_BORROW_WETH,
].includes(action);
};

const selfCampaignConfig: Map<MeritAction, { limit: string; token: string }> = new Map([
[
MeritAction.CELO_SUPPLY_USDT,
{
token: 'USDT',
limit: 'the first $1,000 USDT supplied',
},
],
[
MeritAction.CELO_SUPPLY_WETH,
{
token: 'ETH',
limit: 'the first $35,000 of ETH supplied',
},
],
]);
const isSelfVerificationCampaign = (action: MeritAction): boolean =>
action === MeritAction.CELO_SUPPLY_USDT;
selfCampaignConfig.has(action) && ENABLE_SAFE_CAMPAIGN;

const getCampaignConfig = (action: MeritAction): CampaignConfig => {
if (isSelfVerificationCampaign(action)) {
Expand Down Expand Up @@ -71,6 +90,7 @@ export const MeritIncentivesTooltipContent = ({
const meritIncentivesFormatted = getSymbolMap(meritIncentives);

const campaignConfig = getCampaignConfig(meritIncentives.action);
const selfConfig = selfCampaignConfig.get(meritIncentives.action);

return (
<Box
Expand Down Expand Up @@ -116,11 +136,11 @@ export const MeritIncentivesTooltipContent = ({
</Link>
</Typography>

{campaignConfig.type === CampaignType.SELF_VERIFICATION && (
{campaignConfig.type === CampaignType.SELF_VERIFICATION && selfConfig && (
<>
<Typography variant="caption" color="text.secondary">
<Trans>
Supply USDT and double your yield by{' '}
Supply {selfConfig.token} and double your yield by{' '}
<span>
<Link
href="https://aave.self.xyz/"
Expand All @@ -131,7 +151,7 @@ export const MeritIncentivesTooltipContent = ({
verifying your humanity through Self
</Link>
</span>{' '}
for the first $1,000 USDT supplied per user.
for {selfConfig.limit} per user.
</Trans>{' '}
</Typography>
<Typography variant="caption" color="text.secondary">
Expand Down
6 changes: 5 additions & 1 deletion src/hooks/useAddressAllowed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import { usePolling } from './usePolling';

export interface AddressAllowedResult {
isAllowed: boolean;
message?: string;
}

const TWO_MINUTES = 2 * 60 * 1000;

export const useAddressAllowed = (address: string): AddressAllowedResult => {
const [isAllowed, setIsAllowed] = useState(true);
const [message, setMessage] = useState<string | undefined>(undefined);

const screeningUrl = `${process.env.NEXT_PUBLIC_API_BASEURL}/addresses/status`;
const queryParams = `?address=${address}`;
Expand All @@ -19,8 +21,9 @@ export const useAddressAllowed = (address: string): AddressAllowedResult => {
try {
const response = await fetch(screeningUrl + queryParams);
if (response.ok) {
const data: { addressAllowed: boolean } = await response.json();
const data: { addressAllowed: boolean; message?: string } = await response.json();
setIsAllowed(data.addressAllowed);
setMessage(data.message);
}
} catch (e) {}
} else {
Expand All @@ -32,5 +35,6 @@ export const useAddressAllowed = (address: string): AddressAllowedResult => {

return {
isAllowed,
message,
};
};
15 changes: 8 additions & 7 deletions src/hooks/useMeritIncentives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -673,13 +673,14 @@ export const MERIT_DATA_MAP: Record<string, Record<string, MeritReserveIncentive
protocolAction: ProtocolAction.supply,
customMessage: antiLoopMessage,
},
{
action: MeritAction.CELO_SUPPLY_MULTIPLE_BORROW_USDT,
rewardTokenAddress: AaveV3Celo.ASSETS.CELO.A_TOKEN,
rewardTokenSymbol: 'aCelCELO',
protocolAction: ProtocolAction.supply,
customMessage: celoSupplyMultipleBorrowUsdtMessage,
},
// To re-enable when you support 2 incentive
// {
// action: MeritAction.CELO_SUPPLY_MULTIPLE_BORROW_USDT,
// rewardTokenAddress: AaveV3Celo.ASSETS.CELO.A_TOKEN,
// rewardTokenSymbol: 'aCelCELO',
// protocolAction: ProtocolAction.supply,
// customMessage: celoSupplyMultipleBorrowUsdtMessage,
// },
{
action: MeritAction.CELO_BORROW_WETH,
rewardTokenAddress: AaveV3Celo.ASSETS.CELO.A_TOKEN,
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.

12 changes: 8 additions & 4 deletions src/locales/en/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -1269,10 +1269,6 @@ msgstr "Wallet balance"
msgid "Borrow balance after repay"
msgstr "Borrow balance after repay"

#: src/components/incentives/MeritIncentivesTooltipContent.tsx
msgid "Supply USDT and double your yield by <0><1>verifying your humanity through Self</1></0> for the first $1,000 USDT supplied per user."
msgstr "Supply USDT and double your yield by <0><1>verifying your humanity through Self</1></0> for the first $1,000 USDT supplied per user."

#: src/modules/migration/MigrationLists.tsx
msgid "Supplied assets"
msgstr "Supplied assets"
Expand Down Expand Up @@ -3176,6 +3172,10 @@ msgstr "The caller of this function must be a pool"
msgid "Migrate to V3"
msgstr "Migrate to V3"

#: src/components/AddressBlockedModal.tsx
msgid "Connection Failed"
msgstr "Connection Failed"

#: src/modules/reserve-overview/ReserveConfiguration.tsx
msgid "Interest rate strategy"
msgstr "Interest rate strategy"
Expand Down Expand Up @@ -3405,6 +3405,10 @@ msgstr "Remove"
msgid "Auto Slippage"
msgstr "Auto Slippage"

#: src/components/incentives/MeritIncentivesTooltipContent.tsx
msgid "Supply {0} and double your yield by <0><1>verifying your humanity through Self</1></0> for {1} per user."
msgstr "Supply {0} and double your yield by <0><1>verifying your humanity through Self</1></0> for {1} per user."

#: src/modules/reserve-overview/ReserveTopDetails.tsx
msgid "Oracle price"
msgstr "Oracle price"
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.

Loading