diff --git a/package.json b/package.json
index ea138f2..b097b2f 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "ghost-dao-interface",
"private": true,
- "version": "0.8.12",
+ "version": "0.8.14",
"type": "module",
"scripts": {
"dev": "vite",
diff --git a/src/App.jsx b/src/App.jsx
index 53da5bc..7cff994 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -43,6 +43,7 @@ const Governance = lazy(() => import("./containers/Governance/Governance"));
const ProposalDetails = lazy(() => import("./containers/Governance/ProposalDetails"));
const NewProposal = lazy(() => import("./containers/Governance/NewProposal"));
const History = lazy(() => import("./containers/History/History"));
+const Exodus = lazy(() => import("./containers/Exodus/Exodus"));
const PREFIX = "App";
@@ -208,6 +209,7 @@ function App() {
} />
} />
} />
+ } />
}
{
}
/>
-
+
+
{/* */}
diff --git a/src/containers/Bridge/BridgeConfirmationModal.jsx b/src/containers/Bridge/BridgeConfirmationModal.jsx
index 857f0ea..1ff2b2e 100644
--- a/src/containers/Bridge/BridgeConfirmationModal.jsx
+++ b/src/containers/Bridge/BridgeConfirmationModal.jsx
@@ -74,7 +74,7 @@ export const BridgeInConfirmationModal = ({
+ />
{
estimatedOutAmount={estimatedOutAmount}
formatDecimals={formatDecimals}
ghstSymbol={ghstSymbol}
- nativeSymbol={nativeSymbol}
externalSymbol={chainProperties ? chainProperties.properties.tokenSymbol : "CSPR"}
receiver={customReceiver ? customReceiver : receiver}
sender={account}
@@ -518,7 +517,7 @@ const BridgeOut = ({ chainId, address, config, connect }) => {
}
/>
-
+
Min Bridge-Out}
tooltip="Minimum amount that could be handled by the bridge to avoid dust balances."
diff --git a/src/containers/Exodus/Exodus.jsx b/src/containers/Exodus/Exodus.jsx
new file mode 100644
index 0000000..3cffdd3
--- /dev/null
+++ b/src/containers/Exodus/Exodus.jsx
@@ -0,0 +1,661 @@
+import useSWR from "swr";
+import { useMemo, useState, useCallback } from "react";
+import { useGasPrice } from 'wagmi';
+import { keccak256, hexToBytes, getAddress, toHex } from 'viem';
+
+import {
+ Box,
+ Divider,
+ Link,
+ CircularProgress,
+ Container,
+ Typography,
+ Skeleton,
+ TableContainer,
+ TableCell,
+ Table,
+ TableHead,
+ TableRow,
+ TableBody,
+ useMediaQuery,
+ useTheme,
+} from "@mui/material";
+
+import SearchIcon from '@mui/icons-material/Search';
+import CloseIcon from '@mui/icons-material/Close';
+
+import Chip from "../../components/Chip/Chip";
+import Modal from "../../components/Modal/Modal";
+import Paper from "../../components/Paper/Paper";
+import Metric from "../../components/Metric/Metric";
+import { Tab, Tabs } from "../../components/Tabs/Tabs";
+import DataRow from "../../components/DataRow/DataRow";
+import PageTitle from "../../components/PageTitle/PageTitle";
+import GhostStyledIcon from "../../components/Icon/GhostIcon";
+import TokenStack from "../../components/TokenStack/TokenStack";
+import MetricCollection from "../../components/Metric/MetricCollection";
+import { PrimaryButton, TertiaryButton } from "../../components/Button";
+import LinearProgressBar from "../../components/Progress/LinearProgressBar";
+
+import { useTotalReserves, useCapturedPriceSnapshots } from "../../hooks/treasury";
+import { useCurrentGasPrice, useIsTransactionExecuted } from "../../hooks/staking";
+import { useFtsoPrice, useReservePrice } from "../../hooks/prices";
+import { useTokenSymbol } from "../../hooks/tokens";
+import { useUniswapV2Pair } from "../../hooks/uniswapv2";
+import { useUnstableProvider } from "../../hooks/ghost";
+import { getTokenAddress, getTokenDecimals } from "../../hooks/helpers";
+
+import { formatCurrency, formatNumber, shorten } from "../../helpers";
+import { DecimalBigNumber } from "../../helpers/DecimalBigNumber";
+import { UNISWAP_V2_FACTORY } from "../../constants/addresses";
+
+const SELECTABLE_OPTIONS = ["All Exoduses", "Rotations", "Governance", "Bridge-Out"];
+
+const KEY_ROTATION = "Key Rotation";
+
+const GAS_USED = {
+ [KEY_ROTATION]: 300000n,
+}
+
+const ExodusStatusCard = ({ progressPercent, executionDiscount, currentGasPrice, maxGasPrice }) => {
+ const theme = useTheme();
+
+ return (
+
+
+
+ Execution Discount:
+ 0
+ ? theme.colors.feedback.success
+ : theme.colors.feedback.error
+ }}>
+ {formatNumber(executionDiscount, 2)}%
+
+
+
+
+ Gas Price:
+ {`${formatNumber(currentGasPrice, 5)} / ${formatNumber(maxGasPrice, 5)} gwei`}
+
+
+
+
+
+
+ );
+};
+
+const ExodusItem = ({
+ item,
+ chainId,
+ gasPrice,
+ ftsoSymbol,
+ nativeMetadata,
+ setVerifiedItem,
+ isSmallScreen,
+ currentTwapPrice
+}) => {
+ const theme = useTheme();
+ const isVerySmallScreen = useMediaQuery("(max-width: 450px)");
+
+ const {
+ isTransactionExecuted,
+ isTransactionExecutedLoading
+ } = useIsTransactionExecuted(chainId, item.data.at(0)?.session);
+
+ const chipStatus = useMemo(() => {
+ const width = isVerySmallScreen ? "21px" : "100px";
+
+ if (isTransactionExecuted && !isTransactionExecutedLoading) {
+ return
+ }
+
+ return
+ }, [isTransactionExecutedLoading, isTransactionExecuted]);
+
+ if (isSmallScreen || isVerySmallScreen) {
+ return (
+ <>
+
+
+
+
+
+ {item.type}
+
+ {"Something here"}
+
+
+
+
+
+ {chipStatus}
+
+
+
+
+
+ {nativeMetadata.symbol} Cost
+ {
+ formatCurrency(
+ currentTwapPrice(gasPrice * GAS_USED[item.type]).toString(),
+ 5,
+ ftsoSymbol
+ )
+ }
+
+
+
+ Reward
+
+ {formatCurrency(
+ new DecimalBigNumber(gasPrice * GAS_USED[item.type], 18),
+ 5,
+ nativeMetadata.symbol
+ )}
+
+
+
+
+
+ Verify
+
+
+ >
+ )
+ }
+
+ return (
+
+
+
+
+
+ {item.type}
+
+ {"Something here"}
+
+
+
+
+
+
+ {chipStatus}
+
+
+
+ {formatCurrency(
+ new DecimalBigNumber(gasPrice * GAS_USED[item.type], 18),
+ 5,
+ nativeMetadata.symbol
+ )}
+
+
+
+ {
+ formatCurrency(
+ currentTwapPrice(gasPrice * GAS_USED[item.type]).toString(),
+ 5,
+ ftsoSymbol
+ )
+ }
+
+
+
+
+ setVerifiedItem({ dkgIndex: item.dkgIndex, type: item.type })}
+ >
+ Verify
+
+
+
+
+ )
+}
+
+const ExodusList = ({
+ chainId,
+ nativeMetadata,
+ setVerifiedItem,
+ ftsoSymbol,
+ gasPrice,
+ currentTwapPrice,
+ signedExodusRotations,
+ signedExodusRotationsLoading,
+}) => {
+ const isSmallScreen = useMediaQuery("(max-width: 900px)");
+
+ const chainedExoduses = useMemo(() => {
+ let chain = [];
+
+ if (Array.isArray(signedExodusRotations)) chain = [...chain, ...signedExodusRotations];
+
+ return chain;
+ }, [signedExodusRotations]);
+
+ if (signedExodusRotationsLoading) {
+ return (
+
+
+ Loading Signed Rotations...
+
+ )
+ }
+
+ if (isSmallScreen) {
+ return (
+
+ {chainedExoduses.map((item, i) => {
+ return (
+
+ )
+ })}
+
+ )
+ } else {
+ return (
+
+
+
+
+ Exodus
+ Status
+ {nativeMetadata.symbol} Cost
+ Reward
+
+
+
+
+ {chainedExoduses.map((item, i) => {
+ return (
+
+ )
+ })}
+
+
+
+ )
+ }
+}
+
+const ExodusVerify = ({
+ chainId,
+ isOpen,
+ onClose,
+ nativeMetadata,
+ address,
+ casperApi,
+ item,
+ ftsoSymbol,
+ gasPrice,
+ currentTwapPrice,
+}) => {
+ const [isPending, setIsPending] = useState(false);
+
+ const { data: signedExodusRotation } = useSWR(
+ casperApi && item ? ['signedExodusRotations', casperApi, item] : null,
+ async ([_, api, it]) => api.query.GhostExodus.ExodusSignedRotations.getValue(it.dkgIndex, { type: "Evm" }),
+ );
+
+ const upcomingGroupKey = useMemo(() => {
+ if (!signedExodusRotation) return null;
+
+ const publicKey = signedExodusRotation?.at(1)["r#type"].value.public_key;
+ if (!publicKey) return null;
+
+ const cleanHex = publicKey.startsWith('0x04') && publicKey.length === 130
+ ? `0x${publicKey.slice(4)}`
+ : publicKey.startsWith('0x')
+ ? publicKey
+ : `0x${publicKey}`;
+
+ const hash = keccak256(cleanHex);
+
+ return getAddress(`0x${hash.slice(-40)}`);
+ }, [signedExodusRotation]);
+
+ const signedMessageMetadata = useMemo(() => {
+ if (!signedExodusRotation) return null;
+
+ const nonce = signedExodusRotation?.at(1).nonce;
+ const signature = signedExodusRotation?.at(1).signature;
+
+ return {
+ nonce: nonce ? toHex(nonce) : null,
+ signature: signature ? toHex(signature) : null,
+ message: "0xdeadbeef",
+ };
+ }, [signedExodusRotation])
+
+ return (
+ Verify {item?.type}}
+ onClose={!isPending && onClose}
+ topRight={
+
+ }
+ >
+
+
+ New Group Key}
+ tooltip="Some cool description here."
+ balance={
+ {
+ upcomingGroupKey ? shorten(upcomingGroupKey, 12, -8) : ""
+ }
+ }
+ />
+
+ Verification Reward}
+ tooltip="Some cool description here."
+ balance={{
+ formatCurrency(
+ currentTwapPrice(
+ (gasPrice ? gasPrice : 0n) *
+ (GAS_USED[item?.type] ? GAS_USED[item?.type] : 0n)
+ ).toString(),
+ 5,
+ ftsoSymbol
+ )
+ }}
+ />
+
+
+
+ Nonce}
+ tooltip="Some cool description here."
+ balance={
+ {signedMessageMetadata?.nonce ? shorten(signedMessageMetadata.nonce, 12, -10) : ""}
+ }
+ />
+
+ Signture}
+ tooltip="Some cool description here."
+ balance={
+ {signedMessageMetadata?.signature ? shorten(signedMessageMetadata.signature, 12, -10) : ""}
+ }
+ />
+
+ Signed Message}
+ tooltip="Some cool description here."
+ balance={
+ {signedMessageMetadata?.message ? signedMessageMetadata.message : ""}
+ }
+ />
+
+
+ {
+ alert("not ready for now");
+ onClose();
+ }}
+ >
+ Verify
+
+
+
+ )
+}
+
+const Exodus = ({ chainId, address, config }) => {
+ const theme = useTheme();
+
+ const isSmallScreen = useMediaQuery("(max-width: 650px)");
+ const isSemiSmallScreen = useMediaQuery("(max-width: 850px)");
+ const isVerySmallScreen = useMediaQuery("(max-width: 379px)");
+
+ const [searchOpen, setSearchOpen] = useState(false);
+ const [dkgDeviation, setDkgDeviation] = useState(3);
+ const [verifiedItem, setVerifiedItem] = useState(null);
+ const [selected, setSelected] = useState(0);
+
+ const { casperApi } = useUnstableProvider();
+
+ const nativeMetadata = useMemo(() => {
+ const client = config?.getClient();
+ return {
+ url: client?.chain?.blockExplorers?.default?.url,
+ symbol: client?.chain?.nativeCurrency?.symbol,
+ decimals: client?.chain?.nativeCurrency?.decimals,
+ }
+ }, [config]);
+
+ const { data: gasPrice } = useGasPrice(chainId);
+ const { symbol: ftsoSymbol } = useTokenSymbol(chainId, "FTSO");
+
+ const totalReserves = useTotalReserves(chainId);
+ const ftsoPrice = useFtsoPrice(chainId);
+ const reservePrice = useReservePrice(chainId);
+ const { currentGasPrice, maxGasPrice } = useCurrentGasPrice(chainId);
+
+ const { pairAddress } = useUniswapV2Pair(
+ chainId,
+ UNISWAP_V2_FACTORY[chainId],
+ getTokenAddress(chainId, "WETH"),
+ getTokenAddress(chainId, "FTSO")
+ );
+
+ const { capturedPriceSnapshots } = useCapturedPriceSnapshots(chainId, pairAddress);
+
+ const currentTwapPrice = useCallback((amount) => {
+ const value = ((capturedPriceSnapshots ? capturedPriceSnapshots._value : 0n) * amount) >> 112n;
+ return (new DecimalBigNumber(value, getTokenDecimals("FTSO"))).mul(ftsoPrice);
+ }, [capturedPriceSnapshots, ftsoPrice]);
+
+ const executionDiscount = useMemo(() => {
+ const oneHundred = new DecimalBigNumber(100n, 0);
+ const value = oneHundred.div(ftsoPrice);
+ return ftsoPrice.sub(currentTwapPrice(10n ** BigInt(nativeMetadata.decimals))).mul(value);
+ }, [currentTwapPrice, ftsoPrice, nativeMetadata]);
+
+ const { data: activeDkgAuthorities, isLoading: activeDkgAuthoritiesLoading } = useSWR(
+ casperApi ? ['activeDkgAuthorities', casperApi] : null,
+ () => casperApi.query.GhostExodus.ActiveDkgAuthorities.getValue({ type: "Secp256k1" }),
+ {
+ revalidateOnFocus: true
+ }
+ );
+
+ const { data: signedExodusRotations, isLoading: signedExodusRotationsLoading } = useSWR(
+ casperApi &&
+ dkgDeviation &&
+ (selected === 0 || selected === 1) &&
+ activeDkgAuthorities
+ ? ['signedExodusRotations', casperApi, dkgDeviation]
+ : null,
+ async ([_, api, deviation]) => {
+ const start = Math.max(0, activeDkgAuthorities.dkg_index - deviation);
+ const length = activeDkgAuthorities.dkg_index - start;
+
+ const promises = Array.from({ length }, (_, index) => start + index).map(index =>
+ api.query.GhostExodus.ExodusSignedRotations.getValue(index, { type: "Evm" })
+ .then(data => ({ dkgIndex: index, type: KEY_ROTATION, data }))
+ );
+
+ return Promise.all(promises);
+ },
+ {
+ revalidateOnFocus: true
+ }
+ );
+
+ return (
+
+
+
+ setVerifiedItem(null)}
+ />
+
+
+ Exodus Metrics}
+ >
+
+
+
+
+
+
+
+
+
+
+
+
+ alert("smart search for exodus will be here")}
+ />
+
+ }
+ headerContent={
+
+ {
+ const index = SELECTABLE_OPTIONS.indexOf(selectedValue);
+ if (index !== -1) setSelected(index);
+ }}
+ TabIndicatorProps={{ style: { display: "none" } }}
+ >
+ {SELECTABLE_OPTIONS.map((option, i) => {
+ return (
+ {option}}
+ />
+ )
+ })}
+
+ }
+ >
+
+
+
+
+
+ )
+}
+
+export default Exodus;
diff --git a/src/containers/History/History.jsx b/src/containers/History/History.jsx
index 74386c4..77165df 100644
--- a/src/containers/History/History.jsx
+++ b/src/containers/History/History.jsx
@@ -46,7 +46,16 @@ import BridgeInModal from "./BridgeInModal";
import BondModal from "./BondModal";
import AddRecordModal from "./AddRecordModal";
-const HistoryItem = ({ item, chainId, config, currentTime, eraseRecord, setViewModalOpen, isSmallScreen, finalityDelay }) => {
+const HistoryItem = ({
+ item,
+ chainId,
+ config,
+ currentTime,
+ eraseRecord,
+ setViewModalOpen,
+ isSmallScreen,
+ finalityDelay
+}) => {
const theme = useTheme();
const isVerySmallScreen = useMediaQuery("(max-width: 450px)");
diff --git a/src/hooks/prices/index.js b/src/hooks/prices/index.js
index 6cd4b13..b7b0ff6 100644
--- a/src/hooks/prices/index.js
+++ b/src/hooks/prices/index.js
@@ -141,7 +141,7 @@ export const useFtsoPrice = (chainId) => {
const reserveAddress = RESERVE_ADDRESSES[chainId];
const ftsoAddress = FTSO_ADDRESSES[chainId];
if (!reserveAddress || !ftsoAddress) {
- return new DecimalBigNumber(0n, 9);
+ return new DecimalBigNumber(1n, 9);
}
const stableReserves = reserveAddress.toUpperCase() === tokens.token0.toUpperCase()
diff --git a/src/hooks/staking/index.js b/src/hooks/staking/index.js
index da9aba8..67a0931 100644
--- a/src/hooks/staking/index.js
+++ b/src/hooks/staking/index.js
@@ -11,12 +11,61 @@ import {
import { STAKING_ADDRESSES } from "../../constants/addresses";
import { abi as StakingAbi } from "../../abi/GhostStaking.json";
import { abi as GatekeeperAbi } from "../../abi/GhostGatekeeper.json";
+import { abi as GhostStorageHistoryAbi } from "../../abi/GhostStorageHistory.json";
import { shorten } from "../../helpers";
import { DecimalBigNumber } from "../../helpers/DecimalBigNumber";
import { executeOnChainTransaction, getTokenDecimals } from "../helpers";
import { useCirculatingSupply } from "../tokens";
+export const useIsTransactionExecuted = (chainId, index) => {
+ const { gatekeeperAddress } = useGatekeeperAddress(chainId);
+
+ const { data: storageHistory } = useReadContract({
+ abi: GatekeeperAbi,
+ address: gatekeeperAddress,
+ functionName: "storageHistory",
+ scopeKey: `storageHistory-${chainId}-${gatekeeperAddress}`,
+ chainId: chainId,
+ });
+
+ const { data: isTransactionExecuted, isLoading: isTransactionExecutedLoading, error } = useReadContract({
+ abi: GhostStorageHistoryAbi,
+ address: storageHistory,
+ functionName: "isTransactionExecuted",
+ args: [index],
+ scopeKey: `isTransactionExecuted-${chainId}-${storageHistory}`,
+ chainId: chainId,
+ });
+
+ return { isTransactionExecuted, isTransactionExecutedLoading }
+}
+
+export const useCurrentGasPrice = (chainId) => {
+ const { gatekeeperAddress } = useGatekeeperAddress(chainId);
+
+ const { data: gasPrice } = useReadContract({
+ abi: GatekeeperAbi,
+ address: gatekeeperAddress,
+ functionName: "getCurrentGasPrice",
+ scopeKey: `currentGasPrice-${chainId}-${gatekeeperAddress}`,
+ chainId: chainId,
+ });
+
+ const { data } = useReadContract({
+ abi: GatekeeperAbi,
+ address: gatekeeperAddress,
+ functionName: "MAX_ALLOWED_GAS_PRICE",
+ scopeKey: `MAX_ALLOWED_GAS_PRICE-${chainId}-${gatekeeperAddress}`,
+ chainId: chainId,
+ });
+
+ const maxGasPrice = new DecimalBigNumber(data ? data : 1n, 9);
+ const currentGasPrice = new DecimalBigNumber(gasPrice ? gasPrice : 1n, 9);
+
+ return { currentGasPrice, maxGasPrice };
+}
+
export const useRegistryIndex = (chainId) => {
const { gatekeeperAddress } = useGatekeeperAddress(chainId);
@@ -28,7 +77,7 @@ export const useRegistryIndex = (chainId) => {
chainId: chainId,
});
- return { registryIndex: !isLoading ? data : 69n };
+ return { registryIndex: !isLoading ? data : 0n };
}
export const useWeaverMaximumSlots = (chainId) => {
diff --git a/src/hooks/treasury/index.js b/src/hooks/treasury/index.js
index 68cccd9..cae22f0 100644
--- a/src/hooks/treasury/index.js
+++ b/src/hooks/treasury/index.js
@@ -10,6 +10,21 @@ import { bigIntSqrt } from "../../helpers";
import { DecimalBigNumber } from "../../helpers/DecimalBigNumber";
import { getTokenAddress } from "../helpers";
+export const useCapturedPriceSnapshots = (chainId, address) => {
+ const { data } = useReadContract({
+ abi: TreasuryAbi,
+ address: DAO_TREASURY_ADDRESSES[chainId],
+ functionName: "capturedPriceSnapshots",
+ args: [address],
+ scopeKey: `capturedPriceSnapshots-${address}-${chainId}`,
+ chainId: chainId
+ });
+
+ const capturedPriceSnapshots = new DecimalBigNumber(data ? data : 0n, 18);
+
+ return { capturedPriceSnapshots }
+}
+
export const useOrinalCoefficient = (chainId) => {
const { data: original } = useReadContract({
abi: TreasuryAbi,