From 12f668130d62127b2bddb6725214d7c832e6a58e Mon Sep 17 00:00:00 2001 From: Uncle Fatso Date: Sun, 15 Nov 2026 15:55:14 +0300 Subject: [PATCH] include gas difference for exodus verification discount Signed-off-by: Uncle Fatso --- package.json | 2 +- src/containers/Exodus/Exodus.jsx | 20 ++++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 4af859e..1e000e3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ghost-dao-interface", "private": true, - "version": "0.8.19", + "version": "0.8.20", "type": "module", "scripts": { "dev": "vite", diff --git a/src/containers/Exodus/Exodus.jsx b/src/containers/Exodus/Exodus.jsx index a2bc7e7..adab1b2 100644 --- a/src/containers/Exodus/Exodus.jsx +++ b/src/containers/Exodus/Exodus.jsx @@ -92,16 +92,23 @@ const Exodus = ({ chainId, address, config }) => { const { capturedPriceSnapshots } = useCapturedPriceSnapshots(chainId, pairAddress); - const currentTwapPrice = useCallback((amount) => { - const value = ((capturedPriceSnapshots ? capturedPriceSnapshots._value : 0n) * amount) >> 112n; + const currentTwapPrice = useCallback((gasUsed) => { + const value = ((capturedPriceSnapshots ? capturedPriceSnapshots._value : 0n) * gasUsed) >> 112n; return (new DecimalBigNumber(value, getTokenDecimals("FTSO"))).mul(ftsoPrice); }, [capturedPriceSnapshots, ftsoPrice]); const executionDiscount = useMemo(() => { + const zero = new DecimalBigNumber(0n, 0); + + const twapNativeUsd = currentTwapPrice(10n ** BigInt(nativeMetadata.decimals)); + const actualGasCostPerUnit = new DecimalBigNumber(gasPrice ? gasPrice : 0n, 9); + const oneHundred = new DecimalBigNumber(100n, 0); - const value = oneHundred.div(ftsoPrice); - return ftsoPrice.sub(currentTwapPrice(10n ** BigInt(nativeMetadata.decimals))).mul(value); - }, [currentTwapPrice, ftsoPrice, nativeMetadata]); + return currentGasPrice + .sub(actualGasCostPerUnit) + .mul(oneHundred.add(zero)) + .div(currentGasPrice); + }, [currentTwapPrice, ftsoPrice, nativeMetadata, gasPrice, currentGasPrice]); const { data: activeDkgAuthorities, isLoading: activeDkgAuthoritiesLoading } = useSWR( casperApi ? ['activeDkgAuthorities', casperApi] : null, @@ -127,7 +134,8 @@ const Exodus = ({ chainId, address, config }) => { .then(data => ({ dkgIndex: index, type: KEY_ROTATION, gasUsed: GAS_USED[KEY_ROTATION], data })) ); - return Promise.all(promises); + const results = await Promise.all(promises); + return results.filter(item => item.data !== undefined); }, { revalidateOnFocus: true