Skip to content
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
1 change: 1 addition & 0 deletions public/icons/markets/horizon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 1 addition & 12 deletions public/icons/other/velora.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/icons/tokens/buidl.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/icons/tokens/jaaa.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/icons/tokens/jtrsy.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/icons/tokens/uscc.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/icons/tokens/ustb.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/icons/tokens/usyc.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 31 additions & 3 deletions src/components/transactions/Emode/EmodeModalContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import { useModalContext } from 'src/hooks/useModal';
import { useWeb3Context } from 'src/libs/hooks/useWeb3Context';
import { useRootStore } from 'src/store/root';
import { getNetworkConfig } from 'src/utils/marketsAndNetworksConfig';
import { useShallow } from 'zustand/shallow';

import { TxErrorView } from '../FlowCommons/Error';
import { GasEstimationError } from '../FlowCommons/GasEstimationError';
Expand Down Expand Up @@ -79,7 +80,9 @@ export const EmodeModalContent = ({ user }: { user: ExtendedFormattedUser }) =>
marketReferencePriceInUsd,
userReserves,
} = useAppDataContext();
const currentChainId = useRootStore((store) => store.currentChainId);
const [currentChainId, currentMarket] = useRootStore(
useShallow((store) => [store.currentChainId, store.currentMarket])
);
const { chainId: connectedChainId, readOnlyModeAddress } = useWeb3Context();
const currentTimestamp = useCurrentTimestamp(1);
const { gasLimit, mainTxState: emodeTxState, txError } = useModalContext();
Expand All @@ -95,8 +98,33 @@ export const EmodeModalContent = ({ user }: { user: ExtendedFormattedUser }) =>
])
);

// For Horizon markets, use the next available category after [1]
// For all other markets, use eModeCategories[1] (eth correlanted) as default when user has no eMode enabled (userEmodeCategoryId === 0)
const getDefaultEModeCategory = () => {
if (user.userEmodeCategoryId !== 0) {
return eModeCategories[user.userEmodeCategoryId];
}

const isHorizonMarket =
currentMarket.includes('proto_horizon_v3') ||
currentMarket.includes('fork_proto_horizon_v3') ||
currentMarket.includes('proto_sepolia_horizon_v3');

if (isHorizonMarket) {
// Find the next available category after [1], excluding USYC GHO
// TODO: Add USYC when its available
const availableCategories = Object.values(eModeCategories)
.filter((emode) => emode.id !== 0 && emode.id !== 1 && emode.label !== 'USYC GHO')
.sort((a, b) => a.id - b.id);

return availableCategories.length > 0 ? availableCategories[0] : eModeCategories[1];
}

return eModeCategories[1];
};

const [selectedEmode, setSelectedEmode] = useState<EModeCategoryDisplay>(
user.userEmodeCategoryId === 0 ? eModeCategories[1] : eModeCategories[user.userEmodeCategoryId]
getDefaultEModeCategory()
);
const networkConfig = getNetworkConfig(currentChainId);

Expand Down Expand Up @@ -292,7 +320,7 @@ export const EmodeModalContent = ({ user }: { user: ExtendedFormattedUser }) =>
onChange={(e) => selectEMode(Number(e.target.value))}
>
{Object.values(eModeCategories)
.filter((emode) => emode.id !== 0)
.filter((emode) => emode.id !== 0 && emode.label !== 'USYC GHO')
.sort((a, b) => {
if (a.available !== b.available) {
return a.available ? -1 : 1;
Expand Down
Loading
Loading