@@ -16,6 +16,7 @@ import (
1616 "github.com/ethereum/go-ethereum/core/types"
1717 servicemanager "github.com/yetanotherco/aligned_layer/contracts/bindings/AlignedLayerServiceManager"
1818 "github.com/yetanotherco/aligned_layer/core/config"
19+ "github.com/yetanotherco/aligned_layer/core/utils"
1920 "github.com/yetanotherco/aligned_layer/metrics"
2021)
2122
@@ -29,7 +30,7 @@ type AvsWriter struct {
2930 metrics * metrics.Metrics
3031}
3132
32- func NewAvsWriterFromConfig (baseConfig * config.BaseConfig , ecdsaConfig * config.EcdsaConfig ) (* AvsWriter , error ) {
33+ func NewAvsWriterFromConfig (baseConfig * config.BaseConfig , ecdsaConfig * config.EcdsaConfig , metrics * metrics. Metrics ) (* AvsWriter , error ) {
3334
3435 buildAllConfig := clients.BuildAllConfig {
3536 EthHttpUrl : baseConfig .EthRpcUrl ,
@@ -69,6 +70,7 @@ func NewAvsWriterFromConfig(baseConfig *config.BaseConfig, ecdsaConfig *config.E
6970 Signer : privateKeySigner ,
7071 Client : baseConfig .EthRpcClient ,
7172 ClientFallback : baseConfig .EthRpcClientFallback ,
73+ metrics : metrics ,
7274 }, nil
7375}
7476
@@ -131,10 +133,11 @@ func (w *AvsWriter) checkRespondToTaskFeeLimit(tx *types.Transaction, txOpts bin
131133 w .logger .Info ("Batch RespondToTaskFeeLimit" , "RespondToTaskFeeLimit" , respondToTaskFeeLimit )
132134
133135 if respondToTaskFeeLimit .Cmp (simulatedCost ) < 0 {
134- a , _ := respondToTaskFeeLimit .Sub (big .NewInt (0 ), simulatedCost ).Float64 ()
135- w .metrics .AddAccumulatedGasPayedAggregator (a )
136+ aggregatorDifferenceToPay := new (big.Int ).Sub (simulatedCost , respondToTaskFeeLimit )
137+ aggregatorDifferenceToPayInEth , _ := utils .WeiToEth (aggregatorDifferenceToPay ).Float64 ()
138+ w .metrics .AddAccumulatedGasPayedAggregator (aggregatorDifferenceToPayInEth )
136139 w .metrics .IncAggregatorAccumResponse ()
137- w .logger .Warn ("cost of transaction is higher than Batch.RespondToTaskFeeLimit, aggregator will pay the for the difference" )
140+ w .logger .Warn ("cost of transaction is higher than Batch.RespondToTaskFeeLimit, aggregator will pay the for the difference, aprox: %v" , aggregatorDifferenceToPay )
138141 }
139142
140143 return w .compareBalances (respondToTaskFeeLimit , aggregatorAddress , senderAddress )
0 commit comments