include gas difference for exodus verification discount
Signed-off-by: Uncle Fatso <uncle.fatso@ghostchain.io>
This commit is contained in:
parent
3b2dd422fa
commit
12f668130d
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "ghost-dao-interface",
|
||||
"private": true,
|
||||
"version": "0.8.19",
|
||||
"version": "0.8.20",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user