Skip to content

Commit

Permalink
default to 1 gwei gas price only when chain cannot be found
Browse files Browse the repository at this point in the history
  • Loading branch information
Zodomo committed Nov 18, 2024
1 parent fbfb943 commit f4ba198
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
10 changes: 5 additions & 5 deletions lib/contracts/feeoraclev2/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ func Deploy(ctx context.Context, network netconf.ID, chainID uint64, destChainID
ProtocolFee: big.NewInt(0),
}

return deploy(ctx, network, chainID, destChainIDs, cfg, backend, backends)
return deploy(ctx, chainID, destChainIDs, cfg, backend, backends)
}

func deploy(ctx context.Context, network netconf.ID, chainID uint64, destChainIDs []uint64, cfg DeploymentConfig, backend *ethbackend.Backend, backends ethbackend.Backends) (common.Address, *ethtypes.Receipt, error) {
func deploy(ctx context.Context, chainID uint64, destChainIDs []uint64, cfg DeploymentConfig, backend *ethbackend.Backend, backends ethbackend.Backends) (common.Address, *ethtypes.Receipt, error) {
if err := cfg.Validate(); err != nil {
return common.Address{}, nil, errors.Wrap(err, "validate config")
}
Expand Down Expand Up @@ -167,7 +167,7 @@ func deploy(ctx context.Context, network netconf.ID, chainID uint64, destChainID
return common.Address{}, nil, errors.Wrap(err, "wait mined implementation")
}

initCode, err := packInitCode(ctx, network, chainID, destChainIDs, cfg, backends, impl)
initCode, err := packInitCode(ctx, chainID, destChainIDs, cfg, backends, impl)
if err != nil {
return common.Address{}, nil, errors.Wrap(err, "pack init code")
}
Expand All @@ -185,7 +185,7 @@ func deploy(ctx context.Context, network netconf.ID, chainID uint64, destChainID
return addr, receipt, nil
}

func packInitCode(ctx context.Context, network netconf.ID, chainID uint64, destChainIDs []uint64, cfg DeploymentConfig, backends ethbackend.Backends, impl common.Address) ([]byte, error) {
func packInitCode(ctx context.Context, chainID uint64, destChainIDs []uint64, cfg DeploymentConfig, backends ethbackend.Backends, impl common.Address) ([]byte, error) {
feeOracleAbi, err := bindings.FeeOracleV2MetaData.GetAbi()
if err != nil {
return nil, errors.Wrap(err, "get fee oracle abi")
Expand All @@ -196,7 +196,7 @@ func packInitCode(ctx context.Context, network netconf.ID, chainID uint64, destC
return nil, errors.Wrap(err, "get proxy abi")
}

feeparams, err := feeParams(ctx, network, chainID, destChainIDs, backends, coingecko.New())
feeparams, err := feeParams(ctx, chainID, destChainIDs, backends, coingecko.New())
if err != nil {
return nil, errors.Wrap(err, "fee params")
}
Expand Down
14 changes: 4 additions & 10 deletions lib/contracts/feeoraclev2/feeparams.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ import (
"github.com/omni-network/omni/lib/ethclient/ethbackend"
"github.com/omni-network/omni/lib/evmchain"
"github.com/omni-network/omni/lib/log"
"github.com/omni-network/omni/lib/netconf"
"github.com/omni-network/omni/lib/tokens"
"github.com/omni-network/omni/monitor/xfeemngr/gasprice"

"github.com/ethereum/go-ethereum/params"
)

func feeParams(ctx context.Context, network netconf.ID, srcChainID uint64, destChainIDs []uint64, backends ethbackend.Backends, pricer tokens.Pricer,
func feeParams(ctx context.Context, srcChainID uint64, destChainIDs []uint64, backends ethbackend.Backends, pricer tokens.Pricer,
) ([]bindings.IFeeOracleV2FeeParams, error) {
// used cached pricer, to avoid multiple price requests for same token
pricer = tokens.NewCachedPricer(pricer)
Expand All @@ -33,14 +32,9 @@ func feeParams(ctx context.Context, network netconf.ID, srcChainID uint64, destC
return nil, errors.New("meta by chain id", "dest_chain", destChain.Name)
}

var ps bindings.IFeeOracleV2FeeParams
if network == netconf.Mainnet {
var err error
ps, err = destFeeParams(ctx, srcChain, destChain, backends, pricer)
if err != nil {
return nil, err
}
} else {
ps, err := destFeeParams(ctx, srcChain, destChain, backends, pricer)
if err != nil {
log.Warn(ctx, "Failed getting fee params, defaulting to 1 gwei gas prices", err, "src_chain", srcChain.Name, "dest_chain", destChain.Name)
ps = bindings.IFeeOracleV2FeeParams{
ChainId: destChain.ChainID,
ExecGasPrice: params.GWei,
Expand Down

0 comments on commit f4ba198

Please sign in to comment.