Skip to content

Commit

Permalink
Merge pull request #6631 from filecoin-project/feat/shed-agg-fees
Browse files Browse the repository at this point in the history
shed tool to estimate aggregate network fees
  • Loading branch information
magik6k authored Jun 30, 2021
2 parents 49de60d + 022d4b5 commit ed2d796
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions cmd/lotus-shed/math.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@ import (
"strings"

"github.com/urfave/cli/v2"
"golang.org/x/xerrors"

"github.com/filecoin-project/lotus/chain/types"
miner5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/miner"
)

var mathCmd = &cli.Command{
Name: "math",
Usage: "utility commands around doing math on a list of numbers",
Subcommands: []*cli.Command{
mathSumCmd,
mathAggFeesCmd,
},
}

Expand Down Expand Up @@ -101,3 +104,30 @@ var mathSumCmd = &cli.Command{
return nil
},
}

var mathAggFeesCmd = &cli.Command{
Name: "agg-fees",
Flags: []cli.Flag{
&cli.IntFlag{
Name: "size",
Required: true,
},
&cli.StringFlag{
Name: "base-fee",
Usage: "baseFee aFIL",
Required: true,
},
},
Action: func(cctx *cli.Context) error {
as := cctx.Int("size")

bf, err := types.BigFromString(cctx.String("base-fee"))
if err != nil {
return xerrors.Errorf("parsing basefee: %w", err)
}

fmt.Println(types.FIL(miner5.AggregateNetworkFee(as, bf)))

return nil
},
}

0 comments on commit ed2d796

Please sign in to comment.