File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ type RelayerConfig struct {
4444 WhiteList whitelist
4545 nonce uint64
4646 GasLimitMultiplier float64
47+ GasPriceMultiplier float64
4748
4849 mut * sync.Mutex
4950}
@@ -61,8 +62,10 @@ func (e *ethereum) RelayerConfig() *RelayerConfig {
6162 VaultMountPath string `fig:"vault_mount_path"`
6263 WhiteList []string `fig:"whitelist"`
6364 GasLimitMultiplier float64 `fig:"gas_limit_multiplier"`
65+ GasPriceMultiplier float64 `fig:"gas_price_multiplier"`
6466 }{
6567 GasLimitMultiplier : 1.2 ,
68+ GasPriceMultiplier : 0.9 ,
6669 }
6770 err := figure .
6871 Out (& networkConfig ).
Original file line number Diff line number Diff line change @@ -113,11 +113,20 @@ func newTxResponse(tx *types.Transaction) resources.TxResponse {
113113 }
114114}
115115
116+ var ONE = 1000000000
117+
118+ func multiplyGasPrice (gasPrice * big.Int , multiplier float64 ) * big.Int {
119+ mult := big .NewFloat (0 ).Mul (big .NewFloat (multiplier ), big .NewFloat (float64 (ONE )))
120+ gas , _ := big .NewFloat (0 ).Mul (big .NewFloat (0 ).SetInt (gasPrice ), mult ).Int (nil )
121+ return big .NewInt (0 ).Div (gas , big .NewInt (int64 (ONE )))
122+ }
123+
116124func confGas (r * http.Request , txd * txData , receiver * common.Address ) (err error ) {
117125 txd .gasPrice , err = RelayerConfig (r ).RPC .SuggestGasPrice (r .Context ())
118126 if err != nil {
119127 return fmt .Errorf ("failed to suggest gas price: %w" , err )
120128 }
129+ txd .gasPrice = multiplyGasPrice (txd .gasPrice , RelayerConfig (r ).GasPriceMultiplier )
121130
122131 txd .gas , err = RelayerConfig (r ).RPC .EstimateGas (r .Context (), ethereum.CallMsg {
123132 From : crypto .PubkeyToAddress (RelayerConfig (r ).PrivateKey .PublicKey ),
You can’t perform that action at this time.
0 commit comments