Beispiel #1
0
        public IEnumerable <MevBundle> GetBundles(BlockHeader parent, long gasLimit)
        {
            MevBundle?bestBundle             = null;
            UInt256   bestMevEquivalentPrice = 0;
            long      totalGasUsed           = 0;
            long      maxGasUsed             = gasLimit * _maxBundlesGasUsedRatio / 100;

            foreach (var bundle in _bundleSource.GetBundles(parent, gasLimit))
            {
                if (maxGasUsed - totalGasUsed < 21000)
                {
                    break;
                }

                SimulatedMevBundle simulatedMevBundle = _bundleSimulator.Simulate(parent, gasLimit, bundle);
                UInt256            tailGas            = _tailGasPriceCalculator.Calculate(parent, 0, simulatedMevBundle.GasUsed);
                if (simulatedMevBundle.MevEquivalentGasPrice > bestMevEquivalentPrice &&
                    simulatedMevBundle.MevEquivalentGasPrice > tailGas)
                {
                    if (simulatedMevBundle.GasUsed + totalGasUsed <= maxGasUsed)
                    {
                        totalGasUsed          += simulatedMevBundle.GasUsed;
                        bestMevEquivalentPrice = simulatedMevBundle.MevEquivalentGasPrice;
                        bestBundle             = bundle;
                    }
                }
            }

            if (bestBundle is null)
            {
                return(Enumerable.Empty <MevBundle>());
            }

            return(Enumerable.Repeat(bestBundle, 1));
        }
Beispiel #2
0
        public IEnumerable <MevBundle> GetBundles(BlockHeader parent, long gasLimit)
        {
            MevBundle?bestBundle           = null;
            long      bestAdjustedGasPrice = 0;

            foreach (var bundle in _bundleSource.GetBundles(parent, gasLimit))
            {
                SimulatedMevBundle simulatedMevBundle = _bundleSimulator.Simulate(parent, gasLimit, bundle);
                if (simulatedMevBundle.AdjustedGasPrice > bestAdjustedGasPrice)
                {
                    bestBundle = bundle;
                }
            }

            if (bestBundle is null)
            {
                return(Enumerable.Empty <MevBundle>());
            }

            return(Enumerable.Repeat(bestBundle, 1));
        }