diff --git a/package.json b/package.json index 4531275..85641ed 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ghost-dao-interface", "private": true, - "version": "0.8.10", + "version": "0.8.11", "type": "module", "scripts": { "dev": "vite", diff --git a/src/containers/Bridge/BridgeIn.jsx b/src/containers/Bridge/BridgeIn.jsx index babcdf0..560be67 100644 --- a/src/containers/Bridge/BridgeIn.jsx +++ b/src/containers/Bridge/BridgeIn.jsx @@ -535,9 +535,13 @@ const BridgeIn = ({ chainId, address, config, connect }) => { /> Min Bridge-In} tooltip="Minimum amount that could be handled by the bridge to avoid dust balances." - balance={{formatCurrency(existentialDeposit.toString(), formatDecimals, ghstSymbol)}} + balance={ + + {formatCurrency(existentialDeposit.toString(), formatDecimals, ghstSymbol)} + + } /> { const { balance: ghstBalance } = useBalance(chainId, "GHST", address); const { gatekeeperAddress } = useGatekeeperAddress(chainId); + const ghostedSupply = useGhostedSupply(chainId); + const { data: formatDecimals } = useStorageValue(chainId, address, DECIMALS_PREFIX, "5"); const nativeSymbol = useMemo(() => { @@ -243,6 +245,29 @@ const BridgeOut = ({ chainId, address, config, connect }) => { } ); + const { data: networkGatekeeperAmount } = useSWR( + casperApi ? ['networkGatekeeperAmount', casperApi, chainId] : null, + async () => { + const key = BigInt(chainId); + const res = await casperApi.query.GhostNetworks.GatekeeperAmounts.getValue(key); + return res; + }, + { + refreshInterval: 12000, + revalidateOnFocus: true + } + ); + + const gatekeepedAmount = useMemo(() => { + const gatekeeperAmount = new DecimalBigNumber( + networkGatekeeperAmount ? networkGatekeeperAmount : 0n, + chainProperties ? chainProperties.properties.tokenDecimals : 18, + ); + + if (ghostedSupply.lt(gatekeeperAmount)) return ghostedSupply; + else return gatekeeperAmount; + }, [ghostedSupply, networkGatekeeperAmount, chainProperties]); + const participants = useMemo(() => { if (!qualificationDkgState) return { total: 0, participated: 0 } @@ -335,11 +360,12 @@ const BridgeOut = ({ chainId, address, config, connect }) => { chainProperties ? chainProperties.properties.tokenDecimals : 18 ); + const notEnoughGatekeeped = gatekeepedAmount.lt(preparedAmount); const smallAmount = bigMinimumBridgeOut.gt(preparedAmount); const validReceiver = isAddress(customReceiver ? customReceiver : receiver); - return differentGatekeepers || smallAmount || insufficientAmount || !validReceiver; - }, [networkData, gatekeeperAddress, minimumBridgeOut, preparedAmount, accountBalance, customReceiver, receiver]); + return notEnoughGatekeeped || differentGatekeepers || smallAmount || insufficientAmount || !validReceiver; + }, [gatekeepedAmount, networkData, gatekeeperAddress, minimumBridgeOut, preparedAmount, accountBalance, customReceiver, receiver]); const startGhostExodus = async () => { alert("not ready yet"); @@ -492,20 +518,30 @@ const BridgeOut = ({ chainId, address, config, connect }) => { } /> - { - formatCurrency( - new DecimalBigNumber( - minimumBridgeOut ? minimumBridgeOut : 0n, - chainProperties ? chainProperties.properties.tokenDecimals : 18, - ), - formatDecimals, - ghstSymbol - ) - }} - /> + + Min Bridge-Out} + tooltip="Minimum amount that could be handled by the bridge to avoid dust balances." + balance={{ + formatCurrency( + new DecimalBigNumber( + minimumBridgeOut ? minimumBridgeOut : 0n, + chainProperties ? chainProperties.properties.tokenDecimals : 18, + ), + formatDecimals, + ghstSymbol + ) + }} + /> + + Gatekeeped Amount} + tooltip="Minimum amount that could be handled by the bridge to avoid dust balances." + balance={{ + formatCurrency(gatekeepedAmount, formatDecimals, ghstSymbol) + }} + /> +