Estimate FeeCap 20 blocks in the future
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
+16
-1
@@ -2,6 +2,7 @@ package full
|
||||
|
||||
import (
|
||||
"context"
|
||||
"math"
|
||||
"sort"
|
||||
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
@@ -26,9 +27,23 @@ type GasAPI struct {
|
||||
}
|
||||
|
||||
const MinGasPrice = 1
|
||||
const BaseFeeEstimNBlocks = 20
|
||||
|
||||
func (a *GasAPI) GasEstimateFeeCap(ctx context.Context, maxqueueblks int64,
|
||||
tsk types.TipSetKey) (types.BigInt, error) {
|
||||
ts := a.Chain.GetHeaviestTipSet()
|
||||
|
||||
parentBaseFee := ts.Blocks()[0].ParentBaseFee
|
||||
increaseFactor := math.Pow(1+1/build.BaseFeeMaxChangeDenom, BaseFeeEstimNBlocks)
|
||||
|
||||
out := types.BigMul(parentBaseFee, types.NewInt(uint64(increaseFactor*(1<<8))))
|
||||
out = types.BigDiv(parentBaseFee, types.NewInt(1<<8))
|
||||
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (a *GasAPI) GasEsitmateGasPremium(ctx context.Context, nblocksincl uint64,
|
||||
sender address.Address, gaslimit int64, tsk types.TipSetKey) (types.BigInt, error) {
|
||||
sender address.Address, gaslimit int64, _ types.TipSetKey) (types.BigInt, error) {
|
||||
|
||||
if nblocksincl == 0 {
|
||||
nblocksincl = 1
|
||||
|
||||
Reference in New Issue
Block a user