include gas difference for exodus verification discount

Signed-off-by: Uncle Fatso <uncle.fatso@ghostchain.io>
This commit is contained in:
Uncle Fatso 2026-11-15 15:55:14 +03:00
parent 3b2dd422fa
commit 12f668130d
Signed by: f4ts0
GPG Key ID: 565F4F2860226EBB
2 changed files with 15 additions and 7 deletions

View File

@ -1,7 +1,7 @@
{
"name": "ghost-dao-interface",
"private": true,
"version": "0.8.19",
"version": "0.8.20",
"type": "module",
"scripts": {
"dev": "vite",

View File

@ -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