From 07c7b71e193d5d2026c05fb4687acff505a62e0a Mon Sep 17 00:00:00 2001 From: Jacob Shufro Date: Sat, 25 Jul 2026 11:56:08 -0400 Subject: [PATCH 01/12] Remove shared/utils/wallet --- rocketpool/api/wallet/rebuild.go | 3 +- rocketpool/api/wallet/recover.go | 249 +++++++++++++++++++++++++- rocketpool/api/wallet/test.go | 5 +- shared/utils/wallet/recover-keys.go | 260 ---------------------------- 4 files changed, 249 insertions(+), 268 deletions(-) delete mode 100644 shared/utils/wallet/recover-keys.go diff --git a/rocketpool/api/wallet/rebuild.go b/rocketpool/api/wallet/rebuild.go index 7453aea48..78534d48b 100644 --- a/rocketpool/api/wallet/rebuild.go +++ b/rocketpool/api/wallet/rebuild.go @@ -5,7 +5,6 @@ import ( "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/types/api" - walletutils "github.com/rocket-pool/smartnode/shared/utils/wallet" ) func rebuildWallet(c *cli.Command) (*api.RebuildWalletResponse, error) { @@ -40,7 +39,7 @@ func rebuildWallet(c *cli.Command) (*api.RebuildWalletResponse, error) { } // Recover validator keys - response.ValidatorKeys, err = walletutils.RecoverNodeKeys(c, rp, bc, nodeAccount.Address, w, false) + response.ValidatorKeys, err = recoverNodeKeys(c, rp, bc, nodeAccount.Address, w, false) if err != nil { return nil, err } diff --git a/rocketpool/api/wallet/recover.go b/rocketpool/api/wallet/recover.go index b50f4d202..5bdb44693 100644 --- a/rocketpool/api/wallet/recover.go +++ b/rocketpool/api/wallet/recover.go @@ -1,22 +1,37 @@ package wallet import ( + "bytes" + "encoding/json" "errors" "fmt" + "os" + "path/filepath" + "strings" "github.com/ethereum/go-ethereum/common" "github.com/urfave/cli/v3" + eth2types "github.com/wealdtech/go-eth2-types/v2" + eth2ks "github.com/wealdtech/go-eth2-wallet-encryptor-keystorev4" + "gopkg.in/yaml.v2" + "github.com/rocket-pool/smartnode/bindings/megapool" + "github.com/rocket-pool/smartnode/bindings/minipool" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/shared/services" + "github.com/rocket-pool/smartnode/shared/services/beacon" + "github.com/rocket-pool/smartnode/shared/services/config" "github.com/rocket-pool/smartnode/shared/services/wallet" "github.com/rocket-pool/smartnode/shared/types/api" - walletutils "github.com/rocket-pool/smartnode/shared/utils/wallet" + hexutils "github.com/rocket-pool/smartnode/shared/utils/hex" ) const ( findIterations uint = 100000 + bucketSize uint = 20 + bucketLimit uint = 2000 ) func recoverWalletWithParams(c *cli.Command, mnemonic string, skipValidatorKeyRecovery bool, derivationPath string, walletIndex uint) (*api.RecoverWalletResponse, error) { @@ -73,7 +88,7 @@ func recoverWalletWithParams(c *cli.Command, mnemonic string, skipValidatorKeyRe response.AccountAddress = nodeAccount.Address if !skipValidatorKeyRecovery { - response.ValidatorKeys, err = walletutils.RecoverNodeKeys(c, rp, bc, nodeAccount.Address, w, false) + response.ValidatorKeys, err = recoverNodeKeys(c, rp, bc, nodeAccount.Address, w, false) if err != nil { return nil, err } @@ -172,7 +187,7 @@ func searchAndRecoverWalletWithParams(c *cli.Command, mnemonic string, address c response.AccountAddress = nodeAccount.Address if !skipValidatorKeyRecovery { - response.ValidatorKeys, err = walletutils.RecoverNodeKeys(c, rp, bc, nodeAccount.Address, w, false) + response.ValidatorKeys, err = recoverNodeKeys(c, rp, bc, nodeAccount.Address, w, false) if err != nil { return nil, err } @@ -187,3 +202,231 @@ func searchAndRecoverWalletWithParams(c *cli.Command, mnemonic string, address c return &response, nil } + +func recoverNodeKeys(c *cli.Command, rp *rocketpool.RocketPool, bc beacon.Client, nodeAddress common.Address, w wallet.Wallet, testOnly bool) ([]types.ValidatorPubkey, error) { + cfg, err := services.GetConfig(c) + if err != nil { + return nil, err + } + + // Get node's validating pubkeys + pubkeys, err := minipool.GetNodeValidatingMinipoolPubkeys(rp, nodeAddress, nil) + if err != nil { + return nil, err + } + + // Check if the node has a megapool + megapoolDeployed, err := megapool.GetMegapoolDeployed(rp, nodeAddress, nil) + if err != nil { + return nil, err + } + + if megapoolDeployed { + // Get the megapool address + megapoolAddress, err := megapool.GetMegapoolExpectedAddress(rp, nodeAddress, nil) + if err != nil { + return nil, err + } + + // Load the megapool + mp, err := megapool.NewMegaPoolV1(rp, megapoolAddress, nil) + if err != nil { + return nil, err + } + + megapoolPubkeys, err := mp.GetMegapoolPubkeys(nil) + if err != nil { + return nil, err + } + + pubkeys = append(pubkeys, megapoolPubkeys...) + } + + // Remove zero pubkeys + zeroPubkey := types.ValidatorPubkey{} + filteredPubkeys := []types.ValidatorPubkey{} + for _, pubkey := range pubkeys { + if !bytes.Equal(pubkey[:], zeroPubkey[:]) { + filteredPubkeys = append(filteredPubkeys, pubkey) + } + } + pubkeys = filteredPubkeys + + // Get validator statuses by pubkeys + statuses, err := bc.GetValidatorStatuses(pubkeys, nil) + if err != nil { + return nil, fmt.Errorf("error getting validator statuses: %w", err) + } + + // Filter out inactive validators + filteredPubkeys = []types.ValidatorPubkey{} + for _, pubkey := range pubkeys { + if statuses[pubkey].Status == beacon.ValidatorState_ActiveOngoing || + statuses[pubkey].Status == beacon.ValidatorState_ActiveExiting || + statuses[pubkey].Status == beacon.ValidatorState_PendingInitialized || + statuses[pubkey].Status == beacon.ValidatorState_PendingQueued { + filteredPubkeys = append(filteredPubkeys, pubkey) + } + } + + pubkeyMap := map[types.ValidatorPubkey]bool{} + for _, pubkey := range pubkeys { + pubkeyMap[pubkey] = true + } + + pubkeyMap, err = checkForAndRecoverCustomMinipoolKeys(cfg, pubkeyMap, w, testOnly) + if err != nil { + return nil, fmt.Errorf("error checking for or recovering custom validator keys: %w", err) + } + + // Recover conventionally generated keys + bucketStart := uint(0) + for { + if bucketStart >= bucketLimit { + return nil, fmt.Errorf("attempt limit exceeded (%d keys)", bucketLimit) + } + bucketEnd := bucketStart + bucketSize + if bucketEnd > bucketLimit { + bucketEnd = bucketLimit + } + + // Get the keys for this bucket + keys, err := w.GetValidatorKeys(bucketStart, bucketEnd-bucketStart) + if err != nil { + return nil, err + } + for _, validatorKey := range keys { + _, exists := pubkeyMap[validatorKey.PublicKey] + if exists { + // Found one! + delete(pubkeyMap, validatorKey.PublicKey) + if !testOnly { + err := w.SaveValidatorKey(validatorKey) + if err != nil { + return nil, fmt.Errorf("error recovering validator keys: %w", err) + } + } + } + } + + if len(pubkeyMap) == 0 { + // All keys recovered! + break + } + + // Run another iteration with the next bucket + bucketStart = bucketEnd + } + + return pubkeys, nil + +} + +func checkForAndRecoverCustomMinipoolKeys(cfg *config.RocketPoolConfig, pubkeyMap map[types.ValidatorPubkey]bool, w wallet.Wallet, testOnly bool) (map[types.ValidatorPubkey]bool, error) { + + // Load custom validator keys + customKeyDir := cfg.Smartnode.GetCustomKeyPath() + info, err := os.Stat(customKeyDir) + if !os.IsNotExist(err) && info.IsDir() { + + // Get the custom keystore files + files, err := os.ReadDir(customKeyDir) + if err != nil { + return nil, fmt.Errorf("error enumerating custom keystores: %w", err) + } + + // Initialize the BLS library + err = eth2types.InitBLS() + if err != nil { + return nil, fmt.Errorf("error initializing BLS: %w", err) + } + + if len(files) > 0 { + + // Deserialize the password file + passwordFile := cfg.Smartnode.GetCustomKeyPasswordFilePath() + fileBytes, err := os.ReadFile(passwordFile) + if err != nil { + return nil, fmt.Errorf("%d custom keystores were found but the password file could not be loaded: %w", len(files), err) + } + passwords := map[string]string{} + err = yaml.Unmarshal(fileBytes, &passwords) + if err != nil { + return nil, fmt.Errorf("error unmarshalling custom keystore password file: %w", err) + } + + // Process every custom key + for _, file := range files { + // Read the file + bytes, err := os.ReadFile(filepath.Join(customKeyDir, file.Name())) + if err != nil { + return nil, fmt.Errorf("error reading custom keystore %s: %w", file.Name(), err) + } + + // Deserialize it + keystore := api.ValidatorKeystore{} + err = json.Unmarshal(bytes, &keystore) + if err != nil { + return nil, fmt.Errorf("error deserializing custom keystore %s: %w", file.Name(), err) + } + + // Check if it's one of the pubkeys for the minipool + _, exists := pubkeyMap[keystore.Pubkey] + if !exists { + // This pubkey isn't for any of this node's minipools so ignore it + continue + } + + // Get the password for it + formattedPubkey := strings.ToUpper(hexutils.RemovePrefix(keystore.Pubkey.Hex())) + password, exists := passwords[formattedPubkey] + if !exists { + return nil, fmt.Errorf("custom keystore for pubkey %s needs a password, but none was provided", keystore.Pubkey.Hex()) + } + + // Get the encryption function it uses + kdf, exists := keystore.Crypto["kdf"] + if !exists { + return nil, fmt.Errorf("error processing custom keystore %s: \"crypto\" didn't contain a subkey named \"kdf\"", file.Name()) + } + kdfMap := kdf.(map[string]interface{}) + function, exists := kdfMap["function"] + if !exists { + return nil, fmt.Errorf("error processing custom keystore %s: \"crypto.kdf\" didn't contain a subkey named \"function\"", file.Name()) + } + functionString := function.(string) + + // Decrypt the private key + encryptor := eth2ks.New(eth2ks.WithCipher(functionString)) + decryptedKey, err := encryptor.Decrypt(keystore.Crypto, password) + if err != nil { + return nil, fmt.Errorf("error decrypting keystore for validator %s: %w", keystore.Pubkey.Hex(), err) + } + privateKey, err := eth2types.BLSPrivateKeyFromBytes(decryptedKey) + if err != nil { + return nil, fmt.Errorf("error recreating private key for validator %s: %w", keystore.Pubkey.Hex(), err) + } + + // Verify the private key matches the public key + reconstructedPubkey := types.BytesToValidatorPubkey(privateKey.PublicKey().Marshal()) + if reconstructedPubkey != keystore.Pubkey { + return nil, fmt.Errorf("private keystore file %s claims to be for validator %s but it's for validator %s", file.Name(), keystore.Pubkey.Hex(), reconstructedPubkey.Hex()) + } + + // Store the key + if !testOnly { + err = w.StoreValidatorKey(privateKey, keystore.Path) + if err != nil { + return nil, fmt.Errorf("error storing private keystore for %s: %w", reconstructedPubkey.Hex(), err) + } + } + + // Remove the pubkey from pending minipools to handle + delete(pubkeyMap, reconstructedPubkey) + } + } + } + + return pubkeyMap, nil + +} diff --git a/rocketpool/api/wallet/test.go b/rocketpool/api/wallet/test.go index 651cfa1b2..7268b68fb 100644 --- a/rocketpool/api/wallet/test.go +++ b/rocketpool/api/wallet/test.go @@ -11,7 +11,6 @@ import ( "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/wallet" "github.com/rocket-pool/smartnode/shared/types/api" - walletutils "github.com/rocket-pool/smartnode/shared/utils/wallet" ) func testRecoverWalletWithParams(c *cli.Command, mnemonic string, skipValidatorKeyRecovery bool, derivationPath string, walletIndex uint) (*api.RecoverWalletResponse, error) { @@ -71,7 +70,7 @@ func testRecoverWalletWithParams(c *cli.Command, mnemonic string, skipValidatorK response.AccountAddress = nodeAccount.Address if !skipValidatorKeyRecovery { - response.ValidatorKeys, err = walletutils.RecoverNodeKeys(c, rp, bc, nodeAccount.Address, w, true) + response.ValidatorKeys, err = recoverNodeKeys(c, rp, bc, nodeAccount.Address, w, true) if err != nil { return nil, err } @@ -168,7 +167,7 @@ func testSearchAndRecoverWalletWithParams(c *cli.Command, mnemonic string, addre response.AccountAddress = nodeAccount.Address if !skipValidatorKeyRecovery { - response.ValidatorKeys, err = walletutils.RecoverNodeKeys(c, rp, bc, nodeAccount.Address, w, true) + response.ValidatorKeys, err = recoverNodeKeys(c, rp, bc, nodeAccount.Address, w, true) if err != nil { return nil, err } diff --git a/shared/utils/wallet/recover-keys.go b/shared/utils/wallet/recover-keys.go deleted file mode 100644 index 25bc4d20f..000000000 --- a/shared/utils/wallet/recover-keys.go +++ /dev/null @@ -1,260 +0,0 @@ -package wallet - -import ( - "bytes" - "fmt" - "os" - "path/filepath" - "strings" - - "github.com/ethereum/go-ethereum/common" - "github.com/goccy/go-json" - "github.com/urfave/cli/v3" - eth2types "github.com/wealdtech/go-eth2-types/v2" - eth2ks "github.com/wealdtech/go-eth2-wallet-encryptor-keystorev4" - "gopkg.in/yaml.v2" - - "github.com/rocket-pool/smartnode/bindings/megapool" - "github.com/rocket-pool/smartnode/bindings/minipool" - "github.com/rocket-pool/smartnode/bindings/rocketpool" - "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/shared/services" - "github.com/rocket-pool/smartnode/shared/services/beacon" - "github.com/rocket-pool/smartnode/shared/services/config" - "github.com/rocket-pool/smartnode/shared/services/wallet" - "github.com/rocket-pool/smartnode/shared/types/api" - hexutils "github.com/rocket-pool/smartnode/shared/utils/hex" -) - -const ( - bucketSize uint = 20 - bucketLimit uint = 2000 -) - -func RecoverNodeKeys(c *cli.Command, rp *rocketpool.RocketPool, bc beacon.Client, nodeAddress common.Address, w wallet.Wallet, testOnly bool) ([]types.ValidatorPubkey, error) { - cfg, err := services.GetConfig(c) - if err != nil { - return nil, err - } - - // Get node's validating pubkeys - pubkeys, err := minipool.GetNodeValidatingMinipoolPubkeys(rp, nodeAddress, nil) - if err != nil { - return nil, err - } - - // Check if the node has a megapool - megapoolDeployed, err := megapool.GetMegapoolDeployed(rp, nodeAddress, nil) - if err != nil { - return nil, err - } - - if megapoolDeployed { - // Get the megapool address - megapoolAddress, err := megapool.GetMegapoolExpectedAddress(rp, nodeAddress, nil) - if err != nil { - return nil, err - } - - // Load the megapool - mp, err := megapool.NewMegaPoolV1(rp, megapoolAddress, nil) - if err != nil { - return nil, err - } - - megapoolPubkeys, err := mp.GetMegapoolPubkeys(nil) - if err != nil { - return nil, err - } - - pubkeys = append(pubkeys, megapoolPubkeys...) - } - - // Remove zero pubkeys - zeroPubkey := types.ValidatorPubkey{} - filteredPubkeys := []types.ValidatorPubkey{} - for _, pubkey := range pubkeys { - if !bytes.Equal(pubkey[:], zeroPubkey[:]) { - filteredPubkeys = append(filteredPubkeys, pubkey) - } - } - pubkeys = filteredPubkeys - - // Get validator statuses by pubkeys - statuses, err := bc.GetValidatorStatuses(pubkeys, nil) - if err != nil { - return nil, fmt.Errorf("error getting validator statuses: %w", err) - } - - // Filter out inactive validators - filteredPubkeys = []types.ValidatorPubkey{} - for _, pubkey := range pubkeys { - if statuses[pubkey].Status == beacon.ValidatorState_ActiveOngoing || - statuses[pubkey].Status == beacon.ValidatorState_ActiveExiting || - statuses[pubkey].Status == beacon.ValidatorState_PendingInitialized || - statuses[pubkey].Status == beacon.ValidatorState_PendingQueued { - filteredPubkeys = append(filteredPubkeys, pubkey) - } - } - - pubkeyMap := map[types.ValidatorPubkey]bool{} - for _, pubkey := range pubkeys { - pubkeyMap[pubkey] = true - } - - pubkeyMap, err = CheckForAndRecoverCustomMinipoolKeys(cfg, pubkeyMap, w, testOnly) - if err != nil { - return nil, fmt.Errorf("error checking for or recovering custom validator keys: %w", err) - } - - // Recover conventionally generated keys - bucketStart := uint(0) - for { - if bucketStart >= bucketLimit { - return nil, fmt.Errorf("attempt limit exceeded (%d keys)", bucketLimit) - } - bucketEnd := bucketStart + bucketSize - if bucketEnd > bucketLimit { - bucketEnd = bucketLimit - } - - // Get the keys for this bucket - keys, err := w.GetValidatorKeys(bucketStart, bucketEnd-bucketStart) - if err != nil { - return nil, err - } - for _, validatorKey := range keys { - _, exists := pubkeyMap[validatorKey.PublicKey] - if exists { - // Found one! - delete(pubkeyMap, validatorKey.PublicKey) - if !testOnly { - err := w.SaveValidatorKey(validatorKey) - if err != nil { - return nil, fmt.Errorf("error recovering validator keys: %w", err) - } - } - } - } - - if len(pubkeyMap) == 0 { - // All keys recovered! - break - } - - // Run another iteration with the next bucket - bucketStart = bucketEnd - } - - return pubkeys, nil - -} - -func CheckForAndRecoverCustomMinipoolKeys(cfg *config.RocketPoolConfig, pubkeyMap map[types.ValidatorPubkey]bool, w wallet.Wallet, testOnly bool) (map[types.ValidatorPubkey]bool, error) { - - // Load custom validator keys - customKeyDir := cfg.Smartnode.GetCustomKeyPath() - info, err := os.Stat(customKeyDir) - if !os.IsNotExist(err) && info.IsDir() { - - // Get the custom keystore files - files, err := os.ReadDir(customKeyDir) - if err != nil { - return nil, fmt.Errorf("error enumerating custom keystores: %w", err) - } - - // Initialize the BLS library - err = eth2types.InitBLS() - if err != nil { - return nil, fmt.Errorf("error initializing BLS: %w", err) - } - - if len(files) > 0 { - - // Deserialize the password file - passwordFile := cfg.Smartnode.GetCustomKeyPasswordFilePath() - fileBytes, err := os.ReadFile(passwordFile) - if err != nil { - return nil, fmt.Errorf("%d custom keystores were found but the password file could not be loaded: %w", len(files), err) - } - passwords := map[string]string{} - err = yaml.Unmarshal(fileBytes, &passwords) - if err != nil { - return nil, fmt.Errorf("error unmarshalling custom keystore password file: %w", err) - } - - // Process every custom key - for _, file := range files { - // Read the file - bytes, err := os.ReadFile(filepath.Join(customKeyDir, file.Name())) - if err != nil { - return nil, fmt.Errorf("error reading custom keystore %s: %w", file.Name(), err) - } - - // Deserialize it - keystore := api.ValidatorKeystore{} - err = json.Unmarshal(bytes, &keystore) - if err != nil { - return nil, fmt.Errorf("error deserializing custom keystore %s: %w", file.Name(), err) - } - - // Check if it's one of the pubkeys for the minipool - _, exists := pubkeyMap[keystore.Pubkey] - if !exists { - // This pubkey isn't for any of this node's minipools so ignore it - continue - } - - // Get the password for it - formattedPubkey := strings.ToUpper(hexutils.RemovePrefix(keystore.Pubkey.Hex())) - password, exists := passwords[formattedPubkey] - if !exists { - return nil, fmt.Errorf("custom keystore for pubkey %s needs a password, but none was provided", keystore.Pubkey.Hex()) - } - - // Get the encryption function it uses - kdf, exists := keystore.Crypto["kdf"] - if !exists { - return nil, fmt.Errorf("error processing custom keystore %s: \"crypto\" didn't contain a subkey named \"kdf\"", file.Name()) - } - kdfMap := kdf.(map[string]interface{}) - function, exists := kdfMap["function"] - if !exists { - return nil, fmt.Errorf("error processing custom keystore %s: \"crypto.kdf\" didn't contain a subkey named \"function\"", file.Name()) - } - functionString := function.(string) - - // Decrypt the private key - encryptor := eth2ks.New(eth2ks.WithCipher(functionString)) - decryptedKey, err := encryptor.Decrypt(keystore.Crypto, password) - if err != nil { - return nil, fmt.Errorf("error decrypting keystore for validator %s: %w", keystore.Pubkey.Hex(), err) - } - privateKey, err := eth2types.BLSPrivateKeyFromBytes(decryptedKey) - if err != nil { - return nil, fmt.Errorf("error recreating private key for validator %s: %w", keystore.Pubkey.Hex(), err) - } - - // Verify the private key matches the public key - reconstructedPubkey := types.BytesToValidatorPubkey(privateKey.PublicKey().Marshal()) - if reconstructedPubkey != keystore.Pubkey { - return nil, fmt.Errorf("private keystore file %s claims to be for validator %s but it's for validator %s", file.Name(), keystore.Pubkey.Hex(), reconstructedPubkey.Hex()) - } - - // Store the key - if !testOnly { - err = w.StoreValidatorKey(privateKey, keystore.Path) - if err != nil { - return nil, fmt.Errorf("error storing private keystore for %s: %w", reconstructedPubkey.Hex(), err) - } - } - - // Remove the pubkey from pending minipools to handle - delete(pubkeyMap, reconstructedPubkey) - } - } - } - - return pubkeyMap, nil - -} From 41fc4fad7ac812c2b0a7700afe10a46bf3a77147 Mon Sep 17 00:00:00 2001 From: Jacob Shufro Date: Sat, 25 Jul 2026 14:08:50 -0400 Subject: [PATCH 02/12] Remove shared/utils/api --- bindings/auction/auction.go | 17 +- bindings/dao/protocol/proposal.go | 23 +- bindings/dao/protocol/proposals.go | 81 ++-- bindings/dao/protocol/verify.go | 27 +- bindings/dao/security/actions.go | 21 +- bindings/dao/security/proposals.go | 29 +- bindings/dao/trustednode/actions.go | 21 +- bindings/dao/trustednode/proposals.go | 61 +-- bindings/dao/upgrades/upgrades.go | 5 +- bindings/deposit/deposit-pool.go | 5 +- bindings/deposit/deposit.go | 9 +- bindings/{utils/eth => erc20}/erc20.go | 5 +- bindings/legacy/v1.0.0/rewards/node.go | 9 +- bindings/legacy/v1.0.0/rewards/rewards.go | 3 +- .../legacy/v1.0.0/rewards/trusted-node.go | 9 +- bindings/legacy/v1.1.0-rc1/rewards/rewards.go | 11 +- bindings/legacy/v1.1.0/network/prices.go | 5 +- bindings/legacy/v1.1.0/node/deposit.go | 5 +- bindings/legacy/v1.1.0/node/staking.go | 9 +- bindings/legacy/v1.2.0/network/balances.go | 5 +- bindings/legacy/v1.2.0/network/prices.go | 5 +- bindings/legacy/v1.3.1/node/deposit.go | 13 +- bindings/legacy/v1.3.1/node/staking.go | 21 +- bindings/legacy/v1.3.1/protocol/node.go | 5 +- .../v1.3.1/rewards/distributor-mainnet.go | 9 +- bindings/legacy/v1.3.1/rewards/rewards.go | 9 +- bindings/{utils/eth => logs}/logs.go | 2 +- bindings/megapool/megapool-contract.go | 23 +- bindings/megapool/megapool-interface.go | 23 +- bindings/megapool/megapool-manager.go | 25 +- bindings/megapool/megapool-penalties.go | 5 +- bindings/minipool/minipool-contract-v2.go | 28 +- bindings/minipool/minipool-contract-v3.go | 32 +- bindings/minipool/minipool-interface.go | 17 +- bindings/minipool/status.go | 5 +- bindings/network/balances.go | 12 +- bindings/network/penalties.go | 5 +- bindings/network/prices.go | 13 +- bindings/network/voting.go | 5 +- bindings/node/deposit.go | 35 +- bindings/node/distributor.go | 3 +- bindings/node/node.go | 37 +- bindings/node/staking.go | 25 +- bindings/rewards/distributor-mainnet.go | 9 +- bindings/rewards/rewards.go | 9 +- bindings/rocketpool/contract.go | 23 +- bindings/settings/protocol/auction.go | 15 +- bindings/settings/protocol/deposit.go | 19 +- bindings/settings/protocol/megapool.go | 17 +- bindings/settings/protocol/minipool.go | 15 +- bindings/settings/protocol/network.go | 41 +- bindings/settings/protocol/node.go | 15 +- bindings/settings/protocol/proposals.go | 21 +- bindings/settings/protocol/rewards.go | 3 +- bindings/settings/protocol/security.go | 11 +- bindings/settings/security/auction.go | 5 +- bindings/settings/security/deposit.go | 5 +- bindings/settings/security/minipool.go | 5 +- bindings/settings/security/network.go | 7 +- bindings/settings/security/node.go | 9 +- bindings/settings/trustednode/members.go | 15 +- bindings/settings/trustednode/minipool.go | 13 +- bindings/settings/trustednode/proposals.go | 11 +- bindings/storage/rocket-storage.go | 5 +- bindings/tokens/reth.go | 17 +- bindings/tokens/rpl-fixed.go | 13 +- bindings/tokens/rpl.go | 21 +- bindings/tokens/tokens.go | 7 +- bindings/transactions/gaslimit/gas.go | 72 ++++ .../eth => transactions}/transactions.go | 62 ++- bindings/utils/deposit_retrieval.go | 4 +- rocketpool-cli/auction/bid-lot.go | 2 +- rocketpool-cli/auction/claim-lot.go | 16 +- rocketpool-cli/auction/create-lot.go | 2 +- rocketpool-cli/auction/recover-lot.go | 16 +- rocketpool-cli/claims/claim-all.go | 131 +++--- rocketpool-cli/megapool/claim.go | 2 +- rocketpool-cli/megapool/delegate.go | 2 +- rocketpool-cli/megapool/deposit.go | 2 +- rocketpool-cli/megapool/dissolve-validator.go | 2 +- rocketpool-cli/megapool/distribute.go | 2 +- rocketpool-cli/megapool/exit-queue.go | 9 +- .../megapool/notify-final-balance.go | 2 +- .../megapool/notify-validator-exit.go | 2 +- rocketpool-cli/megapool/reduce-bond.go | 2 +- rocketpool-cli/megapool/repay-debt.go | 2 +- rocketpool-cli/megapool/stake.go | 2 +- rocketpool-cli/minipool/close.go | 9 +- rocketpool-cli/minipool/delegate.go | 14 +- rocketpool-cli/minipool/distribute.go | 16 +- rocketpool-cli/minipool/refund.go | 14 +- rocketpool-cli/minipool/rescue-dissolved.go | 2 +- rocketpool-cli/minipool/stake.go | 15 +- rocketpool-cli/node/allow-lock-rpl.go | 2 +- rocketpool-cli/node/claim-rewards.go | 4 +- .../node/claim-unclaimed-rewards.go | 2 +- rocketpool-cli/node/distributor.go | 4 +- .../node/primary-withdrawal-address.go | 6 +- rocketpool-cli/node/register.go | 2 +- rocketpool-cli/node/rpl-withdrawal-address.go | 6 +- rocketpool-cli/node/send-message.go | 2 +- rocketpool-cli/node/send.go | 8 +- rocketpool-cli/node/set-timezone.go | 2 +- rocketpool-cli/node/smoothing-pool.go | 4 +- rocketpool-cli/node/stake-rpl-whitelist.go | 4 +- rocketpool-cli/node/stake-rpl.go | 8 +- rocketpool-cli/node/swap-rpl.go | 4 +- rocketpool-cli/node/withdraw-credit.go | 2 +- rocketpool-cli/node/withdraw-eth.go | 2 +- rocketpool-cli/node/withdraw-rpl.go | 8 +- rocketpool-cli/odao/cancel-proposal.go | 2 +- rocketpool-cli/odao/execute-proposal.go | 14 +- rocketpool-cli/odao/execute-upgrade.go | 14 +- rocketpool-cli/odao/join.go | 6 +- rocketpool-cli/odao/leave.go | 2 +- rocketpool-cli/odao/penalise-megapool.go | 2 +- rocketpool-cli/odao/propose-invite.go | 2 +- rocketpool-cli/odao/propose-kick.go | 2 +- rocketpool-cli/odao/propose-leave.go | 2 +- rocketpool-cli/odao/propose-settings.go | 26 +- rocketpool-cli/odao/vote-proposal.go | 2 +- rocketpool-cli/pdao/claim-bonds.go | 14 +- rocketpool-cli/pdao/defeat-proposal.go | 2 +- rocketpool-cli/pdao/execute-proposal.go | 14 +- rocketpool-cli/pdao/finalize-proposal.go | 2 +- rocketpool-cli/pdao/invite-sc.go | 2 +- rocketpool-cli/pdao/kick-sc.go | 4 +- rocketpool-cli/pdao/one-time-spend.go | 2 +- rocketpool-cli/pdao/percentages.go | 2 +- rocketpool-cli/pdao/propose-settings.go | 2 +- rocketpool-cli/pdao/recurring-spend-update.go | 2 +- rocketpool-cli/pdao/recurring-spend.go | 2 +- rocketpool-cli/pdao/replace-sc.go | 2 +- rocketpool-cli/pdao/set-allow-list.go | 2 +- rocketpool-cli/pdao/set-signalling-address.go | 4 +- rocketpool-cli/pdao/vote-proposal.go | 2 +- rocketpool-cli/pdao/voting.go | 2 +- rocketpool-cli/queue/assign-deposits.go | 2 +- rocketpool-cli/queue/process.go | 2 +- rocketpool-cli/security/cancel-proposal.go | 2 +- rocketpool-cli/security/execute-proposal.go | 14 +- rocketpool-cli/security/join.go | 2 +- rocketpool-cli/security/leave.go | 2 +- rocketpool-cli/security/propose-leave.go | 2 +- rocketpool-cli/security/propose-settings.go | 2 +- rocketpool-cli/security/vote-proposal.go | 2 +- rocketpool-cli/wallet/ens-name.go | 2 +- rocketpool/api/auction/bid-lot.go | 4 +- rocketpool/api/auction/claim-lot.go | 4 +- rocketpool/api/auction/create-lot.go | 4 +- rocketpool/api/auction/recover-lot.go | 4 +- rocketpool/api/auction/routes.go | 42 +- rocketpool/api/debug/routes.go | 9 +- rocketpool/api/megapool/claim-refunds.go | 4 +- rocketpool/api/megapool/delegate.go | 8 +- rocketpool/api/megapool/dissolve-validator.go | 4 +- .../api/megapool/dissolve-with-proof.go | 4 +- rocketpool/api/megapool/distribute.go | 4 +- rocketpool/api/megapool/exit-queue.go | 4 +- .../api/megapool/notify-final-balance.go | 4 +- .../api/megapool/notify-validator-exit.go | 4 +- rocketpool/api/megapool/reduce-bond.go | 4 +- rocketpool/api/megapool/repay-debt.go | 4 +- rocketpool/api/megapool/routes.go | 152 +++---- rocketpool/api/megapool/stake.go | 4 +- rocketpool/api/minipool/close.go | 12 +- rocketpool/api/minipool/delegate.go | 8 +- rocketpool/api/minipool/dissolve.go | 4 +- rocketpool/api/minipool/distribute.go | 2 +- rocketpool/api/minipool/promote.go | 4 +- rocketpool/api/minipool/refund.go | 4 +- rocketpool/api/minipool/rescue-dissolved.go | 7 +- rocketpool/api/minipool/routes.go | 130 +++--- rocketpool/api/minipool/stake.go | 4 +- rocketpool/api/network/routes.go | 27 +- rocketpool/api/node/burn.go | 4 +- rocketpool/api/node/claim-rewards.go | 12 +- rocketpool/api/node/claim-rpl.go | 4 +- .../api/node/claim-unclaimed-rewards.go | 2 +- rocketpool/api/node/create-vacant-minipool.go | 4 +- rocketpool/api/node/deposit.go | 4 +- rocketpool/api/node/distributor.go | 8 +- rocketpool/api/node/express-ticket.go | 4 +- .../api/node/primary-withdrawal-address.go | 8 +- rocketpool/api/node/register.go | 4 +- rocketpool/api/node/routes.go | 306 ++++++------- rocketpool/api/node/rpl-withdrawal-address.go | 8 +- rocketpool/api/node/send-message.go | 8 +- rocketpool/api/node/send.go | 30 +- rocketpool/api/node/set-rpl-lock-allowed.go | 4 +- .../api/node/set-stake-rpl-for-allowed.go | 4 +- rocketpool/api/node/set-timezone.go | 4 +- rocketpool/api/node/smoothing-pool.go | 4 +- rocketpool/api/node/stake-rpl.go | 8 +- rocketpool/api/node/swap-rpl.go | 8 +- rocketpool/api/node/unstake-rpl.go | 4 +- rocketpool/api/node/withdraw-credit.go | 4 +- rocketpool/api/node/withdraw-eth.go | 4 +- rocketpool/api/node/withdraw-legacy-rpl.go | 4 +- rocketpool/api/node/withdraw-rpl.go | 8 +- rocketpool/api/odao/cancel-proposal.go | 4 +- rocketpool/api/odao/execute-proposal.go | 4 +- rocketpool/api/odao/join.go | 6 +- rocketpool/api/odao/leave.go | 4 +- rocketpool/api/odao/penalise-megapool.go | 4 +- rocketpool/api/odao/propose-invite.go | 4 +- rocketpool/api/odao/propose-kick.go | 4 +- rocketpool/api/odao/propose-leave.go | 4 +- rocketpool/api/odao/propose-settings.go | 52 +-- rocketpool/api/odao/routes.go | 230 +++++----- rocketpool/api/odao/vote-proposal.go | 4 +- rocketpool/api/pdao/claim-bonds.go | 10 +- rocketpool/api/pdao/defeat-proposal.go | 4 +- rocketpool/api/pdao/execute-proposal.go | 4 +- rocketpool/api/pdao/finalize-proposal.go | 4 +- rocketpool/api/pdao/invite-security.go | 4 +- rocketpool/api/pdao/kick-multi-security.go | 4 +- rocketpool/api/pdao/kick-security.go | 4 +- rocketpool/api/pdao/one-time-spend.go | 4 +- rocketpool/api/pdao/override-vote.go | 4 +- rocketpool/api/pdao/percentages.go | 4 +- rocketpool/api/pdao/propose-settings.go | 148 ++++--- rocketpool/api/pdao/recurring-spend.go | 4 +- rocketpool/api/pdao/replace-security.go | 4 +- rocketpool/api/pdao/routes.go | 200 ++++----- rocketpool/api/pdao/set-allow-list.go | 4 +- rocketpool/api/pdao/set-snapshot-address.go | 16 +- rocketpool/api/pdao/update-recurring-spend.go | 4 +- rocketpool/api/pdao/vote-proposal.go | 4 +- rocketpool/api/pdao/voting.go | 4 +- rocketpool/api/queue/assign-deposits.go | 4 +- rocketpool/api/queue/process.go | 4 +- rocketpool/api/queue/routes.go | 26 +- .../api/response/response.go | 2 +- rocketpool/api/security/cancel-proposal.go | 4 +- rocketpool/api/security/execute-proposal.go | 4 +- rocketpool/api/security/join.go | 4 +- rocketpool/api/security/leave.go | 4 +- rocketpool/api/security/propose-leave.go | 4 +- rocketpool/api/security/propose-settings.go | 30 +- rocketpool/api/security/routes.go | 66 +-- rocketpool/api/security/vote-proposal.go | 4 +- rocketpool/api/service/routes.go | 11 +- rocketpool/api/upgrade/execute-upgrade.go | 4 +- rocketpool/api/upgrade/routes.go | 14 +- rocketpool/api/version.go | 6 +- rocketpool/api/wait.go | 8 +- rocketpool/api/wallet/ens-name.go | 16 +- rocketpool/api/wallet/routes.go | 32 +- rocketpool/eip712/eip712.go | 60 +++ rocketpool/eip712/eip712_test.go | 58 +++ rocketpool/node/defend-challenge-exit.go | 15 +- rocketpool/node/defend-pdao-props.go | 10 +- rocketpool/node/distribute-minipools.go | 10 +- rocketpool/node/notify-final-balance.go | 10 +- rocketpool/node/notify-validator-exit.go | 10 +- .../node/prestake-megapool-validator.go | 10 +- rocketpool/node/provision-express-tickets.go | 10 +- rocketpool/node/routes/routes.go | 4 +- rocketpool/node/set-latest-delegate.go | 10 +- rocketpool/node/stake-megapool-validator.go | 10 +- rocketpool/node/verify-pdao-props.go | 18 +- rocketpool/watchtower/challenge-exit.go | 10 +- .../watchtower/check-solo-migrations.go | 10 +- .../dissolve-invalid-credentials.go | 10 +- .../dissolve-timed-out-megapool-validators.go | 10 +- .../dissolve-timed-out-minipools.go | 10 +- .../watchtower/finalize-pdao-proposals.go | 10 +- rocketpool/watchtower/respond-challenges.go | 10 +- .../watchtower/submit-network-balances.go | 18 +- .../submit-rewards-tree-stateless.go | 13 +- rocketpool/watchtower/submit-rpl-price.go | 71 ++- .../watchtower/submit-scrub-minipools.go | 10 +- shared/services/gas/gas.go | 33 +- shared/services/rocketpool/node.go | 55 +-- shared/types/api/auction.go | 60 +-- shared/types/api/megapool.go | 36 +- shared/types/api/minipool.go | 104 ++--- shared/types/api/node.go | 404 +++++++++--------- shared/types/api/odao.go | 162 +++---- shared/types/api/pdao.go | 256 +++++------ shared/types/api/queue.go | 27 +- shared/types/api/security.go | 122 +++--- shared/types/api/upgrades.go | 16 +- shared/types/api/wallet.go | 14 +- shared/utils/api/response.go | 9 - shared/utils/api/utils.go | 137 ------ 287 files changed, 2780 insertions(+), 2692 deletions(-) rename bindings/{utils/eth => erc20}/erc20.go (96%) rename bindings/{utils/eth => logs}/logs.go (99%) create mode 100644 bindings/transactions/gaslimit/gas.go rename bindings/{utils/eth => transactions}/transactions.go (57%) rename shared/utils/api/http.go => rocketpool/api/response/response.go (99%) create mode 100644 rocketpool/eip712/eip712.go create mode 100644 rocketpool/eip712/eip712_test.go delete mode 100644 shared/utils/api/response.go delete mode 100644 shared/utils/api/utils.go diff --git a/bindings/auction/auction.go b/bindings/auction/auction.go index 1f750e420..d06074b1b 100644 --- a/bindings/auction/auction.go +++ b/bindings/auction/auction.go @@ -10,6 +10,7 @@ import ( "golang.org/x/sync/errgroup" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" ) // Settings @@ -505,10 +506,10 @@ func GetLotAddressBidAmount(rp *rocketpool.RocketPool, lotIndex uint64, bidder c } // Estimate the gas of CreateLot -func EstimateCreateLotGas(rp *rocketpool.RocketPool, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateCreateLotGas(rp *rocketpool.RocketPool, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketAuctionManager, err := getRocketAuctionManager(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketAuctionManager.GetTransactionGasInfo(opts, "createLot") } @@ -531,10 +532,10 @@ func CreateLot(rp *rocketpool.RocketPool, opts *bind.TransactOpts) (uint64, comm } // Estimate the gas of PlaceBid -func EstimatePlaceBidGas(rp *rocketpool.RocketPool, lotIndex uint64, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimatePlaceBidGas(rp *rocketpool.RocketPool, lotIndex uint64, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketAuctionManager, err := getRocketAuctionManager(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketAuctionManager.GetTransactionGasInfo(opts, "placeBid", big.NewInt(int64(lotIndex))) } @@ -553,10 +554,10 @@ func PlaceBid(rp *rocketpool.RocketPool, lotIndex uint64, opts *bind.TransactOpt } // Estimate the gas of ClaimBid -func EstimateClaimBidGas(rp *rocketpool.RocketPool, lotIndex uint64, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateClaimBidGas(rp *rocketpool.RocketPool, lotIndex uint64, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketAuctionManager, err := getRocketAuctionManager(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketAuctionManager.GetTransactionGasInfo(opts, "claimBid", big.NewInt(int64(lotIndex))) } @@ -575,10 +576,10 @@ func ClaimBid(rp *rocketpool.RocketPool, lotIndex uint64, opts *bind.TransactOpt } // Estimate the gas of RecoverUnclaimedRPL -func EstimateRecoverUnclaimedRPLGas(rp *rocketpool.RocketPool, lotIndex uint64, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateRecoverUnclaimedRPLGas(rp *rocketpool.RocketPool, lotIndex uint64, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketAuctionManager, err := getRocketAuctionManager(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketAuctionManager.GetTransactionGasInfo(opts, "recoverUnclaimedRPL", big.NewInt(int64(lotIndex))) } diff --git a/bindings/dao/protocol/proposal.go b/bindings/dao/protocol/proposal.go index f5c7600fa..47b99728d 100644 --- a/bindings/dao/protocol/proposal.go +++ b/bindings/dao/protocol/proposal.go @@ -17,6 +17,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/dao" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/types" strutils "github.com/rocket-pool/smartnode/bindings/utils/strings" ) @@ -579,14 +580,14 @@ func GetAddressVoteDirection(rp *rocketpool.RocketPool, proposalId uint64, addre // ==================== // Estimate the gas of a proposal submission -func estimateProposalGas(rp *rocketpool.RocketPool, message string, payload []byte, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func estimateProposalGas(rp *rocketpool.RocketPool, message string, payload []byte, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAOProtocolProposal, err := getRocketDAOProtocolProposal(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } err = simulateProposalExecution(rp, payload) if err != nil { - return rocketpool.GasInfo{}, fmt.Errorf("error simulating proposal execution: %w", err) + return gaslimit.Limits{}, fmt.Errorf("error simulating proposal execution: %w", err) } return rocketDAOProtocolProposal.GetTransactionGasInfo(opts, "propose", message, payload, blockNumber, treeNodes) } @@ -610,10 +611,10 @@ func submitProposal(rp *rocketpool.RocketPool, message string, payload []byte, b } // Estimate the gas of VoteOnProposal -func EstimateVoteOnProposalGas(rp *rocketpool.RocketPool, proposalId uint64, voteDirection types.VoteDirection, votingPower *big.Int, nodeIndex uint64, witness []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateVoteOnProposalGas(rp *rocketpool.RocketPool, proposalId uint64, voteDirection types.VoteDirection, votingPower *big.Int, nodeIndex uint64, witness []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAOProtocolProposal, err := getRocketDAOProtocolProposal(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketDAOProtocolProposal.GetTransactionGasInfo(opts, "vote", big.NewInt(int64(proposalId)), voteDirection, votingPower, big.NewInt(int64(nodeIndex)), witness) } @@ -632,10 +633,10 @@ func VoteOnProposal(rp *rocketpool.RocketPool, proposalId uint64, voteDirection } // Estimate the gas of OverrideVote -func EstimateOverrideVoteGas(rp *rocketpool.RocketPool, proposalId uint64, voteDirection types.VoteDirection, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateOverrideVoteGas(rp *rocketpool.RocketPool, proposalId uint64, voteDirection types.VoteDirection, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAOProtocolProposal, err := getRocketDAOProtocolProposal(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketDAOProtocolProposal.GetTransactionGasInfo(opts, "overrideVote", big.NewInt(int64(proposalId)), voteDirection) } @@ -654,10 +655,10 @@ func OverrideVote(rp *rocketpool.RocketPool, proposalId uint64, voteDirection ty } // Estimate the gas of Finalize -func EstimateFinalizeGas(rp *rocketpool.RocketPool, proposalId uint64, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateFinalizeGas(rp *rocketpool.RocketPool, proposalId uint64, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAOProtocolProposal, err := getRocketDAOProtocolProposal(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketDAOProtocolProposal.GetTransactionGasInfo(opts, "finalise", big.NewInt(int64(proposalId))) } @@ -676,10 +677,10 @@ func Finalize(rp *rocketpool.RocketPool, proposalId uint64, opts *bind.TransactO } // Estimate the gas of ExecuteProposal -func EstimateExecuteProposalGas(rp *rocketpool.RocketPool, proposalId uint64, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateExecuteProposalGas(rp *rocketpool.RocketPool, proposalId uint64, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAOProtocolProposal, err := getRocketDAOProtocolProposal(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketDAOProtocolProposal.GetTransactionGasInfo(opts, "execute", big.NewInt(int64(proposalId))) } diff --git a/bindings/dao/protocol/proposals.go b/bindings/dao/protocol/proposals.go index 849908c5b..f853dff71 100644 --- a/bindings/dao/protocol/proposals.go +++ b/bindings/dao/protocol/proposals.go @@ -11,22 +11,23 @@ import ( "github.com/ethereum/go-ethereum/common/math" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/types" ) // Estimate the gas of ProposeSetMulti -func EstimateProposeSetMultiGas(rp *rocketpool.RocketPool, message string, contractNames []string, settingPaths []string, settingTypes []types.ProposalSettingType, values []any, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeSetMultiGas(rp *rocketpool.RocketPool, message string, contractNames []string, settingPaths []string, settingTypes []types.ProposalSettingType, values []any, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAOProtocolProposals, err := getRocketDAOProtocolProposals(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } encodedValues, err := abiEncodeMultiValues(settingTypes, values) if err != nil { - return rocketpool.GasInfo{}, fmt.Errorf("error ABI encoding values: %w", err) + return gaslimit.Limits{}, fmt.Errorf("error ABI encoding values: %w", err) } payload, err := rocketDAOProtocolProposals.ABI.Pack("proposalSettingMulti", contractNames, settingPaths, settingTypes, encodedValues) if err != nil { - return rocketpool.GasInfo{}, fmt.Errorf("error setting multi-set proposal payload: %w", err) + return gaslimit.Limits{}, fmt.Errorf("error setting multi-set proposal payload: %w", err) } return estimateProposalGas(rp, message, payload, blockNumber, treeNodes, opts) } @@ -49,14 +50,14 @@ func ProposeSetMulti(rp *rocketpool.RocketPool, message string, contractNames [] } // Estimate the gas of ProposeSetBool -func EstimateProposeSetBoolGas(rp *rocketpool.RocketPool, message, contractName, settingPath string, value bool, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeSetBoolGas(rp *rocketpool.RocketPool, message, contractName, settingPath string, value bool, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAOProtocolProposals, err := getRocketDAOProtocolProposals(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } payload, err := rocketDAOProtocolProposals.ABI.Pack("proposalSettingBool", contractName, settingPath, value) if err != nil { - return rocketpool.GasInfo{}, fmt.Errorf("error setting bool setting proposal payload: %w", err) + return gaslimit.Limits{}, fmt.Errorf("error setting bool setting proposal payload: %w", err) } return estimateProposalGas(rp, message, payload, blockNumber, treeNodes, opts) } @@ -75,14 +76,14 @@ func ProposeSetBool(rp *rocketpool.RocketPool, message, contractName, settingPat } // Estimate the gas of ProposeSetUint -func EstimateProposeSetUintGas(rp *rocketpool.RocketPool, message, contractName, settingPath string, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeSetUintGas(rp *rocketpool.RocketPool, message, contractName, settingPath string, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAOProtocolProposals, err := getRocketDAOProtocolProposals(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } payload, err := rocketDAOProtocolProposals.ABI.Pack("proposalSettingUint", contractName, settingPath, value) if err != nil { - return rocketpool.GasInfo{}, fmt.Errorf("error encoding set uint setting proposal payload: %w", err) + return gaslimit.Limits{}, fmt.Errorf("error encoding set uint setting proposal payload: %w", err) } return estimateProposalGas(rp, message, payload, blockNumber, treeNodes, opts) } @@ -101,14 +102,14 @@ func ProposeSetUint(rp *rocketpool.RocketPool, message, contractName, settingPat } // Estimate the gas of ProposeSetAddress -func EstimateProposeSetAddressGas(rp *rocketpool.RocketPool, message, contractName, settingPath string, value common.Address, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeSetAddressGas(rp *rocketpool.RocketPool, message, contractName, settingPath string, value common.Address, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAOProtocolProposals, err := getRocketDAOProtocolProposals(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } payload, err := rocketDAOProtocolProposals.ABI.Pack("proposalSettingAddress", contractName, settingPath, value) if err != nil { - return rocketpool.GasInfo{}, fmt.Errorf("error encoding set address setting proposal payload: %w", err) + return gaslimit.Limits{}, fmt.Errorf("error encoding set address setting proposal payload: %w", err) } return estimateProposalGas(rp, message, payload, blockNumber, treeNodes, opts) } @@ -127,14 +128,14 @@ func ProposeSetAddress(rp *rocketpool.RocketPool, message, contractName, setting } // Estimate the gas of proposalSettingAddressList -func EstimateProposeSetAddressListGas(rp *rocketpool.RocketPool, message, contractName, settingPath string, value []common.Address, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeSetAddressListGas(rp *rocketpool.RocketPool, message, contractName, settingPath string, value []common.Address, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAOProtocolProposals, err := getRocketDAOProtocolProposals(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } payload, err := rocketDAOProtocolProposals.ABI.Pack("proposalSettingAddressList", contractName, settingPath, value) if err != nil { - return rocketpool.GasInfo{}, fmt.Errorf("error encoding set address list setting proposal payload: %w", err) + return gaslimit.Limits{}, fmt.Errorf("error encoding set address list setting proposal payload: %w", err) } return estimateProposalGas(rp, message, payload, blockNumber, treeNodes, opts) } @@ -153,14 +154,14 @@ func ProposeSetAddressList(rp *rocketpool.RocketPool, message, contractName, set } // Estimate the gas of ProposeSetRewardsPercentage -func EstimateProposeSetRewardsPercentageGas(rp *rocketpool.RocketPool, message string, odaoPercentage *big.Int, pdaoPercentage *big.Int, nodePercentage *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeSetRewardsPercentageGas(rp *rocketpool.RocketPool, message string, odaoPercentage *big.Int, pdaoPercentage *big.Int, nodePercentage *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAOProtocolProposals, err := getRocketDAOProtocolProposals(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } payload, err := rocketDAOProtocolProposals.ABI.Pack("proposalSettingRewardsClaimers", odaoPercentage, pdaoPercentage, nodePercentage) if err != nil { - return rocketpool.GasInfo{}, fmt.Errorf("error encoding set rewards-claimers percent proposal payload: %w", err) + return gaslimit.Limits{}, fmt.Errorf("error encoding set rewards-claimers percent proposal payload: %w", err) } return estimateProposalGas(rp, message, payload, blockNumber, treeNodes, opts) } @@ -179,14 +180,14 @@ func ProposeSetRewardsPercentage(rp *rocketpool.RocketPool, message string, odao } // Estimate the gas of ProposeOneTimeTreasurySpend -func EstimateProposeOneTimeTreasurySpendGas(rp *rocketpool.RocketPool, message, invoiceID string, recipient common.Address, amount *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeOneTimeTreasurySpendGas(rp *rocketpool.RocketPool, message, invoiceID string, recipient common.Address, amount *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAOProtocolProposals, err := getRocketDAOProtocolProposals(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } payload, err := rocketDAOProtocolProposals.ABI.Pack("proposalTreasuryOneTimeSpend", invoiceID, recipient, amount) if err != nil { - return rocketpool.GasInfo{}, fmt.Errorf("error encoding set spend-treasury percent proposal payload: %w", err) + return gaslimit.Limits{}, fmt.Errorf("error encoding set spend-treasury percent proposal payload: %w", err) } return estimateProposalGas(rp, message, payload, blockNumber, treeNodes, opts) } @@ -205,14 +206,14 @@ func ProposeOneTimeTreasurySpend(rp *rocketpool.RocketPool, message, invoiceID s } // Estimate the gas of ProposeRecurringTreasurySpend -func EstimateProposeRecurringTreasurySpendGas(rp *rocketpool.RocketPool, message string, contractName string, recipient common.Address, amountPerPeriod *big.Int, periodLength time.Duration, startTime time.Time, numberOfPeriods uint64, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeRecurringTreasurySpendGas(rp *rocketpool.RocketPool, message string, contractName string, recipient common.Address, amountPerPeriod *big.Int, periodLength time.Duration, startTime time.Time, numberOfPeriods uint64, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAOProtocolProposals, err := getRocketDAOProtocolProposals(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } payload, err := rocketDAOProtocolProposals.ABI.Pack("proposalTreasuryNewContract", contractName, recipient, amountPerPeriod, big.NewInt(int64(periodLength.Seconds())), big.NewInt(startTime.Unix()), big.NewInt(int64(numberOfPeriods))) if err != nil { - return rocketpool.GasInfo{}, fmt.Errorf("error encoding proposalTreasuryNewContract payload: %w", err) + return gaslimit.Limits{}, fmt.Errorf("error encoding proposalTreasuryNewContract payload: %w", err) } return estimateProposalGas(rp, message, payload, blockNumber, treeNodes, opts) } @@ -231,14 +232,14 @@ func ProposeRecurringTreasurySpend(rp *rocketpool.RocketPool, message string, co } // Estimate the gas of ProposeRecurringTreasurySpendUpdate -func EstimateProposeRecurringTreasurySpendUpdateGas(rp *rocketpool.RocketPool, message string, contractName string, recipient common.Address, amountPerPeriod *big.Int, periodLength time.Duration, numberOfPeriods uint64, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeRecurringTreasurySpendUpdateGas(rp *rocketpool.RocketPool, message string, contractName string, recipient common.Address, amountPerPeriod *big.Int, periodLength time.Duration, numberOfPeriods uint64, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAOProtocolProposals, err := getRocketDAOProtocolProposals(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } payload, err := rocketDAOProtocolProposals.ABI.Pack("proposalTreasuryUpdateContract", contractName, recipient, amountPerPeriod, big.NewInt(int64(periodLength.Seconds())), big.NewInt(int64(numberOfPeriods))) if err != nil { - return rocketpool.GasInfo{}, fmt.Errorf("error encoding proposalTreasuryUpdateContract payload: %w", err) + return gaslimit.Limits{}, fmt.Errorf("error encoding proposalTreasuryUpdateContract payload: %w", err) } return estimateProposalGas(rp, message, payload, blockNumber, treeNodes, opts) } @@ -257,14 +258,14 @@ func ProposeRecurringTreasurySpendUpdate(rp *rocketpool.RocketPool, message stri } // Estimate the gas of ProposeInviteToSecurityCouncil -func EstimateProposeInviteToSecurityCouncilGas(rp *rocketpool.RocketPool, message string, id string, address common.Address, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeInviteToSecurityCouncilGas(rp *rocketpool.RocketPool, message string, id string, address common.Address, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAOProtocolProposals, err := getRocketDAOProtocolProposals(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } payload, err := rocketDAOProtocolProposals.ABI.Pack("proposalSecurityInvite", id, address) if err != nil { - return rocketpool.GasInfo{}, fmt.Errorf("error encoding proposalSecurityInvite payload: %w", err) + return gaslimit.Limits{}, fmt.Errorf("error encoding proposalSecurityInvite payload: %w", err) } return estimateProposalGas(rp, message, payload, blockNumber, treeNodes, opts) } @@ -283,14 +284,14 @@ func ProposeInviteToSecurityCouncil(rp *rocketpool.RocketPool, message string, i } // Estimate the gas of ProposeKickFromSecurityCouncil -func EstimateProposeKickFromSecurityCouncilGas(rp *rocketpool.RocketPool, message string, address common.Address, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeKickFromSecurityCouncilGas(rp *rocketpool.RocketPool, message string, address common.Address, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAOProtocolProposals, err := getRocketDAOProtocolProposals(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } payload, err := rocketDAOProtocolProposals.ABI.Pack("proposalSecurityKick", address) if err != nil { - return rocketpool.GasInfo{}, fmt.Errorf("error encoding proposalSecurityKick payload: %w", err) + return gaslimit.Limits{}, fmt.Errorf("error encoding proposalSecurityKick payload: %w", err) } return estimateProposalGas(rp, message, payload, blockNumber, treeNodes, opts) } @@ -309,14 +310,14 @@ func ProposeKickFromSecurityCouncil(rp *rocketpool.RocketPool, message string, a } // Estimate the gas of ProposeKickMultiFromSecurityCouncil -func EstimateProposeKickMultiFromSecurityCouncilGas(rp *rocketpool.RocketPool, message string, addresses []common.Address, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeKickMultiFromSecurityCouncilGas(rp *rocketpool.RocketPool, message string, addresses []common.Address, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAOProtocolProposals, err := getRocketDAOProtocolProposals(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } payload, err := rocketDAOProtocolProposals.ABI.Pack("proposalSecurityKickMulti", addresses) if err != nil { - return rocketpool.GasInfo{}, fmt.Errorf("error encoding proposalSecurityKickMulti payload: %w", err) + return gaslimit.Limits{}, fmt.Errorf("error encoding proposalSecurityKickMulti payload: %w", err) } return estimateProposalGas(rp, message, payload, blockNumber, treeNodes, opts) } @@ -335,14 +336,14 @@ func ProposeKickMultiFromSecurityCouncil(rp *rocketpool.RocketPool, message stri } // Estimate the gas of ProposeReplaceSecurityCouncilMember -func EstimateProposeReplaceSecurityCouncilMemberGas(rp *rocketpool.RocketPool, message string, existingMemberAddress common.Address, newMemberID string, newMemberAddress common.Address, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeReplaceSecurityCouncilMemberGas(rp *rocketpool.RocketPool, message string, existingMemberAddress common.Address, newMemberID string, newMemberAddress common.Address, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAOProtocolProposals, err := getRocketDAOProtocolProposals(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } payload, err := rocketDAOProtocolProposals.ABI.Pack("proposalSecurityReplace", existingMemberAddress, newMemberID, newMemberAddress) if err != nil { - return rocketpool.GasInfo{}, fmt.Errorf("error encoding proposalSecurityReplace payload: %w", err) + return gaslimit.Limits{}, fmt.Errorf("error encoding proposalSecurityReplace payload: %w", err) } return estimateProposalGas(rp, message, payload, blockNumber, treeNodes, opts) } diff --git a/bindings/dao/protocol/verify.go b/bindings/dao/protocol/verify.go index aa4f296d3..22a7f3a44 100755 --- a/bindings/dao/protocol/verify.go +++ b/bindings/dao/protocol/verify.go @@ -12,9 +12,10 @@ import ( "github.com/ethereum/go-ethereum/common" "golang.org/x/sync/errgroup" + "github.com/rocket-pool/smartnode/bindings/logs" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/bindings/utils/multicall" ) @@ -94,10 +95,10 @@ func GetNode(rp *rocketpool.RocketPool, proposalId uint64, index uint64, opts *b } // Estimate the gas of CreateChallenge -func EstimateCreateChallengeGas(rp *rocketpool.RocketPool, proposalId uint64, index uint64, node types.VotingTreeNode, witness []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateCreateChallengeGas(rp *rocketpool.RocketPool, proposalId uint64, index uint64, node types.VotingTreeNode, witness []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAOProtocolVerifier, err := getRocketDAOProtocolVerifier(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketDAOProtocolVerifier.GetTransactionGasInfo(opts, "createChallenge", big.NewInt(int64(proposalId)), big.NewInt((int64(index))), node, witness) } @@ -116,10 +117,10 @@ func CreateChallenge(rp *rocketpool.RocketPool, proposalId uint64, index uint64, } // Estimate the gas of SubmitRoot -func EstimateSubmitRootGas(rp *rocketpool.RocketPool, proposalId uint64, index uint64, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateSubmitRootGas(rp *rocketpool.RocketPool, proposalId uint64, index uint64, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAOProtocolVerifier, err := getRocketDAOProtocolVerifier(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketDAOProtocolVerifier.GetTransactionGasInfo(opts, "submitRoot", big.NewInt(int64(proposalId)), big.NewInt((int64(index))), treeNodes) } @@ -306,7 +307,7 @@ func GetRootSubmittedEvents(rp *rocketpool.RocketPool, proposalIDs []uint64, int topicFilter := [][]common.Hash{{rootSubmittedEvent.ID}, idBuffers} // Get the event logs - logs, err := eth.GetLogs(rp, addressFilter, topicFilter, intervalSize, startBlock, endBlock, nil) + logs, err := logs.GetLogs(rp, addressFilter, topicFilter, intervalSize, startBlock, endBlock, nil) if err != nil { return nil, err } @@ -384,7 +385,7 @@ func GetChallengeSubmittedEvents(rp *rocketpool.RocketPool, proposalIDs []uint64 topicFilter := [][]common.Hash{{challengeSubmittedEvent.ID}, idBuffers} // Get the event logs - logs, err := eth.GetLogs(rp, addressFilter, topicFilter, intervalSize, startBlock, endBlock, nil) + logs, err := logs.GetLogs(rp, addressFilter, topicFilter, intervalSize, startBlock, endBlock, nil) if err != nil { return nil, err } @@ -429,10 +430,10 @@ func GetChallengeSubmittedEvents(rp *rocketpool.RocketPool, proposalIDs []uint64 } // Estimate the gas of ClaimBondChallenger -func EstimateClaimBondChallengerGas(rp *rocketpool.RocketPool, proposalID uint64, indices []uint64, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateClaimBondChallengerGas(rp *rocketpool.RocketPool, proposalID uint64, indices []uint64, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAOProtocolVerifier, err := getRocketDAOProtocolVerifier(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } // Make the args proposalIDBig := big.NewInt(int64(proposalID)) @@ -463,10 +464,10 @@ func ClaimBondChallenger(rp *rocketpool.RocketPool, proposalID uint64, indices [ } // Estimate the gas of ClaimBondProposer -func EstimateClaimBondProposerGas(rp *rocketpool.RocketPool, proposalID uint64, indices []uint64, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateClaimBondProposerGas(rp *rocketpool.RocketPool, proposalID uint64, indices []uint64, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAOProtocolVerifier, err := getRocketDAOProtocolVerifier(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } // Make the args proposalIDBig := big.NewInt(int64(proposalID)) @@ -497,10 +498,10 @@ func ClaimBondProposer(rp *rocketpool.RocketPool, proposalID uint64, indices []u } // Estimate the gas of DefeatProposal -func EstimateDefeatProposalGas(rp *rocketpool.RocketPool, proposalId uint64, index uint64, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateDefeatProposalGas(rp *rocketpool.RocketPool, proposalId uint64, index uint64, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAOProtocolVerifier, err := getRocketDAOProtocolVerifier(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketDAOProtocolVerifier.GetTransactionGasInfo(opts, "defeatProposal", big.NewInt(int64(proposalId)), big.NewInt(int64(index))) } diff --git a/bindings/dao/security/actions.go b/bindings/dao/security/actions.go index f84378c60..0f87c13b5 100644 --- a/bindings/dao/security/actions.go +++ b/bindings/dao/security/actions.go @@ -8,13 +8,14 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" ) // Estimate the gas of Join -func EstimateJoinGas(rp *rocketpool.RocketPool, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateJoinGas(rp *rocketpool.RocketPool, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAOSecurityActions, err := getRocketDAOSecurityActions(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketDAOSecurityActions.GetTransactionGasInfo(opts, "actionJoin") } @@ -34,10 +35,10 @@ func Join(rp *rocketpool.RocketPool, opts *bind.TransactOpts) (common.Hash, erro } // Estimate the gas of Kick -func EstimateKickGas(rp *rocketpool.RocketPool, address common.Address, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateKickGas(rp *rocketpool.RocketPool, address common.Address, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAOSecurityActions, err := getRocketDAOSecurityActions(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketDAOSecurityActions.GetTransactionGasInfo(opts, "actionKick", address) } @@ -56,10 +57,10 @@ func Kick(rp *rocketpool.RocketPool, address common.Address, opts *bind.Transact } // Estimate the gas of KickMulti -func EstimateKickMultiGas(rp *rocketpool.RocketPool, addresses []common.Address, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateKickMultiGas(rp *rocketpool.RocketPool, addresses []common.Address, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAOSecurityActions, err := getRocketDAOSecurityActions(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketDAOSecurityActions.GetTransactionGasInfo(opts, "actionKickMulti", addresses) } @@ -78,10 +79,10 @@ func KickMulti(rp *rocketpool.RocketPool, addresses []common.Address, opts *bind } // Estimate the gas of RequestLeave -func EstimateRequestLeaveGas(rp *rocketpool.RocketPool, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateRequestLeaveGas(rp *rocketpool.RocketPool, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAOSecurityActions, err := getRocketDAOSecurityActions(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketDAOSecurityActions.GetTransactionGasInfo(opts, "actionRequestLeave") } @@ -100,10 +101,10 @@ func RequestLeave(rp *rocketpool.RocketPool, opts *bind.TransactOpts) (common.Ha } // Estimate the gas of Leave -func EstimateLeaveGas(rp *rocketpool.RocketPool, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateLeaveGas(rp *rocketpool.RocketPool, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAOSecurityActions, err := getRocketDAOSecurityActions(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketDAOSecurityActions.GetTransactionGasInfo(opts, "actionLeave") } diff --git a/bindings/dao/security/proposals.go b/bindings/dao/security/proposals.go index f4a2a2d28..1d6905c06 100644 --- a/bindings/dao/security/proposals.go +++ b/bindings/dao/security/proposals.go @@ -10,17 +10,18 @@ import ( "github.com/rocket-pool/smartnode/bindings/dao" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" ) // Estimate the gas of ProposeSetUint -func EstimateProposeSetUintGas(rp *rocketpool.RocketPool, message, contractName, settingPath string, value *big.Int, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeSetUintGas(rp *rocketpool.RocketPool, message, contractName, settingPath string, value *big.Int, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAOSecurityProposals, err := getRocketDAOSecurityProposals(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } payload, err := rocketDAOSecurityProposals.ABI.Pack("proposalSettingUint", contractName, settingPath, value) if err != nil { - return rocketpool.GasInfo{}, fmt.Errorf("error encoding set uint setting proposal payload: %w", err) + return gaslimit.Limits{}, fmt.Errorf("error encoding set uint setting proposal payload: %w", err) } return EstimateProposalGas(rp, message, payload, opts) } @@ -39,14 +40,14 @@ func ProposeSetUint(rp *rocketpool.RocketPool, message, contractName, settingPat } // Estimate the gas of ProposeSetBool -func EstimateProposeSetBoolGas(rp *rocketpool.RocketPool, message, contractName, settingPath string, value bool, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeSetBoolGas(rp *rocketpool.RocketPool, message, contractName, settingPath string, value bool, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAOSecurityProposals, err := getRocketDAOSecurityProposals(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } payload, err := rocketDAOSecurityProposals.ABI.Pack("proposalSettingBool", contractName, settingPath, value) if err != nil { - return rocketpool.GasInfo{}, fmt.Errorf("error encoding set bool setting proposal payload: %w", err) + return gaslimit.Limits{}, fmt.Errorf("error encoding set bool setting proposal payload: %w", err) } return EstimateProposalGas(rp, message, payload, opts) } @@ -65,10 +66,10 @@ func ProposeSetBool(rp *rocketpool.RocketPool, message, contractName, settingPat } // Estimate the gas of a proposal submission -func EstimateProposalGas(rp *rocketpool.RocketPool, message string, payload []byte, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposalGas(rp *rocketpool.RocketPool, message string, payload []byte, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAOSecurityProposals, err := getRocketDAOSecurityProposals(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketDAOSecurityProposals.GetTransactionGasInfo(opts, "propose", message, payload) } @@ -92,10 +93,10 @@ func SubmitProposal(rp *rocketpool.RocketPool, message string, payload []byte, o } // Estimate the gas of VoteOnProposal -func EstimateVoteOnProposalGas(rp *rocketpool.RocketPool, proposalId uint64, support bool, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateVoteOnProposalGas(rp *rocketpool.RocketPool, proposalId uint64, support bool, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAOSecurityProposals, err := getRocketDAOSecurityProposals(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketDAOSecurityProposals.GetTransactionGasInfo(opts, "vote", big.NewInt(int64(proposalId)), support) } @@ -114,10 +115,10 @@ func VoteOnProposal(rp *rocketpool.RocketPool, proposalId uint64, support bool, } // Estimate the gas of CancelProposal -func EstimateCancelProposalGas(rp *rocketpool.RocketPool, proposalId uint64, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateCancelProposalGas(rp *rocketpool.RocketPool, proposalId uint64, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAOSecurityProposals, err := getRocketDAOSecurityProposals(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketDAOSecurityProposals.GetTransactionGasInfo(opts, "cancel", big.NewInt(int64(proposalId))) } @@ -136,10 +137,10 @@ func CancelProposal(rp *rocketpool.RocketPool, proposalId uint64, opts *bind.Tra } // Estimate the gas of ExecuteProposal -func EstimateExecuteProposalGas(rp *rocketpool.RocketPool, proposalId uint64, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateExecuteProposalGas(rp *rocketpool.RocketPool, proposalId uint64, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAOSecurityProposals, err := getRocketDAOSecurityProposals(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketDAOSecurityProposals.GetTransactionGasInfo(opts, "execute", big.NewInt(int64(proposalId))) } diff --git a/bindings/dao/trustednode/actions.go b/bindings/dao/trustednode/actions.go index bbb2ce109..ea2a35b14 100644 --- a/bindings/dao/trustednode/actions.go +++ b/bindings/dao/trustednode/actions.go @@ -8,15 +8,16 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" + "github.com/rocket-pool/smartnode/bindings/logs" "github.com/rocket-pool/smartnode/bindings/rocketpool" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" ) // Estimate the gas of Join -func EstimateJoinGas(rp *rocketpool.RocketPool, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateJoinGas(rp *rocketpool.RocketPool, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAONodeTrustedActions, err := getRocketDAONodeTrustedActions(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketDAONodeTrustedActions.GetTransactionGasInfo(opts, "actionJoin") } @@ -36,10 +37,10 @@ func Join(rp *rocketpool.RocketPool, opts *bind.TransactOpts) (common.Hash, erro } // Estimate the gas of Leave -func EstimateLeaveGas(rp *rocketpool.RocketPool, rplBondRefundAddress common.Address, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateLeaveGas(rp *rocketpool.RocketPool, rplBondRefundAddress common.Address, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAONodeTrustedActions, err := getRocketDAONodeTrustedActions(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketDAONodeTrustedActions.GetTransactionGasInfo(opts, "actionLeave", rplBondRefundAddress) } @@ -59,10 +60,10 @@ func Leave(rp *rocketpool.RocketPool, rplBondRefundAddress common.Address, opts } // Estimate the gas of MakeChallenge -func EstimateMakeChallengeGas(rp *rocketpool.RocketPool, memberAddress common.Address, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateMakeChallengeGas(rp *rocketpool.RocketPool, memberAddress common.Address, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAONodeTrustedActions, err := getRocketDAONodeTrustedActions(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketDAONodeTrustedActions.GetTransactionGasInfo(opts, "actionChallengeMake", memberAddress) } @@ -81,10 +82,10 @@ func MakeChallenge(rp *rocketpool.RocketPool, memberAddress common.Address, opts } // Estimate the gas of DecideChallenge -func EstimateDecideChallengeGas(rp *rocketpool.RocketPool, memberAddress common.Address, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateDecideChallengeGas(rp *rocketpool.RocketPool, memberAddress common.Address, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAONodeTrustedActions, err := getRocketDAONodeTrustedActions(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketDAONodeTrustedActions.GetTransactionGasInfo(opts, "actionChallengeDecide", memberAddress) } @@ -114,7 +115,7 @@ func GetLatestMemberCountChangedBlock(rp *rocketpool.RocketPool, fromBlock uint6 topicFilter := [][]common.Hash{{rocketDaoNodeTrustedActions.ABI.Events["ActionJoined"].ID, rocketDaoNodeTrustedActions.ABI.Events["ActionLeave"].ID, rocketDaoNodeTrustedActions.ABI.Events["ActionKick"].ID, rocketDaoNodeTrustedActions.ABI.Events["ActionChallengeDecided"].ID}} // Get the event logs - logs, err := eth.GetLogs(rp, addressFilter, topicFilter, intervalSize, big.NewInt(int64(fromBlock)), nil, nil) + logs, err := logs.GetLogs(rp, addressFilter, topicFilter, intervalSize, big.NewInt(int64(fromBlock)), nil, nil) if err != nil { return 0, err } diff --git a/bindings/dao/trustednode/proposals.go b/bindings/dao/trustednode/proposals.go index 899dd3421..379af3454 100644 --- a/bindings/dao/trustednode/proposals.go +++ b/bindings/dao/trustednode/proposals.go @@ -10,19 +10,20 @@ import ( "github.com/rocket-pool/smartnode/bindings/dao" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/utils/strings" ) // Estimate the gas of ProposeInviteMember -func EstimateProposeInviteMemberGas(rp *rocketpool.RocketPool, message string, newMemberAddress common.Address, newMemberId, newMemberUrl string, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeInviteMemberGas(rp *rocketpool.RocketPool, message string, newMemberAddress common.Address, newMemberId, newMemberUrl string, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAONodeTrustedProposals, err := getRocketDAONodeTrustedProposals(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } newMemberUrl = strings.Sanitize(newMemberUrl) payload, err := rocketDAONodeTrustedProposals.ABI.Pack("proposalInvite", newMemberId, newMemberUrl, newMemberAddress) if err != nil { - return rocketpool.GasInfo{}, fmt.Errorf("error encoding invite member proposal payload: %w", err) + return gaslimit.Limits{}, fmt.Errorf("error encoding invite member proposal payload: %w", err) } return EstimateProposalGas(rp, message, payload, opts) } @@ -42,14 +43,14 @@ func ProposeInviteMember(rp *rocketpool.RocketPool, message string, newMemberAdd } // Estimate the gas of ProposeMemberLeave -func EstimateProposeMemberLeaveGas(rp *rocketpool.RocketPool, message string, memberAddress common.Address, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeMemberLeaveGas(rp *rocketpool.RocketPool, message string, memberAddress common.Address, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAONodeTrustedProposals, err := getRocketDAONodeTrustedProposals(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } payload, err := rocketDAONodeTrustedProposals.ABI.Pack("proposalLeave", memberAddress) if err != nil { - return rocketpool.GasInfo{}, fmt.Errorf("error encoding member leave proposal payload: %w", err) + return gaslimit.Limits{}, fmt.Errorf("error encoding member leave proposal payload: %w", err) } return EstimateProposalGas(rp, message, payload, opts) } @@ -68,15 +69,15 @@ func ProposeMemberLeave(rp *rocketpool.RocketPool, message string, memberAddress } // Estimate the gas of ProposeReplaceMember -func EstimateProposeReplaceMemberGas(rp *rocketpool.RocketPool, message string, memberAddress, newMemberAddress common.Address, newMemberId, newMemberUrl string, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeReplaceMemberGas(rp *rocketpool.RocketPool, message string, memberAddress, newMemberAddress common.Address, newMemberId, newMemberUrl string, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAONodeTrustedProposals, err := getRocketDAONodeTrustedProposals(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } newMemberUrl = strings.Sanitize(newMemberUrl) payload, err := rocketDAONodeTrustedProposals.ABI.Pack("proposalReplace", memberAddress, newMemberId, newMemberUrl, newMemberAddress) if err != nil { - return rocketpool.GasInfo{}, fmt.Errorf("error encoding replace member proposal payload: %w", err) + return gaslimit.Limits{}, fmt.Errorf("error encoding replace member proposal payload: %w", err) } return EstimateProposalGas(rp, message, payload, opts) } @@ -96,14 +97,14 @@ func ProposeReplaceMember(rp *rocketpool.RocketPool, message string, memberAddre } // Estimate the gas of ProposeKickMember -func EstimateProposeKickMemberGas(rp *rocketpool.RocketPool, message string, memberAddress common.Address, rplFineAmount *big.Int, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeKickMemberGas(rp *rocketpool.RocketPool, message string, memberAddress common.Address, rplFineAmount *big.Int, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAONodeTrustedProposals, err := getRocketDAONodeTrustedProposals(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } payload, err := rocketDAONodeTrustedProposals.ABI.Pack("proposalKick", memberAddress, rplFineAmount) if err != nil { - return rocketpool.GasInfo{}, fmt.Errorf("error encoding kick member proposal payload: %w", err) + return gaslimit.Limits{}, fmt.Errorf("error encoding kick member proposal payload: %w", err) } return EstimateProposalGas(rp, message, payload, opts) } @@ -122,14 +123,14 @@ func ProposeKickMember(rp *rocketpool.RocketPool, message string, memberAddress } // Estimate the gas of ProposeSetBool -func EstimateProposeSetBoolGas(rp *rocketpool.RocketPool, message, contractName, settingPath string, value bool, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeSetBoolGas(rp *rocketpool.RocketPool, message, contractName, settingPath string, value bool, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAONodeTrustedProposals, err := getRocketDAONodeTrustedProposals(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } payload, err := rocketDAONodeTrustedProposals.ABI.Pack("proposalSettingBool", contractName, settingPath, value) if err != nil { - return rocketpool.GasInfo{}, fmt.Errorf("error encoding set bool setting proposal payload: %w", err) + return gaslimit.Limits{}, fmt.Errorf("error encoding set bool setting proposal payload: %w", err) } return EstimateProposalGas(rp, message, payload, opts) } @@ -148,14 +149,14 @@ func ProposeSetBool(rp *rocketpool.RocketPool, message, contractName, settingPat } // Estimate the gas of ProposeSetUint -func EstimateProposeSetUintGas(rp *rocketpool.RocketPool, message, contractName, settingPath string, value *big.Int, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeSetUintGas(rp *rocketpool.RocketPool, message, contractName, settingPath string, value *big.Int, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAONodeTrustedProposals, err := getRocketDAONodeTrustedProposals(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } payload, err := rocketDAONodeTrustedProposals.ABI.Pack("proposalSettingUint", contractName, settingPath, value) if err != nil { - return rocketpool.GasInfo{}, fmt.Errorf("error encoding set uint setting proposal payload: %w", err) + return gaslimit.Limits{}, fmt.Errorf("error encoding set uint setting proposal payload: %w", err) } return EstimateProposalGas(rp, message, payload, opts) } @@ -174,18 +175,18 @@ func ProposeSetUint(rp *rocketpool.RocketPool, message, contractName, settingPat } // Estimate the gas of ProposeUpgradeContract -func EstimateProposeUpgradeContractGas(rp *rocketpool.RocketPool, message, upgradeType, contractName, contractAbi string, contractAddress common.Address, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeUpgradeContractGas(rp *rocketpool.RocketPool, message, upgradeType, contractName, contractAbi string, contractAddress common.Address, opts *bind.TransactOpts) (gaslimit.Limits, error) { compressedAbi, err := rocketpool.EncodeAbiStr(contractAbi) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } rocketDAONodeTrustedProposals, err := getRocketDAONodeTrustedProposals(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } payload, err := rocketDAONodeTrustedProposals.ABI.Pack("proposalUpgrade", upgradeType, contractName, compressedAbi, contractAddress) if err != nil { - return rocketpool.GasInfo{}, fmt.Errorf("error encoding upgrade contract proposal payload: %w", err) + return gaslimit.Limits{}, fmt.Errorf("error encoding upgrade contract proposal payload: %w", err) } return EstimateProposalGas(rp, message, payload, opts) } @@ -208,10 +209,10 @@ func ProposeUpgradeContract(rp *rocketpool.RocketPool, message, upgradeType, con } // Estimate the gas of a proposal submission -func EstimateProposalGas(rp *rocketpool.RocketPool, message string, payload []byte, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposalGas(rp *rocketpool.RocketPool, message string, payload []byte, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAONodeTrustedProposals, err := getRocketDAONodeTrustedProposals(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketDAONodeTrustedProposals.GetTransactionGasInfo(opts, "propose", message, payload) } @@ -235,10 +236,10 @@ func SubmitProposal(rp *rocketpool.RocketPool, message string, payload []byte, o } // Estimate the gas of CancelProposal -func EstimateCancelProposalGas(rp *rocketpool.RocketPool, proposalId uint64, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateCancelProposalGas(rp *rocketpool.RocketPool, proposalId uint64, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAONodeTrustedProposals, err := getRocketDAONodeTrustedProposals(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketDAONodeTrustedProposals.GetTransactionGasInfo(opts, "cancel", big.NewInt(int64(proposalId))) } @@ -257,10 +258,10 @@ func CancelProposal(rp *rocketpool.RocketPool, proposalId uint64, opts *bind.Tra } // Estimate the gas of VoteOnProposal -func EstimateVoteOnProposalGas(rp *rocketpool.RocketPool, proposalId uint64, support bool, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateVoteOnProposalGas(rp *rocketpool.RocketPool, proposalId uint64, support bool, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAONodeTrustedProposals, err := getRocketDAONodeTrustedProposals(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketDAONodeTrustedProposals.GetTransactionGasInfo(opts, "vote", big.NewInt(int64(proposalId)), support) } @@ -279,10 +280,10 @@ func VoteOnProposal(rp *rocketpool.RocketPool, proposalId uint64, support bool, } // Estimate the gas of ExecuteProposal -func EstimateExecuteProposalGas(rp *rocketpool.RocketPool, proposalId uint64, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateExecuteProposalGas(rp *rocketpool.RocketPool, proposalId uint64, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAONodeTrustedProposals, err := getRocketDAONodeTrustedProposals(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketDAONodeTrustedProposals.GetTransactionGasInfo(opts, "execute", big.NewInt(int64(proposalId))) } diff --git a/bindings/dao/upgrades/upgrades.go b/bindings/dao/upgrades/upgrades.go index 8251e0bd0..b0013bf38 100644 --- a/bindings/dao/upgrades/upgrades.go +++ b/bindings/dao/upgrades/upgrades.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" rptypes "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/strings" ) @@ -89,10 +90,10 @@ func GetUpgradeProposalName(rp *rocketpool.RocketPool, upgradeProposalId uint64, } // Estimate the gas of ExecuteUpgrade -func EstimateExecuteUpgradeGas(rp *rocketpool.RocketPool, upgradeProposalId uint64, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateExecuteUpgradeGas(rp *rocketpool.RocketPool, upgradeProposalId uint64, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDAONodeTrustedUpgrade, err := getRocketDAONodeTrustedUpgrade(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketDAONodeTrustedUpgrade.GetTransactionGasInfo(opts, "execute", big.NewInt(int64(upgradeProposalId))) } diff --git a/bindings/deposit/deposit-pool.go b/bindings/deposit/deposit-pool.go index 41f65bd82..b5a78ba89 100644 --- a/bindings/deposit/deposit-pool.go +++ b/bindings/deposit/deposit-pool.go @@ -8,13 +8,14 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" ) // Estimate the gas required to exit the validator queue -func EstimateExitQueueGas(rp *rocketpool.RocketPool, validatorIndex uint64, expressQueue bool, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateExitQueueGas(rp *rocketpool.RocketPool, validatorIndex uint64, expressQueue bool, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDepositPool, err := getRocketDepositPool(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } validatorIndexBig := big.NewInt(int64(validatorIndex)) return rocketDepositPool.GetTransactionGasInfo(opts, "exitQueue", validatorIndexBig, expressQueue) diff --git a/bindings/deposit/deposit.go b/bindings/deposit/deposit.go index ffcd880b7..781445e7f 100644 --- a/bindings/deposit/deposit.go +++ b/bindings/deposit/deposit.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" ) // Get the deposit pool balance @@ -51,10 +52,10 @@ func GetExcessBalance(rp *rocketpool.RocketPool, opts *bind.CallOpts) (*big.Int, } // Estimate the gas of Deposit -func EstimateDepositGas(rp *rocketpool.RocketPool, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateDepositGas(rp *rocketpool.RocketPool, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDepositPool, err := getRocketDepositPool(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketDepositPool.GetTransactionGasInfo(opts, "deposit") } @@ -73,10 +74,10 @@ func Deposit(rp *rocketpool.RocketPool, opts *bind.TransactOpts) (common.Hash, e } // Estimate the gas of AssignDeposits -func EstimateAssignDepositsGas(rp *rocketpool.RocketPool, m *big.Int, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateAssignDepositsGas(rp *rocketpool.RocketPool, m *big.Int, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDepositPool, err := getRocketDepositPool(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketDepositPool.GetTransactionGasInfo(opts, "assignDeposits", m) } diff --git a/bindings/utils/eth/erc20.go b/bindings/erc20/erc20.go similarity index 96% rename from bindings/utils/eth/erc20.go rename to bindings/erc20/erc20.go index 21d7d8ece..7606d905d 100644 --- a/bindings/utils/eth/erc20.go +++ b/bindings/erc20/erc20.go @@ -1,4 +1,4 @@ -package eth +package erc20 import ( "fmt" @@ -11,6 +11,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" ) const ( @@ -192,7 +193,7 @@ func (c *Erc20Contract) BalanceOf(address common.Address, opts *bind.CallOpts) ( } // Estimate the gas for transferring an ERC20 to another address -func (c *Erc20Contract) EstimateTransferGas(to common.Address, amount *big.Int, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func (c *Erc20Contract) EstimateTransferGas(to common.Address, amount *big.Int, opts *bind.TransactOpts) (gaslimit.Limits, error) { return c.contract.GetTransactionGasInfo(opts, "transfer", to, amount) } diff --git a/bindings/legacy/v1.0.0/rewards/node.go b/bindings/legacy/v1.0.0/rewards/node.go index 38a4d7334..501781d89 100644 --- a/bindings/legacy/v1.0.0/rewards/node.go +++ b/bindings/legacy/v1.0.0/rewards/node.go @@ -8,8 +8,9 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" + "github.com/rocket-pool/smartnode/bindings/logs" "github.com/rocket-pool/smartnode/bindings/rocketpool" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" ) // Get whether node reward claims are enabled @@ -49,10 +50,10 @@ func GetNodeClaimRewardsAmount(rp *rocketpool.RocketPool, claimerAddress common. } // Estimate the gas of ClaimNodeRewards -func EstimateClaimNodeRewardsGas(rp *rocketpool.RocketPool, opts *bind.TransactOpts, legacyRocketClaimNodeAddress *common.Address) (rocketpool.GasInfo, error) { +func EstimateClaimNodeRewardsGas(rp *rocketpool.RocketPool, opts *bind.TransactOpts, legacyRocketClaimNodeAddress *common.Address) (gaslimit.Limits, error) { rocketClaimNode, err := getRocketClaimNode(rp, legacyRocketClaimNodeAddress, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return estimateClaimGas(rocketClaimNode, opts) } @@ -87,7 +88,7 @@ func CalculateLifetimeNodeRewards(rp *rocketpool.RocketPool, claimerAddress comm } // Get the event logs - logs, err := eth.GetLogs(rp, addressFilter, topicFilter, intervalSize, startBlock, nil, nil) + logs, err := logs.GetLogs(rp, addressFilter, topicFilter, intervalSize, startBlock, nil, nil) if err != nil { return nil, err } diff --git a/bindings/legacy/v1.0.0/rewards/rewards.go b/bindings/legacy/v1.0.0/rewards/rewards.go index f8286ed00..c5ed27749 100644 --- a/bindings/legacy/v1.0.0/rewards/rewards.go +++ b/bindings/legacy/v1.0.0/rewards/rewards.go @@ -10,6 +10,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/utils/eth" ) @@ -78,7 +79,7 @@ func getClaimingContractTotalClaimed(rp *rocketpool.RocketPool, claimsContract s } // Estimate the gas of claim -func estimateClaimGas(claimsContract *rocketpool.Contract, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func estimateClaimGas(claimsContract *rocketpool.Contract, opts *bind.TransactOpts) (gaslimit.Limits, error) { return claimsContract.GetTransactionGasInfo(opts, "claim") } diff --git a/bindings/legacy/v1.0.0/rewards/trusted-node.go b/bindings/legacy/v1.0.0/rewards/trusted-node.go index c1adfd0d4..b3dff5ddb 100644 --- a/bindings/legacy/v1.0.0/rewards/trusted-node.go +++ b/bindings/legacy/v1.0.0/rewards/trusted-node.go @@ -8,8 +8,9 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" + "github.com/rocket-pool/smartnode/bindings/logs" "github.com/rocket-pool/smartnode/bindings/rocketpool" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" ) // Get whether trusted node reward claims are enabled @@ -49,10 +50,10 @@ func GetTrustedNodeClaimRewardsAmount(rp *rocketpool.RocketPool, claimerAddress } // Estimate the gas of ClaimTrustedNodeRewards -func EstimateClaimTrustedNodeRewardsGas(rp *rocketpool.RocketPool, opts *bind.TransactOpts, legacyRocketClaimTrustedNodeAddress *common.Address) (rocketpool.GasInfo, error) { +func EstimateClaimTrustedNodeRewardsGas(rp *rocketpool.RocketPool, opts *bind.TransactOpts, legacyRocketClaimTrustedNodeAddress *common.Address) (gaslimit.Limits, error) { rocketClaimTrustedNode, err := getRocketClaimTrustedNode(rp, legacyRocketClaimTrustedNodeAddress, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return estimateClaimGas(rocketClaimTrustedNode, opts) } @@ -87,7 +88,7 @@ func CalculateLifetimeTrustedNodeRewards(rp *rocketpool.RocketPool, claimerAddre } // Get the event logs - logs, err := eth.GetLogs(rp, addressFilter, topicFilter, intervalSize, startBlock, nil, nil) + logs, err := logs.GetLogs(rp, addressFilter, topicFilter, intervalSize, startBlock, nil, nil) if err != nil { return nil, err } diff --git a/bindings/legacy/v1.1.0-rc1/rewards/rewards.go b/bindings/legacy/v1.1.0-rc1/rewards/rewards.go index 060a82b6c..24e80f98f 100644 --- a/bindings/legacy/v1.1.0-rc1/rewards/rewards.go +++ b/bindings/legacy/v1.1.0-rc1/rewards/rewards.go @@ -10,8 +10,9 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" + "github.com/rocket-pool/smartnode/bindings/logs" "github.com/rocket-pool/smartnode/bindings/rocketpool" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" ) // Info for a rewards snapshot event @@ -150,10 +151,10 @@ func GetPendingETHRewards(rp *rocketpool.RocketPool, opts *bind.CallOpts, legacy } // Estimate the gas for submitting a Merkle Tree-based snapshot for a rewards interval -func EstimateSubmitRewardSnapshotGas(rp *rocketpool.RocketPool, submission RewardSubmission, opts *bind.TransactOpts, legacyRocketRewardsPoolAddress *common.Address) (rocketpool.GasInfo, error) { +func EstimateSubmitRewardSnapshotGas(rp *rocketpool.RocketPool, submission RewardSubmission, opts *bind.TransactOpts, legacyRocketRewardsPoolAddress *common.Address) (gaslimit.Limits, error) { rocketRewardsPool, err := getRocketRewardsPool(rp, legacyRocketRewardsPoolAddress, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketRewardsPool.GetTransactionGasInfo(opts, "submitRewardSnapshot", submission) } @@ -187,7 +188,7 @@ func GetRewardSnapshotEvent(rp *rocketpool.RocketPool, index uint64, intervalSiz topicFilter := [][]common.Hash{{rocketRewardsPool.ABI.Events["RewardSnapshot"].ID}, {indexBytes}} // Get the event logs - logs, err := eth.GetLogs(rp, addressFilter, topicFilter, intervalSize, startBlock, endBlock, nil) + logs, err := logs.GetLogs(rp, addressFilter, topicFilter, intervalSize, startBlock, endBlock, nil) if err != nil { return RewardsEvent{}, err } @@ -249,7 +250,7 @@ func GetRewardSnapshotEventWithUpgrades(rp *rocketpool.RocketPool, index uint64, topicFilter := [][]common.Hash{{rocketRewardsPool.ABI.Events["RewardSnapshot"].ID}, {indexBytes}} // Get the event logs - logs, err := eth.GetLogs(rp, addressFilter, topicFilter, intervalSize, startBlock, endBlock, nil) + logs, err := logs.GetLogs(rp, addressFilter, topicFilter, intervalSize, startBlock, endBlock, nil) if err != nil { return false, RewardsEvent{}, err } diff --git a/bindings/legacy/v1.1.0/network/prices.go b/bindings/legacy/v1.1.0/network/prices.go index de18d7027..005c998d2 100644 --- a/bindings/legacy/v1.1.0/network/prices.go +++ b/bindings/legacy/v1.1.0/network/prices.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" ) // Get the block number which network prices are current for @@ -38,10 +39,10 @@ func GetRPLPrice(rp *rocketpool.RocketPool, opts *bind.CallOpts, legacyRocketNet } // Estimate the gas of SubmitPrices -func EstimateSubmitPricesGas(rp *rocketpool.RocketPool, block uint64, rplPrice *big.Int, effectiveRplStake *big.Int, opts *bind.TransactOpts, legacyRocketNetworkPricesAddress *common.Address) (rocketpool.GasInfo, error) { +func EstimateSubmitPricesGas(rp *rocketpool.RocketPool, block uint64, rplPrice *big.Int, effectiveRplStake *big.Int, opts *bind.TransactOpts, legacyRocketNetworkPricesAddress *common.Address) (gaslimit.Limits, error) { rocketNetworkPrices, err := getRocketNetworkPrices(rp, legacyRocketNetworkPricesAddress, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketNetworkPrices.GetTransactionGasInfo(opts, "submitPrices", big.NewInt(int64(block)), rplPrice, effectiveRplStake) } diff --git a/bindings/legacy/v1.1.0/node/deposit.go b/bindings/legacy/v1.1.0/node/deposit.go index 557b1e561..5c3fdd389 100644 --- a/bindings/legacy/v1.1.0/node/deposit.go +++ b/bindings/legacy/v1.1.0/node/deposit.go @@ -10,15 +10,16 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" rptypes "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" ) // Estimate the gas of Deposit -func EstimateDepositGas(rp *rocketpool.RocketPool, minimumNodeFee float64, validatorPubkey rptypes.ValidatorPubkey, validatorSignature rptypes.ValidatorSignature, depositDataRoot common.Hash, salt *big.Int, expectedMinipoolAddress common.Address, opts *bind.TransactOpts, legacyRocketNodeDepositAddress *common.Address) (rocketpool.GasInfo, error) { +func EstimateDepositGas(rp *rocketpool.RocketPool, minimumNodeFee float64, validatorPubkey rptypes.ValidatorPubkey, validatorSignature rptypes.ValidatorSignature, depositDataRoot common.Hash, salt *big.Int, expectedMinipoolAddress common.Address, opts *bind.TransactOpts, legacyRocketNodeDepositAddress *common.Address) (gaslimit.Limits, error) { rocketNodeDeposit, err := getRocketNodeDeposit(rp, legacyRocketNodeDepositAddress, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketNodeDeposit.GetTransactionGasInfo(opts, "deposit", eth.EthToWei(minimumNodeFee), validatorPubkey[:], validatorSignature[:], depositDataRoot, salt, expectedMinipoolAddress) } diff --git a/bindings/legacy/v1.1.0/node/staking.go b/bindings/legacy/v1.1.0/node/staking.go index a855c9a43..cb05e3adf 100644 --- a/bindings/legacy/v1.1.0/node/staking.go +++ b/bindings/legacy/v1.1.0/node/staking.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" ) // Get the version of the Node Staking contract @@ -141,10 +142,10 @@ func GetNodeMinipoolLimit(rp *rocketpool.RocketPool, nodeAddress common.Address, } // Estimate the gas of Stake -func EstimateStakeGas(rp *rocketpool.RocketPool, rplAmount *big.Int, opts *bind.TransactOpts, legacyRocketNodeStakingAddress *common.Address) (rocketpool.GasInfo, error) { +func EstimateStakeGas(rp *rocketpool.RocketPool, rplAmount *big.Int, opts *bind.TransactOpts, legacyRocketNodeStakingAddress *common.Address) (gaslimit.Limits, error) { rocketNodeStaking, err := getRocketNodeStaking(rp, legacyRocketNodeStakingAddress, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketNodeStaking.GetTransactionGasInfo(opts, "stakeRPL", rplAmount) } @@ -163,10 +164,10 @@ func StakeRPL(rp *rocketpool.RocketPool, rplAmount *big.Int, opts *bind.Transact } // Estimate the gas of WithdrawRPL -func EstimateWithdrawRPLGas(rp *rocketpool.RocketPool, rplAmount *big.Int, opts *bind.TransactOpts, legacyRocketNodeStakingAddress *common.Address) (rocketpool.GasInfo, error) { +func EstimateWithdrawRPLGas(rp *rocketpool.RocketPool, rplAmount *big.Int, opts *bind.TransactOpts, legacyRocketNodeStakingAddress *common.Address) (gaslimit.Limits, error) { rocketNodeStaking, err := getRocketNodeStaking(rp, legacyRocketNodeStakingAddress, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketNodeStaking.GetTransactionGasInfo(opts, "withdrawRPL", rplAmount) } diff --git a/bindings/legacy/v1.2.0/network/balances.go b/bindings/legacy/v1.2.0/network/balances.go index 717a514a2..9752cea82 100644 --- a/bindings/legacy/v1.2.0/network/balances.go +++ b/bindings/legacy/v1.2.0/network/balances.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/utils/eth" ) @@ -91,10 +92,10 @@ func GetETHUtilizationRate(rp *rocketpool.RocketPool, opts *bind.CallOpts, legac } // Estimate the gas of SubmitBalances -func EstimateSubmitBalancesGas(rp *rocketpool.RocketPool, block uint64, totalEth, stakingEth, rethSupply *big.Int, opts *bind.TransactOpts, legacyRocketNetworkBalancesAddress *common.Address) (rocketpool.GasInfo, error) { +func EstimateSubmitBalancesGas(rp *rocketpool.RocketPool, block uint64, totalEth, stakingEth, rethSupply *big.Int, opts *bind.TransactOpts, legacyRocketNetworkBalancesAddress *common.Address) (gaslimit.Limits, error) { rocketNetworkBalances, err := getRocketNetworkBalances(rp, legacyRocketNetworkBalancesAddress, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketNetworkBalances.GetTransactionGasInfo(opts, "submitBalances", big.NewInt(int64(block)), totalEth, stakingEth, rethSupply) } diff --git a/bindings/legacy/v1.2.0/network/prices.go b/bindings/legacy/v1.2.0/network/prices.go index 11856b966..c35017a87 100644 --- a/bindings/legacy/v1.2.0/network/prices.go +++ b/bindings/legacy/v1.2.0/network/prices.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" ) // Get the block number which network prices are current for @@ -38,10 +39,10 @@ func GetRPLPrice(rp *rocketpool.RocketPool, opts *bind.CallOpts, legacyRocketNet } // Estimate the gas of SubmitPrices -func EstimateSubmitPricesGas(rp *rocketpool.RocketPool, block uint64, rplPrice *big.Int, opts *bind.TransactOpts, legacyRocketNetworkPricesAddress *common.Address) (rocketpool.GasInfo, error) { +func EstimateSubmitPricesGas(rp *rocketpool.RocketPool, block uint64, rplPrice *big.Int, opts *bind.TransactOpts, legacyRocketNetworkPricesAddress *common.Address) (gaslimit.Limits, error) { rocketNetworkPrices, err := getRocketNetworkPrices(rp, legacyRocketNetworkPricesAddress, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketNetworkPrices.GetTransactionGasInfo(opts, "submitPrices", big.NewInt(int64(block)), rplPrice) } diff --git a/bindings/legacy/v1.3.1/node/deposit.go b/bindings/legacy/v1.3.1/node/deposit.go index 94465af64..ce8f8fd25 100644 --- a/bindings/legacy/v1.3.1/node/deposit.go +++ b/bindings/legacy/v1.3.1/node/deposit.go @@ -10,15 +10,16 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" rptypes "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" ) // Estimate the gas of Deposit -func EstimateDepositGas(rp *rocketpool.RocketPool, bondAmount *big.Int, minimumNodeFee float64, validatorPubkey rptypes.ValidatorPubkey, validatorSignature rptypes.ValidatorSignature, depositDataRoot common.Hash, salt *big.Int, expectedMinipoolAddress common.Address, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateDepositGas(rp *rocketpool.RocketPool, bondAmount *big.Int, minimumNodeFee float64, validatorPubkey rptypes.ValidatorPubkey, validatorSignature rptypes.ValidatorSignature, depositDataRoot common.Hash, salt *big.Int, expectedMinipoolAddress common.Address, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketNodeDeposit, err := getRocketNodeDeposit(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketNodeDeposit.GetTransactionGasInfo(opts, "deposit", bondAmount, eth.EthToWei(minimumNodeFee), validatorPubkey[:], validatorSignature[:], depositDataRoot, salt, expectedMinipoolAddress) } @@ -37,10 +38,10 @@ func Deposit(rp *rocketpool.RocketPool, bondAmount *big.Int, minimumNodeFee floa } // Estimate the gas of DepositWithCredit -func EstimateDepositWithCreditGas(rp *rocketpool.RocketPool, bondAmount *big.Int, minimumNodeFee float64, validatorPubkey rptypes.ValidatorPubkey, validatorSignature rptypes.ValidatorSignature, depositDataRoot common.Hash, salt *big.Int, expectedMinipoolAddress common.Address, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateDepositWithCreditGas(rp *rocketpool.RocketPool, bondAmount *big.Int, minimumNodeFee float64, validatorPubkey rptypes.ValidatorPubkey, validatorSignature rptypes.ValidatorSignature, depositDataRoot common.Hash, salt *big.Int, expectedMinipoolAddress common.Address, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketNodeDeposit, err := getRocketNodeDeposit(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketNodeDeposit.GetTransactionGasInfo(opts, "depositWithCredit", bondAmount, eth.EthToWei(minimumNodeFee), validatorPubkey[:], validatorSignature[:], depositDataRoot, salt, expectedMinipoolAddress) } @@ -68,10 +69,10 @@ func getRocketNodeDeposit(rp *rocketpool.RocketPool, opts *bind.CallOpts) (*rock } // Estimate the gas of AssignDeposits -func EstimateAssignDepositsGas(rp *rocketpool.RocketPool, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateAssignDepositsGas(rp *rocketpool.RocketPool, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDepositPool, err := getRocketDepositPool(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketDepositPool.GetTransactionGasInfo(opts, "assignDeposits") } diff --git a/bindings/legacy/v1.3.1/node/staking.go b/bindings/legacy/v1.3.1/node/staking.go index 4c0f21f21..80ee0b3ca 100644 --- a/bindings/legacy/v1.3.1/node/staking.go +++ b/bindings/legacy/v1.3.1/node/staking.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" ) // Get the version of the Node Staking contract @@ -137,10 +138,10 @@ func GetNodeEthMatchedLimit(rp *rocketpool.RocketPool, nodeAddress common.Addres } // Estimate the gas of Stake -func EstimateStakeGas(rp *rocketpool.RocketPool, rplAmount *big.Int, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateStakeGas(rp *rocketpool.RocketPool, rplAmount *big.Int, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketNodeStaking, err := getRocketNodeStaking(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketNodeStaking.GetTransactionGasInfo(opts, "stakeRPL", rplAmount) } @@ -159,10 +160,10 @@ func StakeRPL(rp *rocketpool.RocketPool, rplAmount *big.Int, opts *bind.Transact } // Estimate the gas of Burn RPL -func EstimateBurnRpl(rp *rocketpool.RocketPool, from common.Address, rplAmount *big.Int, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateBurnRpl(rp *rocketpool.RocketPool, from common.Address, rplAmount *big.Int, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketNodeStaking, err := getRocketNodeStaking(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketNodeStaking.GetTransactionGasInfo(opts, "burnRPL", from, rplAmount) } @@ -182,10 +183,10 @@ func BurnRPL(rp *rocketpool.RocketPool, from common.Address, rplAmount *big.Int, } // Estimate the gas of set RPL locking allowed -func EstimateSetRPLLockingAllowedGas(rp *rocketpool.RocketPool, caller common.Address, allowed bool, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateSetRPLLockingAllowedGas(rp *rocketpool.RocketPool, caller common.Address, allowed bool, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketNodeStaking, err := getRocketNodeStaking(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketNodeStaking.GetTransactionGasInfo(opts, "setRPLLockingAllowed", caller, allowed) } @@ -217,10 +218,10 @@ func GetRPLLockedAllowed(rp *rocketpool.RocketPool, nodeAddress common.Address, } // Estimate the gas of set stake RPL for allowed -func EstimateSetStakeRPLForAllowedGas(rp *rocketpool.RocketPool, caller common.Address, allowed bool, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateSetStakeRPLForAllowedGas(rp *rocketpool.RocketPool, caller common.Address, allowed bool, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketNodeStaking, err := getRocketNodeStaking(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketNodeStaking.GetTransactionGasInfo(opts, "setStakeRPLForAllowed", caller, allowed) } @@ -239,10 +240,10 @@ func SetStakeRPLForAllowed(rp *rocketpool.RocketPool, caller common.Address, all } // Estimate the gas of WithdrawRPL -func EstimateWithdrawRPLGas(rp *rocketpool.RocketPool, nodeAddress common.Address, rplAmount *big.Int, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateWithdrawRPLGas(rp *rocketpool.RocketPool, nodeAddress common.Address, rplAmount *big.Int, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketNodeStaking, err := getRocketNodeStaking(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketNodeStaking.GetTransactionGasInfo(opts, "withdrawRPL", nodeAddress, rplAmount) } diff --git a/bindings/legacy/v1.3.1/protocol/node.go b/bindings/legacy/v1.3.1/protocol/node.go index f18fb01c7..27845e26c 100644 --- a/bindings/legacy/v1.3.1/protocol/node.go +++ b/bindings/legacy/v1.3.1/protocol/node.go @@ -10,6 +10,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/dao/protocol" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" ) @@ -36,7 +37,7 @@ func GetMinimumPerMinipoolStake(rp *rocketpool.RocketPool, opts *bind.CallOpts) func ProposeMinimumPerMinipoolStake(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", MinimumPerMinipoolStakeSettingPath), NodeSettingsContractName, MinimumPerMinipoolStakeSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeMinimumPerMinipoolStakeGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeMinimumPerMinipoolStakeGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", MinimumPerMinipoolStakeSettingPath), NodeSettingsContractName, MinimumPerMinipoolStakeSettingPath, value, blockNumber, treeNodes, opts) } @@ -68,7 +69,7 @@ func GetMaximumPerMinipoolStake(rp *rocketpool.RocketPool, opts *bind.CallOpts) func ProposeMaximumPerMinipoolStake(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", MaximumPerMinipoolStakeSettingPath), NodeSettingsContractName, MaximumPerMinipoolStakeSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeMaximumPerMinipoolStakeGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeMaximumPerMinipoolStakeGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", MaximumPerMinipoolStakeSettingPath), NodeSettingsContractName, MaximumPerMinipoolStakeSettingPath, value, blockNumber, treeNodes, opts) } diff --git a/bindings/legacy/v1.3.1/rewards/distributor-mainnet.go b/bindings/legacy/v1.3.1/rewards/distributor-mainnet.go index 71e3644a2..f39d29a60 100644 --- a/bindings/legacy/v1.3.1/rewards/distributor-mainnet.go +++ b/bindings/legacy/v1.3.1/rewards/distributor-mainnet.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" ) // Check if the given node has already claimed rewards for the given interval @@ -38,10 +39,10 @@ func MerkleRoots(rp *rocketpool.RocketPool, interval *big.Int, opts *bind.CallOp } // Estimate claim rewards gas -func EstimateClaimGas(rp *rocketpool.RocketPool, address common.Address, indices []*big.Int, amountRPL []*big.Int, amountETH []*big.Int, merkleProofs [][]common.Hash, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateClaimGas(rp *rocketpool.RocketPool, address common.Address, indices []*big.Int, amountRPL []*big.Int, amountETH []*big.Int, merkleProofs [][]common.Hash, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDistributorMainnet, err := getRocketDistributorMainnet(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketDistributorMainnet.GetTransactionGasInfo(opts, "claim", address, indices, amountRPL, amountETH, merkleProofs) } @@ -60,10 +61,10 @@ func Claim(rp *rocketpool.RocketPool, address common.Address, indices []*big.Int } // Estimate claim and restake rewards gas -func EstimateClaimAndStakeGas(rp *rocketpool.RocketPool, address common.Address, indices []*big.Int, amountRPL []*big.Int, amountETH []*big.Int, merkleProofs [][]common.Hash, stakeAmount *big.Int, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateClaimAndStakeGas(rp *rocketpool.RocketPool, address common.Address, indices []*big.Int, amountRPL []*big.Int, amountETH []*big.Int, merkleProofs [][]common.Hash, stakeAmount *big.Int, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDistributorMainnet, err := getRocketDistributorMainnet(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketDistributorMainnet.GetTransactionGasInfo(opts, "claimAndStake", address, indices, amountRPL, amountETH, merkleProofs, stakeAmount) } diff --git a/bindings/legacy/v1.3.1/rewards/rewards.go b/bindings/legacy/v1.3.1/rewards/rewards.go index 566f0c6d0..5542a46e1 100644 --- a/bindings/legacy/v1.3.1/rewards/rewards.go +++ b/bindings/legacy/v1.3.1/rewards/rewards.go @@ -12,8 +12,9 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" + "github.com/rocket-pool/smartnode/bindings/logs" "github.com/rocket-pool/smartnode/bindings/rocketpool" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" ) const ( @@ -208,10 +209,10 @@ func GetTrustedNodeSubmittedSpecificRewards(rp *rocketpool.RocketPool, nodeAddre } // Estimate the gas for submitting a Merkle Tree-based snapshot for a rewards interval -func EstimateSubmitRewardSnapshotGas(rp *rocketpool.RocketPool, submission RewardSubmission, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateSubmitRewardSnapshotGas(rp *rocketpool.RocketPool, submission RewardSubmission, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketRewardsPool, err := getRocketRewardsPool(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketRewardsPool.GetTransactionGasInfo(opts, "submitRewardSnapshot", submission) } @@ -280,7 +281,7 @@ func GetRewardsEvent(rp *rocketpool.RocketPool, index uint64, rocketRewardsPoolA topicFilter := [][]common.Hash{{houstonRewardSnapshotTopicHash}, {indexBytes}} // Get the event logs - logs, err := eth.GetLogs(rp, addressFilter, topicFilter, big.NewInt(1), block, block, nil) + logs, err := logs.GetLogs(rp, addressFilter, topicFilter, big.NewInt(1), block, block, nil) if err != nil { return false, RewardsEvent{}, err } diff --git a/bindings/utils/eth/logs.go b/bindings/logs/logs.go similarity index 99% rename from bindings/utils/eth/logs.go rename to bindings/logs/logs.go index 28c4297f9..aec848a6a 100644 --- a/bindings/utils/eth/logs.go +++ b/bindings/logs/logs.go @@ -1,4 +1,4 @@ -package eth +package logs import ( "context" diff --git a/bindings/megapool/megapool-contract.go b/bindings/megapool/megapool-contract.go index e8e91f0aa..add563694 100644 --- a/bindings/megapool/megapool-contract.go +++ b/bindings/megapool/megapool-contract.go @@ -13,6 +13,7 @@ import ( "golang.org/x/sync/errgroup" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" rptypes "github.com/rocket-pool/smartnode/bindings/types" ) @@ -392,7 +393,7 @@ func (mp *megapoolV1) GetNodeAddress(opts *bind.CallOpts) (common.Address, error } // Estimate the gas required to create a new validator as part of a megapool -func (mp *megapoolV1) EstimateNewValidatorGas(validatorId uint32, validatorSignature rptypes.ValidatorSignature, depositDataRoot common.Hash, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func (mp *megapoolV1) EstimateNewValidatorGas(validatorId uint32, validatorSignature rptypes.ValidatorSignature, depositDataRoot common.Hash, opts *bind.TransactOpts) (gaslimit.Limits, error) { return mp.Contract.GetTransactionGasInfo(opts, "newValidator", validatorId, validatorSignature[:], depositDataRoot) } @@ -406,7 +407,7 @@ func (mp *megapoolV1) NewValidator(bondAmount *big.Int, useExpressTicket bool, v } // Estimate the gas required to remove a validator from the deposit queue -func (mp *megapoolV1) EstimateDequeueGas(validatorId uint32, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func (mp *megapoolV1) EstimateDequeueGas(validatorId uint32, opts *bind.TransactOpts) (gaslimit.Limits, error) { return mp.Contract.GetTransactionGasInfo(opts, "dequeue", validatorId) } @@ -420,7 +421,7 @@ func (mp *megapoolV1) Dequeue(validatorId uint32, opts *bind.TransactOpts) (comm } // Estimate the gas required to accept requested funds from the deposit pool -func (mp *megapoolV1) EstimateAssignFundsGas(validatorId uint32, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func (mp *megapoolV1) EstimateAssignFundsGas(validatorId uint32, opts *bind.TransactOpts) (gaslimit.Limits, error) { return mp.Contract.GetTransactionGasInfo(opts, "assignFunds", validatorId) } @@ -434,7 +435,7 @@ func (mp *megapoolV1) AssignFunds(validatorId uint32, opts *bind.TransactOpts) ( } // Estimate the gas required to dissolve a validator that has not staked within the required period -func (mp *megapoolV1) EstimateDissolveValidatorGas(validatorId uint32, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func (mp *megapoolV1) EstimateDissolveValidatorGas(validatorId uint32, opts *bind.TransactOpts) (gaslimit.Limits, error) { return mp.Contract.GetTransactionGasInfo(opts, "dissolveValidator", validatorId) } @@ -448,7 +449,7 @@ func (mp *megapoolV1) DissolveValidator(validatorId uint32, opts *bind.TransactO } // Estimate the gas required to repay megapool debt -func (mp *megapoolV1) EstimateRepayDebtGas(opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func (mp *megapoolV1) EstimateRepayDebtGas(opts *bind.TransactOpts) (gaslimit.Limits, error) { return mp.Contract.GetTransactionGasInfo(opts, "repayDebt") } @@ -462,7 +463,7 @@ func (mp *megapoolV1) RepayDebt(opts *bind.TransactOpts) (common.Hash, error) { } // Estimate the gas required to reduce a megapool bond -func (mp *megapoolV1) EstimateReduceBondGas(amount *big.Int, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func (mp *megapoolV1) EstimateReduceBondGas(amount *big.Int, opts *bind.TransactOpts) (gaslimit.Limits, error) { return mp.Contract.GetTransactionGasInfo(opts, "reduceBond", amount) } @@ -476,7 +477,7 @@ func (mp *megapoolV1) ReduceBond(amount *big.Int, opts *bind.TransactOpts) (comm } // Estimate the gas required to claim a megapool refund -func (mp *megapoolV1) EstimateClaimRefundGas(opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func (mp *megapoolV1) EstimateClaimRefundGas(opts *bind.TransactOpts) (gaslimit.Limits, error) { return mp.Contract.GetTransactionGasInfo(opts, "claim") } @@ -508,7 +509,7 @@ func (mp *megapoolV1) GetNewValidatorBondRequirement(opts *bind.CallOpts) (*big. } // Estimate the gas required to Request RPL previously staked on this megapool to be unstaked -func (mp *megapoolV1) EstimateRequestUnstakeRPL(opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func (mp *megapoolV1) EstimateRequestUnstakeRPL(opts *bind.TransactOpts) (gaslimit.Limits, error) { return mp.Contract.GetTransactionGasInfo(opts, "requestUnstakeRPL") } @@ -523,7 +524,7 @@ func (mp *megapoolV1) RequestUnstakeRPL(opts *bind.TransactOpts) (common.Hash, e } // Estimate the gas required to distribute megapool rewards -func (mp *megapoolV1) EstimateDistributeGas(opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func (mp *megapoolV1) EstimateDistributeGas(opts *bind.TransactOpts) (gaslimit.Limits, error) { return mp.Contract.GetTransactionGasInfo(opts, "distribute") } @@ -537,7 +538,7 @@ func (mp *megapoolV1) Distribute(opts *bind.TransactOpts) (common.Hash, error) { } // Estimate the gas of SetUseLatestDelegate -func (mp *megapoolV1) EstimateSetUseLatestDelegateGas(setting bool, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func (mp *megapoolV1) EstimateSetUseLatestDelegateGas(setting bool, opts *bind.TransactOpts) (gaslimit.Limits, error) { return mp.Contract.GetTransactionGasInfo(opts, "setUseLatestDelegate", setting) } @@ -587,7 +588,7 @@ func (mp *megapoolV1) GetDelegateExpired(rp *rocketpool.RocketPool, opts *bind.C } // Estimate the gas of DelegateUpgrade -func (mp *megapoolV1) EstimateDelegateUpgradeGas(opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func (mp *megapoolV1) EstimateDelegateUpgradeGas(opts *bind.TransactOpts) (gaslimit.Limits, error) { return mp.Contract.GetTransactionGasInfo(opts, "delegateUpgrade") } diff --git a/bindings/megapool/megapool-interface.go b/bindings/megapool/megapool-interface.go index 20bca5746..045ed0ba5 100644 --- a/bindings/megapool/megapool-interface.go +++ b/bindings/megapool/megapool-interface.go @@ -7,6 +7,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" rptypes "github.com/rocket-pool/smartnode/bindings/types" ) @@ -33,33 +34,33 @@ type Megapool interface { CalculateRewards(amount *big.Int, opts *bind.CallOpts) (RewardSplit, error) GetPendingRewards(opts *bind.CallOpts) (*big.Int, error) GetNodeAddress(opts *bind.CallOpts) (common.Address, error) - EstimateNewValidatorGas(validatorId uint32, validatorSignature rptypes.ValidatorSignature, depositDataRoot common.Hash, opts *bind.TransactOpts) (rocketpool.GasInfo, error) + EstimateNewValidatorGas(validatorId uint32, validatorSignature rptypes.ValidatorSignature, depositDataRoot common.Hash, opts *bind.TransactOpts) (gaslimit.Limits, error) NewValidator(bondAmount *big.Int, useExpressTicket bool, validatorPubkey rptypes.ValidatorPubkey, validatorSignature rptypes.ValidatorSignature, opts *bind.TransactOpts) (common.Hash, error) - EstimateDequeueGas(validatorId uint32, opts *bind.TransactOpts) (rocketpool.GasInfo, error) + EstimateDequeueGas(validatorId uint32, opts *bind.TransactOpts) (gaslimit.Limits, error) Dequeue(validatorId uint32, opts *bind.TransactOpts) (common.Hash, error) - EstimateDistributeGas(opts *bind.TransactOpts) (rocketpool.GasInfo, error) + EstimateDistributeGas(opts *bind.TransactOpts) (gaslimit.Limits, error) Distribute(opts *bind.TransactOpts) (common.Hash, error) - EstimateAssignFundsGas(validatorId uint32, opts *bind.TransactOpts) (rocketpool.GasInfo, error) + EstimateAssignFundsGas(validatorId uint32, opts *bind.TransactOpts) (gaslimit.Limits, error) AssignFunds(validatorId uint32, opts *bind.TransactOpts) (common.Hash, error) - EstimateDissolveValidatorGas(validatorId uint32, opts *bind.TransactOpts) (rocketpool.GasInfo, error) + EstimateDissolveValidatorGas(validatorId uint32, opts *bind.TransactOpts) (gaslimit.Limits, error) DissolveValidator(validatorId uint32, opts *bind.TransactOpts) (common.Hash, error) - EstimateClaimRefundGas(opts *bind.TransactOpts) (rocketpool.GasInfo, error) + EstimateClaimRefundGas(opts *bind.TransactOpts) (gaslimit.Limits, error) ClaimRefund(opts *bind.TransactOpts) (common.Hash, error) - EstimateRepayDebtGas(opts *bind.TransactOpts) (rocketpool.GasInfo, error) + EstimateRepayDebtGas(opts *bind.TransactOpts) (gaslimit.Limits, error) RepayDebt(opts *bind.TransactOpts) (common.Hash, error) - EstimateReduceBondGas(amount *big.Int, opts *bind.TransactOpts) (rocketpool.GasInfo, error) + EstimateReduceBondGas(amount *big.Int, opts *bind.TransactOpts) (gaslimit.Limits, error) ReduceBond(amount *big.Int, opts *bind.TransactOpts) (common.Hash, error) GetWithdrawalCredentials(opts *bind.CallOpts) (common.Hash, error) GetNewValidatorBondRequirement(opts *bind.CallOpts) (*big.Int, error) - EstimateRequestUnstakeRPL(opts *bind.TransactOpts) (rocketpool.GasInfo, error) + EstimateRequestUnstakeRPL(opts *bind.TransactOpts) (gaslimit.Limits, error) RequestUnstakeRPL(opts *bind.TransactOpts) (common.Hash, error) - EstimateSetUseLatestDelegateGas(setting bool, opts *bind.TransactOpts) (rocketpool.GasInfo, error) + EstimateSetUseLatestDelegateGas(setting bool, opts *bind.TransactOpts) (gaslimit.Limits, error) SetUseLatestDelegate(setting bool, opts *bind.TransactOpts) (common.Hash, error) GetUseLatestDelegate(opts *bind.CallOpts) (bool, error) GetDelegate(opts *bind.CallOpts) (common.Address, error) GetDelegateExpired(rp *rocketpool.RocketPool, opts *bind.CallOpts) (bool, error) GetEffectiveDelegate(opts *bind.CallOpts) (common.Address, error) - EstimateDelegateUpgradeGas(opts *bind.TransactOpts) (rocketpool.GasInfo, error) + EstimateDelegateUpgradeGas(opts *bind.TransactOpts) (gaslimit.Limits, error) DelegateUpgrade(opts *bind.TransactOpts) (common.Hash, error) GetMegapoolPubkeys(opts *bind.CallOpts) ([]rptypes.ValidatorPubkey, error) } diff --git a/bindings/megapool/megapool-manager.go b/bindings/megapool/megapool-manager.go index fa4f215d8..1e17f33b0 100644 --- a/bindings/megapool/megapool-manager.go +++ b/bindings/megapool/megapool-manager.go @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" ) type ExitChallenge struct { @@ -110,10 +111,10 @@ func GetValidatorInfo(rp *rocketpool.RocketPool, index uint32, opts *bind.CallOp } // Estimate the gas of Stake -func EstimateStakeGas(rp *rocketpool.RocketPool, megapoolAddress common.Address, validatorId uint32, slotTimestamp uint64, validatorProof ValidatorProof, slotProof SlotProof, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateStakeGas(rp *rocketpool.RocketPool, megapoolAddress common.Address, validatorId uint32, slotTimestamp uint64, validatorProof ValidatorProof, slotProof SlotProof, opts *bind.TransactOpts) (gaslimit.Limits, error) { megapoolManager, err := getRocketMegapoolManager(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return megapoolManager.GetTransactionGasInfo(opts, "stake", megapoolAddress, validatorId, slotTimestamp, validatorProof, slotProof) } @@ -132,10 +133,10 @@ func Stake(rp *rocketpool.RocketPool, megapoolAddress common.Address, validatorI } // Estimate the gas to call NotifyExit -func EstimateNotifyExitGas(rp *rocketpool.RocketPool, megapoolAddress common.Address, validatorId uint32, slotTimestamp uint64, validatorProof ValidatorProof, slotProof SlotProof, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateNotifyExitGas(rp *rocketpool.RocketPool, megapoolAddress common.Address, validatorId uint32, slotTimestamp uint64, validatorProof ValidatorProof, slotProof SlotProof, opts *bind.TransactOpts) (gaslimit.Limits, error) { megapoolManager, err := getRocketMegapoolManager(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return megapoolManager.GetTransactionGasInfo(opts, "notifyExit", megapoolAddress, validatorId, slotTimestamp, validatorProof, slotProof) } @@ -154,10 +155,10 @@ func NotifyExit(rp *rocketpool.RocketPool, megapoolAddress common.Address, valid } // Estimate the gas to call NotifyNotExit -func EstimateNotifyNotExitGas(rp *rocketpool.RocketPool, megapoolAddress common.Address, validatorId uint32, slotTimestamp uint64, validatorProof ValidatorProof, slotProof SlotProof, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateNotifyNotExitGas(rp *rocketpool.RocketPool, megapoolAddress common.Address, validatorId uint32, slotTimestamp uint64, validatorProof ValidatorProof, slotProof SlotProof, opts *bind.TransactOpts) (gaslimit.Limits, error) { megapoolManager, err := getRocketMegapoolManager(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return megapoolManager.GetTransactionGasInfo(opts, "notifyNotExit", megapoolAddress, validatorId, slotTimestamp, validatorProof, slotProof) } @@ -176,10 +177,10 @@ func NotifyNotExit(rp *rocketpool.RocketPool, megapoolAddress common.Address, va } // Estimate the gas to call ChallengeExit -func EstimateChallengeExitGas(rp *rocketpool.RocketPool, exitChallenge []ExitChallenge, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateChallengeExitGas(rp *rocketpool.RocketPool, exitChallenge []ExitChallenge, opts *bind.TransactOpts) (gaslimit.Limits, error) { megapoolManager, err := getRocketMegapoolManager(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return megapoolManager.GetTransactionGasInfo(opts, "challengeExit", exitChallenge) } @@ -198,10 +199,10 @@ func ChallengeExit(rp *rocketpool.RocketPool, exitChallenge []ExitChallenge, opt } // Estimate the gas to call NotifyFinalBalance -func EstimateNotifyFinalBalance(rp *rocketpool.RocketPool, megapoolAddress common.Address, validatorId uint32, slotTimestamp uint64, withdrawalProof WithdrawalProof, validatorProof ValidatorProof, slotProof SlotProof, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateNotifyFinalBalance(rp *rocketpool.RocketPool, megapoolAddress common.Address, validatorId uint32, slotTimestamp uint64, withdrawalProof WithdrawalProof, validatorProof ValidatorProof, slotProof SlotProof, opts *bind.TransactOpts) (gaslimit.Limits, error) { megapoolManager, err := getRocketMegapoolManager(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return megapoolManager.GetTransactionGasInfo(opts, "notifyFinalBalance", megapoolAddress, validatorId, slotTimestamp, withdrawalProof, validatorProof, slotProof) } @@ -220,10 +221,10 @@ func NotifyFinalBalance(rp *rocketpool.RocketPool, megapoolAddress common.Addres } // Estimate the gas to call DissolveWithProof -func EstimateDissolveWithProof(rp *rocketpool.RocketPool, megapoolAddress common.Address, validatorId uint32, slotTimestamp uint64, validatorProof ValidatorProof, slotProof SlotProof, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateDissolveWithProof(rp *rocketpool.RocketPool, megapoolAddress common.Address, validatorId uint32, slotTimestamp uint64, validatorProof ValidatorProof, slotProof SlotProof, opts *bind.TransactOpts) (gaslimit.Limits, error) { megapoolManager, err := getRocketMegapoolManager(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return megapoolManager.GetTransactionGasInfo(opts, "dissolve", megapoolAddress, validatorId, slotTimestamp, validatorProof, slotProof) } diff --git a/bindings/megapool/megapool-penalties.go b/bindings/megapool/megapool-penalties.go index 4c78aab7f..d61c005ce 100644 --- a/bindings/megapool/megapool-penalties.go +++ b/bindings/megapool/megapool-penalties.go @@ -9,12 +9,13 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" ) -func EstimatePenaliseGas(rp *rocketpool.RocketPool, megapoolAddress common.Address, block *big.Int, amount *big.Int, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimatePenaliseGas(rp *rocketpool.RocketPool, megapoolAddress common.Address, block *big.Int, amount *big.Int, opts *bind.TransactOpts) (gaslimit.Limits, error) { megapoolPenalties, err := getRocketMegapoolPenalties(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return megapoolPenalties.GetTransactionGasInfo(opts, "penalise", megapoolAddress, block, amount) } diff --git a/bindings/minipool/minipool-contract-v2.go b/bindings/minipool/minipool-contract-v2.go index 2032d3b0a..695903822 100644 --- a/bindings/minipool/minipool-contract-v2.go +++ b/bindings/minipool/minipool-contract-v2.go @@ -13,8 +13,10 @@ import ( "github.com/ethereum/go-ethereum/common" "golang.org/x/sync/errgroup" + "github.com/rocket-pool/smartnode/bindings/logs" "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/storage" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" rptypes "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" ) @@ -25,9 +27,9 @@ const ( type MinipoolV2 interface { Minipool - EstimateDistributeBalanceAndFinaliseGas(opts *bind.TransactOpts) (rocketpool.GasInfo, error) + EstimateDistributeBalanceAndFinaliseGas(opts *bind.TransactOpts) (gaslimit.Limits, error) DistributeBalanceAndFinalise(opts *bind.TransactOpts) (common.Hash, error) - EstimateDistributeBalanceGas(opts *bind.TransactOpts) (rocketpool.GasInfo, error) + EstimateDistributeBalanceGas(opts *bind.TransactOpts) (gaslimit.Limits, error) DistributeBalance(opts *bind.TransactOpts) (common.Hash, error) } @@ -327,7 +329,7 @@ func (mp *minipool_v2) GetUserDepositAssignedTime(opts *bind.CallOpts) (time.Tim } // Estimate the gas of Refund -func (mp *minipool_v2) EstimateRefundGas(opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func (mp *minipool_v2) EstimateRefundGas(opts *bind.TransactOpts) (gaslimit.Limits, error) { return mp.Contract.GetTransactionGasInfo(opts, "refund") } @@ -341,7 +343,7 @@ func (mp *minipool_v2) Refund(opts *bind.TransactOpts) (common.Hash, error) { } // Estimate the gas of DistributeBalance -func (mp *minipool_v2) EstimateDistributeBalanceGas(opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func (mp *minipool_v2) EstimateDistributeBalanceGas(opts *bind.TransactOpts) (gaslimit.Limits, error) { return mp.Contract.GetTransactionGasInfo(opts, "distributeBalance") } @@ -358,7 +360,7 @@ func (mp *minipool_v2) DistributeBalance(opts *bind.TransactOpts) (common.Hash, } // Estimate the gas of DistributeBalanceAndFinalise -func (mp *minipool_v2) EstimateDistributeBalanceAndFinaliseGas(opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func (mp *minipool_v2) EstimateDistributeBalanceAndFinaliseGas(opts *bind.TransactOpts) (gaslimit.Limits, error) { return mp.Contract.GetTransactionGasInfo(opts, "distributeBalanceAndFinalise") } @@ -376,7 +378,7 @@ func (mp *minipool_v2) DistributeBalanceAndFinalise(opts *bind.TransactOpts) (co } // Estimate the gas of Stake -func (mp *minipool_v2) EstimateStakeGas(validatorSignature rptypes.ValidatorSignature, depositDataRoot common.Hash, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func (mp *minipool_v2) EstimateStakeGas(validatorSignature rptypes.ValidatorSignature, depositDataRoot common.Hash, opts *bind.TransactOpts) (gaslimit.Limits, error) { return mp.Contract.GetTransactionGasInfo(opts, "stake", validatorSignature[:], depositDataRoot) } @@ -390,7 +392,7 @@ func (mp *minipool_v2) Stake(validatorSignature rptypes.ValidatorSignature, depo } // Estimate the gas of Dissolve -func (mp *minipool_v2) EstimateDissolveGas(opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func (mp *minipool_v2) EstimateDissolveGas(opts *bind.TransactOpts) (gaslimit.Limits, error) { return mp.Contract.GetTransactionGasInfo(opts, "dissolve") } @@ -404,7 +406,7 @@ func (mp *minipool_v2) Dissolve(opts *bind.TransactOpts) (common.Hash, error) { } // Estimate the gas of Close -func (mp *minipool_v2) EstimateCloseGas(opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func (mp *minipool_v2) EstimateCloseGas(opts *bind.TransactOpts) (gaslimit.Limits, error) { return mp.Contract.GetTransactionGasInfo(opts, "close") } @@ -418,7 +420,7 @@ func (mp *minipool_v2) Close(opts *bind.TransactOpts) (common.Hash, error) { } // Estimate the gas of Finalise -func (mp *minipool_v2) EstimateFinaliseGas(opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func (mp *minipool_v2) EstimateFinaliseGas(opts *bind.TransactOpts) (gaslimit.Limits, error) { return mp.Contract.GetTransactionGasInfo(opts, "finalise") } @@ -432,7 +434,7 @@ func (mp *minipool_v2) Finalise(opts *bind.TransactOpts) (common.Hash, error) { } // Estimate the gas of DelegateUpgrade -func (mp *minipool_v2) EstimateDelegateUpgradeGas(opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func (mp *minipool_v2) EstimateDelegateUpgradeGas(opts *bind.TransactOpts) (gaslimit.Limits, error) { return mp.Contract.GetTransactionGasInfo(opts, "delegateUpgrade") } @@ -446,7 +448,7 @@ func (mp *minipool_v2) DelegateUpgrade(opts *bind.TransactOpts) (common.Hash, er } // Estimate the gas of SetUseLatestDelegate -func (mp *minipool_v2) EstimateSetUseLatestDelegateGas(opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func (mp *minipool_v2) EstimateSetUseLatestDelegateGas(opts *bind.TransactOpts) (gaslimit.Limits, error) { return mp.Contract.GetTransactionGasInfo(opts, "setUseLatestDelegate", true) } @@ -514,7 +516,7 @@ func (mp *minipool_v2) CalculateUserShare(balance *big.Int, opts *bind.CallOpts) } // Estimate the gas requiired to vote to scrub a minipool -func (mp *minipool_v2) EstimateVoteScrubGas(opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func (mp *minipool_v2) EstimateVoteScrubGas(opts *bind.TransactOpts) (gaslimit.Limits, error) { return mp.Contract.GetTransactionGasInfo(opts, "voteScrub") } @@ -556,7 +558,7 @@ func (mp *minipool_v2) GetPrestakeEvent(intervalSize *big.Int, opts *bind.CallOp fromBig := big.NewInt(0).SetUint64(from) toBig := big.NewInt(0).SetUint64(i) - logs, err := eth.GetLogs(mp.RocketPool, addressFilter, topicFilter, intervalSize, fromBig, toBig, nil) + logs, err := logs.GetLogs(mp.RocketPool, addressFilter, topicFilter, intervalSize, fromBig, toBig, nil) if err != nil { return PrestakeData{}, fmt.Errorf("Error getting prestake logs for minipool %s: %w", mp.Address.Hex(), err) } diff --git a/bindings/minipool/minipool-contract-v3.go b/bindings/minipool/minipool-contract-v3.go index 456ff486b..fcd640e53 100644 --- a/bindings/minipool/minipool-contract-v3.go +++ b/bindings/minipool/minipool-contract-v3.go @@ -13,8 +13,10 @@ import ( "github.com/ethereum/go-ethereum/common" "golang.org/x/sync/errgroup" + "github.com/rocket-pool/smartnode/bindings/logs" "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/storage" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" rptypes "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" ) @@ -25,13 +27,13 @@ const ( type MinipoolV3 interface { Minipool - EstimateReduceBondAmountGas(opts *bind.TransactOpts) (rocketpool.GasInfo, error) + EstimateReduceBondAmountGas(opts *bind.TransactOpts) (gaslimit.Limits, error) ReduceBondAmount(opts *bind.TransactOpts) (common.Hash, error) - EstimatePromoteGas(opts *bind.TransactOpts) (rocketpool.GasInfo, error) + EstimatePromoteGas(opts *bind.TransactOpts) (gaslimit.Limits, error) Promote(opts *bind.TransactOpts) (common.Hash, error) GetPreMigrationBalance(opts *bind.CallOpts) (*big.Int, error) GetUserDistributed(opts *bind.CallOpts) (bool, error) - EstimateDistributeBalanceGas(rewardsOnly bool, opts *bind.TransactOpts) (rocketpool.GasInfo, error) + EstimateDistributeBalanceGas(rewardsOnly bool, opts *bind.TransactOpts) (gaslimit.Limits, error) DistributeBalance(rewardsOnly bool, opts *bind.TransactOpts) (common.Hash, error) PrepareDistributeBalance(rewardsOnly bool, opts *bind.TransactOpts) (*types.Transaction, error) } @@ -353,7 +355,7 @@ func (mp *minipool_v3) GetUserDepositAssignedTime(opts *bind.CallOpts) (time.Tim } // Estimate the gas of Refund -func (mp *minipool_v3) EstimateRefundGas(opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func (mp *minipool_v3) EstimateRefundGas(opts *bind.TransactOpts) (gaslimit.Limits, error) { return mp.Contract.GetTransactionGasInfo(opts, "refund") } @@ -376,7 +378,7 @@ func (mp *minipool_v3) GetUserDistributed(opts *bind.CallOpts) (bool, error) { } // Estimate the gas of DistributeBalance -func (mp *minipool_v3) EstimateDistributeBalanceGas(rewardsOnly bool, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func (mp *minipool_v3) EstimateDistributeBalanceGas(rewardsOnly bool, opts *bind.TransactOpts) (gaslimit.Limits, error) { return mp.Contract.GetTransactionGasInfo(opts, "distributeBalance", rewardsOnly) } @@ -404,7 +406,7 @@ func (mp *minipool_v3) PrepareDistributeBalance(rewardsOnly bool, opts *bind.Tra } // Estimate the gas of Stake -func (mp *minipool_v3) EstimateStakeGas(validatorSignature rptypes.ValidatorSignature, depositDataRoot common.Hash, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func (mp *minipool_v3) EstimateStakeGas(validatorSignature rptypes.ValidatorSignature, depositDataRoot common.Hash, opts *bind.TransactOpts) (gaslimit.Limits, error) { return mp.Contract.GetTransactionGasInfo(opts, "stake", validatorSignature[:], depositDataRoot) } @@ -418,7 +420,7 @@ func (mp *minipool_v3) Stake(validatorSignature rptypes.ValidatorSignature, depo } // Estimate the gas of Dissolve -func (mp *minipool_v3) EstimateDissolveGas(opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func (mp *minipool_v3) EstimateDissolveGas(opts *bind.TransactOpts) (gaslimit.Limits, error) { return mp.Contract.GetTransactionGasInfo(opts, "dissolve") } @@ -432,7 +434,7 @@ func (mp *minipool_v3) Dissolve(opts *bind.TransactOpts) (common.Hash, error) { } // Estimate the gas of Close -func (mp *minipool_v3) EstimateCloseGas(opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func (mp *minipool_v3) EstimateCloseGas(opts *bind.TransactOpts) (gaslimit.Limits, error) { return mp.Contract.GetTransactionGasInfo(opts, "close") } @@ -446,7 +448,7 @@ func (mp *minipool_v3) Close(opts *bind.TransactOpts) (common.Hash, error) { } // Estimate the gas of Finalise -func (mp *minipool_v3) EstimateFinaliseGas(opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func (mp *minipool_v3) EstimateFinaliseGas(opts *bind.TransactOpts) (gaslimit.Limits, error) { return mp.Contract.GetTransactionGasInfo(opts, "finalise") } @@ -460,7 +462,7 @@ func (mp *minipool_v3) Finalise(opts *bind.TransactOpts) (common.Hash, error) { } // Estimate the gas of DelegateUpgrade -func (mp *minipool_v3) EstimateDelegateUpgradeGas(opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func (mp *minipool_v3) EstimateDelegateUpgradeGas(opts *bind.TransactOpts) (gaslimit.Limits, error) { return mp.Contract.GetTransactionGasInfo(opts, "delegateUpgrade") } @@ -474,7 +476,7 @@ func (mp *minipool_v3) DelegateUpgrade(opts *bind.TransactOpts) (common.Hash, er } // Estimate the gas of SetUseLatestDelegate -func (mp *minipool_v3) EstimateSetUseLatestDelegateGas(opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func (mp *minipool_v3) EstimateSetUseLatestDelegateGas(opts *bind.TransactOpts) (gaslimit.Limits, error) { return mp.Contract.GetTransactionGasInfo(opts, "setUseLatestDelegate", true) } @@ -524,7 +526,7 @@ func (mp *minipool_v3) GetEffectiveDelegate(opts *bind.CallOpts) (common.Address } // Estimate the gas required to reduce a minipool's bond -func (mp *minipool_v3) EstimateReduceBondAmountGas(opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func (mp *minipool_v3) EstimateReduceBondAmountGas(opts *bind.TransactOpts) (gaslimit.Limits, error) { return mp.Contract.GetTransactionGasInfo(opts, "reduceBondAmount") } @@ -556,7 +558,7 @@ func (mp *minipool_v3) CalculateUserShare(balance *big.Int, opts *bind.CallOpts) } // Estimate the gas required to vote to scrub a minipool -func (mp *minipool_v3) EstimateVoteScrubGas(opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func (mp *minipool_v3) EstimateVoteScrubGas(opts *bind.TransactOpts) (gaslimit.Limits, error) { return mp.Contract.GetTransactionGasInfo(opts, "voteScrub") } @@ -570,7 +572,7 @@ func (mp *minipool_v3) VoteScrub(opts *bind.TransactOpts) (common.Hash, error) { } // Estimate the gas required to promote a vacant minipool -func (mp *minipool_v3) EstimatePromoteGas(opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func (mp *minipool_v3) EstimatePromoteGas(opts *bind.TransactOpts) (gaslimit.Limits, error) { return mp.Contract.GetTransactionGasInfo(opts, "promote") } @@ -612,7 +614,7 @@ func (mp *minipool_v3) GetPrestakeEvent(intervalSize *big.Int, opts *bind.CallOp fromBig := big.NewInt(0).SetUint64(from) toBig := big.NewInt(0).SetUint64(i) - logs, err := eth.GetLogs(mp.RocketPool, addressFilter, topicFilter, intervalSize, fromBig, toBig, nil) + logs, err := logs.GetLogs(mp.RocketPool, addressFilter, topicFilter, intervalSize, fromBig, toBig, nil) if err != nil { return PrestakeData{}, fmt.Errorf("Error getting prestake logs for minipool %s: %w", mp.Address.Hex(), err) } diff --git a/bindings/minipool/minipool-interface.go b/bindings/minipool/minipool-interface.go index ce3be6462..ae8b2495b 100644 --- a/bindings/minipool/minipool-interface.go +++ b/bindings/minipool/minipool-interface.go @@ -8,6 +8,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" rptypes "github.com/rocket-pool/smartnode/bindings/types" ) @@ -75,19 +76,19 @@ type Minipool interface { GetUserDepositBalance(opts *bind.CallOpts) (*big.Int, error) GetUserDepositAssigned(opts *bind.CallOpts) (bool, error) GetUserDepositAssignedTime(opts *bind.CallOpts) (time.Time, error) - EstimateRefundGas(opts *bind.TransactOpts) (rocketpool.GasInfo, error) + EstimateRefundGas(opts *bind.TransactOpts) (gaslimit.Limits, error) Refund(opts *bind.TransactOpts) (common.Hash, error) - EstimateStakeGas(validatorSignature rptypes.ValidatorSignature, depositDataRoot common.Hash, opts *bind.TransactOpts) (rocketpool.GasInfo, error) + EstimateStakeGas(validatorSignature rptypes.ValidatorSignature, depositDataRoot common.Hash, opts *bind.TransactOpts) (gaslimit.Limits, error) Stake(validatorSignature rptypes.ValidatorSignature, depositDataRoot common.Hash, opts *bind.TransactOpts) (common.Hash, error) - EstimateDissolveGas(opts *bind.TransactOpts) (rocketpool.GasInfo, error) + EstimateDissolveGas(opts *bind.TransactOpts) (gaslimit.Limits, error) Dissolve(opts *bind.TransactOpts) (common.Hash, error) - EstimateCloseGas(opts *bind.TransactOpts) (rocketpool.GasInfo, error) + EstimateCloseGas(opts *bind.TransactOpts) (gaslimit.Limits, error) Close(opts *bind.TransactOpts) (common.Hash, error) - EstimateFinaliseGas(opts *bind.TransactOpts) (rocketpool.GasInfo, error) + EstimateFinaliseGas(opts *bind.TransactOpts) (gaslimit.Limits, error) Finalise(opts *bind.TransactOpts) (common.Hash, error) - EstimateDelegateUpgradeGas(opts *bind.TransactOpts) (rocketpool.GasInfo, error) + EstimateDelegateUpgradeGas(opts *bind.TransactOpts) (gaslimit.Limits, error) DelegateUpgrade(opts *bind.TransactOpts) (common.Hash, error) - EstimateSetUseLatestDelegateGas(opts *bind.TransactOpts) (rocketpool.GasInfo, error) + EstimateSetUseLatestDelegateGas(opts *bind.TransactOpts) (gaslimit.Limits, error) SetUseLatestDelegate(opts *bind.TransactOpts) (common.Hash, error) GetUseLatestDelegate(opts *bind.CallOpts) (bool, error) GetDelegate(opts *bind.CallOpts) (common.Address, error) @@ -95,7 +96,7 @@ type Minipool interface { GetEffectiveDelegate(opts *bind.CallOpts) (common.Address, error) CalculateNodeShare(balance *big.Int, opts *bind.CallOpts) (*big.Int, error) CalculateUserShare(balance *big.Int, opts *bind.CallOpts) (*big.Int, error) - EstimateVoteScrubGas(opts *bind.TransactOpts) (rocketpool.GasInfo, error) + EstimateVoteScrubGas(opts *bind.TransactOpts) (gaslimit.Limits, error) VoteScrub(opts *bind.TransactOpts) (common.Hash, error) GetPrestakeEvent(intervalSize *big.Int, opts *bind.CallOpts) (PrestakeData, error) } diff --git a/bindings/minipool/status.go b/bindings/minipool/status.go index efd51e392..69ecc8c2c 100644 --- a/bindings/minipool/status.go +++ b/bindings/minipool/status.go @@ -8,13 +8,14 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" ) // Estimate the gas of SubmitMinipoolWithdrawable -func EstimateSubmitMinipoolWithdrawableGas(rp *rocketpool.RocketPool, minipoolAddress common.Address, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateSubmitMinipoolWithdrawableGas(rp *rocketpool.RocketPool, minipoolAddress common.Address, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketMinipoolStatus, err := getRocketMinipoolStatus(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketMinipoolStatus.GetTransactionGasInfo(opts, "submitMinipoolWithdrawable", minipoolAddress) } diff --git a/bindings/network/balances.go b/bindings/network/balances.go index d88bbd634..4c11d6676 100644 --- a/bindings/network/balances.go +++ b/bindings/network/balances.go @@ -8,7 +8,9 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" + "github.com/rocket-pool/smartnode/bindings/logs" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/utils/eth" ) @@ -101,10 +103,10 @@ func GetETHUtilizationRate(rp *rocketpool.RocketPool, opts *bind.CallOpts) (floa } // Estimate the gas of SubmitBalances -func EstimateSubmitBalancesGas(rp *rocketpool.RocketPool, block uint64, slotTimestamp uint64, totalEth, stakingEth, rethSupply *big.Int, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateSubmitBalancesGas(rp *rocketpool.RocketPool, block uint64, slotTimestamp uint64, totalEth, stakingEth, rethSupply *big.Int, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketNetworkBalances, err := getRocketNetworkBalances(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketNetworkBalances.GetTransactionGasInfo(opts, "submitBalances", big.NewInt(int64(block)), big.NewInt(int64(slotTimestamp)), totalEth, stakingEth, rethSupply) } @@ -134,7 +136,7 @@ func GetBalancesSubmissions(rp *rocketpool.RocketPool, nodeAddress common.Addres topicFilter := [][]common.Hash{{rocketNetworkBalances.ABI.Events["BalancesSubmitted"].ID}, {common.BytesToHash(nodeAddress.Bytes())}} // Get the event logs - logs, err := eth.GetLogs(rp, addressFilter, topicFilter, intervalSize, big.NewInt(int64(fromBlock)), nil, nil) + logs, err := logs.GetLogs(rp, addressFilter, topicFilter, intervalSize, big.NewInt(int64(fromBlock)), nil, nil) if err != nil { return nil, err } @@ -163,7 +165,7 @@ func GetLatestBalancesSubmissions(rp *rocketpool.RocketPool, fromBlock uint64, i topicFilter := [][]common.Hash{{rocketNetworkBalances.ABI.Events["BalancesSubmitted"].ID}} // Get the event logs - logs, err := eth.GetLogs(rp, addressFilter, topicFilter, intervalSize, big.NewInt(int64(fromBlock)), nil, nil) + logs, err := logs.GetLogs(rp, addressFilter, topicFilter, intervalSize, big.NewInt(int64(fromBlock)), nil, nil) if err != nil { return nil, err } @@ -195,7 +197,7 @@ func GetBalancesUpdatedEvent(rp *rocketpool.RocketPool, blockNumber uint64, opts topicFilter := [][]common.Hash{{balancesUpdatedEvent.ID}, {indexBytes}} // Get the event logs - logs, err := eth.GetLogs(rp, addressFilter, topicFilter, big.NewInt(1), big.NewInt(int64(blockNumber)), big.NewInt(int64(blockNumber)), nil) + logs, err := logs.GetLogs(rp, addressFilter, topicFilter, big.NewInt(1), big.NewInt(int64(blockNumber)), big.NewInt(int64(blockNumber)), nil) if err != nil { return false, BalancesUpdatedEvent{}, err } diff --git a/bindings/network/penalties.go b/bindings/network/penalties.go index 5fafd95c0..70d946424 100644 --- a/bindings/network/penalties.go +++ b/bindings/network/penalties.go @@ -9,13 +9,14 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" ) // Estimate the gas of SubmitPenalty -func EstimateSubmitPenaltyGas(rp *rocketpool.RocketPool, minipoolAddress common.Address, block *big.Int, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateSubmitPenaltyGas(rp *rocketpool.RocketPool, minipoolAddress common.Address, block *big.Int, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketNetworkPenalties, err := getRocketNetworkPenalties(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketNetworkPenalties.GetTransactionGasInfo(opts, "submitPenalty", minipoolAddress, block) } diff --git a/bindings/network/prices.go b/bindings/network/prices.go index 358a14f61..f24c82a74 100644 --- a/bindings/network/prices.go +++ b/bindings/network/prices.go @@ -9,8 +9,9 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" + "github.com/rocket-pool/smartnode/bindings/logs" "github.com/rocket-pool/smartnode/bindings/rocketpool" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" ) // Info for a price updated event @@ -48,10 +49,10 @@ func GetRPLPrice(rp *rocketpool.RocketPool, opts *bind.CallOpts) (*big.Int, erro } // Estimate the gas of SubmitPrices -func EstimateSubmitPricesGas(rp *rocketpool.RocketPool, block uint64, slotTimestamp uint64, rplPrice *big.Int, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateSubmitPricesGas(rp *rocketpool.RocketPool, block uint64, slotTimestamp uint64, rplPrice *big.Int, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketNetworkPrices, err := getRocketNetworkPrices(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketNetworkPrices.GetTransactionGasInfo(opts, "submitPrices", big.NewInt(int64(block)), big.NewInt(int64(slotTimestamp)), rplPrice) } @@ -81,7 +82,7 @@ func GetPricesSubmissions(rp *rocketpool.RocketPool, nodeAddress common.Address, topicFilter := [][]common.Hash{{rocketNetworkPrices.ABI.Events["PricesSubmitted"].ID}, {common.BytesToHash(nodeAddress.Bytes())}} // Get the event logs - logs, err := eth.GetLogs(rp, addressFilter, topicFilter, intervalSize, big.NewInt(int64(fromBlock)), nil, nil) + logs, err := logs.GetLogs(rp, addressFilter, topicFilter, intervalSize, big.NewInt(int64(fromBlock)), nil, nil) if err != nil { return nil, err } @@ -109,7 +110,7 @@ func GetLatestPricesSubmissions(rp *rocketpool.RocketPool, fromBlock uint64, int topicFilter := [][]common.Hash{{rocketNetworkPrices.ABI.Events["PricesSubmitted"].ID}} // Get the event logs - logs, err := eth.GetLogs(rp, addressFilter, topicFilter, intervalSize, big.NewInt(int64(fromBlock)), nil, nil) + logs, err := logs.GetLogs(rp, addressFilter, topicFilter, intervalSize, big.NewInt(int64(fromBlock)), nil, nil) if err != nil { return nil, err } @@ -157,7 +158,7 @@ func GetPriceUpdatedEvent(rp *rocketpool.RocketPool, blockNumber uint64, opts *b } // Get the event logs - logs, err := eth.GetLogs(rp, addressFilter, topicFilter, big.NewInt(100), big.NewInt(int64(blockNumber)), big.NewInt(int64(toBlock)), nil) + logs, err := logs.GetLogs(rp, addressFilter, topicFilter, big.NewInt(100), big.NewInt(int64(blockNumber)), big.NewInt(int64(toBlock)), nil) if err != nil { return false, PriceUpdatedEvent{}, err } diff --git a/bindings/network/voting.go b/bindings/network/voting.go index 2a8be66c1..f287bc099 100644 --- a/bindings/network/voting.go +++ b/bindings/network/voting.go @@ -11,6 +11,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/node" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/multicall" ) @@ -148,10 +149,10 @@ func GetCurrentVotingDelegate(rp *rocketpool.RocketPool, address common.Address, } // Estimate the gas of SetVotingDelegate -func EstimateSetVotingDelegateGas(rp *rocketpool.RocketPool, newDelegate common.Address, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateSetVotingDelegateGas(rp *rocketpool.RocketPool, newDelegate common.Address, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketNetworkVoting, err := getRocketNetworkVoting(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketNetworkVoting.GetTransactionGasInfo(opts, "setDelegate", newDelegate) } diff --git a/bindings/node/deposit.go b/bindings/node/deposit.go index 6491497ef..129563ede 100644 --- a/bindings/node/deposit.go +++ b/bindings/node/deposit.go @@ -10,6 +10,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" rptypes "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" ) @@ -25,19 +26,19 @@ type NodeDeposit struct { type Deposits []NodeDeposit // Estimate the gas of DepositMulti -func EstimateDepositMultiGas(rp *rocketpool.RocketPool, deposits Deposits, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateDepositMultiGas(rp *rocketpool.RocketPool, deposits Deposits, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketNodeDeposit, err := getRocketNodeDeposit(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } - gasInfo, err := rocketNodeDeposit.GetTransactionGasInfo(opts, "depositMulti", deposits) + gasLimits, err := rocketNodeDeposit.GetTransactionGasInfo(opts, "depositMulti", deposits) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } // Use the estimated gas limit instead of the safe gas limit so we can get closer to the 16M tx gas limit - gasInfo.SafeGasLimit = min( - uint64(float64(gasInfo.EstGasLimit)), rocketpool.MaxGasLimit) - return gasInfo, nil + gasLimits.Safe = min( + uint64(float64(gasLimits.Estimated)), rocketpool.MaxGasLimit) + return gasLimits, nil } // Make multiple node deposits @@ -47,12 +48,12 @@ func DepositMulti(rp *rocketpool.RocketPool, deposits Deposits, opts *bind.Trans return nil, err } if opts.GasLimit == 0 { - gasInfo, err := rocketNodeDeposit.GetTransactionGasInfo(opts, "depositMulti", deposits) + gasLimits, err := rocketNodeDeposit.GetTransactionGasInfo(opts, "depositMulti", deposits) if err != nil { return nil, fmt.Errorf("error estimating gas for multiple node deposits: %w", err) } opts.GasLimit = min( - uint64(float64(gasInfo.EstGasLimit)), rocketpool.MaxGasLimit) + uint64(float64(gasLimits.Estimated)), rocketpool.MaxGasLimit) } tx, err := rocketNodeDeposit.Transact(opts, "depositMulti", deposits) if err != nil { @@ -62,10 +63,10 @@ func DepositMulti(rp *rocketpool.RocketPool, deposits Deposits, opts *bind.Trans } // Estimate the gas to WithdrawETH -func EstimateWithdrawEthGas(rp *rocketpool.RocketPool, nodeAccount common.Address, ethAmount *big.Int, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateWithdrawEthGas(rp *rocketpool.RocketPool, nodeAccount common.Address, ethAmount *big.Int, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketNodeDeposit, err := getRocketNodeDeposit(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketNodeDeposit.GetTransactionGasInfo(opts, "withdrawEth", nodeAccount, ethAmount) } @@ -84,10 +85,10 @@ func WithdrawEth(rp *rocketpool.RocketPool, nodeAccount common.Address, ethAmoun } // Estimate the gas required to withdraw credit -func EstimateWithdrawCreditGas(rp *rocketpool.RocketPool, amount *big.Int, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateWithdrawCreditGas(rp *rocketpool.RocketPool, amount *big.Int, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDepositPool, err := getRocketDepositPool(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketDepositPool.GetTransactionGasInfo(opts, "withdrawCredit", amount) } @@ -106,10 +107,10 @@ func WithdrawCredit(rp *rocketpool.RocketPool, amount *big.Int, opts *bind.Trans } // Estimate the gas of DepositWithCredit -func EstimateDepositWithCreditGas(rp *rocketpool.RocketPool, bondAmount *big.Int, useExpressTicket bool, validatorPubkey rptypes.ValidatorPubkey, validatorSignature rptypes.ValidatorSignature, depositDataRoot common.Hash, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateDepositWithCreditGas(rp *rocketpool.RocketPool, bondAmount *big.Int, useExpressTicket bool, validatorPubkey rptypes.ValidatorPubkey, validatorSignature rptypes.ValidatorSignature, depositDataRoot common.Hash, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketNodeDeposit, err := getRocketNodeDeposit(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketNodeDeposit.GetTransactionGasInfo(opts, "depositWithCredit", bondAmount, useExpressTicket, validatorPubkey[:], validatorSignature[:], depositDataRoot) } @@ -128,10 +129,10 @@ func DepositWithCredit(rp *rocketpool.RocketPool, bondAmount *big.Int, useExpres } // Estimate the gas of CreateVacantMinipool -func EstimateCreateVacantMinipoolGas(rp *rocketpool.RocketPool, bondAmount *big.Int, minimumNodeFee float64, validatorPubkey rptypes.ValidatorPubkey, salt *big.Int, expectedMinipoolAddress common.Address, currentBalance *big.Int, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateCreateVacantMinipoolGas(rp *rocketpool.RocketPool, bondAmount *big.Int, minimumNodeFee float64, validatorPubkey rptypes.ValidatorPubkey, salt *big.Int, expectedMinipoolAddress common.Address, currentBalance *big.Int, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketNodeDeposit, err := getRocketNodeDeposit(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketNodeDeposit.GetTransactionGasInfo(opts, "createVacantMinipool", bondAmount, eth.EthToWei(minimumNodeFee), validatorPubkey[:], salt, expectedMinipoolAddress, currentBalance) } diff --git a/bindings/node/distributor.go b/bindings/node/distributor.go index 49f1319df..7ed4ad00b 100644 --- a/bindings/node/distributor.go +++ b/bindings/node/distributor.go @@ -10,6 +10,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" ) // Distributor contract @@ -50,7 +51,7 @@ func GetDistributorAddress(rp *rocketpool.RocketPool, nodeAddress common.Address } // Estimate the gas of a distribute -func (d *Distributor) EstimateDistributeGas(opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func (d *Distributor) EstimateDistributeGas(opts *bind.TransactOpts) (gaslimit.Limits, error) { return d.Contract.GetTransactionGasInfo(opts, "distribute") } diff --git a/bindings/node/node.go b/bindings/node/node.go index 5f327762c..40dfa2e47 100644 --- a/bindings/node/node.go +++ b/bindings/node/node.go @@ -13,6 +13,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/storage" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/bindings/utils/multicall" "github.com/rocket-pool/smartnode/bindings/utils/strings" @@ -343,14 +344,14 @@ func GetNodeTimezoneLocation(rp *rocketpool.RocketPool, nodeAddress common.Addre } // Estimate the gas of RegisterNode -func EstimateRegisterNodeGas(rp *rocketpool.RocketPool, timezoneLocation string, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateRegisterNodeGas(rp *rocketpool.RocketPool, timezoneLocation string, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketNodeManager, err := getRocketNodeManager(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } _, err = time.LoadLocation(timezoneLocation) if err != nil { - return rocketpool.GasInfo{}, fmt.Errorf("error verifying timezone [%s]: %w", timezoneLocation, err) + return gaslimit.Limits{}, fmt.Errorf("error verifying timezone [%s]: %w", timezoneLocation, err) } return rocketNodeManager.GetTransactionGasInfo(opts, "registerNode", timezoneLocation) } @@ -373,14 +374,14 @@ func RegisterNode(rp *rocketpool.RocketPool, timezoneLocation string, opts *bind } // Estimate the gas of SetTimezoneLocation -func EstimateSetTimezoneLocationGas(rp *rocketpool.RocketPool, timezoneLocation string, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateSetTimezoneLocationGas(rp *rocketpool.RocketPool, timezoneLocation string, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketNodeManager, err := getRocketNodeManager(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } _, err = time.LoadLocation(timezoneLocation) if err != nil { - return rocketpool.GasInfo{}, fmt.Errorf("error verifying timezone [%s]: %w", timezoneLocation, err) + return gaslimit.Limits{}, fmt.Errorf("error verifying timezone [%s]: %w", timezoneLocation, err) } return rocketNodeManager.GetTransactionGasInfo(opts, "setTimezoneLocation", timezoneLocation) } @@ -442,10 +443,10 @@ func GetFeeDistributorInitialized(rp *rocketpool.RocketPool, nodeAddress common. } // Estimate the gas for creating the fee distributor contract for a node -func EstimateInitializeFeeDistributorGas(rp *rocketpool.RocketPool, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateInitializeFeeDistributorGas(rp *rocketpool.RocketPool, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketNodeManager, err := getRocketNodeManager(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketNodeManager.GetTransactionGasInfo(opts, "initialiseFeeDistributor") } @@ -555,10 +556,10 @@ func GetSmoothingPoolRegistrationChangedRaw(rp *rocketpool.RocketPool, nodeAddre } // Estimate the gas for opting into / out of the smoothing pool -func EstimateSetSmoothingPoolRegistrationStateGas(rp *rocketpool.RocketPool, optIn bool, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateSetSmoothingPoolRegistrationStateGas(rp *rocketpool.RocketPool, optIn bool, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketNodeManager, err := getRocketNodeManager(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketNodeManager.GetTransactionGasInfo(opts, "setSmoothingPoolRegistrationState", optIn) } @@ -666,10 +667,10 @@ func GetNodePendingRPLWithdrawalAddress(rp *rocketpool.RocketPool, nodeAddress c } // Estimate the gas for setting the RPL-specific withdrawal address -func EstimateSetRPLWithdrawalAddressGas(rp *rocketpool.RocketPool, nodeAddress common.Address, withdrawalAddress common.Address, confirm bool, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateSetRPLWithdrawalAddressGas(rp *rocketpool.RocketPool, nodeAddress common.Address, withdrawalAddress common.Address, confirm bool, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketNodeManager, err := getRocketNodeManager(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketNodeManager.GetTransactionGasInfo(opts, "setRPLWithdrawalAddress", nodeAddress, withdrawalAddress, confirm) } @@ -688,10 +689,10 @@ func SetRPLWithdrawalAddress(rp *rocketpool.RocketPool, nodeAddress common.Addre } // Estimate the gas for confirming the RPL-specific withdrawal address -func EstimateConfirmRPLWithdrawalAddressGas(rp *rocketpool.RocketPool, nodeAddress common.Address, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateConfirmRPLWithdrawalAddressGas(rp *rocketpool.RocketPool, nodeAddress common.Address, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketNodeManager, err := getRocketNodeManager(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketNodeManager.GetTransactionGasInfo(opts, "confirmRPLWithdrawalAddress", nodeAddress) } @@ -778,10 +779,10 @@ func GetUnclaimedRewardsRaw(rp *rocketpool.RocketPool, nodeAddress common.Addres } // Estimate the gas for sending unclaimed rewards to node operator's withdrawal address -func EstimateClaimUnclaimedRewards(rp *rocketpool.RocketPool, nodeAddress common.Address, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateClaimUnclaimedRewards(rp *rocketpool.RocketPool, nodeAddress common.Address, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketNodeManager, err := getRocketNodeManager(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketNodeManager.GetTransactionGasInfo(opts, "claimUnclaimedRewards", nodeAddress) } @@ -814,10 +815,10 @@ func GetExpressTicketsProvisioned(rp *rocketpool.RocketPool, nodeAddress common. } // Estimate the gas for provisioning the node's express tickets -func EstimateProvisionExpressTicketsGas(rp *rocketpool.RocketPool, nodeAddress common.Address, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProvisionExpressTicketsGas(rp *rocketpool.RocketPool, nodeAddress common.Address, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketNodeManager, err := getRocketNodeManager(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketNodeManager.GetTransactionGasInfo(opts, "provisionExpressTickets", nodeAddress) } diff --git a/bindings/node/staking.go b/bindings/node/staking.go index 85688b71c..555d44b38 100644 --- a/bindings/node/staking.go +++ b/bindings/node/staking.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" ) // Get the version of the Node Staking contract @@ -242,10 +243,10 @@ func GetNodeMinipoolETHBonded(rp *rocketpool.RocketPool, nodeAddress common.Addr } // Estimate the gas of Stake -func EstimateStakeGas(rp *rocketpool.RocketPool, rplAmount *big.Int, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateStakeGas(rp *rocketpool.RocketPool, rplAmount *big.Int, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketNodeStaking, err := getRocketNodeStaking(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketNodeStaking.GetTransactionGasInfo(opts, "stakeRPL", rplAmount) } @@ -264,10 +265,10 @@ func StakeRPL(rp *rocketpool.RocketPool, rplAmount *big.Int, opts *bind.Transact } // Estimate the gas of UnstakeRPL -func EstimateUnstakeGas(rp *rocketpool.RocketPool, rplAmount *big.Int, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateUnstakeGas(rp *rocketpool.RocketPool, rplAmount *big.Int, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketNodeStaking, err := getRocketNodeStaking(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketNodeStaking.GetTransactionGasInfo(opts, "unstakeRPL", rplAmount) } @@ -286,10 +287,10 @@ func UnstakeRPL(rp *rocketpool.RocketPool, rplAmount *big.Int, opts *bind.Transa } // Estimate the gas of set RPL locking allowed -func EstimateSetRPLLockingAllowedGas(rp *rocketpool.RocketPool, caller common.Address, allowed bool, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateSetRPLLockingAllowedGas(rp *rocketpool.RocketPool, caller common.Address, allowed bool, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketNodeStaking, err := getRocketNodeStaking(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketNodeStaking.GetTransactionGasInfo(opts, "setRPLLockingAllowed", caller, allowed) } @@ -321,10 +322,10 @@ func GetRPLLockedAllowed(rp *rocketpool.RocketPool, nodeAddress common.Address, } // Estimate the gas of set stake RPL for allowed -func EstimateSetStakeRPLForAllowedGas(rp *rocketpool.RocketPool, caller common.Address, allowed bool, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateSetStakeRPLForAllowedGas(rp *rocketpool.RocketPool, caller common.Address, allowed bool, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketNodeStaking, err := getRocketNodeStaking(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketNodeStaking.GetTransactionGasInfo(opts, "setStakeRPLForAllowed", caller, allowed) } @@ -356,10 +357,10 @@ func SetNodeStakeRPLForAllowed(rp *rocketpool.RocketPool, nodeAddress common.Add } // Estimate the gas of WithdrawRPL -func EstimateWithdrawRPLGas(rp *rocketpool.RocketPool, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateWithdrawRPLGas(rp *rocketpool.RocketPool, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketNodeStaking, err := getRocketNodeStaking(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketNodeStaking.GetTransactionGasInfo(opts, "withdrawRPL") } @@ -378,10 +379,10 @@ func WithdrawRPL(rp *rocketpool.RocketPool, opts *bind.TransactOpts) (common.Has } // Estimate the gas of UnstakeLegacyRPL -func EstimateUnstakeLegacyRPLGas(rp *rocketpool.RocketPool, rplAmount *big.Int, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateUnstakeLegacyRPLGas(rp *rocketpool.RocketPool, rplAmount *big.Int, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketNodeStaking, err := getRocketNodeStaking(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketNodeStaking.GetTransactionGasInfo(opts, "unstakeLegacyRPL", rplAmount) } diff --git a/bindings/rewards/distributor-mainnet.go b/bindings/rewards/distributor-mainnet.go index c35cb82f2..7cf12274c 100644 --- a/bindings/rewards/distributor-mainnet.go +++ b/bindings/rewards/distributor-mainnet.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/types" ) @@ -39,10 +40,10 @@ func MerkleRoots(rp *rocketpool.RocketPool, interval *big.Int, opts *bind.CallOp } // Estimate claim rewards gas -func EstimateClaimGas(rp *rocketpool.RocketPool, address common.Address, claims types.Claims, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateClaimGas(rp *rocketpool.RocketPool, address common.Address, claims types.Claims, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDistributorMainnet, err := getRocketDistributorMainnet(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketDistributorMainnet.GetTransactionGasInfo(opts, "claim", address, claims) } @@ -61,10 +62,10 @@ func Claim(rp *rocketpool.RocketPool, address common.Address, claims types.Claim } // Estimate claim and restake rewards gas -func EstimateClaimAndStakeGas(rp *rocketpool.RocketPool, address common.Address, claims types.Claims, stakeAmount *big.Int, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateClaimAndStakeGas(rp *rocketpool.RocketPool, address common.Address, claims types.Claims, stakeAmount *big.Int, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketDistributorMainnet, err := getRocketDistributorMainnet(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketDistributorMainnet.GetTransactionGasInfo(opts, "claimAndStake", address, claims, stakeAmount) } diff --git a/bindings/rewards/rewards.go b/bindings/rewards/rewards.go index f4ebdf25d..7b25c2d86 100644 --- a/bindings/rewards/rewards.go +++ b/bindings/rewards/rewards.go @@ -13,8 +13,9 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" + "github.com/rocket-pool/smartnode/bindings/logs" "github.com/rocket-pool/smartnode/bindings/rocketpool" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" ) const ( @@ -211,10 +212,10 @@ func GetTrustedNodeSubmittedSpecificRewards(rp *rocketpool.RocketPool, nodeAddre } // Estimate the gas for submitting a Merkle Tree-based snapshot for a rewards interval -func EstimateSubmitRewardSnapshotGas(rp *rocketpool.RocketPool, submission RewardSubmission, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateSubmitRewardSnapshotGas(rp *rocketpool.RocketPool, submission RewardSubmission, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketRewardsPool, err := getRocketRewardsPool(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketRewardsPool.GetTransactionGasInfo(opts, "submitRewardSnapshot", submission) } @@ -276,7 +277,7 @@ func GetRewardsEvent(rp *rocketpool.RocketPool, index uint64, rocketRewardsPoolA topicFilter := [][]common.Hash{{rewardsSnapshotEvent.ID}, {indexBytes}} // Get the event logs - logs, err := eth.GetLogs(rp, addressFilter, topicFilter, big.NewInt(1), block, block, nil) + logs, err := logs.GetLogs(rp, addressFilter, topicFilter, big.NewInt(1), block, block, nil) if err != nil { return false, RewardsEvent{}, err } diff --git a/bindings/rocketpool/contract.go b/bindings/rocketpool/contract.go index aea10a78c..b2f10f624 100644 --- a/bindings/rocketpool/contract.go +++ b/bindings/rocketpool/contract.go @@ -14,6 +14,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" ) // Transaction settings @@ -31,12 +32,6 @@ type Contract struct { Client ExecutionClient } -// Response for gas limits from network and from user request -type GasInfo struct { - EstGasLimit uint64 `json:"estGasLimit"` - SafeGasLimit uint64 `json:"safeGasLimit"` -} - // Call a contract method func (c *Contract) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error { results := make([]interface{}, 1) @@ -45,9 +40,9 @@ func (c *Contract) Call(opts *bind.CallOpts, result interface{}, method string, } // Get Gas Limit for transaction -func (c *Contract) GetTransactionGasInfo(opts *bind.TransactOpts, method string, params ...interface{}) (GasInfo, error) { +func (c *Contract) GetTransactionGasInfo(opts *bind.TransactOpts, method string, params ...interface{}) (gaslimit.Limits, error) { - response := GasInfo{} + response := gaslimit.Limits{} // Pack transaction Info input, err := c.ABI.Pack(method, params...) @@ -61,8 +56,8 @@ func (c *Contract) GetTransactionGasInfo(opts *bind.TransactOpts, method string, if err != nil { return response, fmt.Errorf("Error getting transaction gas info: could not estimate gas limit: %w", err) } - response.EstGasLimit = estGasLimit - response.SafeGasLimit = safeGasLimit + response.Estimated = estGasLimit + response.Safe = safeGasLimit return response, err } @@ -94,17 +89,17 @@ func (c *Contract) Transact(opts *bind.TransactOpts, method string, params ...in } // Get gas limit for a transfer call -func (c *Contract) GetTransferGasInfo(opts *bind.TransactOpts) (GasInfo, error) { +func (c *Contract) GetTransferGasInfo(opts *bind.TransactOpts) (gaslimit.Limits, error) { - response := GasInfo{} + response := gaslimit.Limits{} // Estimate gas limit estGasLimit, safeGasLimit, err := c.estimateGasLimit(opts, []byte{}) if err != nil { return response, fmt.Errorf("Error getting transfer gas info: could not estimate gas limit: %w", err) } - response.EstGasLimit = estGasLimit - response.SafeGasLimit = safeGasLimit + response.Estimated = estGasLimit + response.Safe = safeGasLimit return response, nil } diff --git a/bindings/settings/protocol/auction.go b/bindings/settings/protocol/auction.go index 79da4082b..f0c4e5662 100644 --- a/bindings/settings/protocol/auction.go +++ b/bindings/settings/protocol/auction.go @@ -11,6 +11,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/dao/protocol" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" ) @@ -42,7 +43,7 @@ func GetCreateLotEnabled(rp *rocketpool.RocketPool, opts *bind.CallOpts) (bool, func ProposeCreateLotEnabled(rp *rocketpool.RocketPool, value bool, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetBool(rp, fmt.Sprintf("set %s", CreateLotEnabledSettingPath), AuctionSettingsContractName, CreateLotEnabledSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeCreateLotEnabledGas(rp *rocketpool.RocketPool, value bool, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeCreateLotEnabledGas(rp *rocketpool.RocketPool, value bool, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetBoolGas(rp, fmt.Sprintf("set %s", CreateLotEnabledSettingPath), AuctionSettingsContractName, CreateLotEnabledSettingPath, value, blockNumber, treeNodes, opts) } @@ -61,7 +62,7 @@ func GetBidOnLotEnabled(rp *rocketpool.RocketPool, opts *bind.CallOpts) (bool, e func ProposeBidOnLotEnabled(rp *rocketpool.RocketPool, value bool, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetBool(rp, fmt.Sprintf("set %s", BidOnLotEnabledSettingPath), AuctionSettingsContractName, BidOnLotEnabledSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeBidOnLotEnabledGas(rp *rocketpool.RocketPool, value bool, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeBidOnLotEnabledGas(rp *rocketpool.RocketPool, value bool, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetBoolGas(rp, fmt.Sprintf("set %s", BidOnLotEnabledSettingPath), AuctionSettingsContractName, BidOnLotEnabledSettingPath, value, blockNumber, treeNodes, opts) } @@ -80,7 +81,7 @@ func GetLotMinimumEthValue(rp *rocketpool.RocketPool, opts *bind.CallOpts) (*big func ProposeLotMinimumEthValue(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", LotMinimumEthValueSettingPath), AuctionSettingsContractName, LotMinimumEthValueSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeLotMinimumEthValueGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeLotMinimumEthValueGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", LotMinimumEthValueSettingPath), AuctionSettingsContractName, LotMinimumEthValueSettingPath, value, blockNumber, treeNodes, opts) } @@ -99,7 +100,7 @@ func GetLotMaximumEthValue(rp *rocketpool.RocketPool, opts *bind.CallOpts) (*big func ProposeLotMaximumEthValue(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", LotMaximumEthValueSettingPath), AuctionSettingsContractName, LotMaximumEthValueSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeLotMaximumEthValueGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeLotMaximumEthValueGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", LotMaximumEthValueSettingPath), AuctionSettingsContractName, LotMaximumEthValueSettingPath, value, blockNumber, treeNodes, opts) } @@ -118,7 +119,7 @@ func GetLotDuration(rp *rocketpool.RocketPool, opts *bind.CallOpts) (time.Durati func ProposeLotDuration(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", LotDurationSettingPath), AuctionSettingsContractName, LotDurationSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeLotDurationGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeLotDurationGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", LotDurationSettingPath), AuctionSettingsContractName, LotDurationSettingPath, value, blockNumber, treeNodes, opts) } @@ -150,7 +151,7 @@ func GetLotStartingPriceRatioRaw(rp *rocketpool.RocketPool, opts *bind.CallOpts) func ProposeLotStartingPriceRatio(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", LotStartingPriceRatioSettingPath), AuctionSettingsContractName, LotStartingPriceRatioSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeLotStartingPriceRatioGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeLotStartingPriceRatioGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", LotStartingPriceRatioSettingPath), AuctionSettingsContractName, LotStartingPriceRatioSettingPath, value, blockNumber, treeNodes, opts) } @@ -182,7 +183,7 @@ func GetLotReservePriceRatioRaw(rp *rocketpool.RocketPool, opts *bind.CallOpts) func ProposeLotReservePriceRatio(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", LotReservePriceRatioSettingPath), AuctionSettingsContractName, LotReservePriceRatioSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeLotReservePriceRatioGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeLotReservePriceRatioGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", LotReservePriceRatioSettingPath), AuctionSettingsContractName, LotReservePriceRatioSettingPath, value, blockNumber, treeNodes, opts) } diff --git a/bindings/settings/protocol/deposit.go b/bindings/settings/protocol/deposit.go index 03381f9a6..029fb3391 100644 --- a/bindings/settings/protocol/deposit.go +++ b/bindings/settings/protocol/deposit.go @@ -10,6 +10,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/dao/protocol" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/types" ) @@ -42,7 +43,7 @@ func GetDepositEnabled(rp *rocketpool.RocketPool, opts *bind.CallOpts) (bool, er func ProposeDepositEnabled(rp *rocketpool.RocketPool, value bool, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetBool(rp, fmt.Sprintf("set %s", DepositEnabledSettingPath), DepositSettingsContractName, DepositEnabledSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeDepositEnabledGas(rp *rocketpool.RocketPool, value bool, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeDepositEnabledGas(rp *rocketpool.RocketPool, value bool, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetBoolGas(rp, fmt.Sprintf("set %s", DepositEnabledSettingPath), DepositSettingsContractName, DepositEnabledSettingPath, value, blockNumber, treeNodes, opts) } @@ -61,7 +62,7 @@ func GetAssignDepositsEnabled(rp *rocketpool.RocketPool, opts *bind.CallOpts) (b func ProposeAssignDepositsEnabled(rp *rocketpool.RocketPool, value bool, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetBool(rp, fmt.Sprintf("set %s", AssignDepositsEnabledSettingPath), DepositSettingsContractName, AssignDepositsEnabledSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeAssignDepositsEnabledGas(rp *rocketpool.RocketPool, value bool, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeAssignDepositsEnabledGas(rp *rocketpool.RocketPool, value bool, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetBoolGas(rp, fmt.Sprintf("set %s", AssignDepositsEnabledSettingPath), DepositSettingsContractName, AssignDepositsEnabledSettingPath, value, blockNumber, treeNodes, opts) } @@ -80,7 +81,7 @@ func GetMinimumDeposit(rp *rocketpool.RocketPool, opts *bind.CallOpts) (*big.Int func ProposeMinimumDeposit(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", MinimumDepositSettingPath), DepositSettingsContractName, MinimumDepositSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeMinimumDepositGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeMinimumDepositGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", MinimumDepositSettingPath), DepositSettingsContractName, MinimumDepositSettingPath, value, blockNumber, treeNodes, opts) } @@ -99,7 +100,7 @@ func GetMaximumDepositPoolSize(rp *rocketpool.RocketPool, opts *bind.CallOpts) ( func ProposeMaximumDepositPoolSize(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", MaximumDepositPoolSizeSettingPath), DepositSettingsContractName, MaximumDepositPoolSizeSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeMaximumDepositPoolSizeGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeMaximumDepositPoolSizeGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", MaximumDepositPoolSizeSettingPath), DepositSettingsContractName, MaximumDepositPoolSizeSettingPath, value, blockNumber, treeNodes, opts) } @@ -118,7 +119,7 @@ func GetMaximumDepositAssignments(rp *rocketpool.RocketPool, opts *bind.CallOpts func ProposeMaximumDepositAssignments(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", MaximumDepositAssignmentsSettingPath), DepositSettingsContractName, MaximumDepositAssignmentsSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeMaximumDepositAssignmentsGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeMaximumDepositAssignmentsGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", MaximumDepositAssignmentsSettingPath), DepositSettingsContractName, MaximumDepositAssignmentsSettingPath, value, blockNumber, treeNodes, opts) } @@ -137,7 +138,7 @@ func GetMaximumSocializedDepositAssignments(rp *rocketpool.RocketPool, opts *bin func ProposeMaximumSocializedDepositAssignments(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", MaximumSocializedDepositAssignmentsSettingPath), DepositSettingsContractName, MaximumSocializedDepositAssignmentsSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeMaximumSocializedDepositAssignmentsGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeMaximumSocializedDepositAssignmentsGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", MaximumSocializedDepositAssignmentsSettingPath), DepositSettingsContractName, MaximumSocializedDepositAssignmentsSettingPath, value, blockNumber, treeNodes, opts) } @@ -156,7 +157,7 @@ func GetDepositFee(rp *rocketpool.RocketPool, opts *bind.CallOpts) (*big.Int, er func ProposeDepositFee(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", DepositFeeSettingPath), DepositSettingsContractName, DepositFeeSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeDepositFeeGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeDepositFeeGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", DepositFeeSettingPath), DepositSettingsContractName, DepositFeeSettingPath, value, blockNumber, treeNodes, opts) } @@ -175,7 +176,7 @@ func GetExpressQueueRate(rp *rocketpool.RocketPool, opts *bind.CallOpts) (uint64 func ProposeExpressQueueRate(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", ExpressQueueRatePath), DepositSettingsContractName, ExpressQueueRatePath, value, blockNumber, treeNodes, opts) } -func EstimateProposeExpressQueueRateGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeExpressQueueRateGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", ExpressQueueRatePath), DepositSettingsContractName, ExpressQueueRatePath, value, blockNumber, treeNodes, opts) } @@ -194,7 +195,7 @@ func GetExpressQueueTicketsBaseProvision(rp *rocketpool.RocketPool, opts *bind.C func ProposeExpressQueueTicketsBaseProvision(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", ExpressQueueTicketsBaseProvisionPath), DepositSettingsContractName, ExpressQueueTicketsBaseProvisionPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeExpressQueueTicketsBaseProvisionGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeExpressQueueTicketsBaseProvisionGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", ExpressQueueTicketsBaseProvisionPath), DepositSettingsContractName, ExpressQueueTicketsBaseProvisionPath, value, blockNumber, treeNodes, opts) } diff --git a/bindings/settings/protocol/megapool.go b/bindings/settings/protocol/megapool.go index fd8704324..7b0af9a54 100644 --- a/bindings/settings/protocol/megapool.go +++ b/bindings/settings/protocol/megapool.go @@ -10,6 +10,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/dao/protocol" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/types" ) @@ -42,7 +43,7 @@ func GetMegapoolTimeBeforeDissolve(rp *rocketpool.RocketPool, opts *bind.CallOpt func ProposeMegapoolTimeBeforeDissolve(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", MegapoolTimeBeforeDissolveSettingsPath), MegapoolSettingsContractName, MegapoolTimeBeforeDissolveSettingsPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeMegapoolTimeBeforeDissolve(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeMegapoolTimeBeforeDissolve(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", MegapoolTimeBeforeDissolveSettingsPath), MegapoolSettingsContractName, MegapoolTimeBeforeDissolveSettingsPath, value, blockNumber, treeNodes, opts) } @@ -62,7 +63,7 @@ func GetMaximumEthPenalty(rp *rocketpool.RocketPool, opts *bind.CallOpts) (*big. func ProposeMaximumEthPenalty(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", MegapoolMaximumMegapoolEthPenaltyPath), MegapoolSettingsContractName, MegapoolMaximumMegapoolEthPenaltyPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeMaximumEthPenalty(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeMaximumEthPenalty(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", MegapoolMaximumMegapoolEthPenaltyPath), MegapoolSettingsContractName, MegapoolMaximumMegapoolEthPenaltyPath, value, blockNumber, treeNodes, opts) } @@ -82,7 +83,7 @@ func GetNotifyThreshold(rp *rocketpool.RocketPool, opts *bind.CallOpts) (uint64, func ProposeNotifyThreshold(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", MegapoolNotifyThresholdPath), MegapoolSettingsContractName, MegapoolNotifyThresholdPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeNotifyThreshold(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeNotifyThreshold(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", MegapoolNotifyThresholdPath), MegapoolSettingsContractName, MegapoolNotifyThresholdPath, value, blockNumber, treeNodes, opts) } @@ -102,7 +103,7 @@ func GetLateNotifyFine(rp *rocketpool.RocketPool, opts *bind.CallOpts) (*big.Int func ProposeLateNotifyFine(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", MegapoolLateNotifyFinePath), MegapoolSettingsContractName, MegapoolLateNotifyFinePath, value, blockNumber, treeNodes, opts) } -func EstimateProposeLateNotifyFine(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeLateNotifyFine(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", MegapoolLateNotifyFinePath), MegapoolSettingsContractName, MegapoolLateNotifyFinePath, value, blockNumber, treeNodes, opts) } @@ -122,7 +123,7 @@ func GetMegapoolDissolvePenalty(rp *rocketpool.RocketPool, opts *bind.CallOpts) func ProposeDissolvePenalty(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", MegapoolDissolvePenaltyPath), MegapoolSettingsContractName, MegapoolDissolvePenaltyPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeDissolvePenalty(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeDissolvePenalty(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", MegapoolDissolvePenaltyPath), MegapoolSettingsContractName, MegapoolDissolvePenaltyPath, value, blockNumber, treeNodes, opts) } @@ -142,7 +143,7 @@ func GetUserDistributeDelay(rp *rocketpool.RocketPool, opts *bind.CallOpts) (uin func ProposeUserDistributeDelay(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", MegapoolUserDistributeDelayPath), MegapoolSettingsContractName, MegapoolUserDistributeDelayPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeUserDistributeDelay(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeUserDistributeDelay(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", MegapoolUserDistributeDelayPath), MegapoolSettingsContractName, MegapoolUserDistributeDelayPath, value, blockNumber, treeNodes, opts) } @@ -162,7 +163,7 @@ func GetUserDistributeDelayWithShortfall(rp *rocketpool.RocketPool, opts *bind.C func ProposeUserDistributeDelayWithShortfall(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", MegapoolUserDistributeDelayShortfallPath), MegapoolSettingsContractName, MegapoolUserDistributeDelayShortfallPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeUserDistributeDelayWithShortfall(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeUserDistributeDelayWithShortfall(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", MegapoolUserDistributeDelayShortfallPath), MegapoolSettingsContractName, MegapoolUserDistributeDelayShortfallPath, value, blockNumber, treeNodes, opts) } @@ -182,7 +183,7 @@ func GetPenaltyThreshold(rp *rocketpool.RocketPool, opts *bind.CallOpts) (*big.I func ProposePenaltyThreshold(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", MegapoolPenaltyThreshold), MegapoolSettingsContractName, MegapoolPenaltyThreshold, value, blockNumber, treeNodes, opts) } -func EstimateProposePenaltyThreshold(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposePenaltyThreshold(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", MegapoolPenaltyThreshold), MegapoolSettingsContractName, MegapoolPenaltyThreshold, value, blockNumber, treeNodes, opts) } diff --git a/bindings/settings/protocol/minipool.go b/bindings/settings/protocol/minipool.go index c0b881a51..e9e8a5e1f 100644 --- a/bindings/settings/protocol/minipool.go +++ b/bindings/settings/protocol/minipool.go @@ -11,6 +11,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/dao/protocol" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/types" ) @@ -41,7 +42,7 @@ func GetMinipoolSubmitWithdrawableEnabled(rp *rocketpool.RocketPool, opts *bind. func ProposeMinipoolSubmitWithdrawableEnabled(rp *rocketpool.RocketPool, value bool, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetBool(rp, fmt.Sprintf("set %s", MinipoolSubmitWithdrawableEnabledSettingPath), MinipoolSettingsContractName, MinipoolSubmitWithdrawableEnabledSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeMinipoolSubmitWithdrawableEnabledGas(rp *rocketpool.RocketPool, value bool, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeMinipoolSubmitWithdrawableEnabledGas(rp *rocketpool.RocketPool, value bool, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetBoolGas(rp, fmt.Sprintf("set %s", MinipoolSubmitWithdrawableEnabledSettingPath), MinipoolSettingsContractName, MinipoolSubmitWithdrawableEnabledSettingPath, value, blockNumber, treeNodes, opts) } @@ -61,7 +62,7 @@ func GetMinipoolLaunchTimeout(rp *rocketpool.RocketPool, opts *bind.CallOpts) (t func ProposeMinipoolLaunchTimeout(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", MinipoolLaunchTimeoutSettingPath), MinipoolSettingsContractName, MinipoolLaunchTimeoutSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeMinipoolLaunchTimeoutGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeMinipoolLaunchTimeoutGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", MinipoolLaunchTimeoutSettingPath), MinipoolSettingsContractName, MinipoolLaunchTimeoutSettingPath, value, blockNumber, treeNodes, opts) } @@ -93,7 +94,7 @@ func GetBondReductionEnabled(rp *rocketpool.RocketPool, opts *bind.CallOpts) (bo func ProposeBondReductionEnabled(rp *rocketpool.RocketPool, value bool, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetBool(rp, fmt.Sprintf("set %s", BondReductionEnabledSettingPath), MinipoolSettingsContractName, BondReductionEnabledSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeBondReductionEnabledGas(rp *rocketpool.RocketPool, value bool, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeBondReductionEnabledGas(rp *rocketpool.RocketPool, value bool, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetBoolGas(rp, fmt.Sprintf("set %s", BondReductionEnabledSettingPath), MinipoolSettingsContractName, BondReductionEnabledSettingPath, value, blockNumber, treeNodes, opts) } @@ -112,7 +113,7 @@ func GetMaximumMinipoolCount(rp *rocketpool.RocketPool, opts *bind.CallOpts) (ui func ProposeMaximumMinipoolCount(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", MaximumMinipoolCountSettingPath), MinipoolSettingsContractName, MaximumMinipoolCountSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeMaximumMinipoolCountGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeMaximumMinipoolCountGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", MaximumMinipoolCountSettingPath), MinipoolSettingsContractName, MaximumMinipoolCountSettingPath, value, blockNumber, treeNodes, opts) } @@ -131,7 +132,7 @@ func GetMinipoolUserDistributeWindowStart(rp *rocketpool.RocketPool, opts *bind. func ProposeMinipoolUserDistributeWindowStart(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", MinipoolUserDistributeWindowStartSettingPath), MinipoolSettingsContractName, MinipoolUserDistributeWindowStartSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeMinipoolUserDistributeWindowStartGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeMinipoolUserDistributeWindowStartGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", MinipoolUserDistributeWindowStartSettingPath), MinipoolSettingsContractName, MinipoolUserDistributeWindowStartSettingPath, value, blockNumber, treeNodes, opts) } @@ -150,7 +151,7 @@ func GetMinipoolUserDistributeWindowLength(rp *rocketpool.RocketPool, opts *bind func ProposeMinipoolUserDistributeWindowLength(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", MinipoolUserDistributeWindowLengthSettingPath), MinipoolSettingsContractName, MinipoolUserDistributeWindowLengthSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeMinipoolUserDistributeWindowLengthGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeMinipoolUserDistributeWindowLengthGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", MinipoolUserDistributeWindowLengthSettingPath), MinipoolSettingsContractName, MinipoolUserDistributeWindowLengthSettingPath, value, blockNumber, treeNodes, opts) } @@ -169,7 +170,7 @@ func GetMaximumPenaltyCount(rp *rocketpool.RocketPool, opts *bind.CallOpts) (uin func ProposeMaximumPenaltyCount(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", MinipoolMaximumPenaltyCountSettingPath), MinipoolSettingsContractName, MinipoolMaximumPenaltyCountSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeMaximumPenaltyCountGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeMaximumPenaltyCountGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", MaximumMinipoolCountSettingPath), MinipoolMaximumPenaltyCountSettingPath, MinipoolMaximumPenaltyCountSettingPath, value, blockNumber, treeNodes, opts) } diff --git a/bindings/settings/protocol/network.go b/bindings/settings/protocol/network.go index 6db7b4f90..f103a83d6 100644 --- a/bindings/settings/protocol/network.go +++ b/bindings/settings/protocol/network.go @@ -11,6 +11,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/dao/protocol" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" ) @@ -68,7 +69,7 @@ func GetNodeConsensusThresholdRaw(rp *rocketpool.RocketPool, opts *bind.CallOpts func ProposeNodeConsensusThreshold(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", NodeConsensusThresholdSettingPath), NetworkSettingsContractName, NodeConsensusThresholdSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeNodeConsensusThresholdGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeNodeConsensusThresholdGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", NodeConsensusThresholdSettingPath), NetworkSettingsContractName, NodeConsensusThresholdSettingPath, value, blockNumber, treeNodes, opts) } @@ -87,7 +88,7 @@ func GetSubmitBalancesEnabled(rp *rocketpool.RocketPool, opts *bind.CallOpts) (b func ProposeSubmitBalancesEnabled(rp *rocketpool.RocketPool, value bool, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetBool(rp, fmt.Sprintf("set %s", SubmitBalancesEnabledSettingPath), NetworkSettingsContractName, SubmitBalancesEnabledSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeSubmitBalancesEnabledGas(rp *rocketpool.RocketPool, value bool, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeSubmitBalancesEnabledGas(rp *rocketpool.RocketPool, value bool, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetBoolGas(rp, fmt.Sprintf("set %s", SubmitBalancesEnabledSettingPath), NetworkSettingsContractName, SubmitBalancesEnabledSettingPath, value, blockNumber, treeNodes, opts) } @@ -106,7 +107,7 @@ func GetSubmitBalancesFrequency(rp *rocketpool.RocketPool, opts *bind.CallOpts) func ProposeSubmitBalancesFrequency(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", SubmitBalancesFrequencySettingPath), NetworkSettingsContractName, SubmitBalancesFrequencySettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeSubmitBalancesFrequencyGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeSubmitBalancesFrequencyGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", SubmitBalancesFrequencySettingPath), NetworkSettingsContractName, SubmitBalancesFrequencySettingPath, value, blockNumber, treeNodes, opts) } @@ -125,7 +126,7 @@ func GetSubmitPricesEnabled(rp *rocketpool.RocketPool, opts *bind.CallOpts) (boo func ProposeSubmitPricesEnabled(rp *rocketpool.RocketPool, value bool, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetBool(rp, fmt.Sprintf("set %s", SubmitPricesEnabledSettingPath), NetworkSettingsContractName, SubmitPricesEnabledSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeSubmitPricesEnabledGas(rp *rocketpool.RocketPool, value bool, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeSubmitPricesEnabledGas(rp *rocketpool.RocketPool, value bool, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetBoolGas(rp, fmt.Sprintf("set %s", SubmitPricesEnabledSettingPath), NetworkSettingsContractName, SubmitPricesEnabledSettingPath, value, blockNumber, treeNodes, opts) } @@ -144,7 +145,7 @@ func GetSubmitPricesFrequency(rp *rocketpool.RocketPool, opts *bind.CallOpts) (t func ProposeSubmitPricesFrequency(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", SubmitPricesFrequencySettingPath), NetworkSettingsContractName, SubmitPricesFrequencySettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeSubmitPricesFrequencyGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeSubmitPricesFrequencyGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", SubmitPricesFrequencySettingPath), NetworkSettingsContractName, SubmitPricesFrequencySettingPath, value, blockNumber, treeNodes, opts) } @@ -176,7 +177,7 @@ func GetMinimumNodeFeeRaw(rp *rocketpool.RocketPool, opts *bind.CallOpts) (*big. func ProposeMinimumNodeFee(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", MinimumNodeFeeSettingPath), NetworkSettingsContractName, MinimumNodeFeeSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeMinimumNodeFeeGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeMinimumNodeFeeGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", MinimumNodeFeeSettingPath), NetworkSettingsContractName, MinimumNodeFeeSettingPath, value, blockNumber, treeNodes, opts) } @@ -208,7 +209,7 @@ func GetTargetNodeFeeRaw(rp *rocketpool.RocketPool, opts *bind.CallOpts) (*big.I func ProposeTargetNodeFee(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", TargetNodeFeeSettingPath), NetworkSettingsContractName, TargetNodeFeeSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeTargetNodeFeeGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeTargetNodeFeeGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", TargetNodeFeeSettingPath), NetworkSettingsContractName, TargetNodeFeeSettingPath, value, blockNumber, treeNodes, opts) } @@ -240,7 +241,7 @@ func GetMaximumNodeFeeRaw(rp *rocketpool.RocketPool, opts *bind.CallOpts) (*big. func ProposeMaximumNodeFee(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", MaximumNodeFeeSettingPath), NetworkSettingsContractName, MaximumNodeFeeSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeMaximumNodeFeeGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeMaximumNodeFeeGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", MaximumNodeFeeSettingPath), NetworkSettingsContractName, MaximumNodeFeeSettingPath, value, blockNumber, treeNodes, opts) } @@ -259,7 +260,7 @@ func GetNodeFeeDemandRange(rp *rocketpool.RocketPool, opts *bind.CallOpts) (*big func ProposeNodeFeeDemandRange(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", NodeFeeDemandRangeSettingPath), NetworkSettingsContractName, NodeFeeDemandRangeSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeNodeFeeDemandRangeGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeNodeFeeDemandRangeGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", NodeFeeDemandRangeSettingPath), NetworkSettingsContractName, NodeFeeDemandRangeSettingPath, value, blockNumber, treeNodes, opts) } @@ -291,7 +292,7 @@ func GetTargetRethCollateralRateRaw(rp *rocketpool.RocketPool, opts *bind.CallOp func ProposeTargetRethCollateralRate(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", TargetRethCollateralRateSettingPath), NetworkSettingsContractName, TargetRethCollateralRateSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeTargetRethCollateralRateGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeTargetRethCollateralRateGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", TargetRethCollateralRateSettingPath), NetworkSettingsContractName, TargetRethCollateralRateSettingPath, value, blockNumber, treeNodes, opts) } @@ -323,7 +324,7 @@ func GetNetworkPenaltyThresholdRaw(rp *rocketpool.RocketPool, opts *bind.CallOpt func ProposeNetworkPenaltyThreshold(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", NetworkPenaltyThresholdSettingPath), NetworkSettingsContractName, NetworkPenaltyThresholdSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeNetworkPenaltyThresholdGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeNetworkPenaltyThresholdGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", NetworkPenaltyThresholdSettingPath), NetworkSettingsContractName, NetworkPenaltyThresholdSettingPath, value, blockNumber, treeNodes, opts) } @@ -355,7 +356,7 @@ func GetNetworkPenaltyPerRateRaw(rp *rocketpool.RocketPool, opts *bind.CallOpts) func ProposeNetworkPenaltyPerRate(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", NetworkPenaltyPerRateSettingPath), NetworkSettingsContractName, NetworkPenaltyPerRateSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeNetworkPenaltyPerRateGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeNetworkPenaltyPerRateGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", NetworkPenaltyPerRateSettingPath), NetworkSettingsContractName, NetworkPenaltyPerRateSettingPath, value, blockNumber, treeNodes, opts) } @@ -374,7 +375,7 @@ func GetSubmitRewardsEnabled(rp *rocketpool.RocketPool, opts *bind.CallOpts) (bo func ProposeSubmitRewardsEnabled(rp *rocketpool.RocketPool, value bool, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetBool(rp, fmt.Sprintf("set %s", SubmitRewardsEnabledSettingPath), NetworkSettingsContractName, SubmitRewardsEnabledSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeSubmitRewardsEnabledGas(rp *rocketpool.RocketPool, value bool, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeSubmitRewardsEnabledGas(rp *rocketpool.RocketPool, value bool, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetBoolGas(rp, fmt.Sprintf("set %s", SubmitRewardsEnabledSettingPath), NetworkSettingsContractName, SubmitRewardsEnabledSettingPath, value, blockNumber, treeNodes, opts) } @@ -394,7 +395,7 @@ func GetAllowListedControllers(rp *rocketpool.RocketPool, opts *bind.CallOpts) ( func ProposeAllowListedControllers(rp *rocketpool.RocketPool, value []common.Address, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetAddressList(rp, fmt.Sprintf("set %s", NetworkAllowListedControllersPath), NetworkSettingsContractName, NetworkAllowListedControllersPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeAllowListedControllersGas(rp *rocketpool.RocketPool, value []common.Address, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeAllowListedControllersGas(rp *rocketpool.RocketPool, value []common.Address, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetAddressListGas(rp, fmt.Sprintf("set %s", NetworkAllowListedControllersPath), NetworkSettingsContractName, NetworkAllowListedControllersPath, value, blockNumber, treeNodes, opts) } @@ -414,7 +415,7 @@ func GetNodeShare(rp *rocketpool.RocketPool, opts *bind.CallOpts) (*big.Int, err func ProposeNodeShare(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", NetworkNodeCommissionSharePath), NetworkSettingsContractName, NetworkNodeCommissionSharePath, value, blockNumber, treeNodes, opts) } -func EstimateProposeNodeShareGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeNodeShareGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", NetworkNodeCommissionSharePath), NetworkSettingsContractName, NetworkNodeCommissionSharePath, value, blockNumber, treeNodes, opts) } @@ -434,7 +435,7 @@ func GetNodeShareSecurityCouncilAdder(rp *rocketpool.RocketPool, opts *bind.Call func ProposeNodeShareSecurityCouncilAdder(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", NetworkNodeCommissionShareSecurityCouncilAdderPath), NetworkSettingsContractName, NetworkNodeCommissionShareSecurityCouncilAdderPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeNodeShareSecurityCouncilAdderGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeNodeShareSecurityCouncilAdderGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", NetworkNodeCommissionShareSecurityCouncilAdderPath), NetworkSettingsContractName, NetworkNodeCommissionShareSecurityCouncilAdderPath, value, blockNumber, treeNodes, opts) } @@ -454,7 +455,7 @@ func GetVoterShare(rp *rocketpool.RocketPool, opts *bind.CallOpts) (*big.Int, er func ProposeVoterShare(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", NetworkVoterSharePath), NetworkSettingsContractName, NetworkVoterSharePath, value, blockNumber, treeNodes, opts) } -func EstimateProposeVoterShareGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeVoterShareGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", NetworkVoterSharePath), NetworkSettingsContractName, NetworkVoterSharePath, value, blockNumber, treeNodes, opts) } @@ -474,7 +475,7 @@ func GetProtocolDAOShare(rp *rocketpool.RocketPool, opts *bind.CallOpts) (*big.I func ProposeProtocolDAOShare(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", NetworkPDAOSharePath), NetworkSettingsContractName, NetworkPDAOSharePath, value, blockNumber, treeNodes, opts) } -func EstimateProposeProtocolDAOShare(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeProtocolDAOShare(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", NetworkPDAOSharePath), NetworkSettingsContractName, NetworkPDAOSharePath, value, blockNumber, treeNodes, opts) } @@ -494,7 +495,7 @@ func GetMaxNodeShareSecurityCouncilAdder(rp *rocketpool.RocketPool, opts *bind.C func ProposeMaxNodeShareSecurityCouncilAdder(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", NetworkMaxNodeShareSecurityCouncilAdderPath), NetworkSettingsContractName, NetworkMaxNodeShareSecurityCouncilAdderPath, value, blockNumber, treeNodes, opts) } -func EstimateMaxNodeShareSecurityCouncilAdder(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateMaxNodeShareSecurityCouncilAdder(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", NetworkMaxNodeShareSecurityCouncilAdderPath), NetworkSettingsContractName, NetworkMaxNodeShareSecurityCouncilAdderPath, value, blockNumber, treeNodes, opts) } @@ -514,7 +515,7 @@ func GetMaxRethDelta(rp *rocketpool.RocketPool, opts *bind.CallOpts) (*big.Int, func ProposeMaxRethDelta(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", NetworkMaxRethBalanceDeltaPath), NetworkSettingsContractName, NetworkMaxRethBalanceDeltaPath, value, blockNumber, treeNodes, opts) } -func EstimateMaxRethDeltaGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateMaxRethDeltaGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", NetworkMaxRethBalanceDeltaPath), NetworkSettingsContractName, NetworkMaxRethBalanceDeltaPath, value, blockNumber, treeNodes, opts) } diff --git a/bindings/settings/protocol/node.go b/bindings/settings/protocol/node.go index b9249dac9..f54eea473 100644 --- a/bindings/settings/protocol/node.go +++ b/bindings/settings/protocol/node.go @@ -10,6 +10,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/dao/protocol" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" ) @@ -41,7 +42,7 @@ func GetNodeRegistrationEnabled(rp *rocketpool.RocketPool, opts *bind.CallOpts) func ProposeNodeRegistrationEnabled(rp *rocketpool.RocketPool, value bool, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetBool(rp, fmt.Sprintf("set %s", NodeRegistrationEnabledSettingPath), NodeSettingsContractName, NodeRegistrationEnabledSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeNodeRegistrationEnabledGas(rp *rocketpool.RocketPool, value bool, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeNodeRegistrationEnabledGas(rp *rocketpool.RocketPool, value bool, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetBoolGas(rp, fmt.Sprintf("set %s", NodeRegistrationEnabledSettingPath), NodeSettingsContractName, NodeRegistrationEnabledSettingPath, value, blockNumber, treeNodes, opts) } @@ -60,7 +61,7 @@ func GetSmoothingPoolRegistrationEnabled(rp *rocketpool.RocketPool, opts *bind.C func ProposeSmoothingPoolRegistrationEnabled(rp *rocketpool.RocketPool, value bool, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetBool(rp, fmt.Sprintf("set %s", SmoothingPoolRegistrationEnabledSettingPath), NodeSettingsContractName, SmoothingPoolRegistrationEnabledSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeSmoothingPoolRegistrationEnabledGas(rp *rocketpool.RocketPool, value bool, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeSmoothingPoolRegistrationEnabledGas(rp *rocketpool.RocketPool, value bool, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetBoolGas(rp, fmt.Sprintf("set %s", SmoothingPoolRegistrationEnabledSettingPath), NodeSettingsContractName, SmoothingPoolRegistrationEnabledSettingPath, value, blockNumber, treeNodes, opts) } @@ -79,7 +80,7 @@ func GetNodeDepositEnabled(rp *rocketpool.RocketPool, opts *bind.CallOpts) (bool func ProposeNodeDepositEnabled(rp *rocketpool.RocketPool, value bool, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetBool(rp, fmt.Sprintf("set %s", NodeDepositEnabledSettingPath), NodeSettingsContractName, NodeDepositEnabledSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeNodeDepositEnabledGas(rp *rocketpool.RocketPool, value bool, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeNodeDepositEnabledGas(rp *rocketpool.RocketPool, value bool, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetBoolGas(rp, fmt.Sprintf("set %s", NodeDepositEnabledSettingPath), NodeSettingsContractName, NodeDepositEnabledSettingPath, value, blockNumber, treeNodes, opts) } @@ -98,7 +99,7 @@ func GetVacantMinipoolsEnabled(rp *rocketpool.RocketPool, opts *bind.CallOpts) ( func ProposeVacantMinipoolsEnabled(rp *rocketpool.RocketPool, value bool, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetBool(rp, fmt.Sprintf("set %s", VacantMinipoolsEnabledSettingPath), NodeSettingsContractName, VacantMinipoolsEnabledSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeVacantMinipoolsEnabledGas(rp *rocketpool.RocketPool, value bool, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeVacantMinipoolsEnabledGas(rp *rocketpool.RocketPool, value bool, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetBoolGas(rp, fmt.Sprintf("set %s", VacantMinipoolsEnabledSettingPath), NodeSettingsContractName, VacantMinipoolsEnabledSettingPath, value, blockNumber, treeNodes, opts) } @@ -117,7 +118,7 @@ func GetMinimumLegacyRPLStake(rp *rocketpool.RocketPool, opts *bind.CallOpts) (f func ProposeMinimumLecacyRPLStake(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", MinimumLegacyRplStakePath), NodeSettingsContractName, MinimumLegacyRplStakePath, value, blockNumber, treeNodes, opts) } -func EstimateProposeMinimumLecacyRPLStakeGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeMinimumLecacyRPLStakeGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", MinimumLegacyRplStakePath), NodeSettingsContractName, MinimumLegacyRplStakePath, value, blockNumber, treeNodes, opts) } @@ -149,7 +150,7 @@ func GetReducedBond(rp *rocketpool.RocketPool, opts *bind.CallOpts) (float64, er func ProposeReducedBond(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", ReducedBondSettingPath), NodeSettingsContractName, ReducedBondSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeReducedBond(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeReducedBond(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", ReducedBondSettingPath), NodeSettingsContractName, ReducedBondSettingPath, value, blockNumber, treeNodes, opts) } @@ -181,7 +182,7 @@ func GetNodeUnstakingPeriod(rp *rocketpool.RocketPool, opts *bind.CallOpts) (*bi func ProposeNodeUnstakingPeriod(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", NodeUnstakingPeriodSettingPath), NodeSettingsContractName, NodeUnstakingPeriodSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeNodeUnstakingPeriod(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeNodeUnstakingPeriod(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", NodeUnstakingPeriodSettingPath), NodeSettingsContractName, NodeUnstakingPeriodSettingPath, value, blockNumber, treeNodes, opts) } diff --git a/bindings/settings/protocol/proposals.go b/bindings/settings/protocol/proposals.go index 2a158033d..2f583822b 100644 --- a/bindings/settings/protocol/proposals.go +++ b/bindings/settings/protocol/proposals.go @@ -11,6 +11,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/dao/protocol" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" ) @@ -45,7 +46,7 @@ func GetVotePhase1Time(rp *rocketpool.RocketPool, opts *bind.CallOpts) (time.Dur func ProposeVotePhase1Time(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", VotePhase1TimeSettingPath), ProposalsSettingsContractName, VotePhase1TimeSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeVotePhase1TimeGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeVotePhase1TimeGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", VotePhase1TimeSettingPath), ProposalsSettingsContractName, VotePhase1TimeSettingPath, value, blockNumber, treeNodes, opts) } @@ -64,7 +65,7 @@ func GetVotePhase2Time(rp *rocketpool.RocketPool, opts *bind.CallOpts) (time.Dur func ProposeVotePhase2Time(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", VotePhase2TimeSettingPath), ProposalsSettingsContractName, VotePhase2TimeSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeVotePhase2TimeGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeVotePhase2TimeGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", VotePhase2TimeSettingPath), ProposalsSettingsContractName, VotePhase2TimeSettingPath, value, blockNumber, treeNodes, opts) } @@ -83,7 +84,7 @@ func GetVoteDelayTime(rp *rocketpool.RocketPool, opts *bind.CallOpts) (time.Dura func ProposeVoteDelayTime(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", VoteDelayTimeSettingPath), ProposalsSettingsContractName, VoteDelayTimeSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeVoteDelayTimeGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeVoteDelayTimeGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", VoteDelayTimeSettingPath), ProposalsSettingsContractName, VoteDelayTimeSettingPath, value, blockNumber, treeNodes, opts) } @@ -102,7 +103,7 @@ func GetExecuteTime(rp *rocketpool.RocketPool, opts *bind.CallOpts) (time.Durati func ProposeExecuteTime(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", ExecuteTimeSettingPath), ProposalsSettingsContractName, ExecuteTimeSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeExecuteTimeGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeExecuteTimeGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", ExecuteTimeSettingPath), ProposalsSettingsContractName, ExecuteTimeSettingPath, value, blockNumber, treeNodes, opts) } @@ -121,7 +122,7 @@ func GetProposalBond(rp *rocketpool.RocketPool, opts *bind.CallOpts) (*big.Int, func ProposeProposalBond(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", ProposalBondSettingPath), ProposalsSettingsContractName, ProposalBondSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeProposalBondGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeProposalBondGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", ProposalBondSettingPath), ProposalsSettingsContractName, ProposalBondSettingPath, value, blockNumber, treeNodes, opts) } @@ -140,7 +141,7 @@ func GetChallengeBond(rp *rocketpool.RocketPool, opts *bind.CallOpts) (*big.Int, func ProposeChallengeBond(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", ChallengeBondSettingPath), ProposalsSettingsContractName, ChallengeBondSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeChallengeBondGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeChallengeBondGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", ChallengeBondSettingPath), ProposalsSettingsContractName, ChallengeBondSettingPath, value, blockNumber, treeNodes, opts) } @@ -159,7 +160,7 @@ func GetChallengePeriod(rp *rocketpool.RocketPool, opts *bind.CallOpts) (time.Du func ProposeChallengePeriod(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", ChallengePeriodSettingPath), ProposalsSettingsContractName, ChallengePeriodSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeChallengePeriodGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeChallengePeriodGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", ChallengePeriodSettingPath), ProposalsSettingsContractName, ChallengePeriodSettingPath, value, blockNumber, treeNodes, opts) } @@ -191,7 +192,7 @@ func GetProposalQuorumRaw(rp *rocketpool.RocketPool, opts *bind.CallOpts) (*big. func ProposeProposalQuorum(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", ProposalQuorumSettingPath), ProposalsSettingsContractName, ProposalQuorumSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeProposalQuorumGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeProposalQuorumGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", ProposalQuorumSettingPath), ProposalsSettingsContractName, ProposalQuorumSettingPath, value, blockNumber, treeNodes, opts) } @@ -223,7 +224,7 @@ func GetProposalVetoQuorumRaw(rp *rocketpool.RocketPool, opts *bind.CallOpts) (* func ProposeProposalVetoQuorum(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", ProposalVetoQuorumSettingPath), ProposalsSettingsContractName, ProposalVetoQuorumSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeProposalVetoQuorumGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeProposalVetoQuorumGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", ProposalVetoQuorumSettingPath), ProposalsSettingsContractName, ProposalVetoQuorumSettingPath, value, blockNumber, treeNodes, opts) } @@ -242,7 +243,7 @@ func GetProposalMaxBlockAge(rp *rocketpool.RocketPool, opts *bind.CallOpts) (uin func ProposeProposalMaxBlockAge(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", ProposalMaxBlockAgeSettingPath), ProposalsSettingsContractName, ProposalMaxBlockAgeSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeProposalMaxBlockAgeGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeProposalMaxBlockAgeGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", ProposalMaxBlockAgeSettingPath), ProposalsSettingsContractName, ProposalMaxBlockAgeSettingPath, value, blockNumber, treeNodes, opts) } diff --git a/bindings/settings/protocol/rewards.go b/bindings/settings/protocol/rewards.go index b9adddbb5..2650add4d 100644 --- a/bindings/settings/protocol/rewards.go +++ b/bindings/settings/protocol/rewards.go @@ -11,6 +11,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/dao/protocol" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" ) @@ -121,7 +122,7 @@ func GetRewardsClaimIntervalTime(rp *rocketpool.RocketPool, opts *bind.CallOpts) func ProposeRewardsClaimIntervalTime(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", RewardsClaimIntervalPeriodsSettingPath), RewardsSettingsContractName, RewardsClaimIntervalPeriodsSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeRewardsClaimIntervalTimeGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeRewardsClaimIntervalTimeGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", RewardsClaimIntervalPeriodsSettingPath), RewardsSettingsContractName, RewardsClaimIntervalPeriodsSettingPath, value, blockNumber, treeNodes, opts) } diff --git a/bindings/settings/protocol/security.go b/bindings/settings/protocol/security.go index 8d524f4d4..df6ca1020 100644 --- a/bindings/settings/protocol/security.go +++ b/bindings/settings/protocol/security.go @@ -11,6 +11,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/dao/protocol" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/types" ) @@ -39,7 +40,7 @@ func GetSecurityMembersQuorum(rp *rocketpool.RocketPool, opts *bind.CallOpts) (* func ProposeSecurityMembersQuorum(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", SecurityMembersQuorumSettingPath), SecuritySettingsContractName, SecurityMembersQuorumSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeSecurityMembersQuorumGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeSecurityMembersQuorumGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", SecurityMembersQuorumSettingPath), SecuritySettingsContractName, SecurityMembersQuorumSettingPath, value, blockNumber, treeNodes, opts) } @@ -58,7 +59,7 @@ func GetSecurityMembersLeaveTime(rp *rocketpool.RocketPool, opts *bind.CallOpts) func ProposeSecurityMembersLeaveTime(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", SecurityMembersLeaveTimeSettingPath), SecuritySettingsContractName, SecurityMembersLeaveTimeSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeSecurityMembersLeaveTimeGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeSecurityMembersLeaveTimeGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", SecurityMembersLeaveTimeSettingPath), SecuritySettingsContractName, SecurityMembersLeaveTimeSettingPath, value, blockNumber, treeNodes, opts) } @@ -77,7 +78,7 @@ func GetSecurityProposalVoteTime(rp *rocketpool.RocketPool, opts *bind.CallOpts) func ProposeSecurityProposalVoteTime(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", SecurityProposalVoteTimeSettingPath), SecuritySettingsContractName, SecurityProposalVoteTimeSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeSecurityProposalVoteTimeGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeSecurityProposalVoteTimeGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", SecurityProposalVoteTimeSettingPath), SecuritySettingsContractName, SecurityProposalVoteTimeSettingPath, value, blockNumber, treeNodes, opts) } @@ -96,7 +97,7 @@ func GetSecurityProposalExecuteTime(rp *rocketpool.RocketPool, opts *bind.CallOp func ProposeSecurityProposalExecuteTime(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", SecurityProposalExecuteTimeSettingPath), SecuritySettingsContractName, SecurityProposalExecuteTimeSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeSecurityProposalExecuteTimeGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeSecurityProposalExecuteTimeGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", SecurityProposalExecuteTimeSettingPath), SecuritySettingsContractName, SecurityProposalExecuteTimeSettingPath, value, blockNumber, treeNodes, opts) } @@ -115,7 +116,7 @@ func GetSecurityProposalActionTime(rp *rocketpool.RocketPool, opts *bind.CallOpt func ProposeSecurityProposalActionTime(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", SecurityProposalActionTimeSettingPath), SecuritySettingsContractName, SecurityProposalActionTimeSettingPath, value, blockNumber, treeNodes, opts) } -func EstimateProposeSecurityProposalActionTimeGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeSecurityProposalActionTimeGas(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (gaslimit.Limits, error) { return protocol.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", SecurityProposalActionTimeSettingPath), SecuritySettingsContractName, SecurityProposalActionTimeSettingPath, value, blockNumber, treeNodes, opts) } diff --git a/bindings/settings/security/auction.go b/bindings/settings/security/auction.go index d69ea6e87..d1a4d6f6d 100644 --- a/bindings/settings/security/auction.go +++ b/bindings/settings/security/auction.go @@ -9,6 +9,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/dao/security" "github.com/rocket-pool/smartnode/bindings/rocketpool" psettings "github.com/rocket-pool/smartnode/bindings/settings/protocol" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" ) const ( @@ -19,7 +20,7 @@ const ( func ProposeCreateLotEnabled(rp *rocketpool.RocketPool, value bool, opts *bind.TransactOpts) (uint64, common.Hash, error) { return security.ProposeSetBool(rp, fmt.Sprintf("set %s", psettings.CreateLotEnabledSettingPath), auctionNamespace, psettings.CreateLotEnabledSettingPath, value, opts) } -func EstimateProposeCreateLotEnabledGas(rp *rocketpool.RocketPool, value bool, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeCreateLotEnabledGas(rp *rocketpool.RocketPool, value bool, opts *bind.TransactOpts) (gaslimit.Limits, error) { return security.EstimateProposeSetBoolGas(rp, fmt.Sprintf("set %s", psettings.CreateLotEnabledSettingPath), auctionNamespace, psettings.CreateLotEnabledSettingPath, value, opts) } @@ -27,6 +28,6 @@ func EstimateProposeCreateLotEnabledGas(rp *rocketpool.RocketPool, value bool, o func ProposeBidOnLotEnabled(rp *rocketpool.RocketPool, value bool, opts *bind.TransactOpts) (uint64, common.Hash, error) { return security.ProposeSetBool(rp, fmt.Sprintf("set %s", psettings.BidOnLotEnabledSettingPath), auctionNamespace, psettings.BidOnLotEnabledSettingPath, value, opts) } -func EstimateProposeBidOnLotEnabledGas(rp *rocketpool.RocketPool, value bool, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeBidOnLotEnabledGas(rp *rocketpool.RocketPool, value bool, opts *bind.TransactOpts) (gaslimit.Limits, error) { return security.EstimateProposeSetBoolGas(rp, fmt.Sprintf("set %s", psettings.BidOnLotEnabledSettingPath), auctionNamespace, psettings.BidOnLotEnabledSettingPath, value, opts) } diff --git a/bindings/settings/security/deposit.go b/bindings/settings/security/deposit.go index e5aabfb3d..826029fcd 100644 --- a/bindings/settings/security/deposit.go +++ b/bindings/settings/security/deposit.go @@ -9,6 +9,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/dao/security" "github.com/rocket-pool/smartnode/bindings/rocketpool" psettings "github.com/rocket-pool/smartnode/bindings/settings/protocol" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" ) const ( @@ -19,7 +20,7 @@ const ( func ProposeDepositEnabled(rp *rocketpool.RocketPool, value bool, opts *bind.TransactOpts) (uint64, common.Hash, error) { return security.ProposeSetBool(rp, fmt.Sprintf("set %s", psettings.DepositEnabledSettingPath), depositNamespace, psettings.DepositEnabledSettingPath, value, opts) } -func EstimateProposeDepositEnabledGas(rp *rocketpool.RocketPool, value bool, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeDepositEnabledGas(rp *rocketpool.RocketPool, value bool, opts *bind.TransactOpts) (gaslimit.Limits, error) { return security.EstimateProposeSetBoolGas(rp, fmt.Sprintf("set %s", psettings.DepositEnabledSettingPath), depositNamespace, psettings.DepositEnabledSettingPath, value, opts) } @@ -27,6 +28,6 @@ func EstimateProposeDepositEnabledGas(rp *rocketpool.RocketPool, value bool, opt func ProposeAssignDepositsEnabled(rp *rocketpool.RocketPool, value bool, opts *bind.TransactOpts) (uint64, common.Hash, error) { return security.ProposeSetBool(rp, fmt.Sprintf("set %s", psettings.AssignDepositsEnabledSettingPath), depositNamespace, psettings.AssignDepositsEnabledSettingPath, value, opts) } -func EstimateProposeAssignDepositsEnabledGas(rp *rocketpool.RocketPool, value bool, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeAssignDepositsEnabledGas(rp *rocketpool.RocketPool, value bool, opts *bind.TransactOpts) (gaslimit.Limits, error) { return security.EstimateProposeSetBoolGas(rp, fmt.Sprintf("set %s", psettings.AssignDepositsEnabledSettingPath), depositNamespace, psettings.AssignDepositsEnabledSettingPath, value, opts) } diff --git a/bindings/settings/security/minipool.go b/bindings/settings/security/minipool.go index b2e857da3..c79e54af2 100644 --- a/bindings/settings/security/minipool.go +++ b/bindings/settings/security/minipool.go @@ -9,6 +9,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/dao/security" "github.com/rocket-pool/smartnode/bindings/rocketpool" psettings "github.com/rocket-pool/smartnode/bindings/settings/protocol" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" ) const ( @@ -19,7 +20,7 @@ const ( func ProposeMinipoolSubmitWithdrawableEnabled(rp *rocketpool.RocketPool, value bool, opts *bind.TransactOpts) (uint64, common.Hash, error) { return security.ProposeSetBool(rp, fmt.Sprintf("set %s", psettings.MinipoolSubmitWithdrawableEnabledSettingPath), minipoolNamespace, psettings.MinipoolSubmitWithdrawableEnabledSettingPath, value, opts) } -func EstimateProposeMinipoolSubmitWithdrawableEnabledGas(rp *rocketpool.RocketPool, value bool, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeMinipoolSubmitWithdrawableEnabledGas(rp *rocketpool.RocketPool, value bool, opts *bind.TransactOpts) (gaslimit.Limits, error) { return security.EstimateProposeSetBoolGas(rp, fmt.Sprintf("set %s", psettings.MinipoolSubmitWithdrawableEnabledSettingPath), minipoolNamespace, psettings.MinipoolSubmitWithdrawableEnabledSettingPath, value, opts) } @@ -27,6 +28,6 @@ func EstimateProposeMinipoolSubmitWithdrawableEnabledGas(rp *rocketpool.RocketPo func ProposeBondReductionEnabled(rp *rocketpool.RocketPool, value bool, opts *bind.TransactOpts) (uint64, common.Hash, error) { return security.ProposeSetBool(rp, fmt.Sprintf("set %s", psettings.BondReductionEnabledSettingPath), minipoolNamespace, psettings.BondReductionEnabledSettingPath, value, opts) } -func EstimateProposeBondReductionEnabledGas(rp *rocketpool.RocketPool, value bool, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeBondReductionEnabledGas(rp *rocketpool.RocketPool, value bool, opts *bind.TransactOpts) (gaslimit.Limits, error) { return security.EstimateProposeSetBoolGas(rp, fmt.Sprintf("set %s", psettings.BondReductionEnabledSettingPath), minipoolNamespace, psettings.BondReductionEnabledSettingPath, value, opts) } diff --git a/bindings/settings/security/network.go b/bindings/settings/security/network.go index b18a5899b..121cd9285 100644 --- a/bindings/settings/security/network.go +++ b/bindings/settings/security/network.go @@ -10,6 +10,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/dao/security" "github.com/rocket-pool/smartnode/bindings/rocketpool" psettings "github.com/rocket-pool/smartnode/bindings/settings/protocol" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" ) const ( @@ -20,7 +21,7 @@ const ( func ProposeSubmitBalancesEnabled(rp *rocketpool.RocketPool, value bool, opts *bind.TransactOpts) (uint64, common.Hash, error) { return security.ProposeSetBool(rp, fmt.Sprintf("set %s", psettings.SubmitBalancesEnabledSettingPath), networkNamespace, psettings.SubmitBalancesEnabledSettingPath, value, opts) } -func EstimateProposeSubmitBalancesEnabledGas(rp *rocketpool.RocketPool, value bool, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeSubmitBalancesEnabledGas(rp *rocketpool.RocketPool, value bool, opts *bind.TransactOpts) (gaslimit.Limits, error) { return security.EstimateProposeSetBoolGas(rp, fmt.Sprintf("set %s", psettings.SubmitBalancesEnabledSettingPath), networkNamespace, psettings.SubmitBalancesEnabledSettingPath, value, opts) } @@ -28,13 +29,13 @@ func EstimateProposeSubmitBalancesEnabledGas(rp *rocketpool.RocketPool, value bo func ProposeSubmitRewardsEnabled(rp *rocketpool.RocketPool, value bool, opts *bind.TransactOpts) (uint64, common.Hash, error) { return security.ProposeSetBool(rp, fmt.Sprintf("set %s", psettings.SubmitRewardsEnabledSettingPath), networkNamespace, psettings.SubmitRewardsEnabledSettingPath, value, opts) } -func EstimateProposeSubmitRewardsEnabledGas(rp *rocketpool.RocketPool, value bool, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeSubmitRewardsEnabledGas(rp *rocketpool.RocketPool, value bool, opts *bind.TransactOpts) (gaslimit.Limits, error) { return security.EstimateProposeSetBoolGas(rp, fmt.Sprintf("set %s", psettings.SubmitRewardsEnabledSettingPath), networkNamespace, psettings.SubmitRewardsEnabledSettingPath, value, opts) } func ProposeNodeComissionShareSecurityCouncilAdder(rp *rocketpool.RocketPool, value *big.Int, opts *bind.TransactOpts) (uint64, common.Hash, error) { return security.ProposeSetUint(rp, fmt.Sprintf("set %s", psettings.NetworkNodeCommissionShareSecurityCouncilAdderPath), networkNamespace, psettings.NetworkNodeCommissionShareSecurityCouncilAdderPath, value, opts) } -func EstimateProposeNodeComissionShareSecurityCouncilAdder(rp *rocketpool.RocketPool, value *big.Int, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeNodeComissionShareSecurityCouncilAdder(rp *rocketpool.RocketPool, value *big.Int, opts *bind.TransactOpts) (gaslimit.Limits, error) { return security.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", psettings.NetworkNodeCommissionShareSecurityCouncilAdderPath), networkNamespace, psettings.NetworkNodeCommissionShareSecurityCouncilAdderPath, value, opts) } diff --git a/bindings/settings/security/node.go b/bindings/settings/security/node.go index c9e57afaf..947911c81 100644 --- a/bindings/settings/security/node.go +++ b/bindings/settings/security/node.go @@ -9,6 +9,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/dao/security" "github.com/rocket-pool/smartnode/bindings/rocketpool" psettings "github.com/rocket-pool/smartnode/bindings/settings/protocol" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" ) const ( @@ -19,7 +20,7 @@ const ( func ProposeNodeRegistrationEnabled(rp *rocketpool.RocketPool, value bool, opts *bind.TransactOpts) (uint64, common.Hash, error) { return security.ProposeSetBool(rp, fmt.Sprintf("set %s", psettings.NodeRegistrationEnabledSettingPath), nodeNamespace, psettings.NodeRegistrationEnabledSettingPath, value, opts) } -func EstimateProposeNodeRegistrationEnabledGas(rp *rocketpool.RocketPool, value bool, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeNodeRegistrationEnabledGas(rp *rocketpool.RocketPool, value bool, opts *bind.TransactOpts) (gaslimit.Limits, error) { return security.EstimateProposeSetBoolGas(rp, fmt.Sprintf("set %s", psettings.NodeRegistrationEnabledSettingPath), nodeNamespace, psettings.NodeRegistrationEnabledSettingPath, value, opts) } @@ -27,7 +28,7 @@ func EstimateProposeNodeRegistrationEnabledGas(rp *rocketpool.RocketPool, value func ProposeSmoothingPoolRegistrationEnabled(rp *rocketpool.RocketPool, value bool, opts *bind.TransactOpts) (uint64, common.Hash, error) { return security.ProposeSetBool(rp, fmt.Sprintf("set %s", psettings.SmoothingPoolRegistrationEnabledSettingPath), nodeNamespace, psettings.SmoothingPoolRegistrationEnabledSettingPath, value, opts) } -func EstimateProposeSmoothingPoolRegistrationEnabledGas(rp *rocketpool.RocketPool, value bool, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeSmoothingPoolRegistrationEnabledGas(rp *rocketpool.RocketPool, value bool, opts *bind.TransactOpts) (gaslimit.Limits, error) { return security.EstimateProposeSetBoolGas(rp, fmt.Sprintf("set %s", psettings.SmoothingPoolRegistrationEnabledSettingPath), nodeNamespace, psettings.SmoothingPoolRegistrationEnabledSettingPath, value, opts) } @@ -35,7 +36,7 @@ func EstimateProposeSmoothingPoolRegistrationEnabledGas(rp *rocketpool.RocketPoo func ProposeNodeDepositEnabled(rp *rocketpool.RocketPool, value bool, opts *bind.TransactOpts) (uint64, common.Hash, error) { return security.ProposeSetBool(rp, fmt.Sprintf("set %s", psettings.NodeDepositEnabledSettingPath), nodeNamespace, psettings.NodeDepositEnabledSettingPath, value, opts) } -func EstimateProposeNodeDepositEnabledGas(rp *rocketpool.RocketPool, value bool, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeNodeDepositEnabledGas(rp *rocketpool.RocketPool, value bool, opts *bind.TransactOpts) (gaslimit.Limits, error) { return security.EstimateProposeSetBoolGas(rp, fmt.Sprintf("set %s", psettings.NodeDepositEnabledSettingPath), nodeNamespace, psettings.NodeDepositEnabledSettingPath, value, opts) } @@ -43,6 +44,6 @@ func EstimateProposeNodeDepositEnabledGas(rp *rocketpool.RocketPool, value bool, func ProposeVacantMinipoolsEnabled(rp *rocketpool.RocketPool, value bool, opts *bind.TransactOpts) (uint64, common.Hash, error) { return security.ProposeSetBool(rp, fmt.Sprintf("set %s", psettings.VacantMinipoolsEnabledSettingPath), nodeNamespace, psettings.VacantMinipoolsEnabledSettingPath, value, opts) } -func EstimateProposeVacantMinipoolsEnabledGas(rp *rocketpool.RocketPool, value bool, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeVacantMinipoolsEnabledGas(rp *rocketpool.RocketPool, value bool, opts *bind.TransactOpts) (gaslimit.Limits, error) { return security.EstimateProposeSetBoolGas(rp, fmt.Sprintf("set %s", psettings.VacantMinipoolsEnabledSettingPath), nodeNamespace, psettings.VacantMinipoolsEnabledSettingPath, value, opts) } diff --git a/bindings/settings/trustednode/members.go b/bindings/settings/trustednode/members.go index 5d703b65d..3f71a2977 100644 --- a/bindings/settings/trustednode/members.go +++ b/bindings/settings/trustednode/members.go @@ -10,6 +10,7 @@ import ( trustednodedao "github.com/rocket-pool/smartnode/bindings/dao/trustednode" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/utils/eth" ) @@ -40,7 +41,7 @@ func GetQuorum(rp *rocketpool.RocketPool, opts *bind.CallOpts) (float64, error) func ProposeQuorum(rp *rocketpool.RocketPool, value float64, opts *bind.TransactOpts) (uint64, common.Hash, error) { return trustednodedao.ProposeSetUint(rp, fmt.Sprintf("set %s", QuorumSettingPath), MembersSettingsContractName, QuorumSettingPath, eth.EthToWei(value), opts) } -func EstimateProposeQuorumGas(rp *rocketpool.RocketPool, value float64, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeQuorumGas(rp *rocketpool.RocketPool, value float64, opts *bind.TransactOpts) (gaslimit.Limits, error) { return trustednodedao.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", QuorumSettingPath), MembersSettingsContractName, QuorumSettingPath, eth.EthToWei(value), opts) } @@ -59,7 +60,7 @@ func GetRPLBond(rp *rocketpool.RocketPool, opts *bind.CallOpts) (*big.Int, error func ProposeRPLBond(rp *rocketpool.RocketPool, value *big.Int, opts *bind.TransactOpts) (uint64, common.Hash, error) { return trustednodedao.ProposeSetUint(rp, fmt.Sprintf("set %s", RPLBondSettingPath), MembersSettingsContractName, RPLBondSettingPath, value, opts) } -func EstimateProposeRPLBondGas(rp *rocketpool.RocketPool, value *big.Int, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeRPLBondGas(rp *rocketpool.RocketPool, value *big.Int, opts *bind.TransactOpts) (gaslimit.Limits, error) { return trustednodedao.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", RPLBondSettingPath), MembersSettingsContractName, RPLBondSettingPath, value, opts) } @@ -78,7 +79,7 @@ func GetMinipoolUnbondedMax(rp *rocketpool.RocketPool, opts *bind.CallOpts) (uin func ProposeMinipoolUnbondedMax(rp *rocketpool.RocketPool, value uint64, opts *bind.TransactOpts) (uint64, common.Hash, error) { return trustednodedao.ProposeSetUint(rp, fmt.Sprintf("set %s", MinipoolUnbondedMaxSettingPath), MembersSettingsContractName, MinipoolUnbondedMaxSettingPath, big.NewInt(int64(value)), opts) } -func EstimateProposeMinipoolUnbondedMaxGas(rp *rocketpool.RocketPool, value uint64, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeMinipoolUnbondedMaxGas(rp *rocketpool.RocketPool, value uint64, opts *bind.TransactOpts) (gaslimit.Limits, error) { return trustednodedao.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", MinipoolUnbondedMaxSettingPath), MembersSettingsContractName, MinipoolUnbondedMaxSettingPath, big.NewInt(int64(value)), opts) } @@ -97,7 +98,7 @@ func GetMinipoolUnbondedMinFee(rp *rocketpool.RocketPool, opts *bind.CallOpts) ( func ProposeMinipoolUnbondedMinFee(rp *rocketpool.RocketPool, value uint64, opts *bind.TransactOpts) (uint64, common.Hash, error) { return trustednodedao.ProposeSetUint(rp, fmt.Sprintf("set %s", MinipoolUnbondedMinFeeSettingPath), MembersSettingsContractName, MinipoolUnbondedMinFeeSettingPath, big.NewInt(int64(value)), opts) } -func EstimateProposeMinipoolUnbondedMinFeeGas(rp *rocketpool.RocketPool, value uint64, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeMinipoolUnbondedMinFeeGas(rp *rocketpool.RocketPool, value uint64, opts *bind.TransactOpts) (gaslimit.Limits, error) { return trustednodedao.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", MinipoolUnbondedMinFeeSettingPath), MembersSettingsContractName, MinipoolUnbondedMinFeeSettingPath, big.NewInt(int64(value)), opts) } @@ -116,7 +117,7 @@ func GetChallengeCooldown(rp *rocketpool.RocketPool, opts *bind.CallOpts) (uint6 func ProposeChallengeCooldown(rp *rocketpool.RocketPool, value uint64, opts *bind.TransactOpts) (uint64, common.Hash, error) { return trustednodedao.ProposeSetUint(rp, fmt.Sprintf("set %s", ChallengeCooldownSettingPath), MembersSettingsContractName, ChallengeCooldownSettingPath, big.NewInt(int64(value)), opts) } -func EstimateProposeChallengeCooldownGas(rp *rocketpool.RocketPool, value uint64, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeChallengeCooldownGas(rp *rocketpool.RocketPool, value uint64, opts *bind.TransactOpts) (gaslimit.Limits, error) { return trustednodedao.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", ChallengeCooldownSettingPath), MembersSettingsContractName, ChallengeCooldownSettingPath, big.NewInt(int64(value)), opts) } @@ -135,7 +136,7 @@ func GetChallengeWindow(rp *rocketpool.RocketPool, opts *bind.CallOpts) (uint64, func ProposeChallengeWindow(rp *rocketpool.RocketPool, value uint64, opts *bind.TransactOpts) (uint64, common.Hash, error) { return trustednodedao.ProposeSetUint(rp, fmt.Sprintf("set %s", ChallengeWindowSettingPath), MembersSettingsContractName, ChallengeWindowSettingPath, big.NewInt(int64(value)), opts) } -func EstimateProposeChallengeWindowGas(rp *rocketpool.RocketPool, value uint64, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeChallengeWindowGas(rp *rocketpool.RocketPool, value uint64, opts *bind.TransactOpts) (gaslimit.Limits, error) { return trustednodedao.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", ChallengeWindowSettingPath), MembersSettingsContractName, ChallengeWindowSettingPath, big.NewInt(int64(value)), opts) } @@ -154,7 +155,7 @@ func GetChallengeCost(rp *rocketpool.RocketPool, opts *bind.CallOpts) (*big.Int, func ProposeChallengeCost(rp *rocketpool.RocketPool, value *big.Int, opts *bind.TransactOpts) (uint64, common.Hash, error) { return trustednodedao.ProposeSetUint(rp, fmt.Sprintf("set %s", ChallengeCostSettingPath), MembersSettingsContractName, ChallengeCostSettingPath, value, opts) } -func EstimateProposeChallengeCostGas(rp *rocketpool.RocketPool, value *big.Int, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeChallengeCostGas(rp *rocketpool.RocketPool, value *big.Int, opts *bind.TransactOpts) (gaslimit.Limits, error) { return trustednodedao.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", ChallengeCostSettingPath), MembersSettingsContractName, ChallengeCostSettingPath, value, opts) } diff --git a/bindings/settings/trustednode/minipool.go b/bindings/settings/trustednode/minipool.go index 385f90a36..d6cb511f8 100644 --- a/bindings/settings/trustednode/minipool.go +++ b/bindings/settings/trustednode/minipool.go @@ -10,6 +10,7 @@ import ( trustednodedao "github.com/rocket-pool/smartnode/bindings/dao/trustednode" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" ) // Config @@ -38,7 +39,7 @@ func GetScrubPeriod(rp *rocketpool.RocketPool, opts *bind.CallOpts) (uint64, err func ProposeScrubPeriod(rp *rocketpool.RocketPool, value uint64, opts *bind.TransactOpts) (uint64, common.Hash, error) { return trustednodedao.ProposeSetUint(rp, fmt.Sprintf("set %s", ScrubPeriodPath), MinipoolSettingsContractName, ScrubPeriodPath, big.NewInt(int64(value)), opts) } -func EstimateProposeScrubPeriodGas(rp *rocketpool.RocketPool, value uint64, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeScrubPeriodGas(rp *rocketpool.RocketPool, value uint64, opts *bind.TransactOpts) (gaslimit.Limits, error) { return trustednodedao.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", ScrubPeriodPath), MinipoolSettingsContractName, ScrubPeriodPath, big.NewInt(int64(value)), opts) } @@ -57,7 +58,7 @@ func GetPromotionScrubPeriod(rp *rocketpool.RocketPool, opts *bind.CallOpts) (ui func ProposePromotionScrubPeriod(rp *rocketpool.RocketPool, value uint64, opts *bind.TransactOpts) (uint64, common.Hash, error) { return trustednodedao.ProposeSetUint(rp, fmt.Sprintf("set %s", PromotionScrubPeriodPath), MinipoolSettingsContractName, PromotionScrubPeriodPath, big.NewInt(int64(value)), opts) } -func EstimateProposePromotionScrubPeriodGas(rp *rocketpool.RocketPool, value uint64, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposePromotionScrubPeriodGas(rp *rocketpool.RocketPool, value uint64, opts *bind.TransactOpts) (gaslimit.Limits, error) { return trustednodedao.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", PromotionScrubPeriodPath), MinipoolSettingsContractName, PromotionScrubPeriodPath, big.NewInt(int64(value)), opts) } @@ -76,7 +77,7 @@ func GetScrubPenaltyEnabled(rp *rocketpool.RocketPool, opts *bind.CallOpts) (boo func ProposeScrubPenaltyEnabled(rp *rocketpool.RocketPool, value bool, opts *bind.TransactOpts) (uint64, common.Hash, error) { return trustednodedao.ProposeSetBool(rp, fmt.Sprintf("set %s", ScrubPenaltyEnabledPath), MinipoolSettingsContractName, ScrubPenaltyEnabledPath, value, opts) } -func EstimateProposeScrubPenaltyEnabledGas(rp *rocketpool.RocketPool, value bool, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeScrubPenaltyEnabledGas(rp *rocketpool.RocketPool, value bool, opts *bind.TransactOpts) (gaslimit.Limits, error) { return trustednodedao.EstimateProposeSetBoolGas(rp, fmt.Sprintf("set %s", ScrubPenaltyEnabledPath), MinipoolSettingsContractName, ScrubPenaltyEnabledPath, value, opts) } @@ -95,7 +96,7 @@ func GetBondReductionWindowStart(rp *rocketpool.RocketPool, opts *bind.CallOpts) func ProposeBondReductionWindowStart(rp *rocketpool.RocketPool, value uint64, opts *bind.TransactOpts) (uint64, common.Hash, error) { return trustednodedao.ProposeSetUint(rp, fmt.Sprintf("set %s", BondReductionWindowStartPath), MinipoolSettingsContractName, BondReductionWindowStartPath, big.NewInt(int64(value)), opts) } -func EstimateProposeBondReductionWindowStartGas(rp *rocketpool.RocketPool, value uint64, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeBondReductionWindowStartGas(rp *rocketpool.RocketPool, value uint64, opts *bind.TransactOpts) (gaslimit.Limits, error) { return trustednodedao.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", BondReductionWindowStartPath), MinipoolSettingsContractName, BondReductionWindowStartPath, big.NewInt(int64(value)), opts) } @@ -114,7 +115,7 @@ func GetBondReductionWindowLength(rp *rocketpool.RocketPool, opts *bind.CallOpts func ProposeBondReductionWindowLength(rp *rocketpool.RocketPool, value uint64, opts *bind.TransactOpts) (uint64, common.Hash, error) { return trustednodedao.ProposeSetUint(rp, fmt.Sprintf("set %s", BondReductionWindowLengthPath), MinipoolSettingsContractName, BondReductionWindowLengthPath, big.NewInt(int64(value)), opts) } -func EstimateProposeBondReductionWindowLengthGas(rp *rocketpool.RocketPool, value uint64, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeBondReductionWindowLengthGas(rp *rocketpool.RocketPool, value uint64, opts *bind.TransactOpts) (gaslimit.Limits, error) { return trustednodedao.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", BondReductionWindowLengthPath), MinipoolSettingsContractName, BondReductionWindowLengthPath, big.NewInt(int64(value)), opts) } @@ -133,7 +134,7 @@ func GetDissolvePeriod(rp *rocketpool.RocketPool, opts *bind.CallOpts) (uint64, func ProposeDissolvePeriod(rp *rocketpool.RocketPool, value uint64, opts *bind.TransactOpts) (uint64, common.Hash, error) { return trustednodedao.ProposeSetUint(rp, fmt.Sprintf("set %s", DissolvePeriodPath), MinipoolSettingsContractName, DissolvePeriodPath, big.NewInt(int64(value)), opts) } -func EstimateProposeDissolvePeriodGas(rp *rocketpool.RocketPool, value uint64, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeDissolvePeriodGas(rp *rocketpool.RocketPool, value uint64, opts *bind.TransactOpts) (gaslimit.Limits, error) { return trustednodedao.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", DissolvePeriodPath), MinipoolSettingsContractName, DissolvePeriodPath, big.NewInt(int64(value)), opts) } diff --git a/bindings/settings/trustednode/proposals.go b/bindings/settings/trustednode/proposals.go index 3a23f416d..1437f70ac 100644 --- a/bindings/settings/trustednode/proposals.go +++ b/bindings/settings/trustednode/proposals.go @@ -10,6 +10,7 @@ import ( trustednodedao "github.com/rocket-pool/smartnode/bindings/dao/trustednode" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" ) // Config @@ -37,7 +38,7 @@ func GetProposalCooldownTime(rp *rocketpool.RocketPool, opts *bind.CallOpts) (ui func ProposeProposalCooldownTime(rp *rocketpool.RocketPool, value uint64, opts *bind.TransactOpts) (uint64, common.Hash, error) { return trustednodedao.ProposeSetUint(rp, fmt.Sprintf("set %s", CooldownTimeSettingPath), ProposalsSettingsContractName, CooldownTimeSettingPath, big.NewInt(int64(value)), opts) } -func EstimateProposeProposalCooldownTimeGas(rp *rocketpool.RocketPool, value uint64, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeProposalCooldownTimeGas(rp *rocketpool.RocketPool, value uint64, opts *bind.TransactOpts) (gaslimit.Limits, error) { return trustednodedao.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", CooldownTimeSettingPath), ProposalsSettingsContractName, CooldownTimeSettingPath, big.NewInt(int64(value)), opts) } @@ -56,7 +57,7 @@ func GetProposalVoteTime(rp *rocketpool.RocketPool, opts *bind.CallOpts) (uint64 func ProposeProposalVoteTime(rp *rocketpool.RocketPool, value uint64, opts *bind.TransactOpts) (uint64, common.Hash, error) { return trustednodedao.ProposeSetUint(rp, fmt.Sprintf("set %s", VoteTimeSettingPath), ProposalsSettingsContractName, VoteTimeSettingPath, big.NewInt(int64(value)), opts) } -func EstimateProposeProposalVoteTimeGas(rp *rocketpool.RocketPool, value uint64, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeProposalVoteTimeGas(rp *rocketpool.RocketPool, value uint64, opts *bind.TransactOpts) (gaslimit.Limits, error) { return trustednodedao.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", VoteTimeSettingPath), ProposalsSettingsContractName, VoteTimeSettingPath, big.NewInt(int64(value)), opts) } @@ -75,7 +76,7 @@ func GetProposalVoteDelayTime(rp *rocketpool.RocketPool, opts *bind.CallOpts) (u func ProposeProposalVoteDelayTime(rp *rocketpool.RocketPool, value uint64, opts *bind.TransactOpts) (uint64, common.Hash, error) { return trustednodedao.ProposeSetUint(rp, fmt.Sprintf("set %s", VoteDelayTimeSettingPath), ProposalsSettingsContractName, VoteDelayTimeSettingPath, big.NewInt(int64(value)), opts) } -func EstimateProposeProposalVoteDelayTimeGas(rp *rocketpool.RocketPool, value uint64, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeProposalVoteDelayTimeGas(rp *rocketpool.RocketPool, value uint64, opts *bind.TransactOpts) (gaslimit.Limits, error) { return trustednodedao.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", VoteDelayTimeSettingPath), ProposalsSettingsContractName, VoteDelayTimeSettingPath, big.NewInt(int64(value)), opts) } @@ -94,7 +95,7 @@ func GetProposalExecuteTime(rp *rocketpool.RocketPool, opts *bind.CallOpts) (uin func ProposeProposalExecuteTime(rp *rocketpool.RocketPool, value uint64, opts *bind.TransactOpts) (uint64, common.Hash, error) { return trustednodedao.ProposeSetUint(rp, fmt.Sprintf("set %s", ExecuteTimeSettingPath), ProposalsSettingsContractName, ExecuteTimeSettingPath, big.NewInt(int64(value)), opts) } -func EstimateProposeProposalExecuteTimeGas(rp *rocketpool.RocketPool, value uint64, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeProposalExecuteTimeGas(rp *rocketpool.RocketPool, value uint64, opts *bind.TransactOpts) (gaslimit.Limits, error) { return trustednodedao.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", ExecuteTimeSettingPath), ProposalsSettingsContractName, ExecuteTimeSettingPath, big.NewInt(int64(value)), opts) } @@ -113,7 +114,7 @@ func GetProposalActionTime(rp *rocketpool.RocketPool, opts *bind.CallOpts) (uint func ProposeProposalActionTime(rp *rocketpool.RocketPool, value uint64, opts *bind.TransactOpts) (uint64, common.Hash, error) { return trustednodedao.ProposeSetUint(rp, fmt.Sprintf("set %s", ActionTimeSettingPath), ProposalsSettingsContractName, ActionTimeSettingPath, big.NewInt(int64(value)), opts) } -func EstimateProposeProposalActionTimeGas(rp *rocketpool.RocketPool, value uint64, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateProposeProposalActionTimeGas(rp *rocketpool.RocketPool, value uint64, opts *bind.TransactOpts) (gaslimit.Limits, error) { return trustednodedao.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", ActionTimeSettingPath), ProposalsSettingsContractName, ActionTimeSettingPath, big.NewInt(int64(value)), opts) } diff --git a/bindings/storage/rocket-storage.go b/bindings/storage/rocket-storage.go index 56270a533..3d5992124 100644 --- a/bindings/storage/rocket-storage.go +++ b/bindings/storage/rocket-storage.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" ) // Get a node's withdrawal address @@ -30,7 +31,7 @@ func GetNodePendingWithdrawalAddress(rp *rocketpool.RocketPool, nodeAddress comm } // Estimate the gas of SetWithdrawalAddress -func EstimateSetWithdrawalAddressGas(rp *rocketpool.RocketPool, nodeAddress common.Address, withdrawalAddress common.Address, confirm bool, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateSetWithdrawalAddressGas(rp *rocketpool.RocketPool, nodeAddress common.Address, withdrawalAddress common.Address, confirm bool, opts *bind.TransactOpts) (gaslimit.Limits, error) { return rp.RocketStorageContract.GetTransactionGasInfo(opts, "setWithdrawalAddress", nodeAddress, withdrawalAddress, confirm) } @@ -44,7 +45,7 @@ func SetWithdrawalAddress(rp *rocketpool.RocketPool, nodeAddress common.Address, } // Estimate the gas of ConfirmWithdrawalAddress -func EstimateConfirmWithdrawalAddressGas(rp *rocketpool.RocketPool, nodeAddress common.Address, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateConfirmWithdrawalAddressGas(rp *rocketpool.RocketPool, nodeAddress common.Address, opts *bind.TransactOpts) (gaslimit.Limits, error) { return rp.RocketStorageContract.GetTransactionGasInfo(opts, "confirmWithdrawalAddress", nodeAddress) } diff --git a/bindings/tokens/reth.go b/bindings/tokens/reth.go index eeafad031..cd6acbd70 100644 --- a/bindings/tokens/reth.go +++ b/bindings/tokens/reth.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/utils/eth" ) @@ -44,10 +45,10 @@ func GetRETHAllowance(rp *rocketpool.RocketPool, owner, spender common.Address, } // Estimate the gas of TransferRETH -func EstimateTransferRETHGas(rp *rocketpool.RocketPool, to common.Address, amount *big.Int, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateTransferRETHGas(rp *rocketpool.RocketPool, to common.Address, amount *big.Int, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketTokenRETH, err := getRocketTokenRETH(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return estimateTransferGas(rocketTokenRETH, "rETH", to, amount, opts) } @@ -62,10 +63,10 @@ func TransferRETH(rp *rocketpool.RocketPool, to common.Address, amount *big.Int, } // Estimate the gas of ApproveRETH -func EstimateApproveRETHGas(rp *rocketpool.RocketPool, spender common.Address, amount *big.Int, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateApproveRETHGas(rp *rocketpool.RocketPool, spender common.Address, amount *big.Int, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketTokenRETH, err := getRocketTokenRETH(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return estimateApproveGas(rocketTokenRETH, "rETH", spender, amount, opts) } @@ -80,10 +81,10 @@ func ApproveRETH(rp *rocketpool.RocketPool, spender common.Address, amount *big. } // Estimate the gas of TransferFromRETH -func EstimateTransferFromRETHGas(rp *rocketpool.RocketPool, from, to common.Address, amount *big.Int, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateTransferFromRETHGas(rp *rocketpool.RocketPool, from, to common.Address, amount *big.Int, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketTokenRETH, err := getRocketTokenRETH(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return estimateTransferFromGas(rocketTokenRETH, "rETH", from, to, amount, opts) } @@ -176,10 +177,10 @@ func GetRETHCollateralRate(rp *rocketpool.RocketPool, opts *bind.CallOpts) (floa } // Estimate the gas of BurnRETH -func EstimateBurnRETHGas(rp *rocketpool.RocketPool, amount *big.Int, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateBurnRETHGas(rp *rocketpool.RocketPool, amount *big.Int, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketTokenRETH, err := getRocketTokenRETH(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketTokenRETH.GetTransactionGasInfo(opts, "burn", amount) } diff --git a/bindings/tokens/rpl-fixed.go b/bindings/tokens/rpl-fixed.go index b77895467..f6ef02398 100644 --- a/bindings/tokens/rpl-fixed.go +++ b/bindings/tokens/rpl-fixed.go @@ -8,6 +8,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" ) // @@ -42,10 +43,10 @@ func GetFixedSupplyRPLAllowance(rp *rocketpool.RocketPool, owner, spender common } // Estimate the gas of TransferFixedSupplyRPL -func EstimateTransferFixedSupplyRPLGas(rp *rocketpool.RocketPool, to common.Address, amount *big.Int, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateTransferFixedSupplyRPLGas(rp *rocketpool.RocketPool, to common.Address, amount *big.Int, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketTokenFixedSupplyRPL, err := getRocketTokenRPLFixedSupply(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return estimateTransferGas(rocketTokenFixedSupplyRPL, "fixed-supply RPL", to, amount, opts) } @@ -60,10 +61,10 @@ func TransferFixedSupplyRPL(rp *rocketpool.RocketPool, to common.Address, amount } // Estimate the gas of ApproveFixedSupplyRPL -func EstimateApproveFixedSupplyRPLGas(rp *rocketpool.RocketPool, spender common.Address, amount *big.Int, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateApproveFixedSupplyRPLGas(rp *rocketpool.RocketPool, spender common.Address, amount *big.Int, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketTokenFixedSupplyRPL, err := getRocketTokenRPLFixedSupply(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return estimateApproveGas(rocketTokenFixedSupplyRPL, "fixed-supply RPL", spender, amount, opts) } @@ -78,10 +79,10 @@ func ApproveFixedSupplyRPL(rp *rocketpool.RocketPool, spender common.Address, am } // Estimate the gas of TransferFromFixedSupplyRPL -func EstimateTransferFromFixedSupplyRPLGas(rp *rocketpool.RocketPool, from, to common.Address, amount *big.Int, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateTransferFromFixedSupplyRPLGas(rp *rocketpool.RocketPool, from, to common.Address, amount *big.Int, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketTokenFixedSupplyRPL, err := getRocketTokenRPLFixedSupply(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return estimateTransferFromGas(rocketTokenFixedSupplyRPL, "fixed-supply RPL", from, to, amount, opts) } diff --git a/bindings/tokens/rpl.go b/bindings/tokens/rpl.go index 7d24e46fd..f714ef185 100644 --- a/bindings/tokens/rpl.go +++ b/bindings/tokens/rpl.go @@ -10,6 +10,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" ) // @@ -44,10 +45,10 @@ func GetRPLAllowance(rp *rocketpool.RocketPool, owner, spender common.Address, o } // Estimate the gas of TransferRPL -func EstimateTransferRPLGas(rp *rocketpool.RocketPool, to common.Address, amount *big.Int, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateTransferRPLGas(rp *rocketpool.RocketPool, to common.Address, amount *big.Int, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketTokenRPL, err := getRocketTokenRPL(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return estimateTransferGas(rocketTokenRPL, "RPL", to, amount, opts) } @@ -62,10 +63,10 @@ func TransferRPL(rp *rocketpool.RocketPool, to common.Address, amount *big.Int, } // Estimate the gas of ApproveRPL -func EstimateApproveRPLGas(rp *rocketpool.RocketPool, spender common.Address, amount *big.Int, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateApproveRPLGas(rp *rocketpool.RocketPool, spender common.Address, amount *big.Int, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketTokenRPL, err := getRocketTokenRPL(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return estimateApproveGas(rocketTokenRPL, "RPL", spender, amount, opts) } @@ -80,10 +81,10 @@ func ApproveRPL(rp *rocketpool.RocketPool, spender common.Address, amount *big.I } // Estimate the gas of TransferFromRPL -func EstimateTransferFromRPLGas(rp *rocketpool.RocketPool, from, to common.Address, amount *big.Int, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateTransferFromRPLGas(rp *rocketpool.RocketPool, from, to common.Address, amount *big.Int, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketTokenRPL, err := getRocketTokenRPL(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return estimateTransferFromGas(rocketTokenRPL, "RPL", from, to, amount, opts) } @@ -102,10 +103,10 @@ func TransferFromRPL(rp *rocketpool.RocketPool, from, to common.Address, amount // // Estimate the gas of MintInflationRPL -func EstimateMintInflationRPLGas(rp *rocketpool.RocketPool, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateMintInflationRPLGas(rp *rocketpool.RocketPool, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketTokenRPL, err := getRocketTokenRPL(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketTokenRPL.GetTransactionGasInfo(opts, "inflationMintTokens") } @@ -124,10 +125,10 @@ func MintInflationRPL(rp *rocketpool.RocketPool, opts *bind.TransactOpts) (commo } // Estimate the gas of SwapFixedSupplyRPLForRPL -func EstimateSwapFixedSupplyRPLForRPLGas(rp *rocketpool.RocketPool, amount *big.Int, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateSwapFixedSupplyRPLForRPLGas(rp *rocketpool.RocketPool, amount *big.Int, opts *bind.TransactOpts) (gaslimit.Limits, error) { rocketTokenRPL, err := getRocketTokenRPL(rp, nil) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } return rocketTokenRPL.GetTransactionGasInfo(opts, "swapTokens", amount) } diff --git a/bindings/tokens/tokens.go b/bindings/tokens/tokens.go index 36bd5f4e9..9f27f460c 100644 --- a/bindings/tokens/tokens.go +++ b/bindings/tokens/tokens.go @@ -10,6 +10,7 @@ import ( "golang.org/x/sync/errgroup" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" ) // Token balances @@ -110,7 +111,7 @@ func allowance(tokenContract *rocketpool.Contract, tokenName string, owner, spen } // Estimate the gas of transfer -func estimateTransferGas(tokenContract *rocketpool.Contract, tokenName string, to common.Address, amount *big.Int, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func estimateTransferGas(tokenContract *rocketpool.Contract, tokenName string, to common.Address, amount *big.Int, opts *bind.TransactOpts) (gaslimit.Limits, error) { return tokenContract.GetTransactionGasInfo(opts, "transfer", to, amount) } @@ -124,7 +125,7 @@ func transfer(tokenContract *rocketpool.Contract, tokenName string, to common.Ad } // Estimate the gas of approve -func estimateApproveGas(tokenContract *rocketpool.Contract, tokenName string, spender common.Address, amount *big.Int, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func estimateApproveGas(tokenContract *rocketpool.Contract, tokenName string, spender common.Address, amount *big.Int, opts *bind.TransactOpts) (gaslimit.Limits, error) { return tokenContract.GetTransactionGasInfo(opts, "approve", spender, amount) } @@ -138,7 +139,7 @@ func approve(tokenContract *rocketpool.Contract, tokenName string, spender commo } // Estimate the gas of transferFrom -func estimateTransferFromGas(tokenContract *rocketpool.Contract, tokenName string, from, to common.Address, amount *big.Int, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func estimateTransferFromGas(tokenContract *rocketpool.Contract, tokenName string, from, to common.Address, amount *big.Int, opts *bind.TransactOpts) (gaslimit.Limits, error) { return tokenContract.GetTransactionGasInfo(opts, "transferFrom", from, to, amount) } diff --git a/bindings/transactions/gaslimit/gas.go b/bindings/transactions/gaslimit/gas.go new file mode 100644 index 000000000..6490b7ee9 --- /dev/null +++ b/bindings/transactions/gaslimit/gas.go @@ -0,0 +1,72 @@ +package gaslimit + +import ( + "math/big" + + "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/shared/utils/log" + "github.com/rocket-pool/smartnode/shared/utils/math" +) + +// Response for gas limits from network and from user request +type Limits struct { + Estimated uint64 `json:"estimated"` + Safe uint64 `json:"safe"` +} + +func (l Limits) IsBlank() bool { + return l == Limits{} +} + +func (l Limits) Add(other Limits) Limits { + return Limits{ + Estimated: l.Estimated + other.Estimated, + Safe: l.Safe + other.Safe, + } +} + +func (l Limits) Check(checkThreshold bool, gasThresholdGwei float64, logger *log.ColorLogger, maxFeeWei *big.Int, gasLimit uint64) bool { + if !checkThreshold { + logger.Println("This transaction does not check the gas threshold limit, continuing...") + return true + } + + gasThresholdWei := math.RoundUp(gasThresholdGwei*eth.WeiPerGwei, 0) + gasThreshold := new(big.Int).SetUint64(uint64(gasThresholdWei)) + if maxFeeWei.Cmp(gasThreshold) != -1 { + logger.Printlnf("Current network gas price is %.2f Gwei, which is not lower than the set threshold of %.2f Gwei. "+ + "Aborting the transaction.", eth.WeiToGwei(maxFeeWei), gasThresholdGwei) + return false + } + + return true +} + +func (l Limits) Print(logger *log.ColorLogger, maxFeeWei *big.Int, gasLimit uint64) { + + // Print the total TX cost + var gas *big.Int + var safeGas *big.Int + if gasLimit != 0 { + gas = new(big.Int).SetUint64(gasLimit) + safeGas = gas + } else { + gas = new(big.Int).SetUint64(l.Estimated) + safeGas = new(big.Int).SetUint64(l.Safe) + } + totalGasWei := new(big.Int).Mul(maxFeeWei, gas) + totalSafeGasWei := new(big.Int).Mul(maxFeeWei, safeGas) + logger.Printlnf("This transaction will use a max fee of %.6f Gwei, for a total of up to %.6f - %.6f ETH.", + eth.WeiToGwei(maxFeeWei), + math.RoundDown(eth.WeiToEth(totalGasWei), 6), + math.RoundDown(eth.WeiToEth(totalSafeGasWei), 6)) +} + +func (l Limits) PrintAndCheck(checkThreshold bool, gasThresholdGwei float64, logger *log.ColorLogger, maxFeeWei *big.Int, gasLimit uint64) bool { + if !l.Check(checkThreshold, gasThresholdGwei, logger, maxFeeWei, gasLimit) { + return false + } + + l.Print(logger, maxFeeWei, gasLimit) + return true +} diff --git a/bindings/utils/eth/transactions.go b/bindings/transactions/transactions.go similarity index 57% rename from bindings/utils/eth/transactions.go rename to bindings/transactions/transactions.go index f5f9f4041..ad494673c 100644 --- a/bindings/utils/eth/transactions.go +++ b/bindings/transactions/transactions.go @@ -1,8 +1,10 @@ -package eth +package transactions import ( "context" + "fmt" "math/big" + "time" "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts/abi/bind" @@ -10,13 +12,59 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/settings/protocol" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" + "github.com/rocket-pool/smartnode/bindings/utils" + "github.com/rocket-pool/smartnode/shared/services/config" + "github.com/rocket-pool/smartnode/shared/utils/log" ) +// The fraction of the timeout period to trigger overdue transactions +const TimeoutSafetyFactor int = 2 + +// Print a TX's details to the logger and waits for it to validated. +func PrintAndWaitForTransaction(cfg *config.RocketPoolConfig, hash common.Hash, ec rocketpool.ExecutionClient, logger *log.ColorLogger) error { + + txWatchUrl := cfg.Smartnode.GetTxWatchUrl() + hashString := hash.String() + + logger.Printlnf("Transaction has been submitted with hash %s.", hashString) + if txWatchUrl != "" { + logger.Printlnf("You may follow its progress by visiting:") + logger.Printlnf("%s/%s\n", txWatchUrl, hashString) + } + logger.Println("Waiting for the transaction to be validated...") + + // Wait for the TX to be included in a block + if _, err := utils.WaitForTransaction(ec, hash); err != nil { + return fmt.Errorf("Error waiting for transaction: %w", err) + } + + return nil + +} + +// True if a transaction is due and needs to bypass the gas threshold +func IsTransactionDue(rp *rocketpool.RocketPool, startTime time.Time) (bool, time.Duration, error) { + + // Get the dissolve timeout + timeout, err := protocol.GetMinipoolLaunchTimeout(rp, nil) + if err != nil { + return false, 0, err + } + + dueTime := timeout / time.Duration(TimeoutSafetyFactor) + isDue := time.Since(startTime) > dueTime + timeUntilDue := time.Until(startTime.Add(dueTime)) + return isDue, timeUntilDue, nil + +} + // Estimate the gas of SendTransaction -func EstimateSendTransactionGas(client rocketpool.ExecutionClient, toAddress common.Address, data []byte, useSafeGasLimit bool, opts *bind.TransactOpts) (rocketpool.GasInfo, error) { +func EstimateSendTransactionGas(client rocketpool.ExecutionClient, toAddress common.Address, data []byte, useSafeGasLimit bool, opts *bind.TransactOpts) (gaslimit.Limits, error) { // User-defined settings - response := rocketpool.GasInfo{} + response := gaslimit.Limits{} // Set default value value := opts.Value @@ -38,14 +86,14 @@ func EstimateSendTransactionGas(client rocketpool.ExecutionClient, toAddress com Value: value, }) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } - response.EstGasLimit = gasLimit + response.Estimated = gasLimit if useSafeGasLimit { - response.SafeGasLimit = uint64(float64(gasLimit) * rocketpool.GasLimitMultiplier) + response.Safe = uint64(float64(gasLimit) * rocketpool.GasLimitMultiplier) } else { - response.SafeGasLimit = gasLimit + response.Safe = gasLimit } return response, err diff --git a/bindings/utils/deposit_retrieval.go b/bindings/utils/deposit_retrieval.go index 597429155..2f6faa704 100644 --- a/bindings/utils/deposit_retrieval.go +++ b/bindings/utils/deposit_retrieval.go @@ -11,9 +11,9 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/rocket-pool/smartnode/bindings/logs" "github.com/rocket-pool/smartnode/bindings/rocketpool" rptypes "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" ) // BeaconDepositEvent represents a DepositEvent event raised by the BeaconDeposit contract. @@ -52,7 +52,7 @@ func GetDeposits(rp *rocketpool.RocketPool, pubkeys map[rptypes.ValidatorPubkey] // Get the deposit events addressFilter := []common.Address{*casperDeposit.Address} topicFilter := [][]common.Hash{{casperDeposit.ABI.Events["DepositEvent"].ID}} - logs, err := eth.GetLogs(rp, addressFilter, topicFilter, intervalSize, startBlock, nil, nil) + logs, err := logs.GetLogs(rp, addressFilter, topicFilter, intervalSize, startBlock, nil, nil) if err != nil { return nil, err } diff --git a/rocketpool-cli/auction/bid-lot.go b/rocketpool-cli/auction/bid-lot.go index cfa826c8f..f9b5faa7f 100644 --- a/rocketpool-cli/auction/bid-lot.go +++ b/rocketpool-cli/auction/bid-lot.go @@ -138,7 +138,7 @@ func bidOnLot(lot, amount string, yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canBid.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canBid.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/auction/claim-lot.go b/rocketpool-cli/auction/claim-lot.go index a5c8e88de..7d0d44176 100644 --- a/rocketpool-cli/auction/claim-lot.go +++ b/rocketpool-cli/auction/claim-lot.go @@ -4,7 +4,7 @@ import ( "fmt" "strconv" - rocketpoolapi "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/shared/services/gas" @@ -94,21 +94,21 @@ func claimFromLot(lot string, yes bool) error { // Get the total gas limit estimate var totalGas uint64 var totalSafeGas uint64 - var gasInfo rocketpoolapi.GasInfo + var gasLimits gaslimit.Limits for _, lot := range selectedLots { canResponse, err := rp.CanClaimFromLot(lot.Details.Index) if err != nil { return fmt.Errorf("Error checking if claiming lot %d is possible: %w", lot.Details.Index, err) } - gasInfo = canResponse.GasInfo - totalGas += canResponse.GasInfo.EstGasLimit - totalSafeGas += canResponse.GasInfo.SafeGasLimit + gasLimits = canResponse.GasLimits + totalGas += canResponse.GasLimits.Estimated + totalSafeGas += canResponse.GasLimits.Safe } - gasInfo.EstGasLimit = totalGas - gasInfo.SafeGasLimit = totalSafeGas + gasLimits.Estimated = totalGas + gasLimits.Safe = totalSafeGas // Get max fees - g, err := gas.GetMaxFeeAndLimit(gasInfo, rp, yes) + g, err := gas.GetMaxFeeAndLimit(gasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/auction/create-lot.go b/rocketpool-cli/auction/create-lot.go index e463822b6..c8afacf53 100644 --- a/rocketpool-cli/auction/create-lot.go +++ b/rocketpool-cli/auction/create-lot.go @@ -35,7 +35,7 @@ func createLot(yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canCreate.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canCreate.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/auction/recover-lot.go b/rocketpool-cli/auction/recover-lot.go index 9749688c4..62c594730 100644 --- a/rocketpool-cli/auction/recover-lot.go +++ b/rocketpool-cli/auction/recover-lot.go @@ -4,7 +4,7 @@ import ( "fmt" "strconv" - rocketpoolapi "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/shared/services/gas" @@ -94,21 +94,21 @@ func recoverRplFromLot(lot string, yes bool) error { // Get the total gas limit estimate var totalGas uint64 var totalSafeGas uint64 - var gasInfo rocketpoolapi.GasInfo + var gasLimits gaslimit.Limits for _, lot := range selectedLots { canResponse, err := rp.CanRecoverUnclaimedRPLFromLot(lot.Details.Index) if err != nil { return fmt.Errorf("Error checking if recovering lot %d is possible: %w", lot.Details.Index, err) } - gasInfo = canResponse.GasInfo - totalGas += canResponse.GasInfo.EstGasLimit - totalSafeGas += canResponse.GasInfo.SafeGasLimit + gasLimits = canResponse.GasLimits + totalGas += canResponse.GasLimits.Estimated + totalSafeGas += canResponse.GasLimits.Safe } - gasInfo.EstGasLimit = totalGas - gasInfo.SafeGasLimit = totalSafeGas + gasLimits.Estimated = totalGas + gasLimits.Safe = totalSafeGas // Get max fees - g, err := gas.GetMaxFeeAndLimit(gasInfo, rp, yes) + g, err := gas.GetMaxFeeAndLimit(gasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/claims/claim-all.go b/rocketpool-cli/claims/claim-all.go index 7f0288ee7..593ba5a6e 100644 --- a/rocketpool-cli/claims/claim-all.go +++ b/rocketpool-cli/claims/claim-all.go @@ -9,7 +9,7 @@ import ( "github.com/ethereum/go-ethereum/common" - rocketpoolapi "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/shared/services/gas" @@ -23,12 +23,12 @@ import ( // pendingClaim represents a single category of rewards that can be claimed. type pendingClaim struct { - id int - name string - ethValue *big.Int // node's ETH value (wei), nil if none - rplValue *big.Int // node's RPL value (wei), nil if none - gasInfo rocketpoolapi.GasInfo - execute func() error + id int + name string + ethValue *big.Int // node's ETH value (wei), nil if none + rplValue *big.Int // node's RPL value (wei), nil if none + gasLimits gaslimit.Limits + execute func() error } // valueString returns a human-readable summary of the claim's ETH and/or RPL value. @@ -126,12 +126,12 @@ func claimAll(restakeAmount string, statusOnly bool, yes bool) error { totalEthWei.Add(totalEthWei, megapoolTotal) - gasInfo := canDistribute.GasInfo + gasLimits := canDistribute.GasLimits claims = append(claims, pendingClaim{ - id: id, - name: "Megapool EL Rewards (distribute)", - ethValue: megapoolTotal, - gasInfo: gasInfo, + id: id, + name: "Megapool EL Rewards (distribute)", + ethValue: megapoolTotal, + gasLimits: gasLimits, execute: func() error { fmt.Println(" Submitting transaction...") response, err := rp.DistributeMegapool() @@ -188,12 +188,12 @@ func claimAll(restakeAmount string, statusOnly bool, yes bool) error { nodeShareWei := eth.EthToWei(canDistResp.NodeShare) totalEthWei.Add(totalEthWei, nodeShareWei) - gasInfo := canDistResp.GasInfo + gasLimits := canDistResp.GasLimits claims = append(claims, pendingClaim{ - id: feeDistID, - name: "Fee Distributor (distribute)", - ethValue: nodeShareWei, - gasInfo: gasInfo, + id: feeDistID, + name: "Fee Distributor (distribute)", + ethValue: nodeShareWei, + gasLimits: gasLimits, execute: func() error { fmt.Println(" Submitting transaction...") response, err := rp.Distribute() @@ -273,23 +273,18 @@ func claimAll(restakeAmount string, statusOnly bool, yes bool) error { totalEthWei.Add(totalEthWei, mpTotalEth) // Accumulate gas - var totalGasEst, totalGasSafe uint64 - var mpGasInfo rocketpoolapi.GasInfo + var mpGasLimits gaslimit.Limits for _, mp := range eligibleMinipools { - mpGasInfo = mp.GasInfo - totalGasEst += mp.GasInfo.EstGasLimit - totalGasSafe += mp.GasInfo.SafeGasLimit + mpGasLimits = mpGasLimits.Add(mp.GasLimits) } - mpGasInfo.EstGasLimit = totalGasEst - mpGasInfo.SafeGasLimit = totalGasSafe // Capture for closure mps := eligibleMinipools claims = append(claims, pendingClaim{ - id: minipoolID, - name: fmt.Sprintf("Minipool Balance Distribution (%d minipool(s))", len(mps)), - ethValue: mpTotalEth, - gasInfo: mpGasInfo, + id: minipoolID, + name: fmt.Sprintf("Minipool Balance Distribution (%d minipool(s))", len(mps)), + ethValue: mpTotalEth, + gasLimits: mpGasLimits, execute: func() error { failCount := 0 for _, mp := range mps { @@ -419,20 +414,20 @@ func claimAll(restakeAmount string, statusOnly bool, yes bool) error { } // Get preliminary gas estimate (restake prompt deferred, so use claim-only estimate) - var gasInfo rocketpoolapi.GasInfo + var gasLimits gaslimit.Limits canClaim, canErr := rp.CanNodeClaimRewards(intervalIndices) if canErr != nil { color.YellowPrintf(" Warning: could not estimate gas for periodic rewards: %s\n", canErr) } else { - gasInfo = canClaim.GasInfo + gasLimits = canClaim.GasLimits } claims = append(claims, pendingClaim{ - id: periodicID, - name: "Periodic Rewards (RPL + ETH)", - ethValue: prTotalEth, - rplValue: prTotalRpl, - gasInfo: gasInfo, + id: periodicID, + name: "Periodic Rewards (RPL + ETH)", + ethValue: prTotalEth, + rplValue: prTotalRpl, + gasLimits: gasLimits, execute: func() error { fmt.Println(" Submitting transaction...") var txHash common.Hash @@ -501,23 +496,23 @@ func claimAll(restakeAmount string, statusOnly bool, yes bool) error { nodeAddr := nodeStatus.AccountAddress canClaim, canErr := rp.CanClaimUnclaimedRewards(nodeAddr) - var gasInfo rocketpoolapi.GasInfo + var gasLimits gaslimit.Limits canClaimOk := false if canErr != nil { color.YellowPrintf(" Warning: could not estimate gas: %s\n", canErr) } else if !canClaim.CanClaim { color.YellowPrintln(" Cannot claim unclaimed rewards at this time.") } else { - gasInfo = canClaim.GasInfo + gasLimits = canClaim.GasLimits canClaimOk = true } if canClaimOk { claims = append(claims, pendingClaim{ - id: unclaimedID, - name: "Unclaimed Rewards (claim)", - ethValue: nodeStatus.UnclaimedRewards, - gasInfo: gasInfo, + id: unclaimedID, + name: "Unclaimed Rewards (claim)", + ethValue: nodeStatus.UnclaimedRewards, + gasLimits: gasLimits, execute: func() error { fmt.Println(" Submitting transaction...") response, err := rp.ClaimUnclaimedRewards(nodeAddr) @@ -551,7 +546,7 @@ func claimAll(restakeAmount string, statusOnly bool, yes bool) error { totalEthWei.Add(totalEthWei, creditBalance) canWithdraw, canErr := rp.CanNodeWithdrawCredit(creditBalance) - var gasInfo rocketpoolapi.GasInfo + var gasInfo gaslimit.Limits canWithdrawOk := false if canErr != nil { color.YellowPrintf(" Warning: could not estimate gas: %s\n", canErr) @@ -562,17 +557,17 @@ func claimAll(restakeAmount string, statusOnly bool, yes bool) error { color.YellowPrintln(" Cannot withdraw credit at this time.") } } else { - gasInfo = canWithdraw.GasInfo + gasInfo = canWithdraw.GasLimits canWithdrawOk = true } if canWithdrawOk { withdrawAmount := creditBalance claims = append(claims, pendingClaim{ - id: creditID, - name: "Credit Balance Withdrawal", - ethValue: withdrawAmount, - gasInfo: gasInfo, + id: creditID, + name: "Credit Balance Withdrawal", + ethValue: withdrawAmount, + gasLimits: gasInfo, execute: func() error { fmt.Println(" Submitting transaction...") response, err := rp.NodeWithdrawCredit(withdrawAmount) @@ -606,7 +601,7 @@ func claimAll(restakeAmount string, statusOnly bool, yes bool) error { totalEthWei.Add(totalEthWei, ethOnBehalf) canWithdraw, canErr := rp.CanNodeWithdrawEth(ethOnBehalf) - var gasInfo rocketpoolapi.GasInfo + var gasInfo gaslimit.Limits canWithdrawOk := false if canErr != nil { color.YellowPrintf(" Warning: could not estimate gas: %s\n", canErr) @@ -619,17 +614,17 @@ func claimAll(restakeAmount string, statusOnly bool, yes bool) error { color.YellowPrintln(" Cannot withdraw staked ETH at this time.") } } else { - gasInfo = canWithdraw.GasInfo + gasInfo = canWithdraw.GasLimits canWithdrawOk = true } if canWithdrawOk { withdrawAmount := ethOnBehalf claims = append(claims, pendingClaim{ - id: ethOnBehalfID, - name: "Staked ETH on Behalf Withdrawal", - ethValue: withdrawAmount, - gasInfo: gasInfo, + id: ethOnBehalfID, + name: "Staked ETH on Behalf Withdrawal", + ethValue: withdrawAmount, + gasLimits: gasInfo, execute: func() error { fmt.Println(" Submitting transaction...") response, err := rp.NodeWithdrawEth(withdrawAmount) @@ -678,8 +673,7 @@ func claimAll(restakeAmount string, statusOnly bool, yes bool) error { totalRplWei.Add(totalRplWei, pdaoRplTotal) // Accumulate gas - var totalGasEst, totalGasSafe uint64 - var bondGasInfo rocketpoolapi.GasInfo + var bondGasLimits gaslimit.Limits allCanClaim := true for _, bond := range bondsResponse.ClaimableBonds { indices := getClaimIndicesForBond(bond) @@ -689,20 +683,16 @@ func claimAll(restakeAmount string, statusOnly bool, yes bool) error { allCanClaim = false break } - bondGasInfo = canResponse.GasInfo - totalGasEst += canResponse.GasInfo.EstGasLimit - totalGasSafe += canResponse.GasInfo.SafeGasLimit + bondGasLimits = bondGasLimits.Add(canResponse.GasLimits) } if allCanClaim { - bondGasInfo.EstGasLimit = totalGasEst - bondGasInfo.SafeGasLimit = totalGasSafe bonds := bondsResponse.ClaimableBonds claims = append(claims, pendingClaim{ - id: pdaoID, - name: fmt.Sprintf("PDAO Bond Claims (%d proposal(s))", len(bonds)), - rplValue: pdaoRplTotal, - gasInfo: bondGasInfo, + id: pdaoID, + name: fmt.Sprintf("PDAO Bond Claims (%d proposal(s))", len(bonds)), + rplValue: pdaoRplTotal, + gasLimits: bondGasLimits, execute: func() error { failCount := 0 for _, bond := range bonds { @@ -849,7 +839,7 @@ func claimAll(restakeAmount string, statusOnly bool, yes bool) error { if periodicRestakeAmount != nil { canClaim, canErr := rp.CanNodeClaimAndStakeRewards(periodicIntervalIndices, periodicRestakeAmount) if canErr == nil { - selectedClaims[i].gasInfo = canClaim.GasInfo + selectedClaims[i].gasLimits = canClaim.GasLimits } } break @@ -859,18 +849,13 @@ func claimAll(restakeAmount string, statusOnly bool, yes bool) error { fmt.Println() // Accumulate total gas for fee estimation - var totalGasEst, totalGasSafe uint64 - var lastGasInfo rocketpoolapi.GasInfo + var totalGas gaslimit.Limits for _, claim := range selectedClaims { - lastGasInfo = claim.gasInfo - totalGasEst += claim.gasInfo.EstGasLimit - totalGasSafe += claim.gasInfo.SafeGasLimit + totalGas = totalGas.Add(claim.gasLimits) } - lastGasInfo.EstGasLimit = totalGasEst - lastGasInfo.SafeGasLimit = totalGasSafe // Get gas fee settings (single prompt for all transactions) - g, err := gas.GetMaxFeeAndLimit(lastGasInfo, rp, yes) + g, err := gas.GetMaxFeeAndLimit(totalGas, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/megapool/claim.go b/rocketpool-cli/megapool/claim.go index 7ef022ebd..96dc5fe7b 100644 --- a/rocketpool-cli/megapool/claim.go +++ b/rocketpool-cli/megapool/claim.go @@ -52,7 +52,7 @@ func claim(yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canRepay.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canRepay.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/megapool/delegate.go b/rocketpool-cli/megapool/delegate.go index d3e2af9ec..14410983a 100644 --- a/rocketpool-cli/megapool/delegate.go +++ b/rocketpool-cli/megapool/delegate.go @@ -76,7 +76,7 @@ func setUseLatestDelegateMegapool(setting *bool, yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canResponse.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canResponse.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/megapool/deposit.go b/rocketpool-cli/megapool/deposit.go index d0f7eb696..8dabfbe39 100644 --- a/rocketpool-cli/megapool/deposit.go +++ b/rocketpool-cli/megapool/deposit.go @@ -262,7 +262,7 @@ func nodeMegapoolDeposit(count uint64, expressTickets int64, yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canDeposit.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canDeposit.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/megapool/dissolve-validator.go b/rocketpool-cli/megapool/dissolve-validator.go index cd5e4f1d8..b85aa87a4 100644 --- a/rocketpool-cli/megapool/dissolve-validator.go +++ b/rocketpool-cli/megapool/dissolve-validator.go @@ -72,7 +72,7 @@ func dissolveValidator(validatorId uint64, yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canDissolve.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canDissolve.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/megapool/distribute.go b/rocketpool-cli/megapool/distribute.go index 341aa001b..8fa4129c2 100644 --- a/rocketpool-cli/megapool/distribute.go +++ b/rocketpool-cli/megapool/distribute.go @@ -80,7 +80,7 @@ func distribute(yes bool) error { fmt.Println() // Assign max fees - err = gas.AssignMaxFeeAndLimit(canResponse.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canResponse.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/megapool/exit-queue.go b/rocketpool-cli/megapool/exit-queue.go index 51070500b..a1f427d97 100644 --- a/rocketpool-cli/megapool/exit-queue.go +++ b/rocketpool-cli/megapool/exit-queue.go @@ -5,7 +5,7 @@ import ( "strconv" "strings" - rocketpoolapi "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" @@ -133,7 +133,7 @@ func exitQueue(validatorId string, yes bool) error { } // Check whether each validator can be exited and accumulate gas estimates - var totalGasInfo rocketpoolapi.GasInfo + var totalGasLimits gaslimit.Limits canExitResponses := make(map[uint64]*api.CanExitQueueResponse) for _, v := range selectedValidators { validatorId := uint64(v.ValidatorId) @@ -146,8 +146,7 @@ func exitQueue(validatorId string, yes bool) error { continue } canExitResponses[validatorId] = &canExit - totalGasInfo.EstGasLimit += canExit.GasInfo.EstGasLimit - totalGasInfo.SafeGasLimit += canExit.GasInfo.SafeGasLimit + totalGasLimits = totalGasLimits.Add(canExit.GasLimits) } if len(canExitResponses) == 0 { @@ -161,7 +160,7 @@ func exitQueue(validatorId string, yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(totalGasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(totalGasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/megapool/notify-final-balance.go b/rocketpool-cli/megapool/notify-final-balance.go index c1607df75..dd71bef41 100644 --- a/rocketpool-cli/megapool/notify-final-balance.go +++ b/rocketpool-cli/megapool/notify-final-balance.go @@ -100,7 +100,7 @@ func notifyFinalBalance(validatorId, validatorIndex, slot uint64, yes bool) erro } // Assign max fees - err = gas.AssignMaxFeeAndLimit(response.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(response.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/megapool/notify-validator-exit.go b/rocketpool-cli/megapool/notify-validator-exit.go index d15cb4cd4..fb2b150c8 100644 --- a/rocketpool-cli/megapool/notify-validator-exit.go +++ b/rocketpool-cli/megapool/notify-validator-exit.go @@ -68,7 +68,7 @@ func notifyValidatorExit(validatorId uint64, yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(response.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(response.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/megapool/reduce-bond.go b/rocketpool-cli/megapool/reduce-bond.go index 368920b44..dd383569d 100644 --- a/rocketpool-cli/megapool/reduce-bond.go +++ b/rocketpool-cli/megapool/reduce-bond.go @@ -67,7 +67,7 @@ func reduceBond(yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canReduceBond.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canReduceBond.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/megapool/repay-debt.go b/rocketpool-cli/megapool/repay-debt.go index 157e37189..5bc349014 100644 --- a/rocketpool-cli/megapool/repay-debt.go +++ b/rocketpool-cli/megapool/repay-debt.go @@ -59,7 +59,7 @@ func repayDebt(yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canRepay.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canRepay.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/megapool/stake.go b/rocketpool-cli/megapool/stake.go index 7788a61a5..3db9d4933 100644 --- a/rocketpool-cli/megapool/stake.go +++ b/rocketpool-cli/megapool/stake.go @@ -90,7 +90,7 @@ func stake(validatorId uint64, yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canStake.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canStake.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/minipool/close.go b/rocketpool-cli/minipool/close.go index 219eb8fad..240771dd2 100644 --- a/rocketpool-cli/minipool/close.go +++ b/rocketpool-cli/minipool/close.go @@ -7,7 +7,7 @@ import ( "github.com/ethereum/go-ethereum/common" - rocketpoolapi "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" @@ -251,14 +251,13 @@ func closeMinipools(minipool string, confirmSlashing, yes, bundle bool) error { } // Get the total gas limit estimate - var gasInfo rocketpoolapi.GasInfo + var gasLimits gaslimit.Limits for _, minipool := range selectedMinipools { - gasInfo.EstGasLimit += minipool.GasInfo.EstGasLimit - gasInfo.SafeGasLimit += minipool.GasInfo.SafeGasLimit + gasLimits = gasLimits.Add(minipool.GasLimits) } // Assign max fees - err = gas.AssignMaxFeeAndLimit(gasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(gasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/minipool/delegate.go b/rocketpool-cli/minipool/delegate.go index f3eecce2c..5322452d1 100644 --- a/rocketpool-cli/minipool/delegate.go +++ b/rocketpool-cli/minipool/delegate.go @@ -5,7 +5,7 @@ import ( "github.com/ethereum/go-ethereum/common" - rocketpoolapi "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" @@ -81,9 +81,7 @@ func delegateUpgradeMinipools(minipool string, includeFinalized, yes bool) error } // Get the total gas limit estimate - var totalGas uint64 - var totalSafeGas uint64 - var gasInfo rocketpoolapi.GasInfo + var gasLimits gaslimit.Limits for _, minipool := range selectedMinipools { canResponse, err := rp.CanDelegateUpgradeMinipool(minipool) if err != nil { @@ -91,15 +89,11 @@ func delegateUpgradeMinipools(minipool string, includeFinalized, yes bool) error break } fmt.Printf("Minipool %s will upgrade to delegate contract %s.\n", minipool.Hex(), canResponse.LatestDelegateAddress.Hex()) - gasInfo = canResponse.GasInfo - totalGas += canResponse.GasInfo.EstGasLimit - totalSafeGas += canResponse.GasInfo.SafeGasLimit + gasLimits = gasLimits.Add(canResponse.GasLimits) } - gasInfo.EstGasLimit = totalGas - gasInfo.SafeGasLimit = totalSafeGas // Get max fees - g, err := gas.GetMaxFeeAndLimit(gasInfo, rp, yes) + g, err := gas.GetMaxFeeAndLimit(gasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/minipool/distribute.go b/rocketpool-cli/minipool/distribute.go index a0f758235..7cb0572c6 100644 --- a/rocketpool-cli/minipool/distribute.go +++ b/rocketpool-cli/minipool/distribute.go @@ -8,7 +8,7 @@ import ( "github.com/ethereum/go-ethereum/common" - rocketpoolapi "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" @@ -205,19 +205,13 @@ func distributeBalance(minipool string, threshold float64, yes bool) error { } // Get the total gas limit estimate - var totalGas uint64 - var totalSafeGas uint64 - var gasInfo rocketpoolapi.GasInfo + var gasLimits gaslimit.Limits for _, minipool := range selectedMinipools { - gasInfo = minipool.GasInfo - totalGas += gasInfo.EstGasLimit - totalSafeGas += gasInfo.SafeGasLimit + gasLimits = gasLimits.Add(minipool.GasLimits) } - gasInfo.EstGasLimit = totalGas - gasInfo.SafeGasLimit = totalSafeGas // Assign max fees - err = gas.AssignMaxFeeAndLimit(gasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(gasLimits, rp, yes) if err != nil { return err } @@ -234,7 +228,7 @@ func distributeBalance(minipool string, threshold float64, yes bool) error { for _, minipool := range selectedMinipools { // to avoid a second eth_estimateGas if userGasLimit == 0 { - rp.AssignGasSettings(maxFee, maxPrioFee, minipool.GasInfo.SafeGasLimit) + rp.AssignGasSettings(maxFee, maxPrioFee, minipool.GasLimits.Safe) } response, err := rp.DistributeBalance(minipool.Address) diff --git a/rocketpool-cli/minipool/refund.go b/rocketpool-cli/minipool/refund.go index 1d84ec6dd..8fe236895 100644 --- a/rocketpool-cli/minipool/refund.go +++ b/rocketpool-cli/minipool/refund.go @@ -6,7 +6,7 @@ import ( "github.com/ethereum/go-ethereum/common" - rocketpoolapi "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/shared/services/gas" @@ -86,24 +86,18 @@ func refundMinipools(minipool string, yes bool) error { } // Get the total gas limit estimate - var totalGas uint64 - var totalSafeGas uint64 - var gasInfo rocketpoolapi.GasInfo + var gasLimits gaslimit.Limits for _, minipool := range selectedMinipools { canResponse, err := rp.CanRefundMinipool(minipool.Address) if err != nil { fmt.Printf("WARNING: Couldn't get gas price for refund transaction (%s)", err.Error()) break } - gasInfo = canResponse.GasInfo - totalGas += canResponse.GasInfo.EstGasLimit - totalSafeGas += canResponse.GasInfo.SafeGasLimit + gasLimits = gasLimits.Add(canResponse.GasLimits) } - gasInfo.EstGasLimit = totalGas - gasInfo.SafeGasLimit = totalSafeGas // Get max fees - g, err := gas.GetMaxFeeAndLimit(gasInfo, rp, yes) + g, err := gas.GetMaxFeeAndLimit(gasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/minipool/rescue-dissolved.go b/rocketpool-cli/minipool/rescue-dissolved.go index a31ffd2df..72ba0fb8c 100644 --- a/rocketpool-cli/minipool/rescue-dissolved.go +++ b/rocketpool-cli/minipool/rescue-dissolved.go @@ -208,7 +208,7 @@ func rescueDissolved(minipool string, amount string, noSend bool, yes bool) erro } // Assign max fee - err = gas.AssignMaxFeeAndLimit(selectedMinipool.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(selectedMinipool.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/minipool/stake.go b/rocketpool-cli/minipool/stake.go index 969984f2b..d6452280c 100644 --- a/rocketpool-cli/minipool/stake.go +++ b/rocketpool-cli/minipool/stake.go @@ -6,8 +6,7 @@ import ( "github.com/ethereum/go-ethereum/common" - rocketpoolapi "github.com/rocket-pool/smartnode/bindings/rocketpool" - + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" @@ -84,24 +83,18 @@ func stakeMinipools(minipool string, yes bool) error { } // Get the total gas limit estimate - var totalGas = uint64(0) - var totalSafeGas = uint64(0) - var gasInfo rocketpoolapi.GasInfo + var gasLimits gaslimit.Limits for _, minipool := range selectedMinipools { canResponse, err := rp.CanStakeMinipool(minipool.Address) if err != nil { fmt.Printf("WARNING: Couldn't get gas price for stake transaction (%s)", err) break } - gasInfo = canResponse.GasInfo - totalGas += canResponse.GasInfo.EstGasLimit - totalSafeGas += canResponse.GasInfo.SafeGasLimit + gasLimits = gasLimits.Add(canResponse.GasLimits) } - gasInfo.EstGasLimit = totalGas - gasInfo.SafeGasLimit = totalSafeGas // Assign max fees - err = gas.AssignMaxFeeAndLimit(gasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(gasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/node/allow-lock-rpl.go b/rocketpool-cli/node/allow-lock-rpl.go index a51146813..3742af658 100644 --- a/rocketpool-cli/node/allow-lock-rpl.go +++ b/rocketpool-cli/node/allow-lock-rpl.go @@ -25,7 +25,7 @@ func setRPLLockingAllowed(yes, allowedToLock bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canResponse.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canResponse.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/node/claim-rewards.go b/rocketpool-cli/node/claim-rewards.go index 10184a9d8..448ffde86 100644 --- a/rocketpool-cli/node/claim-rewards.go +++ b/rocketpool-cli/node/claim-rewards.go @@ -210,7 +210,7 @@ func nodeClaimRewards(restakeAmountFlag string, yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canClaim.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canClaim.GasLimits, rp, yes) if err != nil { return err } @@ -221,7 +221,7 @@ func nodeClaimRewards(restakeAmountFlag string, yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canClaim.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canClaim.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/node/claim-unclaimed-rewards.go b/rocketpool-cli/node/claim-unclaimed-rewards.go index d22a96751..5c251145c 100644 --- a/rocketpool-cli/node/claim-unclaimed-rewards.go +++ b/rocketpool-cli/node/claim-unclaimed-rewards.go @@ -49,7 +49,7 @@ func claimUnclaimedRewards(yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canClaim.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canClaim.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/node/distributor.go b/rocketpool-cli/node/distributor.go index 6240ad9b1..a61594b08 100644 --- a/rocketpool-cli/node/distributor.go +++ b/rocketpool-cli/node/distributor.go @@ -42,7 +42,7 @@ func initializeFeeDistributor(yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(gasResponse.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(gasResponse.GasLimits, rp, yes) if err != nil { return err } @@ -111,7 +111,7 @@ func distribute(yes bool) error { fmt.Printf("\trETH pool stakers will receive %.6f ETH.\n\n", rEthShare) // Assign max fees - err = gas.AssignMaxFeeAndLimit(canDistributeResponse.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canDistributeResponse.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/node/primary-withdrawal-address.go b/rocketpool-cli/node/primary-withdrawal-address.go index 65b63099c..ce8f6806f 100644 --- a/rocketpool-cli/node/primary-withdrawal-address.go +++ b/rocketpool-cli/node/primary-withdrawal-address.go @@ -77,7 +77,7 @@ func setPrimaryWithdrawalAddress(withdrawalAddressOrENS string, yes, force bool) } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canSendResponse.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canSendResponse.GasLimits, rp, yes) if err != nil { return err } @@ -103,7 +103,7 @@ func setPrimaryWithdrawalAddress(withdrawalAddressOrENS string, yes, force bool) } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canResponse.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canResponse.GasLimits, rp, yes) if err != nil { return err } @@ -163,7 +163,7 @@ func confirmPrimaryWithdrawalAddress(yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canResponse.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canResponse.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/node/register.go b/rocketpool-cli/node/register.go index e52dfe807..068a76f05 100644 --- a/rocketpool-cli/node/register.go +++ b/rocketpool-cli/node/register.go @@ -40,7 +40,7 @@ func registerNode(timezoneLocation string, yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canRegister.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canRegister.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/node/rpl-withdrawal-address.go b/rocketpool-cli/node/rpl-withdrawal-address.go index 3e148e6a4..13215ad25 100644 --- a/rocketpool-cli/node/rpl-withdrawal-address.go +++ b/rocketpool-cli/node/rpl-withdrawal-address.go @@ -89,7 +89,7 @@ func setRPLWithdrawalAddress(withdrawalAddressOrENS string, yes, force bool) err } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canSendResponse.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canSendResponse.GasLimits, rp, yes) if err != nil { return err } @@ -115,7 +115,7 @@ func setRPLWithdrawalAddress(withdrawalAddressOrENS string, yes, force bool) err } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canResponse.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canResponse.GasLimits, rp, yes) if err != nil { return err } @@ -184,7 +184,7 @@ func confirmRPLWithdrawalAddress(yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canResponse.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canResponse.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/node/send-message.go b/rocketpool-cli/node/send-message.go index 351db74e4..fb398dc1e 100644 --- a/rocketpool-cli/node/send-message.go +++ b/rocketpool-cli/node/send-message.go @@ -46,7 +46,7 @@ func sendMessage(toAddressOrENS string, message []byte, yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canSend.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canSend.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/node/send.go b/rocketpool-cli/node/send.go index 1229296d2..8f1c06948 100644 --- a/rocketpool-cli/node/send.go +++ b/rocketpool-cli/node/send.go @@ -86,7 +86,7 @@ func nodeSend(amountRaw float64, sendAll bool, token string, toAddressOrENS stri } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canSend.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canSend.GasLimits, rp, yes) if err != nil { return err } @@ -144,12 +144,12 @@ func nodeSendAll(rp *rocketpool.Client, token string, toAddress common.Address, fmt.Printf("For sending all ETH, we need to estimate the gas costs first.\n") // For ETH, determine gas settings first so we can subtract the gas cost from the balance. // This may prompt the user to select a gas price. - g, err := gas.GetMaxFeeAndLimit(canSend.GasInfo, rp, yes) + g, err := gas.GetMaxFeeAndLimit(canSend.GasLimits, rp, yes) if err != nil { return err } - gasCost := g.GetMaxGasCostEth(canSend.GasInfo) + gasCost := g.GetMaxGasCostEth(canSend.GasLimits) amountRaw = canSend.Balance - gasCost if amountRaw <= 0 { @@ -205,7 +205,7 @@ func nodeSendAll(rp *rocketpool.Client, token string, toAddress common.Address, } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canSend.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canSend.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/node/set-timezone.go b/rocketpool-cli/node/set-timezone.go index caedbccba..b403ec600 100644 --- a/rocketpool-cli/node/set-timezone.go +++ b/rocketpool-cli/node/set-timezone.go @@ -30,7 +30,7 @@ func setTimezoneLocation(timezoneLocation string, yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canResponse.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canResponse.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/node/smoothing-pool.go b/rocketpool-cli/node/smoothing-pool.go index b8ec77593..d84b75fde 100644 --- a/rocketpool-cli/node/smoothing-pool.go +++ b/rocketpool-cli/node/smoothing-pool.go @@ -50,7 +50,7 @@ func joinSmoothingPool(yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canResponse.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canResponse.GasLimits, rp, yes) if err != nil { return err } @@ -123,7 +123,7 @@ func leaveSmoothingPool(yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canResponse.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canResponse.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/node/stake-rpl-whitelist.go b/rocketpool-cli/node/stake-rpl-whitelist.go index ccd1389cc..c0088ca55 100644 --- a/rocketpool-cli/node/stake-rpl-whitelist.go +++ b/rocketpool-cli/node/stake-rpl-whitelist.go @@ -45,7 +45,7 @@ func addAddressToStakeRplWhitelist(addressOrENS string, yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canResponse.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canResponse.GasLimits, rp, yes) if err != nil { return err } @@ -106,7 +106,7 @@ func removeAddressFromStakeRplWhitelist(addressOrENS string, yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canResponse.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canResponse.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/node/stake-rpl.go b/rocketpool-cli/node/stake-rpl.go index 2454f1aea..9b359c183 100644 --- a/rocketpool-cli/node/stake-rpl.go +++ b/rocketpool-cli/node/stake-rpl.go @@ -83,7 +83,7 @@ func nodeStakeRpl(amount string, swap bool, yes bool) error { return err } // Assign max fees - err = gas.AssignMaxFeeAndLimit(approvalGas.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(approvalGas.GasLimits, rp, yes) if err != nil { return err } @@ -127,7 +127,7 @@ func nodeStakeRpl(amount string, swap bool, yes bool) error { } fmt.Println("RPL Swap Gas Info:") // Assign max fees - err = gas.AssignMaxFeeAndLimit(canSwap.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canSwap.GasLimits, rp, yes) if err != nil { return err } @@ -270,7 +270,7 @@ func nodeStakeRpl(amount string, swap bool, yes bool) error { return err } // Assign max fees - err = gas.AssignMaxFeeAndLimit(approvalGas.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(approvalGas.GasLimits, rp, yes) if err != nil { return err } @@ -315,7 +315,7 @@ func nodeStakeRpl(amount string, swap bool, yes bool) error { fmt.Println("RPL Stake Gas Info:") // Assign max fees - err = gas.AssignMaxFeeAndLimit(canStake.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canStake.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/node/swap-rpl.go b/rocketpool-cli/node/swap-rpl.go index 8171fa912..39ff0aa5a 100644 --- a/rocketpool-cli/node/swap-rpl.go +++ b/rocketpool-cli/node/swap-rpl.go @@ -95,7 +95,7 @@ func nodeSwapRpl(amount string, yes bool) error { return err } // Assign max fees - err = gas.AssignMaxFeeAndLimit(approvalGas.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(approvalGas.GasLimits, rp, yes) if err != nil { return err } @@ -139,7 +139,7 @@ func nodeSwapRpl(amount string, yes bool) error { } fmt.Println("RPL Swap Gas Info:") // Assign max fees - err = gas.AssignMaxFeeAndLimit(canSwap.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canSwap.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/node/withdraw-credit.go b/rocketpool-cli/node/withdraw-credit.go index 975b5153c..75031d95e 100644 --- a/rocketpool-cli/node/withdraw-credit.go +++ b/rocketpool-cli/node/withdraw-credit.go @@ -84,7 +84,7 @@ func nodeWithdrawCredit(amount string, yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canWithdraw.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canWithdraw.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/node/withdraw-eth.go b/rocketpool-cli/node/withdraw-eth.go index c1d38311d..e71db9695 100644 --- a/rocketpool-cli/node/withdraw-eth.go +++ b/rocketpool-cli/node/withdraw-eth.go @@ -88,7 +88,7 @@ func nodeWithdrawEth(amount string, yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canWithdraw.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canWithdraw.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/node/withdraw-rpl.go b/rocketpool-cli/node/withdraw-rpl.go index c6c04e524..8feb59f33 100644 --- a/rocketpool-cli/node/withdraw-rpl.go +++ b/rocketpool-cli/node/withdraw-rpl.go @@ -100,7 +100,7 @@ func nodeWithdrawRpl(amount string, yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canWithdraw.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canWithdraw.GasLimits, rp, yes) if err != nil { return err } @@ -203,7 +203,7 @@ func nodeWithdrawRpl(amount string, yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canWithdraw.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canWithdraw.GasLimits, rp, yes) if err != nil { return err } @@ -299,7 +299,7 @@ func nodeWithdrawRpl(amount string, yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canUnstakeLegacyRpl.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canUnstakeLegacyRpl.GasLimits, rp, yes) if err != nil { return err } @@ -410,7 +410,7 @@ func nodeWithdrawRpl(amount string, yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canWithdraw.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canWithdraw.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/odao/cancel-proposal.go b/rocketpool-cli/odao/cancel-proposal.go index 8f28bc2c0..691926d95 100644 --- a/rocketpool-cli/odao/cancel-proposal.go +++ b/rocketpool-cli/odao/cancel-proposal.go @@ -90,7 +90,7 @@ func cancelProposal(proposal string, yes bool) error { return err } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canResponse.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canResponse.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/odao/execute-proposal.go b/rocketpool-cli/odao/execute-proposal.go index c29cbbc3d..2b30555b3 100644 --- a/rocketpool-cli/odao/execute-proposal.go +++ b/rocketpool-cli/odao/execute-proposal.go @@ -5,7 +5,7 @@ import ( "strconv" "github.com/rocket-pool/smartnode/bindings/dao" - rocketpoolapi "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/shared/services/gas" @@ -91,24 +91,18 @@ func executeProposal(proposal string, yes bool) error { } // Get the total gas limit estimate - var totalGas uint64 - var totalSafeGas uint64 - var gasInfo rocketpoolapi.GasInfo + var gasLimits gaslimit.Limits for _, proposal := range selectedProposals { canResponse, err := rp.CanExecuteTNDAOProposal(proposal.ID) if err != nil { fmt.Printf("WARNING: Couldn't get gas price for execute transaction (%s)", err) break } - gasInfo = canResponse.GasInfo - totalGas += canResponse.GasInfo.EstGasLimit - totalSafeGas += canResponse.GasInfo.SafeGasLimit + gasLimits = gasLimits.Add(canResponse.GasLimits) } - gasInfo.EstGasLimit = totalGas - gasInfo.SafeGasLimit = totalSafeGas // Get max fees - g, err := gas.GetMaxFeeAndLimit(gasInfo, rp, yes) + g, err := gas.GetMaxFeeAndLimit(gasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/odao/execute-upgrade.go b/rocketpool-cli/odao/execute-upgrade.go index 24cbb0e23..de200c0b8 100644 --- a/rocketpool-cli/odao/execute-upgrade.go +++ b/rocketpool-cli/odao/execute-upgrade.go @@ -8,7 +8,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/rocket-pool/smartnode/bindings/dao/upgrades" - rocketpoolapi "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/shared/services/gas" @@ -148,24 +148,18 @@ func executeUpgrade(proposal string, yes bool) error { } // Get the total gas limit estimate - var totalGas = uint64(0) - var totalSafeGas = uint64(0) - var gasInfo rocketpoolapi.GasInfo + var gasLimits gaslimit.Limits for _, proposal := range selectedProposals { canResponse, err := rp.CanExecuteUpgradeProposal(proposal.ID) if err != nil { fmt.Printf("WARNING: Couldn't get gas price for execute transaction (%s)", err) break } - gasInfo = canResponse.GasInfo - totalGas += canResponse.GasInfo.EstGasLimit - totalSafeGas += canResponse.GasInfo.SafeGasLimit + gasLimits = gasLimits.Add(canResponse.GasLimits) } - gasInfo.EstGasLimit = totalGas - gasInfo.SafeGasLimit = totalSafeGas // Get max fees - g, err := gas.GetMaxFeeAndLimit(gasInfo, rp, yes) + g, err := gas.GetMaxFeeAndLimit(gasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/odao/join.go b/rocketpool-cli/odao/join.go index ac30b78cf..96da55d27 100644 --- a/rocketpool-cli/odao/join.go +++ b/rocketpool-cli/odao/join.go @@ -65,7 +65,7 @@ func join(yes bool, swap bool) error { return err } // Assign max fees - err = gas.AssignMaxFeeAndLimit(approvalGas.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(approvalGas.GasLimits, rp, yes) if err != nil { return err } @@ -109,7 +109,7 @@ func join(yes bool, swap bool) error { } fmt.Println("RPL Swap Gas Info:") // Assign max fees - err = gas.AssignMaxFeeAndLimit(canSwap.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canSwap.GasLimits, rp, yes) if err != nil { return err } @@ -164,7 +164,7 @@ func join(yes bool, swap bool) error { // Display gas estimate // Assign max fees - err = gas.AssignMaxFeeAndLimit(canJoin.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canJoin.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/odao/leave.go b/rocketpool-cli/odao/leave.go index abddb8900..a243493de 100644 --- a/rocketpool-cli/odao/leave.go +++ b/rocketpool-cli/odao/leave.go @@ -74,7 +74,7 @@ func leave(refundAddress string, yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canLeave.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canLeave.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/odao/penalise-megapool.go b/rocketpool-cli/odao/penalise-megapool.go index e9f50688d..7227689e6 100644 --- a/rocketpool-cli/odao/penalise-megapool.go +++ b/rocketpool-cli/odao/penalise-megapool.go @@ -43,7 +43,7 @@ func penaliseMegapool(megapoolAddress common.Address, block *big.Int, yes bool) } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canPenalise.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canPenalise.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/odao/propose-invite.go b/rocketpool-cli/odao/propose-invite.go index 67305576c..c111032cb 100644 --- a/rocketpool-cli/odao/propose-invite.go +++ b/rocketpool-cli/odao/propose-invite.go @@ -37,7 +37,7 @@ func proposeInvite(memberAddress common.Address, memberId, memberUrl string, yes } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canPropose.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canPropose.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/odao/propose-kick.go b/rocketpool-cli/odao/propose-kick.go index 8bbb7d024..e66a4c849 100644 --- a/rocketpool-cli/odao/propose-kick.go +++ b/rocketpool-cli/odao/propose-kick.go @@ -106,7 +106,7 @@ func proposeKick(member, fine string, yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canPropose.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canPropose.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/odao/propose-leave.go b/rocketpool-cli/odao/propose-leave.go index 1900f2171..a5b34109c 100644 --- a/rocketpool-cli/odao/propose-leave.go +++ b/rocketpool-cli/odao/propose-leave.go @@ -34,7 +34,7 @@ func proposeLeave(yes bool) error { return nil } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canPropose.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canPropose.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/odao/propose-settings.go b/rocketpool-cli/odao/propose-settings.go index fe1b7bf82..492f24689 100644 --- a/rocketpool-cli/odao/propose-settings.go +++ b/rocketpool-cli/odao/propose-settings.go @@ -35,7 +35,7 @@ func proposeSettingMembersQuorum(quorumPercent float64, yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canPropose.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canPropose.GasLimits, rp, yes) if err != nil { return err } @@ -87,7 +87,7 @@ func proposeSettingMembersRplBond(bondAmountEth float64, yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canPropose.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canPropose.GasLimits, rp, yes) if err != nil { return err } @@ -139,7 +139,7 @@ func proposeSettingMinipoolUnbondedMax(unbondedMinipoolMax uint64, yes bool) err } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canPropose.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canPropose.GasLimits, rp, yes) if err != nil { return err } @@ -198,7 +198,7 @@ func proposeSettingProposalCooldown(proposalCooldownTimespan string, yes bool) e } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canPropose.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canPropose.GasLimits, rp, yes) if err != nil { return err } @@ -257,7 +257,7 @@ func proposeSettingProposalVoteTimespan(proposalVoteTimespan string, yes bool) e } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canPropose.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canPropose.GasLimits, rp, yes) if err != nil { return err } @@ -316,7 +316,7 @@ func proposeSettingProposalVoteDelayTimespan(proposalDelayTimespan string, yes b } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canPropose.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canPropose.GasLimits, rp, yes) if err != nil { return err } @@ -375,7 +375,7 @@ func proposeSettingProposalExecuteTimespan(proposalExecuteTimespan string, yes b } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canPropose.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canPropose.GasLimits, rp, yes) if err != nil { return err } @@ -434,7 +434,7 @@ func proposeSettingProposalActionTimespan(proposalActionTimespan string, yes boo } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canPropose.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canPropose.GasLimits, rp, yes) if err != nil { return err } @@ -493,7 +493,7 @@ func proposeSettingScrubPeriod(scrubPeriod string, yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canPropose.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canPropose.GasLimits, rp, yes) if err != nil { return err } @@ -552,7 +552,7 @@ func proposeSettingPromotionScrubPeriod(scrubPeriod string, yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canPropose.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canPropose.GasLimits, rp, yes) if err != nil { return err } @@ -604,7 +604,7 @@ func proposeSettingScrubPenaltyEnabled(enabled bool, yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canPropose.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canPropose.GasLimits, rp, yes) if err != nil { return err } @@ -663,7 +663,7 @@ func proposeSettingBondReductionWindowStart(windowStart string, yes bool) error } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canPropose.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canPropose.GasLimits, rp, yes) if err != nil { return err } @@ -722,7 +722,7 @@ func proposeSettingBondReductionWindowLength(windowLength string, yes bool) erro } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canPropose.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canPropose.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/odao/vote-proposal.go b/rocketpool-cli/odao/vote-proposal.go index 411e73ae7..c1811059f 100644 --- a/rocketpool-cli/odao/vote-proposal.go +++ b/rocketpool-cli/odao/vote-proposal.go @@ -138,7 +138,7 @@ func voteOnProposal(proposal string, supportFlag string, yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canVote.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canVote.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/pdao/claim-bonds.go b/rocketpool-cli/pdao/claim-bonds.go index 34a49364d..d0ff5a5ab 100644 --- a/rocketpool-cli/pdao/claim-bonds.go +++ b/rocketpool-cli/pdao/claim-bonds.go @@ -5,7 +5,7 @@ import ( "sort" "strconv" - rocketpoolapi "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/shared/services/gas" @@ -85,24 +85,18 @@ func claimBonds(proposal string, yes bool) error { } // Get the total gas limit estimate - var totalGas = uint64(0) - var totalSafeGas = uint64(0) - var gasInfo rocketpoolapi.GasInfo + var gasLimits gaslimit.Limits for _, bond := range selectedClaims { indices := getClaimIndicesForBond(bond) canResponse, err := rp.PDAOCanClaimBonds(bond.ProposalID, indices) if err != nil { return fmt.Errorf("error simulating claim-bond on proposal %d: %s", bond.ProposalID, err.Error()) } - gasInfo = canResponse.GasInfo - totalGas += canResponse.GasInfo.EstGasLimit - totalSafeGas += canResponse.GasInfo.SafeGasLimit + gasLimits = gasLimits.Add(canResponse.GasLimits) } - gasInfo.EstGasLimit = totalGas - gasInfo.SafeGasLimit = totalSafeGas // Assign max fees - err = gas.AssignMaxFeeAndLimit(gasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(gasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/pdao/defeat-proposal.go b/rocketpool-cli/pdao/defeat-proposal.go index 9b8571af6..363bf2f74 100644 --- a/rocketpool-cli/pdao/defeat-proposal.go +++ b/rocketpool-cli/pdao/defeat-proposal.go @@ -40,7 +40,7 @@ func defeatProposal(proposalID uint64, challengedIndex uint64, yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canResponse.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canResponse.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/pdao/execute-proposal.go b/rocketpool-cli/pdao/execute-proposal.go index e35bbfa2b..76ea5558c 100644 --- a/rocketpool-cli/pdao/execute-proposal.go +++ b/rocketpool-cli/pdao/execute-proposal.go @@ -4,7 +4,7 @@ import ( "fmt" "strconv" - rocketpoolapi "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/strings" @@ -96,24 +96,18 @@ func executeProposal(proposal string, yes bool) error { } // Get the total gas limit estimate - var totalGas = uint64(0) - var totalSafeGas = uint64(0) - var gasInfo rocketpoolapi.GasInfo + var gasLimits gaslimit.Limits for _, proposal := range selectedProposals { canResponse, err := rp.PDAOCanExecuteProposal(proposal.ID) if err != nil { fmt.Printf("WARNING: Couldn't get gas price for execute transaction (%s)", err.Error()) break } - gasInfo = canResponse.GasInfo - totalGas += canResponse.GasInfo.EstGasLimit - totalSafeGas += canResponse.GasInfo.SafeGasLimit + gasLimits = gasLimits.Add(canResponse.GasLimits) } - gasInfo.EstGasLimit = totalGas - gasInfo.SafeGasLimit = totalSafeGas // Assign max fees - err = gas.AssignMaxFeeAndLimit(gasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(gasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/pdao/finalize-proposal.go b/rocketpool-cli/pdao/finalize-proposal.go index d8ccb1750..e18ac1b9c 100644 --- a/rocketpool-cli/pdao/finalize-proposal.go +++ b/rocketpool-cli/pdao/finalize-proposal.go @@ -37,7 +37,7 @@ func finalizeProposal(proposalID uint64, yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canResponse.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canResponse.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/pdao/invite-sc.go b/rocketpool-cli/pdao/invite-sc.go index 23163bdc3..70d501b5a 100644 --- a/rocketpool-cli/pdao/invite-sc.go +++ b/rocketpool-cli/pdao/invite-sc.go @@ -52,7 +52,7 @@ func proposeSecurityCouncilInvite(id string, addressFlag string, yes bool) error } // Assign max fee - err = gas.AssignMaxFeeAndLimit(canResponse.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canResponse.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/pdao/kick-sc.go b/rocketpool-cli/pdao/kick-sc.go index 8d400faef..364840933 100644 --- a/rocketpool-cli/pdao/kick-sc.go +++ b/rocketpool-cli/pdao/kick-sc.go @@ -111,7 +111,7 @@ func proposeSecurityCouncilKick(addressesFlag string, yes bool) error { } // Assign max fee - err = gas.AssignMaxFeeAndLimit(canResponse.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canResponse.GasLimits, rp, yes) if err != nil { return err } @@ -152,7 +152,7 @@ func proposeSecurityCouncilKick(addressesFlag string, yes bool) error { } // Assign max fee - err = gas.AssignMaxFeeAndLimit(canResponse.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canResponse.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/pdao/one-time-spend.go b/rocketpool-cli/pdao/one-time-spend.go index 2c02d5b2a..cf7f403ea 100644 --- a/rocketpool-cli/pdao/one-time-spend.go +++ b/rocketpool-cli/pdao/one-time-spend.go @@ -75,7 +75,7 @@ func proposeOneTimeSpend(invoiceIDFlag string, recipientFlag string, amountFlag } // Assign max fee - err = gas.AssignMaxFeeAndLimit(canResponse.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canResponse.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/pdao/percentages.go b/rocketpool-cli/pdao/percentages.go index 38333209a..1a28e3a44 100644 --- a/rocketpool-cli/pdao/percentages.go +++ b/rocketpool-cli/pdao/percentages.go @@ -95,7 +95,7 @@ func proposeRewardsPercentages(rawEnabled bool, nodeFlag string, odaoFlag string } // Assign max fee - err = gas.AssignMaxFeeAndLimit(canResponse.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canResponse.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/pdao/propose-settings.go b/rocketpool-cli/pdao/propose-settings.go index 46b0876dc..cc6d13420 100644 --- a/rocketpool-cli/pdao/propose-settings.go +++ b/rocketpool-cli/pdao/propose-settings.go @@ -419,7 +419,7 @@ func proposeSetting(contract string, setting string, value string, yes bool) err } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canPropose.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canPropose.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/pdao/recurring-spend-update.go b/rocketpool-cli/pdao/recurring-spend-update.go index ebed69ebe..9c68cc989 100644 --- a/rocketpool-cli/pdao/recurring-spend-update.go +++ b/rocketpool-cli/pdao/recurring-spend-update.go @@ -92,7 +92,7 @@ func proposeRecurringSpendUpdate(rawEnabled bool, contractName string, recipient } // Assign max fee - err = gas.AssignMaxFeeAndLimit(canResponse.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canResponse.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/pdao/recurring-spend.go b/rocketpool-cli/pdao/recurring-spend.go index 53b311425..53c07383a 100644 --- a/rocketpool-cli/pdao/recurring-spend.go +++ b/rocketpool-cli/pdao/recurring-spend.go @@ -108,7 +108,7 @@ func proposeRecurringSpend(rawEnabled bool, contractName string, recipientString } // Assign max fee - err = gas.AssignMaxFeeAndLimit(canResponse.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canResponse.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/pdao/replace-sc.go b/rocketpool-cli/pdao/replace-sc.go index e7f2bd6b7..b14c41eda 100644 --- a/rocketpool-cli/pdao/replace-sc.go +++ b/rocketpool-cli/pdao/replace-sc.go @@ -88,7 +88,7 @@ func proposeSecurityCouncilReplace(existingAddressString string, newID string, n } // Assign max fee - err = gas.AssignMaxFeeAndLimit(canResponse.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canResponse.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/pdao/set-allow-list.go b/rocketpool-cli/pdao/set-allow-list.go index 808df62de..9e572504e 100644 --- a/rocketpool-cli/pdao/set-allow-list.go +++ b/rocketpool-cli/pdao/set-allow-list.go @@ -73,7 +73,7 @@ func setAllowListedControllers(addressListStr string, yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canResponse.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canResponse.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/pdao/set-signalling-address.go b/rocketpool-cli/pdao/set-signalling-address.go index 0e41ff48c..9ed0beb43 100644 --- a/rocketpool-cli/pdao/set-signalling-address.go +++ b/rocketpool-cli/pdao/set-signalling-address.go @@ -32,7 +32,7 @@ func setSignallingAddress(signallingAddress common.Address, signature string, ye } // Assign max fees - err = gas.AssignMaxFeeAndLimit(resp.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(resp.GasLimits, rp, yes) if err != nil { return err } @@ -81,7 +81,7 @@ func clearSignallingAddress(yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(resp.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(resp.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/pdao/vote-proposal.go b/rocketpool-cli/pdao/vote-proposal.go index 346c28c23..87934bd29 100644 --- a/rocketpool-cli/pdao/vote-proposal.go +++ b/rocketpool-cli/pdao/vote-proposal.go @@ -165,7 +165,7 @@ func voteOnProposal(proposal, voteDirectionFlag string, yes bool) error { fmt.Printf("\n\nYour voting power on this proposal: %.10f\n\n", eth.WeiToEth(canVote.VotingPower)) // Assign max fees - err = gas.AssignMaxFeeAndLimit(canVote.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canVote.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/pdao/voting.go b/rocketpool-cli/pdao/voting.go index b40c1ce71..2c57058ac 100644 --- a/rocketpool-cli/pdao/voting.go +++ b/rocketpool-cli/pdao/voting.go @@ -44,7 +44,7 @@ func pdaoSetVotingDelegate(nameOrAddress string, yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(gasEstimate.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(gasEstimate.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/queue/assign-deposits.go b/rocketpool-cli/queue/assign-deposits.go index deffdfbe9..5aca99d48 100644 --- a/rocketpool-cli/queue/assign-deposits.go +++ b/rocketpool-cli/queue/assign-deposits.go @@ -86,7 +86,7 @@ func assignDeposits(yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canAssign.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canAssign.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/queue/process.go b/rocketpool-cli/queue/process.go index 7440ce5e9..4a28feb6d 100644 --- a/rocketpool-cli/queue/process.go +++ b/rocketpool-cli/queue/process.go @@ -48,7 +48,7 @@ func processQueue(yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canProcess.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canProcess.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/security/cancel-proposal.go b/rocketpool-cli/security/cancel-proposal.go index 82f7a85c7..9afc3f184 100644 --- a/rocketpool-cli/security/cancel-proposal.go +++ b/rocketpool-cli/security/cancel-proposal.go @@ -90,7 +90,7 @@ func cancelProposal(proposal string, yes bool) error { return err } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canResponse.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canResponse.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/security/execute-proposal.go b/rocketpool-cli/security/execute-proposal.go index 5436cb176..b5cae476e 100644 --- a/rocketpool-cli/security/execute-proposal.go +++ b/rocketpool-cli/security/execute-proposal.go @@ -5,7 +5,7 @@ import ( "strconv" "github.com/rocket-pool/smartnode/bindings/dao" - rocketpoolapi "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/shared/services/gas" @@ -91,24 +91,18 @@ func executeProposal(proposal string, yes bool) error { } // Get the total gas limit estimate - var totalGas uint64 - var totalSafeGas uint64 - var gasInfo rocketpoolapi.GasInfo + var gasLimits gaslimit.Limits for _, proposal := range selectedProposals { canResponse, err := rp.SecurityCanExecuteProposal(proposal.ID) if err != nil { fmt.Printf("WARNING: Couldn't get gas price for execute transaction (%s)", err) break } - gasInfo = canResponse.GasInfo - totalGas += canResponse.GasInfo.EstGasLimit - totalSafeGas += canResponse.GasInfo.SafeGasLimit + gasLimits = gasLimits.Add(canResponse.GasLimits) } - gasInfo.EstGasLimit = totalGas - gasInfo.SafeGasLimit = totalSafeGas // Assign max fees - err = gas.AssignMaxFeeAndLimit(gasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(gasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/security/join.go b/rocketpool-cli/security/join.go index 4948d9d1d..8e2679b81 100644 --- a/rocketpool-cli/security/join.go +++ b/rocketpool-cli/security/join.go @@ -35,7 +35,7 @@ func join(yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canJoin.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canJoin.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/security/leave.go b/rocketpool-cli/security/leave.go index 7a4582951..18c16fa2f 100644 --- a/rocketpool-cli/security/leave.go +++ b/rocketpool-cli/security/leave.go @@ -32,7 +32,7 @@ func leave(yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canLeave.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canLeave.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/security/propose-leave.go b/rocketpool-cli/security/propose-leave.go index d6e6c129d..5bf5c7105 100644 --- a/rocketpool-cli/security/propose-leave.go +++ b/rocketpool-cli/security/propose-leave.go @@ -31,7 +31,7 @@ func proposeLeave(yes bool) error { return nil } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canPropose.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canPropose.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/security/propose-settings.go b/rocketpool-cli/security/propose-settings.go index 2cd286bc5..a4c8a42d5 100644 --- a/rocketpool-cli/security/propose-settings.go +++ b/rocketpool-cli/security/propose-settings.go @@ -98,7 +98,7 @@ func proposeSetting(contract string, setting string, value string, yes bool) err } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canPropose.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canPropose.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/security/vote-proposal.go b/rocketpool-cli/security/vote-proposal.go index 5f7751d83..bf14147ae 100644 --- a/rocketpool-cli/security/vote-proposal.go +++ b/rocketpool-cli/security/vote-proposal.go @@ -138,7 +138,7 @@ func voteOnProposal(proposal string, supportFlag string, yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(canVote.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(canVote.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool-cli/wallet/ens-name.go b/rocketpool-cli/wallet/ens-name.go index e4e7bd5bf..6c35fc599 100644 --- a/rocketpool-cli/wallet/ens-name.go +++ b/rocketpool-cli/wallet/ens-name.go @@ -32,7 +32,7 @@ func setEnsName(name string, yes bool) error { } // Assign max fees - err = gas.AssignMaxFeeAndLimit(estimateGasSetName.GasInfo, rp, yes) + err = gas.AssignMaxFeeAndLimit(estimateGasSetName.GasLimits, rp, yes) if err != nil { return err } diff --git a/rocketpool/api/auction/bid-lot.go b/rocketpool/api/auction/bid-lot.go index a8b9bf6be..91ec9a27a 100644 --- a/rocketpool/api/auction/bid-lot.go +++ b/rocketpool/api/auction/bid-lot.go @@ -81,9 +81,9 @@ func canBidOnLot(c *cli.Command, lotIndex uint64, amountWei *big.Int) (*api.CanB return err } opts.Value = amountWei - gasInfo, err := auction.EstimatePlaceBidGas(rp, lotIndex, opts) + gasLimits, err := auction.EstimatePlaceBidGas(rp, lotIndex, opts) if err == nil { - response.GasInfo = gasInfo + response.GasLimits = gasLimits } return err }) diff --git a/rocketpool/api/auction/claim-lot.go b/rocketpool/api/auction/claim-lot.go index 397e01eee..9dacd5794 100644 --- a/rocketpool/api/auction/claim-lot.go +++ b/rocketpool/api/auction/claim-lot.go @@ -74,9 +74,9 @@ func canClaimFromLot(c *cli.Command, lotIndex uint64) (*api.CanClaimFromLotRespo if err != nil { return err } - gasInfo, err := auction.EstimateClaimBidGas(rp, lotIndex, opts) + gasLimits, err := auction.EstimateClaimBidGas(rp, lotIndex, opts) if err == nil { - response.GasInfo = gasInfo + response.GasLimits = gasLimits } return err }) diff --git a/rocketpool/api/auction/create-lot.go b/rocketpool/api/auction/create-lot.go index 0bcfc945d..30c86a17b 100644 --- a/rocketpool/api/auction/create-lot.go +++ b/rocketpool/api/auction/create-lot.go @@ -60,9 +60,9 @@ func canCreateLot(c *cli.Command) (*api.CanCreateLotResponse, error) { if err != nil { return err } - gasInfo, err := auction.EstimateCreateLotGas(rp, opts) + gasLimits, err := auction.EstimateCreateLotGas(rp, opts) if err == nil { - response.GasInfo = gasInfo + response.GasLimits = gasLimits } return err }) diff --git a/rocketpool/api/auction/recover-lot.go b/rocketpool/api/auction/recover-lot.go index de8c3e875..c3d50a9e7 100644 --- a/rocketpool/api/auction/recover-lot.go +++ b/rocketpool/api/auction/recover-lot.go @@ -79,9 +79,9 @@ func canRecoverRplFromLot(c *cli.Command, lotIndex uint64) (*api.CanRecoverRPLFr if err != nil { return err } - gasInfo, err := auction.EstimateRecoverUnclaimedRPLGas(rp, lotIndex, opts) + gasLimits, err := auction.EstimateRecoverUnclaimedRPLGas(rp, lotIndex, opts) if err == nil { - response.GasInfo = gasInfo + response.GasLimits = gasLimits } return err }) diff --git a/rocketpool/api/auction/routes.go b/rocketpool/api/auction/routes.go index b5e0ab268..ae72497ec 100644 --- a/rocketpool/api/auction/routes.go +++ b/rocketpool/api/auction/routes.go @@ -8,110 +8,110 @@ import ( "github.com/urfave/cli/v3" + "github.com/rocket-pool/smartnode/rocketpool/api/response" "github.com/rocket-pool/smartnode/shared/services" - apiutils "github.com/rocket-pool/smartnode/shared/utils/api" ) // RegisterRoutes registers the auction module's HTTP routes onto mux. func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { mux.HandleFunc("/api/auction/status", func(w http.ResponseWriter, r *http.Request) { resp, err := getStatus(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/auction/lots", func(w http.ResponseWriter, r *http.Request) { resp, err := getLots(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/auction/can-create-lot", func(w http.ResponseWriter, r *http.Request) { resp, err := canCreateLot(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/auction/create-lot", func(w http.ResponseWriter, r *http.Request) { opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := createLot(c, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/auction/can-bid-lot", func(w http.ResponseWriter, r *http.Request) { lotIndex, amountWei, err := parseLotIndexAndAmount(r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canBidOnLot(c, lotIndex, amountWei) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/auction/bid-lot", func(w http.ResponseWriter, r *http.Request) { lotIndex, amountWei, err := parseLotIndexAndAmount(r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := bidOnLot(c, lotIndex, amountWei, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/auction/can-claim-lot", func(w http.ResponseWriter, r *http.Request) { lotIndex, err := parseLotIndex(r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canClaimFromLot(c, lotIndex) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/auction/claim-lot", func(w http.ResponseWriter, r *http.Request) { lotIndex, err := parseLotIndex(r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := claimFromLot(c, lotIndex, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/auction/can-recover-lot", func(w http.ResponseWriter, r *http.Request) { lotIndex, err := parseLotIndex(r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canRecoverRplFromLot(c, lotIndex) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/auction/recover-lot", func(w http.ResponseWriter, r *http.Request) { lotIndex, err := parseLotIndex(r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := recoverRplFromLot(c, lotIndex, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) } diff --git a/rocketpool/api/debug/routes.go b/rocketpool/api/debug/routes.go index b97c8e761..45392d838 100644 --- a/rocketpool/api/debug/routes.go +++ b/rocketpool/api/debug/routes.go @@ -5,24 +5,23 @@ import ( "net/http" "strconv" + "github.com/rocket-pool/smartnode/rocketpool/api/response" "github.com/urfave/cli/v3" - - apiutils "github.com/rocket-pool/smartnode/shared/utils/api" ) func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { mux.HandleFunc("/api/debug/rewards-event", func(w http.ResponseWriter, r *http.Request) { raw := r.URL.Query().Get("interval") if raw == "" { - apiutils.WriteErrorResponse(w, &apiutils.BadRequestError{Err: fmt.Errorf("missing required query parameter: interval")}) + response.WriteErrorResponse(w, &response.BadRequestError{Err: fmt.Errorf("missing required query parameter: interval")}) return } interval, err := strconv.ParseUint(raw, 10, 64) if err != nil { - apiutils.WriteErrorResponse(w, &apiutils.BadRequestError{Err: fmt.Errorf("invalid interval: %w", err)}) + response.WriteErrorResponse(w, &response.BadRequestError{Err: fmt.Errorf("invalid interval: %w", err)}) return } resp, err := getRewardsEvent(c, interval) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) } diff --git a/rocketpool/api/megapool/claim-refunds.go b/rocketpool/api/megapool/claim-refunds.go index f79a05f76..d36c6126a 100644 --- a/rocketpool/api/megapool/claim-refunds.go +++ b/rocketpool/api/megapool/claim-refunds.go @@ -72,11 +72,11 @@ func canClaimRefund(c *cli.Command) (*api.CanClaimRefundResponse, error) { if err != nil { return nil, err } - gasInfo, err := mp.EstimateClaimRefundGas(opts) + gasLimits, err := mp.EstimateClaimRefundGas(opts) if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits response.CanClaim = true return &response, nil diff --git a/rocketpool/api/megapool/delegate.go b/rocketpool/api/megapool/delegate.go index 8cc327a3a..0c2f6d783 100644 --- a/rocketpool/api/megapool/delegate.go +++ b/rocketpool/api/megapool/delegate.go @@ -41,9 +41,9 @@ func canDelegateUpgrade(c *cli.Command, megapoolAddress common.Address) (*api.Me if err != nil { return nil, err } - gasInfo, err := mega.EstimateDelegateUpgradeGas(opts) + gasLimits, err := mega.EstimateDelegateUpgradeGas(opts) if err == nil { - response.GasInfo = gasInfo + response.GasLimits = gasLimits } // Return response @@ -176,9 +176,9 @@ func canSetUseLatestDelegate(c *cli.Command, useLatest bool) (*api.MegapoolCanSe return nil, err } - gasInfo, err := mega.EstimateSetUseLatestDelegateGas(useLatest, opts) + gasLimits, err := mega.EstimateSetUseLatestDelegateGas(useLatest, opts) if err == nil { - response.GasInfo = gasInfo + response.GasLimits = gasLimits } // Return response diff --git a/rocketpool/api/megapool/dissolve-validator.go b/rocketpool/api/megapool/dissolve-validator.go index f6cd06957..d482183fc 100644 --- a/rocketpool/api/megapool/dissolve-validator.go +++ b/rocketpool/api/megapool/dissolve-validator.go @@ -71,11 +71,11 @@ func canDissolveValidator(c *cli.Command, validatorId uint32) (*api.CanDissolveV if err != nil { return nil, err } - gasInfo, err := mp.EstimateDissolveValidatorGas(validatorId, opts) + gasLimits, err := mp.EstimateDissolveValidatorGas(validatorId, opts) if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits response.CanDissolve = true return &response, nil diff --git a/rocketpool/api/megapool/dissolve-with-proof.go b/rocketpool/api/megapool/dissolve-with-proof.go index 02d5515b3..34456107f 100644 --- a/rocketpool/api/megapool/dissolve-with-proof.go +++ b/rocketpool/api/megapool/dissolve-with-proof.go @@ -100,11 +100,11 @@ func canDissolveWithProof(c *cli.Command, validatorId uint32) (*api.CanDissolveW if err != nil { return nil, err } - gasInfo, err := megapool.EstimateDissolveWithProof(rp, megapoolAddress, validatorId, slotTimestamp, proof, slotProof, opts) + gasLimits, err := megapool.EstimateDissolveWithProof(rp, megapoolAddress, validatorId, slotTimestamp, proof, slotProof, opts) if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits response.CanDissolve = true return &response, nil diff --git a/rocketpool/api/megapool/distribute.go b/rocketpool/api/megapool/distribute.go index 37c4d05ae..947fad2e4 100644 --- a/rocketpool/api/megapool/distribute.go +++ b/rocketpool/api/megapool/distribute.go @@ -82,13 +82,13 @@ func canDistributeMegapool(c *cli.Command) (*api.CanDistributeMegapoolResponse, return &response, nil } - gasInfo, err := mp.EstimateDistributeGas(opts) + gasLimits, err := mp.EstimateDistributeGas(opts) if err != nil { return nil, err } // Return response response.CanDistribute = true - response.GasInfo = gasInfo + response.GasLimits = gasLimits return &response, nil } diff --git a/rocketpool/api/megapool/exit-queue.go b/rocketpool/api/megapool/exit-queue.go index 82b047856..342025bb1 100644 --- a/rocketpool/api/megapool/exit-queue.go +++ b/rocketpool/api/megapool/exit-queue.go @@ -63,11 +63,11 @@ func canExitQueue(c *cli.Command, validatorIndex uint32) (*api.CanExitQueueRespo return nil, err } - gasInfo, err := mp.EstimateDequeueGas(validatorIndex, opts) + gasLimits, err := mp.EstimateDequeueGas(validatorIndex, opts) if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits response.CanExit = true return &response, nil diff --git a/rocketpool/api/megapool/notify-final-balance.go b/rocketpool/api/megapool/notify-final-balance.go index 99e92cf43..6d2b65a93 100644 --- a/rocketpool/api/megapool/notify-final-balance.go +++ b/rocketpool/api/megapool/notify-final-balance.go @@ -127,13 +127,13 @@ func canNotifyFinalBalance(c *cli.Command, validatorId uint32, withdrawalSlot ui } // Notify the validator exit - gasInfo, err := megapool.EstimateNotifyFinalBalance(rp, megapoolAddress, validatorId, slotTimestamp, finalBalanceProof, validatorProof, slotProof, opts) + gasLimits, err := megapool.EstimateNotifyFinalBalance(rp, megapoolAddress, validatorId, slotTimestamp, finalBalanceProof, validatorProof, slotProof, opts) if err != nil { return nil, err } // Update & return response - response.GasInfo = gasInfo + response.GasLimits = gasLimits response.CanExit = !response.InvalidStatus return &response, nil diff --git a/rocketpool/api/megapool/notify-validator-exit.go b/rocketpool/api/megapool/notify-validator-exit.go index 77afdf2c8..d7e885f49 100644 --- a/rocketpool/api/megapool/notify-validator-exit.go +++ b/rocketpool/api/megapool/notify-validator-exit.go @@ -76,13 +76,13 @@ func canNotifyValidatorExit(c *cli.Command, validatorId uint32) (*api.CanNotifyV } // Notify the validator exit - gasInfo, err := megapool.EstimateNotifyExitGas(rp, megapoolAddress, validatorId, slotTimestamp, proof, slotProof, opts) + gasLimits, err := megapool.EstimateNotifyExitGas(rp, megapoolAddress, validatorId, slotTimestamp, proof, slotProof, opts) if err != nil { return nil, err } // Update & return response - response.GasInfo = gasInfo + response.GasLimits = gasLimits response.CanExit = !response.InvalidStatus return &response, nil diff --git a/rocketpool/api/megapool/reduce-bond.go b/rocketpool/api/megapool/reduce-bond.go index 8de93fd04..6c35bbaaa 100644 --- a/rocketpool/api/megapool/reduce-bond.go +++ b/rocketpool/api/megapool/reduce-bond.go @@ -79,11 +79,11 @@ func canReduceBond(c *cli.Command, amount *big.Int) (*api.CanReduceBondResponse, if err != nil { return nil, err } - gasInfo, err := mp.EstimateReduceBondGas(amount, opts) + gasLimits, err := mp.EstimateReduceBondGas(amount, opts) if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits response.CanReduceBond = true return &response, nil diff --git a/rocketpool/api/megapool/repay-debt.go b/rocketpool/api/megapool/repay-debt.go index 0d0bbb825..896bff5de 100644 --- a/rocketpool/api/megapool/repay-debt.go +++ b/rocketpool/api/megapool/repay-debt.go @@ -93,11 +93,11 @@ func canRepayDebt(c *cli.Command, amount *big.Int) (*api.CanRepayDebtResponse, e return nil, err } opts.Value = amount - gasInfo, err := mp.EstimateRepayDebtGas(opts) + gasLimits, err := mp.EstimateRepayDebtGas(opts) if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits response.CanRepay = true return &response, nil diff --git a/rocketpool/api/megapool/routes.go b/rocketpool/api/megapool/routes.go index ec4085677..5cd1b3982 100644 --- a/rocketpool/api/megapool/routes.go +++ b/rocketpool/api/megapool/routes.go @@ -9,8 +9,8 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/urfave/cli/v3" + "github.com/rocket-pool/smartnode/rocketpool/api/response" "github.com/rocket-pool/smartnode/shared/services" - apiutils "github.com/rocket-pool/smartnode/shared/utils/api" ) // RegisterRoutes registers the megapool module's HTTP routes onto mux. @@ -18,359 +18,359 @@ func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { mux.HandleFunc("/api/megapool/status", func(w http.ResponseWriter, r *http.Request) { finalizedState := r.URL.Query().Get("finalizedState") == "true" resp, err := getStatus(c, finalizedState) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/megapool/validator-map-and-balances", func(w http.ResponseWriter, r *http.Request) { resp, err := getValidatorMapAndBalances(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/megapool/can-claim-refund", func(w http.ResponseWriter, r *http.Request) { resp, err := canClaimRefund(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/megapool/claim-refund", func(w http.ResponseWriter, r *http.Request) { opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := claimRefund(c, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/megapool/can-repay-debt", func(w http.ResponseWriter, r *http.Request) { amountWei, err := parseBigInt(r, "amountWei") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canRepayDebt(c, amountWei) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/megapool/repay-debt", func(w http.ResponseWriter, r *http.Request) { amountWei, err := parseBigInt(r, "amountWei") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := repayDebt(c, amountWei, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/megapool/can-reduce-bond", func(w http.ResponseWriter, r *http.Request) { amountWei, err := parseBigInt(r, "amountWei") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canReduceBond(c, amountWei) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/megapool/reduce-bond", func(w http.ResponseWriter, r *http.Request) { amountWei, err := parseBigInt(r, "amountWei") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := reduceBond(c, amountWei, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/megapool/can-stake", func(w http.ResponseWriter, r *http.Request) { validatorId, err := parseUint64(r, "validatorId") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canStake(c, validatorId) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/megapool/stake", func(w http.ResponseWriter, r *http.Request) { validatorId, err := parseUint64(r, "validatorId") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := stake(c, validatorId, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/megapool/can-dissolve-validator", func(w http.ResponseWriter, r *http.Request) { validatorId, err := parseUint32(r, "validatorId") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canDissolveValidator(c, validatorId) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/megapool/dissolve-validator", func(w http.ResponseWriter, r *http.Request) { validatorId, err := parseUint32(r, "validatorId") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := dissolveValidator(c, validatorId, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/megapool/can-dissolve-with-proof", func(w http.ResponseWriter, r *http.Request) { validatorId, err := parseUint32(r, "validatorId") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canDissolveWithProof(c, validatorId) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/megapool/dissolve-with-proof", func(w http.ResponseWriter, r *http.Request) { validatorId, err := parseUint32(r, "validatorId") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := dissolveWithProof(c, validatorId, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/megapool/can-exit-validator", func(w http.ResponseWriter, r *http.Request) { validatorId, err := parseUint32(r, "validatorId") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canExitValidator(c, validatorId) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/megapool/exit-validator", func(w http.ResponseWriter, r *http.Request) { validatorId, err := parseUint32(r, "validatorId") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := exitValidator(c, validatorId) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/megapool/can-notify-validator-exit", func(w http.ResponseWriter, r *http.Request) { validatorId, err := parseUint32(r, "validatorId") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canNotifyValidatorExit(c, validatorId) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/megapool/notify-validator-exit", func(w http.ResponseWriter, r *http.Request) { validatorId, err := parseUint32(r, "validatorId") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := notifyValidatorExit(c, validatorId, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/megapool/can-notify-final-balance", func(w http.ResponseWriter, r *http.Request) { validatorId, err := parseUint32(r, "validatorId") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } slot, err := parseUint64(r, "slot") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canNotifyFinalBalance(c, validatorId, slot) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/megapool/notify-final-balance", func(w http.ResponseWriter, r *http.Request) { validatorId, err := parseUint32(r, "validatorId") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } slot, err := parseUint64(r, "slot") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := notifyFinalBalance(c, validatorId, slot, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/megapool/can-exit-queue", func(w http.ResponseWriter, r *http.Request) { validatorIndex, err := parseUint32(r, "validatorIndex") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canExitQueue(c, validatorIndex) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/megapool/exit-queue", func(w http.ResponseWriter, r *http.Request) { validatorIndex, err := parseUint32(r, "validatorIndex") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := exitQueue(c, validatorIndex, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/megapool/can-distribute", func(w http.ResponseWriter, r *http.Request) { resp, err := canDistributeMegapool(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/megapool/distribute", func(w http.ResponseWriter, r *http.Request) { opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := distributeMegapool(c, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/megapool/get-new-validator-bond-requirement", func(w http.ResponseWriter, r *http.Request) { resp, err := getNewValidatorBondRequirement(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/megapool/pending-rewards", func(w http.ResponseWriter, r *http.Request) { resp, err := calculatePendingRewards(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/megapool/calculate-rewards", func(w http.ResponseWriter, r *http.Request) { amountWei, err := parseBigInt(r, "amountWei") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := calculateRewards(c, amountWei) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/megapool/get-use-latest-delegate", func(w http.ResponseWriter, r *http.Request) { resp, err := getUseLatestDelegate(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/megapool/can-delegate-upgrade", func(w http.ResponseWriter, r *http.Request) { address := common.HexToAddress(r.URL.Query().Get("address")) resp, err := canDelegateUpgrade(c, address) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/megapool/delegate-upgrade", func(w http.ResponseWriter, r *http.Request) { address := common.HexToAddress(r.FormValue("address")) opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := delegateUpgrade(c, address, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/megapool/can-set-use-latest-delegate", func(w http.ResponseWriter, r *http.Request) { setLatest, err := parseBool(r, "setLatest") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canSetUseLatestDelegate(c, setLatest) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/megapool/set-use-latest-delegate", func(w http.ResponseWriter, r *http.Request) { setting, err := parseBool(r, "setting") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := setUseLatestDelegate(c, setting, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/megapool/get-delegate", func(w http.ResponseWriter, r *http.Request) { resp, err := getDelegate(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/megapool/get-effective-delegate", func(w http.ResponseWriter, r *http.Request) { resp, err := getEffectiveDelegate(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/megapool/latest-block-withdrawals", func(w http.ResponseWriter, r *http.Request) { resp, err := getLatestBlockWithdrawals(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/megapool/beacon-withdrawal-queue-estimate", func(w http.ResponseWriter, r *http.Request) { resp, err := getBeaconWithdrawalQueueEstimate(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) } @@ -397,11 +397,11 @@ func parseBool(r *http.Request, name string) (bool, error) { raw = r.FormValue(name) } if raw == "" { - return false, &apiutils.BadRequestError{Err: fmt.Errorf("missing required parameter '%s'", name)} + return false, &response.BadRequestError{Err: fmt.Errorf("missing required parameter '%s'", name)} } v, err := strconv.ParseBool(raw) if err != nil { - return false, &apiutils.BadRequestError{Err: fmt.Errorf("invalid %s: %s", name, raw)} + return false, &response.BadRequestError{Err: fmt.Errorf("invalid %s: %s", name, raw)} } return v, nil } @@ -412,11 +412,11 @@ func parseBigInt(r *http.Request, name string) (*big.Int, error) { raw = r.FormValue(name) } if raw == "" { - return nil, &apiutils.BadRequestError{Err: fmt.Errorf("missing required parameter '%s'", name)} + return nil, &response.BadRequestError{Err: fmt.Errorf("missing required parameter '%s'", name)} } v, ok := new(big.Int).SetString(raw, 10) if !ok { - return nil, &apiutils.BadRequestError{Err: fmt.Errorf("invalid %s: %s", name, raw)} + return nil, &response.BadRequestError{Err: fmt.Errorf("invalid %s: %s", name, raw)} } return v, nil } diff --git a/rocketpool/api/megapool/stake.go b/rocketpool/api/megapool/stake.go index 098a5ebec..1630ab65e 100644 --- a/rocketpool/api/megapool/stake.go +++ b/rocketpool/api/megapool/stake.go @@ -104,11 +104,11 @@ func canStake(c *cli.Command, validatorId uint64) (*api.CanStakeResponse, error) if err != nil { return nil, err } - gasInfo, err := megapool.EstimateStakeGas(rp, megapoolAddress, uint32(validatorId), slotTimestamp, validatorProof, slotProof, opts) + gasLimits, err := megapool.EstimateStakeGas(rp, megapoolAddress, uint32(validatorId), slotTimestamp, validatorProof, slotProof, opts) if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits response.CanStake = true return &response, nil diff --git a/rocketpool/api/minipool/close.go b/rocketpool/api/minipool/close.go index 929556e50..f35129e4d 100644 --- a/rocketpool/api/minipool/close.go +++ b/rocketpool/api/minipool/close.go @@ -256,11 +256,11 @@ func getMinipoolCloseDetails(rp *rocketpool.RocketPool, minipoolAddress common.A // If it's dissolved, just close it if details.MinipoolStatus == types.Dissolved { // Get gas estimate - gasInfo, err := mp.EstimateCloseGas(opts) + gasLimits, err := mp.EstimateCloseGas(opts) if err != nil { return api.MinipoolCloseDetails{}, fmt.Errorf("error estimating close gas for MP %s: %w", minipoolAddress.Hex(), err) } - details.GasInfo = gasInfo + details.GasLimits = gasLimits } else { // Check if it's an upgraded Atlas-era minipool mpv3, success := minipool.GetMinipoolAsV3(mp) @@ -290,18 +290,18 @@ func getMinipoolCloseDetails(rp *rocketpool.RocketPool, minipoolAddress common.A if details.Distributed { // It's already been distributed so just finalize it - gasInfo, err := mpv3.EstimateFinaliseGas(opts) + gasLimits, err := mpv3.EstimateFinaliseGas(opts) if err != nil { return api.MinipoolCloseDetails{}, fmt.Errorf("error estimating finalise gas for MP %s: %w", minipoolAddress.Hex(), err) } - details.GasInfo = gasInfo + details.GasLimits = gasLimits } else { // Do a distribution, which will finalize it - gasInfo, err := mpv3.EstimateDistributeBalanceGas(false, opts) + gasLimits, err := mpv3.EstimateDistributeBalanceGas(false, opts) if err != nil { return api.MinipoolCloseDetails{}, fmt.Errorf("error estimating distribute balance gas for MP %s: %w", minipoolAddress.Hex(), err) } - details.GasInfo = gasInfo + details.GasLimits = gasLimits } } else { return api.MinipoolCloseDetails{}, fmt.Errorf("cannot create v3 binding for minipool %s, version %d", minipoolAddress.Hex(), mp.GetVersion()) diff --git a/rocketpool/api/minipool/delegate.go b/rocketpool/api/minipool/delegate.go index 726420d19..87b411835 100644 --- a/rocketpool/api/minipool/delegate.go +++ b/rocketpool/api/minipool/delegate.go @@ -51,9 +51,9 @@ func canDelegateUpgrade(c *cli.Command, minipoolAddress common.Address) (*api.Ca if err != nil { return nil, err } - gasInfo, err := mp.EstimateDelegateUpgradeGas(opts) + gasLimits, err := mp.EstimateDelegateUpgradeGas(opts) if err == nil { - response.GasInfo = gasInfo + response.GasLimits = gasLimits } // Return response @@ -149,9 +149,9 @@ func canSetUseLatestDelegate(c *cli.Command, minipoolAddress common.Address) (*a if err != nil { return nil, err } - gasInfo, err := mp.EstimateSetUseLatestDelegateGas(opts) + gasLimits, err := mp.EstimateSetUseLatestDelegateGas(opts) if err == nil { - response.GasInfo = gasInfo + response.GasLimits = gasLimits } // Return response diff --git a/rocketpool/api/minipool/dissolve.go b/rocketpool/api/minipool/dissolve.go index f7c248c25..f38b5f7e2 100644 --- a/rocketpool/api/minipool/dissolve.go +++ b/rocketpool/api/minipool/dissolve.go @@ -57,9 +57,9 @@ func canDissolveMinipool(c *cli.Command, minipoolAddress common.Address) (*api.C if err != nil { return nil, err } - gasInfo, err := mp.EstimateDissolveGas(opts) + gasLimits, err := mp.EstimateDissolveGas(opts) if err == nil { - response.GasInfo = gasInfo + response.GasLimits = gasLimits } // Update & return response diff --git a/rocketpool/api/minipool/distribute.go b/rocketpool/api/minipool/distribute.go index d1e5b270b..36c025273 100644 --- a/rocketpool/api/minipool/distribute.go +++ b/rocketpool/api/minipool/distribute.go @@ -172,7 +172,7 @@ func getDistributeBalanceDetails(c *cli.Command) (*api.GetDistributeBalanceDetai if !success { return fmt.Errorf("minipool %s cannot be converted to v3 (current version: %d)", address.Hex(), minipoolDetails.MinipoolVersion) } - minipoolDetails.GasInfo, err = mpv3.EstimateDistributeBalanceGas(true, opts) + minipoolDetails.GasLimits, err = mpv3.EstimateDistributeBalanceGas(true, opts) if err != nil { return fmt.Errorf("error estimating gas to distribute minipool %s: %w", address.Hex(), err) } diff --git a/rocketpool/api/minipool/promote.go b/rocketpool/api/minipool/promote.go index 07a4e82bb..1d44255b8 100644 --- a/rocketpool/api/minipool/promote.go +++ b/rocketpool/api/minipool/promote.go @@ -99,11 +99,11 @@ func canPromoteMinipool(c *cli.Command, minipoolAddress common.Address) (*api.Ca } // Get the gas limit - gasInfo, err := mpv3.EstimatePromoteGas(opts) + gasLimits, err := mpv3.EstimatePromoteGas(opts) if err != nil { return nil, fmt.Errorf("Could not estimate the gas required to promote the minipool: %w", err) } - response.GasInfo = gasInfo + response.GasLimits = gasLimits } diff --git a/rocketpool/api/minipool/refund.go b/rocketpool/api/minipool/refund.go index 8dc1312c5..fc8942113 100644 --- a/rocketpool/api/minipool/refund.go +++ b/rocketpool/api/minipool/refund.go @@ -58,9 +58,9 @@ func canRefundMinipool(c *cli.Command, minipoolAddress common.Address) (*api.Can if err != nil { return nil, err } - gasInfo, err := mp.EstimateRefundGas(opts) + gasLimits, err := mp.EstimateRefundGas(opts) if err == nil { - response.GasInfo = gasInfo + response.GasLimits = gasLimits } // Update & return response diff --git a/rocketpool/api/minipool/rescue-dissolved.go b/rocketpool/api/minipool/rescue-dissolved.go index c6224cb41..b3a4f513c 100644 --- a/rocketpool/api/minipool/rescue-dissolved.go +++ b/rocketpool/api/minipool/rescue-dissolved.go @@ -12,6 +12,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/minipool" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" rptypes "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" @@ -206,9 +207,9 @@ func getMinipoolRescueDissolvedDetails(rp *rocketpool.RocketPool, w wallet.Walle safeGasLimit = rocketpool.MaxGasLimit } - details.GasInfo = rocketpool.GasInfo{ - EstGasLimit: gasLimit, - SafeGasLimit: safeGasLimit, + details.GasLimits = gaslimit.Limits{ + Estimated: gasLimit, + Safe: safeGasLimit, } return details, nil diff --git a/rocketpool/api/minipool/routes.go b/rocketpool/api/minipool/routes.go index a29a9c73b..37141f6e6 100644 --- a/rocketpool/api/minipool/routes.go +++ b/rocketpool/api/minipool/routes.go @@ -8,338 +8,338 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/urfave/cli/v3" + "github.com/rocket-pool/smartnode/rocketpool/api/response" "github.com/rocket-pool/smartnode/shared/services" - apiutils "github.com/rocket-pool/smartnode/shared/utils/api" ) // RegisterRoutes registers the minipool module's HTTP routes onto mux. func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { mux.HandleFunc("/api/minipool/status", func(w http.ResponseWriter, r *http.Request) { resp, err := getStatus(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/minipool/can-refund", func(w http.ResponseWriter, r *http.Request) { addr, err := parseAddress(r, "address") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canRefundMinipool(c, addr) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/minipool/refund", func(w http.ResponseWriter, r *http.Request) { addr, err := parseAddress(r, "address") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := refundMinipool(c, addr, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/minipool/can-stake", func(w http.ResponseWriter, r *http.Request) { addr, err := parseAddress(r, "address") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canStakeMinipool(c, addr) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/minipool/stake", func(w http.ResponseWriter, r *http.Request) { addr, err := parseAddress(r, "address") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := stakeMinipool(c, addr, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/minipool/can-promote", func(w http.ResponseWriter, r *http.Request) { addr, err := parseAddress(r, "address") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canPromoteMinipool(c, addr) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/minipool/promote", func(w http.ResponseWriter, r *http.Request) { addr, err := parseAddress(r, "address") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := promoteMinipool(c, addr, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/minipool/can-dissolve", func(w http.ResponseWriter, r *http.Request) { addr, err := parseAddress(r, "address") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canDissolveMinipool(c, addr) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/minipool/dissolve", func(w http.ResponseWriter, r *http.Request) { addr, err := parseAddress(r, "address") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := dissolveMinipool(c, addr, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/minipool/can-exit", func(w http.ResponseWriter, r *http.Request) { addr, err := parseAddress(r, "address") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canExitMinipool(c, addr) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/minipool/exit", func(w http.ResponseWriter, r *http.Request) { addr, err := parseAddress(r, "address") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := exitMinipool(c, addr) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/minipool/get-minipool-close-details-for-node", func(w http.ResponseWriter, r *http.Request) { resp, err := getMinipoolCloseDetailsForNode(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/minipool/close", func(w http.ResponseWriter, r *http.Request) { addr, err := parseAddress(r, "address") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } bundle := r.FormValue("bundle") == "true" resp, err := closeMinipool(c, addr, opts, bundle) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/minipool/can-delegate-upgrade", func(w http.ResponseWriter, r *http.Request) { addr, err := parseAddress(r, "address") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canDelegateUpgrade(c, addr) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/minipool/delegate-upgrade", func(w http.ResponseWriter, r *http.Request) { addr, err := parseAddress(r, "address") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := delegateUpgrade(c, addr, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/minipool/can-set-use-latest-delegate", func(w http.ResponseWriter, r *http.Request) { addr, err := parseAddress(r, "address") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canSetUseLatestDelegate(c, addr) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/minipool/set-use-latest-delegate", func(w http.ResponseWriter, r *http.Request) { addr, err := parseAddress(r, "address") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := setUseLatestDelegate(c, addr, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/minipool/get-use-latest-delegate", func(w http.ResponseWriter, r *http.Request) { addr, err := parseAddress(r, "address") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := getUseLatestDelegate(c, addr) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/minipool/get-delegate", func(w http.ResponseWriter, r *http.Request) { addr, err := parseAddress(r, "address") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := getDelegate(c, addr) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/minipool/get-effective-delegate", func(w http.ResponseWriter, r *http.Request) { addr, err := parseAddress(r, "address") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := getEffectiveDelegate(c, addr) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/minipool/get-previous-delegate", func(w http.ResponseWriter, r *http.Request) { addr, err := parseAddress(r, "address") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := getPreviousDelegate(c, addr) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/minipool/get-vanity-artifacts", func(w http.ResponseWriter, r *http.Request) { depositAmountStr := r.URL.Query().Get("depositAmount") depositAmount, ok := new(big.Int).SetString(depositAmountStr, 10) if !ok { - apiutils.WriteErrorResponse(w, fmt.Errorf("invalid depositAmount: %s", depositAmountStr)) + response.WriteErrorResponse(w, fmt.Errorf("invalid depositAmount: %s", depositAmountStr)) return } nodeAddressStr := r.URL.Query().Get("nodeAddress") resp, err := getVanityArtifacts(c, depositAmount, nodeAddressStr) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/minipool/get-distribute-balance-details", func(w http.ResponseWriter, r *http.Request) { resp, err := getDistributeBalanceDetails(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/minipool/distribute-balance", func(w http.ResponseWriter, r *http.Request) { addr, err := parseAddress(r, "address") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := distributeBalance(c, addr, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/minipool/import-key", func(w http.ResponseWriter, r *http.Request) { addr, err := parseAddress(r, "address") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } mnemonic := r.FormValue("mnemonic") resp, err := importKey(c, addr, mnemonic) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/minipool/can-change-withdrawal-creds", func(w http.ResponseWriter, r *http.Request) { addr, err := parseAddress(r, "address") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } mnemonic := r.URL.Query().Get("mnemonic") resp, err := canChangeWithdrawalCreds(c, addr, mnemonic) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/minipool/change-withdrawal-creds", func(w http.ResponseWriter, r *http.Request) { addr, err := parseAddress(r, "address") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } mnemonic := r.FormValue("mnemonic") resp, err := changeWithdrawalCreds(c, addr, mnemonic) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/minipool/get-rescue-dissolved-details-for-node", func(w http.ResponseWriter, r *http.Request) { resp, err := getMinipoolRescueDissolvedDetailsForNode(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/minipool/rescue-dissolved", func(w http.ResponseWriter, r *http.Request) { addr, err := parseAddress(r, "address") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } amountStr := r.FormValue("amount") amount, ok := new(big.Int).SetString(amountStr, 10) if !ok { - apiutils.WriteErrorResponse(w, fmt.Errorf("invalid amount: %s", amountStr)) + response.WriteErrorResponse(w, fmt.Errorf("invalid amount: %s", amountStr)) return } submit := r.FormValue("submit") == "true" opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := rescueDissolvedMinipool(c, addr, amount, submit, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) } diff --git a/rocketpool/api/minipool/stake.go b/rocketpool/api/minipool/stake.go index 48e42e4c1..74907c9dc 100644 --- a/rocketpool/api/minipool/stake.go +++ b/rocketpool/api/minipool/stake.go @@ -139,9 +139,9 @@ func canStakeMinipool(c *cli.Command, minipoolAddress common.Address) (*api.CanS // Get the gas limit signature := rptypes.BytesToValidatorSignature(depositData.Signature) - gasInfo, err := mp.EstimateStakeGas(signature, depositDataRoot, opts) + gasLimits, err := mp.EstimateStakeGas(signature, depositDataRoot, opts) if err == nil { - response.GasInfo = gasInfo + response.GasLimits = gasLimits } } diff --git a/rocketpool/api/network/routes.go b/rocketpool/api/network/routes.go index bc07a5b61..af3eb5db0 100644 --- a/rocketpool/api/network/routes.go +++ b/rocketpool/api/network/routes.go @@ -4,71 +4,70 @@ import ( "net/http" "strconv" + "github.com/rocket-pool/smartnode/rocketpool/api/response" "github.com/urfave/cli/v3" - - apiutils "github.com/rocket-pool/smartnode/shared/utils/api" ) // RegisterRoutes registers the network module's HTTP routes onto mux. func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { mux.HandleFunc("/api/network/node-fee", func(w http.ResponseWriter, r *http.Request) { resp, err := getNodeFee(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/network/rpl-price", func(w http.ResponseWriter, r *http.Request) { resp, err := getRplPrice(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/network/stats", func(w http.ResponseWriter, r *http.Request) { resp, err := getStats(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/network/timezone-map", func(w http.ResponseWriter, r *http.Request) { resp, err := getTimezones(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/network/can-generate-rewards-tree", func(w http.ResponseWriter, r *http.Request) { index, err := parseUint64Param(r, "index") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canGenerateRewardsTree(c, index) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/network/generate-rewards-tree", func(w http.ResponseWriter, r *http.Request) { index, err := parseUint64Param(r, "index") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := generateRewardsTree(c, index) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/network/dao-proposals", func(w http.ResponseWriter, r *http.Request) { resp, err := getActiveDAOProposals(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/network/download-rewards-file", func(w http.ResponseWriter, r *http.Request) { interval, err := parseUint64Param(r, "interval") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := downloadRewardsFile(c, interval) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/network/latest-delegate", func(w http.ResponseWriter, r *http.Request) { resp, err := getLatestDelegate(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) } diff --git a/rocketpool/api/node/burn.go b/rocketpool/api/node/burn.go index e003f5406..c8c9b6c7f 100644 --- a/rocketpool/api/node/burn.go +++ b/rocketpool/api/node/burn.go @@ -84,9 +84,9 @@ func canNodeBurn(c *cli.Command, amountWei *big.Int, token string) (*api.CanNode } switch token { case "reth": - gasInfo, err := tokens.EstimateBurnRETHGas(rp, amountWei, opts) + gasLimits, err := tokens.EstimateBurnRETHGas(rp, amountWei, opts) if err == nil { - response.GasInfo = gasInfo + response.GasLimits = gasLimits } return err } diff --git a/rocketpool/api/node/claim-rewards.go b/rocketpool/api/node/claim-rewards.go index d6a62ca60..131574c9c 100644 --- a/rocketpool/api/node/claim-rewards.go +++ b/rocketpool/api/node/claim-rewards.go @@ -16,6 +16,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/node" "github.com/rocket-pool/smartnode/bindings/rewards" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/shared/services" @@ -226,17 +227,16 @@ func canClaimRewards(c *cli.Command, indicesString string) (*api.CanNodeClaimRew return nil, err } - var gasInfo rocketpool.GasInfo + var gasLimits gaslimit.Limits claims, err := getRewardsForIntervals(rp, cfg, nodeAccount.Address, indicesString) if err != nil { return nil, err } - gasInfo, err = rewards.EstimateClaimGas(rp, nodeAccount.Address, claims, opts) + gasLimits, err = rewards.EstimateClaimGas(rp, nodeAccount.Address, claims, opts) if err != nil { return nil, err } - - response.GasInfo = gasInfo + response.GasLimits = gasLimits return &response, nil } @@ -323,11 +323,11 @@ func canClaimAndStakeRewards(c *cli.Command, indicesString string, stakeAmount * if err != nil { return nil, err } - gasInfo, err := rewards.EstimateClaimAndStakeGas(rp, nodeAccount.Address, claims, stakeAmount, opts) + gasLimits, err := rewards.EstimateClaimAndStakeGas(rp, nodeAccount.Address, claims, stakeAmount, opts) if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits return &response, nil diff --git a/rocketpool/api/node/claim-rpl.go b/rocketpool/api/node/claim-rpl.go index f813be4d8..26828c0e2 100644 --- a/rocketpool/api/node/claim-rpl.go +++ b/rocketpool/api/node/claim-rpl.go @@ -67,11 +67,11 @@ func canNodeClaimRpl(c *cli.Command) (*api.CanNodeClaimRplResponse, error) { if err != nil { return nil, err } - gasInfo, err := rewards.EstimateClaimNodeRewardsGas(rp, opts, &legacyClaimNodeAddress) + gasLimits, err := rewards.EstimateClaimNodeRewardsGas(rp, opts, &legacyClaimNodeAddress) if err != nil { return nil, fmt.Errorf("Could not estimate the gas required to claim RPL: %w", err) } - response.GasInfo = gasInfo + response.GasLimits = gasLimits return &response, nil } diff --git a/rocketpool/api/node/claim-unclaimed-rewards.go b/rocketpool/api/node/claim-unclaimed-rewards.go index cfb3fcf17..ee722d6a2 100644 --- a/rocketpool/api/node/claim-unclaimed-rewards.go +++ b/rocketpool/api/node/claim-unclaimed-rewards.go @@ -41,7 +41,7 @@ func canClaimUnclaimedRewards(c *cli.Command, nodeAddress common.Address) (*api. if err != nil { return nil, err } - response.GasInfo, err = node.EstimateClaimUnclaimedRewards(rp, nodeAddress, opts) + response.GasLimits, err = node.EstimateClaimUnclaimedRewards(rp, nodeAddress, opts) if err != nil { return nil, err } diff --git a/rocketpool/api/node/create-vacant-minipool.go b/rocketpool/api/node/create-vacant-minipool.go index 8e56151e7..5f0d2623e 100644 --- a/rocketpool/api/node/create-vacant-minipool.go +++ b/rocketpool/api/node/create-vacant-minipool.go @@ -145,11 +145,11 @@ func canCreateVacantMinipool(c *cli.Command, amountWei *big.Int, minNodeFee floa balanceWei.Mul(balanceWei, big.NewInt(1e9)) // Run the deposit gas estimator - gasInfo, err := node.EstimateCreateVacantMinipoolGas(rp, amountWei, minNodeFee, pubkey, salt, minipoolAddress, balanceWei, opts) + gasLimits, err := node.EstimateCreateVacantMinipoolGas(rp, amountWei, minNodeFee, pubkey, salt, minipoolAddress, balanceWei, opts) if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits return &response, nil diff --git a/rocketpool/api/node/deposit.go b/rocketpool/api/node/deposit.go index 663f2a712..9dab21f7d 100644 --- a/rocketpool/api/node/deposit.go +++ b/rocketpool/api/node/deposit.go @@ -284,11 +284,11 @@ func canNodeDeposits(c *cli.Command, count uint64, amountWei *big.Int, minNodeFe return nil, fmt.Errorf("count must be greater than 0") } - gasInfo, err := node.EstimateDepositMultiGas(rp, deposits, opts) + gasLimits, err := node.EstimateDepositMultiGas(rp, deposits, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for depositMulti: %w", err) } - response.GasInfo = gasInfo + response.GasLimits = gasLimits return &response, nil diff --git a/rocketpool/api/node/distributor.go b/rocketpool/api/node/distributor.go index c12831b88..60f423ff5 100644 --- a/rocketpool/api/node/distributor.go +++ b/rocketpool/api/node/distributor.go @@ -87,11 +87,11 @@ func getInitializeFeeDistributorGas(c *cli.Command) (*api.NodeInitializeFeeDistr if err != nil { return nil, err } - gasInfo, err := node.EstimateInitializeFeeDistributorGas(rp, opts) + gasLimits, err := node.EstimateInitializeFeeDistributorGas(rp, opts) if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits // Return response return &response, nil @@ -187,8 +187,8 @@ func canDistribute(c *cli.Command) (*api.NodeCanDistributeResponse, error) { if err != nil { return err } - gasInfo, err := distributor.EstimateDistributeGas(opts) - response.GasInfo = gasInfo + gasLimits, err := distributor.EstimateDistributeGas(opts) + response.GasLimits = gasLimits return err }) diff --git a/rocketpool/api/node/express-ticket.go b/rocketpool/api/node/express-ticket.go index f4138c6ba..e2bc01a3c 100644 --- a/rocketpool/api/node/express-ticket.go +++ b/rocketpool/api/node/express-ticket.go @@ -103,11 +103,11 @@ func canProvisionExpressTickets(c *cli.Command) (*api.CanProvisionExpressTickets if err != nil { return nil, err } - gasInfo, err := node.EstimateProvisionExpressTicketsGas(rp, nodeAccount.Address, opts) + gasLimits, err := node.EstimateProvisionExpressTicketsGas(rp, nodeAccount.Address, opts) if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits // Check data response.CanProvision = !(response.AlreadyProvisioned) diff --git a/rocketpool/api/node/primary-withdrawal-address.go b/rocketpool/api/node/primary-withdrawal-address.go index 5681f2543..4360d8e21 100644 --- a/rocketpool/api/node/primary-withdrawal-address.go +++ b/rocketpool/api/node/primary-withdrawal-address.go @@ -44,11 +44,11 @@ func canSetPrimaryWithdrawalAddress(c *cli.Command, withdrawalAddress common.Add } // Check withdrawal address setting - gasInfo, err := storage.EstimateSetWithdrawalAddressGas(rp, nodeAccount.Address, withdrawalAddress, confirm, opts) + gasLimits, err := storage.EstimateSetWithdrawalAddressGas(rp, nodeAccount.Address, withdrawalAddress, confirm, opts) if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits // Return response response.CanSet = true @@ -138,11 +138,11 @@ func canConfirmPrimaryWithdrawalAddress(c *cli.Command) (*api.CanConfirmNodePrim } // Check withdrawal address setting - gasInfo, err := storage.EstimateConfirmWithdrawalAddressGas(rp, nodeAccount.Address, opts) + gasLimits, err := storage.EstimateConfirmWithdrawalAddressGas(rp, nodeAccount.Address, opts) if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits // Return response response.CanConfirm = (pendingAddress != nodeAccount.Address) diff --git a/rocketpool/api/node/register.go b/rocketpool/api/node/register.go index dddd55d9a..629d2d897 100644 --- a/rocketpool/api/node/register.go +++ b/rocketpool/api/node/register.go @@ -66,9 +66,9 @@ func canRegisterNode(c *cli.Command, timezoneLocation string) (*api.CanRegisterN if err != nil { return err } - gasInfo, err := node.EstimateRegisterNodeGas(rp, timezoneLocation, opts) + gasLimits, err := node.EstimateRegisterNodeGas(rp, timezoneLocation, opts) if err == nil { - response.GasInfo = gasInfo + response.GasLimits = gasLimits } return err }) diff --git a/rocketpool/api/node/routes.go b/rocketpool/api/node/routes.go index 154a35bb1..cc7e589f5 100644 --- a/rocketpool/api/node/routes.go +++ b/rocketpool/api/node/routes.go @@ -11,46 +11,46 @@ import ( "github.com/urfave/cli/v3" rptypes "github.com/rocket-pool/smartnode/bindings/types" + "github.com/rocket-pool/smartnode/rocketpool/api/response" "github.com/rocket-pool/smartnode/shared/services" - apiutils "github.com/rocket-pool/smartnode/shared/utils/api" ) // RegisterRoutes registers the node module's HTTP routes onto mux. func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { mux.HandleFunc("/api/node/status", func(w http.ResponseWriter, r *http.Request) { resp, err := getStatus(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/alerts", func(w http.ResponseWriter, r *http.Request) { resp, err := getAlerts(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/sync", func(w http.ResponseWriter, r *http.Request) { resp, err := getSyncProgress(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/get-eth-balance", func(w http.ResponseWriter, r *http.Request) { resp, err := getNodeEthBalance(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/check-collateral", func(w http.ResponseWriter, r *http.Request) { resp, err := checkCollateral(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/rewards", func(w http.ResponseWriter, r *http.Request) { resp, err := getRewards(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/deposit-contract-info", func(w http.ResponseWriter, r *http.Request) { resp, err := getDepositContractInfo(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) // --- Register --- @@ -58,18 +58,18 @@ func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { mux.HandleFunc("/api/node/can-register", func(w http.ResponseWriter, r *http.Request) { tz := r.URL.Query().Get("timezoneLocation") resp, err := canRegisterNode(c, tz) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/register", func(w http.ResponseWriter, r *http.Request) { tz := r.FormValue("timezoneLocation") opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := registerNode(c, tz, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) // --- Timezone --- @@ -77,18 +77,18 @@ func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { mux.HandleFunc("/api/node/can-set-timezone", func(w http.ResponseWriter, r *http.Request) { tz := r.URL.Query().Get("timezoneLocation") resp, err := canSetTimezoneLocation(c, tz) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/set-timezone", func(w http.ResponseWriter, r *http.Request) { tz := r.FormValue("timezoneLocation") opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := setTimezoneLocation(c, tz, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) // --- Primary withdrawal address --- @@ -97,7 +97,7 @@ func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { addr := common.HexToAddress(r.URL.Query().Get("address")) confirm := r.URL.Query().Get("confirm") == "true" resp, err := canSetPrimaryWithdrawalAddress(c, addr, confirm) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/set-primary-withdrawal-address", func(w http.ResponseWriter, r *http.Request) { @@ -105,26 +105,26 @@ func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { confirm := r.FormValue("confirm") == "true" opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := setPrimaryWithdrawalAddress(c, addr, confirm, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/can-confirm-primary-withdrawal-address", func(w http.ResponseWriter, r *http.Request) { resp, err := canConfirmPrimaryWithdrawalAddress(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/confirm-primary-withdrawal-address", func(w http.ResponseWriter, r *http.Request) { opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := confirmPrimaryWithdrawalAddress(c, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) // --- RPL withdrawal address --- @@ -133,7 +133,7 @@ func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { addr := common.HexToAddress(r.URL.Query().Get("address")) confirm := r.URL.Query().Get("confirm") == "true" resp, err := canSetRPLWithdrawalAddress(c, addr, confirm) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/set-rpl-withdrawal-address", func(w http.ResponseWriter, r *http.Request) { @@ -141,172 +141,172 @@ func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { confirm := r.FormValue("confirm") == "true" opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := setRPLWithdrawalAddress(c, addr, confirm, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/can-confirm-rpl-withdrawal-address", func(w http.ResponseWriter, r *http.Request) { resp, err := canConfirmRPLWithdrawalAddress(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/confirm-rpl-withdrawal-address", func(w http.ResponseWriter, r *http.Request) { opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := confirmRPLWithdrawalAddress(c, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) // --- Swap RPL --- mux.HandleFunc("/api/node/swap-rpl-allowance", func(w http.ResponseWriter, r *http.Request) { resp, err := allowanceFsRpl(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/can-swap-rpl", func(w http.ResponseWriter, r *http.Request) { amountWei, err := parseNodeBigInt(r, "amountWei") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canNodeSwapRpl(c, amountWei) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/get-swap-rpl-approval-gas", func(w http.ResponseWriter, r *http.Request) { amountWei, err := parseNodeBigInt(r, "amountWei") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := getSwapApprovalGas(c, amountWei) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/swap-rpl-approve-rpl", func(w http.ResponseWriter, r *http.Request) { amountWei, err := parseNodeBigInt(r, "amountWei") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := approveFsRpl(c, amountWei, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/wait-and-swap-rpl", func(w http.ResponseWriter, r *http.Request) { amountWei, err := parseNodeBigInt(r, "amountWei") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } hash := common.HexToHash(r.FormValue("approvalTxHash")) opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := waitForApprovalAndSwapFsRpl(c, amountWei, hash, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/swap-rpl", func(w http.ResponseWriter, r *http.Request) { amountWei, err := parseNodeBigInt(r, "amountWei") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := swapRpl(c, amountWei, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) // --- Stake RPL --- mux.HandleFunc("/api/node/stake-rpl-allowance", func(w http.ResponseWriter, r *http.Request) { resp, err := allowanceRpl(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/can-stake-rpl", func(w http.ResponseWriter, r *http.Request) { amountWei, err := parseNodeBigInt(r, "amountWei") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canNodeStakeRpl(c, amountWei) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/get-stake-rpl-approval-gas", func(w http.ResponseWriter, r *http.Request) { amountWei, err := parseNodeBigInt(r, "amountWei") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := getStakeApprovalGas(c, amountWei) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/stake-rpl-approve-rpl", func(w http.ResponseWriter, r *http.Request) { amountWei, err := parseNodeBigInt(r, "amountWei") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := approveRpl(c, amountWei, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/wait-and-stake-rpl", func(w http.ResponseWriter, r *http.Request) { amountWei, err := parseNodeBigInt(r, "amountWei") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } hash := common.HexToHash(r.FormValue("approvalTxHash")) opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := waitForApprovalAndStakeRpl(c, amountWei, hash, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/stake-rpl", func(w http.ResponseWriter, r *http.Request) { amountWei, err := parseNodeBigInt(r, "amountWei") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := stakeRpl(c, amountWei, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) // --- RPL locking --- @@ -314,18 +314,18 @@ func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { mux.HandleFunc("/api/node/can-set-rpl-locking-allowed", func(w http.ResponseWriter, r *http.Request) { allowed := r.URL.Query().Get("allowed") == "true" resp, err := canSetRplLockAllowed(c, allowed) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/set-rpl-locking-allowed", func(w http.ResponseWriter, r *http.Request) { allowed := r.FormValue("allowed") == "true" opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := setRplLockAllowed(c, allowed, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) // --- Stake RPL for allowed --- @@ -334,7 +334,7 @@ func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { caller := common.HexToAddress(r.URL.Query().Get("caller")) allowed := r.URL.Query().Get("allowed") == "true" resp, err := canSetStakeRplForAllowed(c, caller, allowed) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/set-stake-rpl-for-allowed", func(w http.ResponseWriter, r *http.Request) { @@ -342,103 +342,103 @@ func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { allowed := r.FormValue("allowed") == "true" opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := setStakeRplForAllowed(c, caller, allowed, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) // --- Withdraw RPL --- mux.HandleFunc("/api/node/can-withdraw-rpl", func(w http.ResponseWriter, r *http.Request) { resp, err := canNodeWithdrawRpl(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/withdraw-rpl", func(w http.ResponseWriter, r *http.Request) { opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := nodeWithdrawRpl(c, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/can-unstake-legacy-rpl", func(w http.ResponseWriter, r *http.Request) { amountWei, err := parseNodeBigInt(r, "amountWei") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canNodeUnstakeLegacyRpl(c, amountWei) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/unstake-legacy-rpl", func(w http.ResponseWriter, r *http.Request) { amountWei, err := parseNodeBigInt(r, "amountWei") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := nodeUnstakeLegacyRpl(c, amountWei, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/can-withdraw-rpl-v131", func(w http.ResponseWriter, r *http.Request) { amountWei, err := parseNodeBigInt(r, "amountWei") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canNodeWithdrawRplv1_3_1(c, amountWei) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/withdraw-rpl-v131", func(w http.ResponseWriter, r *http.Request) { amountWei, err := parseNodeBigInt(r, "amountWei") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := nodeWithdrawRplv1_3_1(c, amountWei, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/can-unstake-rpl", func(w http.ResponseWriter, r *http.Request) { amountWei, err := parseNodeBigInt(r, "amountWei") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canNodeUnstakeRpl(c, amountWei) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/unstake-rpl", func(w http.ResponseWriter, r *http.Request) { amountWei, err := parseNodeBigInt(r, "amountWei") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := nodeUnstakeRpl(c, amountWei, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) // --- Withdraw ETH / credit --- @@ -446,51 +446,51 @@ func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { mux.HandleFunc("/api/node/can-withdraw-eth", func(w http.ResponseWriter, r *http.Request) { amountWei, err := parseNodeBigInt(r, "amountWei") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canNodeWithdrawEth(c, amountWei) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/withdraw-eth", func(w http.ResponseWriter, r *http.Request) { amountWei, err := parseNodeBigInt(r, "amountWei") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := nodeWithdrawEth(c, amountWei, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/can-withdraw-credit", func(w http.ResponseWriter, r *http.Request) { amountWei, err := parseNodeBigInt(r, "amountWei") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canNodeWithdrawCredit(c, amountWei) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/withdraw-credit", func(w http.ResponseWriter, r *http.Request) { amountWei, err := parseNodeBigInt(r, "amountWei") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := nodeWithdrawCredit(c, amountWei, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) // --- Deposit --- @@ -498,26 +498,26 @@ func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { mux.HandleFunc("/api/node/can-deposit", func(w http.ResponseWriter, r *http.Request) { params, err := parseDepositParams(r, false) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canNodeDeposits(c, params.count, params.amountWei, params.minFee, params.salt, params.expressTickets) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/deposit", func(w http.ResponseWriter, r *http.Request) { params, err := parseDepositParams(r, true) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := nodeDeposits(c, params.count, params.amountWei, params.minFee, params.salt, params.useCreditBalance, params.expressTickets, params.submit, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) // --- Send / burn --- @@ -525,30 +525,30 @@ func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { mux.HandleFunc("/api/node/can-send", func(w http.ResponseWriter, r *http.Request) { amountRaw, err := parseNodeFloat64(r, "amountRaw") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } token := r.URL.Query().Get("token") to := common.HexToAddress(r.URL.Query().Get("to")) resp, err := canNodeSend(c, amountRaw, token, to) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/send", func(w http.ResponseWriter, r *http.Request) { amountRaw, err := parseNodeFloat64(r, "amountRaw") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } token := r.FormValue("token") to := common.HexToAddress(r.FormValue("to")) opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := nodeSend(c, amountRaw, token, to, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/send-all", func(w http.ResponseWriter, r *http.Request) { @@ -556,171 +556,171 @@ func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { to := common.HexToAddress(r.FormValue("to")) opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := nodeSendAllTokens(c, token, to, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/can-burn", func(w http.ResponseWriter, r *http.Request) { amountWei, err := parseNodeBigInt(r, "amountWei") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } token := r.URL.Query().Get("token") resp, err := canNodeBurn(c, amountWei, token) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/burn", func(w http.ResponseWriter, r *http.Request) { amountWei, err := parseNodeBigInt(r, "amountWei") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } token := r.FormValue("token") opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := nodeBurn(c, amountWei, token, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) // --- RPL claim --- mux.HandleFunc("/api/node/can-claim-rpl-rewards", func(w http.ResponseWriter, r *http.Request) { resp, err := canNodeClaimRpl(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/claim-rpl-rewards", func(w http.ResponseWriter, r *http.Request) { opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := nodeClaimRpl(c, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) // --- Fee distributor --- mux.HandleFunc("/api/node/is-fee-distributor-initialized", func(w http.ResponseWriter, r *http.Request) { resp, err := isFeeDistributorInitialized(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/get-initialize-fee-distributor-gas", func(w http.ResponseWriter, r *http.Request) { resp, err := getInitializeFeeDistributorGas(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/initialize-fee-distributor", func(w http.ResponseWriter, r *http.Request) { opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := initializeFeeDistributor(c, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/can-distribute", func(w http.ResponseWriter, r *http.Request) { resp, err := canDistribute(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/distribute", func(w http.ResponseWriter, r *http.Request) { opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := distribute(c, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) // --- Interval rewards --- mux.HandleFunc("/api/node/get-rewards-info", func(w http.ResponseWriter, r *http.Request) { resp, err := getRewardsInfo(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/can-claim-rewards", func(w http.ResponseWriter, r *http.Request) { indices := r.URL.Query().Get("indices") resp, err := canClaimRewards(c, indices) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/claim-rewards", func(w http.ResponseWriter, r *http.Request) { indices := r.FormValue("indices") opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := claimRewards(c, indices, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/can-claim-and-stake-rewards", func(w http.ResponseWriter, r *http.Request) { indices := r.URL.Query().Get("indices") stakeAmount, err := parseNodeBigInt(r, "stakeAmount") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canClaimAndStakeRewards(c, indices, stakeAmount) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/claim-and-stake-rewards", func(w http.ResponseWriter, r *http.Request) { indices := r.FormValue("indices") stakeAmount, err := parseNodeBigInt(r, "stakeAmount") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := claimAndStakeRewards(c, indices, stakeAmount, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) // --- Smoothing pool --- mux.HandleFunc("/api/node/get-smoothing-pool-registration-status", func(w http.ResponseWriter, r *http.Request) { resp, err := getSmoothingPoolRegistrationStatus(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/can-set-smoothing-pool-status", func(w http.ResponseWriter, r *http.Request) { if !r.URL.Query().Has("status") { - apiutils.WriteErrorResponse(w, &apiutils.BadRequestError{Err: fmt.Errorf("missing required parameter 'status'")}) + response.WriteErrorResponse(w, &response.BadRequestError{Err: fmt.Errorf("missing required parameter 'status'")}) return } status := r.URL.Query().Get("status") == "true" resp, err := canSetSmoothingPoolStatus(c, status) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/set-smoothing-pool-status", func(w http.ResponseWriter, r *http.Request) { status := r.FormValue("status") == "true" opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := setSmoothingPoolStatus(c, status, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) // --- ENS --- @@ -728,13 +728,13 @@ func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { mux.HandleFunc("/api/node/resolve-ens-name", func(w http.ResponseWriter, r *http.Request) { name := r.URL.Query().Get("name") resp, err := resolveEnsName(c, name) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/reverse-resolve-ens-name", func(w http.ResponseWriter, r *http.Request) { addr := common.HexToAddress(r.URL.Query().Get("address")) resp, err := reverseResolveEnsName(c, addr) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) // --- Sign --- @@ -742,13 +742,13 @@ func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { mux.HandleFunc("/api/node/sign-message", func(w http.ResponseWriter, r *http.Request) { message := r.FormValue("message") resp, err := signMessage(c, message) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/sign", func(w http.ResponseWriter, r *http.Request) { serializedTx := r.FormValue("serializedTx") resp, err := sign(c, serializedTx) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) // --- Vacant minipool --- @@ -756,26 +756,26 @@ func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { mux.HandleFunc("/api/node/can-create-vacant-minipool", func(w http.ResponseWriter, r *http.Request) { params, err := parseVacantMinipoolParams(r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canCreateVacantMinipool(c, params.amountWei, params.minFee, params.salt, params.pubkey) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/create-vacant-minipool", func(w http.ResponseWriter, r *http.Request) { params, err := parseVacantMinipoolParams(r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := createVacantMinipool(c, params.amountWei, params.minFee, params.salt, params.pubkey, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) // --- Send message --- @@ -784,54 +784,54 @@ func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { addr := common.HexToAddress(r.URL.Query().Get("address")) msgBytes, err := hex.DecodeString(r.URL.Query().Get("message")) if err != nil { - apiutils.WriteErrorResponse(w, fmt.Errorf("invalid message hex: %w", err)) + response.WriteErrorResponse(w, fmt.Errorf("invalid message hex: %w", err)) return } resp, err := canSendMessage(c, addr, msgBytes) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/send-message", func(w http.ResponseWriter, r *http.Request) { addr := common.HexToAddress(r.FormValue("address")) msgBytes, err := hex.DecodeString(r.FormValue("message")) if err != nil { - apiutils.WriteErrorResponse(w, fmt.Errorf("invalid message hex: %w", err)) + response.WriteErrorResponse(w, fmt.Errorf("invalid message hex: %w", err)) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := sendMessage(c, addr, msgBytes, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) // --- Express tickets --- mux.HandleFunc("/api/node/get-express-ticket-count", func(w http.ResponseWriter, r *http.Request) { resp, err := getExpressTicketCount(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/get-express-tickets-provisioned", func(w http.ResponseWriter, r *http.Request) { resp, err := getExpressTicketsProvisioned(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/can-provision-express-tickets", func(w http.ResponseWriter, r *http.Request) { resp, err := canProvisionExpressTickets(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/provision-express-tickets", func(w http.ResponseWriter, r *http.Request) { opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := provisionExpressTickets(c, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) // --- Unclaimed rewards --- @@ -839,18 +839,18 @@ func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { mux.HandleFunc("/api/node/can-claim-unclaimed-rewards", func(w http.ResponseWriter, r *http.Request) { nodeAddr := common.HexToAddress(r.URL.Query().Get("nodeAddress")) resp, err := canClaimUnclaimedRewards(c, nodeAddr) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/node/claim-unclaimed-rewards", func(w http.ResponseWriter, r *http.Request) { nodeAddr := common.HexToAddress(r.FormValue("nodeAddress")) opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := claimUnclaimedRewards(c, nodeAddr, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) // --- Bond requirement --- @@ -858,11 +858,11 @@ func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { mux.HandleFunc("/api/node/get-bond-requirement", func(w http.ResponseWriter, r *http.Request) { numValidators, err := strconv.ParseUint(r.URL.Query().Get("numValidators"), 10, 64) if err != nil { - apiutils.WriteErrorResponse(w, fmt.Errorf("invalid numValidators: %w", err)) + response.WriteErrorResponse(w, fmt.Errorf("invalid numValidators: %w", err)) return } resp, err := getBondRequirement(c, numValidators) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) } diff --git a/rocketpool/api/node/rpl-withdrawal-address.go b/rocketpool/api/node/rpl-withdrawal-address.go index e6084b156..5c5d71b7e 100644 --- a/rocketpool/api/node/rpl-withdrawal-address.go +++ b/rocketpool/api/node/rpl-withdrawal-address.go @@ -93,11 +93,11 @@ func canSetRPLWithdrawalAddress(c *cli.Command, withdrawalAddress common.Address } // Check withdrawal address setting - gasInfo, err := node.EstimateSetRPLWithdrawalAddressGas(rp, nodeAccount.Address, withdrawalAddress, confirm, opts) + gasLimits, err := node.EstimateSetRPLWithdrawalAddressGas(rp, nodeAccount.Address, withdrawalAddress, confirm, opts) if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits // Return response return &response, nil @@ -178,11 +178,11 @@ func canConfirmRPLWithdrawalAddress(c *cli.Command) (*api.CanConfirmNodeRPLWithd } // Check withdrawal address setting - gasInfo, err := node.EstimateConfirmRPLWithdrawalAddressGas(rp, nodeAccount.Address, opts) + gasLimits, err := node.EstimateConfirmRPLWithdrawalAddressGas(rp, nodeAccount.Address, opts) if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits // Return response return &response, nil diff --git a/rocketpool/api/node/send-message.go b/rocketpool/api/node/send-message.go index 305371425..ed8414f19 100644 --- a/rocketpool/api/node/send-message.go +++ b/rocketpool/api/node/send-message.go @@ -3,7 +3,7 @@ package node import ( "fmt" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/bindings/transactions" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" @@ -37,12 +37,12 @@ func canSendMessage(c *cli.Command, address common.Address, message []byte) (*ap return nil, err } - gasInfo, err := eth.EstimateSendTransactionGas(ec, address, message, true, opts) + gasLimits, err := transactions.EstimateSendTransactionGas(ec, address, message, true, opts) if err != nil { return nil, fmt.Errorf("error estimating gas to send message: %w", err) } - response.GasInfo = gasInfo + response.GasLimits = gasLimits return &response, nil @@ -67,7 +67,7 @@ func sendMessage(c *cli.Command, address common.Address, message []byte, opts *b response := api.NodeSendMessageResponse{} // Send the message - hash, err := eth.SendTransaction(ec, address, w.GetChainID(), message, true, opts) + hash, err := transactions.SendTransaction(ec, address, w.GetChainID(), message, true, opts) if err != nil { return nil, fmt.Errorf("error sending message: %w", err) } diff --git a/rocketpool/api/node/send.go b/rocketpool/api/node/send.go index beb3c97c9..47bc06ef3 100644 --- a/rocketpool/api/node/send.go +++ b/rocketpool/api/node/send.go @@ -11,7 +11,9 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/urfave/cli/v3" + "github.com/rocket-pool/smartnode/bindings/erc20" "github.com/rocket-pool/smartnode/bindings/tokens" + "github.com/rocket-pool/smartnode/bindings/transactions" "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/shared/services" @@ -97,7 +99,7 @@ func canNodeSend(c *cli.Command, amountRaw float64, token string, to common.Addr } // Create the ERC20 binding - contract, err := eth.NewErc20Contract(tokenAddress, ec, nil) + contract, err := erc20.NewErc20Contract(tokenAddress, ec, nil) if err != nil { return nil, fmt.Errorf("error creating ERC20 contract binding: %w", err) } @@ -116,11 +118,11 @@ func canNodeSend(c *cli.Command, amountRaw float64, token string, to common.Addr response.InsufficientBalance = (amountWei.Cmp(balance) > 0) // Get the gas info - gasInfo, err := contract.EstimateTransferGas(to, amountWei, opts) + gasLimits, err := contract.EstimateTransferGas(to, amountWei, opts) if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits } else { // Handle well-known token types amountWei := eth.EthToWei(amountRaw) @@ -134,11 +136,11 @@ func canNodeSend(c *cli.Command, amountRaw float64, token string, to common.Addr return nil, err } response.InsufficientBalance = (amountWei.Cmp(balanceWei) > 0) - gasInfo, err := eth.EstimateSendTransactionGas(ec, to, nil, false, opts) + gasLimits, err := transactions.EstimateSendTransactionGas(ec, to, nil, false, opts) if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits case "rpl": @@ -152,11 +154,11 @@ func canNodeSend(c *cli.Command, amountRaw float64, token string, to common.Addr return nil, err } response.InsufficientBalance = (amountWei.Cmp(balanceWei) > 0) - gasInfo, err := tokens.EstimateTransferRPLGas(rp, to, amountWei, opts) + gasLimits, err := tokens.EstimateTransferRPLGas(rp, to, amountWei, opts) if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits case "fsrpl": @@ -170,11 +172,11 @@ func canNodeSend(c *cli.Command, amountRaw float64, token string, to common.Addr return nil, err } response.InsufficientBalance = (amountWei.Cmp(balanceWei) > 0) - gasInfo, err := tokens.EstimateTransferFixedSupplyRPLGas(rp, to, amountWei, opts) + gasLimits, err := tokens.EstimateTransferFixedSupplyRPLGas(rp, to, amountWei, opts) if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits case "reth": @@ -188,11 +190,11 @@ func canNodeSend(c *cli.Command, amountRaw float64, token string, to common.Addr return nil, err } response.InsufficientBalance = (amountWei.Cmp(balanceWei) > 0) - gasInfo, err := tokens.EstimateTransferRETHGas(rp, to, amountWei, opts) + gasLimits, err := tokens.EstimateTransferRETHGas(rp, to, amountWei, opts) if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits } response.Balance = eth.WeiToEth(balanceWei) @@ -229,7 +231,7 @@ func nodeSend(c *cli.Command, amountRaw float64, token string, to common.Address // Handle explicit token addresses if strings.HasPrefix(token, "0x") { tokenAddress := common.HexToAddress(token) - contract, err := eth.NewErc20Contract(tokenAddress, ec, nil) + contract, err := erc20.NewErc20Contract(tokenAddress, ec, nil) if err != nil { return nil, fmt.Errorf("error creating ERC20 contract binding: %w", err) } @@ -249,7 +251,7 @@ func nodeSend(c *cli.Command, amountRaw float64, token string, to common.Address // Transfer ETH opts.Value = amountWei - hash, err := eth.SendTransaction(ec, to, w.GetChainID(), nil, false, opts) + hash, err := transactions.SendTransaction(ec, to, w.GetChainID(), nil, false, opts) if err != nil { return nil, err } @@ -337,7 +339,7 @@ func nodeSendAllTokens(c *cli.Command, token string, to common.Address, opts *bi // Handle explicit token addresses if strings.HasPrefix(token, "0x") { tokenAddress := common.HexToAddress(token) - contract, err := eth.NewErc20Contract(tokenAddress, ec, nil) + contract, err := erc20.NewErc20Contract(tokenAddress, ec, nil) if err != nil { return nil, fmt.Errorf("error creating ERC20 contract binding: %w", err) } diff --git a/rocketpool/api/node/set-rpl-lock-allowed.go b/rocketpool/api/node/set-rpl-lock-allowed.go index 1cb64317d..93f2dffa3 100644 --- a/rocketpool/api/node/set-rpl-lock-allowed.go +++ b/rocketpool/api/node/set-rpl-lock-allowed.go @@ -44,11 +44,11 @@ func canSetRplLockAllowed(c *cli.Command, allowed bool) (*api.CanSetRplLockingAl if err != nil { return nil, err } - gasInfo, err := node.EstimateSetStakeRPLForAllowedGas(rp, account.Address, allowed, opts) + gasLimits, err := node.EstimateSetStakeRPLForAllowedGas(rp, account.Address, allowed, opts) if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits // Update & return response response.CanSet = (!isAllowed && allowed) || (isAllowed && !allowed) diff --git a/rocketpool/api/node/set-stake-rpl-for-allowed.go b/rocketpool/api/node/set-stake-rpl-for-allowed.go index 87b50d68d..163773a0e 100644 --- a/rocketpool/api/node/set-stake-rpl-for-allowed.go +++ b/rocketpool/api/node/set-stake-rpl-for-allowed.go @@ -34,11 +34,11 @@ func canSetStakeRplForAllowed(c *cli.Command, caller common.Address, allowed boo if err != nil { return nil, err } - gasInfo, err := node.EstimateSetStakeRPLForAllowedGas(rp, caller, allowed, opts) + gasLimits, err := node.EstimateSetStakeRPLForAllowedGas(rp, caller, allowed, opts) if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits // Update & return response response.CanSet = true diff --git a/rocketpool/api/node/set-timezone.go b/rocketpool/api/node/set-timezone.go index be785870b..709eaa4f4 100644 --- a/rocketpool/api/node/set-timezone.go +++ b/rocketpool/api/node/set-timezone.go @@ -36,11 +36,11 @@ func canSetTimezoneLocation(c *cli.Command, timezoneLocation string) (*api.CanSe if err != nil { return nil, err } - gasInfo, err := node.EstimateSetTimezoneLocationGas(rp, timezoneLocation, opts) + gasLimits, err := node.EstimateSetTimezoneLocationGas(rp, timezoneLocation, opts) if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits response.CanSet = true return &response, nil diff --git a/rocketpool/api/node/smoothing-pool.go b/rocketpool/api/node/smoothing-pool.go index 26cc234f7..dcb3bd381 100644 --- a/rocketpool/api/node/smoothing-pool.go +++ b/rocketpool/api/node/smoothing-pool.go @@ -105,9 +105,9 @@ func canSetSmoothingPoolStatus(c *cli.Command, status bool) (*api.CanSetSmoothin if err != nil { return nil, err } - gasInfo, err := node.EstimateSetSmoothingPoolRegistrationStateGas(rp, status, opts) + gasLimits, err := node.EstimateSetSmoothingPoolRegistrationStateGas(rp, status, opts) if err == nil { - response.GasInfo = gasInfo + response.GasLimits = gasLimits } return &response, err diff --git a/rocketpool/api/node/stake-rpl.go b/rocketpool/api/node/stake-rpl.go index 5064e214c..6bdffac81 100644 --- a/rocketpool/api/node/stake-rpl.go +++ b/rocketpool/api/node/stake-rpl.go @@ -52,11 +52,11 @@ func canNodeStakeRpl(c *cli.Command, amountWei *big.Int) (*api.CanNodeStakeRplRe if err != nil { return nil, err } - gasInfo, err := node.EstimateStakeGas(rp, amountWei, opts) + gasLimits, err := node.EstimateStakeGas(rp, amountWei, opts) if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits // Update & return response response.CanStake = !(response.InsufficientBalance) @@ -95,11 +95,11 @@ func getStakeApprovalGas(c *cli.Command, amountWei *big.Int) (*api.NodeStakeRplA if err != nil { return nil, err } - gasInfo, err := tokens.EstimateApproveRPLGas(rp, *rocketNodeStakingAddress, amountWei, opts) + gasLimits, err := tokens.EstimateApproveRPLGas(rp, *rocketNodeStakingAddress, amountWei, opts) if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits return &response, nil } diff --git a/rocketpool/api/node/swap-rpl.go b/rocketpool/api/node/swap-rpl.go index 75095e15e..5bdb24cd4 100644 --- a/rocketpool/api/node/swap-rpl.go +++ b/rocketpool/api/node/swap-rpl.go @@ -53,11 +53,11 @@ func canNodeSwapRpl(c *cli.Command, amountWei *big.Int) (*api.CanNodeSwapRplResp if err != nil { return nil, err } - gasInfo, err := tokens.EstimateSwapFixedSupplyRPLForRPLGas(rp, amountWei, opts) + gasLimits, err := tokens.EstimateSwapFixedSupplyRPLForRPLGas(rp, amountWei, opts) if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits // Update & return response response.CanSwap = !response.InsufficientBalance @@ -137,11 +137,11 @@ func getSwapApprovalGas(c *cli.Command, amountWei *big.Int) (*api.NodeSwapRplApp if err != nil { return nil, err } - gasInfo, err := tokens.EstimateApproveFixedSupplyRPLGas(rp, *rocketTokenRPLAddress, amountWei, opts) + gasLimits, err := tokens.EstimateApproveFixedSupplyRPLGas(rp, *rocketTokenRPLAddress, amountWei, opts) if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits return &response, nil } diff --git a/rocketpool/api/node/unstake-rpl.go b/rocketpool/api/node/unstake-rpl.go index 5957e5aa8..9ff4d2e2b 100644 --- a/rocketpool/api/node/unstake-rpl.go +++ b/rocketpool/api/node/unstake-rpl.go @@ -79,9 +79,9 @@ func canNodeUnstakeRpl(c *cli.Command, amountWei *big.Int) (*api.CanNodeUnstakeR if err != nil { return err } - gasInfo, err := node.EstimateUnstakeGas(rp, amountWei, opts) + gasLimits, err := node.EstimateUnstakeGas(rp, amountWei, opts) if err == nil { - response.GasInfo = gasInfo + response.GasLimits = gasLimits } return err }) diff --git a/rocketpool/api/node/withdraw-credit.go b/rocketpool/api/node/withdraw-credit.go index 2541f2f84..d921e809d 100644 --- a/rocketpool/api/node/withdraw-credit.go +++ b/rocketpool/api/node/withdraw-credit.go @@ -54,9 +54,9 @@ func canNodeWithdrawCredit(c *cli.Command, amountWei *big.Int) (*api.CanNodeWith if err != nil { return err } - gasInfo, err := node.EstimateWithdrawCreditGas(rp, amountWei, opts) + gasLimits, err := node.EstimateWithdrawCreditGas(rp, amountWei, opts) if err == nil { - response.GasInfo = gasInfo + response.GasLimits = gasLimits } return err }) diff --git a/rocketpool/api/node/withdraw-eth.go b/rocketpool/api/node/withdraw-eth.go index a937b5298..af3d5ea7d 100644 --- a/rocketpool/api/node/withdraw-eth.go +++ b/rocketpool/api/node/withdraw-eth.go @@ -63,9 +63,9 @@ func canNodeWithdrawEth(c *cli.Command, amountWei *big.Int) (*api.CanNodeWithdra if err != nil { return err } - gasInfo, err := node.EstimateWithdrawEthGas(rp, nodeAccount.Address, amountWei, opts) + gasLimits, err := node.EstimateWithdrawEthGas(rp, nodeAccount.Address, amountWei, opts) if err == nil { - response.GasInfo = gasInfo + response.GasLimits = gasLimits } return err }) diff --git a/rocketpool/api/node/withdraw-legacy-rpl.go b/rocketpool/api/node/withdraw-legacy-rpl.go index fbd158e1c..61ffc84c3 100644 --- a/rocketpool/api/node/withdraw-legacy-rpl.go +++ b/rocketpool/api/node/withdraw-legacy-rpl.go @@ -87,9 +87,9 @@ func canNodeUnstakeLegacyRpl(c *cli.Command, amountWei *big.Int) (*api.CanNodeUn if err != nil { return err } - gasInfo, err := node.EstimateUnstakeLegacyRPLGas(rp, amountWei, opts) + gasLimits, err := node.EstimateUnstakeLegacyRPLGas(rp, amountWei, opts) if err == nil { - response.GasInfo = gasInfo + response.GasLimits = gasLimits } return err }) diff --git a/rocketpool/api/node/withdraw-rpl.go b/rocketpool/api/node/withdraw-rpl.go index 3268f7caf..9cc4e2f78 100644 --- a/rocketpool/api/node/withdraw-rpl.go +++ b/rocketpool/api/node/withdraw-rpl.go @@ -105,9 +105,9 @@ func canNodeWithdrawRpl(c *cli.Command) (*api.CanNodeWithdrawRplResponse, error) if err != nil { return err } - gasInfo, err := node.EstimateWithdrawRPLGas(rp, opts) + gasLimits, err := node.EstimateWithdrawRPLGas(rp, opts) if err == nil { - response.GasInfo = gasInfo + response.GasLimits = gasLimits } return err }) @@ -267,9 +267,9 @@ func canNodeWithdrawRplv1_3_1(c *cli.Command, amountWei *big.Int) (*api.CanNodeW if err != nil { return err } - gasInfo, err := node131.EstimateWithdrawRPLGas(rp, nodeAccount.Address, amountWei, opts) + gasLimits, err := node131.EstimateWithdrawRPLGas(rp, nodeAccount.Address, amountWei, opts) if err == nil { - response.GasInfo = gasInfo + response.GasLimits = gasLimits } return err }) diff --git a/rocketpool/api/odao/cancel-proposal.go b/rocketpool/api/odao/cancel-proposal.go index 9a105d2d0..6ee43f503 100644 --- a/rocketpool/api/odao/cancel-proposal.go +++ b/rocketpool/api/odao/cancel-proposal.go @@ -74,9 +74,9 @@ func canCancelProposal(c *cli.Command, proposalId uint64) (*api.CanCancelTNDAOPr if err != nil { return err } - gasInfo, err := trustednode.EstimateCancelProposalGas(rp, proposalId, opts) + gasLimits, err := trustednode.EstimateCancelProposalGas(rp, proposalId, opts) if err == nil { - response.GasInfo = gasInfo + response.GasLimits = gasLimits } return err }) diff --git a/rocketpool/api/odao/execute-proposal.go b/rocketpool/api/odao/execute-proposal.go index 7998e023c..5bf9b7e59 100644 --- a/rocketpool/api/odao/execute-proposal.go +++ b/rocketpool/api/odao/execute-proposal.go @@ -62,9 +62,9 @@ func canExecuteProposal(c *cli.Command, proposalId uint64) (*api.CanExecuteTNDAO if err != nil { return err } - gasInfo, err := trustednode.EstimateExecuteProposalGas(rp, proposalId, opts) + gasLimits, err := trustednode.EstimateExecuteProposalGas(rp, proposalId, opts) if err == nil { - response.GasInfo = gasInfo + response.GasLimits = gasLimits } return err }) diff --git a/rocketpool/api/odao/join.go b/rocketpool/api/odao/join.go index f6d03800d..0d7add3d2 100644 --- a/rocketpool/api/odao/join.go +++ b/rocketpool/api/odao/join.go @@ -92,14 +92,14 @@ func canJoin(c *cli.Command) (*api.CanJoinTNDAOResponse, error) { if err != nil { return err } - approveGasInfo, err := tokens.EstimateApproveRPLGas(rp, *rocketDAONodeTrustedActionsAddress, rplBondAmount, opts) + approveGasLimits, err := tokens.EstimateApproveRPLGas(rp, *rocketDAONodeTrustedActionsAddress, rplBondAmount, opts) if err != nil { return err } //joinGasInfo, err := tndao.EstimateJoinGas(rp, opts) if err == nil { - response.GasInfo = approveGasInfo - //response.GasInfo.EstGasLimit += joinGasInfo.EstGasLimit + response.GasLimits = approveGasLimits + //response.GasLimits.EstGasLimit += joinGasInfo.EstGasLimit } return err }) diff --git a/rocketpool/api/odao/leave.go b/rocketpool/api/odao/leave.go index 7e9c17b50..4578b539a 100644 --- a/rocketpool/api/odao/leave.go +++ b/rocketpool/api/odao/leave.go @@ -61,9 +61,9 @@ func canLeave(c *cli.Command) (*api.CanLeaveTNDAOResponse, error) { if err != nil { return err } - gasInfo, err := trustednode.EstimateLeaveGas(rp, opts.From, opts) + gasLimits, err := trustednode.EstimateLeaveGas(rp, opts.From, opts) if err == nil { - response.GasInfo = gasInfo + response.GasLimits = gasLimits } return err }) diff --git a/rocketpool/api/odao/penalise-megapool.go b/rocketpool/api/odao/penalise-megapool.go index 1022671bf..11e7b2898 100644 --- a/rocketpool/api/odao/penalise-megapool.go +++ b/rocketpool/api/odao/penalise-megapool.go @@ -47,11 +47,11 @@ func canPenaliseMegapool(c *cli.Command, megapoolAddress common.Address, block * return nil, err } - gasInfo, err := megapool.EstimatePenaliseGas(rp, megapoolAddress, block, amount, opts) + gasLimits, err := megapool.EstimatePenaliseGas(rp, megapoolAddress, block, amount, opts) if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits response.CanPenalise = true return &response, nil diff --git a/rocketpool/api/odao/propose-invite.go b/rocketpool/api/odao/propose-invite.go index 0cdacee49..693a73220 100644 --- a/rocketpool/api/odao/propose-invite.go +++ b/rocketpool/api/odao/propose-invite.go @@ -64,9 +64,9 @@ func canProposeInvite(c *cli.Command, memberAddress common.Address, memberId, me return err } message := fmt.Sprintf("invite %s (%s)", memberId, memberUrl) - gasInfo, err := trustednode.EstimateProposeInviteMemberGas(rp, message, memberAddress, memberId, memberUrl, opts) + gasLimits, err := trustednode.EstimateProposeInviteMemberGas(rp, message, memberAddress, memberId, memberUrl, opts) if err == nil { - response.GasInfo = gasInfo + response.GasLimits = gasLimits } return err }) diff --git a/rocketpool/api/odao/propose-kick.go b/rocketpool/api/odao/propose-kick.go index d97e3e552..3f37a89ef 100644 --- a/rocketpool/api/odao/propose-kick.go +++ b/rocketpool/api/odao/propose-kick.go @@ -75,9 +75,9 @@ func canProposeKick(c *cli.Command, memberAddress common.Address, fineAmountWei return err } message := fmt.Sprintf("kick %s (%s) with %.6f RPL fine", memberId, memberUrl, math.RoundDown(eth.WeiToEth(fineAmountWei), 6)) - gasInfo, err := trustednode.EstimateProposeKickMemberGas(rp, message, memberAddress, fineAmountWei, opts) + gasLimits, err := trustednode.EstimateProposeKickMemberGas(rp, message, memberAddress, fineAmountWei, opts) if err == nil { - response.GasInfo = gasInfo + response.GasLimits = gasLimits } return err }) diff --git a/rocketpool/api/odao/propose-leave.go b/rocketpool/api/odao/propose-leave.go index 56bd1ed8b..05bde9f33 100644 --- a/rocketpool/api/odao/propose-leave.go +++ b/rocketpool/api/odao/propose-leave.go @@ -76,9 +76,9 @@ func canProposeLeave(c *cli.Command) (*api.CanProposeTNDAOLeaveResponse, error) return err } message := fmt.Sprintf("%s (%s) leaves", nodeMemberId, nodeMemberUrl) - gasInfo, err := trustednode.EstimateProposeMemberLeaveGas(rp, message, nodeAccount.Address, opts) + gasLimits, err := trustednode.EstimateProposeMemberLeaveGas(rp, message, nodeAccount.Address, opts) if err == nil { - response.GasInfo = gasInfo + response.GasLimits = gasLimits } return err }) diff --git a/rocketpool/api/odao/propose-settings.go b/rocketpool/api/odao/propose-settings.go index 48be67a2f..87a29e33a 100644 --- a/rocketpool/api/odao/propose-settings.go +++ b/rocketpool/api/odao/propose-settings.go @@ -65,12 +65,12 @@ func canProposeSettingMembersQuorum(c *cli.Command, quorum float64) (*api.CanPro return nil, err } - gasInfo, err := trustednode.EstimateProposeQuorumGas(rp, quorum, opts) + gasLimits, err := trustednode.EstimateProposeQuorumGas(rp, quorum, opts) if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits return response, nil } @@ -128,12 +128,12 @@ func canProposeSettingMembersRplBond(c *cli.Command, bondAmountWei *big.Int) (*a return nil, err } - gasInfo, err := trustednode.EstimateProposeRPLBondGas(rp, bondAmountWei, opts) + gasLimits, err := trustednode.EstimateProposeRPLBondGas(rp, bondAmountWei, opts) if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits return response, nil } @@ -191,12 +191,12 @@ func canProposeSettingMinipoolUnbondedMax(c *cli.Command, unbondedMinipoolMax ui return nil, err } - gasInfo, err := trustednode.EstimateProposeMinipoolUnbondedMaxGas(rp, unbondedMinipoolMax, opts) + gasLimits, err := trustednode.EstimateProposeMinipoolUnbondedMaxGas(rp, unbondedMinipoolMax, opts) if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits return response, nil } @@ -254,12 +254,12 @@ func canProposeSettingProposalCooldown(c *cli.Command, proposalCooldownTimespan return nil, err } - gasInfo, err := trustednode.EstimateProposeProposalCooldownTimeGas(rp, proposalCooldownTimespan, opts) + gasLimits, err := trustednode.EstimateProposeProposalCooldownTimeGas(rp, proposalCooldownTimespan, opts) if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits return response, nil } @@ -317,12 +317,12 @@ func canProposeSettingProposalVoteTimespan(c *cli.Command, proposalVoteTimespan return nil, err } - gasInfo, err := trustednode.EstimateProposeProposalVoteTimeGas(rp, proposalVoteTimespan, opts) + gasLimits, err := trustednode.EstimateProposeProposalVoteTimeGas(rp, proposalVoteTimespan, opts) if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits return response, nil } @@ -380,12 +380,12 @@ func canProposeSettingProposalVoteDelayTimespan(c *cli.Command, proposalDelayTim return nil, err } - gasInfo, err := trustednode.EstimateProposeProposalVoteDelayTimeGas(rp, proposalDelayTimespan, opts) + gasLimits, err := trustednode.EstimateProposeProposalVoteDelayTimeGas(rp, proposalDelayTimespan, opts) if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits return response, nil } @@ -443,12 +443,12 @@ func canProposeSettingProposalExecuteTimespan(c *cli.Command, proposalExecuteTim return nil, err } - gasInfo, err := trustednode.EstimateProposeProposalExecuteTimeGas(rp, proposalExecuteTimespan, opts) + gasLimits, err := trustednode.EstimateProposeProposalExecuteTimeGas(rp, proposalExecuteTimespan, opts) if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits return response, nil } @@ -506,12 +506,12 @@ func canProposeSettingProposalActionTimespan(c *cli.Command, proposalActionTimes return nil, err } - gasInfo, err := trustednode.EstimateProposeProposalActionTimeGas(rp, proposalActionTimespan, opts) + gasLimits, err := trustednode.EstimateProposeProposalActionTimeGas(rp, proposalActionTimespan, opts) if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits return response, nil } @@ -569,12 +569,12 @@ func canProposeSettingScrubPeriod(c *cli.Command, scrubPeriod uint64) (*api.CanP return nil, err } - gasInfo, err := trustednode.EstimateProposeScrubPeriodGas(rp, scrubPeriod, opts) + gasLimits, err := trustednode.EstimateProposeScrubPeriodGas(rp, scrubPeriod, opts) if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits return response, nil } @@ -632,12 +632,12 @@ func canProposeSettingPromotionScrubPeriod(c *cli.Command, promotionScrubPeriod return nil, err } - gasInfo, err := trustednode.EstimateProposePromotionScrubPeriodGas(rp, promotionScrubPeriod, opts) + gasLimits, err := trustednode.EstimateProposePromotionScrubPeriodGas(rp, promotionScrubPeriod, opts) if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits return response, nil } @@ -695,12 +695,12 @@ func canProposeSettingScrubPenaltyEnabled(c *cli.Command, enabled bool) (*api.Ca return nil, err } - gasInfo, err := trustednode.EstimateProposeScrubPenaltyEnabledGas(rp, enabled, opts) + gasLimits, err := trustednode.EstimateProposeScrubPenaltyEnabledGas(rp, enabled, opts) if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits return response, nil } @@ -758,12 +758,12 @@ func canProposeSettingBondReductionWindowStart(c *cli.Command, bondReductionWind return nil, err } - gasInfo, err := trustednode.EstimateProposeBondReductionWindowStartGas(rp, bondReductionWindowStart, opts) + gasLimits, err := trustednode.EstimateProposeBondReductionWindowStartGas(rp, bondReductionWindowStart, opts) if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits return response, nil } @@ -821,12 +821,12 @@ func canProposeSettingBondReductionWindowLength(c *cli.Command, bondReductionWin return nil, err } - gasInfo, err := trustednode.EstimateProposeBondReductionWindowLengthGas(rp, bondReductionWindowLength, opts) + gasLimits, err := trustednode.EstimateProposeBondReductionWindowLengthGas(rp, bondReductionWindowLength, opts) if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits return response, nil } diff --git a/rocketpool/api/odao/routes.go b/rocketpool/api/odao/routes.go index 91dbd26e4..ffc8758da 100644 --- a/rocketpool/api/odao/routes.go +++ b/rocketpool/api/odao/routes.go @@ -9,586 +9,586 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/urfave/cli/v3" + "github.com/rocket-pool/smartnode/rocketpool/api/response" "github.com/rocket-pool/smartnode/shared/services" - apiutils "github.com/rocket-pool/smartnode/shared/utils/api" ) // RegisterRoutes registers the odao module's HTTP routes onto mux. func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { mux.HandleFunc("/api/odao/status", func(w http.ResponseWriter, r *http.Request) { resp, err := getStatus(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/members", func(w http.ResponseWriter, r *http.Request) { resp, err := getMembers(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/proposals", func(w http.ResponseWriter, r *http.Request) { resp, err := getProposals(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/proposal-details", func(w http.ResponseWriter, r *http.Request) { id, err := parseUint64(r, "id") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := getProposal(c, id) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/can-propose-invite", func(w http.ResponseWriter, r *http.Request) { addr, memberId, memberUrl, err := parseInviteParams(r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canProposeInvite(c, addr, memberId, memberUrl) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/propose-invite", func(w http.ResponseWriter, r *http.Request) { addr, memberId, memberUrl, err := parseInviteParams(r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := proposeInvite(c, addr, memberId, memberUrl, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/can-propose-leave", func(w http.ResponseWriter, r *http.Request) { resp, err := canProposeLeave(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/propose-leave", func(w http.ResponseWriter, r *http.Request) { opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := proposeLeave(c, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/can-propose-kick", func(w http.ResponseWriter, r *http.Request) { addr, fine, err := parseKickParams(r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canProposeKick(c, addr, fine) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/propose-kick", func(w http.ResponseWriter, r *http.Request) { addr, fine, err := parseKickParams(r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := proposeKick(c, addr, fine, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/can-cancel-proposal", func(w http.ResponseWriter, r *http.Request) { id, err := parseUint64(r, "id") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canCancelProposal(c, id) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/cancel-proposal", func(w http.ResponseWriter, r *http.Request) { id, err := parseUint64(r, "id") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := cancelProposal(c, id, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/can-vote-proposal", func(w http.ResponseWriter, r *http.Request) { id, err := parseUint64(r, "id") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canVoteOnProposal(c, id) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/vote-proposal", func(w http.ResponseWriter, r *http.Request) { id, err := parseUint64(r, "id") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } supportStr := r.FormValue("support") support := supportStr == "true" opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := voteOnProposal(c, id, support, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/can-execute-proposal", func(w http.ResponseWriter, r *http.Request) { id, err := parseUint64(r, "id") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canExecuteProposal(c, id) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/execute-proposal", func(w http.ResponseWriter, r *http.Request) { id, err := parseUint64(r, "id") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := executeProposal(c, id, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/can-join", func(w http.ResponseWriter, r *http.Request) { resp, err := canJoin(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/join-approve-rpl", func(w http.ResponseWriter, r *http.Request) { opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := approveRpl(c, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/join", func(w http.ResponseWriter, r *http.Request) { hashStr := r.FormValue("approvalTxHash") if hashStr == "" { - apiutils.WriteErrorResponse(w, fmt.Errorf("missing required parameter: approvalTxHash")) + response.WriteErrorResponse(w, fmt.Errorf("missing required parameter: approvalTxHash")) return } hash := common.HexToHash(hashStr) opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := waitForApprovalAndJoin(c, hash, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/can-leave", func(w http.ResponseWriter, r *http.Request) { resp, err := canLeave(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/leave", func(w http.ResponseWriter, r *http.Request) { bondRefundStr := r.FormValue("bondRefundAddress") if bondRefundStr == "" { - apiutils.WriteErrorResponse(w, fmt.Errorf("missing required parameter: bondRefundAddress")) + response.WriteErrorResponse(w, fmt.Errorf("missing required parameter: bondRefundAddress")) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := leave(c, common.HexToAddress(bondRefundStr), opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/get-member-settings", func(w http.ResponseWriter, r *http.Request) { resp, err := getMemberSettings(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/get-proposal-settings", func(w http.ResponseWriter, r *http.Request) { resp, err := getProposalSettings(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/get-minipool-settings", func(w http.ResponseWriter, r *http.Request) { resp, err := getMinipoolSettings(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/can-penalise-megapool", func(w http.ResponseWriter, r *http.Request) { megapool, block, amount, err := parsePenaliseParams(r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canPenaliseMegapool(c, megapool, block, amount) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/penalise-megapool", func(w http.ResponseWriter, r *http.Request) { megapool, block, amount, err := parsePenaliseParams(r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := penaliseMegapool(c, megapool, block, amount, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) // propose-settings endpoints mux.HandleFunc("/api/odao/can-propose-members-quorum", func(w http.ResponseWriter, r *http.Request) { quorum, err := parseFloat64(r, "quorum") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canProposeSettingMembersQuorum(c, quorum) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/propose-members-quorum", func(w http.ResponseWriter, r *http.Request) { quorum, err := parseFloat64(r, "quorum") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := proposeSettingMembersQuorum(c, quorum, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/can-propose-members-rplbond", func(w http.ResponseWriter, r *http.Request) { bond, err := parseBigInt(r, "bondAmountWei") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canProposeSettingMembersRplBond(c, bond) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/propose-members-rplbond", func(w http.ResponseWriter, r *http.Request) { bond, err := parseBigInt(r, "bondAmountWei") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := proposeSettingMembersRplBond(c, bond, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/can-propose-members-minipool-unbonded-max", func(w http.ResponseWriter, r *http.Request) { m, err := parseUint64(r, "max") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canProposeSettingMinipoolUnbondedMax(c, m) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/propose-members-minipool-unbonded-max", func(w http.ResponseWriter, r *http.Request) { m, err := parseUint64(r, "max") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := proposeSettingMinipoolUnbondedMax(c, m, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/can-propose-proposal-cooldown", func(w http.ResponseWriter, r *http.Request) { val, err := parseUint64(r, "value") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canProposeSettingProposalCooldown(c, val) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/propose-proposal-cooldown", func(w http.ResponseWriter, r *http.Request) { val, err := parseUint64(r, "value") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := proposeSettingProposalCooldown(c, val, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/can-propose-proposal-vote-timespan", func(w http.ResponseWriter, r *http.Request) { val, err := parseUint64(r, "value") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canProposeSettingProposalVoteTimespan(c, val) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/propose-proposal-vote-timespan", func(w http.ResponseWriter, r *http.Request) { val, err := parseUint64(r, "value") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := proposeSettingProposalVoteTimespan(c, val, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/can-propose-proposal-vote-delay-timespan", func(w http.ResponseWriter, r *http.Request) { val, err := parseUint64(r, "value") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canProposeSettingProposalVoteDelayTimespan(c, val) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/propose-proposal-vote-delay-timespan", func(w http.ResponseWriter, r *http.Request) { val, err := parseUint64(r, "value") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := proposeSettingProposalVoteDelayTimespan(c, val, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/can-propose-proposal-execute-timespan", func(w http.ResponseWriter, r *http.Request) { val, err := parseUint64(r, "value") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canProposeSettingProposalExecuteTimespan(c, val) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/propose-proposal-execute-timespan", func(w http.ResponseWriter, r *http.Request) { val, err := parseUint64(r, "value") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := proposeSettingProposalExecuteTimespan(c, val, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/can-propose-proposal-action-timespan", func(w http.ResponseWriter, r *http.Request) { val, err := parseUint64(r, "value") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canProposeSettingProposalActionTimespan(c, val) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/propose-proposal-action-timespan", func(w http.ResponseWriter, r *http.Request) { val, err := parseUint64(r, "value") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := proposeSettingProposalActionTimespan(c, val, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/can-propose-scrub-period", func(w http.ResponseWriter, r *http.Request) { val, err := parseUint64(r, "value") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canProposeSettingScrubPeriod(c, val) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/propose-scrub-period", func(w http.ResponseWriter, r *http.Request) { val, err := parseUint64(r, "value") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := proposeSettingScrubPeriod(c, val, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/can-propose-promotion-scrub-period", func(w http.ResponseWriter, r *http.Request) { val, err := parseUint64(r, "value") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canProposeSettingPromotionScrubPeriod(c, val) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/propose-promotion-scrub-period", func(w http.ResponseWriter, r *http.Request) { val, err := parseUint64(r, "value") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := proposeSettingPromotionScrubPeriod(c, val, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/can-propose-scrub-penalty-enabled", func(w http.ResponseWriter, r *http.Request) { enabledStr := r.URL.Query().Get("enabled") resp, err := canProposeSettingScrubPenaltyEnabled(c, enabledStr == "true") - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/propose-scrub-penalty-enabled", func(w http.ResponseWriter, r *http.Request) { enabledStr := r.FormValue("enabled") opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := proposeSettingScrubPenaltyEnabled(c, enabledStr == "true", opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/can-propose-bond-reduction-window-start", func(w http.ResponseWriter, r *http.Request) { val, err := parseUint64(r, "value") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canProposeSettingBondReductionWindowStart(c, val) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/propose-bond-reduction-window-start", func(w http.ResponseWriter, r *http.Request) { val, err := parseUint64(r, "value") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := proposeSettingBondReductionWindowStart(c, val, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/can-propose-bond-reduction-window-length", func(w http.ResponseWriter, r *http.Request) { val, err := parseUint64(r, "value") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canProposeSettingBondReductionWindowLength(c, val) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/odao/propose-bond-reduction-window-length", func(w http.ResponseWriter, r *http.Request) { val, err := parseUint64(r, "value") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := proposeSettingBondReductionWindowLength(c, val, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) } diff --git a/rocketpool/api/odao/vote-proposal.go b/rocketpool/api/odao/vote-proposal.go index a9ff0ed21..b9801dc48 100644 --- a/rocketpool/api/odao/vote-proposal.go +++ b/rocketpool/api/odao/vote-proposal.go @@ -90,9 +90,9 @@ func canVoteOnProposal(c *cli.Command, proposalId uint64) (*api.CanVoteOnTNDAOPr if err != nil { return err } - gasInfo, err := trustednode.EstimateVoteOnProposalGas(rp, proposalId, false, opts) + gasLimits, err := trustednode.EstimateVoteOnProposalGas(rp, proposalId, false, opts) if err == nil { - response.GasInfo = gasInfo + response.GasLimits = gasLimits } return err }) diff --git a/rocketpool/api/pdao/claim-bonds.go b/rocketpool/api/pdao/claim-bonds.go index 42686a5ee..174f9a109 100644 --- a/rocketpool/api/pdao/claim-bonds.go +++ b/rocketpool/api/pdao/claim-bonds.go @@ -7,7 +7,7 @@ import ( "golang.org/x/sync/errgroup" "github.com/rocket-pool/smartnode/bindings/dao/protocol" - "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/shared/services" @@ -88,19 +88,19 @@ func canClaimBonds(c *cli.Command, proposalId uint64, indices []uint64) (*api.PD if err != nil { return nil, err } - var gasInfo rocketpool.GasInfo + var gasLimits gaslimit.Limits if response.IsProposer { - gasInfo, err = protocol.EstimateClaimBondProposerGas(rp, proposalId, indices, opts) + gasLimits, err = protocol.EstimateClaimBondProposerGas(rp, proposalId, indices, opts) } else { - gasInfo, err = protocol.EstimateClaimBondChallengerGas(rp, proposalId, indices, opts) + gasLimits, err = protocol.EstimateClaimBondChallengerGas(rp, proposalId, indices, opts) } if err != nil { return nil, err } // Update & return response - response.GasInfo = gasInfo + response.GasLimits = gasLimits return &response, nil } diff --git a/rocketpool/api/pdao/defeat-proposal.go b/rocketpool/api/pdao/defeat-proposal.go index e3bf39463..d93e15df7 100644 --- a/rocketpool/api/pdao/defeat-proposal.go +++ b/rocketpool/api/pdao/defeat-proposal.go @@ -99,13 +99,13 @@ func canDefeatProposal(c *cli.Command, proposalId uint64, index uint64) (*api.PD if err != nil { return nil, err } - gasInfo, err := protocol.EstimateDefeatProposalGas(rp, proposalId, index, opts) + gasLimits, err := protocol.EstimateDefeatProposalGas(rp, proposalId, index, opts) if err != nil { return nil, err } // Update & return response - response.GasInfo = gasInfo + response.GasLimits = gasLimits return &response, nil } diff --git a/rocketpool/api/pdao/execute-proposal.go b/rocketpool/api/pdao/execute-proposal.go index 5397f0b54..d2560db60 100644 --- a/rocketpool/api/pdao/execute-proposal.go +++ b/rocketpool/api/pdao/execute-proposal.go @@ -61,9 +61,9 @@ func canExecuteProposal(c *cli.Command, proposalId uint64) (*api.CanExecutePDAOP if err != nil { return err } - gasInfo, err := protocol.EstimateExecuteProposalGas(rp, proposalId, opts) + gasLimits, err := protocol.EstimateExecuteProposalGas(rp, proposalId, opts) if err == nil { - response.GasInfo = gasInfo + response.GasLimits = gasLimits } return err }) diff --git a/rocketpool/api/pdao/finalize-proposal.go b/rocketpool/api/pdao/finalize-proposal.go index b8e78b4e5..f4bc7a3b6 100644 --- a/rocketpool/api/pdao/finalize-proposal.go +++ b/rocketpool/api/pdao/finalize-proposal.go @@ -77,13 +77,13 @@ func canFinalizeProposal(c *cli.Command, proposalId uint64) (*api.PDAOCanFinaliz if err != nil { return nil, err } - gasInfo, err := protocol.EstimateFinalizeGas(rp, proposalId, opts) + gasLimits, err := protocol.EstimateFinalizeGas(rp, proposalId, opts) if err != nil { return nil, err } // Update & return response - response.GasInfo = gasInfo + response.GasLimits = gasLimits return &response, nil } diff --git a/rocketpool/api/pdao/invite-security.go b/rocketpool/api/pdao/invite-security.go index 94ddb1547..5192e3e69 100644 --- a/rocketpool/api/pdao/invite-security.go +++ b/rocketpool/api/pdao/invite-security.go @@ -87,14 +87,14 @@ func canProposeInviteToSecurityCouncil(c *cli.Command, id string, address common if err != nil { return nil, err } - gasInfo, err := protocol.EstimateProposeInviteToSecurityCouncilGas(rp, message, id, address, blockNumber, pollard, opts) + gasLimits, err := protocol.EstimateProposeInviteToSecurityCouncilGas(rp, message, id, address, blockNumber, pollard, opts) if err != nil { return nil, err } // Update & return response response.BlockNumber = blockNumber - response.GasInfo = gasInfo + response.GasLimits = gasLimits return &response, nil } diff --git a/rocketpool/api/pdao/kick-multi-security.go b/rocketpool/api/pdao/kick-multi-security.go index 7e5376c88..e56ced7ff 100644 --- a/rocketpool/api/pdao/kick-multi-security.go +++ b/rocketpool/api/pdao/kick-multi-security.go @@ -44,14 +44,14 @@ func canProposeKickMultiFromSecurityCouncil(c *cli.Command, addresses []common.A if err != nil { return nil, err } - gasInfo, err := protocol.EstimateProposeKickMultiFromSecurityCouncilGas(rp, message, addresses, blockNumber, pollard, opts) + gasLimits, err := protocol.EstimateProposeKickMultiFromSecurityCouncilGas(rp, message, addresses, blockNumber, pollard, opts) if err != nil { return nil, err } // Update & return response response.BlockNumber = blockNumber - response.GasInfo = gasInfo + response.GasLimits = gasLimits return &response, nil } diff --git a/rocketpool/api/pdao/kick-security.go b/rocketpool/api/pdao/kick-security.go index b56c67822..335f5e34f 100644 --- a/rocketpool/api/pdao/kick-security.go +++ b/rocketpool/api/pdao/kick-security.go @@ -71,14 +71,14 @@ func canProposeKickFromSecurityCouncil(c *cli.Command, address common.Address) ( if err != nil { return nil, err } - gasInfo, err := protocol.EstimateProposeKickFromSecurityCouncilGas(rp, message, address, blockNumber, pollard, opts) + gasLimits, err := protocol.EstimateProposeKickFromSecurityCouncilGas(rp, message, address, blockNumber, pollard, opts) if err != nil { return nil, err } // Update & return response response.BlockNumber = blockNumber - response.GasInfo = gasInfo + response.GasLimits = gasLimits return &response, nil } diff --git a/rocketpool/api/pdao/one-time-spend.go b/rocketpool/api/pdao/one-time-spend.go index 62ec378c4..c6429914d 100644 --- a/rocketpool/api/pdao/one-time-spend.go +++ b/rocketpool/api/pdao/one-time-spend.go @@ -70,14 +70,14 @@ func canProposeOneTimeSpend(c *cli.Command, invoiceID string, recipient common.A if err != nil { return nil, err } - gasInfo, err := protocol.EstimateProposeOneTimeTreasurySpendGas(rp, customMessage, invoiceID, recipient, amount, blockNumber, pollard, opts) + gasLimits, err := protocol.EstimateProposeOneTimeTreasurySpendGas(rp, customMessage, invoiceID, recipient, amount, blockNumber, pollard, opts) if err != nil { return nil, err } // Update & return response response.BlockNumber = blockNumber - response.GasInfo = gasInfo + response.GasLimits = gasLimits return &response, nil } diff --git a/rocketpool/api/pdao/override-vote.go b/rocketpool/api/pdao/override-vote.go index 885d021ef..24dff329e 100644 --- a/rocketpool/api/pdao/override-vote.go +++ b/rocketpool/api/pdao/override-vote.go @@ -95,11 +95,11 @@ func canOverrideVote(c *cli.Command, proposalId uint64, voteDirection types.Vote if err != nil { return nil, err } - gasInfo, err := protocol.EstimateOverrideVoteGas(rp, proposalId, voteDirection, opts) + gasLimits, err := protocol.EstimateOverrideVoteGas(rp, proposalId, voteDirection, opts) if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits // Update & return response return &response, nil diff --git a/rocketpool/api/pdao/percentages.go b/rocketpool/api/pdao/percentages.go index 1b0c2e831..e579cdb9e 100644 --- a/rocketpool/api/pdao/percentages.go +++ b/rocketpool/api/pdao/percentages.go @@ -117,11 +117,11 @@ func canProposeRewardsPercentages(c *cli.Command, node *big.Int, odao *big.Int, response.BlockNumber = blockNumber // Simulate - gasInfo, err := protocol.EstimateProposeSetRewardsPercentageGas(rp, "update RPL rewards distribution", odao, pdao, node, blockNumber, pollard, opts) + gasLimits, err := protocol.EstimateProposeSetRewardsPercentageGas(rp, "update RPL rewards distribution", odao, pdao, node, blockNumber, pollard, opts) if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits // Return response return &response, nil diff --git a/rocketpool/api/pdao/propose-settings.go b/rocketpool/api/pdao/propose-settings.go index 79db09544..876a6bde3 100644 --- a/rocketpool/api/pdao/propose-settings.go +++ b/rocketpool/api/pdao/propose-settings.go @@ -13,7 +13,6 @@ import ( "golang.org/x/sync/errgroup" "github.com/rocket-pool/smartnode/bindings/node" - "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/settings/protocol" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/types/api" @@ -133,7 +132,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeCreateLotEnabledGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeCreateLotEnabledGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing CreateLotEnabled: %w", err) } @@ -144,7 +143,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeBidOnLotEnabledGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeBidOnLotEnabledGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing BidOnLotEnabled: %w", err) } @@ -155,7 +154,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeLotMinimumEthValueGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeLotMinimumEthValueGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing LotMinimumEthValue: %w", err) } @@ -166,7 +165,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeLotMaximumEthValueGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeLotMaximumEthValueGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing LotMaximumEthValue: %w", err) } @@ -177,7 +176,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeLotDurationGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeLotDurationGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing LotDuration: %w", err) } @@ -188,7 +187,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeLotStartingPriceRatioGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeLotStartingPriceRatioGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing LotStartingPriceRatio: %w", err) } @@ -199,7 +198,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeLotReservePriceRatioGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeLotReservePriceRatioGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing LotReservePriceRatio: %w", err) } @@ -213,7 +212,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeDepositEnabledGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeDepositEnabledGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing DepositEnabled: %w", err) } @@ -224,7 +223,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeAssignDepositsEnabledGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeAssignDepositsEnabledGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing AssignDepositsEnabled: %w", err) } @@ -235,7 +234,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeMinimumDepositGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeMinimumDepositGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing MinimumDeposit: %w", err) } @@ -246,7 +245,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeMaximumDepositPoolSizeGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeMaximumDepositPoolSizeGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing MaximumDepositPoolSize: %w", err) } @@ -257,7 +256,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeMaximumDepositAssignmentsGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeMaximumDepositAssignmentsGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing MaximumDepositAssignments: %w", err) } @@ -268,7 +267,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeMaximumSocializedDepositAssignmentsGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeMaximumSocializedDepositAssignmentsGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing MaximumSocializedDepositAssignments: %w", err) } @@ -279,7 +278,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeDepositFeeGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeDepositFeeGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing DepositFee: %w", err) } @@ -293,7 +292,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeMinipoolSubmitWithdrawableEnabledGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeMinipoolSubmitWithdrawableEnabledGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing MinipoolSubmitWithdrawableEnabled: %w", err) } @@ -304,7 +303,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeMinipoolLaunchTimeoutGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeMinipoolLaunchTimeoutGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing MinipoolLaunchTimeout: %w", err) } @@ -315,7 +314,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeBondReductionEnabledGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeBondReductionEnabledGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing BondReductionEnabled: %w", err) } @@ -326,7 +325,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeMaximumMinipoolCountGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeMaximumMinipoolCountGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing MaximumMinipoolCount: %w", err) } @@ -337,7 +336,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeMinipoolUserDistributeWindowStartGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeMinipoolUserDistributeWindowStartGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing MinipoolUserDistributeWindowStart: %w", err) } @@ -348,7 +347,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeMinipoolUserDistributeWindowLengthGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeMinipoolUserDistributeWindowLengthGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing MinipoolUserDistributeWindowLength: %w", err) } @@ -362,7 +361,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeNodeConsensusThresholdGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeNodeConsensusThresholdGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing NodeConsensusThreshold: %w", err) } @@ -373,7 +372,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeSubmitBalancesEnabledGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeSubmitBalancesEnabledGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing SubmitBalancesEnabled: %w", err) } @@ -384,7 +383,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeSubmitBalancesFrequencyGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeSubmitBalancesFrequencyGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing SubmitBalancesFrequency: %w", err) } @@ -395,7 +394,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeSubmitPricesEnabledGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeSubmitPricesEnabledGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing SubmitPricesEnabled: %w", err) } @@ -406,7 +405,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeSubmitPricesFrequencyGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeSubmitPricesFrequencyGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing SubmitPricesFrequency: %w", err) } @@ -417,7 +416,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeMinimumNodeFeeGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeMinimumNodeFeeGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing MinimumNodeFee: %w", err) } @@ -428,7 +427,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeTargetNodeFeeGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeTargetNodeFeeGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing TargetNodeFee: %w", err) } @@ -439,7 +438,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeMaximumNodeFeeGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeMaximumNodeFeeGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing MaximumNodeFee: %w", err) } @@ -450,7 +449,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeNodeFeeDemandRangeGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeNodeFeeDemandRangeGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing NodeFeeDemandRange: %w", err) } @@ -461,7 +460,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeTargetRethCollateralRateGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeTargetRethCollateralRateGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing TargetRethCollateralRate: %w", err) } @@ -472,7 +471,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeNetworkPenaltyThresholdGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeNetworkPenaltyThresholdGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing NetworkPenaltyThreshold: %w", err) } @@ -483,7 +482,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeNetworkPenaltyPerRateGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeNetworkPenaltyPerRateGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing NetworkPenaltyPerRate: %w", err) } @@ -494,7 +493,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeSubmitRewardsEnabledGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeSubmitRewardsEnabledGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing SubmitRewardsEnabled: %w", err) } @@ -505,7 +504,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeNodeShareGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeNodeShareGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing NodeShare: %w", err) } @@ -515,7 +514,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeNodeShareSecurityCouncilAdderGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeNodeShareSecurityCouncilAdderGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing NodeShareSecurityCouncilAdder: %w", err) } @@ -525,7 +524,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeVoterShareGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeVoterShareGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing VoterShare: %w", err) } @@ -535,7 +534,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeProtocolDAOShare(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeProtocolDAOShare(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing ProtocolDAOShare: %w", err) } @@ -545,7 +544,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateMaxNodeShareSecurityCouncilAdder(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateMaxNodeShareSecurityCouncilAdder(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing MaxNodeShareSecurityCouncilAdder: %w", err) } @@ -555,7 +554,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateMaxRethDeltaGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateMaxRethDeltaGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing MaxRethBalanceDelta: %w", err) } @@ -570,7 +569,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeNodeRegistrationEnabledGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeNodeRegistrationEnabledGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing NodeRegistrationEnabled: %w", err) } @@ -581,7 +580,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeSmoothingPoolRegistrationEnabledGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeSmoothingPoolRegistrationEnabledGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing SmoothingPoolRegistrationEnabled: %w", err) } @@ -592,7 +591,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeNodeDepositEnabledGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeNodeDepositEnabledGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing NodeDepositEnabled: %w", err) } @@ -603,7 +602,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeVacantMinipoolsEnabledGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeVacantMinipoolsEnabledGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing VacantMinipoolsEnabled: %w", err) } @@ -613,7 +612,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol131.EstimateProposeMinimumPerMinipoolStakeGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol131.EstimateProposeMinimumPerMinipoolStakeGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing MinimumPerMinipoolStake: %w", err) } @@ -623,7 +622,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol131.EstimateProposeMaximumPerMinipoolStakeGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol131.EstimateProposeMaximumPerMinipoolStakeGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing MaximumPerMinipoolStake: %w", err) } @@ -633,7 +632,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeMinimumLecacyRPLStakeGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeMinimumLecacyRPLStakeGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing MinimumLegacyRplStake: %w", err) } @@ -644,7 +643,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeReducedBond(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeReducedBond(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing ReducedBond: %w", err) } @@ -654,7 +653,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeNodeUnstakingPeriod(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeNodeUnstakingPeriod(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing NodeUnstakingPeriod: %w", err) } @@ -669,7 +668,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeVotePhase1TimeGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeVotePhase1TimeGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing VoteTime: %w", err) } @@ -679,7 +678,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeVotePhase2TimeGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeVotePhase2TimeGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing VoteTime: %w", err) } @@ -689,7 +688,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeVoteDelayTimeGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeVoteDelayTimeGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing VoteDelayTime: %w", err) } @@ -700,7 +699,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeExecuteTimeGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeExecuteTimeGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing ExecuteTime: %w", err) } @@ -711,7 +710,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeProposalBondGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeProposalBondGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing ProposalBond: %w", err) } @@ -722,7 +721,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeChallengeBondGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeChallengeBondGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing ChallengeBond: %w", err) } @@ -733,7 +732,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeChallengePeriodGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeChallengePeriodGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing ChallengePeriod: %w", err) } @@ -744,7 +743,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeProposalQuorumGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeProposalQuorumGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing ProposalQuorum: %w", err) } @@ -755,7 +754,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeProposalVetoQuorumGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeProposalVetoQuorumGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing ProposalVetoQuorum: %w", err) } @@ -766,7 +765,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeProposalMaxBlockAgeGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeProposalMaxBlockAgeGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing ProposalMaxBlockAge: %w", err) } @@ -780,7 +779,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeRewardsClaimIntervalTimeGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeRewardsClaimIntervalTimeGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing RewardsClaimIntervalTime: %w", err) } @@ -794,7 +793,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeSecurityMembersQuorumGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeSecurityMembersQuorumGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing SecurityMembersQuorum: %w", err) } @@ -805,7 +804,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeSecurityMembersLeaveTimeGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeSecurityMembersLeaveTimeGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing SecurityMembersLeaveTime: %w", err) } @@ -816,7 +815,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeSecurityProposalVoteTimeGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeSecurityProposalVoteTimeGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing SecurityProposalVoteTime: %w", err) } @@ -827,7 +826,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeSecurityProposalExecuteTimeGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeSecurityProposalExecuteTimeGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing SecurityProposalExecuteTime: %w", err) } @@ -838,7 +837,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeSecurityProposalActionTimeGas(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeSecurityProposalActionTimeGas(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing SecurityProposalActionTime: %w", err) } @@ -852,7 +851,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeMegapoolTimeBeforeDissolve(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeMegapoolTimeBeforeDissolve(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing TimeBeforeDissolve: %w", err) } @@ -862,7 +861,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeMaximumEthPenalty(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeMaximumEthPenalty(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing MaximumEthPenalty: %w", err) } @@ -872,7 +871,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeNotifyThreshold(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeNotifyThreshold(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing NotifyThreshold: %w", err) } @@ -882,7 +881,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeLateNotifyFine(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeLateNotifyFine(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing LateNofifyFine: %w", err) } @@ -892,7 +891,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeDissolvePenalty(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeDissolvePenalty(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing DissolvePenalty: %w", err) } @@ -902,7 +901,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeUserDistributeDelay(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeUserDistributeDelay(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing UserDistributeDelay: %w", err) } @@ -912,7 +911,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposeUserDistributeDelayWithShortfall(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposeUserDistributeDelayWithShortfall(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing UserDistributeDelayWithShortfall: %w", err) } @@ -922,7 +921,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = protocol.EstimateProposePenaltyThreshold(rp, newValue, blockNumber, pollard, opts) + response.GasLimits, err = protocol.EstimateProposePenaltyThreshold(rp, newValue, blockNumber, pollard, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing PenaltyThreshold: %w", err) } @@ -931,8 +930,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, } // Make sure a setting was actually hit - blankGasInfo := rocketpool.GasInfo{} - if response.GasInfo == blankGasInfo { + if response.GasLimits.IsBlank() { return nil, fmt.Errorf("[%s - %s] is not a valid PDAO contract and setting name combo", contractName, settingName) } diff --git a/rocketpool/api/pdao/recurring-spend.go b/rocketpool/api/pdao/recurring-spend.go index ce1828a5e..8c9bf0a9a 100644 --- a/rocketpool/api/pdao/recurring-spend.go +++ b/rocketpool/api/pdao/recurring-spend.go @@ -71,14 +71,14 @@ func canProposeRecurringSpend(c *cli.Command, contractName string, recipient com if err != nil { return nil, err } - gasInfo, err := protocol.EstimateProposeRecurringTreasurySpendGas(rp, customMessage, contractName, recipient, amountPerPeriod, periodLength, startTime, numberOfPeriods, blockNumber, pollard, opts) + gasLimits, err := protocol.EstimateProposeRecurringTreasurySpendGas(rp, customMessage, contractName, recipient, amountPerPeriod, periodLength, startTime, numberOfPeriods, blockNumber, pollard, opts) if err != nil { return nil, err } // Update & return response response.BlockNumber = blockNumber - response.GasInfo = gasInfo + response.GasLimits = gasLimits return &response, nil } diff --git a/rocketpool/api/pdao/replace-security.go b/rocketpool/api/pdao/replace-security.go index dc4168d88..e94d00942 100644 --- a/rocketpool/api/pdao/replace-security.go +++ b/rocketpool/api/pdao/replace-security.go @@ -78,14 +78,14 @@ func canProposeReplaceMemberOfSecurityCouncil(c *cli.Command, existingMemberAddr if err != nil { return nil, err } - gasInfo, err := protocol.EstimateProposeReplaceSecurityCouncilMemberGas(rp, message, existingMemberAddress, newMemberID, newMemberAddress, blockNumber, pollard, opts) + gasLimits, err := protocol.EstimateProposeReplaceSecurityCouncilMemberGas(rp, message, existingMemberAddress, newMemberID, newMemberAddress, blockNumber, pollard, opts) if err != nil { return nil, err } // Update & return response response.BlockNumber = blockNumber - response.GasInfo = gasInfo + response.GasLimits = gasLimits return &response, nil } diff --git a/rocketpool/api/pdao/routes.go b/rocketpool/api/pdao/routes.go index ae09560fd..2ac2e9c55 100644 --- a/rocketpool/api/pdao/routes.go +++ b/rocketpool/api/pdao/routes.go @@ -12,8 +12,8 @@ import ( "github.com/urfave/cli/v3" bindtypes "github.com/rocket-pool/smartnode/bindings/types" + "github.com/rocket-pool/smartnode/rocketpool/api/response" "github.com/rocket-pool/smartnode/shared/services" - apiutils "github.com/rocket-pool/smartnode/shared/utils/api" cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" ) @@ -21,102 +21,102 @@ import ( func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { mux.HandleFunc("/api/pdao/status", func(w http.ResponseWriter, r *http.Request) { resp, err := getStatus(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/pdao/proposals", func(w http.ResponseWriter, r *http.Request) { resp, err := getProposals(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/pdao/proposal-details", func(w http.ResponseWriter, r *http.Request) { id, err := parseUint64Param(r, "id") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := getProposal(c, id) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/pdao/can-vote-proposal", func(w http.ResponseWriter, r *http.Request) { id, voteDir, err := parseProposalVoteParams(r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canVoteOnProposal(c, id, voteDir) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/pdao/vote-proposal", func(w http.ResponseWriter, r *http.Request) { id, voteDir, err := parseProposalVoteParams(r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := voteOnProposal(c, id, voteDir, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/pdao/can-override-vote", func(w http.ResponseWriter, r *http.Request) { id, voteDir, err := parseProposalVoteParams(r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canOverrideVote(c, id, voteDir) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/pdao/override-vote", func(w http.ResponseWriter, r *http.Request) { id, voteDir, err := parseProposalVoteParams(r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := overrideVote(c, id, voteDir, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/pdao/can-execute-proposal", func(w http.ResponseWriter, r *http.Request) { id, err := parseUint64Param(r, "id") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canExecuteProposal(c, id) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/pdao/execute-proposal", func(w http.ResponseWriter, r *http.Request) { id, err := parseUint64Param(r, "id") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := executeProposal(c, id, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/pdao/get-settings", func(w http.ResponseWriter, r *http.Request) { resp, err := getSettings(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/pdao/can-propose-setting", func(w http.ResponseWriter, r *http.Request) { @@ -124,7 +124,7 @@ func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { setting := paramVal(r, "setting") value := paramVal(r, "value") resp, err := canProposeSetting(c, contract, setting, value) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/pdao/propose-setting", func(w http.ResponseWriter, r *http.Request) { @@ -133,148 +133,148 @@ func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { value := paramVal(r, "value") blockNumber, err := parseUint32Param(r, "blockNumber") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := proposeSetting(c, contract, setting, value, blockNumber, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/pdao/get-rewards-percentages", func(w http.ResponseWriter, r *http.Request) { resp, err := getRewardsPercentages(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/pdao/can-propose-rewards-percentages", func(w http.ResponseWriter, r *http.Request) { node, odaoAmt, pdaoAmt, err := parseRewardPercentages(r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canProposeRewardsPercentages(c, node, odaoAmt, pdaoAmt) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/pdao/propose-rewards-percentages", func(w http.ResponseWriter, r *http.Request) { node, odaoAmt, pdaoAmt, err := parseRewardPercentages(r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } blockNumber, err := parseUint32Param(r, "blockNumber") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := proposeRewardsPercentages(c, node, odaoAmt, pdaoAmt, blockNumber, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/pdao/can-propose-one-time-spend", func(w http.ResponseWriter, r *http.Request) { invoiceID, recipient, amount, customMessage, err := parseOneTimeSpendParams(r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canProposeOneTimeSpend(c, invoiceID, recipient, amount, customMessage) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/pdao/propose-one-time-spend", func(w http.ResponseWriter, r *http.Request) { invoiceID, recipient, amount, customMessage, err := parseOneTimeSpendParams(r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } blockNumber, err := parseUint32Param(r, "blockNumber") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := proposeOneTimeSpend(c, invoiceID, recipient, amount, blockNumber, customMessage, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/pdao/can-propose-recurring-spend", func(w http.ResponseWriter, r *http.Request) { contractName, recipient, amountPerPeriod, periodLength, startTime, numberOfPeriods, customMessage, err := parseRecurringSpendParams(r, false) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canProposeRecurringSpend(c, contractName, recipient, amountPerPeriod, periodLength, startTime, numberOfPeriods, customMessage) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/pdao/propose-recurring-spend", func(w http.ResponseWriter, r *http.Request) { contractName, recipient, amountPerPeriod, periodLength, startTime, numberOfPeriods, customMessage, err := parseRecurringSpendParams(r, false) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } blockNumber, err := parseUint32Param(r, "blockNumber") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := proposeRecurringSpend(c, contractName, recipient, amountPerPeriod, periodLength, startTime, numberOfPeriods, blockNumber, customMessage, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/pdao/can-propose-recurring-spend-update", func(w http.ResponseWriter, r *http.Request) { contractName, recipient, amountPerPeriod, periodLength, _, numberOfPeriods, customMessage, err := parseRecurringSpendParams(r, true) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canProposeRecurringSpendUpdate(c, contractName, recipient, amountPerPeriod, periodLength, numberOfPeriods, customMessage) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/pdao/propose-recurring-spend-update", func(w http.ResponseWriter, r *http.Request) { contractName, recipient, amountPerPeriod, periodLength, _, numberOfPeriods, customMessage, err := parseRecurringSpendParams(r, true) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } blockNumber, err := parseUint32Param(r, "blockNumber") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := proposeRecurringSpendUpdate(c, contractName, recipient, amountPerPeriod, periodLength, numberOfPeriods, blockNumber, customMessage, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/pdao/can-propose-invite-to-security-council", func(w http.ResponseWriter, r *http.Request) { id := paramVal(r, "id") addr := common.HexToAddress(paramVal(r, "address")) resp, err := canProposeInviteToSecurityCouncil(c, id, addr) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/pdao/propose-invite-to-security-council", func(w http.ResponseWriter, r *http.Request) { @@ -282,68 +282,68 @@ func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { addr := common.HexToAddress(paramVal(r, "address")) blockNumber, err := parseUint32Param(r, "blockNumber") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := proposeInviteToSecurityCouncil(c, id, addr, blockNumber, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/pdao/can-propose-kick-from-security-council", func(w http.ResponseWriter, r *http.Request) { addr := common.HexToAddress(paramVal(r, "address")) resp, err := canProposeKickFromSecurityCouncil(c, addr) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/pdao/propose-kick-from-security-council", func(w http.ResponseWriter, r *http.Request) { addr := common.HexToAddress(paramVal(r, "address")) blockNumber, err := parseUint32Param(r, "blockNumber") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := proposeKickFromSecurityCouncil(c, addr, blockNumber, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/pdao/can-propose-kick-multi-from-security-council", func(w http.ResponseWriter, r *http.Request) { addresses, err := parseAddressList(r, "addresses") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canProposeKickMultiFromSecurityCouncil(c, addresses) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/pdao/propose-kick-multi-from-security-council", func(w http.ResponseWriter, r *http.Request) { addresses, err := parseAddressList(r, "addresses") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } blockNumber, err := parseUint32Param(r, "blockNumber") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := proposeKickMultiFromSecurityCouncil(c, addresses, blockNumber, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/pdao/can-propose-replace-member-of-security-council", func(w http.ResponseWriter, r *http.Request) { @@ -351,7 +351,7 @@ func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { newID := paramVal(r, "newId") newAddr := common.HexToAddress(paramVal(r, "newAddress")) resp, err := canProposeReplaceMemberOfSecurityCouncil(c, existing, newID, newAddr) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/pdao/propose-replace-member-of-security-council", func(w http.ResponseWriter, r *http.Request) { @@ -360,136 +360,136 @@ func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { newAddr := common.HexToAddress(paramVal(r, "newAddress")) blockNumber, err := parseUint32Param(r, "blockNumber") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := proposeReplaceMemberOfSecurityCouncil(c, existing, newID, newAddr, blockNumber, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/pdao/get-claimable-bonds", func(w http.ResponseWriter, r *http.Request) { resp, err := getClaimableBonds(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/pdao/can-claim-bonds", func(w http.ResponseWriter, r *http.Request) { proposalID, indices, err := parseClaimBondsParams(r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canClaimBonds(c, proposalID, indices) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/pdao/claim-bonds", func(w http.ResponseWriter, r *http.Request) { proposalID, indices, err := parseClaimBondsParams(r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } isProposer := paramVal(r, "isProposer") == "true" opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := claimBonds(c, isProposer, proposalID, indices, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/pdao/can-defeat-proposal", func(w http.ResponseWriter, r *http.Request) { id, err := parseUint64Param(r, "id") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } index, err := parseUint64Param(r, "index") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canDefeatProposal(c, id, index) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/pdao/defeat-proposal", func(w http.ResponseWriter, r *http.Request) { id, err := parseUint64Param(r, "id") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } index, err := parseUint64Param(r, "index") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := defeatProposal(c, id, index, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/pdao/can-finalize-proposal", func(w http.ResponseWriter, r *http.Request) { id, err := parseUint64Param(r, "id") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canFinalizeProposal(c, id) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/pdao/finalize-proposal", func(w http.ResponseWriter, r *http.Request) { id, err := parseUint64Param(r, "id") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := finalizeProposal(c, id, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/pdao/estimate-set-voting-delegate-gas", func(w http.ResponseWriter, r *http.Request) { addr := common.HexToAddress(paramVal(r, "address")) resp, err := estimateSetVotingDelegateGas(c, addr) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/pdao/set-voting-delegate", func(w http.ResponseWriter, r *http.Request) { addr := common.HexToAddress(paramVal(r, "address")) opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := setVotingDelegate(c, addr, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/pdao/get-current-voting-delegate", func(w http.ResponseWriter, r *http.Request) { resp, err := getCurrentVotingDelegate(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/pdao/can-set-signalling-address", func(w http.ResponseWriter, r *http.Request) { addr := common.HexToAddress(paramVal(r, "address")) sig := paramVal(r, "signature") resp, err := canSetSignallingAddress(c, addr, sig) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/pdao/set-signalling-address", func(w http.ResponseWriter, r *http.Request) { @@ -497,26 +497,26 @@ func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { sig := paramVal(r, "signature") opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := setSignallingAddress(c, addr, sig, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/pdao/can-clear-signalling-address", func(w http.ResponseWriter, r *http.Request) { resp, err := canClearSignallingAddress(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/pdao/clear-signalling-address", func(w http.ResponseWriter, r *http.Request) { opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := clearSignallingAddress(c, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/pdao/can-propose-allow-listed-controllers", func(w http.ResponseWriter, r *http.Request) { @@ -527,7 +527,7 @@ func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { addresses = parseRawAddressList(addressList) } resp, err := canProposeAllowListedControllers(c, addresses) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/pdao/propose-allow-listed-controllers", func(w http.ResponseWriter, r *http.Request) { @@ -538,16 +538,16 @@ func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { } blockNumber, err := parseUint32Param(r, "blockNumber") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := proposeAllowListedControllers(c, addresses, blockNumber, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) } diff --git a/rocketpool/api/pdao/set-allow-list.go b/rocketpool/api/pdao/set-allow-list.go index 8aad33db0..e1af9f814 100644 --- a/rocketpool/api/pdao/set-allow-list.go +++ b/rocketpool/api/pdao/set-allow-list.go @@ -68,14 +68,14 @@ func canProposeAllowListedControllers(c *cli.Command, addressList []common.Addre if err != nil { return nil, err } - gasInfo, err := protocol.EstimateProposeAllowListedControllersGas(rp, addressList, blockNumber, pollard, opts) + gasLimits, err := protocol.EstimateProposeAllowListedControllersGas(rp, addressList, blockNumber, pollard, opts) if err != nil { return nil, err } // Update & return response response.BlockNumber = blockNumber - response.GasInfo = gasInfo + response.GasLimits = gasLimits return &response, nil } diff --git a/rocketpool/api/pdao/set-snapshot-address.go b/rocketpool/api/pdao/set-snapshot-address.go index 356910d11..3dcbde421 100644 --- a/rocketpool/api/pdao/set-snapshot-address.go +++ b/rocketpool/api/pdao/set-snapshot-address.go @@ -9,11 +9,11 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/rocketpool/eip712" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/contracts" "github.com/rocket-pool/smartnode/shared/types/api" cfgtypes "github.com/rocket-pool/smartnode/shared/types/config" - apiutils "github.com/rocket-pool/smartnode/shared/utils/api" "github.com/urfave/cli/v3" ) @@ -91,17 +91,18 @@ func canSetSignallingAddress(c *cli.Command, signallingAddress common.Address, s } // Parse signature into vrs components, v to uint8 and v,s to [32]byte - sig, err := apiutils.ParseEIP712(signature) + sig := eip712.Components{} + err = sig.UnmarshalText([]byte(signature)) if err != nil { fmt.Println("Error parsing signature", err) } // Get the gas info - gasInfo, err := contract.GetTransactionGasInfo(opts, "setSigner", signallingAddress, sig.V, sig.R, sig.S) + gasLimits, err := contract.GetTransactionGasInfo(opts, "setSigner", signallingAddress, sig.V, sig.R, sig.S) if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits // Return response return &response, nil @@ -129,7 +130,8 @@ func setSignallingAddress(c *cli.Command, signallingAddress common.Address, sign response := api.PDAOSetSignallingAddressResponse{} // Parse signature into vrs components, v to uint8 and v,s to [32]byte - sig, err := apiutils.ParseEIP712(signature) + sig := eip712.Components{} + err = sig.UnmarshalText([]byte(signature)) if err != nil { fmt.Println("Error parsing signature", err) } @@ -218,11 +220,11 @@ func canClearSignallingAddress(c *cli.Command) (*api.PDAOCanClearSignallingAddre } // Get the gas info - gasInfo, err := contract.GetTransactionGasInfo(opts, "clearSigner") + gasLimits, err := contract.GetTransactionGasInfo(opts, "clearSigner") if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits return &response, nil } diff --git a/rocketpool/api/pdao/update-recurring-spend.go b/rocketpool/api/pdao/update-recurring-spend.go index 38c888240..47d6f5b09 100644 --- a/rocketpool/api/pdao/update-recurring-spend.go +++ b/rocketpool/api/pdao/update-recurring-spend.go @@ -71,14 +71,14 @@ func canProposeRecurringSpendUpdate(c *cli.Command, contractName string, recipie if err != nil { return nil, err } - gasInfo, err := protocol.EstimateProposeRecurringTreasurySpendUpdateGas(rp, customMessage, contractName, recipient, amountPerPeriod, periodLength, numberOfPeriods, blockNumber, pollard, opts) + gasLimits, err := protocol.EstimateProposeRecurringTreasurySpendUpdateGas(rp, customMessage, contractName, recipient, amountPerPeriod, periodLength, numberOfPeriods, blockNumber, pollard, opts) if err != nil { return nil, err } // Update & return response response.BlockNumber = blockNumber - response.GasInfo = gasInfo + response.GasLimits = gasLimits return &response, nil } diff --git a/rocketpool/api/pdao/vote-proposal.go b/rocketpool/api/pdao/vote-proposal.go index 2cd79196e..7c0767062 100644 --- a/rocketpool/api/pdao/vote-proposal.go +++ b/rocketpool/api/pdao/vote-proposal.go @@ -109,11 +109,11 @@ func canVoteOnProposal(c *cli.Command, proposalId uint64, voteDirection types.Vo if err != nil { return nil, err } - gasInfo, err := protocol.EstimateVoteOnProposalGas(rp, proposalId, voteDirection, totalDelegatedVP, nodeIndex, proof, opts) + gasLimits, err := protocol.EstimateVoteOnProposalGas(rp, proposalId, voteDirection, totalDelegatedVP, nodeIndex, proof, opts) if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits // Update & return response return &response, nil diff --git a/rocketpool/api/pdao/voting.go b/rocketpool/api/pdao/voting.go index fabf4095f..18abd28e8 100644 --- a/rocketpool/api/pdao/voting.go +++ b/rocketpool/api/pdao/voting.go @@ -35,11 +35,11 @@ func estimateSetVotingDelegateGas(c *cli.Command, address common.Address) (*api. } // Get the gas info - gasInfo, err := network.EstimateSetVotingDelegateGas(rp, address, opts) + gasLimits, err := network.EstimateSetVotingDelegateGas(rp, address, opts) if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits // Return response return &response, nil diff --git a/rocketpool/api/queue/assign-deposits.go b/rocketpool/api/queue/assign-deposits.go index 74a793014..e8b1270f4 100644 --- a/rocketpool/api/queue/assign-deposits.go +++ b/rocketpool/api/queue/assign-deposits.go @@ -53,9 +53,9 @@ func canAssignDeposits(c *cli.Command, m int64) (*api.CanAssignDepositsResponse, if err != nil { return err } - gasInfo, err := deposit.EstimateAssignDepositsGas(rp, big.NewInt(m), opts) + gasLimits, err := deposit.EstimateAssignDepositsGas(rp, big.NewInt(m), opts) if err == nil { - response.GasInfo = gasInfo + response.GasLimits = gasLimits } return err }) diff --git a/rocketpool/api/queue/process.go b/rocketpool/api/queue/process.go index 7df0ce64f..a008bf2fe 100644 --- a/rocketpool/api/queue/process.go +++ b/rocketpool/api/queue/process.go @@ -53,9 +53,9 @@ func canProcessQueue(c *cli.Command, m int64) (*api.CanProcessQueueResponse, err if err != nil { return err } - gasInfo, err := deposit.EstimateAssignDepositsGas(rp, big.NewInt(m), opts) + gasLimits, err := deposit.EstimateAssignDepositsGas(rp, big.NewInt(m), opts) if err == nil { - response.GasInfo = gasInfo + response.GasLimits = gasLimits } return err }) diff --git a/rocketpool/api/queue/routes.go b/rocketpool/api/queue/routes.go index 198572b5d..2fa636e04 100644 --- a/rocketpool/api/queue/routes.go +++ b/rocketpool/api/queue/routes.go @@ -6,70 +6,70 @@ import ( "github.com/urfave/cli/v3" + "github.com/rocket-pool/smartnode/rocketpool/api/response" "github.com/rocket-pool/smartnode/shared/services" - apiutils "github.com/rocket-pool/smartnode/shared/utils/api" ) // RegisterRoutes registers the queue module's HTTP routes onto mux. func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { mux.HandleFunc("/api/queue/status", func(w http.ResponseWriter, r *http.Request) { resp, err := getStatus(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/queue/can-process", func(w http.ResponseWriter, r *http.Request) { m, err := parseUint32Param(r, "max") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canProcessQueue(c, int64(m)) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/queue/process", func(w http.ResponseWriter, r *http.Request) { m, err := parseUint32Param(r, "max") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := processQueue(c, int64(m), opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/queue/get-queue-details", func(w http.ResponseWriter, r *http.Request) { resp, err := getQueueDetails(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/queue/can-assign-deposits", func(w http.ResponseWriter, r *http.Request) { m, err := parseUint32Param(r, "max") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canAssignDeposits(c, int64(m)) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/queue/assign-deposits", func(w http.ResponseWriter, r *http.Request) { m, err := parseUint32Param(r, "max") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := assignDeposits(c, int64(m), opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) } diff --git a/shared/utils/api/http.go b/rocketpool/api/response/response.go similarity index 99% rename from shared/utils/api/http.go rename to rocketpool/api/response/response.go index 215dc2489..e73949acb 100644 --- a/shared/utils/api/http.go +++ b/rocketpool/api/response/response.go @@ -1,4 +1,4 @@ -package api +package response import ( "errors" diff --git a/rocketpool/api/security/cancel-proposal.go b/rocketpool/api/security/cancel-proposal.go index 3b752a695..dd0520bb5 100644 --- a/rocketpool/api/security/cancel-proposal.go +++ b/rocketpool/api/security/cancel-proposal.go @@ -74,9 +74,9 @@ func canCancelProposal(c *cli.Command, proposalId uint64) (*api.SecurityCanCance if err != nil { return err } - gasInfo, err := security.EstimateCancelProposalGas(rp, proposalId, opts) + gasLimits, err := security.EstimateCancelProposalGas(rp, proposalId, opts) if err == nil { - response.GasInfo = gasInfo + response.GasLimits = gasLimits } return err }) diff --git a/rocketpool/api/security/execute-proposal.go b/rocketpool/api/security/execute-proposal.go index 1b5b0ecdf..4bc835b68 100644 --- a/rocketpool/api/security/execute-proposal.go +++ b/rocketpool/api/security/execute-proposal.go @@ -62,9 +62,9 @@ func canExecuteProposal(c *cli.Command, proposalId uint64) (*api.SecurityCanExec if err != nil { return err } - gasInfo, err := security.EstimateExecuteProposalGas(rp, proposalId, opts) + gasLimits, err := security.EstimateExecuteProposalGas(rp, proposalId, opts) if err == nil { - response.GasInfo = gasInfo + response.GasLimits = gasLimits } return err }) diff --git a/rocketpool/api/security/join.go b/rocketpool/api/security/join.go index 38c30b7a0..a3b57f58b 100644 --- a/rocketpool/api/security/join.go +++ b/rocketpool/api/security/join.go @@ -62,9 +62,9 @@ func canJoin(c *cli.Command) (*api.SecurityCanJoinResponse, error) { if err != nil { return err } - gasInfo, err := security.EstimateJoinGas(rp, opts) + gasLimits, err := security.EstimateJoinGas(rp, opts) if err == nil { - response.GasInfo = gasInfo + response.GasLimits = gasLimits } return err }) diff --git a/rocketpool/api/security/leave.go b/rocketpool/api/security/leave.go index 9e9bba263..eb4ca6cba 100644 --- a/rocketpool/api/security/leave.go +++ b/rocketpool/api/security/leave.go @@ -52,9 +52,9 @@ func canLeave(c *cli.Command) (*api.SecurityCanLeaveResponse, error) { if err != nil { return err } - gasInfo, err := security.EstimateLeaveGas(rp, opts) + gasLimits, err := security.EstimateLeaveGas(rp, opts) if err == nil { - response.GasInfo = gasInfo + response.GasLimits = gasLimits } return err }) diff --git a/rocketpool/api/security/propose-leave.go b/rocketpool/api/security/propose-leave.go index 605c042ca..25cdcf554 100644 --- a/rocketpool/api/security/propose-leave.go +++ b/rocketpool/api/security/propose-leave.go @@ -53,13 +53,13 @@ func canProposeLeave(c *cli.Command) (*api.SecurityCanProposeLeaveResponse, erro if err != nil { return nil, err } - gasInfo, err := security.EstimateRequestLeaveGas(rp, opts) + gasLimits, err := security.EstimateRequestLeaveGas(rp, opts) if err != nil { return nil, err } // Update & return response - response.GasInfo = gasInfo + response.GasLimits = gasLimits return &response, nil } diff --git a/rocketpool/api/security/propose-settings.go b/rocketpool/api/security/propose-settings.go index 6edee9a0b..6a19a14d7 100644 --- a/rocketpool/api/security/propose-settings.go +++ b/rocketpool/api/security/propose-settings.go @@ -7,7 +7,6 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/urfave/cli/v3" - "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/settings/protocol" "github.com/rocket-pool/smartnode/bindings/settings/security" "github.com/rocket-pool/smartnode/shared/services" @@ -53,7 +52,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = security.EstimateProposeCreateLotEnabledGas(rp, newValue, opts) + response.GasLimits, err = security.EstimateProposeCreateLotEnabledGas(rp, newValue, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing CreateLotEnabled: %w", err) } @@ -64,7 +63,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = security.EstimateProposeBidOnLotEnabledGas(rp, newValue, opts) + response.GasLimits, err = security.EstimateProposeBidOnLotEnabledGas(rp, newValue, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing BidOnLotEnabled: %w", err) } @@ -78,7 +77,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = security.EstimateProposeDepositEnabledGas(rp, newValue, opts) + response.GasLimits, err = security.EstimateProposeDepositEnabledGas(rp, newValue, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing DepositEnabled: %w", err) } @@ -89,7 +88,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = security.EstimateProposeAssignDepositsEnabledGas(rp, newValue, opts) + response.GasLimits, err = security.EstimateProposeAssignDepositsEnabledGas(rp, newValue, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing AssignDepositsEnabled: %w", err) } @@ -103,7 +102,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = security.EstimateProposeMinipoolSubmitWithdrawableEnabledGas(rp, newValue, opts) + response.GasLimits, err = security.EstimateProposeMinipoolSubmitWithdrawableEnabledGas(rp, newValue, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing MinipoolSubmitWithdrawableEnabled: %w", err) } @@ -114,7 +113,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = security.EstimateProposeBondReductionEnabledGas(rp, newValue, opts) + response.GasLimits, err = security.EstimateProposeBondReductionEnabledGas(rp, newValue, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing BondReductionEnabled: %w", err) } @@ -128,7 +127,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = security.EstimateProposeSubmitBalancesEnabledGas(rp, newValue, opts) + response.GasLimits, err = security.EstimateProposeSubmitBalancesEnabledGas(rp, newValue, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing SubmitBalancesEnabled: %w", err) } @@ -139,7 +138,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = security.EstimateProposeSubmitRewardsEnabledGas(rp, newValue, opts) + response.GasLimits, err = security.EstimateProposeSubmitRewardsEnabledGas(rp, newValue, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing SubmitRewardsEnabled: %w", err) } @@ -149,7 +148,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = security.EstimateProposeNodeComissionShareSecurityCouncilAdder(rp, newValue, opts) + response.GasLimits, err = security.EstimateProposeNodeComissionShareSecurityCouncilAdder(rp, newValue, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing NodeComissionShareSecurityCouncilAdder: %w", err) } @@ -164,7 +163,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = security.EstimateProposeNodeRegistrationEnabledGas(rp, newValue, opts) + response.GasLimits, err = security.EstimateProposeNodeRegistrationEnabledGas(rp, newValue, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing NodeRegistrationEnabled: %w", err) } @@ -175,7 +174,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = security.EstimateProposeSmoothingPoolRegistrationEnabledGas(rp, newValue, opts) + response.GasLimits, err = security.EstimateProposeSmoothingPoolRegistrationEnabledGas(rp, newValue, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing SmoothingPoolRegistrationEnabled: %w", err) } @@ -186,7 +185,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = security.EstimateProposeNodeDepositEnabledGas(rp, newValue, opts) + response.GasLimits, err = security.EstimateProposeNodeDepositEnabledGas(rp, newValue, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing NodeDepositEnabled: %w", err) } @@ -197,7 +196,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, if err != nil { return nil, err } - response.GasInfo, err = security.EstimateProposeVacantMinipoolsEnabledGas(rp, newValue, opts) + response.GasLimits, err = security.EstimateProposeVacantMinipoolsEnabledGas(rp, newValue, opts) if err != nil { return nil, fmt.Errorf("error estimating gas for proposing VacantMinipoolsEnabled: %w", err) } @@ -205,8 +204,7 @@ func canProposeSetting(c *cli.Command, contractName string, settingName string, } // Make sure a setting was actually hit - blankGasInfo := rocketpool.GasInfo{} - if response.GasInfo == blankGasInfo { + if response.GasLimits.IsBlank() { return nil, fmt.Errorf("[%s - %s] is not a valid PDAO contract and setting name combo", contractName, settingName) } diff --git a/rocketpool/api/security/routes.go b/rocketpool/api/security/routes.go index 2446a17ef..8aff0f67a 100644 --- a/rocketpool/api/security/routes.go +++ b/rocketpool/api/security/routes.go @@ -6,50 +6,50 @@ import ( "github.com/urfave/cli/v3" + "github.com/rocket-pool/smartnode/rocketpool/api/response" "github.com/rocket-pool/smartnode/shared/services" - apiutils "github.com/rocket-pool/smartnode/shared/utils/api" ) // RegisterRoutes registers the security module's HTTP routes onto mux. func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { mux.HandleFunc("/api/security/status", func(w http.ResponseWriter, r *http.Request) { resp, err := getStatus(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/security/members", func(w http.ResponseWriter, r *http.Request) { resp, err := getMembers(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/security/proposals", func(w http.ResponseWriter, r *http.Request) { resp, err := getProposals(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/security/proposal-details", func(w http.ResponseWriter, r *http.Request) { id, err := parseUint64(r, "id") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := getProposal(c, id) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/security/can-propose-leave", func(w http.ResponseWriter, r *http.Request) { resp, err := canProposeLeave(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/security/propose-leave", func(w http.ResponseWriter, r *http.Request) { opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := proposeLeave(c, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/security/can-propose-setting", func(w http.ResponseWriter, r *http.Request) { @@ -57,7 +57,7 @@ func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { settingName := r.URL.Query().Get("settingName") value := r.URL.Query().Get("value") resp, err := canProposeSetting(c, contractName, settingName, value) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/security/propose-setting", func(w http.ResponseWriter, r *http.Request) { @@ -66,117 +66,117 @@ func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { value := r.FormValue("value") opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := proposeSetting(c, contractName, settingName, value, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/security/can-cancel-proposal", func(w http.ResponseWriter, r *http.Request) { id, err := parseUint64(r, "id") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canCancelProposal(c, id) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/security/cancel-proposal", func(w http.ResponseWriter, r *http.Request) { id, err := parseUint64(r, "id") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := cancelProposal(c, id, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/security/can-vote-proposal", func(w http.ResponseWriter, r *http.Request) { id, err := parseUint64(r, "id") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canVoteOnProposal(c, id) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/security/vote-proposal", func(w http.ResponseWriter, r *http.Request) { id, err := parseUint64(r, "id") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } support := r.FormValue("support") == "true" opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := voteOnProposal(c, id, support, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/security/can-execute-proposal", func(w http.ResponseWriter, r *http.Request) { id, err := parseUint64(r, "id") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := canExecuteProposal(c, id) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/security/execute-proposal", func(w http.ResponseWriter, r *http.Request) { id, err := parseUint64(r, "id") if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := executeProposal(c, id, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/security/can-join", func(w http.ResponseWriter, r *http.Request) { resp, err := canJoin(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/security/join", func(w http.ResponseWriter, r *http.Request) { opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := join(c, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/security/can-leave", func(w http.ResponseWriter, r *http.Request) { resp, err := canLeave(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/security/leave", func(w http.ResponseWriter, r *http.Request) { opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := leave(c, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) } diff --git a/rocketpool/api/security/vote-proposal.go b/rocketpool/api/security/vote-proposal.go index 960dea5ff..96693732f 100644 --- a/rocketpool/api/security/vote-proposal.go +++ b/rocketpool/api/security/vote-proposal.go @@ -90,9 +90,9 @@ func canVoteOnProposal(c *cli.Command, proposalId uint64) (*api.SecurityCanVoteO if err != nil { return err } - gasInfo, err := security.EstimateVoteOnProposalGas(rp, proposalId, false, opts) + gasLimits, err := security.EstimateVoteOnProposalGas(rp, proposalId, false, opts) if err == nil { - response.GasInfo = gasInfo + response.GasLimits = gasLimits } return err }) diff --git a/rocketpool/api/service/routes.go b/rocketpool/api/service/routes.go index ca9c2bbb7..455f33a72 100644 --- a/rocketpool/api/service/routes.go +++ b/rocketpool/api/service/routes.go @@ -3,30 +3,29 @@ package service import ( "net/http" + "github.com/rocket-pool/smartnode/rocketpool/api/response" "github.com/urfave/cli/v3" - - apiutils "github.com/rocket-pool/smartnode/shared/utils/api" ) // RegisterRoutes registers the service module's HTTP routes onto mux. func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { mux.HandleFunc("/api/service/get-client-status", func(w http.ResponseWriter, r *http.Request) { resp, err := getClientStatus(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/service/restart-vc", func(w http.ResponseWriter, r *http.Request) { resp, err := restartVc(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/service/terminate-data-folder", func(w http.ResponseWriter, r *http.Request) { resp, err := terminateDataFolder(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/service/get-gas-price-from-latest-block", func(w http.ResponseWriter, r *http.Request) { resp, err := getGasPriceFromLatestBlock(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) } diff --git a/rocketpool/api/upgrade/execute-upgrade.go b/rocketpool/api/upgrade/execute-upgrade.go index 5d84a6722..1eef3b9c4 100644 --- a/rocketpool/api/upgrade/execute-upgrade.go +++ b/rocketpool/api/upgrade/execute-upgrade.go @@ -84,11 +84,11 @@ func canExecuteUpgrade(c *cli.Command, upgradeProposalId uint64) (*api.CanExecut if err != nil { return nil, err } - gasInfo, err := upgrades.EstimateExecuteUpgradeGas(rp, upgradeProposalId, opts) + gasLimits, err := upgrades.EstimateExecuteUpgradeGas(rp, upgradeProposalId, opts) if err != nil { return nil, err } - response.GasInfo = gasInfo + response.GasLimits = gasLimits } return &response, nil diff --git a/rocketpool/api/upgrade/routes.go b/rocketpool/api/upgrade/routes.go index 4eb0912ce..1c94520d2 100644 --- a/rocketpool/api/upgrade/routes.go +++ b/rocketpool/api/upgrade/routes.go @@ -6,8 +6,8 @@ import ( "github.com/urfave/cli/v3" + "github.com/rocket-pool/smartnode/rocketpool/api/response" "github.com/rocket-pool/smartnode/shared/services" - apiutils "github.com/rocket-pool/smartnode/shared/utils/api" cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" ) @@ -15,31 +15,31 @@ import ( func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { mux.HandleFunc("/api/upgrade/get-upgrade-proposals", func(w http.ResponseWriter, r *http.Request) { resp, err := getUpgradeProposals(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/upgrade/can-execute-upgrade", func(w http.ResponseWriter, r *http.Request) { id, err := cliutils.ValidatePositiveUint("upgrade proposal ID", r.URL.Query().Get("id")) if err != nil { - apiutils.WriteResponse(w, nil, err) + response.WriteResponse(w, nil, err) return } resp, err := canExecuteUpgrade(c, id) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/upgrade/execute-upgrade", func(w http.ResponseWriter, r *http.Request) { id, err := strconv.ParseUint(r.URL.Query().Get("id"), 10, 64) if err != nil { - apiutils.WriteResponse(w, nil, err) + response.WriteResponse(w, nil, err) return } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := executeUpgrade(c, id, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) } diff --git a/rocketpool/api/version.go b/rocketpool/api/version.go index 832e68741..673abd571 100644 --- a/rocketpool/api/version.go +++ b/rocketpool/api/version.go @@ -3,8 +3,8 @@ package api import ( "net/http" + "github.com/rocket-pool/smartnode/rocketpool/api/response" "github.com/rocket-pool/smartnode/shared" - apiutils "github.com/rocket-pool/smartnode/shared/utils/api" ) type VersionResponse struct { @@ -16,7 +16,7 @@ type VersionResponse struct { // RegisterVersionRoute registers the /api/version endpoint on mux. func RegisterVersionRoute(mux *http.ServeMux) { mux.HandleFunc("/api/version", func(w http.ResponseWriter, r *http.Request) { - response := VersionResponse{Version: shared.RocketPoolVersion()} - apiutils.WriteResponse(w, &response, nil) + resp := VersionResponse{Version: shared.RocketPoolVersion()} + response.WriteResponse(w, &resp, nil) }) } diff --git a/rocketpool/api/wait.go b/rocketpool/api/wait.go index 0dc873a80..6fe31add0 100644 --- a/rocketpool/api/wait.go +++ b/rocketpool/api/wait.go @@ -7,9 +7,9 @@ import ( "github.com/urfave/cli/v3" "github.com/rocket-pool/smartnode/bindings/utils" + "github.com/rocket-pool/smartnode/rocketpool/api/response" "github.com/rocket-pool/smartnode/shared/services" apitypes "github.com/rocket-pool/smartnode/shared/types/api" - apiutils "github.com/rocket-pool/smartnode/shared/utils/api" ) // RegisterWaitRoute registers the /api/wait endpoint on mux. @@ -19,11 +19,11 @@ func RegisterWaitRoute(mux *http.ServeMux, c *cli.Command) { hash := common.HexToHash(r.URL.Query().Get("txHash")) rp, err := services.GetRocketPool(c) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } - response := apitypes.APIResponse{} + resp := apitypes.APIResponse{} _, err = utils.WaitForTransactionWithContext(r.Context(), rp.Client, hash) - apiutils.WriteResponse(w, &response, err) + response.WriteResponse(w, &resp, err) }) } diff --git a/rocketpool/api/wallet/ens-name.go b/rocketpool/api/wallet/ens-name.go index cc5fd370e..0c9066a22 100644 --- a/rocketpool/api/wallet/ens-name.go +++ b/rocketpool/api/wallet/ens-name.go @@ -7,7 +7,7 @@ import ( "github.com/urfave/cli/v3" ens "github.com/wealdtech/go-ens/v3" - "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/types/api" ) @@ -71,17 +71,17 @@ func setEnsName(c *cli.Command, name string, onlyEstimateGas bool, opts *bind.Tr Address: account.Address, EnsName: name, TxHash: tx.Hash(), - GasInfo: rocketpool.GasInfo{ - EstGasLimit: tx.Gas(), - SafeGasLimit: uint64(float64(tx.Gas()) * GasLimitMultiplier), + GasLimits: gaslimit.Limits{ + Estimated: tx.Gas(), + Safe: uint64(float64(tx.Gas()) * GasLimitMultiplier), }, } - if response.GasInfo.EstGasLimit > MaxGasLimit { - return nil, fmt.Errorf("estimated gas of %d is greater than the max gas limit of %d", response.GasInfo.EstGasLimit, MaxGasLimit) + if response.GasLimits.Estimated > MaxGasLimit { + return nil, fmt.Errorf("estimated gas of %d is greater than the max gas limit of %d", response.GasLimits.Estimated, MaxGasLimit) } - if response.GasInfo.SafeGasLimit > MaxGasLimit { - response.GasInfo.SafeGasLimit = MaxGasLimit + if response.GasLimits.Safe > MaxGasLimit { + response.GasLimits.Safe = MaxGasLimit } return &response, nil diff --git a/rocketpool/api/wallet/routes.go b/rocketpool/api/wallet/routes.go index 584947d11..babbca17a 100644 --- a/rocketpool/api/wallet/routes.go +++ b/rocketpool/api/wallet/routes.go @@ -7,21 +7,21 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/urfave/cli/v3" + "github.com/rocket-pool/smartnode/rocketpool/api/response" "github.com/rocket-pool/smartnode/shared/services" - apiutils "github.com/rocket-pool/smartnode/shared/utils/api" ) // RegisterRoutes registers the wallet module's HTTP routes onto mux. func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { mux.HandleFunc("/api/wallet/status", func(w http.ResponseWriter, r *http.Request) { resp, err := getStatus(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/wallet/set-password", func(w http.ResponseWriter, r *http.Request) { password := r.FormValue("password") resp, err := setPassword(c, password) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/wallet/init", func(w http.ResponseWriter, r *http.Request) { @@ -30,7 +30,7 @@ func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { derivationPath = r.FormValue("derivationPath") } resp, err := initWalletWithPath(c, derivationPath) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/wallet/recover", func(w http.ResponseWriter, r *http.Request) { @@ -39,7 +39,7 @@ func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { derivationPath := r.FormValue("derivationPath") walletIndex, _ := strconv.ParseUint(r.FormValue("walletIndex"), 10, 64) resp, err := recoverWalletWithParams(c, mnemonic, skipRecovery, derivationPath, uint(walletIndex)) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/wallet/search-and-recover", func(w http.ResponseWriter, r *http.Request) { @@ -47,7 +47,7 @@ func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { address := common.HexToAddress(r.FormValue("address")) skipRecovery := r.FormValue("skipValidatorKeyRecovery") == "true" resp, err := searchAndRecoverWalletWithParams(c, mnemonic, address, skipRecovery) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/wallet/test-recover", func(w http.ResponseWriter, r *http.Request) { @@ -56,7 +56,7 @@ func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { derivationPath := r.FormValue("derivationPath") walletIndex, _ := strconv.ParseUint(r.FormValue("walletIndex"), 10, 64) resp, err := testRecoverWalletWithParams(c, mnemonic, skipRecovery, derivationPath, uint(walletIndex)) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/wallet/test-search-and-recover", func(w http.ResponseWriter, r *http.Request) { @@ -64,29 +64,29 @@ func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { address := common.HexToAddress(r.FormValue("address")) skipRecovery := r.FormValue("skipValidatorKeyRecovery") == "true" resp, err := testSearchAndRecoverWalletWithParams(c, mnemonic, address, skipRecovery) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/wallet/rebuild", func(w http.ResponseWriter, r *http.Request) { resp, err := rebuildWallet(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/wallet/export", func(w http.ResponseWriter, r *http.Request) { resp, err := exportWallet(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/wallet/masquerade", func(w http.ResponseWriter, r *http.Request) { address := common.HexToAddress(r.FormValue("address")) observe := r.FormValue("observe") == "true" resp, err := masquerade(c, address, observe) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/wallet/end-masquerade", func(w http.ResponseWriter, r *http.Request) { resp, err := endMasquerade(c) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/wallet/estimate-gas-set-ens-name", func(w http.ResponseWriter, r *http.Request) { @@ -96,21 +96,21 @@ func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { } opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := setEnsName(c, name, true, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) mux.HandleFunc("/api/wallet/set-ens-name", func(w http.ResponseWriter, r *http.Request) { name := r.FormValue("name") opts, err := services.GetNodeAccountTransactorFromRequest(c, r) if err != nil { - apiutils.WriteErrorResponse(w, err) + response.WriteErrorResponse(w, err) return } resp, err := setEnsName(c, name, false, opts) - apiutils.WriteResponse(w, resp, err) + response.WriteResponse(w, resp, err) }) } diff --git a/rocketpool/eip712/eip712.go b/rocketpool/eip712/eip712.go new file mode 100644 index 000000000..5fb166a10 --- /dev/null +++ b/rocketpool/eip712/eip712.go @@ -0,0 +1,60 @@ +package eip712 + +import ( + "encoding/hex" + "fmt" + "regexp" + "strconv" +) + +type Components struct { + V uint8 `json:"v"` + R [32]byte `json:"r"` + S [32]byte `json:"s"` +} + +func (c *Components) UnmarshalText(text []byte) error { + signature := string(text) + + if c == nil { + return fmt.Errorf("Components is nil") + } + + if len(signature) != 132 || signature[:2] != "0x" { + return fmt.Errorf("Invalid 129 byte 0x-prefixed EIP-712 signature while parsing: '%s'", signature) + } + signature = signature[2:] + if !regexp.MustCompile("^[A-Fa-f0-9]+$").MatchString(signature) { + return fmt.Errorf("Invalid 129 byte 0x-prefixed EIP-712 signature while parsing: '%s'", signature) + } + + // Slice signature string into v, r, s component of a signature giving node permission to use the given signer + str_v := signature[len(signature)-2:] + str_r := signature[:64] + str_s := signature[64:128] + + // Convert v to uint8 and v,s to [32]byte + bytes_r, err := hex.DecodeString(str_r) + if err != nil { + return fmt.Errorf("error decoding r: %v", err) + } + bytes_s, err := hex.DecodeString(str_s) + if err != nil { + return fmt.Errorf("error decoding s: %v", err) + } + + int_v, err := strconv.ParseUint(str_v, 16, 8) + if err != nil { + return fmt.Errorf("error parsing v: %v", err) + } + + c.V = uint8(int_v) + c.R = ([32]byte)(bytes_r) + c.S = ([32]byte)(bytes_s) + + return nil +} + +func (c *Components) MarshalText() ([]byte, error) { + return []byte(fmt.Sprintf("0x%x%x%x", c.R, c.S, c.V)), nil +} diff --git a/rocketpool/eip712/eip712_test.go b/rocketpool/eip712/eip712_test.go new file mode 100644 index 000000000..efe0b465a --- /dev/null +++ b/rocketpool/eip712/eip712_test.go @@ -0,0 +1,58 @@ +package eip712 + +import ( + "bytes" + "encoding/hex" + "testing" +) + +const ( + sigStr = "0x659e8fd295febd9bdec44e1e357f57860498756080ff588ed4b47cfe66306ee94652244f44f4b0e6b059fadd07a9ca81361fc40af4391c4d54bbc40e471f79921b" + + expectedV = 27 + expectedR = "659e8fd295febd9bdec44e1e357f57860498756080ff588ed4b47cfe66306ee9" + expectedS = "4652244f44f4b0e6b059fadd07a9ca81361fc40af4391c4d54bbc40e471f7992" +) + +func TestUnmarshalText(t *testing.T) { + sig := Components{} + err := sig.UnmarshalText([]byte(sigStr)) + if err != nil { + t.Fatalf("Failed to unmarshal text: %v", err) + } + + if sig.V != expectedV { + t.Fatalf("Expected V: %d, got: %d", expectedV, sig.V) + } + expectedRBytes, err := hex.DecodeString(expectedR) + if err != nil { + t.Fatalf("Failed to decode expected R: %v", err) + } + if !bytes.Equal(sig.R[:], expectedRBytes) { + t.Fatalf("Expected R: %x, got: %x", expectedRBytes, sig.R[:]) + } + expectedSBytes, err := hex.DecodeString(expectedS) + if err != nil { + t.Fatalf("Failed to decode expected S: %v", err) + } + if !bytes.Equal(sig.S[:], expectedSBytes) { + t.Fatalf("Expected S: %x, got: %x", expectedSBytes, sig.S[:]) + } +} + +func TestRoundTrip(t *testing.T) { + sig := Components{} + err := sig.UnmarshalText([]byte(sigStr)) + if err != nil { + t.Fatalf("Failed to unmarshal text: %v", err) + } + + marshalled, err := sig.MarshalText() + if err != nil { + t.Fatalf("Failed to marshal text: %v", err) + } + + if string(marshalled) != sigStr { + t.Fatalf("Expected marshalled: %s, got: %s", sigStr, string(marshalled)) + } +} diff --git a/rocketpool/node/defend-challenge-exit.go b/rocketpool/node/defend-challenge-exit.go index ed557848c..556c63c57 100644 --- a/rocketpool/node/defend-challenge-exit.go +++ b/rocketpool/node/defend-challenge-exit.go @@ -10,6 +10,8 @@ import ( "github.com/rocket-pool/smartnode/bindings/megapool" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" @@ -19,7 +21,6 @@ import ( rpgas "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" - "github.com/rocket-pool/smartnode/shared/utils/api" "github.com/rocket-pool/smartnode/shared/utils/log" ) @@ -188,22 +189,22 @@ func (t *defendChallengeExit) defendChallenge(rp *rocketpool.RocketPool, mp mega } t.log.Printlnf("[FINISHED] The beacon state proof has been successfully created.") - var gasInfo rocketpool.GasInfo + var gasLimits gaslimit.Limits if !exiting { // Get the gas limit - gasInfo, err = megapool.EstimateNotifyNotExitGas(rp, mp.GetAddress(), validatorId, slotTimestamp, validatorProof, slotProof, opts) + gasLimits, err = megapool.EstimateNotifyNotExitGas(rp, mp.GetAddress(), validatorId, slotTimestamp, validatorProof, slotProof, opts) if err != nil { return err } } else { - gasInfo, err = megapool.EstimateNotifyExitGas(rp, mp.GetAddress(), validatorId, slotTimestamp, validatorProof, slotProof, opts) + gasLimits, err = megapool.EstimateNotifyExitGas(rp, mp.GetAddress(), validatorId, slotTimestamp, validatorProof, slotProof, opts) if err != nil { return err } } - gas := big.NewInt(int64(gasInfo.SafeGasLimit)) + gas := big.NewInt(int64(gasLimits.Safe)) // Get the max fee maxFee := t.maxFee if maxFee == nil || maxFee.Uint64() == 0 { @@ -214,7 +215,7 @@ func (t *defendChallengeExit) defendChallenge(rp *rocketpool.RocketPool, mp mega } // Print the gas info - if !api.PrintAndCheckGasInfo(gasInfo, true, t.gasThreshold, &t.log, maxFee, t.gasLimit) { + if !gasLimits.PrintAndCheck(true, t.gasThreshold, &t.log, maxFee, t.gasLimit) { return nil } @@ -241,7 +242,7 @@ func (t *defendChallengeExit) defendChallenge(rp *rocketpool.RocketPool, mp mega } // Print TX info and wait for it to be included in a block - err = api.PrintAndWaitForTransaction(t.cfg, tx.Hash(), t.rp.Client, &t.log) + err = transactions.PrintAndWaitForTransaction(t.cfg, tx.Hash(), t.rp.Client, &t.log) if err != nil { return err } diff --git a/rocketpool/node/defend-pdao-props.go b/rocketpool/node/defend-pdao-props.go index d77eebfef..a61569b7f 100644 --- a/rocketpool/node/defend-pdao-props.go +++ b/rocketpool/node/defend-pdao-props.go @@ -11,6 +11,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/dao/protocol" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions" "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/shared/services" @@ -20,7 +21,6 @@ import ( "github.com/rocket-pool/smartnode/shared/services/proposals" "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" - "github.com/rocket-pool/smartnode/shared/utils/api" "github.com/rocket-pool/smartnode/shared/utils/log" ) @@ -251,11 +251,11 @@ func (t *defendPdaoProps) defendProposal(prop defendableProposal) error { } // Get the gas limit - gasInfo, err := protocol.EstimateSubmitRootGas(t.rp, propID, challengedIndex, pollard, opts) + gasLimits, err := protocol.EstimateSubmitRootGas(t.rp, propID, challengedIndex, pollard, opts) if err != nil { return fmt.Errorf("error estimating the gas required to respond to challenge against proposal %d, index %d: %w", propID, challengedIndex, err) } - gas := big.NewInt(int64(gasInfo.SafeGasLimit)) + gas := big.NewInt(int64(gasLimits.Safe)) // Get the max fee maxFee := t.maxFee @@ -267,7 +267,7 @@ func (t *defendPdaoProps) defendProposal(prop defendableProposal) error { } // Print the gas info - if !api.PrintAndCheckGasInfo(gasInfo, true, t.gasThreshold, t.log, maxFee, t.gasLimit) { + if !gasLimits.PrintAndCheck(true, t.gasThreshold, t.log, maxFee, t.gasLimit) { t.log.Println("NOTICE: Challenge responses bypass the automatic TX gas threshold, responding for safety.") } @@ -282,7 +282,7 @@ func (t *defendPdaoProps) defendProposal(prop defendableProposal) error { } // Print TX info and wait for it to be included in a block - err = api.PrintAndWaitForTransaction(t.cfg, hash, t.rp.Client, t.log) + err = transactions.PrintAndWaitForTransaction(t.cfg, hash, t.rp.Client, t.log) if err != nil { return err } diff --git a/rocketpool/node/distribute-minipools.go b/rocketpool/node/distribute-minipools.go index 140abc342..e6caad350 100644 --- a/rocketpool/node/distribute-minipools.go +++ b/rocketpool/node/distribute-minipools.go @@ -11,6 +11,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/minipool" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions" rptypes "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" rpstate "github.com/rocket-pool/smartnode/bindings/utils/state" @@ -22,7 +23,6 @@ import ( rpgas "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" - "github.com/rocket-pool/smartnode/shared/utils/api" "github.com/rocket-pool/smartnode/shared/utils/log" ) @@ -232,7 +232,7 @@ func (t *distributeMinipools) distributeMinipool(mpd *rpstate.NativeMinipoolDeta if !success { return false, fmt.Errorf("minipool %s cannot be converted to v3 (current version: %d)", mpd.MinipoolAddress.Hex(), mp.GetVersion()) } - gasInfo, err := mpv3.EstimateDistributeBalanceGas(true, opts) + gasLimits, err := mpv3.EstimateDistributeBalanceGas(true, opts) if err != nil { return false, fmt.Errorf("Could not estimate the gas required to distribute minipool %s: %w", mpd.MinipoolAddress.Hex(), err) } @@ -240,7 +240,7 @@ func (t *distributeMinipools) distributeMinipool(mpd *rpstate.NativeMinipoolDeta if t.gasLimit != 0 { gas = new(big.Int).SetUint64(t.gasLimit) } else { - gas = new(big.Int).SetUint64(gasInfo.SafeGasLimit) + gas = new(big.Int).SetUint64(gasLimits.Safe) } // Get the max fee @@ -253,7 +253,7 @@ func (t *distributeMinipools) distributeMinipool(mpd *rpstate.NativeMinipoolDeta } // Print the gas info - if !api.PrintAndCheckGasInfo(gasInfo, true, t.gasThreshold, &t.log, maxFee, t.gasLimit) { + if !gasLimits.PrintAndCheck(true, t.gasThreshold, &t.log, maxFee, t.gasLimit) { return false, nil } @@ -268,7 +268,7 @@ func (t *distributeMinipools) distributeMinipool(mpd *rpstate.NativeMinipoolDeta } // Print TX info and wait for it to be included in a block - err = api.PrintAndWaitForTransaction(t.cfg, hash, t.rp.Client, &t.log) + err = transactions.PrintAndWaitForTransaction(t.cfg, hash, t.rp.Client, &t.log) if err != nil { return false, err } diff --git a/rocketpool/node/notify-final-balance.go b/rocketpool/node/notify-final-balance.go index 02c235c44..a649aa5c2 100644 --- a/rocketpool/node/notify-final-balance.go +++ b/rocketpool/node/notify-final-balance.go @@ -11,6 +11,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/megapool" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions" "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/shared/services" @@ -19,7 +20,6 @@ import ( rpgas "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" - "github.com/rocket-pool/smartnode/shared/utils/api" "github.com/rocket-pool/smartnode/shared/utils/log" ) @@ -232,12 +232,12 @@ func (t *notifyFinalBalance) createFinalBalanceProof(rp *rocketpool.RocketPool, t.log.Printlnf("The validator final balance proof has been successfully created.") // Get the gas limit - gasInfo, err := megapool.EstimateNotifyFinalBalance(rp, mp.GetAddress(), validatorId, slotTimestamp, finalBalanceProof, validatorProof, slotProof, opts) + gasLimits, err := megapool.EstimateNotifyFinalBalance(rp, mp.GetAddress(), validatorId, slotTimestamp, finalBalanceProof, validatorProof, slotProof, opts) if err != nil { t.log.Printlnf("Could not estimate the gas required to notify final balance on megapool validator %d: %w", validatorId, err) return err } - gas := big.NewInt(int64(gasInfo.SafeGasLimit)) + gas := big.NewInt(int64(gasLimits.Safe)) // Get the max fee maxFee := t.maxFee if maxFee == nil || maxFee.Uint64() == 0 { @@ -248,7 +248,7 @@ func (t *notifyFinalBalance) createFinalBalanceProof(rp *rocketpool.RocketPool, } // Print the gas info - if !api.PrintAndCheckGasInfo(gasInfo, true, t.gasThreshold, &t.log, maxFee, t.gasLimit) { + if !gasLimits.PrintAndCheck(true, t.gasThreshold, &t.log, maxFee, t.gasLimit) { return nil } @@ -263,7 +263,7 @@ func (t *notifyFinalBalance) createFinalBalanceProof(rp *rocketpool.RocketPool, } // Print TX info and wait for it to be included in a block - err = api.PrintAndWaitForTransaction(t.cfg, tx.Hash(), t.rp.Client, &t.log) + err = transactions.PrintAndWaitForTransaction(t.cfg, tx.Hash(), t.rp.Client, &t.log) if err != nil { return err } diff --git a/rocketpool/node/notify-validator-exit.go b/rocketpool/node/notify-validator-exit.go index 86f8fb2cc..a35daf018 100644 --- a/rocketpool/node/notify-validator-exit.go +++ b/rocketpool/node/notify-validator-exit.go @@ -10,6 +10,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/megapool" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions" "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" @@ -20,7 +21,6 @@ import ( "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" "github.com/rocket-pool/smartnode/shared/types/eth2" - "github.com/rocket-pool/smartnode/shared/utils/api" "github.com/rocket-pool/smartnode/shared/utils/log" ) @@ -208,12 +208,12 @@ func (t *notifyValidatorExit) createExitProof(rp *rocketpool.RocketPool, beaconS t.log.Printlnf("[FINISHED] The validator exit proof has been successfully created.") // Get the gas limit - gasInfo, err := megapool.EstimateNotifyExitGas(rp, mp.GetAddress(), validatorId, slotTimestamp, validatorProof, slotProof, opts) + gasLimits, err := megapool.EstimateNotifyExitGas(rp, mp.GetAddress(), validatorId, slotTimestamp, validatorProof, slotProof, opts) if err != nil { t.log.Printlnf("Could not estimate the gas required to notify exit on megapool validator %d: %w", validatorId, err) return err } - gas := big.NewInt(int64(gasInfo.SafeGasLimit)) + gas := big.NewInt(int64(gasLimits.Safe)) // Get the max fee maxFee := t.maxFee if maxFee == nil || maxFee.Uint64() == 0 { @@ -224,7 +224,7 @@ func (t *notifyValidatorExit) createExitProof(rp *rocketpool.RocketPool, beaconS } // Print the gas info - if !api.PrintAndCheckGasInfo(gasInfo, true, t.gasThreshold, &t.log, maxFee, t.gasLimit) { + if !gasLimits.PrintAndCheck(true, t.gasThreshold, &t.log, maxFee, t.gasLimit) { return nil } @@ -239,7 +239,7 @@ func (t *notifyValidatorExit) createExitProof(rp *rocketpool.RocketPool, beaconS } // Print TX info and wait for it to be included in a block - err = api.PrintAndWaitForTransaction(t.cfg, tx.Hash(), t.rp.Client, &t.log) + err = transactions.PrintAndWaitForTransaction(t.cfg, tx.Hash(), t.rp.Client, &t.log) if err != nil { return err } diff --git a/rocketpool/node/prestake-megapool-validator.go b/rocketpool/node/prestake-megapool-validator.go index 10cf97668..e2b33e8ea 100644 --- a/rocketpool/node/prestake-megapool-validator.go +++ b/rocketpool/node/prestake-megapool-validator.go @@ -13,6 +13,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/deposit" "github.com/rocket-pool/smartnode/bindings/megapool" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions" "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/shared/services" @@ -20,7 +21,6 @@ import ( rpgas "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" - "github.com/rocket-pool/smartnode/shared/utils/api" "github.com/rocket-pool/smartnode/shared/utils/log" ) @@ -179,12 +179,12 @@ func (t *prestakeMegapoolValidator) assignDeposit(callopts *bind.CallOpts) error } // Get the gas limit - gasInfo, err := deposit.EstimateAssignDepositsGas(t.rp, big.NewInt(1), opts) + gasLimits, err := deposit.EstimateAssignDepositsGas(t.rp, big.NewInt(1), opts) if err != nil { t.log.Printlnf("error estimating assignment %w", err) return err } - gas := big.NewInt(int64(gasInfo.SafeGasLimit)) + gas := big.NewInt(int64(gasLimits.Safe)) // Get the max fee maxFee := t.maxFee if maxFee == nil || maxFee.Uint64() == 0 { @@ -195,7 +195,7 @@ func (t *prestakeMegapoolValidator) assignDeposit(callopts *bind.CallOpts) error } // Print the gas info - if !api.PrintAndCheckGasInfo(gasInfo, true, t.gasThreshold, &t.log, maxFee, t.gasLimit) { + if !gasLimits.PrintAndCheck(true, t.gasThreshold, &t.log, maxFee, t.gasLimit) { return nil } @@ -210,7 +210,7 @@ func (t *prestakeMegapoolValidator) assignDeposit(callopts *bind.CallOpts) error } // Print TX info and wait for it to be included in a block - err = api.PrintAndWaitForTransaction(t.cfg, hash, t.rp.Client, &t.log) + err = transactions.PrintAndWaitForTransaction(t.cfg, hash, t.rp.Client, &t.log) if err != nil { return err } diff --git a/rocketpool/node/provision-express-tickets.go b/rocketpool/node/provision-express-tickets.go index 625078c34..0958ca89c 100644 --- a/rocketpool/node/provision-express-tickets.go +++ b/rocketpool/node/provision-express-tickets.go @@ -9,6 +9,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/node" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions" "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/shared/services" @@ -16,7 +17,6 @@ import ( rpgas "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" - "github.com/rocket-pool/smartnode/shared/utils/api" "github.com/rocket-pool/smartnode/shared/utils/log" ) @@ -157,11 +157,11 @@ func (t *provisionExpress) provisionExpress(nodeAddress common.Address) error { } // Get the gas limit - gasInfo, err := node.EstimateProvisionExpressTicketsGas(t.rp, nodeAddress, opts) + gasLimits, err := node.EstimateProvisionExpressTicketsGas(t.rp, nodeAddress, opts) if err != nil { return err } - gas := big.NewInt(int64(gasInfo.SafeGasLimit)) + gas := big.NewInt(int64(gasLimits.Safe)) // Get the max fee maxFee := t.maxFee if maxFee == nil || maxFee.Uint64() == 0 { @@ -172,7 +172,7 @@ func (t *provisionExpress) provisionExpress(nodeAddress common.Address) error { } // Print the gas info - if !api.PrintAndCheckGasInfo(gasInfo, true, t.gasThreshold, &t.log, maxFee, t.gasLimit) { + if !gasLimits.PrintAndCheck(true, t.gasThreshold, &t.log, maxFee, t.gasLimit) { return nil } @@ -187,7 +187,7 @@ func (t *provisionExpress) provisionExpress(nodeAddress common.Address) error { } // Print TX info and wait for it to be included in a block - err = api.PrintAndWaitForTransaction(t.cfg, hash, t.rp.Client, &t.log) + err = transactions.PrintAndWaitForTransaction(t.cfg, hash, t.rp.Client, &t.log) if err != nil { return err } diff --git a/rocketpool/node/routes/routes.go b/rocketpool/node/routes/routes.go index fdbb6940a..295715f78 100644 --- a/rocketpool/node/routes/routes.go +++ b/rocketpool/node/routes/routes.go @@ -15,11 +15,11 @@ import ( odaoroutes "github.com/rocket-pool/smartnode/rocketpool/api/odao" pdaoroutes "github.com/rocket-pool/smartnode/rocketpool/api/pdao" queueroutes "github.com/rocket-pool/smartnode/rocketpool/api/queue" + "github.com/rocket-pool/smartnode/rocketpool/api/response" securityroutes "github.com/rocket-pool/smartnode/rocketpool/api/security" serviceroutes "github.com/rocket-pool/smartnode/rocketpool/api/service" upgraderoutes "github.com/rocket-pool/smartnode/rocketpool/api/upgrade" walletroutes "github.com/rocket-pool/smartnode/rocketpool/api/wallet" - apiutils "github.com/rocket-pool/smartnode/shared/utils/api" ) // RegisterRoutes registers all HTTP API routes onto mux. @@ -47,7 +47,7 @@ func RegisterRoutes(mux *http.ServeMux, c *cli.Command) { // Catch-all: any path not matched by a specific route gets a JSON 404. mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { - apiutils.WriteErrorResponse(w, &apiutils.NotFoundError{Path: r.URL.Path}) + response.WriteErrorResponse(w, &response.NotFoundError{Path: r.URL.Path}) }) } diff --git a/rocketpool/node/set-latest-delegate.go b/rocketpool/node/set-latest-delegate.go index fd08d1da6..e4d3f6039 100644 --- a/rocketpool/node/set-latest-delegate.go +++ b/rocketpool/node/set-latest-delegate.go @@ -12,6 +12,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/minipool" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions" "github.com/rocket-pool/smartnode/bindings/utils/eth" rpstate "github.com/rocket-pool/smartnode/bindings/utils/state" "github.com/rocket-pool/smartnode/shared/services/alerting" @@ -22,7 +23,6 @@ import ( rpgas "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" - "github.com/rocket-pool/smartnode/shared/utils/api" "github.com/rocket-pool/smartnode/shared/utils/log" ) @@ -208,7 +208,7 @@ func (t *setUseLatestDelegate) setUseLatestDelegate(mpd *rpstate.NativeMinipoolD if !success { return false, fmt.Errorf("minipool %s cannot be converted to v3 (current version: %d)", mpd.MinipoolAddress.Hex(), mp.GetVersion()) } - gasInfo, err := mpv3.EstimateSetUseLatestDelegateGas(opts) + gasLimits, err := mpv3.EstimateSetUseLatestDelegateGas(opts) if err != nil { return false, fmt.Errorf("Could not estimate the gas required to distribute minipool %s: %w", mpd.MinipoolAddress.Hex(), err) } @@ -216,7 +216,7 @@ func (t *setUseLatestDelegate) setUseLatestDelegate(mpd *rpstate.NativeMinipoolD if t.gasLimit != 0 { gas = new(big.Int).SetUint64(t.gasLimit) } else { - gas = new(big.Int).SetUint64(gasInfo.SafeGasLimit) + gas = new(big.Int).SetUint64(gasLimits.Safe) } // Get the max fee @@ -229,7 +229,7 @@ func (t *setUseLatestDelegate) setUseLatestDelegate(mpd *rpstate.NativeMinipoolD } // Print the gas info - if !api.PrintAndCheckGasInfo(gasInfo, true, t.gasThreshold, &t.log, maxFee, t.gasLimit) { + if !gasLimits.PrintAndCheck(true, t.gasThreshold, &t.log, maxFee, t.gasLimit) { return false, nil } @@ -244,7 +244,7 @@ func (t *setUseLatestDelegate) setUseLatestDelegate(mpd *rpstate.NativeMinipoolD } // Print TX info and wait for it to be included in a block - err = api.PrintAndWaitForTransaction(t.cfg, hash, t.rp.Client, &t.log) + err = transactions.PrintAndWaitForTransaction(t.cfg, hash, t.rp.Client, &t.log) if err != nil { return false, err } diff --git a/rocketpool/node/stake-megapool-validator.go b/rocketpool/node/stake-megapool-validator.go index 298115b49..4157f54e6 100644 --- a/rocketpool/node/stake-megapool-validator.go +++ b/rocketpool/node/stake-megapool-validator.go @@ -10,6 +10,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/megapool" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions" "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" @@ -20,7 +21,6 @@ import ( "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" "github.com/rocket-pool/smartnode/shared/types/eth2" - "github.com/rocket-pool/smartnode/shared/utils/api" "github.com/rocket-pool/smartnode/shared/utils/log" "github.com/rocket-pool/smartnode/shared/utils/validator" ) @@ -233,12 +233,12 @@ func (t *stakeMegapoolValidator) stakeValidator(rp *rocketpool.RocketPool, beaco t.log.Printlnf("The beacon state proof has been successfully created.") // Get the gas limit - gasInfo, err := megapool.EstimateStakeGas(rp, mp.GetAddress(), validatorId, slotTimestamp, validatorProof, slotProof, opts) + gasLimits, err := megapool.EstimateStakeGas(rp, mp.GetAddress(), validatorId, slotTimestamp, validatorProof, slotProof, opts) if err != nil { t.log.Printlnf("Could not estimate the gas required to stake megapool validator %d: %w", validatorId, err) return err } - gas := big.NewInt(int64(gasInfo.SafeGasLimit)) + gas := big.NewInt(int64(gasLimits.Safe)) // Get the max fee maxFee := t.maxFee if maxFee == nil || maxFee.Uint64() == 0 { @@ -249,7 +249,7 @@ func (t *stakeMegapoolValidator) stakeValidator(rp *rocketpool.RocketPool, beaco } // Print the gas info - if !api.PrintAndCheckGasInfo(gasInfo, true, t.gasThreshold, &t.log, maxFee, t.gasLimit) { + if !gasLimits.PrintAndCheck(true, t.gasThreshold, &t.log, maxFee, t.gasLimit) { return nil } @@ -264,7 +264,7 @@ func (t *stakeMegapoolValidator) stakeValidator(rp *rocketpool.RocketPool, beaco } // Print TX info and wait for it to be included in a block - err = api.PrintAndWaitForTransaction(t.cfg, tx.Hash(), t.rp.Client, &t.log) + err = transactions.PrintAndWaitForTransaction(t.cfg, tx.Hash(), t.rp.Client, &t.log) if err != nil { return err } diff --git a/rocketpool/node/verify-pdao-props.go b/rocketpool/node/verify-pdao-props.go index 8a96ff60e..16c8a0c5c 100644 --- a/rocketpool/node/verify-pdao-props.go +++ b/rocketpool/node/verify-pdao-props.go @@ -11,6 +11,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/dao/protocol" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions" "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/shared/services" @@ -20,7 +21,6 @@ import ( "github.com/rocket-pool/smartnode/shared/services/proposals" "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" - "github.com/rocket-pool/smartnode/shared/utils/api" "github.com/rocket-pool/smartnode/shared/utils/log" ) @@ -474,11 +474,11 @@ func (t *verifyPdaoProps) submitChallenge(challenge challenge) error { } // Get the gas limit - gasInfo, err := protocol.EstimateCreateChallengeGas(t.rp, propID, challengedIndex, challenge.challengedNode, challenge.witness, opts) + gasLimits, err := protocol.EstimateCreateChallengeGas(t.rp, propID, challengedIndex, challenge.challengedNode, challenge.witness, opts) if err != nil { return fmt.Errorf("error estimating the gas required to submit challenge against proposal %d, index %d: %w", propID, challengedIndex, err) } - gas := big.NewInt(int64(gasInfo.SafeGasLimit)) + gas := big.NewInt(int64(gasLimits.Safe)) // Get the max fee maxFee := t.maxFee @@ -490,7 +490,7 @@ func (t *verifyPdaoProps) submitChallenge(challenge challenge) error { } // Print the gas info - if !api.PrintAndCheckGasInfo(gasInfo, true, t.gasThreshold, t.log, maxFee, t.gasLimit) { + if !gasLimits.PrintAndCheck(true, t.gasThreshold, t.log, maxFee, t.gasLimit) { return nil } @@ -505,7 +505,7 @@ func (t *verifyPdaoProps) submitChallenge(challenge challenge) error { } // Print TX info and wait for it to be included in a block - err = api.PrintAndWaitForTransaction(t.cfg, hash, t.rp.Client, t.log) + err = transactions.PrintAndWaitForTransaction(t.cfg, hash, t.rp.Client, t.log) if err != nil { return err } @@ -530,11 +530,11 @@ func (t *verifyPdaoProps) submitDefeat(defeat defeat) error { } // Get the gas limit - gasInfo, err := protocol.EstimateDefeatProposalGas(t.rp, propID, challengedIndex, opts) + gasLimits, err := protocol.EstimateDefeatProposalGas(t.rp, propID, challengedIndex, opts) if err != nil { return fmt.Errorf("error estimating the gas required to defeat proposal %d with index %d: %w", propID, challengedIndex, err) } - gas := big.NewInt(int64(gasInfo.SafeGasLimit)) + gas := big.NewInt(int64(gasLimits.Safe)) // Get the max fee maxFee := t.maxFee @@ -546,7 +546,7 @@ func (t *verifyPdaoProps) submitDefeat(defeat defeat) error { } // Print the gas info - if !api.PrintAndCheckGasInfo(gasInfo, true, t.gasThreshold, t.log, maxFee, t.gasLimit) { + if !gasLimits.PrintAndCheck(true, t.gasThreshold, t.log, maxFee, t.gasLimit) { return nil } @@ -561,7 +561,7 @@ func (t *verifyPdaoProps) submitDefeat(defeat defeat) error { } // Print TX info and wait for it to be included in a block - err = api.PrintAndWaitForTransaction(t.cfg, hash, t.rp.Client, t.log) + err = transactions.PrintAndWaitForTransaction(t.cfg, hash, t.rp.Client, t.log) if err != nil { return err } diff --git a/rocketpool/watchtower/challenge-exit.go b/rocketpool/watchtower/challenge-exit.go index e2fb7d3fe..b5e068b4f 100644 --- a/rocketpool/watchtower/challenge-exit.go +++ b/rocketpool/watchtower/challenge-exit.go @@ -9,6 +9,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/megapool" "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/settings/protocol" + "github.com/rocket-pool/smartnode/bindings/transactions" "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/rocketpool/watchtower/utils" @@ -16,7 +17,6 @@ import ( "github.com/rocket-pool/smartnode/shared/services/config" "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" - "github.com/rocket-pool/smartnode/shared/utils/api" "github.com/rocket-pool/smartnode/shared/utils/log" ) @@ -139,21 +139,21 @@ func (t *challengeValidatorsExiting) challengeValidatorsExiting(state *state.Net } // Challenge the validators - gasInfo, err := megapool.EstimateChallengeExitGas(t.rp, exitChallenges, opts) + gasLimits, err := megapool.EstimateChallengeExitGas(t.rp, exitChallenges, opts) if err != nil { return fmt.Errorf("error calling estimate challenge exit: %w", err) } // Print the gas info maxFee := eth.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) - if !api.PrintAndCheckGasInfo(gasInfo, false, 0, &t.log, maxFee, 0) { + if !gasLimits.PrintAndCheck(false, 0, &t.log, maxFee, 0) { return nil } // Set the gas settings opts.GasFeeCap = maxFee opts.GasTipCap = eth.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) - opts.GasLimit = gasInfo.SafeGasLimit + opts.GasLimit = gasLimits.Safe // Challenge tx, err := megapool.ChallengeExit(t.rp, exitChallenges, opts) @@ -162,7 +162,7 @@ func (t *challengeValidatorsExiting) challengeValidatorsExiting(state *state.Net } // Print TX info and wait for it to be included in a block - err = api.PrintAndWaitForTransaction(t.cfg, tx.Hash(), t.rp.Client, &t.log) + err = transactions.PrintAndWaitForTransaction(t.cfg, tx.Hash(), t.rp.Client, &t.log) if err != nil { return err } diff --git a/rocketpool/watchtower/check-solo-migrations.go b/rocketpool/watchtower/check-solo-migrations.go index ba1be21eb..303be0ad1 100644 --- a/rocketpool/watchtower/check-solo-migrations.go +++ b/rocketpool/watchtower/check-solo-migrations.go @@ -13,6 +13,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/minipool" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions" "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/rocketpool/watchtower/utils" @@ -21,7 +22,6 @@ import ( "github.com/rocket-pool/smartnode/shared/services/config" "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" - "github.com/rocket-pool/smartnode/shared/utils/api" "github.com/rocket-pool/smartnode/shared/utils/log" ) @@ -280,7 +280,7 @@ func (t *checkSoloMigrations) scrubVacantMinipool(address common.Address, reason } // Get the gas limit - gasInfo, err := mp.EstimateVoteScrubGas(opts) + gasLimits, err := mp.EstimateVoteScrubGas(opts) if err != nil { t.printMessage(fmt.Sprintf("could not estimate the gas required to scrub the minipool: %s", err.Error())) return @@ -288,14 +288,14 @@ func (t *checkSoloMigrations) scrubVacantMinipool(address common.Address, reason // Print the gas info maxFee := eth.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) - if !api.PrintAndCheckGasInfo(gasInfo, false, 0, &t.log, maxFee, 0) { + if !gasLimits.PrintAndCheck(false, 0, &t.log, maxFee, 0) { return } // Set the gas settings opts.GasFeeCap = maxFee opts.GasTipCap = eth.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) - opts.GasLimit = gasInfo.SafeGasLimit + opts.GasLimit = gasLimits.Safe // Cancel the reduction hash, err := mp.VoteScrub(opts) @@ -305,7 +305,7 @@ func (t *checkSoloMigrations) scrubVacantMinipool(address common.Address, reason } // Print TX info and wait for it to be included in a block - err = api.PrintAndWaitForTransaction(t.cfg, hash, t.rp.Client, &t.log) + err = transactions.PrintAndWaitForTransaction(t.cfg, hash, t.rp.Client, &t.log) if err != nil { t.printMessage(fmt.Sprintf("error waiting for scrub transaction: %s", err.Error())) return diff --git a/rocketpool/watchtower/dissolve-invalid-credentials.go b/rocketpool/watchtower/dissolve-invalid-credentials.go index 4023176cb..18c4ef7ab 100644 --- a/rocketpool/watchtower/dissolve-invalid-credentials.go +++ b/rocketpool/watchtower/dissolve-invalid-credentials.go @@ -7,6 +7,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/megapool" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions" "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/rocketpool/watchtower/utils" @@ -14,7 +15,6 @@ import ( "github.com/rocket-pool/smartnode/shared/services/config" "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" - "github.com/rocket-pool/smartnode/shared/utils/api" "github.com/rocket-pool/smartnode/shared/utils/log" ) @@ -168,7 +168,7 @@ func (t *dissolveInvalidCredentials) dissolveMegapoolValidator(validator megapoo } // Get the gas limit - gasInfo, err := megapool.EstimateDissolveWithProof(t.rp, validator.MegapoolAddress, validator.ValidatorId, slotTimestamp, validatorProof, slotProof, opts) + gasLimits, err := megapool.EstimateDissolveWithProof(t.rp, validator.MegapoolAddress, validator.ValidatorId, slotTimestamp, validatorProof, slotProof, opts) if err != nil { t.log.Printlnf("error estimating the gas required to dissolve the validator: %v", err) return @@ -176,14 +176,14 @@ func (t *dissolveInvalidCredentials) dissolveMegapoolValidator(validator megapoo // Print the gas info maxFee := eth.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) - if !api.PrintAndCheckGasInfo(gasInfo, false, 0, &t.log, maxFee, 0) { + if !gasLimits.PrintAndCheck(false, 0, &t.log, maxFee, 0) { return } // Set the gas settings opts.GasFeeCap = maxFee opts.GasTipCap = eth.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) - opts.GasLimit = gasInfo.SafeGasLimit + opts.GasLimit = gasLimits.Safe // Dissolve tx, err := megapool.DissolveWithProof(t.rp, validator.MegapoolAddress, validator.ValidatorId, slotTimestamp, validatorProof, slotProof, opts) @@ -193,7 +193,7 @@ func (t *dissolveInvalidCredentials) dissolveMegapoolValidator(validator megapoo } // Print TX info and wait for it to be included in a block - err = api.PrintAndWaitForTransaction(t.cfg, tx.Hash(), t.rp.Client, &t.log) + err = transactions.PrintAndWaitForTransaction(t.cfg, tx.Hash(), t.rp.Client, &t.log) if err != nil { t.log.Printlnf("error waiting for the transaction to be included in a block: %v", err) return diff --git a/rocketpool/watchtower/dissolve-timed-out-megapool-validators.go b/rocketpool/watchtower/dissolve-timed-out-megapool-validators.go index a6a36f14d..aa9b4e42e 100644 --- a/rocketpool/watchtower/dissolve-timed-out-megapool-validators.go +++ b/rocketpool/watchtower/dissolve-timed-out-megapool-validators.go @@ -9,13 +9,13 @@ import ( "github.com/rocket-pool/smartnode/bindings/megapool" "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/settings/protocol" + "github.com/rocket-pool/smartnode/bindings/transactions" "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/rocketpool/watchtower/utils" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/config" "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" - "github.com/rocket-pool/smartnode/shared/utils/api" "github.com/rocket-pool/smartnode/shared/utils/log" ) @@ -121,21 +121,21 @@ func (t *dissolveTimedOutMegapoolValidators) dissolveMegapoolValidator(validator } // Get the gas limit - gasInfo, err := mp.EstimateDissolveValidatorGas(validator.ValidatorId, opts) + gasLimits, err := mp.EstimateDissolveValidatorGas(validator.ValidatorId, opts) if err != nil { return fmt.Errorf("Could not estimate the gas required to dissolve the megapool validator: %w", err) } // Print the gas info maxFee := eth.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) - if !api.PrintAndCheckGasInfo(gasInfo, false, 0, &t.log, maxFee, 0) { + if !gasLimits.PrintAndCheck(false, 0, &t.log, maxFee, 0) { return nil } // Set the gas settings opts.GasFeeCap = maxFee opts.GasTipCap = eth.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) - opts.GasLimit = gasInfo.SafeGasLimit + opts.GasLimit = gasLimits.Safe // Dissolve hash, err := mp.DissolveValidator(validator.ValidatorId, opts) @@ -144,7 +144,7 @@ func (t *dissolveTimedOutMegapoolValidators) dissolveMegapoolValidator(validator } // Print TX info and wait for it to be included in a block - err = api.PrintAndWaitForTransaction(t.cfg, hash, t.rp.Client, &t.log) + err = transactions.PrintAndWaitForTransaction(t.cfg, hash, t.rp.Client, &t.log) if err != nil { return err } diff --git a/rocketpool/watchtower/dissolve-timed-out-minipools.go b/rocketpool/watchtower/dissolve-timed-out-minipools.go index fa7c66d9a..4992206e0 100644 --- a/rocketpool/watchtower/dissolve-timed-out-minipools.go +++ b/rocketpool/watchtower/dissolve-timed-out-minipools.go @@ -10,6 +10,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/minipool" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions" rptypes "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" @@ -18,7 +19,6 @@ import ( "github.com/rocket-pool/smartnode/shared/services/config" "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" - "github.com/rocket-pool/smartnode/shared/utils/api" "github.com/rocket-pool/smartnode/shared/utils/log" ) @@ -146,21 +146,21 @@ func (t *dissolveTimedOutMinipools) dissolveMinipool(mp minipool.Minipool) error } // Get the gas limit - gasInfo, err := mp.EstimateDissolveGas(opts) + gasLimits, err := mp.EstimateDissolveGas(opts) if err != nil { return fmt.Errorf("Could not estimate the gas required to dissolve the minipool: %w", err) } // Print the gas info maxFee := eth.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) - if !api.PrintAndCheckGasInfo(gasInfo, false, 0, &t.log, maxFee, 0) { + if !gasLimits.PrintAndCheck(false, 0, &t.log, maxFee, 0) { return nil } // Set the gas settings opts.GasFeeCap = maxFee opts.GasTipCap = eth.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) - opts.GasLimit = gasInfo.SafeGasLimit + opts.GasLimit = gasLimits.Safe // Dissolve hash, err := mp.Dissolve(opts) @@ -169,7 +169,7 @@ func (t *dissolveTimedOutMinipools) dissolveMinipool(mp minipool.Minipool) error } // Print TX info and wait for it to be included in a block - err = api.PrintAndWaitForTransaction(t.cfg, hash, t.rp.Client, &t.log) + err = transactions.PrintAndWaitForTransaction(t.cfg, hash, t.rp.Client, &t.log) if err != nil { return err } diff --git a/rocketpool/watchtower/finalize-pdao-proposals.go b/rocketpool/watchtower/finalize-pdao-proposals.go index 1ef42cf1a..ec499573e 100644 --- a/rocketpool/watchtower/finalize-pdao-proposals.go +++ b/rocketpool/watchtower/finalize-pdao-proposals.go @@ -7,6 +7,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/dao/protocol" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions" "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" @@ -15,7 +16,6 @@ import ( "github.com/rocket-pool/smartnode/shared/services/config" "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" - "github.com/rocket-pool/smartnode/shared/utils/api" "github.com/rocket-pool/smartnode/shared/utils/log" ) @@ -116,21 +116,21 @@ func (t *finalizePdaoProposals) finalizeProposal(propID uint64) error { } // Get the gas limit - gasInfo, err := protocol.EstimateFinalizeGas(t.rp, propID, opts) + gasLimits, err := protocol.EstimateFinalizeGas(t.rp, propID, opts) if err != nil { return fmt.Errorf("Could not estimate the gas required to finalize the proposal: %w", err) } // Print the gas info maxFee := eth.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) - if !api.PrintAndCheckGasInfo(gasInfo, false, 0, &t.log, maxFee, 0) { + if !gasLimits.PrintAndCheck(false, 0, &t.log, maxFee, 0) { return nil } // Set the gas settings opts.GasFeeCap = maxFee opts.GasTipCap = eth.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) - opts.GasLimit = gasInfo.SafeGasLimit + opts.GasLimit = gasLimits.Safe // Dissolve hash, err := protocol.Finalize(t.rp, propID, opts) @@ -139,7 +139,7 @@ func (t *finalizePdaoProposals) finalizeProposal(propID uint64) error { } // Print TX info and wait for it to be included in a block - err = api.PrintAndWaitForTransaction(t.cfg, hash, t.rp.Client, &t.log) + err = transactions.PrintAndWaitForTransaction(t.cfg, hash, t.rp.Client, &t.log) if err != nil { return err } diff --git a/rocketpool/watchtower/respond-challenges.go b/rocketpool/watchtower/respond-challenges.go index 2a1173243..9ae37d609 100644 --- a/rocketpool/watchtower/respond-challenges.go +++ b/rocketpool/watchtower/respond-challenges.go @@ -7,6 +7,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/dao/trustednode" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions" "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/rocketpool/watchtower/utils" @@ -14,7 +15,6 @@ import ( "github.com/rocket-pool/smartnode/shared/services/config" "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" - "github.com/rocket-pool/smartnode/shared/utils/api" "github.com/rocket-pool/smartnode/shared/utils/log" ) @@ -93,21 +93,21 @@ func (t *respondChallenges) run() error { } // Get the gas limit - gasInfo, err := trustednode.EstimateDecideChallengeGas(t.rp, nodeAccount.Address, opts) + gasLimits, err := trustednode.EstimateDecideChallengeGas(t.rp, nodeAccount.Address, opts) if err != nil { return fmt.Errorf("Could not estimate the gas required to respond to the challenge: %w", err) } // Print the gas info maxFee := eth.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) - if !api.PrintAndCheckGasInfo(gasInfo, false, 0, &t.log, maxFee, 0) { + if !gasLimits.PrintAndCheck(false, 0, &t.log, maxFee, 0) { return nil } // Set the gas settings opts.GasFeeCap = maxFee opts.GasTipCap = eth.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) - opts.GasLimit = gasInfo.SafeGasLimit + opts.GasLimit = gasLimits.Safe // Respond to challenge hash, err := trustednode.DecideChallenge(t.rp, nodeAccount.Address, opts) @@ -116,7 +116,7 @@ func (t *respondChallenges) run() error { } // Print TX info and wait for it to be included in a block - err = api.PrintAndWaitForTransaction(t.cfg, hash, t.rp.Client, &t.log) + err = transactions.PrintAndWaitForTransaction(t.cfg, hash, t.rp.Client, &t.log) if err != nil { return err } diff --git a/rocketpool/watchtower/submit-network-balances.go b/rocketpool/watchtower/submit-network-balances.go index d8869cc4c..65225cad4 100644 --- a/rocketpool/watchtower/submit-network-balances.go +++ b/rocketpool/watchtower/submit-network-balances.go @@ -18,6 +18,8 @@ import ( "github.com/rocket-pool/smartnode/bindings/megapool" "github.com/rocket-pool/smartnode/bindings/network" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" rptypes "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" rpstate "github.com/rocket-pool/smartnode/bindings/utils/state" @@ -30,7 +32,6 @@ import ( rprewards "github.com/rocket-pool/smartnode/shared/services/rewards" "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" - "github.com/rocket-pool/smartnode/shared/utils/api" "github.com/rocket-pool/smartnode/shared/utils/eth1" "github.com/rocket-pool/smartnode/shared/utils/log" ) @@ -762,15 +763,14 @@ func (t *submitNetworkBalances) submitBalances(balances networkBalances) error { } // Get the gas limit - var gasInfo rocketpool.GasInfo - gasInfo, err = network.EstimateSubmitBalancesGas(t.rp, balances.Block, balances.SlotTimestamp, balances.ClampedTotalBalanceWei, balances.TotalStaking, balances.RETHSupply, opts) + gasLimits, err := network.EstimateSubmitBalancesGas(t.rp, balances.Block, balances.SlotTimestamp, balances.ClampedTotalBalanceWei, balances.TotalStaking, balances.RETHSupply, opts) if err != nil { if enableSubmissionAfterConsensus_Balances && strings.Contains(err.Error(), "Network balances for an equal or higher block are set") { // Override the gas info to force a submission - gasInfo = rocketpool.GasInfo{ - EstGasLimit: utils.BalanceSubmissionForcedGas, - SafeGasLimit: utils.BalanceSubmissionForcedGas, + gasLimits = gaslimit.Limits{ + Estimated: utils.BalanceSubmissionForcedGas, + Safe: utils.BalanceSubmissionForcedGas, } t.log.Println("Network balance consensus has already been reached but submitting anyway for the health check.") } else { @@ -780,14 +780,14 @@ func (t *submitNetworkBalances) submitBalances(balances networkBalances) error { // Print the gas info maxFee := eth.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) - if !api.PrintAndCheckGasInfo(gasInfo, false, 0, t.log, maxFee, 0) { + if !gasLimits.PrintAndCheck(false, 0, t.log, maxFee, 0) { return nil } // Set the gas settings opts.GasFeeCap = maxFee opts.GasTipCap = eth.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) - opts.GasLimit = gasInfo.SafeGasLimit + opts.GasLimit = gasLimits.Safe var hash common.Hash // Submit balances hash, err = network.SubmitBalances(t.rp, balances.Block, balances.SlotTimestamp, balances.ClampedTotalBalanceWei, balances.TotalStaking, balances.RETHSupply, opts) @@ -796,7 +796,7 @@ func (t *submitNetworkBalances) submitBalances(balances networkBalances) error { } // Print TX info and wait for it to be included in a block - err = api.PrintAndWaitForTransaction(t.cfg, hash, t.rp.Client, t.log) + err = transactions.PrintAndWaitForTransaction(t.cfg, hash, t.rp.Client, t.log) if err != nil { return fmt.Errorf("error waiting for transaction: %w", err) } diff --git a/rocketpool/watchtower/submit-rewards-tree-stateless.go b/rocketpool/watchtower/submit-rewards-tree-stateless.go index 0b182d5c9..ad1c9c4f5 100644 --- a/rocketpool/watchtower/submit-rewards-tree-stateless.go +++ b/rocketpool/watchtower/submit-rewards-tree-stateless.go @@ -20,6 +20,8 @@ import ( "github.com/rocket-pool/smartnode/bindings/rewards" "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/tokens" + "github.com/rocket-pool/smartnode/bindings/transactions" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/rocketpool/watchtower/utils" "github.com/rocket-pool/smartnode/shared/services" @@ -29,7 +31,6 @@ import ( "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" cfgtypes "github.com/rocket-pool/smartnode/shared/types/config" - "github.com/rocket-pool/smartnode/shared/utils/api" "github.com/rocket-pool/smartnode/shared/utils/eth1" hexutil "github.com/rocket-pool/smartnode/shared/utils/hex" "github.com/rocket-pool/smartnode/shared/utils/log" @@ -394,7 +395,7 @@ func (t *submitRewardsTree_Stateless) submitRewardsSnapshot(index *big.Int, cons return false, err } - var gasInfo rocketpool.GasInfo + var gasLimits gaslimit.Limits submission := rewards.RewardSubmission{ RewardIndex: index, @@ -422,20 +423,20 @@ func (t *submitRewardsTree_Stateless) submitRewardsSnapshot(index *big.Int, cons } // Get the gas limit - gasInfo, err = rewards.EstimateSubmitRewardSnapshotGas(t.rp, submission, opts) + gasLimits, err = rewards.EstimateSubmitRewardSnapshotGas(t.rp, submission, opts) if err != nil { return false, fmt.Errorf("Could not estimate the gas required to submit the rewards tree: %w", err) } // Print the gas info maxFee := eth.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) - if !api.PrintAndCheckGasInfo(gasInfo, false, 0, t.log, maxFee, 0) { + if !gasLimits.PrintAndCheck(false, 0, t.log, maxFee, 0) { return false, nil } opts.GasFeeCap = maxFee opts.GasTipCap = eth.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) - opts.GasLimit = gasInfo.SafeGasLimit + opts.GasLimit = gasLimits.Safe var hash common.Hash // Submit rewards snapshot @@ -445,7 +446,7 @@ func (t *submitRewardsTree_Stateless) submitRewardsSnapshot(index *big.Int, cons } // Print TX info and wait for it to be included in a block - err = api.PrintAndWaitForTransaction(t.cfg, hash, t.rp.Client, t.log) + err = transactions.PrintAndWaitForTransaction(t.cfg, hash, t.rp.Client, t.log) if err != nil { return false, err } diff --git a/rocketpool/watchtower/submit-rpl-price.go b/rocketpool/watchtower/submit-rpl-price.go index f6fd1842b..4b1ab3b72 100644 --- a/rocketpool/watchtower/submit-rpl-price.go +++ b/rocketpool/watchtower/submit-rpl-price.go @@ -22,6 +22,8 @@ import ( "github.com/rocket-pool/smartnode/bindings/dao/trustednode" "github.com/rocket-pool/smartnode/bindings/network" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/rocketpool/watchtower/utils" @@ -31,7 +33,6 @@ import ( rpgas "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" - "github.com/rocket-pool/smartnode/shared/utils/api" "github.com/rocket-pool/smartnode/shared/utils/eth1" "github.com/rocket-pool/smartnode/shared/utils/log" mathutils "github.com/rocket-pool/smartnode/shared/utils/math" @@ -668,24 +669,22 @@ func (t *submitRplPrice) submitRplPrice(blockNumber uint64, slotTimestamp uint64 return err } - var gasInfo rocketpool.GasInfo - // Get the gas limit - gasInfo, err = network.EstimateSubmitPricesGas(t.rp, blockNumber, slotTimestamp, rplPrice, opts) + gasLimits, err := network.EstimateSubmitPricesGas(t.rp, blockNumber, slotTimestamp, rplPrice, opts) if err != nil { return fmt.Errorf("Could not estimate the gas required to submit RPL price: %w", err) } // Print the gas info maxFee := eth.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) - if !api.PrintAndCheckGasInfo(gasInfo, false, 0, t.log, maxFee, 0) { + if !gasLimits.PrintAndCheck(false, 0, t.log, maxFee, 0) { return nil } // Set the gas settings opts.GasFeeCap = maxFee opts.GasTipCap = eth.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) - opts.GasLimit = gasInfo.SafeGasLimit + opts.GasLimit = gasLimits.Safe var hash common.Hash // Submit RPL price @@ -695,7 +694,7 @@ func (t *submitRplPrice) submitRplPrice(blockNumber uint64, slotTimestamp uint64 } // Print TX info and wait for it to be included in a block - err = api.PrintAndWaitForTransaction(t.cfg, hash, t.rp.Client, t.log) + err = transactions.PrintAndWaitForTransaction(t.cfg, hash, t.rp.Client, t.log) if err != nil { return err } @@ -791,21 +790,21 @@ func (t *submitRplPrice) submitOptimismPrice() error { } // Estimate gas limit - gasInfo, err := t.estimateGasLimit(opts, priceMessenger.Address, input) + gasLimits, err := t.estimateGasLimit(opts, priceMessenger.Address, input) if err != nil { return fmt.Errorf("Error estimating gas limit of submitOptimismPrice: %w", err) } // Print the gas info maxFee := eth.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) - if !api.PrintAndCheckGasInfo(gasInfo, false, 0, t.log, maxFee, 0) { + if !gasLimits.PrintAndCheck(false, 0, t.log, maxFee, 0) { return nil } // Set the gas settings opts.GasFeeCap = maxFee opts.GasTipCap = eth.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) - opts.GasLimit = gasInfo.SafeGasLimit + opts.GasLimit = gasLimits.Safe t.log.Println("Submitting rate to Optimism...") @@ -816,7 +815,7 @@ func (t *submitRplPrice) submitOptimismPrice() error { } // Print TX info and wait for it to be included in a block - err = api.PrintAndWaitForTransaction(t.cfg, tx.Hash(), t.rp.Client, t.log) + err = transactions.PrintAndWaitForTransaction(t.cfg, tx.Hash(), t.rp.Client, t.log) if err != nil { return err } @@ -912,21 +911,21 @@ func (t *submitRplPrice) submitPolygonPrice() error { } // Estimate gas limit - gasInfo, err := t.estimateGasLimit(opts, priceMessenger.Address, input) + gasLimits, err := t.estimateGasLimit(opts, priceMessenger.Address, input) if err != nil { return fmt.Errorf("Error estimating gas limit of submitPolygonPrice: %w", err) } // Print the gas info maxFee := eth.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) - if !api.PrintAndCheckGasInfo(gasInfo, false, 0, t.log, maxFee, 0) { + if !gasLimits.PrintAndCheck(false, 0, t.log, maxFee, 0) { return nil } // Set the gas settings opts.GasFeeCap = maxFee opts.GasTipCap = eth.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) - opts.GasLimit = gasInfo.SafeGasLimit + opts.GasLimit = gasLimits.Safe t.log.Println("Submitting rate to Polygon...") @@ -937,7 +936,7 @@ func (t *submitRplPrice) submitPolygonPrice() error { } // Print TX info and wait for it to be included in a block - err = api.PrintAndWaitForTransaction(t.cfg, tx.Hash(), t.rp.Client, t.log) + err = transactions.PrintAndWaitForTransaction(t.cfg, tx.Hash(), t.rp.Client, t.log) if err != nil { return err } @@ -1056,21 +1055,21 @@ func (t *submitRplPrice) submitArbitrumPrice(priceMessengerAddress string) error } // Estimate gas limit - gasInfo, err := t.estimateGasLimit(opts, priceMessenger.Address, input) + gasLimits, err := t.estimateGasLimit(opts, priceMessenger.Address, input) if err != nil { return fmt.Errorf("Error estimating gas limit of submitArbitrumPrice: %w", err) } // Print the gas info maxFee := eth.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) - if !api.PrintAndCheckGasInfo(gasInfo, false, 0, t.log, maxFee, 0) { + if !gasLimits.PrintAndCheck(false, 0, t.log, maxFee, 0) { return nil } // Set the gas settings opts.GasFeeCap = maxFee opts.GasTipCap = eth.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) - opts.GasLimit = gasInfo.SafeGasLimit + opts.GasLimit = gasLimits.Safe t.log.Println("Submitting rate to Arbitrum %s...", priceMessengerAddress) @@ -1081,7 +1080,7 @@ func (t *submitRplPrice) submitArbitrumPrice(priceMessengerAddress string) error } // Print TX info and wait for it to be included in a block - err = api.PrintAndWaitForTransaction(t.cfg, tx.Hash(), t.rp.Client, t.log) + err = transactions.PrintAndWaitForTransaction(t.cfg, tx.Hash(), t.rp.Client, t.log) if err != nil { return err } @@ -1196,20 +1195,20 @@ func (t *submitRplPrice) submitZkSyncEraPrice() error { } // Estimate gas limit - gasInfo, err := t.estimateGasLimit(opts, priceMessenger.Address, input) + gasLimits, err := t.estimateGasLimit(opts, priceMessenger.Address, input) if err != nil { return fmt.Errorf("Error estimating gas limit of submitZkSyncEraPrice: %w", err) } // Print the gas info - if !api.PrintAndCheckGasInfo(gasInfo, false, 0, t.log, maxFee, 0) { + if !gasLimits.PrintAndCheck(false, 0, t.log, maxFee, 0) { return nil } // Set the gas settings opts.GasFeeCap = maxFee opts.GasTipCap = eth.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) - opts.GasLimit = gasInfo.SafeGasLimit + opts.GasLimit = gasLimits.Safe t.log.Println("Submitting rate to zkSync Era...") @@ -1220,7 +1219,7 @@ func (t *submitRplPrice) submitZkSyncEraPrice() error { } // Print TX info and wait for it to be included in a block - err = api.PrintAndWaitForTransaction(t.cfg, tx.Hash(), t.rp.Client, t.log) + err = transactions.PrintAndWaitForTransaction(t.cfg, tx.Hash(), t.rp.Client, t.log) if err != nil { return err } @@ -1316,21 +1315,21 @@ func (t *submitRplPrice) submitBasePrice() error { } // Estimate gas limit - gasInfo, err := t.estimateGasLimit(opts, priceMessenger.Address, input) + gasLimits, err := t.estimateGasLimit(opts, priceMessenger.Address, input) if err != nil { return fmt.Errorf("Error estimating gas limit of submitBasePrice: %w", err) } // Print the gas info maxFee := eth.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) - if !api.PrintAndCheckGasInfo(gasInfo, false, 0, t.log, maxFee, 0) { + if !gasLimits.PrintAndCheck(false, 0, t.log, maxFee, 0) { return nil } // Set the gas settings opts.GasFeeCap = maxFee opts.GasTipCap = eth.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) - opts.GasLimit = gasInfo.SafeGasLimit + opts.GasLimit = gasLimits.Safe t.log.Println("Submitting rate to Base...") @@ -1341,7 +1340,7 @@ func (t *submitRplPrice) submitBasePrice() error { } // Print TX info and wait for it to be included in a block - err = api.PrintAndWaitForTransaction(t.cfg, tx.Hash(), t.rp.Client, t.log) + err = transactions.PrintAndWaitForTransaction(t.cfg, tx.Hash(), t.rp.Client, t.log) if err != nil { return err } @@ -1462,21 +1461,21 @@ func (t *submitRplPrice) submitScrollPrice() error { opts.Value = messageFee // Estimate gas limit - gasInfo, err := t.estimateGasLimit(opts, priceMessenger.Address, input) + gasLimits, err := t.estimateGasLimit(opts, priceMessenger.Address, input) if err != nil { return fmt.Errorf("Error estimating gas limit of submitScrollPrice: %w", err) } // Print the gas info maxFee := eth.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) - if !api.PrintAndCheckGasInfo(gasInfo, false, 0, t.log, maxFee, 0) { + if !gasLimits.PrintAndCheck(false, 0, t.log, maxFee, 0) { return nil } // Set the gas settings opts.GasFeeCap = maxFee opts.GasTipCap = eth.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) - opts.GasLimit = gasInfo.SafeGasLimit + opts.GasLimit = gasLimits.Safe t.log.Println("Submitting rate to Scroll...") @@ -1487,7 +1486,7 @@ func (t *submitRplPrice) submitScrollPrice() error { } // Print TX info and wait for it to be included in a block - err = api.PrintAndWaitForTransaction(t.cfg, tx.Hash(), t.rp.Client, t.log) + err = transactions.PrintAndWaitForTransaction(t.cfg, tx.Hash(), t.rp.Client, t.log) if err != nil { return err } @@ -1501,7 +1500,7 @@ func (t *submitRplPrice) submitScrollPrice() error { } // estimateGasLimit estimates gas limit for a transaction -func (t *submitRplPrice) estimateGasLimit(opts *bind.TransactOpts, contractAddress *common.Address, input []byte) (rocketpool.GasInfo, error) { +func (t *submitRplPrice) estimateGasLimit(opts *bind.TransactOpts, contractAddress *common.Address, input []byte) (gaslimit.Limits, error) { // Estimate gas limit gasLimit, err := t.rp.Client.EstimateGas(context.Background(), ethereum.CallMsg{ From: opts.From, @@ -1511,7 +1510,7 @@ func (t *submitRplPrice) estimateGasLimit(opts *bind.TransactOpts, contractAddre Data: input, }) if err != nil { - return rocketpool.GasInfo{}, err + return gaslimit.Limits{}, err } // Get the safe gas limit @@ -1519,8 +1518,8 @@ func (t *submitRplPrice) estimateGasLimit(opts *bind.TransactOpts, contractAddre gasLimit = min(gasLimit, rocketpool.MaxGasLimit) safeGasLimit = min(safeGasLimit, rocketpool.MaxGasLimit) - return rocketpool.GasInfo{ - EstGasLimit: gasLimit, - SafeGasLimit: safeGasLimit, + return gaslimit.Limits{ + Estimated: gasLimit, + Safe: safeGasLimit, }, nil } diff --git a/rocketpool/watchtower/submit-scrub-minipools.go b/rocketpool/watchtower/submit-scrub-minipools.go index 36a138c25..2ebf74a2d 100644 --- a/rocketpool/watchtower/submit-scrub-minipools.go +++ b/rocketpool/watchtower/submit-scrub-minipools.go @@ -15,6 +15,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/minipool" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions" "github.com/rocket-pool/smartnode/bindings/types" rputils "github.com/rocket-pool/smartnode/bindings/utils" "github.com/rocket-pool/smartnode/bindings/utils/eth" @@ -30,7 +31,6 @@ import ( "github.com/rocket-pool/smartnode/shared/services/config" "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" - "github.com/rocket-pool/smartnode/shared/utils/api" "github.com/rocket-pool/smartnode/shared/utils/log" ) @@ -572,21 +572,21 @@ func (t *submitScrubMinipools) submitVoteScrubMinipool(mp minipool.Minipool) err } // Get the gas limit - gasInfo, err := mp.EstimateVoteScrubGas(opts) + gasLimits, err := mp.EstimateVoteScrubGas(opts) if err != nil { return fmt.Errorf("Could not estimate the gas required to voteScrub the minipool: %w", err) } // Print the gas info maxFee := eth.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) - if !api.PrintAndCheckGasInfo(gasInfo, false, 0, &t.log, maxFee, 0) { + if !gasLimits.PrintAndCheck(false, 0, &t.log, maxFee, 0) { return nil } // Set the gas settings opts.GasFeeCap = maxFee opts.GasTipCap = eth.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) - opts.GasLimit = gasInfo.SafeGasLimit + opts.GasLimit = gasLimits.Safe // Dissolve hash, err := mp.VoteScrub(opts) @@ -595,7 +595,7 @@ func (t *submitScrubMinipools) submitVoteScrubMinipool(mp minipool.Minipool) err } // Print TX info and wait for it to be included in a block - err = api.PrintAndWaitForTransaction(t.cfg, hash, t.rp.Client, &t.log) + err = transactions.PrintAndWaitForTransaction(t.cfg, hash, t.rp.Client, &t.log) if err != nil { return err } diff --git a/shared/services/gas/gas.go b/shared/services/gas/gas.go index d0477e33a..f8b3ed694 100644 --- a/shared/services/gas/gas.go +++ b/shared/services/gas/gas.go @@ -7,6 +7,7 @@ import ( "strconv" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/shared/services/config" "github.com/rocket-pool/smartnode/shared/services/gas/etherscan" @@ -24,8 +25,8 @@ type Gas struct { gasLimit uint64 } -func AssignMaxFeeAndLimit(gasInfo rocketpool.GasInfo, rp *rpsvc.Client, headless bool) error { - g, err := GetMaxFeeAndLimit(gasInfo, rp, headless) +func AssignMaxFeeAndLimit(gasLimits gaslimit.Limits, rp *rpsvc.Client, headless bool) error { + g, err := GetMaxFeeAndLimit(gasLimits, rp, headless) if err != nil { return err } @@ -38,15 +39,15 @@ func (g *Gas) Assign(rp *rpsvc.Client) { } // GetMaxGasCostEth returns the maximum possible gas cost in ETH for the given gas info, -func (g *Gas) GetMaxGasCostEth(gasInfo rocketpool.GasInfo) float64 { - limit := uint64(float64(gasInfo.EstGasLimit) * 1.1) +func (g *Gas) GetMaxGasCostEth(gasLimits gaslimit.Limits) float64 { + limit := uint64(float64(gasLimits.Estimated) * 1.1) if g.gasLimit != 0 { limit = g.gasLimit } return g.maxFeeGwei / eth.WeiPerGwei * float64(limit) } -func GetMaxFeeAndLimit(gasInfo rocketpool.GasInfo, rp *rpsvc.Client, headless bool) (Gas, error) { +func GetMaxFeeAndLimit(gasLimits gaslimit.Limits, rp *rpsvc.Client, headless bool) (Gas, error) { cfg, isNew, err := rp.LoadConfig() if err != nil { @@ -85,8 +86,8 @@ func GetMaxFeeAndLimit(gasInfo rocketpool.GasInfo, rp *rpsvc.Client, headless bo var lowLimit float64 var highLimit float64 if gasLimit == 0 { - lowLimit = maxFeeGwei / eth.WeiPerGwei * float64(gasInfo.EstGasLimit) - highLimit = maxFeeGwei / eth.WeiPerGwei * float64(gasInfo.SafeGasLimit) + lowLimit = maxFeeGwei / eth.WeiPerGwei * float64(gasLimits.Estimated) + highLimit = maxFeeGwei / eth.WeiPerGwei * float64(gasLimits.Safe) } else { lowLimit = maxFeeGwei / eth.WeiPerGwei * float64(gasLimit) highLimit = lowLimit @@ -116,7 +117,7 @@ func GetMaxFeeAndLimit(gasInfo rocketpool.GasInfo, rp *rpsvc.Client, headless bo } // Print the gas data and ask for an amount - maxFeeGwei = handleEtherscanGasPrices(gasData, gasInfo, maxPriorityFeeGwei, gasLimit) + maxFeeGwei = handleEtherscanGasPrices(gasData, gasLimits, maxPriorityFeeGwei, gasLimit) } color.LightBluePrintf("Using a max fee of %.3f gwei and a priority fee of %.3f gwei.\n", maxFeeGwei, maxPriorityFeeGwei) } @@ -136,7 +137,7 @@ func GetMaxFeeAndLimit(gasInfo rocketpool.GasInfo, rp *rpsvc.Client, headless bo if gasLimit != 0 { ethRequired.Mul(maxFee, big.NewInt(int64(gasLimit))) } else { - ethRequired.Mul(maxFee, big.NewInt(int64(gasInfo.SafeGasLimit))) + ethRequired.Mul(maxFee, big.NewInt(int64(gasLimits.Safe))) } response, err := rp.GetEthBalance() if err != nil { @@ -176,7 +177,7 @@ func GetHeadlessMaxFeeWeiWithLatestBlock(cfg *config.RocketPoolConfig, rp *rocke return nil, fmt.Errorf("error getting gas estimates. You can try again later or specify fees manually using --maxFee and --maxPrioFee.") } -func handleEtherscanGasPrices(gasSuggestion etherscan.GasFeeSuggestion, gasInfo rocketpool.GasInfo, priorityFee float64, gasLimit uint64) float64 { +func handleEtherscanGasPrices(gasSuggestion etherscan.GasFeeSuggestion, gasLimits gaslimit.Limits, priorityFee float64, gasLimit uint64) float64 { fastGwei := gasSuggestion.FastGwei + priorityFee fastEth := fastGwei / eth.WeiPerGwei @@ -184,8 +185,8 @@ func handleEtherscanGasPrices(gasSuggestion etherscan.GasFeeSuggestion, gasInfo var fastLowLimit float64 var fastHighLimit float64 if gasLimit == 0 { - fastLowLimit = fastEth * float64(gasInfo.EstGasLimit) - fastHighLimit = fastEth * float64(gasInfo.SafeGasLimit) + fastLowLimit = fastEth * float64(gasLimits.Estimated) + fastHighLimit = fastEth * float64(gasLimits.Safe) } else { fastLowLimit = fastEth * float64(gasLimit) fastHighLimit = fastLowLimit @@ -197,8 +198,8 @@ func handleEtherscanGasPrices(gasSuggestion etherscan.GasFeeSuggestion, gasInfo var standardLowLimit float64 var standardHighLimit float64 if gasLimit == 0 { - standardLowLimit = standardEth * float64(gasInfo.EstGasLimit) - standardHighLimit = standardEth * float64(gasInfo.SafeGasLimit) + standardLowLimit = standardEth * float64(gasLimits.Estimated) + standardHighLimit = standardEth * float64(gasLimits.Safe) } else { standardLowLimit = standardEth * float64(gasLimit) standardHighLimit = standardLowLimit @@ -210,8 +211,8 @@ func handleEtherscanGasPrices(gasSuggestion etherscan.GasFeeSuggestion, gasInfo var slowLowLimit float64 var slowHighLimit float64 if gasLimit == 0 { - slowLowLimit = slowEth * float64(gasInfo.EstGasLimit) - slowHighLimit = slowEth * float64(gasInfo.SafeGasLimit) + slowLowLimit = slowEth * float64(gasLimits.Estimated) + slowHighLimit = slowEth * float64(gasLimits.Safe) } else { slowLowLimit = slowEth * float64(gasLimit) slowHighLimit = slowLowLimit diff --git a/shared/services/rocketpool/node.go b/shared/services/rocketpool/node.go index f54aab1e2..ec699e5ff 100644 --- a/shared/services/rocketpool/node.go +++ b/shared/services/rocketpool/node.go @@ -14,9 +14,14 @@ import ( "github.com/goccy/go-json" "github.com/rocket-pool/smartnode/shared/types/api" - utils "github.com/rocket-pool/smartnode/shared/utils/api" ) +func zeroIfNil(in **big.Int) { + if *in == nil { + *in = big.NewInt(0) + } +} + // Get node status func (c *Client) NodeStatus() (api.NodeStatusResponse, error) { responseBytes, err := c.callHTTPAPI("GET", "/api/node/status", nil) @@ -30,30 +35,30 @@ func (c *Client) NodeStatus() (api.NodeStatusResponse, error) { if response.Error != "" { return api.NodeStatusResponse{}, fmt.Errorf("Could not get node status: %s", response.Error) } - utils.ZeroIfNil(&response.TotalRplStake) - utils.ZeroIfNil(&response.RplStakeMegapool) - utils.ZeroIfNil(&response.RplStakeLegacy) - utils.ZeroIfNil(&response.RplStakeThreshold) - utils.ZeroIfNil(&response.AccountBalances.ETH) - utils.ZeroIfNil(&response.AccountBalances.RPL) - utils.ZeroIfNil(&response.AccountBalances.RETH) - utils.ZeroIfNil(&response.AccountBalances.FixedSupplyRPL) - utils.ZeroIfNil(&response.PrimaryWithdrawalBalances.ETH) - utils.ZeroIfNil(&response.PrimaryWithdrawalBalances.RPL) - utils.ZeroIfNil(&response.PrimaryWithdrawalBalances.RETH) - utils.ZeroIfNil(&response.PrimaryWithdrawalBalances.FixedSupplyRPL) - utils.ZeroIfNil(&response.NodeRPLLocked) - utils.ZeroIfNil(&response.RPLWithdrawalBalances.ETH) - utils.ZeroIfNil(&response.RPLWithdrawalBalances.RPL) - utils.ZeroIfNil(&response.RPLWithdrawalBalances.RETH) - utils.ZeroIfNil(&response.RPLWithdrawalBalances.FixedSupplyRPL) - utils.ZeroIfNil(&response.PendingMinimumRplStake) - utils.ZeroIfNil(&response.PendingMaximumRplStake) - utils.ZeroIfNil(&response.EthBorrowed) - utils.ZeroIfNil(&response.EthBorrowedLimit) - utils.ZeroIfNil(&response.PendingBorrowAmount) - utils.ZeroIfNil(&response.CreditBalance) - utils.ZeroIfNil(&response.FeeDistributorBalance) + zeroIfNil(&response.TotalRplStake) + zeroIfNil(&response.RplStakeMegapool) + zeroIfNil(&response.RplStakeLegacy) + zeroIfNil(&response.RplStakeThreshold) + zeroIfNil(&response.AccountBalances.ETH) + zeroIfNil(&response.AccountBalances.RPL) + zeroIfNil(&response.AccountBalances.RETH) + zeroIfNil(&response.AccountBalances.FixedSupplyRPL) + zeroIfNil(&response.PrimaryWithdrawalBalances.ETH) + zeroIfNil(&response.PrimaryWithdrawalBalances.RPL) + zeroIfNil(&response.PrimaryWithdrawalBalances.RETH) + zeroIfNil(&response.PrimaryWithdrawalBalances.FixedSupplyRPL) + zeroIfNil(&response.NodeRPLLocked) + zeroIfNil(&response.RPLWithdrawalBalances.ETH) + zeroIfNil(&response.RPLWithdrawalBalances.RPL) + zeroIfNil(&response.RPLWithdrawalBalances.RETH) + zeroIfNil(&response.RPLWithdrawalBalances.FixedSupplyRPL) + zeroIfNil(&response.PendingMinimumRplStake) + zeroIfNil(&response.PendingMaximumRplStake) + zeroIfNil(&response.EthBorrowed) + zeroIfNil(&response.EthBorrowedLimit) + zeroIfNil(&response.PendingBorrowAmount) + zeroIfNil(&response.CreditBalance) + zeroIfNil(&response.FeeDistributorBalance) return response, nil } diff --git a/shared/types/api/auction.go b/shared/types/api/auction.go index 8e88e7a04..4bdb61790 100644 --- a/shared/types/api/auction.go +++ b/shared/types/api/auction.go @@ -6,7 +6,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/rocket-pool/smartnode/bindings/auction" - "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" ) type AuctionStatusResponse struct { @@ -36,12 +36,12 @@ type LotDetails struct { } type CanCreateLotResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanCreate bool `json:"canCreate"` - InsufficientBalance bool `json:"insufficientBalance"` - CreateLotDisabled bool `json:"createLotDisabled"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanCreate bool `json:"canCreate"` + InsufficientBalance bool `json:"insufficientBalance"` + CreateLotDisabled bool `json:"createLotDisabled"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type CreateLotResponse struct { Status string `json:"status"` @@ -51,14 +51,14 @@ type CreateLotResponse struct { } type CanBidOnLotResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanBid bool `json:"canBid"` - DoesNotExist bool `json:"doesNotExist"` - BiddingEnded bool `json:"biddingEnded"` - RPLExhausted bool `json:"rplExhausted"` - BidOnLotDisabled bool `json:"bidOnLotDisabled"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanBid bool `json:"canBid"` + DoesNotExist bool `json:"doesNotExist"` + BiddingEnded bool `json:"biddingEnded"` + RPLExhausted bool `json:"rplExhausted"` + BidOnLotDisabled bool `json:"bidOnLotDisabled"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type BidOnLotResponse struct { Status string `json:"status"` @@ -67,13 +67,13 @@ type BidOnLotResponse struct { } type CanClaimFromLotResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanClaim bool `json:"canClaim"` - DoesNotExist bool `json:"doesNotExist"` - NoBidFromAddress bool `json:"noBidFromAddress"` - NotCleared bool `json:"notCleared"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanClaim bool `json:"canClaim"` + DoesNotExist bool `json:"doesNotExist"` + NoBidFromAddress bool `json:"noBidFromAddress"` + NotCleared bool `json:"notCleared"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type ClaimFromLotResponse struct { Status string `json:"status"` @@ -82,14 +82,14 @@ type ClaimFromLotResponse struct { } type CanRecoverRPLFromLotResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanRecover bool `json:"canRecover"` - DoesNotExist bool `json:"doesNotExist"` - BiddingNotEnded bool `json:"biddingNotEnded"` - NoUnclaimedRPL bool `json:"noUnclaimedRpl"` - RPLAlreadyRecovered bool `json:"rplAlreadyRecovered"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanRecover bool `json:"canRecover"` + DoesNotExist bool `json:"doesNotExist"` + BiddingNotEnded bool `json:"biddingNotEnded"` + NoUnclaimedRPL bool `json:"noUnclaimedRpl"` + RPLAlreadyRecovered bool `json:"rplAlreadyRecovered"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type RecoverRPLFromLotResponse struct { Status string `json:"status"` diff --git a/shared/types/api/megapool.go b/shared/types/api/megapool.go index ed0e4906b..ad936c60f 100644 --- a/shared/types/api/megapool.go +++ b/shared/types/api/megapool.go @@ -8,8 +8,8 @@ import ( "github.com/rocket-pool/smartnode/bindings/megapool" "github.com/rocket-pool/smartnode/bindings/network" - "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/tokens" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/shared/services/beacon" ) @@ -101,9 +101,9 @@ type QueueDetails struct { } type MegapoolCanDelegateUpgradeResponse struct { - Status string `json:"status"` - Error string `json:"error"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type MegapoolDelegateUpgradeResponse struct { Status string `json:"status"` @@ -118,10 +118,10 @@ type MegapoolGetDelegateResponse struct { } type MegapoolCanSetUseLatestDelegateResponse struct { - Status string `json:"status"` - Error string `json:"error"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` - MatchesCurrentSetting bool `json:"matchesCurrentSetting"` + Status string `json:"status"` + Error string `json:"error"` + GasLimits gaslimit.Limits `json:"gasLimits"` + MatchesCurrentSetting bool `json:"matchesCurrentSetting"` } type MegapoolSetUseLatestDelegateResponse struct { Status string `json:"status"` @@ -142,16 +142,16 @@ type MegapoolGetEffectiveDelegateResponse struct { } type CanDistributeMegapoolResponse struct { - Status string `json:"status"` - Error string `json:"error"` - MegapoolAddress common.Address `json:"megapoolAddress"` - MegapoolNotDeployed bool `json:"megapoolNotDeployed"` - LastDistributionTime uint64 `json:"lastDistributionTime"` - LockedValidatorCount uint32 `json:"lockedValidatorCount"` - ExitingValidatorCount uint32 `json:"exitingValidatorCount"` - CanDistribute bool `json:"canDistribute"` - Details MegapoolDetails `json:"details"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + MegapoolAddress common.Address `json:"megapoolAddress"` + MegapoolNotDeployed bool `json:"megapoolNotDeployed"` + LastDistributionTime uint64 `json:"lastDistributionTime"` + LockedValidatorCount uint32 `json:"lockedValidatorCount"` + ExitingValidatorCount uint32 `json:"exitingValidatorCount"` + CanDistribute bool `json:"canDistribute"` + Details MegapoolDetails `json:"details"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type DistributeMegapoolResponse struct { diff --git a/shared/types/api/minipool.go b/shared/types/api/minipool.go index fe4d0a5ff..0fbf96859 100644 --- a/shared/types/api/minipool.go +++ b/shared/types/api/minipool.go @@ -7,8 +7,8 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/rocket-pool/smartnode/bindings/minipool" - "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/tokens" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/shared/services/beacon" ) @@ -60,15 +60,15 @@ type MinipoolBalanceDistributionDetails struct { Status types.MinipoolStatus `json:"status"` IsFinalized bool `json:"isFinalized"` CanDistribute bool `json:"canDistribute"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type CanRefundMinipoolResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanRefund bool `json:"canRefund"` - InsufficientRefundBalance bool `json:"insufficientRefundBalance"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanRefund bool `json:"canRefund"` + InsufficientRefundBalance bool `json:"insufficientRefundBalance"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type RefundMinipoolResponse struct { Status string `json:"status"` @@ -77,11 +77,11 @@ type RefundMinipoolResponse struct { } type CanDissolveMinipoolResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanDissolve bool `json:"canDissolve"` - InvalidStatus bool `json:"invalidStatus"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanDissolve bool `json:"canDissolve"` + InvalidStatus bool `json:"invalidStatus"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type DissolveMinipoolResponse struct { Status string `json:"status"` @@ -116,11 +116,11 @@ type ImportKeyResponse struct { } type CanProcessWithdrawalResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanWithdraw bool `json:"canWithdraw"` - InvalidStatus bool `json:"invalidStatus"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanWithdraw bool `json:"canWithdraw"` + InvalidStatus bool `json:"invalidStatus"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type ProcessWithdrawalResponse struct { Status string `json:"status"` @@ -129,11 +129,11 @@ type ProcessWithdrawalResponse struct { } type CanProcessWithdrawalAndFinaliseResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanWithdraw bool `json:"canWithdraw"` - InvalidStatus bool `json:"invalidStatus"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanWithdraw bool `json:"canWithdraw"` + InvalidStatus bool `json:"invalidStatus"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type ProcessWithdrawalAndFinaliseResponse struct { Status string `json:"status"` @@ -153,7 +153,7 @@ type MinipoolCloseDetails struct { UserDepositBalance *big.Int `json:"userDepositBalance"` BeaconState beacon.ValidatorState `json:"beaconState"` NodeShare *big.Int `json:"nodeShare"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type GetMinipoolCloseDetailsForNodeResponse struct { @@ -181,12 +181,12 @@ type CanDistributeBalanceResponse struct { MinipoolStatus types.MinipoolStatus `json:"minipoolStatus"` Balance *big.Int `json:"balance"` CanDistribute bool `json:"canDistribute"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type EstimateDistributeBalanceGasResponse struct { - Status string `json:"status"` - Error string `json:"error"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type DistributeBalanceResponse struct { Status string `json:"status"` @@ -195,9 +195,9 @@ type DistributeBalanceResponse struct { } type CanFinaliseMinipoolResponse struct { - Status string `json:"status"` - Error string `json:"error"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type FinaliseMinipoolResponse struct { Status string `json:"status"` @@ -206,10 +206,10 @@ type FinaliseMinipoolResponse struct { } type CanDelegateUpgradeResponse struct { - Status string `json:"status"` - Error string `json:"error"` - LatestDelegateAddress common.Address `json:"latestDelegateAddress"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + LatestDelegateAddress common.Address `json:"latestDelegateAddress"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type DelegateUpgradeResponse struct { Status string `json:"status"` @@ -218,9 +218,9 @@ type DelegateUpgradeResponse struct { } type CanSetUseLatestDelegateResponse struct { - Status string `json:"status"` - Error string `json:"error"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type SetUseLatestDelegateResponse struct { Status string `json:"status"` @@ -229,10 +229,10 @@ type SetUseLatestDelegateResponse struct { } type CanStakeMinipoolResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanStake bool `json:"canStake"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanStake bool `json:"canStake"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type StakeMinipoolResponse struct { Status string `json:"status"` @@ -241,10 +241,10 @@ type StakeMinipoolResponse struct { } type CanPromoteMinipoolResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanPromote bool `json:"canPromote"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanPromote bool `json:"canPromote"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type PromoteMinipoolResponse struct { Status string `json:"status"` @@ -295,7 +295,7 @@ type CanBeginReduceBondAmountResponse struct { BeaconState beacon.ValidatorState `json:"beaconState"` InvalidBeaconState bool `json:"invalidBeaconState"` CanReduce bool `json:"canReduce"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type BeginReduceBondAmountResponse struct { Status string `json:"status"` @@ -304,11 +304,11 @@ type BeginReduceBondAmountResponse struct { } type CanReduceBondAmountResponse struct { - Status string `json:"status"` - Error string `json:"error"` - MinipoolVersion uint8 `json:"minipoolVersion"` - CanReduce bool `json:"canReduce"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + MinipoolVersion uint8 `json:"minipoolVersion"` + CanReduce bool `json:"canReduce"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type ReduceBondAmountResponse struct { Status string `json:"status"` @@ -324,7 +324,7 @@ type MinipoolRescueDissolvedDetails struct { MinipoolVersion uint8 `json:"minipoolVersion"` BeaconBalance *big.Int `json:"beaconBalance"` BeaconState beacon.ValidatorState `json:"beaconState"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type GetMinipoolRescueDissolvedDetailsForNodeResponse struct { diff --git a/shared/types/api/node.go b/shared/types/api/node.go index 34b87116a..e09d2ca44 100644 --- a/shared/types/api/node.go +++ b/shared/types/api/node.go @@ -7,8 +7,8 @@ import ( "github.com/ethereum/go-ethereum/common" - "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/tokens" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" rptypes "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/shared/services/rewards" "github.com/rocket-pool/smartnode/shared/utils/cli/color" @@ -161,12 +161,12 @@ func (n NodeAlert) ColorString() string { } type CanRegisterNodeResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanRegister bool `json:"canRegister"` - AlreadyRegistered bool `json:"alreadyRegistered"` - RegistrationDisabled bool `json:"registrationDisabled"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanRegister bool `json:"canRegister"` + AlreadyRegistered bool `json:"alreadyRegistered"` + RegistrationDisabled bool `json:"registrationDisabled"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type RegisterNodeResponse struct { Status string `json:"status"` @@ -175,11 +175,11 @@ type RegisterNodeResponse struct { } type CanProvisionExpressTicketsResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanProvision bool `json:"canProvision"` - AlreadyProvisioned bool `json:"alreadyProvisioned"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanProvision bool `json:"canProvision"` + AlreadyProvisioned bool `json:"alreadyProvisioned"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type ProvisionExpressTicketsResponse struct { Status string `json:"status"` @@ -188,10 +188,10 @@ type ProvisionExpressTicketsResponse struct { } type CanSetNodePrimaryWithdrawalAddressResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanSet bool `json:"canSet"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanSet bool `json:"canSet"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type SetNodePrimaryWithdrawalAddressResponse struct { Status string `json:"status"` @@ -200,10 +200,10 @@ type SetNodePrimaryWithdrawalAddressResponse struct { } type CanConfirmNodePrimaryWithdrawalAddressResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanConfirm bool `json:"canConfirm"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanConfirm bool `json:"canConfirm"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type ConfirmNodePrimaryWithdrawalAddressResponse struct { Status string `json:"status"` @@ -212,13 +212,13 @@ type ConfirmNodePrimaryWithdrawalAddressResponse struct { } type CanSetNodeRPLWithdrawalAddressResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanSet bool `json:"canSet"` - PrimaryAddressDiffers bool `json:"primaryAddressDiffers"` - RPLAddressDiffers bool `json:"rplAddressDiffers"` - RPLStake *big.Int `json:"rplStake"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanSet bool `json:"canSet"` + PrimaryAddressDiffers bool `json:"primaryAddressDiffers"` + RPLAddressDiffers bool `json:"rplAddressDiffers"` + RPLStake *big.Int `json:"rplStake"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type SetNodeRPLWithdrawalAddressResponse struct { Status string `json:"status"` @@ -227,10 +227,10 @@ type SetNodeRPLWithdrawalAddressResponse struct { } type CanConfirmNodeRPLWithdrawalAddressResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanConfirm bool `json:"canConfirm"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanConfirm bool `json:"canConfirm"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type ConfirmNodeRPLWithdrawalAddressResponse struct { Status string `json:"status"` @@ -251,10 +251,10 @@ type GetNodePendingPrimaryWithdrawalAddressResponse struct { } type CanSetNodeTimezoneResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanSet bool `json:"canSet"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanSet bool `json:"canSet"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type SetNodeTimezoneResponse struct { Status string `json:"status"` @@ -263,16 +263,16 @@ type SetNodeTimezoneResponse struct { } type CanNodeSwapRplResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanSwap bool `json:"canSwap"` - InsufficientBalance bool `json:"insufficientBalance"` - GasInfo rocketpool.GasInfo `json:"GasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanSwap bool `json:"canSwap"` + InsufficientBalance bool `json:"insufficientBalance"` + GasLimits gaslimit.Limits `json:"GasLimits"` } type NodeSwapRplApproveGasResponse struct { - Status string `json:"status"` - Error string `json:"error"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type NodeSwapRplApproveResponse struct { Status string `json:"status"` @@ -291,17 +291,17 @@ type NodeSwapRplAllowanceResponse struct { } type CanNodeStakeRplResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanStake bool `json:"canStake"` - InsufficientBalance bool `json:"insufficientBalance"` - InConsensus bool `json:"inConsensus"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanStake bool `json:"canStake"` + InsufficientBalance bool `json:"insufficientBalance"` + InConsensus bool `json:"inConsensus"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type NodeStakeRplApproveGasResponse struct { - Status string `json:"status"` - Error string `json:"error"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type NodeStakeRplApproveResponse struct { Status string `json:"status"` @@ -320,10 +320,10 @@ type NodeStakeRplAllowanceResponse struct { } type CanSetRplLockingAllowedResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanSet bool `json:"canSet"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanSet bool `json:"canSet"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type SetRplLockingAllowedResponse struct { @@ -332,10 +332,10 @@ type SetRplLockingAllowedResponse struct { SetTxHash common.Hash `json:"setTxHash"` } type CanSetStakeRplForAllowedResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanSet bool `json:"canSet"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanSet bool `json:"canSet"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type SetStakeRplForAllowedResponse struct { Status string `json:"status"` @@ -343,12 +343,12 @@ type SetStakeRplForAllowedResponse struct { SetTxHash common.Hash `json:"setTxHash"` } type CanNodeWithdrawEthResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanWithdraw bool `json:"canWithdraw"` - InsufficientBalance bool `json:"insufficientBalance"` - HasDifferentWithdrawalAddress bool `json:"hasDifferentWithdrawalAddress"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanWithdraw bool `json:"canWithdraw"` + InsufficientBalance bool `json:"insufficientBalance"` + HasDifferentWithdrawalAddress bool `json:"hasDifferentWithdrawalAddress"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type NodeWithdrawEthResponse struct { Status string `json:"status"` @@ -356,11 +356,11 @@ type NodeWithdrawEthResponse struct { TxHash common.Hash `json:"txHash"` } type CanNodeWithdrawCreditResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanWithdraw bool `json:"canWithdraw"` - InsufficientBalance bool `json:"insufficientBalance"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanWithdraw bool `json:"canWithdraw"` + InsufficientBalance bool `json:"insufficientBalance"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type NodeWithdrawCreditResponse struct { Status string `json:"status"` @@ -369,12 +369,12 @@ type NodeWithdrawCreditResponse struct { } type CanNodeUnstakeRplResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanUnstake bool `json:"canUnstake"` - InsufficientBalance bool `json:"insufficientBalance"` - HasDifferentRPLWithdrawalAddress bool `json:"hasDifferentRPLWithdrawalAddress"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanUnstake bool `json:"canUnstake"` + InsufficientBalance bool `json:"insufficientBalance"` + HasDifferentRPLWithdrawalAddress bool `json:"hasDifferentRPLWithdrawalAddress"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type NodeUnstakeRplResponse struct { Status string `json:"status"` @@ -382,13 +382,13 @@ type NodeUnstakeRplResponse struct { TxHash common.Hash `json:"txHash"` } type CanNodeUnstakeLegacyRplResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanUnstake bool `json:"canUnstake"` - InsufficientBalance bool `json:"insufficientBalance"` - HasDifferentRPLWithdrawalAddress bool `json:"hasDifferentRPLWithdrawalAddress"` - BelowMaxRPLStake bool `json:"belowMaxRPLStake"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanUnstake bool `json:"canUnstake"` + InsufficientBalance bool `json:"insufficientBalance"` + HasDifferentRPLWithdrawalAddress bool `json:"hasDifferentRPLWithdrawalAddress"` + BelowMaxRPLStake bool `json:"belowMaxRPLStake"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type NodeUnstakeLegacyRplResponse struct { Status string `json:"status"` @@ -402,24 +402,24 @@ type NodeWithdrawRplResponse struct { TxHash common.Hash `json:"txHash"` } type CanNodeWithdrawRplResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanWithdraw bool `json:"canWithdraw"` - InsufficientBalance bool `json:"insufficientBalance"` - UnstakingPeriodActive bool `json:"unstakingPeriodActive"` - HasDifferentRPLWithdrawalAddress bool `json:"hasDifferentRPLWithdrawalAddress"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanWithdraw bool `json:"canWithdraw"` + InsufficientBalance bool `json:"insufficientBalance"` + UnstakingPeriodActive bool `json:"unstakingPeriodActive"` + HasDifferentRPLWithdrawalAddress bool `json:"hasDifferentRPLWithdrawalAddress"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type CanNodeWithdrawRplv1_3_1Response struct { - Status string `json:"status"` - Error string `json:"error"` - CanWithdraw bool `json:"canWithdraw"` - InsufficientBalance bool `json:"insufficientBalance"` - BelowMaxRPLStake bool `json:"belowMaxRPLStake"` - MinipoolsUndercollateralized bool `json:"minipoolsUndercollateralized"` - WithdrawalDelayActive bool `json:"withdrawalDelayActive"` - HasDifferentRPLWithdrawalAddress bool `json:"hasDifferentRPLWithdrawalAddress"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanWithdraw bool `json:"canWithdraw"` + InsufficientBalance bool `json:"insufficientBalance"` + BelowMaxRPLStake bool `json:"belowMaxRPLStake"` + MinipoolsUndercollateralized bool `json:"minipoolsUndercollateralized"` + WithdrawalDelayActive bool `json:"withdrawalDelayActive"` + HasDifferentRPLWithdrawalAddress bool `json:"hasDifferentRPLWithdrawalAddress"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type CanNodeDepositsResponse struct { @@ -440,7 +440,7 @@ type CanNodeDepositsResponse struct { MinipoolAddress common.Address `json:"minipoolAddress"` MegapoolAddress common.Address `json:"megapoolAddress"` ValidatorPubkeys []rptypes.ValidatorPubkey `json:"validatorPubkeys"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type NodeDepositsResponse struct { @@ -452,14 +452,14 @@ type NodeDepositsResponse struct { } type CanCreateVacantMinipoolResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanDeposit bool `json:"canDeposit"` - InsufficientRplStake bool `json:"insufficientRplStake"` - InvalidAmount bool `json:"invalidAmount"` - DepositDisabled bool `json:"depositDisabled"` - MinipoolAddress common.Address `json:"minipoolAddress"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanDeposit bool `json:"canDeposit"` + InsufficientRplStake bool `json:"insufficientRplStake"` + InvalidAmount bool `json:"invalidAmount"` + DepositDisabled bool `json:"depositDisabled"` + MinipoolAddress common.Address `json:"minipoolAddress"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type CreateVacantMinipoolResponse struct { Status string `json:"status"` @@ -471,14 +471,14 @@ type CreateVacantMinipoolResponse struct { } type CanNodeSendResponse struct { - Status string `json:"status"` - Error string `json:"error"` - Balance float64 `json:"balance"` - TokenName string `json:"name"` - TokenSymbol string `json:"symbol"` - CanSend bool `json:"canSend"` - InsufficientBalance bool `json:"insufficientBalance"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + Balance float64 `json:"balance"` + TokenName string `json:"name"` + TokenSymbol string `json:"symbol"` + CanSend bool `json:"canSend"` + InsufficientBalance bool `json:"insufficientBalance"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type NodeSendResponse struct { Status string `json:"status"` @@ -487,9 +487,9 @@ type NodeSendResponse struct { } type CanNodeSendMessageResponse struct { - Status string `json:"status"` - Error string `json:"error"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type NodeSendMessageResponse struct { Status string `json:"status"` @@ -498,12 +498,12 @@ type NodeSendMessageResponse struct { } type CanNodeBurnResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanBurn bool `json:"canBurn"` - InsufficientBalance bool `json:"insufficientBalance"` - InsufficientCollateral bool `json:"insufficientCollateral"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanBurn bool `json:"canBurn"` + InsufficientBalance bool `json:"insufficientBalance"` + InsufficientCollateral bool `json:"insufficientCollateral"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type NodeBurnResponse struct { Status string `json:"status"` @@ -519,10 +519,10 @@ type NodeSyncProgressResponse struct { } type CanNodeClaimRplResponse struct { - Status string `json:"status"` - Error string `json:"error"` - RplAmount *big.Int `json:"rplAmount"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + RplAmount *big.Int `json:"rplAmount"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type NodeClaimRplResponse struct { Status string `json:"status"` @@ -575,10 +575,10 @@ type NodeIsFeeDistributorInitializedResponse struct { IsInitialized bool `json:"isInitialized"` } type NodeInitializeFeeDistributorGasResponse struct { - Status string `json:"status"` - Error string `json:"error"` - Distributor common.Address `json:"distributor"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + Distributor common.Address `json:"distributor"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type NodeInitializeFeeDistributorResponse struct { Status string `json:"status"` @@ -586,11 +586,11 @@ type NodeInitializeFeeDistributorResponse struct { TxHash common.Hash `json:"txHash"` } type NodeCanDistributeResponse struct { - Status string `json:"status"` - Error string `json:"error"` - Balance *big.Int `json:"balance"` - NodeShare float64 `json:"nodeShare"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + Balance *big.Int `json:"balance"` + NodeShare float64 `json:"nodeShare"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type NodeDistributeResponse struct { Status string `json:"status"` @@ -617,9 +617,9 @@ type NodeGetRewardsInfoResponse struct { } type CanNodeClaimRewardsResponse struct { - Status string `json:"status"` - Error string `json:"error"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type NodeClaimRewardsResponse struct { Status string `json:"status"` @@ -628,9 +628,9 @@ type NodeClaimRewardsResponse struct { } type CanNodeClaimAndStakeRewardsResponse struct { - Status string `json:"status"` - Error string `json:"error"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type NodeClaimAndStakeRewardsResponse struct { Status string `json:"status"` @@ -645,9 +645,9 @@ type GetSmoothingPoolRegistrationStatusResponse struct { TimeLeftUntilChangeable time.Duration `json:"timeLeftUntilChangeable"` } type CanSetSmoothingPoolRegistrationStatusResponse struct { - Status string `json:"status"` - Error string `json:"error"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type SetSmoothingPoolRegistrationStatusResponse struct { Status string `json:"status"` @@ -750,10 +750,10 @@ type GetExpressTicketsProvisionedResponse struct { } type CanClaimRefundResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanClaim bool `json:"canClaim"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanClaim bool `json:"canClaim"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type ClaimRefundResponse struct { Status string `json:"status"` @@ -762,11 +762,11 @@ type ClaimRefundResponse struct { } type CanReduceBondResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanReduceBond bool `json:"canReduceBond"` - NotEnoughBond bool `json:"notEnoughBond"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanReduceBond bool `json:"canReduceBond"` + NotEnoughBond bool `json:"notEnoughBond"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type ReduceBondResponse struct { Status string `json:"status"` @@ -775,12 +775,12 @@ type ReduceBondResponse struct { } type CanRepayDebtResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanRepay bool `json:"canRepay"` - NotEnoughDebt bool `json:"notEnoughDebt"` - NotEnoughBalance bool `json:"notEnoughBalance"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanRepay bool `json:"canRepay"` + NotEnoughDebt bool `json:"notEnoughDebt"` + NotEnoughBalance bool `json:"notEnoughBalance"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type RepayDebtResponse struct { Status string `json:"status"` @@ -789,11 +789,11 @@ type RepayDebtResponse struct { } type CanDissolveValidatorResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanDissolve bool `json:"canDissolve"` - NotInPrestake bool `json:"notInPrestake"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanDissolve bool `json:"canDissolve"` + NotInPrestake bool `json:"notInPrestake"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type DissolveValidatorResponse struct { Status string `json:"status"` @@ -802,12 +802,12 @@ type DissolveValidatorResponse struct { } type CanDissolveWithProofResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanDissolve bool `json:"canDissolve"` - NotInPrestake bool `json:"notInPrestake"` - ValidCredentials bool `json:"validCredentials"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanDissolve bool `json:"canDissolve"` + NotInPrestake bool `json:"notInPrestake"` + ValidCredentials bool `json:"validCredentials"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type DissolveWithProofResponse struct { Status string `json:"status"` @@ -816,11 +816,11 @@ type DissolveWithProofResponse struct { } type CanExitValidatorResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanExit bool `json:"canExit"` - InvalidStatus bool `json:"invalidStatus"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanExit bool `json:"canExit"` + InvalidStatus bool `json:"invalidStatus"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type ExitValidatorResponse struct { Status string `json:"status"` @@ -829,11 +829,11 @@ type ExitValidatorResponse struct { } type CanNotifyValidatorExitResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanExit bool `json:"canExit"` - InvalidStatus bool `json:"invalidStatus"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanExit bool `json:"canExit"` + InvalidStatus bool `json:"invalidStatus"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type NotifyValidatorExitResponse struct { Status string `json:"status"` @@ -842,11 +842,11 @@ type NotifyValidatorExitResponse struct { } type CanNotifyFinalBalanceResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanExit bool `json:"canExit"` - InvalidStatus bool `json:"invalidStatus"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanExit bool `json:"canExit"` + InvalidStatus bool `json:"invalidStatus"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type NotifyFinalBalanceResponse struct { Status string `json:"status"` @@ -855,11 +855,11 @@ type NotifyFinalBalanceResponse struct { } type CanStakeResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanStake bool `json:"canStake"` - IndexNotFound bool `json:"indexNotFound"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanStake bool `json:"canStake"` + IndexNotFound bool `json:"indexNotFound"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type StakeResponse struct { Status string `json:"status"` @@ -868,10 +868,10 @@ type StakeResponse struct { } type CanExitQueueResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanExit bool `json:"canExit"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanExit bool `json:"canExit"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type ExitQueueResponse struct { @@ -881,10 +881,10 @@ type ExitQueueResponse struct { } type CanClaimUnclaimedRewardsResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanClaim bool `json:"canClaim"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanClaim bool `json:"canClaim"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type ClaimUnclaimedRewardsResponse struct { diff --git a/shared/types/api/odao.go b/shared/types/api/odao.go index 3c2d36dd5..30e642863 100644 --- a/shared/types/api/odao.go +++ b/shared/types/api/odao.go @@ -7,7 +7,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/dao" tn "github.com/rocket-pool/smartnode/bindings/dao/trustednode" - "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" ) type TNDAOStatusResponse struct { @@ -49,12 +49,12 @@ type TNDAOProposalResponse struct { } type CanProposeTNDAOInviteResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanPropose bool `json:"canPropose"` - ProposalCooldownActive bool `json:"proposalCooldownActive"` - MemberAlreadyExists bool `json:"memberAlreadyExists"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanPropose bool `json:"canPropose"` + ProposalCooldownActive bool `json:"proposalCooldownActive"` + MemberAlreadyExists bool `json:"memberAlreadyExists"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type ProposeTNDAOInviteResponse struct { Status string `json:"status"` @@ -64,12 +64,12 @@ type ProposeTNDAOInviteResponse struct { } type CanProposeTNDAOLeaveResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanPropose bool `json:"canPropose"` - ProposalCooldownActive bool `json:"proposalCooldownActive"` - InsufficientMembers bool `json:"insufficientMembers"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanPropose bool `json:"canPropose"` + ProposalCooldownActive bool `json:"proposalCooldownActive"` + InsufficientMembers bool `json:"insufficientMembers"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type ProposeTNDAOLeaveResponse struct { Status string `json:"status"` @@ -79,12 +79,12 @@ type ProposeTNDAOLeaveResponse struct { } type CanProposeTNDAOReplaceResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanPropose bool `json:"canPropose"` - ProposalCooldownActive bool `json:"proposalCooldownActive"` - MemberAlreadyExists bool `json:"memberAlreadyExists"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanPropose bool `json:"canPropose"` + ProposalCooldownActive bool `json:"proposalCooldownActive"` + MemberAlreadyExists bool `json:"memberAlreadyExists"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type ProposeTNDAOReplaceResponse struct { Status string `json:"status"` @@ -94,12 +94,12 @@ type ProposeTNDAOReplaceResponse struct { } type CanProposeTNDAOKickResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanPropose bool `json:"canPropose"` - ProposalCooldownActive bool `json:"proposalCooldownActive"` - InsufficientRplBond bool `json:"insufficientRplBond"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanPropose bool `json:"canPropose"` + ProposalCooldownActive bool `json:"proposalCooldownActive"` + InsufficientRplBond bool `json:"insufficientRplBond"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type ProposeTNDAOKickResponse struct { Status string `json:"status"` @@ -109,13 +109,13 @@ type ProposeTNDAOKickResponse struct { } type CanCancelTNDAOProposalResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanCancel bool `json:"canCancel"` - DoesNotExist bool `json:"doesNotExist"` - InvalidState bool `json:"invalidState"` - InvalidProposer bool `json:"invalidProposer"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanCancel bool `json:"canCancel"` + DoesNotExist bool `json:"doesNotExist"` + InvalidState bool `json:"invalidState"` + InvalidProposer bool `json:"invalidProposer"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type CancelTNDAOProposalResponse struct { Status string `json:"status"` @@ -124,14 +124,14 @@ type CancelTNDAOProposalResponse struct { } type CanVoteOnTNDAOProposalResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanVote bool `json:"canVote"` - DoesNotExist bool `json:"doesNotExist"` - InvalidState bool `json:"invalidState"` - JoinedAfterCreated bool `json:"joinedAfterCreated"` - AlreadyVoted bool `json:"alreadyVoted"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanVote bool `json:"canVote"` + DoesNotExist bool `json:"doesNotExist"` + InvalidState bool `json:"invalidState"` + JoinedAfterCreated bool `json:"joinedAfterCreated"` + AlreadyVoted bool `json:"alreadyVoted"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type VoteOnTNDAOProposalResponse struct { Status string `json:"status"` @@ -140,12 +140,12 @@ type VoteOnTNDAOProposalResponse struct { } type CanExecuteTNDAOProposalResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanExecute bool `json:"canExecute"` - DoesNotExist bool `json:"doesNotExist"` - InvalidState bool `json:"invalidState"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanExecute bool `json:"canExecute"` + DoesNotExist bool `json:"doesNotExist"` + InvalidState bool `json:"invalidState"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type ExecuteTNDAOProposalResponse struct { Status string `json:"status"` @@ -154,13 +154,13 @@ type ExecuteTNDAOProposalResponse struct { } type CanExecuteTNDAOUpgradeResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanExecute bool `json:"canExecute"` - InvalidTrustedNode bool `json:"invalidTrustedNode"` - DoesNotExist bool `json:"doesNotExist"` - InvalidState bool `json:"invalidState"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanExecute bool `json:"canExecute"` + InvalidTrustedNode bool `json:"invalidTrustedNode"` + DoesNotExist bool `json:"doesNotExist"` + InvalidState bool `json:"invalidState"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type ExecuteTNDAOUpgradeResponse struct { Status string `json:"status"` @@ -169,13 +169,13 @@ type ExecuteTNDAOUpgradeResponse struct { } type CanJoinTNDAOResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanJoin bool `json:"canJoin"` - ProposalExpired bool `json:"proposalExpired"` - AlreadyMember bool `json:"alreadyMember"` - InsufficientRplBalance bool `json:"insufficientRplBalance"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanJoin bool `json:"canJoin"` + ProposalExpired bool `json:"proposalExpired"` + AlreadyMember bool `json:"alreadyMember"` + InsufficientRplBalance bool `json:"insufficientRplBalance"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type JoinTNDAOApproveResponse struct { Status string `json:"status"` @@ -189,12 +189,12 @@ type JoinTNDAOJoinResponse struct { } type CanLeaveTNDAOResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanLeave bool `json:"canLeave"` - ProposalExpired bool `json:"proposalExpired"` - InsufficientMembers bool `json:"insufficientMembers"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanLeave bool `json:"canLeave"` + ProposalExpired bool `json:"proposalExpired"` + InsufficientMembers bool `json:"insufficientMembers"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type LeaveTNDAOResponse struct { Status string `json:"status"` @@ -203,12 +203,12 @@ type LeaveTNDAOResponse struct { } type CanReplaceTNDAOPositionResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanReplace bool `json:"canReplace"` - ProposalExpired bool `json:"proposalExpired"` - MemberAlreadyExists bool `json:"memberAlreadyExists"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanReplace bool `json:"canReplace"` + ProposalExpired bool `json:"proposalExpired"` + MemberAlreadyExists bool `json:"memberAlreadyExists"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type ReplaceTNDAOPositionResponse struct { Status string `json:"status"` @@ -217,11 +217,11 @@ type ReplaceTNDAOPositionResponse struct { } type CanProposeTNDAOSettingResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanPropose bool `json:"canPropose"` - ProposalCooldownActive bool `json:"proposalCooldownActive"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanPropose bool `json:"canPropose"` + ProposalCooldownActive bool `json:"proposalCooldownActive"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type ProposeTNDAOSettingMembersQuorumResponse struct { Status string `json:"status"` @@ -332,10 +332,10 @@ type GetTNDAOMinipoolSettingsResponse struct { } type CanPenaliseMegapoolResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanPenalise bool `json:"canPenalise"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanPenalise bool `json:"canPenalise"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type PenaliseMegapoolResponse struct { Status string `json:"status"` diff --git a/shared/types/api/pdao.go b/shared/types/api/pdao.go index d078ba1de..3eddf747a 100644 --- a/shared/types/api/pdao.go +++ b/shared/types/api/pdao.go @@ -7,7 +7,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/rocket-pool/smartnode/bindings/dao/protocol" - "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/types" ) @@ -30,13 +30,13 @@ type PDAOProposalResponse struct { } type CanCancelPDAOProposalResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanCancel bool `json:"canCancel"` - DoesNotExist bool `json:"doesNotExist"` - InvalidState bool `json:"invalidState"` - InvalidProposer bool `json:"invalidProposer"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanCancel bool `json:"canCancel"` + DoesNotExist bool `json:"doesNotExist"` + InvalidState bool `json:"invalidState"` + InvalidProposer bool `json:"invalidProposer"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type CancelPDAOProposalResponse struct { Status string `json:"status"` @@ -45,15 +45,15 @@ type CancelPDAOProposalResponse struct { } type CanVoteOnPDAOProposalResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanVote bool `json:"canVote"` - DoesNotExist bool `json:"doesNotExist"` - InvalidState bool `json:"invalidState"` - InsufficientPower bool `json:"insufficientPower"` - AlreadyVoted bool `json:"alreadyVoted"` - VotingPower *big.Int `json:"votingPower"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanVote bool `json:"canVote"` + DoesNotExist bool `json:"doesNotExist"` + InvalidState bool `json:"invalidState"` + InsufficientPower bool `json:"insufficientPower"` + AlreadyVoted bool `json:"alreadyVoted"` + VotingPower *big.Int `json:"votingPower"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type VoteOnPDAOProposalResponse struct { Status string `json:"status"` @@ -62,12 +62,12 @@ type VoteOnPDAOProposalResponse struct { } type CanExecutePDAOProposalResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanExecute bool `json:"canExecute"` - DoesNotExist bool `json:"doesNotExist"` - InvalidState bool `json:"invalidState"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanExecute bool `json:"canExecute"` + DoesNotExist bool `json:"doesNotExist"` + InvalidState bool `json:"invalidState"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type ExecutePDAOProposalResponse struct { Status string `json:"status"` @@ -188,16 +188,16 @@ type GetPDAOSettingsResponse struct { } type CanProposePDAOSettingResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanPropose bool `json:"canPropose"` - InsufficientRpl bool `json:"proposalCooldownActive"` - StakedRpl *big.Int `json:"stakedRpl"` - LockedRpl *big.Int `json:"lockedRpl"` - ProposalBond *big.Int `json:"proposalBond"` - BlockNumber uint32 `json:"blockNumber"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` - IsRplLockingDisallowed bool `json:"isRplLockingDisallowed"` + Status string `json:"status"` + Error string `json:"error"` + CanPropose bool `json:"canPropose"` + InsufficientRpl bool `json:"proposalCooldownActive"` + StakedRpl *big.Int `json:"stakedRpl"` + LockedRpl *big.Int `json:"lockedRpl"` + ProposalBond *big.Int `json:"proposalBond"` + BlockNumber uint32 `json:"blockNumber"` + GasLimits gaslimit.Limits `json:"gasLimits"` + IsRplLockingDisallowed bool `json:"isRplLockingDisallowed"` } type ProposePDAOSettingResponse struct { Status string `json:"status"` @@ -215,12 +215,12 @@ type PDAOGetRewardsPercentagesResponse struct { } type PDAOCanProposeRewardsPercentagesResponse struct { - Status string `json:"status"` - Error string `json:"error"` - BlockNumber uint32 `json:"blockNumber"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` - CanPropose bool `json:"canPropose"` - IsRplLockingDisallowed bool `json:"isRplLockingDisallowed"` + Status string `json:"status"` + Error string `json:"error"` + BlockNumber uint32 `json:"blockNumber"` + GasLimits gaslimit.Limits `json:"gasLimits"` + CanPropose bool `json:"canPropose"` + IsRplLockingDisallowed bool `json:"isRplLockingDisallowed"` } type PDAOProposeRewardsPercentagesResponse struct { @@ -231,12 +231,12 @@ type PDAOProposeRewardsPercentagesResponse struct { } type PDAOCanProposeOneTimeSpendResponse struct { - Status string `json:"status"` - Error string `json:"error"` - BlockNumber uint32 `json:"blockNumber"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` - CanPropose bool `json:"canPropose"` - IsRplLockingDisallowed bool `json:"isRplLockingDisallowed"` + Status string `json:"status"` + Error string `json:"error"` + BlockNumber uint32 `json:"blockNumber"` + GasLimits gaslimit.Limits `json:"gasLimits"` + CanPropose bool `json:"canPropose"` + IsRplLockingDisallowed bool `json:"isRplLockingDisallowed"` } type PDAOProposeOneTimeSpendResponse struct { Status string `json:"status"` @@ -246,12 +246,12 @@ type PDAOProposeOneTimeSpendResponse struct { } type PDAOCanProposeRecurringSpendResponse struct { - Status string `json:"status"` - Error string `json:"error"` - BlockNumber uint32 `json:"blockNumber"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` - CanPropose bool `json:"canPropose"` - IsRplLockingDisallowed bool `json:"isRplLockingDisallowed"` + Status string `json:"status"` + Error string `json:"error"` + BlockNumber uint32 `json:"blockNumber"` + GasLimits gaslimit.Limits `json:"gasLimits"` + CanPropose bool `json:"canPropose"` + IsRplLockingDisallowed bool `json:"isRplLockingDisallowed"` } type PDAOProposeRecurringSpendResponse struct { @@ -262,12 +262,12 @@ type PDAOProposeRecurringSpendResponse struct { } type PDAOCanProposeRecurringSpendUpdateResponse struct { - Status string `json:"status"` - Error string `json:"error"` - BlockNumber uint32 `json:"blockNumber"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` - CanPropose bool `json:"canPropose"` - IsRplLockingDisallowed bool `json:"isRplLockingDisallowed"` + Status string `json:"status"` + Error string `json:"error"` + BlockNumber uint32 `json:"blockNumber"` + GasLimits gaslimit.Limits `json:"gasLimits"` + CanPropose bool `json:"canPropose"` + IsRplLockingDisallowed bool `json:"isRplLockingDisallowed"` } type PDAOProposeRecurringSpendUpdateResponse struct { @@ -278,13 +278,13 @@ type PDAOProposeRecurringSpendUpdateResponse struct { } type PDAOCanProposeInviteToSecurityCouncilResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanPropose bool `json:"canPropose"` - MemberAlreadyExists bool `json:"memberAlreadyExists"` - BlockNumber uint32 `json:"blockNumber"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` - IsRplLockingDisallowed bool `json:"isRplLockingDisallowed"` + Status string `json:"status"` + Error string `json:"error"` + CanPropose bool `json:"canPropose"` + MemberAlreadyExists bool `json:"memberAlreadyExists"` + BlockNumber uint32 `json:"blockNumber"` + GasLimits gaslimit.Limits `json:"gasLimits"` + IsRplLockingDisallowed bool `json:"isRplLockingDisallowed"` } type PDAOProposeInviteToSecurityCouncilResponse struct { Status string `json:"status"` @@ -294,12 +294,12 @@ type PDAOProposeInviteToSecurityCouncilResponse struct { } type PDAOCanProposeKickFromSecurityCouncilResponse struct { - Status string `json:"status"` - Error string `json:"error"` - BlockNumber uint32 `json:"blockNumber"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` - CanPropose bool `json:"canPropose"` - IsRplLockingDisallowed bool `json:"isRplLockingDisallowed"` + Status string `json:"status"` + Error string `json:"error"` + BlockNumber uint32 `json:"blockNumber"` + GasLimits gaslimit.Limits `json:"gasLimits"` + CanPropose bool `json:"canPropose"` + IsRplLockingDisallowed bool `json:"isRplLockingDisallowed"` } type PDAOProposeKickFromSecurityCouncilResponse struct { Status string `json:"status"` @@ -309,10 +309,10 @@ type PDAOProposeKickFromSecurityCouncilResponse struct { } type PDAOCanProposeKickMultiFromSecurityCouncilResponse struct { - Status string `json:"status"` - Error string `json:"error"` - BlockNumber uint32 `json:"blockNumber"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + BlockNumber uint32 `json:"blockNumber"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type PDAOProposeKickMultiFromSecurityCouncilResponse struct { Status string `json:"status"` @@ -322,12 +322,12 @@ type PDAOProposeKickMultiFromSecurityCouncilResponse struct { } type PDAOCanProposeReplaceMemberOfSecurityCouncilResponse struct { - Status string `json:"status"` - Error string `json:"error"` - BlockNumber uint32 `json:"blockNumber"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` - CanPropose bool `json:"canPropose"` - IsRplLockingDisallowed bool `json:"isRplLockingDisallowed"` + Status string `json:"status"` + Error string `json:"error"` + BlockNumber uint32 `json:"blockNumber"` + GasLimits gaslimit.Limits `json:"gasLimits"` + CanPropose bool `json:"canPropose"` + IsRplLockingDisallowed bool `json:"isRplLockingDisallowed"` } type PDAOProposeReplaceMemberOfSecurityCouncilResponse struct { @@ -353,13 +353,13 @@ type PDAOGetClaimableBondsResponse struct { } type PDAOCanClaimBondsResponse struct { - Status string `json:"status"` - Error string `json:"error"` - IsProposer bool `json:"isProposer"` - CanClaim bool `json:"canClaim"` - DoesNotExist bool `json:"doesNotExist"` - InvalidState bool `json:"invalidState"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + IsProposer bool `json:"isProposer"` + CanClaim bool `json:"canClaim"` + DoesNotExist bool `json:"doesNotExist"` + InvalidState bool `json:"invalidState"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type PDAOClaimBondsResponse struct { Status string `json:"status"` @@ -368,14 +368,14 @@ type PDAOClaimBondsResponse struct { } type PDAOCanDefeatProposalResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanDefeat bool `json:"canDefeat"` - DoesNotExist bool `json:"doesNotExist"` - AlreadyDefeated bool `json:"alreadyDefeated"` - StillInChallengeWindow bool `json:"stillInChallengeWindow"` - InvalidChallengeState bool `json:"invalidChallengeState"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanDefeat bool `json:"canDefeat"` + DoesNotExist bool `json:"doesNotExist"` + AlreadyDefeated bool `json:"alreadyDefeated"` + StillInChallengeWindow bool `json:"stillInChallengeWindow"` + InvalidChallengeState bool `json:"invalidChallengeState"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type PDAODefeatProposalResponse struct { Status string `json:"status"` @@ -384,13 +384,13 @@ type PDAODefeatProposalResponse struct { } type PDAOCanFinalizeProposalResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanFinalize bool `json:"canFinalize"` - DoesNotExist bool `json:"doesNotExist"` - InvalidState bool `json:"invalidState"` - AlreadyFinalized bool `json:"alreadyFinalized"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanFinalize bool `json:"canFinalize"` + DoesNotExist bool `json:"doesNotExist"` + InvalidState bool `json:"invalidState"` + AlreadyFinalized bool `json:"alreadyFinalized"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type PDAOFinalizeProposalResponse struct { Status string `json:"status"` @@ -399,9 +399,9 @@ type PDAOFinalizeProposalResponse struct { } type PDAOCanSetVotingDelegateResponse struct { - Status string `json:"status"` - Error string `json:"error"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type PDAOSetVotingDelegateResponse struct { @@ -418,10 +418,10 @@ type PDAOCurrentVotingDelegateResponse struct { } type PDAOCanInitializeVotingWithDelegateResponse struct { - Status string `json:"status"` - Error string `json:"error"` - VotingInitialized bool `json:"votingInitialized"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + VotingInitialized bool `json:"votingInitialized"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type PDAOInitializeVotingWithDelegateResponse struct { @@ -431,10 +431,10 @@ type PDAOInitializeVotingWithDelegateResponse struct { } type PDAOCanInitializeVotingResponse struct { - Status string `json:"status"` - Error string `json:"error"` - VotingInitialized bool `json:"votingInitialized"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + VotingInitialized bool `json:"votingInitialized"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type PDAOInitializeVotingResponse struct { @@ -470,10 +470,10 @@ type PDAOStatusResponse struct { } type PDAOCanSetSignallingAddressResponse struct { - Status string `json:"status"` - Error string `json:"error"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` - NodeToSigner common.Address `json:"nodeToSigner"` + Status string `json:"status"` + Error string `json:"error"` + GasLimits gaslimit.Limits `json:"gasLimits"` + NodeToSigner common.Address `json:"nodeToSigner"` } type PDAOSetSignallingAddressResponse struct { @@ -483,11 +483,11 @@ type PDAOSetSignallingAddressResponse struct { } type PDAOCanClearSignallingAddressResponse struct { - Status string `json:"status"` - Error string `json:"error"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` - VotingInitialized bool `json:"votingInitialized"` - NodeToSigner common.Address `json:"nodeToSigner"` + Status string `json:"status"` + Error string `json:"error"` + GasLimits gaslimit.Limits `json:"gasLimits"` + VotingInitialized bool `json:"votingInitialized"` + NodeToSigner common.Address `json:"nodeToSigner"` } type PDAOClearSignallingAddressResponse struct { @@ -497,12 +497,12 @@ type PDAOClearSignallingAddressResponse struct { } type PDAOACanProposeAllowListedControllersResponse struct { - Status string `json:"status"` - Error string `json:"error"` - BlockNumber uint32 `json:"blockNumber"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` - CanPropose bool `json:"canPropose"` - IsRplLockingDisallowed bool `json:"isRplLockingDisallowed"` + Status string `json:"status"` + Error string `json:"error"` + BlockNumber uint32 `json:"blockNumber"` + GasLimits gaslimit.Limits `json:"gasLimits"` + CanPropose bool `json:"canPropose"` + IsRplLockingDisallowed bool `json:"isRplLockingDisallowed"` } type PDAOProposeAllowListedControllersResponse struct { Status string `json:"status"` diff --git a/shared/types/api/queue.go b/shared/types/api/queue.go index c438a2150..084a9e411 100644 --- a/shared/types/api/queue.go +++ b/shared/types/api/queue.go @@ -4,8 +4,7 @@ import ( "math/big" "github.com/ethereum/go-ethereum/common" - - "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" ) type QueueStatusResponse struct { @@ -17,13 +16,13 @@ type QueueStatusResponse struct { } type CanProcessQueueResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanProcess bool `json:"canProcess"` - AssignDepositsDisabled bool `json:"assignDepositsDisabled"` - NoMinipoolsAvailable bool `json:"noMinipoolsAvailable"` - InsufficientDepositBalance bool `json:"insufficientDepositBalance"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanProcess bool `json:"canProcess"` + AssignDepositsDisabled bool `json:"assignDepositsDisabled"` + NoMinipoolsAvailable bool `json:"noMinipoolsAvailable"` + InsufficientDepositBalance bool `json:"insufficientDepositBalance"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type ProcessQueueResponse struct { Status string `json:"status"` @@ -42,11 +41,11 @@ type GetQueueDetailsResponse struct { } type CanAssignDepositsResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanAssign bool `json:"canAssign"` - AssignDepositsDisabled bool `json:"assignDepositsDisabled"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanAssign bool `json:"canAssign"` + AssignDepositsDisabled bool `json:"assignDepositsDisabled"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type AssignDepositsResponse struct { diff --git a/shared/types/api/security.go b/shared/types/api/security.go index 35ba1d958..545d45aee 100644 --- a/shared/types/api/security.go +++ b/shared/types/api/security.go @@ -5,7 +5,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/dao" "github.com/rocket-pool/smartnode/bindings/dao/security" - "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" ) type SecurityStatusResponse struct { @@ -46,11 +46,11 @@ type SecurityProposalResponse struct { } type SecurityCanProposeInviteResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanPropose bool `json:"canPropose"` - MemberAlreadyExists bool `json:"memberAlreadyExists"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanPropose bool `json:"canPropose"` + MemberAlreadyExists bool `json:"memberAlreadyExists"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type SecurityProposeInviteResponse struct { Status string `json:"status"` @@ -60,11 +60,11 @@ type SecurityProposeInviteResponse struct { } type SecurityCanProposeLeaveResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanPropose bool `json:"canPropose"` - MemberDoesntExist bool `json:"memberDoesntExist"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanPropose bool `json:"canPropose"` + MemberDoesntExist bool `json:"memberDoesntExist"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type SecurityProposeLeaveResponse struct { Status string `json:"status"` @@ -73,10 +73,10 @@ type SecurityProposeLeaveResponse struct { } type SecurityCanProposeKickResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanPropose bool `json:"canPropose"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanPropose bool `json:"canPropose"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type SecurityProposeKickResponse struct { Status string `json:"status"` @@ -86,10 +86,10 @@ type SecurityProposeKickResponse struct { } type SecurityCanProposeKickMultiResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanPropose bool `json:"canPropose"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanPropose bool `json:"canPropose"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type SecurityProposeKickMultiResponse struct { Status string `json:"status"` @@ -99,10 +99,10 @@ type SecurityProposeKickMultiResponse struct { } type SecurityCanProposeSettingResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanPropose bool `json:"canPropose"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanPropose bool `json:"canPropose"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type SecurityProposeSettingResponse struct { Status string `json:"status"` @@ -112,12 +112,12 @@ type SecurityProposeSettingResponse struct { } type SecurityCanProposeReplaceResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanPropose bool `json:"canPropose"` - OldMemberDoesntExist bool `json:"oldMemberDoesntExist"` - NewMemberAlreadyExists bool `json:"newMemberAlreadyExists"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanPropose bool `json:"canPropose"` + OldMemberDoesntExist bool `json:"oldMemberDoesntExist"` + NewMemberAlreadyExists bool `json:"newMemberAlreadyExists"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type SecurityProposeReplaceResponse struct { Status string `json:"status"` @@ -127,13 +127,13 @@ type SecurityProposeReplaceResponse struct { } type SecurityCanCancelProposalResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanCancel bool `json:"canCancel"` - DoesNotExist bool `json:"doesNotExist"` - InvalidState bool `json:"invalidState"` - InvalidProposer bool `json:"invalidProposer"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanCancel bool `json:"canCancel"` + DoesNotExist bool `json:"doesNotExist"` + InvalidState bool `json:"invalidState"` + InvalidProposer bool `json:"invalidProposer"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type SecurityCancelProposalResponse struct { Status string `json:"status"` @@ -142,14 +142,14 @@ type SecurityCancelProposalResponse struct { } type SecurityCanVoteOnProposalResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanVote bool `json:"canVote"` - DoesNotExist bool `json:"doesNotExist"` - InvalidState bool `json:"invalidState"` - JoinedAfterCreated bool `json:"joinedAfterCreated"` - AlreadyVoted bool `json:"alreadyVoted"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanVote bool `json:"canVote"` + DoesNotExist bool `json:"doesNotExist"` + InvalidState bool `json:"invalidState"` + JoinedAfterCreated bool `json:"joinedAfterCreated"` + AlreadyVoted bool `json:"alreadyVoted"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type SecurityVoteOnProposalResponse struct { Status string `json:"status"` @@ -158,12 +158,12 @@ type SecurityVoteOnProposalResponse struct { } type SecurityCanExecuteProposalResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanExecute bool `json:"canExecute"` - DoesNotExist bool `json:"doesNotExist"` - InvalidState bool `json:"invalidState"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanExecute bool `json:"canExecute"` + DoesNotExist bool `json:"doesNotExist"` + InvalidState bool `json:"invalidState"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type SecurityExecuteProposalResponse struct { Status string `json:"status"` @@ -172,12 +172,12 @@ type SecurityExecuteProposalResponse struct { } type SecurityCanJoinResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanJoin bool `json:"canJoin"` - ProposalExpired bool `json:"proposalExpired"` - AlreadyMember bool `json:"alreadyMember"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanJoin bool `json:"canJoin"` + ProposalExpired bool `json:"proposalExpired"` + AlreadyMember bool `json:"alreadyMember"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type SecurityJoinResponse struct { Status string `json:"status"` @@ -186,11 +186,11 @@ type SecurityJoinResponse struct { } type SecurityCanLeaveResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanLeave bool `json:"canLeave"` - ProposalExpired bool `json:"proposalExpired"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanLeave bool `json:"canLeave"` + ProposalExpired bool `json:"proposalExpired"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type SecurityLeaveResponse struct { Status string `json:"status"` diff --git a/shared/types/api/upgrades.go b/shared/types/api/upgrades.go index 641209457..3f1b34222 100644 --- a/shared/types/api/upgrades.go +++ b/shared/types/api/upgrades.go @@ -4,7 +4,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/rocket-pool/smartnode/bindings/dao/upgrades" - "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" ) type TNDAOUpgradeStatusResponse struct { @@ -22,13 +22,13 @@ type TNDAOGetUpgradeProposalsResponse struct { } type CanExecuteUpgradeProposalResponse struct { - Status string `json:"status"` - Error string `json:"error"` - CanExecute bool `json:"canExecute"` - DoesNotExist bool `json:"doesNotExist"` - InvalidTrustedNode bool `json:"invalidTrustedNode"` - InvalidState bool `json:"invalidState"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + CanExecute bool `json:"canExecute"` + DoesNotExist bool `json:"doesNotExist"` + InvalidTrustedNode bool `json:"invalidTrustedNode"` + InvalidState bool `json:"invalidState"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type ExecuteUpgradeProposalResponse struct { Status string `json:"status"` diff --git a/shared/types/api/wallet.go b/shared/types/api/wallet.go index c42d6fbf9..f4213225b 100644 --- a/shared/types/api/wallet.go +++ b/shared/types/api/wallet.go @@ -4,7 +4,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/google/uuid" - "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/types" ) @@ -76,12 +76,12 @@ type ExportWalletResponse struct { } type SetEnsNameResponse struct { - Status string `json:"status"` - Error string `json:"error"` - Address common.Address `json:"address"` - EnsName string `json:"ensName"` - TxHash common.Hash `json:"txHash"` - GasInfo rocketpool.GasInfo `json:"gasInfo"` + Status string `json:"status"` + Error string `json:"error"` + Address common.Address `json:"address"` + EnsName string `json:"ensName"` + TxHash common.Hash `json:"txHash"` + GasLimits gaslimit.Limits `json:"gasLimits"` } type TestMnemonicResponse struct { diff --git a/shared/utils/api/response.go b/shared/utils/api/response.go deleted file mode 100644 index b7b6fd512..000000000 --- a/shared/utils/api/response.go +++ /dev/null @@ -1,9 +0,0 @@ -package api - -import "math/big" - -func ZeroIfNil(in **big.Int) { - if *in == nil { - *in = big.NewInt(0) - } -} diff --git a/shared/utils/api/utils.go b/shared/utils/api/utils.go deleted file mode 100644 index 0c06248fb..000000000 --- a/shared/utils/api/utils.go +++ /dev/null @@ -1,137 +0,0 @@ -package api - -import ( - "encoding/hex" - "fmt" - "math/big" - "regexp" - "strconv" - "time" - - "github.com/ethereum/go-ethereum/common" - - "github.com/rocket-pool/smartnode/bindings/rocketpool" - "github.com/rocket-pool/smartnode/bindings/settings/protocol" - "github.com/rocket-pool/smartnode/bindings/utils" - "github.com/rocket-pool/smartnode/bindings/utils/eth" - "github.com/rocket-pool/smartnode/shared/services/config" - "github.com/rocket-pool/smartnode/shared/utils/log" - "github.com/rocket-pool/smartnode/shared/utils/math" -) - -type EIP712Components struct { - V uint8 `json:"v"` - R [32]byte `json:"r"` - S [32]byte `json:"s"` -} - -// The fraction of the timeout period to trigger overdue transactions -const TimeoutSafetyFactor int = 2 - -// Print the gas price and cost of a TX -func PrintAndCheckGasInfo(gasInfo rocketpool.GasInfo, checkThreshold bool, gasThresholdGwei float64, logger *log.ColorLogger, maxFeeWei *big.Int, gasLimit uint64) bool { - - // Check the gas threshold if requested - if checkThreshold { - gasThresholdWei := math.RoundUp(gasThresholdGwei*eth.WeiPerGwei, 0) - gasThreshold := new(big.Int).SetUint64(uint64(gasThresholdWei)) - if maxFeeWei.Cmp(gasThreshold) != -1 { - logger.Printlnf("Current network gas price is %.2f Gwei, which is not lower than the set threshold of %.2f Gwei. "+ - "Aborting the transaction.", eth.WeiToGwei(maxFeeWei), gasThresholdGwei) - return false - } - } else { - logger.Println("This transaction does not check the gas threshold limit, continuing...") - } - - // Print the total TX cost - var gas *big.Int - var safeGas *big.Int - if gasLimit != 0 { - gas = new(big.Int).SetUint64(gasLimit) - safeGas = gas - } else { - gas = new(big.Int).SetUint64(gasInfo.EstGasLimit) - safeGas = new(big.Int).SetUint64(gasInfo.SafeGasLimit) - } - totalGasWei := new(big.Int).Mul(maxFeeWei, gas) - totalSafeGasWei := new(big.Int).Mul(maxFeeWei, safeGas) - logger.Printlnf("This transaction will use a max fee of %.6f Gwei, for a total of up to %.6f - %.6f ETH.", - eth.WeiToGwei(maxFeeWei), - math.RoundDown(eth.WeiToEth(totalGasWei), 6), - math.RoundDown(eth.WeiToEth(totalSafeGasWei), 6)) - - return true -} - -// Print a TX's details to the logger and waits for it to validated. -func PrintAndWaitForTransaction(cfg *config.RocketPoolConfig, hash common.Hash, ec rocketpool.ExecutionClient, logger *log.ColorLogger) error { - - txWatchUrl := cfg.Smartnode.GetTxWatchUrl() - hashString := hash.String() - - logger.Printlnf("Transaction has been submitted with hash %s.", hashString) - if txWatchUrl != "" { - logger.Printlnf("You may follow its progress by visiting:") - logger.Printlnf("%s/%s\n", txWatchUrl, hashString) - } - logger.Println("Waiting for the transaction to be validated...") - - // Wait for the TX to be included in a block - if _, err := utils.WaitForTransaction(ec, hash); err != nil { - return fmt.Errorf("Error waiting for transaction: %w", err) - } - - return nil - -} - -// True if a transaction is due and needs to bypass the gas threshold -func IsTransactionDue(rp *rocketpool.RocketPool, startTime time.Time) (bool, time.Duration, error) { - - // Get the dissolve timeout - timeout, err := protocol.GetMinipoolLaunchTimeout(rp, nil) - if err != nil { - return false, 0, err - } - - dueTime := timeout / time.Duration(TimeoutSafetyFactor) - isDue := time.Since(startTime) > dueTime - timeUntilDue := time.Until(startTime.Add(dueTime)) - return isDue, timeUntilDue, nil - -} - -// Expects a 129 byte 0x-prefixed EIP-712 signature and returns v/r/s as v uint8 and r, s [32]byte - -func ParseEIP712(signature string) (*EIP712Components, error) { - if len(signature) != 132 || signature[:2] != "0x" { - return nil, fmt.Errorf("Invalid 129 byte 0x-prefixed EIP-712 signature while parsing: '%s'", signature) - } - signature = signature[2:] - if !regexp.MustCompile("^[A-Fa-f0-9]+$").MatchString(signature) { - return &EIP712Components{}, fmt.Errorf("Invalid 129 byte 0x-prefixed EIP-712 signature while parsing: '%s'", signature) - } - - // Slice signature string into v, r, s component of a signature giving node permission to use the given signer - str_v := signature[len(signature)-2:] - str_r := signature[:64] - str_s := signature[64:128] - - // Convert v to uint8 and v,s to [32]byte - bytes_r, err := hex.DecodeString(str_r) - if err != nil { - return &EIP712Components{}, fmt.Errorf("error decoding r: %v", err) - } - bytes_s, err := hex.DecodeString(str_s) - if err != nil { - return &EIP712Components{}, fmt.Errorf("error decoding s: %v", err) - } - - int_v, err := strconv.ParseUint(str_v, 16, 8) - if err != nil { - return &EIP712Components{}, fmt.Errorf("error parsing v: %v", err) - } - - return &EIP712Components{uint8(int_v), ([32]byte)(bytes_r), ([32]byte)(bytes_s)}, nil -} From 2b2ab30e9ad41ba31047e1f35126ce73ba970c37 Mon Sep 17 00:00:00 2001 From: Jacob Shufro Date: Sat, 25 Jul 2026 14:23:24 -0400 Subject: [PATCH 03/12] Remove shared/utils/cli --- addons/rescue_node/addon.go | 2 +- rocketpool-cli/auction/bid-lot.go | 4 ++-- rocketpool-cli/auction/claim-lot.go | 4 ++-- rocketpool-cli/auction/commands.go | 2 +- rocketpool-cli/auction/create-lot.go | 4 ++-- rocketpool-cli/auction/recover-lot.go | 4 ++-- rocketpool-cli/claims/claim-all.go | 6 +++--- rocketpool-cli/claims/commands.go | 2 +- shared/utils/cli/utils.go => rocketpool-cli/cli/cli.go | 2 +- {shared/utils => rocketpool-cli}/cli/color/color.go | 0 {shared/utils => rocketpool-cli}/cli/prompt/prompt.go | 2 +- {shared/utils => rocketpool-cli}/cli/prompt/prompt_unix.go | 0 .../utils => rocketpool-cli}/cli/prompt/prompt_windows.go | 0 {shared/utils => rocketpool-cli}/cli/validation.go | 2 +- rocketpool-cli/megapool/claim.go | 4 ++-- rocketpool-cli/megapool/commands.go | 2 +- rocketpool-cli/megapool/delegate.go | 4 ++-- rocketpool-cli/megapool/deposit.go | 6 +++--- rocketpool-cli/megapool/dissolve-validator.go | 4 ++-- rocketpool-cli/megapool/distribute.go | 4 ++-- rocketpool-cli/megapool/exit-queue.go | 4 ++-- rocketpool-cli/megapool/exit-validator.go | 4 ++-- rocketpool-cli/megapool/notify-final-balance.go | 6 +++--- rocketpool-cli/megapool/notify-validator-exit.go | 4 ++-- rocketpool-cli/megapool/reduce-bond.go | 4 ++-- rocketpool-cli/megapool/repay-debt.go | 4 ++-- rocketpool-cli/megapool/stake.go | 4 ++-- rocketpool-cli/megapool/status.go | 4 ++-- rocketpool-cli/minipool/close.go | 6 +++--- rocketpool-cli/minipool/commands.go | 2 +- rocketpool-cli/minipool/delegate.go | 4 ++-- rocketpool-cli/minipool/distribute.go | 6 +++--- rocketpool-cli/minipool/exit.go | 6 +++--- rocketpool-cli/minipool/import-key.go | 4 ++-- rocketpool-cli/minipool/refund.go | 4 ++-- rocketpool-cli/minipool/rescue-dissolved.go | 6 +++--- rocketpool-cli/minipool/stake.go | 4 ++-- rocketpool-cli/minipool/status.go | 4 ++-- rocketpool-cli/network/commands.go | 2 +- rocketpool-cli/network/dao-proposals.go | 4 ++-- rocketpool-cli/network/generate-tree.go | 4 ++-- rocketpool-cli/network/stats.go | 2 +- rocketpool-cli/node/allow-lock-rpl.go | 4 ++-- rocketpool-cli/node/claim-rewards.go | 6 +++--- rocketpool-cli/node/claim-unclaimed-rewards.go | 6 +++--- rocketpool-cli/node/commands.go | 2 +- rocketpool-cli/node/distributor.go | 4 ++-- rocketpool-cli/node/express-tickets.go | 2 +- rocketpool-cli/node/primary-withdrawal-address.go | 6 +++--- rocketpool-cli/node/register.go | 4 ++-- rocketpool-cli/node/rewards.go | 6 +++--- rocketpool-cli/node/rpl-withdrawal-address.go | 6 +++--- rocketpool-cli/node/send-message.go | 4 ++-- rocketpool-cli/node/send.go | 6 +++--- rocketpool-cli/node/set-timezone.go | 4 ++-- rocketpool-cli/node/sign-message.go | 2 +- rocketpool-cli/node/smoothing-pool.go | 6 +++--- rocketpool-cli/node/stake-rpl-whitelist.go | 4 ++-- rocketpool-cli/node/stake-rpl.go | 4 ++-- rocketpool-cli/node/status.go | 4 ++-- rocketpool-cli/node/swap-rpl.go | 4 ++-- rocketpool-cli/node/sync.go | 4 ++-- rocketpool-cli/node/utils.go | 2 +- rocketpool-cli/node/withdraw-credit.go | 4 ++-- rocketpool-cli/node/withdraw-eth.go | 4 ++-- rocketpool-cli/node/withdraw-rpl.go | 6 +++--- rocketpool-cli/odao/cancel-proposal.go | 4 ++-- rocketpool-cli/odao/commands.go | 2 +- rocketpool-cli/odao/execute-proposal.go | 4 ++-- rocketpool-cli/odao/execute-upgrade.go | 4 ++-- rocketpool-cli/odao/join.go | 4 ++-- rocketpool-cli/odao/leave.go | 4 ++-- rocketpool-cli/odao/members.go | 2 +- rocketpool-cli/odao/penalise-megapool.go | 4 ++-- rocketpool-cli/odao/proposals.go | 2 +- rocketpool-cli/odao/propose-invite.go | 4 ++-- rocketpool-cli/odao/propose-kick.go | 4 ++-- rocketpool-cli/odao/propose-leave.go | 4 ++-- rocketpool-cli/odao/propose-settings.go | 4 ++-- rocketpool-cli/odao/vote-proposal.go | 4 ++-- rocketpool-cli/pdao/claim-bonds.go | 4 ++-- rocketpool-cli/pdao/commands.go | 2 +- rocketpool-cli/pdao/defeat-proposal.go | 4 ++-- rocketpool-cli/pdao/execute-proposal.go | 4 ++-- rocketpool-cli/pdao/finalize-proposal.go | 4 ++-- rocketpool-cli/pdao/invite-sc.go | 4 ++-- rocketpool-cli/pdao/kick-sc.go | 4 ++-- rocketpool-cli/pdao/one-time-spend.go | 4 ++-- rocketpool-cli/pdao/percentages.go | 4 ++-- rocketpool-cli/pdao/propose-settings.go | 4 ++-- rocketpool-cli/pdao/recurring-spend-update.go | 4 ++-- rocketpool-cli/pdao/recurring-spend.go | 4 ++-- rocketpool-cli/pdao/replace-sc.go | 4 ++-- rocketpool-cli/pdao/set-allow-list.go | 6 +++--- rocketpool-cli/pdao/set-signalling-address.go | 4 ++-- rocketpool-cli/pdao/status.go | 4 ++-- rocketpool-cli/pdao/vote-proposal.go | 4 ++-- rocketpool-cli/pdao/voting.go | 4 ++-- rocketpool-cli/queue/assign-deposits.go | 4 ++-- rocketpool-cli/queue/commands.go | 2 +- rocketpool-cli/queue/process.go | 4 ++-- rocketpool-cli/rocketpool-cli.go | 4 ++-- rocketpool-cli/security/cancel-proposal.go | 4 ++-- rocketpool-cli/security/commands.go | 2 +- rocketpool-cli/security/execute-proposal.go | 4 ++-- rocketpool-cli/security/join.go | 4 ++-- rocketpool-cli/security/leave.go | 4 ++-- rocketpool-cli/security/members.go | 2 +- rocketpool-cli/security/proposals.go | 2 +- rocketpool-cli/security/propose-leave.go | 4 ++-- rocketpool-cli/security/propose-settings.go | 4 ++-- rocketpool-cli/security/vote-proposal.go | 4 ++-- rocketpool-cli/service/commands.go | 4 ++-- rocketpool-cli/service/service.go | 6 +++--- rocketpool-cli/update/update.go | 4 ++-- rocketpool-cli/wallet/commands.go | 4 ++-- rocketpool-cli/wallet/end-masquerade.go | 4 ++-- rocketpool-cli/wallet/ens-name.go | 6 +++--- rocketpool-cli/wallet/export.go | 2 +- rocketpool-cli/wallet/init.go | 2 +- rocketpool-cli/wallet/masquerade.go | 6 +++--- rocketpool-cli/wallet/purge.go | 4 ++-- rocketpool-cli/wallet/recover.go | 4 ++-- rocketpool-cli/wallet/status.go | 4 ++-- rocketpool-cli/wallet/test.go | 2 +- rocketpool-cli/wallet/utils.go | 4 ++-- rocketpool/api/pdao/propose-settings.go | 2 +- rocketpool/api/pdao/routes.go | 2 +- rocketpool/api/security/propose-settings.go | 2 +- rocketpool/api/upgrade/routes.go | 2 +- shared/services/ec-manager.go | 2 +- shared/services/gas/gas.go | 4 ++-- shared/services/rocketpool/client.go | 2 +- shared/services/rocketpool/gas.go | 2 +- shared/types/api/node.go | 2 +- treegen/main.go | 2 +- 136 files changed, 251 insertions(+), 251 deletions(-) rename shared/utils/cli/utils.go => rocketpool-cli/cli/cli.go (98%) rename {shared/utils => rocketpool-cli}/cli/color/color.go (100%) rename {shared/utils => rocketpool-cli}/cli/prompt/prompt.go (98%) rename {shared/utils => rocketpool-cli}/cli/prompt/prompt_unix.go (100%) rename {shared/utils => rocketpool-cli}/cli/prompt/prompt_windows.go (100%) rename {shared/utils => rocketpool-cli}/cli/validation.go (99%) diff --git a/addons/rescue_node/addon.go b/addons/rescue_node/addon.go index 8192a7ca7..e53e26039 100644 --- a/addons/rescue_node/addon.go +++ b/addons/rescue_node/addon.go @@ -10,9 +10,9 @@ import ( "google.golang.org/protobuf/proto" "github.com/rocket-pool/smartnode/addons/rescue_node/pb" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" "github.com/rocket-pool/smartnode/shared/types/addons" cfgtypes "github.com/rocket-pool/smartnode/shared/types/config" - "github.com/rocket-pool/smartnode/shared/utils/cli/color" ) const ( diff --git a/rocketpool-cli/auction/bid-lot.go b/rocketpool-cli/auction/bid-lot.go index f9b5faa7f..e68a35995 100644 --- a/rocketpool-cli/auction/bid-lot.go +++ b/rocketpool-cli/auction/bid-lot.go @@ -7,11 +7,11 @@ import ( "github.com/rocket-pool/smartnode/bindings/utils/eth" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" "github.com/rocket-pool/smartnode/shared/utils/math" ) diff --git a/rocketpool-cli/auction/claim-lot.go b/rocketpool-cli/auction/claim-lot.go index 7d0d44176..2560fd5f4 100644 --- a/rocketpool-cli/auction/claim-lot.go +++ b/rocketpool-cli/auction/claim-lot.go @@ -7,11 +7,11 @@ import ( "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/utils/eth" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" "github.com/rocket-pool/smartnode/shared/utils/math" ) diff --git a/rocketpool-cli/auction/commands.go b/rocketpool-cli/auction/commands.go index 38a298368..a6f1772aa 100644 --- a/rocketpool-cli/auction/commands.go +++ b/rocketpool-cli/auction/commands.go @@ -5,7 +5,7 @@ import ( "github.com/urfave/cli/v3" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" ) // Register commands diff --git a/rocketpool-cli/auction/create-lot.go b/rocketpool-cli/auction/create-lot.go index c8afacf53..bbc97df55 100644 --- a/rocketpool-cli/auction/create-lot.go +++ b/rocketpool-cli/auction/create-lot.go @@ -3,10 +3,10 @@ package auction import ( "fmt" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func createLot(yes bool) error { diff --git a/rocketpool-cli/auction/recover-lot.go b/rocketpool-cli/auction/recover-lot.go index 62c594730..2856c58c5 100644 --- a/rocketpool-cli/auction/recover-lot.go +++ b/rocketpool-cli/auction/recover-lot.go @@ -7,11 +7,11 @@ import ( "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/utils/eth" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" "github.com/rocket-pool/smartnode/shared/utils/math" ) diff --git a/rocketpool-cli/claims/claim-all.go b/rocketpool-cli/claims/claim-all.go index 593ba5a6e..493970d70 100644 --- a/rocketpool-cli/claims/claim-all.go +++ b/rocketpool-cli/claims/claim-all.go @@ -12,12 +12,12 @@ import ( "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/color" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" "github.com/rocket-pool/smartnode/shared/utils/math" ) diff --git a/rocketpool-cli/claims/commands.go b/rocketpool-cli/claims/commands.go index 5bd598432..a92d57c4b 100644 --- a/rocketpool-cli/claims/commands.go +++ b/rocketpool-cli/claims/commands.go @@ -5,7 +5,7 @@ import ( "github.com/urfave/cli/v3" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" ) // Register commands diff --git a/shared/utils/cli/utils.go b/rocketpool-cli/cli/cli.go similarity index 98% rename from shared/utils/cli/utils.go rename to rocketpool-cli/cli/cli.go index 0876b54d9..26f15e8a0 100644 --- a/shared/utils/cli/utils.go +++ b/rocketpool-cli/cli/cli.go @@ -8,9 +8,9 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/urfave/cli/v3" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" "github.com/rocket-pool/smartnode/shared/services/rocketpool" cfgtypes "github.com/rocket-pool/smartnode/shared/types/config" - "github.com/rocket-pool/smartnode/shared/utils/cli/color" ) const TimeFormat = "2006-01-02, 15:04 -0700 MST" diff --git a/shared/utils/cli/color/color.go b/rocketpool-cli/cli/color/color.go similarity index 100% rename from shared/utils/cli/color/color.go rename to rocketpool-cli/cli/color/color.go diff --git a/shared/utils/cli/prompt/prompt.go b/rocketpool-cli/cli/prompt/prompt.go similarity index 98% rename from shared/utils/cli/prompt/prompt.go rename to rocketpool-cli/cli/prompt/prompt.go index d41e88ca6..ea9137ab5 100644 --- a/shared/utils/cli/prompt/prompt.go +++ b/rocketpool-cli/cli/prompt/prompt.go @@ -10,7 +10,7 @@ import ( "strconv" "strings" - "github.com/rocket-pool/smartnode/shared/utils/cli/color" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" ) // Prompt for user input diff --git a/shared/utils/cli/prompt/prompt_unix.go b/rocketpool-cli/cli/prompt/prompt_unix.go similarity index 100% rename from shared/utils/cli/prompt/prompt_unix.go rename to rocketpool-cli/cli/prompt/prompt_unix.go diff --git a/shared/utils/cli/prompt/prompt_windows.go b/rocketpool-cli/cli/prompt/prompt_windows.go similarity index 100% rename from shared/utils/cli/prompt/prompt_windows.go rename to rocketpool-cli/cli/prompt/prompt_windows.go diff --git a/shared/utils/cli/validation.go b/rocketpool-cli/cli/validation.go similarity index 99% rename from shared/utils/cli/validation.go rename to rocketpool-cli/cli/validation.go index 80a202b45..678e981b9 100644 --- a/shared/utils/cli/validation.go +++ b/rocketpool-cli/cli/validation.go @@ -15,8 +15,8 @@ import ( "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/passwords" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" hexutils "github.com/rocket-pool/smartnode/shared/utils/hex" ) diff --git a/rocketpool-cli/megapool/claim.go b/rocketpool-cli/megapool/claim.go index 96dc5fe7b..5e89f50d0 100644 --- a/rocketpool-cli/megapool/claim.go +++ b/rocketpool-cli/megapool/claim.go @@ -5,10 +5,10 @@ import ( "math/big" "github.com/rocket-pool/smartnode/bindings/utils/eth" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" "github.com/rocket-pool/smartnode/shared/utils/math" ) diff --git a/rocketpool-cli/megapool/commands.go b/rocketpool-cli/megapool/commands.go index ac97227df..ee72ac6cc 100644 --- a/rocketpool-cli/megapool/commands.go +++ b/rocketpool-cli/megapool/commands.go @@ -5,7 +5,7 @@ import ( "github.com/urfave/cli/v3" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" ) // Register commands diff --git a/rocketpool-cli/megapool/delegate.go b/rocketpool-cli/megapool/delegate.go index 14410983a..74f7505a9 100644 --- a/rocketpool-cli/megapool/delegate.go +++ b/rocketpool-cli/megapool/delegate.go @@ -3,10 +3,10 @@ package megapool import ( "fmt" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func setUseLatestDelegateMegapool(setting *bool, yes bool) error { diff --git a/rocketpool-cli/megapool/deposit.go b/rocketpool-cli/megapool/deposit.go index 8dabfbe39..6eb0def10 100644 --- a/rocketpool-cli/megapool/deposit.go +++ b/rocketpool-cli/megapool/deposit.go @@ -9,12 +9,12 @@ import ( "github.com/rocket-pool/smartnode/bindings/utils/eth" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/color" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" "github.com/rocket-pool/smartnode/shared/utils/math" ) diff --git a/rocketpool-cli/megapool/dissolve-validator.go b/rocketpool-cli/megapool/dissolve-validator.go index b85aa87a4..52c146375 100644 --- a/rocketpool-cli/megapool/dissolve-validator.go +++ b/rocketpool-cli/megapool/dissolve-validator.go @@ -3,11 +3,11 @@ package megapool import ( "fmt" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func getDissolvableValidator() (uint64, bool, error) { diff --git a/rocketpool-cli/megapool/distribute.go b/rocketpool-cli/megapool/distribute.go index 8fa4129c2..21df76488 100644 --- a/rocketpool-cli/megapool/distribute.go +++ b/rocketpool-cli/megapool/distribute.go @@ -5,11 +5,11 @@ import ( "math/big" "github.com/rocket-pool/smartnode/bindings/utils/eth" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func distribute(yes bool) error { diff --git a/rocketpool-cli/megapool/exit-queue.go b/rocketpool-cli/megapool/exit-queue.go index a1f427d97..263ebffa1 100644 --- a/rocketpool-cli/megapool/exit-queue.go +++ b/rocketpool-cli/megapool/exit-queue.go @@ -6,11 +6,11 @@ import ( "strings" "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) // Exit the megapool queue diff --git a/rocketpool-cli/megapool/exit-validator.go b/rocketpool-cli/megapool/exit-validator.go index 11120a04d..1eb0ccee1 100644 --- a/rocketpool-cli/megapool/exit-validator.go +++ b/rocketpool-cli/megapool/exit-validator.go @@ -7,11 +7,11 @@ import ( "strings" "time" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" - "github.com/rocket-pool/smartnode/shared/utils/cli/color" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) type ByIndex []api.MegapoolValidatorDetails diff --git a/rocketpool-cli/megapool/notify-final-balance.go b/rocketpool-cli/megapool/notify-final-balance.go index dd71bef41..7393e1d65 100644 --- a/rocketpool-cli/megapool/notify-final-balance.go +++ b/rocketpool-cli/megapool/notify-final-balance.go @@ -5,15 +5,15 @@ import ( "sort" "strconv" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/config" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" cfgtypes "github.com/rocket-pool/smartnode/shared/types/config" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/color" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func getNotifiableValidator() (uint64, uint64, bool, error) { diff --git a/rocketpool-cli/megapool/notify-validator-exit.go b/rocketpool-cli/megapool/notify-validator-exit.go index fb2b150c8..cb32571d3 100644 --- a/rocketpool-cli/megapool/notify-validator-exit.go +++ b/rocketpool-cli/megapool/notify-validator-exit.go @@ -4,11 +4,11 @@ import ( "fmt" "sort" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) const FarFutureEpoch uint64 = 0xffffffffffffffff diff --git a/rocketpool-cli/megapool/reduce-bond.go b/rocketpool-cli/megapool/reduce-bond.go index dd383569d..fc44c65f5 100644 --- a/rocketpool-cli/megapool/reduce-bond.go +++ b/rocketpool-cli/megapool/reduce-bond.go @@ -5,10 +5,10 @@ import ( "strconv" "github.com/rocket-pool/smartnode/bindings/utils/eth" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" "github.com/rocket-pool/smartnode/shared/utils/math" ) diff --git a/rocketpool-cli/megapool/repay-debt.go b/rocketpool-cli/megapool/repay-debt.go index 5bc349014..f5bdb33e5 100644 --- a/rocketpool-cli/megapool/repay-debt.go +++ b/rocketpool-cli/megapool/repay-debt.go @@ -6,10 +6,10 @@ import ( "strconv" "github.com/rocket-pool/smartnode/bindings/utils/eth" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" "github.com/rocket-pool/smartnode/shared/utils/math" ) diff --git a/rocketpool-cli/megapool/stake.go b/rocketpool-cli/megapool/stake.go index 3db9d4933..967d7d597 100644 --- a/rocketpool-cli/megapool/stake.go +++ b/rocketpool-cli/megapool/stake.go @@ -3,11 +3,11 @@ package megapool import ( "fmt" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func getStakableValidator() (uint64, bool, error) { diff --git a/rocketpool-cli/megapool/status.go b/rocketpool-cli/megapool/status.go index f6f721600..52f056839 100644 --- a/rocketpool-cli/megapool/status.go +++ b/rocketpool-cli/megapool/status.go @@ -8,9 +8,9 @@ import ( "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/shared/types/api" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/color" "github.com/rocket-pool/smartnode/shared/utils/math" ) diff --git a/rocketpool-cli/minipool/close.go b/rocketpool-cli/minipool/close.go index 240771dd2..7c2867122 100644 --- a/rocketpool-cli/minipool/close.go +++ b/rocketpool-cli/minipool/close.go @@ -11,13 +11,13 @@ import ( "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/color" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" "github.com/rocket-pool/smartnode/shared/utils/math" ) diff --git a/rocketpool-cli/minipool/commands.go b/rocketpool-cli/minipool/commands.go index 40dd1bffc..91c1acfb2 100644 --- a/rocketpool-cli/minipool/commands.go +++ b/rocketpool-cli/minipool/commands.go @@ -5,7 +5,7 @@ import ( "github.com/urfave/cli/v3" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" ) // Register commands diff --git a/rocketpool-cli/minipool/delegate.go b/rocketpool-cli/minipool/delegate.go index 5322452d1..2a1fd8ada 100644 --- a/rocketpool-cli/minipool/delegate.go +++ b/rocketpool-cli/minipool/delegate.go @@ -6,11 +6,11 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func delegateUpgradeMinipools(minipool string, includeFinalized, yes bool) error { diff --git a/rocketpool-cli/minipool/distribute.go b/rocketpool-cli/minipool/distribute.go index 7cb0572c6..3ea26df50 100644 --- a/rocketpool-cli/minipool/distribute.go +++ b/rocketpool-cli/minipool/distribute.go @@ -12,12 +12,12 @@ import ( "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/color" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" "github.com/rocket-pool/smartnode/shared/utils/math" ) diff --git a/rocketpool-cli/minipool/exit.go b/rocketpool-cli/minipool/exit.go index b5e69580d..515000ab0 100644 --- a/rocketpool-cli/minipool/exit.go +++ b/rocketpool-cli/minipool/exit.go @@ -8,11 +8,11 @@ import ( "github.com/rocket-pool/smartnode/bindings/types" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/color" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func exitMinipools(minipool string, yes bool) error { diff --git a/rocketpool-cli/minipool/import-key.go b/rocketpool-cli/minipool/import-key.go index 2b077e412..92b854321 100644 --- a/rocketpool-cli/minipool/import-key.go +++ b/rocketpool-cli/minipool/import-key.go @@ -5,10 +5,10 @@ import ( "github.com/ethereum/go-ethereum/common" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/rocketpool-cli/wallet" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - "github.com/rocket-pool/smartnode/shared/utils/cli/color" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func importKey(mnemonic string, noRestart, yes bool, minipoolAddress common.Address) error { diff --git a/rocketpool-cli/minipool/refund.go b/rocketpool-cli/minipool/refund.go index 8fe236895..946bd1c90 100644 --- a/rocketpool-cli/minipool/refund.go +++ b/rocketpool-cli/minipool/refund.go @@ -9,11 +9,11 @@ import ( "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/utils/eth" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" "github.com/rocket-pool/smartnode/shared/utils/math" ) diff --git a/rocketpool-cli/minipool/rescue-dissolved.go b/rocketpool-cli/minipool/rescue-dissolved.go index 72ba0fb8c..69df76971 100644 --- a/rocketpool-cli/minipool/rescue-dissolved.go +++ b/rocketpool-cli/minipool/rescue-dissolved.go @@ -11,13 +11,13 @@ import ( "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/color" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" "github.com/rocket-pool/smartnode/shared/utils/math" ) diff --git a/rocketpool-cli/minipool/stake.go b/rocketpool-cli/minipool/stake.go index d6452280c..6d727a174 100644 --- a/rocketpool-cli/minipool/stake.go +++ b/rocketpool-cli/minipool/stake.go @@ -7,11 +7,11 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func stakeMinipools(minipool string, yes bool) error { diff --git a/rocketpool-cli/minipool/status.go b/rocketpool-cli/minipool/status.go index 9e4dfbe18..1b69144c0 100644 --- a/rocketpool-cli/minipool/status.go +++ b/rocketpool-cli/minipool/status.go @@ -9,10 +9,10 @@ import ( "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/color" "github.com/rocket-pool/smartnode/shared/utils/hex" "github.com/rocket-pool/smartnode/shared/utils/math" ) diff --git a/rocketpool-cli/network/commands.go b/rocketpool-cli/network/commands.go index c1c40385a..ee5f52aaa 100644 --- a/rocketpool-cli/network/commands.go +++ b/rocketpool-cli/network/commands.go @@ -5,7 +5,7 @@ import ( "github.com/urfave/cli/v3" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" ) // Register commands diff --git a/rocketpool-cli/network/dao-proposals.go b/rocketpool-cli/network/dao-proposals.go index 7b1ee5abc..b4f1cc262 100644 --- a/rocketpool-cli/network/dao-proposals.go +++ b/rocketpool-cli/network/dao-proposals.go @@ -9,9 +9,9 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/rocket-pool/smartnode/bindings/utils/eth" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/color" ) func getActiveDAOProposals() error { diff --git a/rocketpool-cli/network/generate-tree.go b/rocketpool-cli/network/generate-tree.go index dc1dea585..1743f0ab3 100644 --- a/rocketpool-cli/network/generate-tree.go +++ b/rocketpool-cli/network/generate-tree.go @@ -4,9 +4,9 @@ import ( "fmt" "strconv" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - "github.com/rocket-pool/smartnode/shared/utils/cli/color" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) const ( diff --git a/rocketpool-cli/network/stats.go b/rocketpool-cli/network/stats.go index 3bcac7b67..188580428 100644 --- a/rocketpool-cli/network/stats.go +++ b/rocketpool-cli/network/stats.go @@ -3,8 +3,8 @@ package network import ( "fmt" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - "github.com/rocket-pool/smartnode/shared/utils/cli/color" ) func getStats() error { diff --git a/rocketpool-cli/node/allow-lock-rpl.go b/rocketpool-cli/node/allow-lock-rpl.go index 3742af658..0d69c0c2a 100644 --- a/rocketpool-cli/node/allow-lock-rpl.go +++ b/rocketpool-cli/node/allow-lock-rpl.go @@ -3,10 +3,10 @@ package node import ( "fmt" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func setRPLLockingAllowed(yes, allowedToLock bool) error { diff --git a/rocketpool-cli/node/claim-rewards.go b/rocketpool-cli/node/claim-rewards.go index 448ffde86..585187ddc 100644 --- a/rocketpool-cli/node/claim-rewards.go +++ b/rocketpool-cli/node/claim-rewards.go @@ -11,13 +11,13 @@ import ( "github.com/rocket-pool/smartnode/bindings/utils/eth" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" rprewards "github.com/rocket-pool/smartnode/shared/services/rewards" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/color" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func nodeClaimRewards(restakeAmountFlag string, yes bool) error { diff --git a/rocketpool-cli/node/claim-unclaimed-rewards.go b/rocketpool-cli/node/claim-unclaimed-rewards.go index 5c251145c..8ff75f71d 100644 --- a/rocketpool-cli/node/claim-unclaimed-rewards.go +++ b/rocketpool-cli/node/claim-unclaimed-rewards.go @@ -5,11 +5,11 @@ import ( "math/big" "github.com/rocket-pool/smartnode/bindings/utils/eth" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/color" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" "github.com/rocket-pool/smartnode/shared/utils/math" ) diff --git a/rocketpool-cli/node/commands.go b/rocketpool-cli/node/commands.go index 55a9b6cc3..18b2b33d8 100644 --- a/rocketpool-cli/node/commands.go +++ b/rocketpool-cli/node/commands.go @@ -8,7 +8,7 @@ import ( "github.com/urfave/cli/v3" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" ) // Register commands diff --git a/rocketpool-cli/node/distributor.go b/rocketpool-cli/node/distributor.go index a61594b08..7bce3fca6 100644 --- a/rocketpool-cli/node/distributor.go +++ b/rocketpool-cli/node/distributor.go @@ -4,10 +4,10 @@ import ( "fmt" "github.com/rocket-pool/smartnode/bindings/utils/eth" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func initializeFeeDistributor(yes bool) error { diff --git a/rocketpool-cli/node/express-tickets.go b/rocketpool-cli/node/express-tickets.go index 45100c4fb..0519812d7 100644 --- a/rocketpool-cli/node/express-tickets.go +++ b/rocketpool-cli/node/express-tickets.go @@ -3,8 +3,8 @@ package node import ( "fmt" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" ) func provisionExpressTickets() error { diff --git a/rocketpool-cli/node/primary-withdrawal-address.go b/rocketpool-cli/node/primary-withdrawal-address.go index ce8f6806f..11f48b697 100644 --- a/rocketpool-cli/node/primary-withdrawal-address.go +++ b/rocketpool-cli/node/primary-withdrawal-address.go @@ -7,11 +7,11 @@ import ( "github.com/ethereum/go-ethereum/common" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/color" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func setPrimaryWithdrawalAddress(withdrawalAddressOrENS string, yes, force bool) error { diff --git a/rocketpool-cli/node/register.go b/rocketpool-cli/node/register.go index 068a76f05..ac53da61a 100644 --- a/rocketpool-cli/node/register.go +++ b/rocketpool-cli/node/register.go @@ -3,10 +3,10 @@ package node import ( "fmt" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func registerNode(timezoneLocation string, yes bool) error { diff --git a/rocketpool-cli/node/rewards.go b/rocketpool-cli/node/rewards.go index 8f6356f68..d155f3f5d 100644 --- a/rocketpool-cli/node/rewards.go +++ b/rocketpool-cli/node/rewards.go @@ -6,11 +6,11 @@ import ( "time" "github.com/rocket-pool/smartnode/bindings/utils/eth" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" rprewards "github.com/rocket-pool/smartnode/shared/services/rewards" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/color" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func getRewards(yes bool) error { diff --git a/rocketpool-cli/node/rpl-withdrawal-address.go b/rocketpool-cli/node/rpl-withdrawal-address.go index 13215ad25..f4d4c5d51 100644 --- a/rocketpool-cli/node/rpl-withdrawal-address.go +++ b/rocketpool-cli/node/rpl-withdrawal-address.go @@ -8,11 +8,11 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/rocket-pool/smartnode/bindings/utils/eth" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/color" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func setRPLWithdrawalAddress(withdrawalAddressOrENS string, yes, force bool) error { diff --git a/rocketpool-cli/node/send-message.go b/rocketpool-cli/node/send-message.go index fb398dc1e..e450a1269 100644 --- a/rocketpool-cli/node/send-message.go +++ b/rocketpool-cli/node/send-message.go @@ -6,10 +6,10 @@ import ( "github.com/ethereum/go-ethereum/common" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func sendMessage(toAddressOrENS string, message []byte, yes bool) error { diff --git a/rocketpool-cli/node/send.go b/rocketpool-cli/node/send.go index 8f1c06948..7c74ec856 100644 --- a/rocketpool-cli/node/send.go +++ b/rocketpool-cli/node/send.go @@ -6,11 +6,11 @@ import ( "github.com/ethereum/go-ethereum/common" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/color" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func nodeSend(amountRaw float64, sendAll bool, token string, toAddressOrENS string, yes bool) error { diff --git a/rocketpool-cli/node/set-timezone.go b/rocketpool-cli/node/set-timezone.go index b403ec600..eebfd922a 100644 --- a/rocketpool-cli/node/set-timezone.go +++ b/rocketpool-cli/node/set-timezone.go @@ -3,10 +3,10 @@ package node import ( "fmt" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func setTimezoneLocation(timezoneLocation string, yes bool) error { diff --git a/rocketpool-cli/node/sign-message.go b/rocketpool-cli/node/sign-message.go index c81025976..5feccab99 100644 --- a/rocketpool-cli/node/sign-message.go +++ b/rocketpool-cli/node/sign-message.go @@ -6,8 +6,8 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/goccy/go-json" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) const signatureVersion = 1 diff --git a/rocketpool-cli/node/smoothing-pool.go b/rocketpool-cli/node/smoothing-pool.go index d84b75fde..9a13c2115 100644 --- a/rocketpool-cli/node/smoothing-pool.go +++ b/rocketpool-cli/node/smoothing-pool.go @@ -3,11 +3,11 @@ package node import ( "fmt" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/color" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func joinSmoothingPool(yes bool) error { diff --git a/rocketpool-cli/node/stake-rpl-whitelist.go b/rocketpool-cli/node/stake-rpl-whitelist.go index c0088ca55..434e05a10 100644 --- a/rocketpool-cli/node/stake-rpl-whitelist.go +++ b/rocketpool-cli/node/stake-rpl-whitelist.go @@ -6,10 +6,10 @@ import ( "github.com/ethereum/go-ethereum/common" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func addAddressToStakeRplWhitelist(addressOrENS string, yes bool) error { diff --git a/rocketpool-cli/node/stake-rpl.go b/rocketpool-cli/node/stake-rpl.go index 9b359c183..3d2fd2bff 100644 --- a/rocketpool-cli/node/stake-rpl.go +++ b/rocketpool-cli/node/stake-rpl.go @@ -8,10 +8,10 @@ import ( "github.com/rocket-pool/smartnode/bindings/utils/eth" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" "github.com/rocket-pool/smartnode/shared/utils/math" ) diff --git a/rocketpool-cli/node/status.go b/rocketpool-cli/node/status.go index 62a1eb9a9..1f1dfad1b 100644 --- a/rocketpool-cli/node/status.go +++ b/rocketpool-cli/node/status.go @@ -13,9 +13,9 @@ import ( "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/addons/rescue_node" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/color" "github.com/rocket-pool/smartnode/shared/utils/math" ) diff --git a/rocketpool-cli/node/swap-rpl.go b/rocketpool-cli/node/swap-rpl.go index 39ff0aa5a..e5e8d5fd6 100644 --- a/rocketpool-cli/node/swap-rpl.go +++ b/rocketpool-cli/node/swap-rpl.go @@ -7,10 +7,10 @@ import ( "github.com/rocket-pool/smartnode/bindings/utils/eth" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" "github.com/rocket-pool/smartnode/shared/utils/math" ) diff --git a/rocketpool-cli/node/sync.go b/rocketpool-cli/node/sync.go index 5359a40af..5281e083b 100644 --- a/rocketpool-cli/node/sync.go +++ b/rocketpool-cli/node/sync.go @@ -4,10 +4,10 @@ import ( "fmt" "strings" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/color" ) func printClientStatus(status *api.ClientStatus, name string) { diff --git a/rocketpool-cli/node/utils.go b/rocketpool-cli/node/utils.go index 4315b8b1e..0ab0a3fef 100644 --- a/rocketpool-cli/node/utils.go +++ b/rocketpool-cli/node/utils.go @@ -14,7 +14,7 @@ import ( "github.com/goccy/go-json" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" ) // IPInfo API diff --git a/rocketpool-cli/node/withdraw-credit.go b/rocketpool-cli/node/withdraw-credit.go index 75031d95e..43bc42622 100644 --- a/rocketpool-cli/node/withdraw-credit.go +++ b/rocketpool-cli/node/withdraw-credit.go @@ -7,10 +7,10 @@ import ( "github.com/rocket-pool/smartnode/bindings/utils/eth" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" "github.com/rocket-pool/smartnode/shared/utils/math" ) diff --git a/rocketpool-cli/node/withdraw-eth.go b/rocketpool-cli/node/withdraw-eth.go index e71db9695..ec02578ad 100644 --- a/rocketpool-cli/node/withdraw-eth.go +++ b/rocketpool-cli/node/withdraw-eth.go @@ -7,10 +7,10 @@ import ( "github.com/rocket-pool/smartnode/bindings/utils/eth" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" "github.com/rocket-pool/smartnode/shared/utils/math" ) diff --git a/rocketpool-cli/node/withdraw-rpl.go b/rocketpool-cli/node/withdraw-rpl.go index 8feb59f33..4351da3a7 100644 --- a/rocketpool-cli/node/withdraw-rpl.go +++ b/rocketpool-cli/node/withdraw-rpl.go @@ -9,11 +9,11 @@ import ( "github.com/rocket-pool/smartnode/bindings/utils/eth" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/color" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" "github.com/rocket-pool/smartnode/shared/utils/math" ) diff --git a/rocketpool-cli/odao/cancel-proposal.go b/rocketpool-cli/odao/cancel-proposal.go index 691926d95..e54bd2ab4 100644 --- a/rocketpool-cli/odao/cancel-proposal.go +++ b/rocketpool-cli/odao/cancel-proposal.go @@ -8,10 +8,10 @@ import ( "github.com/rocket-pool/smartnode/bindings/dao" "github.com/rocket-pool/smartnode/bindings/types" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func cancelProposal(proposal string, yes bool) error { diff --git a/rocketpool-cli/odao/commands.go b/rocketpool-cli/odao/commands.go index 92f7e313b..2522c1faa 100644 --- a/rocketpool-cli/odao/commands.go +++ b/rocketpool-cli/odao/commands.go @@ -5,7 +5,7 @@ import ( "github.com/urfave/cli/v3" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" ) // Register commands diff --git a/rocketpool-cli/odao/execute-proposal.go b/rocketpool-cli/odao/execute-proposal.go index 2b30555b3..47a4f2f39 100644 --- a/rocketpool-cli/odao/execute-proposal.go +++ b/rocketpool-cli/odao/execute-proposal.go @@ -8,10 +8,10 @@ import ( "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/types" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func executeProposal(proposal string, yes bool) error { diff --git a/rocketpool-cli/odao/execute-upgrade.go b/rocketpool-cli/odao/execute-upgrade.go index de200c0b8..70608b3fa 100644 --- a/rocketpool-cli/odao/execute-upgrade.go +++ b/rocketpool-cli/odao/execute-upgrade.go @@ -11,10 +11,10 @@ import ( "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/types" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func getUpgradeProposals() error { diff --git a/rocketpool-cli/odao/join.go b/rocketpool-cli/odao/join.go index 96da55d27..72415f64d 100644 --- a/rocketpool-cli/odao/join.go +++ b/rocketpool-cli/odao/join.go @@ -6,10 +6,10 @@ import ( "github.com/rocket-pool/smartnode/bindings/utils/eth" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" "github.com/rocket-pool/smartnode/shared/utils/math" ) diff --git a/rocketpool-cli/odao/leave.go b/rocketpool-cli/odao/leave.go index a243493de..70e4a87c1 100644 --- a/rocketpool-cli/odao/leave.go +++ b/rocketpool-cli/odao/leave.go @@ -5,10 +5,10 @@ import ( "github.com/ethereum/go-ethereum/common" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func leave(refundAddress string, yes bool) error { diff --git a/rocketpool-cli/odao/members.go b/rocketpool-cli/odao/members.go index 05ace9635..7105475ff 100644 --- a/rocketpool-cli/odao/members.go +++ b/rocketpool-cli/odao/members.go @@ -5,8 +5,8 @@ import ( "github.com/rocket-pool/smartnode/bindings/utils/eth" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" "github.com/rocket-pool/smartnode/shared/utils/math" ) diff --git a/rocketpool-cli/odao/penalise-megapool.go b/rocketpool-cli/odao/penalise-megapool.go index 7227689e6..f10e7e5bc 100644 --- a/rocketpool-cli/odao/penalise-megapool.go +++ b/rocketpool-cli/odao/penalise-megapool.go @@ -8,10 +8,10 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/rocket-pool/smartnode/bindings/utils/eth" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" "github.com/rocket-pool/smartnode/shared/utils/math" ) diff --git a/rocketpool-cli/odao/proposals.go b/rocketpool-cli/odao/proposals.go index e61651c03..766ec14e2 100644 --- a/rocketpool-cli/odao/proposals.go +++ b/rocketpool-cli/odao/proposals.go @@ -10,8 +10,8 @@ import ( "github.com/rocket-pool/smartnode/bindings/dao" "github.com/rocket-pool/smartnode/bindings/types" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" ) func filterProposalState(state string, stateFilter string) bool { diff --git a/rocketpool-cli/odao/propose-invite.go b/rocketpool-cli/odao/propose-invite.go index c111032cb..a665f3c00 100644 --- a/rocketpool-cli/odao/propose-invite.go +++ b/rocketpool-cli/odao/propose-invite.go @@ -5,10 +5,10 @@ import ( "github.com/ethereum/go-ethereum/common" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func proposeInvite(memberAddress common.Address, memberId, memberUrl string, yes bool) error { diff --git a/rocketpool-cli/odao/propose-kick.go b/rocketpool-cli/odao/propose-kick.go index e66a4c849..bef687c05 100644 --- a/rocketpool-cli/odao/propose-kick.go +++ b/rocketpool-cli/odao/propose-kick.go @@ -11,10 +11,10 @@ import ( "github.com/rocket-pool/smartnode/bindings/dao/trustednode" "github.com/rocket-pool/smartnode/bindings/utils/eth" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" "github.com/rocket-pool/smartnode/shared/utils/math" ) diff --git a/rocketpool-cli/odao/propose-leave.go b/rocketpool-cli/odao/propose-leave.go index a5b34109c..739b69a24 100644 --- a/rocketpool-cli/odao/propose-leave.go +++ b/rocketpool-cli/odao/propose-leave.go @@ -3,10 +3,10 @@ package odao import ( "fmt" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func proposeLeave(yes bool) error { diff --git a/rocketpool-cli/odao/propose-settings.go b/rocketpool-cli/odao/propose-settings.go index 492f24689..9f8c2674d 100644 --- a/rocketpool-cli/odao/propose-settings.go +++ b/rocketpool-cli/odao/propose-settings.go @@ -6,10 +6,10 @@ import ( "github.com/rocket-pool/smartnode/bindings/utils/eth" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func proposeSettingMembersQuorum(quorumPercent float64, yes bool) error { diff --git a/rocketpool-cli/odao/vote-proposal.go b/rocketpool-cli/odao/vote-proposal.go index c1811059f..fb5323581 100644 --- a/rocketpool-cli/odao/vote-proposal.go +++ b/rocketpool-cli/odao/vote-proposal.go @@ -8,10 +8,10 @@ import ( "github.com/rocket-pool/smartnode/bindings/dao" "github.com/rocket-pool/smartnode/bindings/types" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func voteOnProposal(proposal string, supportFlag string, yes bool) error { diff --git a/rocketpool-cli/pdao/claim-bonds.go b/rocketpool-cli/pdao/claim-bonds.go index d0ff5a5ab..d5d7a8b17 100644 --- a/rocketpool-cli/pdao/claim-bonds.go +++ b/rocketpool-cli/pdao/claim-bonds.go @@ -8,11 +8,11 @@ import ( "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/utils/eth" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func claimBonds(proposal string, yes bool) error { diff --git a/rocketpool-cli/pdao/commands.go b/rocketpool-cli/pdao/commands.go index 54234e742..6b11403ef 100644 --- a/rocketpool-cli/pdao/commands.go +++ b/rocketpool-cli/pdao/commands.go @@ -8,7 +8,7 @@ import ( protocol131 "github.com/rocket-pool/smartnode/bindings/legacy/v1.3.1/protocol" "github.com/rocket-pool/smartnode/bindings/settings/protocol" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" ) const ( diff --git a/rocketpool-cli/pdao/defeat-proposal.go b/rocketpool-cli/pdao/defeat-proposal.go index 363bf2f74..17ac7d1fc 100644 --- a/rocketpool-cli/pdao/defeat-proposal.go +++ b/rocketpool-cli/pdao/defeat-proposal.go @@ -3,10 +3,10 @@ package pdao import ( "fmt" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func defeatProposal(proposalID uint64, challengedIndex uint64, yes bool) error { diff --git a/rocketpool-cli/pdao/execute-proposal.go b/rocketpool-cli/pdao/execute-proposal.go index 76ea5558c..e5b5f0f20 100644 --- a/rocketpool-cli/pdao/execute-proposal.go +++ b/rocketpool-cli/pdao/execute-proposal.go @@ -8,11 +8,11 @@ import ( "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/strings" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func executeProposal(proposal string, yes bool) error { diff --git a/rocketpool-cli/pdao/finalize-proposal.go b/rocketpool-cli/pdao/finalize-proposal.go index e18ac1b9c..522598cc3 100644 --- a/rocketpool-cli/pdao/finalize-proposal.go +++ b/rocketpool-cli/pdao/finalize-proposal.go @@ -3,10 +3,10 @@ package pdao import ( "fmt" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func finalizeProposal(proposalID uint64, yes bool) error { diff --git a/rocketpool-cli/pdao/invite-sc.go b/rocketpool-cli/pdao/invite-sc.go index 70d501b5a..070eb2aa0 100644 --- a/rocketpool-cli/pdao/invite-sc.go +++ b/rocketpool-cli/pdao/invite-sc.go @@ -3,10 +3,10 @@ package pdao import ( "fmt" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func proposeSecurityCouncilInvite(id string, addressFlag string, yes bool) error { diff --git a/rocketpool-cli/pdao/kick-sc.go b/rocketpool-cli/pdao/kick-sc.go index 364840933..beace592b 100644 --- a/rocketpool-cli/pdao/kick-sc.go +++ b/rocketpool-cli/pdao/kick-sc.go @@ -8,10 +8,10 @@ import ( "github.com/ethereum/go-ethereum/common" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func proposeSecurityCouncilKick(addressesFlag string, yes bool) error { diff --git a/rocketpool-cli/pdao/one-time-spend.go b/rocketpool-cli/pdao/one-time-spend.go index cf7f403ea..876cd2128 100644 --- a/rocketpool-cli/pdao/one-time-spend.go +++ b/rocketpool-cli/pdao/one-time-spend.go @@ -4,10 +4,10 @@ import ( "fmt" "math/big" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func proposeOneTimeSpend(invoiceIDFlag string, recipientFlag string, amountFlag string, customMessageFlag string, rawEnabled bool, yes bool) error { diff --git a/rocketpool-cli/pdao/percentages.go b/rocketpool-cli/pdao/percentages.go index 1a28e3a44..a3f0788d2 100644 --- a/rocketpool-cli/pdao/percentages.go +++ b/rocketpool-cli/pdao/percentages.go @@ -4,10 +4,10 @@ import ( "fmt" "github.com/rocket-pool/smartnode/bindings/utils/eth" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func getRewardsPercentages() error { diff --git a/rocketpool-cli/pdao/propose-settings.go b/rocketpool-cli/pdao/propose-settings.go index cc6d13420..07caad445 100644 --- a/rocketpool-cli/pdao/propose-settings.go +++ b/rocketpool-cli/pdao/propose-settings.go @@ -9,11 +9,11 @@ import ( "github.com/rocket-pool/smartnode/bindings/utils/eth" protocol131 "github.com/rocket-pool/smartnode/bindings/legacy/v1.3.1/protocol" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" ) func proposeSettingAuctionIsCreateLotEnabled(value bool, yes bool) error { diff --git a/rocketpool-cli/pdao/recurring-spend-update.go b/rocketpool-cli/pdao/recurring-spend-update.go index 9c68cc989..199b32ac5 100644 --- a/rocketpool-cli/pdao/recurring-spend-update.go +++ b/rocketpool-cli/pdao/recurring-spend-update.go @@ -4,10 +4,10 @@ import ( "fmt" "math/big" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func proposeRecurringSpendUpdate(rawEnabled bool, contractName string, recipientString string, amountString string, periodLengthString string, numPeriods uint64, customMessage string, yes bool) error { diff --git a/rocketpool-cli/pdao/recurring-spend.go b/rocketpool-cli/pdao/recurring-spend.go index 53c07383a..a2b3304bc 100644 --- a/rocketpool-cli/pdao/recurring-spend.go +++ b/rocketpool-cli/pdao/recurring-spend.go @@ -5,10 +5,10 @@ import ( "math/big" "time" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func proposeRecurringSpend(rawEnabled bool, contractName string, recipientString string, amountString string, startTimeUnix uint64, periodLengthString string, numPeriods uint64, customMessage string, yes bool) error { diff --git a/rocketpool-cli/pdao/replace-sc.go b/rocketpool-cli/pdao/replace-sc.go index b14c41eda..2aed4f727 100644 --- a/rocketpool-cli/pdao/replace-sc.go +++ b/rocketpool-cli/pdao/replace-sc.go @@ -6,10 +6,10 @@ import ( "github.com/ethereum/go-ethereum/common" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func proposeSecurityCouncilReplace(existingAddressString string, newID string, newAddressString string, yes bool) error { diff --git a/rocketpool-cli/pdao/set-allow-list.go b/rocketpool-cli/pdao/set-allow-list.go index 9e572504e..02f668530 100644 --- a/rocketpool-cli/pdao/set-allow-list.go +++ b/rocketpool-cli/pdao/set-allow-list.go @@ -5,11 +5,11 @@ import ( "strconv" "strings" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/color" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func setAllowListedControllers(addressListStr string, yes bool) error { diff --git a/rocketpool-cli/pdao/set-signalling-address.go b/rocketpool-cli/pdao/set-signalling-address.go index 9ed0beb43..8aa991668 100644 --- a/rocketpool-cli/pdao/set-signalling-address.go +++ b/rocketpool-cli/pdao/set-signalling-address.go @@ -5,10 +5,10 @@ import ( "github.com/ethereum/go-ethereum/common" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func setSignallingAddress(signallingAddress common.Address, signature string, yes bool) error { diff --git a/rocketpool-cli/pdao/status.go b/rocketpool-cli/pdao/status.go index 6dc1ecbfd..cb80e4f81 100644 --- a/rocketpool-cli/pdao/status.go +++ b/rocketpool-cli/pdao/status.go @@ -10,10 +10,10 @@ import ( "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/bindings/utils/strings" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/color" "github.com/rocket-pool/smartnode/shared/utils/math" ) diff --git a/rocketpool-cli/pdao/vote-proposal.go b/rocketpool-cli/pdao/vote-proposal.go index 87934bd29..0e7f706e3 100644 --- a/rocketpool-cli/pdao/vote-proposal.go +++ b/rocketpool-cli/pdao/vote-proposal.go @@ -8,11 +8,11 @@ import ( "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func voteOnProposal(proposal, voteDirectionFlag string, yes bool) error { diff --git a/rocketpool-cli/pdao/voting.go b/rocketpool-cli/pdao/voting.go index 2c57058ac..4cb04d2c4 100644 --- a/rocketpool-cli/pdao/voting.go +++ b/rocketpool-cli/pdao/voting.go @@ -6,10 +6,10 @@ import ( "github.com/ethereum/go-ethereum/common" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func pdaoSetVotingDelegate(nameOrAddress string, yes bool) error { diff --git a/rocketpool-cli/queue/assign-deposits.go b/rocketpool-cli/queue/assign-deposits.go index 5aca99d48..53102461c 100644 --- a/rocketpool-cli/queue/assign-deposits.go +++ b/rocketpool-cli/queue/assign-deposits.go @@ -6,10 +6,10 @@ import ( "strconv" "github.com/rocket-pool/smartnode/bindings/utils/eth" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func assignDeposits(yes bool) error { diff --git a/rocketpool-cli/queue/commands.go b/rocketpool-cli/queue/commands.go index 509fd89a6..8045effc4 100644 --- a/rocketpool-cli/queue/commands.go +++ b/rocketpool-cli/queue/commands.go @@ -5,7 +5,7 @@ import ( "github.com/urfave/cli/v3" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" ) // Register commands diff --git a/rocketpool-cli/queue/process.go b/rocketpool-cli/queue/process.go index 4a28feb6d..582462b59 100644 --- a/rocketpool-cli/queue/process.go +++ b/rocketpool-cli/queue/process.go @@ -4,10 +4,10 @@ import ( "fmt" "strconv" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func processQueue(yes bool) error { diff --git a/rocketpool-cli/rocketpool-cli.go b/rocketpool-cli/rocketpool-cli.go index 057dec99f..f35411dad 100644 --- a/rocketpool-cli/rocketpool-cli.go +++ b/rocketpool-cli/rocketpool-cli.go @@ -11,6 +11,8 @@ import ( "github.com/rocket-pool/smartnode/rocketpool-cli/auction" "github.com/rocket-pool/smartnode/rocketpool-cli/claims" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" "github.com/rocket-pool/smartnode/rocketpool-cli/megapool" "github.com/rocket-pool/smartnode/rocketpool-cli/minipool" "github.com/rocket-pool/smartnode/rocketpool-cli/network" @@ -24,8 +26,6 @@ import ( "github.com/rocket-pool/smartnode/rocketpool-cli/wallet" "github.com/rocket-pool/smartnode/shared" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/color" ) const ( diff --git a/rocketpool-cli/security/cancel-proposal.go b/rocketpool-cli/security/cancel-proposal.go index 9afc3f184..ad3f72867 100644 --- a/rocketpool-cli/security/cancel-proposal.go +++ b/rocketpool-cli/security/cancel-proposal.go @@ -8,10 +8,10 @@ import ( "github.com/rocket-pool/smartnode/bindings/dao" "github.com/rocket-pool/smartnode/bindings/types" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func cancelProposal(proposal string, yes bool) error { diff --git a/rocketpool-cli/security/commands.go b/rocketpool-cli/security/commands.go index bd5162f0a..58d509d5b 100644 --- a/rocketpool-cli/security/commands.go +++ b/rocketpool-cli/security/commands.go @@ -7,7 +7,7 @@ import ( "github.com/urfave/cli/v3" "github.com/rocket-pool/smartnode/bindings/settings/protocol" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" ) const ( diff --git a/rocketpool-cli/security/execute-proposal.go b/rocketpool-cli/security/execute-proposal.go index b5cae476e..ed54305a7 100644 --- a/rocketpool-cli/security/execute-proposal.go +++ b/rocketpool-cli/security/execute-proposal.go @@ -8,10 +8,10 @@ import ( "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/types" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func executeProposal(proposal string, yes bool) error { diff --git a/rocketpool-cli/security/join.go b/rocketpool-cli/security/join.go index 8e2679b81..6398b009f 100644 --- a/rocketpool-cli/security/join.go +++ b/rocketpool-cli/security/join.go @@ -3,10 +3,10 @@ package security import ( "fmt" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func join(yes bool) error { diff --git a/rocketpool-cli/security/leave.go b/rocketpool-cli/security/leave.go index 18c16fa2f..3ce9a85d9 100644 --- a/rocketpool-cli/security/leave.go +++ b/rocketpool-cli/security/leave.go @@ -3,10 +3,10 @@ package security import ( "fmt" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func leave(yes bool) error { diff --git a/rocketpool-cli/security/members.go b/rocketpool-cli/security/members.go index 4f5498194..78c696390 100644 --- a/rocketpool-cli/security/members.go +++ b/rocketpool-cli/security/members.go @@ -3,8 +3,8 @@ package security import ( "fmt" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" ) func getMembers() error { diff --git a/rocketpool-cli/security/proposals.go b/rocketpool-cli/security/proposals.go index a3590163f..b686ee58f 100644 --- a/rocketpool-cli/security/proposals.go +++ b/rocketpool-cli/security/proposals.go @@ -10,8 +10,8 @@ import ( "github.com/rocket-pool/smartnode/bindings/dao" "github.com/rocket-pool/smartnode/bindings/types" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" ) func filterProposalState(state string, stateFilter string) bool { diff --git a/rocketpool-cli/security/propose-leave.go b/rocketpool-cli/security/propose-leave.go index 5bf5c7105..483b4584a 100644 --- a/rocketpool-cli/security/propose-leave.go +++ b/rocketpool-cli/security/propose-leave.go @@ -3,10 +3,10 @@ package security import ( "fmt" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func proposeLeave(yes bool) error { diff --git a/rocketpool-cli/security/propose-settings.go b/rocketpool-cli/security/propose-settings.go index a4c8a42d5..a130c3034 100644 --- a/rocketpool-cli/security/propose-settings.go +++ b/rocketpool-cli/security/propose-settings.go @@ -6,10 +6,10 @@ import ( "github.com/rocket-pool/smartnode/bindings/settings/protocol" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func proposeSettingAuctionIsCreateLotEnabled(value bool, yes bool) error { diff --git a/rocketpool-cli/security/vote-proposal.go b/rocketpool-cli/security/vote-proposal.go index bf14147ae..0b6f41c92 100644 --- a/rocketpool-cli/security/vote-proposal.go +++ b/rocketpool-cli/security/vote-proposal.go @@ -8,10 +8,10 @@ import ( "github.com/rocket-pool/smartnode/bindings/dao" "github.com/rocket-pool/smartnode/bindings/types" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func voteOnProposal(proposal string, supportFlag string, yes bool) error { diff --git a/rocketpool-cli/service/commands.go b/rocketpool-cli/service/commands.go index 10d36d568..c7831b5a9 100644 --- a/rocketpool-cli/service/commands.go +++ b/rocketpool-cli/service/commands.go @@ -9,11 +9,11 @@ import ( "github.com/mitchellh/go-homedir" "github.com/urfave/cli/v3" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" "github.com/rocket-pool/smartnode/shared" "github.com/rocket-pool/smartnode/shared/services/config" cfgtypes "github.com/rocket-pool/smartnode/shared/types/config" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/color" ) // Get the compose file paths for a CLI context diff --git a/rocketpool-cli/service/service.go b/rocketpool-cli/service/service.go index b7b64cf54..fa5ab22f7 100644 --- a/rocketpool-cli/service/service.go +++ b/rocketpool-cli/service/service.go @@ -16,14 +16,14 @@ import ( "github.com/dustin/go-humanize" "github.com/shirou/gopsutil/v3/disk" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" cliconfig "github.com/rocket-pool/smartnode/rocketpool-cli/service/config" "github.com/rocket-pool/smartnode/shared" "github.com/rocket-pool/smartnode/shared/services/config" "github.com/rocket-pool/smartnode/shared/services/rocketpool" cfgtypes "github.com/rocket-pool/smartnode/shared/types/config" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/color" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) // Settings diff --git a/rocketpool-cli/update/update.go b/rocketpool-cli/update/update.go index 436e7fbb1..adaae3681 100644 --- a/rocketpool-cli/update/update.go +++ b/rocketpool-cli/update/update.go @@ -10,11 +10,11 @@ import ( "runtime" "strings" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/rocketpool-cli/update/assets" "github.com/rocket-pool/smartnode/shared" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - "github.com/rocket-pool/smartnode/shared/utils/cli/color" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) const ( diff --git a/rocketpool-cli/wallet/commands.go b/rocketpool-cli/wallet/commands.go index 36fc5881d..6e1098719 100644 --- a/rocketpool-cli/wallet/commands.go +++ b/rocketpool-cli/wallet/commands.go @@ -5,8 +5,8 @@ import ( "github.com/urfave/cli/v3" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/color" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" ) // Register commands diff --git a/rocketpool-cli/wallet/end-masquerade.go b/rocketpool-cli/wallet/end-masquerade.go index 71fc4bcb6..2d3467db7 100644 --- a/rocketpool-cli/wallet/end-masquerade.go +++ b/rocketpool-cli/wallet/end-masquerade.go @@ -5,9 +5,9 @@ import ( "github.com/ethereum/go-ethereum/common" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - "github.com/rocket-pool/smartnode/shared/utils/cli/color" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func endMasquerade(yes bool) error { diff --git a/rocketpool-cli/wallet/ens-name.go b/rocketpool-cli/wallet/ens-name.go index 6c35fc599..c9c598b20 100644 --- a/rocketpool-cli/wallet/ens-name.go +++ b/rocketpool-cli/wallet/ens-name.go @@ -3,11 +3,11 @@ package wallet import ( "fmt" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" + promptcli "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/color" - promptcli "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func setEnsName(name string, yes bool) error { diff --git a/rocketpool-cli/wallet/export.go b/rocketpool-cli/wallet/export.go index f74b488f3..2ffe876c9 100644 --- a/rocketpool-cli/wallet/export.go +++ b/rocketpool-cli/wallet/export.go @@ -4,8 +4,8 @@ import ( "fmt" "os" + promptcli "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - promptcli "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func exportWallet(secureSession bool) error { diff --git a/rocketpool-cli/wallet/init.go b/rocketpool-cli/wallet/init.go index 00652a8d5..77f87ee8f 100644 --- a/rocketpool-cli/wallet/init.go +++ b/rocketpool-cli/wallet/init.go @@ -3,8 +3,8 @@ package wallet import ( "fmt" + promptcli "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - promptcli "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" "github.com/rocket-pool/smartnode/shared/utils/term" ) diff --git a/rocketpool-cli/wallet/masquerade.go b/rocketpool-cli/wallet/masquerade.go index fc6cd507c..c091e22a7 100644 --- a/rocketpool-cli/wallet/masquerade.go +++ b/rocketpool-cli/wallet/masquerade.go @@ -3,10 +3,10 @@ package wallet import ( "fmt" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/color" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func masquerade(addressFlag string, yes bool, observe bool) error { diff --git a/rocketpool-cli/wallet/purge.go b/rocketpool-cli/wallet/purge.go index eb76400d3..6ce30f179 100644 --- a/rocketpool-cli/wallet/purge.go +++ b/rocketpool-cli/wallet/purge.go @@ -3,9 +3,9 @@ package wallet import ( "fmt" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" + promptcli "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - "github.com/rocket-pool/smartnode/shared/utils/cli/color" - promptcli "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func purge(composeFiles []string) error { diff --git a/rocketpool-cli/wallet/recover.go b/rocketpool-cli/wallet/recover.go index d2f1ec904..4bf4d9443 100644 --- a/rocketpool-cli/wallet/recover.go +++ b/rocketpool-cli/wallet/recover.go @@ -7,9 +7,9 @@ import ( "github.com/ethereum/go-ethereum/common" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" + promptcli "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - "github.com/rocket-pool/smartnode/shared/utils/cli/color" - promptcli "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) func recoverWallet(password, mnemonic, addressFlag string, skipValidatorKeyRecovery bool, derivationPath string, walletIndex uint) error { diff --git a/rocketpool-cli/wallet/status.go b/rocketpool-cli/wallet/status.go index 60722af18..428ee961f 100644 --- a/rocketpool-cli/wallet/status.go +++ b/rocketpool-cli/wallet/status.go @@ -5,9 +5,9 @@ import ( "github.com/ethereum/go-ethereum/common" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" - "github.com/rocket-pool/smartnode/shared/utils/cli/color" ) func getStatus() error { diff --git a/rocketpool-cli/wallet/test.go b/rocketpool-cli/wallet/test.go index 571c7be4b..fb0d72876 100644 --- a/rocketpool-cli/wallet/test.go +++ b/rocketpool-cli/wallet/test.go @@ -7,8 +7,8 @@ import ( "github.com/ethereum/go-ethereum/common" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - "github.com/rocket-pool/smartnode/shared/utils/cli/color" ) func testRecovery(mnemonic, addressFlag string, skipValidatorKeyRecovery bool, derivationPath string, walletIndex uint) error { diff --git a/rocketpool-cli/wallet/utils.go b/rocketpool-cli/wallet/utils.go index 9246461cf..b1c4734c5 100644 --- a/rocketpool-cli/wallet/utils.go +++ b/rocketpool-cli/wallet/utils.go @@ -12,13 +12,13 @@ import ( "gopkg.in/yaml.v2" "github.com/rocket-pool/smartnode/bindings/types" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" + promptcli "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/rocketpool-cli/wallet/bip39" "github.com/rocket-pool/smartnode/shared/services/config" "github.com/rocket-pool/smartnode/shared/services/passwords" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" - "github.com/rocket-pool/smartnode/shared/utils/cli/color" - promptcli "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" hexutils "github.com/rocket-pool/smartnode/shared/utils/hex" ) diff --git a/rocketpool/api/pdao/propose-settings.go b/rocketpool/api/pdao/propose-settings.go index 876a6bde3..d2593ae58 100644 --- a/rocketpool/api/pdao/propose-settings.go +++ b/rocketpool/api/pdao/propose-settings.go @@ -14,9 +14,9 @@ import ( "github.com/rocket-pool/smartnode/bindings/node" "github.com/rocket-pool/smartnode/bindings/settings/protocol" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/types/api" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" ) func canProposeSetting(c *cli.Command, contractName string, settingName string, value string) (*api.CanProposePDAOSettingResponse, error) { diff --git a/rocketpool/api/pdao/routes.go b/rocketpool/api/pdao/routes.go index 2ac2e9c55..57151516d 100644 --- a/rocketpool/api/pdao/routes.go +++ b/rocketpool/api/pdao/routes.go @@ -12,9 +12,9 @@ import ( "github.com/urfave/cli/v3" bindtypes "github.com/rocket-pool/smartnode/bindings/types" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" "github.com/rocket-pool/smartnode/rocketpool/api/response" "github.com/rocket-pool/smartnode/shared/services" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" ) // RegisterRoutes registers the pdao module's HTTP routes onto mux. diff --git a/rocketpool/api/security/propose-settings.go b/rocketpool/api/security/propose-settings.go index 6a19a14d7..fa93e48b3 100644 --- a/rocketpool/api/security/propose-settings.go +++ b/rocketpool/api/security/propose-settings.go @@ -9,9 +9,9 @@ import ( "github.com/rocket-pool/smartnode/bindings/settings/protocol" "github.com/rocket-pool/smartnode/bindings/settings/security" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/types/api" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" ) func canProposeSetting(c *cli.Command, contractName string, settingName string, value string) (*api.SecurityCanProposeSettingResponse, error) { diff --git a/rocketpool/api/upgrade/routes.go b/rocketpool/api/upgrade/routes.go index 1c94520d2..4a1e128e5 100644 --- a/rocketpool/api/upgrade/routes.go +++ b/rocketpool/api/upgrade/routes.go @@ -6,9 +6,9 @@ import ( "github.com/urfave/cli/v3" + cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" "github.com/rocket-pool/smartnode/rocketpool/api/response" "github.com/rocket-pool/smartnode/shared/services" - cliutils "github.com/rocket-pool/smartnode/shared/utils/cli" ) // RegisterRoutes registers the upgrade module's HTTP routes onto mux. diff --git a/shared/services/ec-manager.go b/shared/services/ec-manager.go index 760582dcf..ee328418d 100644 --- a/shared/services/ec-manager.go +++ b/shared/services/ec-manager.go @@ -15,10 +15,10 @@ import ( "github.com/fatih/color" "github.com/rocket-pool/smartnode/bindings/rocketpool" + clicolor "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" "github.com/rocket-pool/smartnode/shared/services/config" "github.com/rocket-pool/smartnode/shared/types/api" cfgtypes "github.com/rocket-pool/smartnode/shared/types/config" - clicolor "github.com/rocket-pool/smartnode/shared/utils/cli/color" "github.com/rocket-pool/smartnode/shared/utils/log" ) diff --git a/shared/services/gas/gas.go b/shared/services/gas/gas.go index f8b3ed694..fac5827b9 100644 --- a/shared/services/gas/gas.go +++ b/shared/services/gas/gas.go @@ -9,11 +9,11 @@ import ( "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/shared/services/config" "github.com/rocket-pool/smartnode/shared/services/gas/etherscan" rpsvc "github.com/rocket-pool/smartnode/shared/services/rocketpool" - "github.com/rocket-pool/smartnode/shared/utils/cli/color" - "github.com/rocket-pool/smartnode/shared/utils/cli/prompt" ) // DefaultPriorityFeeGwei is the default priority fee in gwei used for automatic transactions diff --git a/shared/services/rocketpool/client.go b/shared/services/rocketpool/client.go index df2e223b6..53502f009 100644 --- a/shared/services/rocketpool/client.go +++ b/shared/services/rocketpool/client.go @@ -29,12 +29,12 @@ import ( "github.com/mitchellh/go-homedir" "github.com/rocket-pool/smartnode/addons/graffiti_wall_writer" + clicolor "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" "github.com/rocket-pool/smartnode/shared/services/config" "github.com/rocket-pool/smartnode/shared/services/rocketpool/assets" "github.com/rocket-pool/smartnode/shared/services/rocketpool/template" "github.com/rocket-pool/smartnode/shared/types/api" cfgtypes "github.com/rocket-pool/smartnode/shared/types/config" - clicolor "github.com/rocket-pool/smartnode/shared/utils/cli/color" "github.com/rocket-pool/smartnode/shared/utils/rp" ) diff --git a/shared/services/rocketpool/gas.go b/shared/services/rocketpool/gas.go index 2a9086862..1d1855153 100644 --- a/shared/services/rocketpool/gas.go +++ b/shared/services/rocketpool/gas.go @@ -5,8 +5,8 @@ import ( "github.com/goccy/go-json" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" "github.com/rocket-pool/smartnode/shared/types/api" - "github.com/rocket-pool/smartnode/shared/utils/cli/color" ) // Print a warning about the gas estimate for operations that have multiple transactions diff --git a/shared/types/api/node.go b/shared/types/api/node.go index e09d2ca44..7055e4922 100644 --- a/shared/types/api/node.go +++ b/shared/types/api/node.go @@ -10,8 +10,8 @@ import ( "github.com/rocket-pool/smartnode/bindings/tokens" "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" rptypes "github.com/rocket-pool/smartnode/bindings/types" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" "github.com/rocket-pool/smartnode/shared/services/rewards" - "github.com/rocket-pool/smartnode/shared/utils/cli/color" "github.com/rocket-pool/smartnode/shared/utils/rp" ) diff --git a/treegen/main.go b/treegen/main.go index bbff0d4ac..4bf611980 100644 --- a/treegen/main.go +++ b/treegen/main.go @@ -10,7 +10,7 @@ import ( "github.com/felixge/fgprof" "github.com/urfave/cli/v3" - "github.com/rocket-pool/smartnode/shared/utils/cli/color" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" ) const ( From 27e203ea31253b877e91996cb1cc4e51bce9ec6d Mon Sep 17 00:00:00 2001 From: Jacob Shufro Date: Sat, 25 Jul 2026 14:28:19 -0400 Subject: [PATCH 04/12] Remove shared/utils/eth1 --- .../watchtower/submit-network-balances.go | 3 +- .../submit-rewards-tree-stateless.go | 3 +- rocketpool/watchtower/submit-rpl-price.go | 3 +- rocketpool/watchtower/utils/utils.go | 50 ++++++++++++++++ shared/utils/eth1/eth1.go | 60 ------------------- 5 files changed, 53 insertions(+), 66 deletions(-) delete mode 100644 shared/utils/eth1/eth1.go diff --git a/rocketpool/watchtower/submit-network-balances.go b/rocketpool/watchtower/submit-network-balances.go index 65225cad4..677d3e963 100644 --- a/rocketpool/watchtower/submit-network-balances.go +++ b/rocketpool/watchtower/submit-network-balances.go @@ -32,7 +32,6 @@ import ( rprewards "github.com/rocket-pool/smartnode/shared/services/rewards" "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" - "github.com/rocket-pool/smartnode/shared/utils/eth1" "github.com/rocket-pool/smartnode/shared/utils/log" ) @@ -432,7 +431,7 @@ func (t *submitNetworkBalances) printMessage(message string) { func (t *submitNetworkBalances) getNetworkBalances(elBlockHeader *types.Header, elBlock *big.Int, beaconBlock uint64, slotTime time.Time) (networkBalances, error) { // Get a client with the block number available - client, err := eth1.GetBestApiClient(t.rp, t.cfg, t.printMessage, elBlock) + client, err := utils.GetBestApiClient(t.rp, t.cfg, t.printMessage, elBlock) if err != nil { return networkBalances{}, err } diff --git a/rocketpool/watchtower/submit-rewards-tree-stateless.go b/rocketpool/watchtower/submit-rewards-tree-stateless.go index ad1c9c4f5..2c52f06d0 100644 --- a/rocketpool/watchtower/submit-rewards-tree-stateless.go +++ b/rocketpool/watchtower/submit-rewards-tree-stateless.go @@ -31,7 +31,6 @@ import ( "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" cfgtypes "github.com/rocket-pool/smartnode/shared/types/config" - "github.com/rocket-pool/smartnode/shared/utils/eth1" hexutil "github.com/rocket-pool/smartnode/shared/utils/hex" "github.com/rocket-pool/smartnode/shared/utils/log" ) @@ -291,7 +290,7 @@ func (t *submitRewardsTree_Stateless) generateTree(intervalsPassed time.Duration t.lock.Unlock() // Get an appropriate client - client, err := eth1.GetBestApiClient(t.rp, t.cfg, t.printMessage, snapshotElBlockHeader.Number) + client, err := utils.GetBestApiClient(t.rp, t.cfg, t.printMessage, snapshotElBlockHeader.Number) if err != nil { t.handleError(err) return diff --git a/rocketpool/watchtower/submit-rpl-price.go b/rocketpool/watchtower/submit-rpl-price.go index 4b1ab3b72..f17775610 100644 --- a/rocketpool/watchtower/submit-rpl-price.go +++ b/rocketpool/watchtower/submit-rpl-price.go @@ -33,7 +33,6 @@ import ( rpgas "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" - "github.com/rocket-pool/smartnode/shared/utils/eth1" "github.com/rocket-pool/smartnode/shared/utils/log" mathutils "github.com/rocket-pool/smartnode/shared/utils/math" ) @@ -601,7 +600,7 @@ func (t *submitRplPrice) getRplTwap(blockNumber uint64) (*big.Int, error) { } // Get a client with the block number available - client, err := eth1.GetBestApiClient(t.rp, t.cfg, t.printMessage, opts.BlockNumber) + client, err := utils.GetBestApiClient(t.rp, t.cfg, t.printMessage, opts.BlockNumber) if err != nil { return nil, err } diff --git a/rocketpool/watchtower/utils/utils.go b/rocketpool/watchtower/utils/utils.go index ebe055e87..de527c8b9 100644 --- a/rocketpool/watchtower/utils/utils.go +++ b/rocketpool/watchtower/utils/utils.go @@ -7,9 +7,13 @@ import ( "strconv" "time" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/config" ) @@ -119,3 +123,49 @@ func FindNextSubmissionTarget(rp *rocketpool.RocketPool, eth2Config beacon.Eth2C return targetSlot, targetSlotTime, targetBlockHeader, true, nil } + +// Determines if the primary EC can be used for historical queries, or if the Archive EC is required +func GetBestApiClient(primary *rocketpool.RocketPool, cfg *config.RocketPoolConfig, printMessage func(string), blockNumber *big.Int) (*rocketpool.RocketPool, error) { + + client := primary + + // Try getting the rETH address as a canary to see if the block is available + opts := &bind.CallOpts{ + BlockNumber: blockNumber, + } + address, err := client.RocketStorage.GetAddress(opts, crypto.Keccak256Hash([]byte("contract.addressrocketTokenRETH"))) + if err != nil { + errMessage := err.Error() + printMessage(fmt.Sprintf("Error getting state for block %d: %s", blockNumber.Uint64(), errMessage)) + // The state was missing so fall back to the archive node + archiveEcUrl := cfg.Smartnode.ArchiveECUrl.Value.(string) + if archiveEcUrl != "" { + printMessage(fmt.Sprintf("Primary EC cannot retrieve state for historical block %d, using archive EC [%s]", blockNumber.Uint64(), archiveEcUrl)) + ec, err := services.NewEthClient(archiveEcUrl) + if err != nil { + return nil, fmt.Errorf("Error connecting to archive EC: %w", err) + } + client, err = rocketpool.NewRocketPool(ec, common.HexToAddress(cfg.Smartnode.GetStorageAddress())) + if err != nil { + return nil, fmt.Errorf("Error creating Rocket Pool client connected to archive EC: %w", err) + } + + // Get the rETH address from the archive EC + address, err = client.RocketStorage.GetAddress(opts, crypto.Keccak256Hash([]byte("contract.addressrocketTokenRETH"))) + if err != nil { + return nil, fmt.Errorf("Error verifying rETH address with Archive EC: %w", err) + } + } else { + // No archive node specified + return nil, fmt.Errorf("***ERROR*** Primary EC cannot retrieve state for historical block %d and the Archive EC is not specified.", blockNumber.Uint64()) + } + } + + // Sanity check the rETH address to make sure the client is working right + if address != cfg.Smartnode.GetRethAddress() { + return nil, fmt.Errorf("***ERROR*** Your Primary EC provided %s as the rETH address, but it should have been %s!", address.Hex(), cfg.Smartnode.GetRethAddress().Hex()) + } + + return client, nil + +} diff --git a/shared/utils/eth1/eth1.go b/shared/utils/eth1/eth1.go deleted file mode 100644 index 84e381877..000000000 --- a/shared/utils/eth1/eth1.go +++ /dev/null @@ -1,60 +0,0 @@ -package eth1 - -import ( - "fmt" - "math/big" - - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" - - "github.com/rocket-pool/smartnode/bindings/rocketpool" - "github.com/rocket-pool/smartnode/shared/services" - "github.com/rocket-pool/smartnode/shared/services/config" -) - -// Determines if the primary EC can be used for historical queries, or if the Archive EC is required -func GetBestApiClient(primary *rocketpool.RocketPool, cfg *config.RocketPoolConfig, printMessage func(string), blockNumber *big.Int) (*rocketpool.RocketPool, error) { - - client := primary - - // Try getting the rETH address as a canary to see if the block is available - opts := &bind.CallOpts{ - BlockNumber: blockNumber, - } - address, err := client.RocketStorage.GetAddress(opts, crypto.Keccak256Hash([]byte("contract.addressrocketTokenRETH"))) - if err != nil { - errMessage := err.Error() - printMessage(fmt.Sprintf("Error getting state for block %d: %s", blockNumber.Uint64(), errMessage)) - // The state was missing so fall back to the archive node - archiveEcUrl := cfg.Smartnode.ArchiveECUrl.Value.(string) - if archiveEcUrl != "" { - printMessage(fmt.Sprintf("Primary EC cannot retrieve state for historical block %d, using archive EC [%s]", blockNumber.Uint64(), archiveEcUrl)) - ec, err := services.NewEthClient(archiveEcUrl) - if err != nil { - return nil, fmt.Errorf("Error connecting to archive EC: %w", err) - } - client, err = rocketpool.NewRocketPool(ec, common.HexToAddress(cfg.Smartnode.GetStorageAddress())) - if err != nil { - return nil, fmt.Errorf("Error creating Rocket Pool client connected to archive EC: %w", err) - } - - // Get the rETH address from the archive EC - address, err = client.RocketStorage.GetAddress(opts, crypto.Keccak256Hash([]byte("contract.addressrocketTokenRETH"))) - if err != nil { - return nil, fmt.Errorf("Error verifying rETH address with Archive EC: %w", err) - } - } else { - // No archive node specified - return nil, fmt.Errorf("***ERROR*** Primary EC cannot retrieve state for historical block %d and the Archive EC is not specified.", blockNumber.Uint64()) - } - } - - // Sanity check the rETH address to make sure the client is working right - if address != cfg.Smartnode.GetRethAddress() { - return nil, fmt.Errorf("***ERROR*** Your Primary EC provided %s as the rETH address, but it should have been %s!", address.Hex(), cfg.Smartnode.GetRethAddress().Hex()) - } - - return client, nil - -} From cc462db9f76974a7d6e7f30cc498f081b827fa75 Mon Sep 17 00:00:00 2001 From: Jacob Shufro Date: Sat, 25 Jul 2026 15:17:13 -0400 Subject: [PATCH 05/12] Remove shared/utils/eth2 --- bindings/utils/eth/units.go | 10 + rocketpool/api/debug/validators.go | 8 +- rocketpool/api/node/rewards.go | 142 +++++++++- rocketpool/node/collectors/node-collector.go | 29 +- .../services/beacon/client/std-http-client.go | 3 +- shared/services/beacon/config.go | 5 + shared/utils/eth2/eth2.go | 258 ------------------ 7 files changed, 169 insertions(+), 286 deletions(-) delete mode 100644 shared/utils/eth2/eth2.go diff --git a/bindings/utils/eth/units.go b/bindings/utils/eth/units.go index 4b5ec450f..bf86781a5 100644 --- a/bindings/utils/eth/units.go +++ b/bindings/utils/eth/units.go @@ -11,6 +11,7 @@ const ( WeiPerEth float64 = 1e18 WeiPerGwei float64 = 1e9 WeiPerMilliEth float64 = 1e15 + GweiPerEth float64 = 1e9 ) // Convert wei to eth @@ -61,6 +62,15 @@ func GweiToWei(gwei float64) *big.Int { return &wei } +func GweiToEth(gwei uint64) float64 { + var gweiFloat big.Float + var eth big.Float + gweiFloat.SetUint64(gwei) + eth.Quo(&gweiFloat, big.NewFloat(GweiPerEth)) + eth64, _ := eth.Float64() + return eth64 +} + // Convert milliEth to wei func MilliEthToWei(milliEth float64) *big.Int { var milliEthFloat big.Float diff --git a/rocketpool/api/debug/validators.go b/rocketpool/api/debug/validators.go index 923bf2766..9629339be 100644 --- a/rocketpool/api/debug/validators.go +++ b/rocketpool/api/debug/validators.go @@ -5,6 +5,7 @@ import ( "fmt" "math/big" "strings" + "time" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" @@ -17,7 +18,6 @@ import ( "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/beacon" - "github.com/rocket-pool/smartnode/shared/utils/eth2" "github.com/rocket-pool/smartnode/shared/utils/rp" ) @@ -47,7 +47,7 @@ func ExportValidators(c *cli.Command) error { var addresses []common.Address var eth2Config beacon.Eth2Config var beaconHead beacon.BeaconHead - var blockTime uint64 + var blockTime time.Time // Get minipool addresses wg1.Go(func() error { @@ -74,7 +74,7 @@ func ExportValidators(c *cli.Command) error { wg1.Go(func() error { header, err := ec.HeaderByNumber(context.Background(), opts.BlockNumber) if err == nil { - blockTime = header.Time + blockTime = time.Unix(int64(header.Time), 0) } return err }) @@ -85,7 +85,7 @@ func ExportValidators(c *cli.Command) error { } // Get & check epoch at block - blockEpoch := eth2.EpochAt(eth2Config, blockTime) + blockEpoch := eth2Config.EpochAt(blockTime) if blockEpoch > beaconHead.Epoch { return fmt.Errorf("Epoch %d at block %s is higher than current epoch %d", blockEpoch, opts.BlockNumber.String(), beaconHead.Epoch) } diff --git a/rocketpool/api/node/rewards.go b/rocketpool/api/node/rewards.go index 12c0851ac..c7e004e6e 100644 --- a/rocketpool/api/node/rewards.go +++ b/rocketpool/api/node/rewards.go @@ -6,13 +6,16 @@ import ( "math/big" "time" + "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/rocket-pool/smartnode/bindings/dao/trustednode" "github.com/rocket-pool/smartnode/bindings/minipool" "github.com/rocket-pool/smartnode/bindings/node" "github.com/rocket-pool/smartnode/bindings/rewards" + "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/tokens" + "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" rpstate "github.com/rocket-pool/smartnode/bindings/utils/state" @@ -23,9 +26,140 @@ import ( "github.com/rocket-pool/smartnode/shared/services/beacon" rprewards "github.com/rocket-pool/smartnode/shared/services/rewards" "github.com/rocket-pool/smartnode/shared/types/api" - "github.com/rocket-pool/smartnode/shared/utils/eth2" + rputils "github.com/rocket-pool/smartnode/shared/utils/rp" ) +// Settings +const minipoolBalanceDetailsBatchSize = 20 + +// Beacon chain balance info for a minipool +type minipoolBalanceDetails struct { + nodeDeposit *big.Int + nodeBalance *big.Int +} + +// Get the balances of the minipools on the beacon chain +func getBeaconBalances(rp *rocketpool.RocketPool, bc beacon.Client, addresses []common.Address, beaconHead beacon.BeaconHead, opts *bind.CallOpts) ([]minipoolBalanceDetails, error) { + + // Get minipool validator statuses + validators, err := rputils.GetMinipoolValidators(rp, bc, addresses, opts, &beacon.ValidatorStatusOptions{Epoch: &beaconHead.Epoch}) + if err != nil { + return []minipoolBalanceDetails{}, err + } + + // Load details in batches + details := make([]minipoolBalanceDetails, len(addresses)) + for bsi := 0; bsi < len(addresses); bsi += minipoolBalanceDetailsBatchSize { + + // Get batch start & end index + msi := bsi + mei := min(bsi+minipoolBalanceDetailsBatchSize, len(addresses)) + + // Load details + var wg errgroup.Group + for mi := msi; mi < mei; mi++ { + mi := mi + wg.Go(func() error { + address := addresses[mi] + validator := validators[address] + mpDetails, err := getMinipoolBalanceDetails(rp, address, opts, validator, beaconHead.Epoch) + if err == nil { + details[mi] = mpDetails + } + return err + }) + } + if err := wg.Wait(); err != nil { + return []minipoolBalanceDetails{}, err + } + + } + + // Return + return details, nil +} + +// Get minipool balance details +func getMinipoolBalanceDetails(rp *rocketpool.RocketPool, minipoolAddress common.Address, opts *bind.CallOpts, validator beacon.ValidatorStatus, blockEpoch uint64) (minipoolBalanceDetails, error) { + + // Create minipool + mp, err := minipool.NewMinipool(rp, minipoolAddress, opts) + if err != nil { + return minipoolBalanceDetails{}, err + } + blockBalance := eth.GweiToWei(float64(validator.Balance)) + + // Data + var wg errgroup.Group + var status types.MinipoolStatus + var nodeDepositBalance *big.Int + var finalized bool + + // Load data + wg.Go(func() error { + var err error + status, err = mp.GetStatus(opts) + return err + }) + wg.Go(func() error { + var err error + nodeDepositBalance, err = mp.GetNodeDepositBalance(opts) + return err + }) + wg.Go(func() error { + var err error + finalized, err = mp.GetFinalised(opts) + return err + }) + + // Wait for data + if err := wg.Wait(); err != nil { + return minipoolBalanceDetails{}, err + } + + // Deal with pools that haven't received deposits yet so their balance is still 0 + if nodeDepositBalance == nil { + nodeDepositBalance = big.NewInt(0) + } + + // Ignore finalized minipools + if finalized { + return minipoolBalanceDetails{ + nodeDeposit: big.NewInt(0), + nodeBalance: big.NewInt(0), + }, nil + } + + // Use node deposit balance if initialized or prelaunch + if status == types.Initialized || status == types.Prelaunch { + return minipoolBalanceDetails{ + nodeDeposit: nodeDepositBalance, + nodeBalance: nodeDepositBalance, + }, nil + } + + // Use node deposit balance if validator not yet active on beacon chain at block + if !validator.Exists || validator.ActivationEpoch >= blockEpoch { + return minipoolBalanceDetails{ + nodeDeposit: nodeDepositBalance, + nodeBalance: nodeDepositBalance, + }, nil + } + + // Get node balance at block + nodeBalance, err := mp.CalculateNodeShare(blockBalance, opts) + if err != nil { + return minipoolBalanceDetails{}, err + } + + // Return + return minipoolBalanceDetails{ + nodeDeposit: nodeDepositBalance, + nodeBalance: nodeBalance, + }, nil + +} + func getRewards(c *cli.Command) (*api.NodeRewardsResponse, error) { // Get services @@ -257,13 +391,13 @@ func getRewards(c *cli.Command) (*api.NodeRewardsResponse, error) { } // Calculate the total deposits and corresponding beacon chain balance share - minipoolDetails, err := eth2.GetBeaconBalances(rp, bc, addresses, beaconHead, nil) + minipoolDetails, err := getBeaconBalances(rp, bc, addresses, beaconHead, nil) if err != nil { return nil, err } for _, minipool := range minipoolDetails { - totalDepositBalance += eth.WeiToEth(minipool.NodeDeposit) - totalNodeShare += eth.WeiToEth(minipool.NodeBalance) + totalDepositBalance += eth.WeiToEth(minipool.nodeDeposit) + totalNodeShare += eth.WeiToEth(minipool.nodeBalance) } response.BeaconRewards = totalNodeShare - totalDepositBalance diff --git a/rocketpool/node/collectors/node-collector.go b/rocketpool/node/collectors/node-collector.go index 933eea62b..a72b33fd0 100644 --- a/rocketpool/node/collectors/node-collector.go +++ b/rocketpool/node/collectors/node-collector.go @@ -8,7 +8,6 @@ import ( "math/big" "time" - "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/prometheus/client_golang/prometheus" "golang.org/x/sync/errgroup" @@ -21,7 +20,6 @@ import ( "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/config" rprewards "github.com/rocket-pool/smartnode/shared/services/rewards" - "github.com/rocket-pool/smartnode/shared/utils/eth2" ) // Represents the collector for the user's node @@ -57,7 +55,7 @@ type NodeCollector struct { depositedEth *prometheus.Desc // The node's total share of its minipool's beacon chain balances - minipoolbeaconShare *prometheus.Desc + minipoolBeaconShare *prometheus.Desc // The total balances of all this node's validators on the beacon chain minipoolBeaconBalance *prometheus.Desc @@ -229,7 +227,7 @@ func NewNodeCollector(rp *rocketpool.RocketPool, bc *services.BeaconClientManage "The amount of ETH this node deposited into minipools", nil, nil, ), - minipoolbeaconShare: prometheus.NewDesc(prometheus.BuildFQName(namespace, subsystem, "beacon_share"), + minipoolBeaconShare: prometheus.NewDesc(prometheus.BuildFQName(namespace, subsystem, "beacon_share"), "The node's total share of its minipool's beacon chain balances", nil, nil, ), @@ -374,7 +372,7 @@ func (collector *NodeCollector) Describe(channel chan<- *prometheus.Desc) { channel <- collector.activeMinipoolCount channel <- collector.depositedEth channel <- collector.minipoolBeaconBalance - channel <- collector.minipoolbeaconShare + channel <- collector.minipoolBeaconShare channel <- collector.clientSyncProgress channel <- collector.minipoolBalance channel <- collector.minipoolShare @@ -791,21 +789,16 @@ func (collector *NodeCollector) Collect(channel chan<- prometheus.Metric) { } // Calculate the total deposits and corresponding beacon chain balance share - opts := &bind.CallOpts{ - BlockNumber: big.NewInt(0).SetUint64(state.ElBlockNumber), - } - minipoolDetails, err := eth2.GetBeaconBalancesFromState(collector.rp, minipools, state, beaconHead, opts) - if err != nil { - collector.logError(err) - return - } totalDepositBalance := float64(0) totalNodeShare := float64(0) totalBeaconBalance := float64(0) - for _, minipool := range minipoolDetails { - totalDepositBalance += eth.WeiToEth(minipool.NodeDeposit) - totalNodeShare += eth.WeiToEth(minipool.NodeBalance) - totalBeaconBalance += eth.WeiToEth(minipool.TotalBalance) + for _, minipool := range minipools { + validator, exists := state.MinipoolValidatorDetails[minipool.Pubkey] + if exists { + totalBeaconBalance += eth.GweiToEth(validator.Balance) + } + totalDepositBalance += eth.WeiToEth(minipool.NodeDepositBalance) + totalNodeShare += eth.WeiToEth(minipool.NodeShareOfBeaconBalance) } totalMinipoolBalance := float64(0) @@ -864,7 +857,7 @@ func (collector *NodeCollector) Collect(channel chan<- prometheus.Metric) { channel <- prometheus.MustNewConstMetric( collector.depositedEth, prometheus.GaugeValue, totalDepositBalance) channel <- prometheus.MustNewConstMetric( - collector.minipoolbeaconShare, prometheus.GaugeValue, totalNodeShare) + collector.minipoolBeaconShare, prometheus.GaugeValue, totalNodeShare) channel <- prometheus.MustNewConstMetric( collector.minipoolBeaconBalance, prometheus.GaugeValue, totalBeaconBalance) channel <- prometheus.MustNewConstMetric( diff --git a/shared/services/beacon/client/std-http-client.go b/shared/services/beacon/client/std-http-client.go index 7380e9809..f21bde572 100644 --- a/shared/services/beacon/client/std-http-client.go +++ b/shared/services/beacon/client/std-http-client.go @@ -24,7 +24,6 @@ import ( "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/shared/services/beacon" - "github.com/rocket-pool/smartnode/shared/utils/eth2" hexutil "github.com/rocket-pool/smartnode/shared/utils/hex" ) @@ -197,7 +196,7 @@ func (c *StandardHttpClient) GetBeaconHead() (beacon.BeaconHead, error) { // Return response return beacon.BeaconHead{ - Epoch: eth2.EpochAt(eth2Config, uint64(time.Now().Unix())), + Epoch: eth2Config.EpochAt(time.Now()), FinalizedEpoch: uint64(finalityCheckpoints.Data.Finalized.Epoch), JustifiedEpoch: uint64(finalityCheckpoints.Data.CurrentJustified.Epoch), PreviousJustifiedEpoch: uint64(finalityCheckpoints.Data.PreviousJustified.Epoch), diff --git a/shared/services/beacon/config.go b/shared/services/beacon/config.go index fd0299fa5..ad96d0d23 100644 --- a/shared/services/beacon/config.go +++ b/shared/services/beacon/config.go @@ -102,6 +102,11 @@ func (c *Eth2Config) EpochToSlot(epoch uint64) uint64 { return epoch * c.SlotsPerEpoch } +func (c *Eth2Config) EpochAt(time time.Time) uint64 { + ts := uint64(time.Unix()) + return c.GenesisEpoch + (ts-c.GenesisTime)/c.SecondsPerEpoch +} + func (c *Eth2Config) SlotOfEpoch(epoch uint64, slot uint64) (uint64, error) { if slot > c.SlotsPerEpoch-1 { return 0, fmt.Errorf("slot %d is not in range 0 - %d", slot, c.SlotsPerEpoch-1) diff --git a/shared/utils/eth2/eth2.go b/shared/utils/eth2/eth2.go deleted file mode 100644 index 4accbaad9..000000000 --- a/shared/utils/eth2/eth2.go +++ /dev/null @@ -1,258 +0,0 @@ -package eth2 - -import ( - "math/big" - - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - "golang.org/x/sync/errgroup" - - "github.com/rocket-pool/smartnode/bindings/minipool" - "github.com/rocket-pool/smartnode/bindings/rocketpool" - "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" - rpstate "github.com/rocket-pool/smartnode/bindings/utils/state" - "github.com/rocket-pool/smartnode/shared/services/beacon" - "github.com/rocket-pool/smartnode/shared/services/state" - rputils "github.com/rocket-pool/smartnode/shared/utils/rp" -) - -// Settings -const MinipoolBalanceDetailsBatchSize = 20 - -// Beacon chain balance info for a minipool -type MinipoolBalanceDetails struct { - IsStaking bool - NodeDeposit *big.Int - NodeBalance *big.Int - TotalBalance *big.Int -} - -// Get an eth2 epoch number by time -func EpochAt(config beacon.Eth2Config, time uint64) uint64 { - return config.GenesisEpoch + (time-config.GenesisTime)/config.SecondsPerEpoch -} - -// Get the balances of the minipools on the beacon chain -func GetBeaconBalances(rp *rocketpool.RocketPool, bc beacon.Client, addresses []common.Address, beaconHead beacon.BeaconHead, opts *bind.CallOpts) ([]MinipoolBalanceDetails, error) { - - // Get minipool validator statuses - validators, err := rputils.GetMinipoolValidators(rp, bc, addresses, opts, &beacon.ValidatorStatusOptions{Epoch: &beaconHead.Epoch}) - if err != nil { - return []MinipoolBalanceDetails{}, err - } - - // Load details in batches - details := make([]MinipoolBalanceDetails, len(addresses)) - for bsi := 0; bsi < len(addresses); bsi += MinipoolBalanceDetailsBatchSize { - - // Get batch start & end index - msi := bsi - mei := min(bsi+MinipoolBalanceDetailsBatchSize, len(addresses)) - - // Load details - var wg errgroup.Group - for mi := msi; mi < mei; mi++ { - mi := mi - wg.Go(func() error { - address := addresses[mi] - validator := validators[address] - mpDetails, err := getMinipoolBalanceDetails(rp, address, opts, validator, beaconHead.Epoch) - if err == nil { - details[mi] = mpDetails - } - return err - }) - } - if err := wg.Wait(); err != nil { - return []MinipoolBalanceDetails{}, err - } - - } - - // Return - return details, nil -} - -// Get the balances of the minipools on the beacon chain -func GetBeaconBalancesFromState(rp *rocketpool.RocketPool, mpds []*rpstate.NativeMinipoolDetails, state *state.NetworkState, beaconHead beacon.BeaconHead, opts *bind.CallOpts) ([]MinipoolBalanceDetails, error) { - - // Load details in batches - details := make([]MinipoolBalanceDetails, len(mpds)) - for bsi := 0; bsi < len(mpds); bsi += MinipoolBalanceDetailsBatchSize { - - // Get batch start & end index - msi := bsi - mei := min(bsi+MinipoolBalanceDetailsBatchSize, len(mpds)) - - // Load details - var wg errgroup.Group - for mi := msi; mi < mei; mi++ { - mi := mi - wg.Go(func() error { - mpDetails, err := getMinipoolBalanceDetailsFromState(rp, mpds[mi], state, opts, beaconHead.Epoch) - if err == nil { - details[mi] = mpDetails - } - return err - }) - } - if err := wg.Wait(); err != nil { - return []MinipoolBalanceDetails{}, err - } - - } - - // Return - return details, nil -} - -// Get minipool balance details -func getMinipoolBalanceDetails(rp *rocketpool.RocketPool, minipoolAddress common.Address, opts *bind.CallOpts, validator beacon.ValidatorStatus, blockEpoch uint64) (MinipoolBalanceDetails, error) { - - // Create minipool - mp, err := minipool.NewMinipool(rp, minipoolAddress, opts) - if err != nil { - return MinipoolBalanceDetails{}, err - } - blockBalance := eth.GweiToWei(float64(validator.Balance)) - - // Data - var wg errgroup.Group - var status types.MinipoolStatus - var nodeDepositBalance *big.Int - var finalized bool - - // Load data - wg.Go(func() error { - var err error - status, err = mp.GetStatus(opts) - return err - }) - wg.Go(func() error { - var err error - nodeDepositBalance, err = mp.GetNodeDepositBalance(opts) - return err - }) - wg.Go(func() error { - var err error - finalized, err = mp.GetFinalised(opts) - return err - }) - - // Wait for data - if err := wg.Wait(); err != nil { - return MinipoolBalanceDetails{}, err - } - - // Deal with pools that haven't received deposits yet so their balance is still 0 - if nodeDepositBalance == nil { - nodeDepositBalance = big.NewInt(0) - } - - // Ignore finalized minipools - if finalized { - return MinipoolBalanceDetails{ - NodeDeposit: big.NewInt(0), - NodeBalance: big.NewInt(0), - TotalBalance: big.NewInt(0), - }, nil - } - - // Use node deposit balance if initialized or prelaunch - if status == types.Initialized || status == types.Prelaunch { - return MinipoolBalanceDetails{ - NodeDeposit: nodeDepositBalance, - NodeBalance: nodeDepositBalance, - TotalBalance: blockBalance, - }, nil - } - - // Use node deposit balance if validator not yet active on beacon chain at block - if !validator.Exists || validator.ActivationEpoch >= blockEpoch { - return MinipoolBalanceDetails{ - NodeDeposit: nodeDepositBalance, - NodeBalance: nodeDepositBalance, - TotalBalance: blockBalance, - }, nil - } - - // Get node balance at block - nodeBalance, err := mp.CalculateNodeShare(blockBalance, opts) - if err != nil { - return MinipoolBalanceDetails{}, err - } - - // Return - return MinipoolBalanceDetails{ - IsStaking: (validator.ExitEpoch > blockEpoch), - NodeDeposit: nodeDepositBalance, - NodeBalance: nodeBalance, - TotalBalance: blockBalance, - }, nil - -} - -// Get minipool balance details -func getMinipoolBalanceDetailsFromState(rp *rocketpool.RocketPool, mpd *rpstate.NativeMinipoolDetails, state *state.NetworkState, opts *bind.CallOpts, blockEpoch uint64) (MinipoolBalanceDetails, error) { - - // Create minipool - mp, err := minipool.NewMinipoolFromVersion(rp, mpd.MinipoolAddress, mpd.Version, opts) - if err != nil { - return MinipoolBalanceDetails{}, err - } - validator := state.MinipoolValidatorDetails[mpd.Pubkey] - blockBalance := eth.GweiToWei(float64(validator.Balance)) - - // Data - status := mpd.Status - nodeDepositBalance := mpd.NodeDepositBalance - finalized := mpd.Finalised - - // Deal with pools that haven't received deposits yet so their balance is still 0 - if nodeDepositBalance == nil { - nodeDepositBalance = big.NewInt(0) - } - - // Ignore finalized minipools - if finalized { - return MinipoolBalanceDetails{ - NodeDeposit: big.NewInt(0), - NodeBalance: big.NewInt(0), - TotalBalance: big.NewInt(0), - }, nil - } - - // Use node deposit balance if initialized or prelaunch - if status == types.Initialized || status == types.Prelaunch { - return MinipoolBalanceDetails{ - NodeDeposit: nodeDepositBalance, - NodeBalance: nodeDepositBalance, - TotalBalance: blockBalance, - }, nil - } - - // Use node deposit balance if validator not yet active on beacon chain at block - if !validator.Exists || validator.ActivationEpoch >= blockEpoch { - return MinipoolBalanceDetails{ - NodeDeposit: nodeDepositBalance, - NodeBalance: nodeDepositBalance, - TotalBalance: blockBalance, - }, nil - } - - // Get node balance at block - nodeBalance, err := mp.CalculateNodeShare(blockBalance, opts) - if err != nil { - return MinipoolBalanceDetails{}, err - } - - // Return - return MinipoolBalanceDetails{ - IsStaking: (validator.ExitEpoch > blockEpoch), - NodeDeposit: nodeDepositBalance, - NodeBalance: nodeBalance, - TotalBalance: blockBalance, - }, nil - -} From 59833e88259f359801bfc952cbc9549ac4244fad Mon Sep 17 00:00:00 2001 From: Jacob Shufro Date: Sat, 25 Jul 2026 15:22:17 -0400 Subject: [PATCH 06/12] Remove shared/utils/hex --- rocketpool-cli/cli/validation.go | 2 +- rocketpool-cli/minipool/status.go | 2 +- rocketpool-cli/wallet/utils.go | 2 +- rocketpool/api/minipool/vanity.go | 2 +- rocketpool/api/node/sign-message.go | 2 +- rocketpool/api/node/sign.go | 2 +- rocketpool/api/wallet/recover.go | 2 +- rocketpool/watchtower/submit-rewards-tree-stateless.go | 2 +- shared/{utils => }/hex/hex.go | 10 +++++----- shared/services/beacon/client/std-http-client.go | 2 +- shared/services/beacon/client/types.go | 2 +- shared/services/wallet/keystore/lighthouse/keystore.go | 2 +- shared/services/wallet/keystore/lodestar/keystore.go | 2 +- shared/services/wallet/keystore/nimbus/keystore.go | 2 +- shared/services/wallet/keystore/teku/keystore.go | 2 +- shared/types/eth2/proofs_test.go | 2 +- 16 files changed, 20 insertions(+), 20 deletions(-) rename shared/{utils => }/hex/hex.go (78%) diff --git a/rocketpool-cli/cli/validation.go b/rocketpool-cli/cli/validation.go index 678e981b9..b350c4885 100644 --- a/rocketpool-cli/cli/validation.go +++ b/rocketpool-cli/cli/validation.go @@ -16,8 +16,8 @@ import ( "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" + hexutils "github.com/rocket-pool/smartnode/shared/hex" "github.com/rocket-pool/smartnode/shared/services/passwords" - hexutils "github.com/rocket-pool/smartnode/shared/utils/hex" ) // Config diff --git a/rocketpool-cli/minipool/status.go b/rocketpool-cli/minipool/status.go index 1b69144c0..d63c28d82 100644 --- a/rocketpool-cli/minipool/status.go +++ b/rocketpool-cli/minipool/status.go @@ -11,9 +11,9 @@ import ( cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" + "github.com/rocket-pool/smartnode/shared/hex" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" - "github.com/rocket-pool/smartnode/shared/utils/hex" "github.com/rocket-pool/smartnode/shared/utils/math" ) diff --git a/rocketpool-cli/wallet/utils.go b/rocketpool-cli/wallet/utils.go index b1c4734c5..e77edfb3f 100644 --- a/rocketpool-cli/wallet/utils.go +++ b/rocketpool-cli/wallet/utils.go @@ -15,11 +15,11 @@ import ( "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" promptcli "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" "github.com/rocket-pool/smartnode/rocketpool-cli/wallet/bip39" + hexutils "github.com/rocket-pool/smartnode/shared/hex" "github.com/rocket-pool/smartnode/shared/services/config" "github.com/rocket-pool/smartnode/shared/services/passwords" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" - hexutils "github.com/rocket-pool/smartnode/shared/utils/hex" ) // Prompt for a wallet password diff --git a/rocketpool/api/minipool/vanity.go b/rocketpool/api/minipool/vanity.go index 8a1ca131b..ca1c637c9 100644 --- a/rocketpool/api/minipool/vanity.go +++ b/rocketpool/api/minipool/vanity.go @@ -9,9 +9,9 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/urfave/cli/v3" + hexutils "github.com/rocket-pool/smartnode/shared/hex" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/types/api" - hexutils "github.com/rocket-pool/smartnode/shared/utils/hex" ) const ( diff --git a/rocketpool/api/node/sign-message.go b/rocketpool/api/node/sign-message.go index 0e2dc2bf5..9404bcd29 100644 --- a/rocketpool/api/node/sign-message.go +++ b/rocketpool/api/node/sign-message.go @@ -6,9 +6,9 @@ import ( "github.com/urfave/cli/v3" + hexutils "github.com/rocket-pool/smartnode/shared/hex" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/types/api" - hexutils "github.com/rocket-pool/smartnode/shared/utils/hex" ) func signMessage(c *cli.Command, message string) (*api.NodeSignResponse, error) { diff --git a/rocketpool/api/node/sign.go b/rocketpool/api/node/sign.go index 043db404c..265c16590 100644 --- a/rocketpool/api/node/sign.go +++ b/rocketpool/api/node/sign.go @@ -7,9 +7,9 @@ import ( "github.com/urfave/cli/v3" + hexutils "github.com/rocket-pool/smartnode/shared/hex" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/types/api" - hexutils "github.com/rocket-pool/smartnode/shared/utils/hex" ) func sign(c *cli.Command, serializedTx string) (*api.NodeSignResponse, error) { diff --git a/rocketpool/api/wallet/recover.go b/rocketpool/api/wallet/recover.go index 5bdb44693..cc8899ea9 100644 --- a/rocketpool/api/wallet/recover.go +++ b/rocketpool/api/wallet/recover.go @@ -20,12 +20,12 @@ import ( "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/types" + hexutils "github.com/rocket-pool/smartnode/shared/hex" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/config" "github.com/rocket-pool/smartnode/shared/services/wallet" "github.com/rocket-pool/smartnode/shared/types/api" - hexutils "github.com/rocket-pool/smartnode/shared/utils/hex" ) const ( diff --git a/rocketpool/watchtower/submit-rewards-tree-stateless.go b/rocketpool/watchtower/submit-rewards-tree-stateless.go index 2c52f06d0..96f421c1b 100644 --- a/rocketpool/watchtower/submit-rewards-tree-stateless.go +++ b/rocketpool/watchtower/submit-rewards-tree-stateless.go @@ -24,6 +24,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/rocketpool/watchtower/utils" + hexutil "github.com/rocket-pool/smartnode/shared/hex" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/config" @@ -31,7 +32,6 @@ import ( "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" cfgtypes "github.com/rocket-pool/smartnode/shared/types/config" - hexutil "github.com/rocket-pool/smartnode/shared/utils/hex" "github.com/rocket-pool/smartnode/shared/utils/log" ) diff --git a/shared/utils/hex/hex.go b/shared/hex/hex.go similarity index 78% rename from shared/utils/hex/hex.go rename to shared/hex/hex.go index f74308a23..a79abcdc1 100644 --- a/shared/utils/hex/hex.go +++ b/shared/hex/hex.go @@ -1,6 +1,9 @@ package hex -import "encoding/hex" +import ( + "encoding/hex" + "strings" +) func EncodeToString(value []byte) string { return AddPrefix(hex.EncodeToString(value)) @@ -16,8 +19,5 @@ func AddPrefix(value string) string { // Remove a prefix from a hex string if present func RemovePrefix(value string) string { - if len(value) >= 2 && value[0:2] == "0x" { - return value[2:] - } - return value + return strings.TrimPrefix(value, "0x") } diff --git a/shared/services/beacon/client/std-http-client.go b/shared/services/beacon/client/std-http-client.go index f21bde572..29ffd0781 100644 --- a/shared/services/beacon/client/std-http-client.go +++ b/shared/services/beacon/client/std-http-client.go @@ -23,8 +23,8 @@ import ( "github.com/rocket-pool/smartnode/bindings/types" + hexutil "github.com/rocket-pool/smartnode/shared/hex" "github.com/rocket-pool/smartnode/shared/services/beacon" - hexutil "github.com/rocket-pool/smartnode/shared/utils/hex" ) // Config diff --git a/shared/services/beacon/client/types.go b/shared/services/beacon/client/types.go index 8a99c7b7d..9347a0a54 100644 --- a/shared/services/beacon/client/types.go +++ b/shared/services/beacon/client/types.go @@ -7,7 +7,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/goccy/go-json" - hexutil "github.com/rocket-pool/smartnode/shared/utils/hex" + hexutil "github.com/rocket-pool/smartnode/shared/hex" ) // Request types diff --git a/shared/services/wallet/keystore/lighthouse/keystore.go b/shared/services/wallet/keystore/lighthouse/keystore.go index f0602a0eb..9321fc680 100644 --- a/shared/services/wallet/keystore/lighthouse/keystore.go +++ b/shared/services/wallet/keystore/lighthouse/keystore.go @@ -12,9 +12,9 @@ import ( "github.com/rocket-pool/smartnode/bindings/types" + hexutil "github.com/rocket-pool/smartnode/shared/hex" "github.com/rocket-pool/smartnode/shared/services/passwords" keystore "github.com/rocket-pool/smartnode/shared/services/wallet/keystore" - hexutil "github.com/rocket-pool/smartnode/shared/utils/hex" ) // Config diff --git a/shared/services/wallet/keystore/lodestar/keystore.go b/shared/services/wallet/keystore/lodestar/keystore.go index f8729ea81..7e6cd59de 100644 --- a/shared/services/wallet/keystore/lodestar/keystore.go +++ b/shared/services/wallet/keystore/lodestar/keystore.go @@ -12,9 +12,9 @@ import ( "github.com/rocket-pool/smartnode/bindings/types" + hexutil "github.com/rocket-pool/smartnode/shared/hex" "github.com/rocket-pool/smartnode/shared/services/passwords" keystore "github.com/rocket-pool/smartnode/shared/services/wallet/keystore" - hexutil "github.com/rocket-pool/smartnode/shared/utils/hex" ) // Config diff --git a/shared/services/wallet/keystore/nimbus/keystore.go b/shared/services/wallet/keystore/nimbus/keystore.go index 76ea19d9a..b9a3283ee 100644 --- a/shared/services/wallet/keystore/nimbus/keystore.go +++ b/shared/services/wallet/keystore/nimbus/keystore.go @@ -12,9 +12,9 @@ import ( "github.com/rocket-pool/smartnode/bindings/types" + hexutil "github.com/rocket-pool/smartnode/shared/hex" "github.com/rocket-pool/smartnode/shared/services/passwords" keystore "github.com/rocket-pool/smartnode/shared/services/wallet/keystore" - hexutil "github.com/rocket-pool/smartnode/shared/utils/hex" ) // Config diff --git a/shared/services/wallet/keystore/teku/keystore.go b/shared/services/wallet/keystore/teku/keystore.go index 23516edf9..ad88473c0 100644 --- a/shared/services/wallet/keystore/teku/keystore.go +++ b/shared/services/wallet/keystore/teku/keystore.go @@ -12,9 +12,9 @@ import ( "github.com/rocket-pool/smartnode/bindings/types" + hexutil "github.com/rocket-pool/smartnode/shared/hex" "github.com/rocket-pool/smartnode/shared/services/passwords" keystore "github.com/rocket-pool/smartnode/shared/services/wallet/keystore" - hexutil "github.com/rocket-pool/smartnode/shared/utils/hex" ) // Config diff --git a/shared/types/eth2/proofs_test.go b/shared/types/eth2/proofs_test.go index 085cfe342..a334f7611 100644 --- a/shared/types/eth2/proofs_test.go +++ b/shared/types/eth2/proofs_test.go @@ -15,9 +15,9 @@ import ( _ "embed" "testing" + hexutils "github.com/rocket-pool/smartnode/shared/hex" "github.com/rocket-pool/smartnode/shared/types/eth2/fork/deneb" "github.com/rocket-pool/smartnode/shared/types/eth2/generic" - hexutils "github.com/rocket-pool/smartnode/shared/utils/hex" ) // Test state - deneb fork. Hoodi genesis state. From 549deadf43a79d134174de77481a0fcc2f5618be Mon Sep 17 00:00:00 2001 From: Jacob Shufro Date: Sat, 25 Jul 2026 15:28:42 -0400 Subject: [PATCH 07/12] Remove shared/utils/log --- bindings/transactions/gaslimit/gas.go | 2 +- bindings/transactions/transactions.go | 2 +- rocketpool/node/defend-challenge-exit.go | 2 +- rocketpool/node/defend-pdao-props.go | 2 +- rocketpool/node/distribute-minipools.go | 2 +- rocketpool/node/download-reward-trees.go | 2 +- rocketpool/node/manage-fee-recipient.go | 2 +- rocketpool/node/metrics-exporter.go | 2 +- rocketpool/node/node.go | 2 +- rocketpool/node/notify-final-balance.go | 2 +- rocketpool/node/notify-validator-exit.go | 2 +- rocketpool/node/prestake-megapool-validator.go | 2 +- rocketpool/node/provision-express-tickets.go | 2 +- rocketpool/node/set-latest-delegate.go | 2 +- rocketpool/node/stake-megapool-validator.go | 2 +- rocketpool/node/verify-pdao-props-state_test.go | 2 +- rocketpool/node/verify-pdao-props.go | 2 +- rocketpool/watchtower/challenge-exit.go | 2 +- rocketpool/watchtower/check-solo-migrations.go | 2 +- rocketpool/watchtower/dissolve-invalid-credentials.go | 2 +- rocketpool/watchtower/dissolve-timed-out-megapool-validators.go | 2 +- rocketpool/watchtower/dissolve-timed-out-minipools.go | 2 +- rocketpool/watchtower/finalize-pdao-proposals.go | 2 +- rocketpool/watchtower/generate-rewards-tree.go | 2 +- rocketpool/watchtower/metrics-exporter.go | 2 +- rocketpool/watchtower/respond-challenges.go | 2 +- rocketpool/watchtower/submit-network-balances-state_test.go | 2 +- rocketpool/watchtower/submit-network-balances.go | 2 +- rocketpool/watchtower/submit-rewards-tree-stateless.go | 2 +- rocketpool/watchtower/submit-rpl-price.go | 2 +- rocketpool/watchtower/submit-scrub-minipools.go | 2 +- rocketpool/watchtower/watchtower.go | 2 +- shared/{utils/log => logger}/logger.go | 0 shared/services/bc-manager.go | 2 +- shared/services/connectivity/check-port-connectivity.go | 2 +- shared/services/connectivity/check-port-connectivity_test.go | 2 +- shared/services/ec-manager.go | 2 +- shared/services/proposals/network-tree-manager.go | 2 +- shared/services/proposals/node-tree-manager.go | 2 +- shared/services/proposals/proposal-manager.go | 2 +- shared/services/proposals/vi-snapshot-manager.go | 2 +- shared/services/rewards/generator-impl-v11.go | 2 +- shared/services/rewards/generator-impl-v9-v10.go | 2 +- shared/services/rewards/generator.go | 2 +- shared/services/rewards/mock_v11_test.go | 2 +- shared/services/state/manager.go | 2 +- shared/utils/validator/fee-recipient.go | 2 +- treegen/tree-gen.go | 2 +- 48 files changed, 47 insertions(+), 47 deletions(-) rename shared/{utils/log => logger}/logger.go (100%) diff --git a/bindings/transactions/gaslimit/gas.go b/bindings/transactions/gaslimit/gas.go index 6490b7ee9..1cc29c646 100644 --- a/bindings/transactions/gaslimit/gas.go +++ b/bindings/transactions/gaslimit/gas.go @@ -4,7 +4,7 @@ import ( "math/big" "github.com/rocket-pool/smartnode/bindings/utils/eth" - "github.com/rocket-pool/smartnode/shared/utils/log" + log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/utils/math" ) diff --git a/bindings/transactions/transactions.go b/bindings/transactions/transactions.go index ad494673c..520b4e58b 100644 --- a/bindings/transactions/transactions.go +++ b/bindings/transactions/transactions.go @@ -15,8 +15,8 @@ import ( "github.com/rocket-pool/smartnode/bindings/settings/protocol" "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/utils" + log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services/config" - "github.com/rocket-pool/smartnode/shared/utils/log" ) // The fraction of the timeout period to trigger overdue transactions diff --git a/rocketpool/node/defend-challenge-exit.go b/rocketpool/node/defend-challenge-exit.go index 556c63c57..a79179378 100644 --- a/rocketpool/node/defend-challenge-exit.go +++ b/rocketpool/node/defend-challenge-exit.go @@ -15,13 +15,13 @@ import ( "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" + log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/config" rpgas "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" - "github.com/rocket-pool/smartnode/shared/utils/log" ) // Stake megapool validator task diff --git a/rocketpool/node/defend-pdao-props.go b/rocketpool/node/defend-pdao-props.go index a61569b7f..1db5278de 100644 --- a/rocketpool/node/defend-pdao-props.go +++ b/rocketpool/node/defend-pdao-props.go @@ -14,6 +14,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/transactions" "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" + log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/config" @@ -21,7 +22,6 @@ import ( "github.com/rocket-pool/smartnode/shared/services/proposals" "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" - "github.com/rocket-pool/smartnode/shared/utils/log" ) type defendableProposal struct { diff --git a/rocketpool/node/distribute-minipools.go b/rocketpool/node/distribute-minipools.go index e6caad350..79b1cc22d 100644 --- a/rocketpool/node/distribute-minipools.go +++ b/rocketpool/node/distribute-minipools.go @@ -16,6 +16,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/utils/eth" rpstate "github.com/rocket-pool/smartnode/bindings/utils/state" + log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/alerting" "github.com/rocket-pool/smartnode/shared/services/beacon" @@ -23,7 +24,6 @@ import ( rpgas "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" - "github.com/rocket-pool/smartnode/shared/utils/log" ) // Distribute minipools task diff --git a/rocketpool/node/download-reward-trees.go b/rocketpool/node/download-reward-trees.go index 837dbb97b..4970c44ec 100644 --- a/rocketpool/node/download-reward-trees.go +++ b/rocketpool/node/download-reward-trees.go @@ -9,6 +9,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/rocketpool" + log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/config" @@ -16,7 +17,6 @@ import ( "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" cfgtypes "github.com/rocket-pool/smartnode/shared/types/config" - "github.com/rocket-pool/smartnode/shared/utils/log" ) // Manage download rewards trees task diff --git a/rocketpool/node/manage-fee-recipient.go b/rocketpool/node/manage-fee-recipient.go index 8347bcdaa..1bc1a410b 100644 --- a/rocketpool/node/manage-fee-recipient.go +++ b/rocketpool/node/manage-fee-recipient.go @@ -9,6 +9,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/rocketpool" + log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/alerting" "github.com/rocket-pool/smartnode/shared/services/beacon" @@ -16,7 +17,6 @@ import ( rpsvc "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" - "github.com/rocket-pool/smartnode/shared/utils/log" rputils "github.com/rocket-pool/smartnode/shared/utils/rp" "github.com/rocket-pool/smartnode/shared/utils/validator" ) diff --git a/rocketpool/node/metrics-exporter.go b/rocketpool/node/metrics-exporter.go index 13783c12d..19a63412f 100644 --- a/rocketpool/node/metrics-exporter.go +++ b/rocketpool/node/metrics-exporter.go @@ -14,8 +14,8 @@ import ( "github.com/urfave/cli/v3" "github.com/rocket-pool/smartnode/rocketpool/node/collectors" + log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services" - "github.com/rocket-pool/smartnode/shared/utils/log" ) func runMetricsServer(ctx context.Context, c *cli.Command, logger log.ColorLogger, stateLocker *collectors.StateLocker) error { diff --git a/rocketpool/node/node.go b/rocketpool/node/node.go index 2fa154d21..71bb8c20f 100644 --- a/rocketpool/node/node.go +++ b/rocketpool/node/node.go @@ -18,6 +18,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/utils" "github.com/rocket-pool/smartnode/rocketpool/node/collectors" + log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/alerting" "github.com/rocket-pool/smartnode/shared/services/connectivity" @@ -27,7 +28,6 @@ import ( "github.com/rocket-pool/smartnode/shared/services/wallet/keystore/nimbus" "github.com/rocket-pool/smartnode/shared/services/wallet/keystore/prysm" "github.com/rocket-pool/smartnode/shared/services/wallet/keystore/teku" - "github.com/rocket-pool/smartnode/shared/utils/log" ) // Config diff --git a/rocketpool/node/notify-final-balance.go b/rocketpool/node/notify-final-balance.go index a649aa5c2..47c933388 100644 --- a/rocketpool/node/notify-final-balance.go +++ b/rocketpool/node/notify-final-balance.go @@ -14,13 +14,13 @@ import ( "github.com/rocket-pool/smartnode/bindings/transactions" "github.com/rocket-pool/smartnode/bindings/utils/eth" + log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/config" rpgas "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" - "github.com/rocket-pool/smartnode/shared/utils/log" ) // Notify final balance task diff --git a/rocketpool/node/notify-validator-exit.go b/rocketpool/node/notify-validator-exit.go index a35daf018..b7ed0bc33 100644 --- a/rocketpool/node/notify-validator-exit.go +++ b/rocketpool/node/notify-validator-exit.go @@ -14,6 +14,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" + log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/config" @@ -21,7 +22,6 @@ import ( "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" "github.com/rocket-pool/smartnode/shared/types/eth2" - "github.com/rocket-pool/smartnode/shared/utils/log" ) const FarFutureEpoch uint64 = 0xffffffffffffffff diff --git a/rocketpool/node/prestake-megapool-validator.go b/rocketpool/node/prestake-megapool-validator.go index e2b33e8ea..24b27a796 100644 --- a/rocketpool/node/prestake-megapool-validator.go +++ b/rocketpool/node/prestake-megapool-validator.go @@ -16,12 +16,12 @@ import ( "github.com/rocket-pool/smartnode/bindings/transactions" "github.com/rocket-pool/smartnode/bindings/utils/eth" + log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/config" rpgas "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" - "github.com/rocket-pool/smartnode/shared/utils/log" ) // Prestake megapool validator task diff --git a/rocketpool/node/provision-express-tickets.go b/rocketpool/node/provision-express-tickets.go index 0958ca89c..3f4dd8721 100644 --- a/rocketpool/node/provision-express-tickets.go +++ b/rocketpool/node/provision-express-tickets.go @@ -12,12 +12,12 @@ import ( "github.com/rocket-pool/smartnode/bindings/transactions" "github.com/rocket-pool/smartnode/bindings/utils/eth" + log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/config" rpgas "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" - "github.com/rocket-pool/smartnode/shared/utils/log" ) // Provision Express Tickets task diff --git a/rocketpool/node/set-latest-delegate.go b/rocketpool/node/set-latest-delegate.go index e4d3f6039..706675431 100644 --- a/rocketpool/node/set-latest-delegate.go +++ b/rocketpool/node/set-latest-delegate.go @@ -17,13 +17,13 @@ import ( rpstate "github.com/rocket-pool/smartnode/bindings/utils/state" "github.com/rocket-pool/smartnode/shared/services/alerting" + log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/config" rpgas "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" - "github.com/rocket-pool/smartnode/shared/utils/log" ) // Distribute minipools task diff --git a/rocketpool/node/stake-megapool-validator.go b/rocketpool/node/stake-megapool-validator.go index 4157f54e6..ae8af4a68 100644 --- a/rocketpool/node/stake-megapool-validator.go +++ b/rocketpool/node/stake-megapool-validator.go @@ -14,6 +14,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" + log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/config" @@ -21,7 +22,6 @@ import ( "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" "github.com/rocket-pool/smartnode/shared/types/eth2" - "github.com/rocket-pool/smartnode/shared/utils/log" "github.com/rocket-pool/smartnode/shared/utils/validator" ) diff --git a/rocketpool/node/verify-pdao-props-state_test.go b/rocketpool/node/verify-pdao-props-state_test.go index 432fe803d..14e9f4b5d 100644 --- a/rocketpool/node/verify-pdao-props-state_test.go +++ b/rocketpool/node/verify-pdao-props-state_test.go @@ -7,10 +7,10 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/rocket-pool/smartnode/bindings/dao/protocol" "github.com/rocket-pool/smartnode/bindings/types" + log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/proposals" "github.com/rocket-pool/smartnode/shared/services/state" - "github.com/rocket-pool/smartnode/shared/utils/log" ) const stateFixture = "../../shared/services/state/testdata/small_state.json" diff --git a/rocketpool/node/verify-pdao-props.go b/rocketpool/node/verify-pdao-props.go index 16c8a0c5c..c25a18ca4 100644 --- a/rocketpool/node/verify-pdao-props.go +++ b/rocketpool/node/verify-pdao-props.go @@ -14,6 +14,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/transactions" "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" + log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/config" @@ -21,7 +22,6 @@ import ( "github.com/rocket-pool/smartnode/shared/services/proposals" "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" - "github.com/rocket-pool/smartnode/shared/utils/log" ) type challenge struct { diff --git a/rocketpool/watchtower/challenge-exit.go b/rocketpool/watchtower/challenge-exit.go index b5e068b4f..261785d48 100644 --- a/rocketpool/watchtower/challenge-exit.go +++ b/rocketpool/watchtower/challenge-exit.go @@ -13,11 +13,11 @@ import ( "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/rocketpool/watchtower/utils" + log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/config" "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" - "github.com/rocket-pool/smartnode/shared/utils/log" ) type challengeValidatorsExiting struct { diff --git a/rocketpool/watchtower/check-solo-migrations.go b/rocketpool/watchtower/check-solo-migrations.go index 303be0ad1..61ecbc963 100644 --- a/rocketpool/watchtower/check-solo-migrations.go +++ b/rocketpool/watchtower/check-solo-migrations.go @@ -17,12 +17,12 @@ import ( "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/rocketpool/watchtower/utils" + log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/config" "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" - "github.com/rocket-pool/smartnode/shared/utils/log" ) const ( diff --git a/rocketpool/watchtower/dissolve-invalid-credentials.go b/rocketpool/watchtower/dissolve-invalid-credentials.go index 18c4ef7ab..15187d523 100644 --- a/rocketpool/watchtower/dissolve-invalid-credentials.go +++ b/rocketpool/watchtower/dissolve-invalid-credentials.go @@ -11,11 +11,11 @@ import ( "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/rocketpool/watchtower/utils" + log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/config" "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" - "github.com/rocket-pool/smartnode/shared/utils/log" ) // Dissolve timed out minipools task diff --git a/rocketpool/watchtower/dissolve-timed-out-megapool-validators.go b/rocketpool/watchtower/dissolve-timed-out-megapool-validators.go index aa9b4e42e..cab1c78c7 100644 --- a/rocketpool/watchtower/dissolve-timed-out-megapool-validators.go +++ b/rocketpool/watchtower/dissolve-timed-out-megapool-validators.go @@ -12,11 +12,11 @@ import ( "github.com/rocket-pool/smartnode/bindings/transactions" "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/rocketpool/watchtower/utils" + log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/config" "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" - "github.com/rocket-pool/smartnode/shared/utils/log" ) // Dissolve timed out megapool validators task diff --git a/rocketpool/watchtower/dissolve-timed-out-minipools.go b/rocketpool/watchtower/dissolve-timed-out-minipools.go index 4992206e0..6b4f91649 100644 --- a/rocketpool/watchtower/dissolve-timed-out-minipools.go +++ b/rocketpool/watchtower/dissolve-timed-out-minipools.go @@ -15,11 +15,11 @@ import ( "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/rocketpool/watchtower/utils" + log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/config" "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" - "github.com/rocket-pool/smartnode/shared/utils/log" ) // Settings diff --git a/rocketpool/watchtower/finalize-pdao-proposals.go b/rocketpool/watchtower/finalize-pdao-proposals.go index ec499573e..f30f1143d 100644 --- a/rocketpool/watchtower/finalize-pdao-proposals.go +++ b/rocketpool/watchtower/finalize-pdao-proposals.go @@ -12,11 +12,11 @@ import ( "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/rocketpool/watchtower/utils" + log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/config" "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" - "github.com/rocket-pool/smartnode/shared/utils/log" ) // Finalize PDAO proposals task diff --git a/rocketpool/watchtower/generate-rewards-tree.go b/rocketpool/watchtower/generate-rewards-tree.go index 21f9d5396..4ed37e3e9 100644 --- a/rocketpool/watchtower/generate-rewards-tree.go +++ b/rocketpool/watchtower/generate-rewards-tree.go @@ -18,12 +18,12 @@ import ( "github.com/rocket-pool/smartnode/bindings/rewards" "github.com/rocket-pool/smartnode/bindings/rocketpool" + log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/config" rprewards "github.com/rocket-pool/smartnode/shared/services/rewards" "github.com/rocket-pool/smartnode/shared/services/state" - "github.com/rocket-pool/smartnode/shared/utils/log" ) // Generate rewards Merkle Tree task diff --git a/rocketpool/watchtower/metrics-exporter.go b/rocketpool/watchtower/metrics-exporter.go index abe2a5711..64e94ee7e 100644 --- a/rocketpool/watchtower/metrics-exporter.go +++ b/rocketpool/watchtower/metrics-exporter.go @@ -11,8 +11,8 @@ import ( "github.com/urfave/cli/v3" "github.com/rocket-pool/smartnode/rocketpool/watchtower/collectors" + log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services" - "github.com/rocket-pool/smartnode/shared/utils/log" ) func runMetricsServer(c *cli.Command, logger log.ColorLogger, scrubCollector *collectors.ScrubCollector, bondReductionCollector *collectors.BondReductionCollector, soloMigrationCollector *collectors.SoloMigrationCollector) error { diff --git a/rocketpool/watchtower/respond-challenges.go b/rocketpool/watchtower/respond-challenges.go index 9ae37d609..a74a0e43c 100644 --- a/rocketpool/watchtower/respond-challenges.go +++ b/rocketpool/watchtower/respond-challenges.go @@ -11,11 +11,11 @@ import ( "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/rocketpool/watchtower/utils" + log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/config" "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" - "github.com/rocket-pool/smartnode/shared/utils/log" ) // Respond to challenges task diff --git a/rocketpool/watchtower/submit-network-balances-state_test.go b/rocketpool/watchtower/submit-network-balances-state_test.go index fb4bef3b9..3c0483257 100644 --- a/rocketpool/watchtower/submit-network-balances-state_test.go +++ b/rocketpool/watchtower/submit-network-balances-state_test.go @@ -8,9 +8,9 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/rocket-pool/smartnode/bindings/megapool" + log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services/config" "github.com/rocket-pool/smartnode/shared/services/state" - "github.com/rocket-pool/smartnode/shared/utils/log" ) const smallStateFixture = "../../shared/services/state/testdata/network_state.json.gz" diff --git a/rocketpool/watchtower/submit-network-balances.go b/rocketpool/watchtower/submit-network-balances.go index 677d3e963..d3a7951b7 100644 --- a/rocketpool/watchtower/submit-network-balances.go +++ b/rocketpool/watchtower/submit-network-balances.go @@ -26,13 +26,13 @@ import ( "github.com/rocket-pool/smartnode/bindings/settings/protocol" "github.com/rocket-pool/smartnode/rocketpool/watchtower/utils" + log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/config" rprewards "github.com/rocket-pool/smartnode/shared/services/rewards" "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" - "github.com/rocket-pool/smartnode/shared/utils/log" ) const ( diff --git a/rocketpool/watchtower/submit-rewards-tree-stateless.go b/rocketpool/watchtower/submit-rewards-tree-stateless.go index 96f421c1b..7c1b07661 100644 --- a/rocketpool/watchtower/submit-rewards-tree-stateless.go +++ b/rocketpool/watchtower/submit-rewards-tree-stateless.go @@ -25,6 +25,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/rocketpool/watchtower/utils" hexutil "github.com/rocket-pool/smartnode/shared/hex" + log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/config" @@ -32,7 +33,6 @@ import ( "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" cfgtypes "github.com/rocket-pool/smartnode/shared/types/config" - "github.com/rocket-pool/smartnode/shared/utils/log" ) // Submit rewards Merkle Tree task diff --git a/rocketpool/watchtower/submit-rpl-price.go b/rocketpool/watchtower/submit-rpl-price.go index f17775610..8b25ca29e 100644 --- a/rocketpool/watchtower/submit-rpl-price.go +++ b/rocketpool/watchtower/submit-rpl-price.go @@ -27,13 +27,13 @@ import ( "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/rocketpool/watchtower/utils" + log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/config" rpgas "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" - "github.com/rocket-pool/smartnode/shared/utils/log" mathutils "github.com/rocket-pool/smartnode/shared/utils/math" ) diff --git a/rocketpool/watchtower/submit-scrub-minipools.go b/rocketpool/watchtower/submit-scrub-minipools.go index 2ebf74a2d..074389f5f 100644 --- a/rocketpool/watchtower/submit-scrub-minipools.go +++ b/rocketpool/watchtower/submit-scrub-minipools.go @@ -26,12 +26,12 @@ import ( "github.com/rocket-pool/smartnode/rocketpool/watchtower/collectors" "github.com/rocket-pool/smartnode/rocketpool/watchtower/utils" + log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/config" "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" - "github.com/rocket-pool/smartnode/shared/utils/log" ) // Settings diff --git a/rocketpool/watchtower/watchtower.go b/rocketpool/watchtower/watchtower.go index 6d839c067..0882df7ba 100644 --- a/rocketpool/watchtower/watchtower.go +++ b/rocketpool/watchtower/watchtower.go @@ -20,11 +20,11 @@ import ( "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/utils" "github.com/rocket-pool/smartnode/rocketpool/watchtower/collectors" + log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" - "github.com/rocket-pool/smartnode/shared/utils/log" ) // Config diff --git a/shared/utils/log/logger.go b/shared/logger/logger.go similarity index 100% rename from shared/utils/log/logger.go rename to shared/logger/logger.go diff --git a/shared/services/bc-manager.go b/shared/services/bc-manager.go index 13b4f3037..91697eb67 100644 --- a/shared/services/bc-manager.go +++ b/shared/services/bc-manager.go @@ -9,12 +9,12 @@ import ( "github.com/fatih/color" "github.com/rocket-pool/smartnode/bindings/types" + log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/beacon/client" "github.com/rocket-pool/smartnode/shared/services/config" "github.com/rocket-pool/smartnode/shared/types/api" cfgtypes "github.com/rocket-pool/smartnode/shared/types/config" - "github.com/rocket-pool/smartnode/shared/utils/log" ) const bnContainerName string = "eth2" diff --git a/shared/services/connectivity/check-port-connectivity.go b/shared/services/connectivity/check-port-connectivity.go index e5634d88c..b45c21822 100644 --- a/shared/services/connectivity/check-port-connectivity.go +++ b/shared/services/connectivity/check-port-connectivity.go @@ -13,10 +13,10 @@ import ( "github.com/urfave/cli/v3" + log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services/alerting" cfg "github.com/rocket-pool/smartnode/shared/services/config" cfgtypes "github.com/rocket-pool/smartnode/shared/types/config" - "github.com/rocket-pool/smartnode/shared/utils/log" ) const ( diff --git a/shared/services/connectivity/check-port-connectivity_test.go b/shared/services/connectivity/check-port-connectivity_test.go index 5938dd7c2..24ec4bab0 100644 --- a/shared/services/connectivity/check-port-connectivity_test.go +++ b/shared/services/connectivity/check-port-connectivity_test.go @@ -3,9 +3,9 @@ package connectivity import ( "testing" + log "github.com/rocket-pool/smartnode/shared/logger" cfg "github.com/rocket-pool/smartnode/shared/services/config" cfgtypes "github.com/rocket-pool/smartnode/shared/types/config" - log "github.com/rocket-pool/smartnode/shared/utils/log" ) // TestCheckPortConnectivity_Run verifies that the port connectivity task correctly diff --git a/shared/services/ec-manager.go b/shared/services/ec-manager.go index ee328418d..a57172cea 100644 --- a/shared/services/ec-manager.go +++ b/shared/services/ec-manager.go @@ -16,10 +16,10 @@ import ( "github.com/rocket-pool/smartnode/bindings/rocketpool" clicolor "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" + log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services/config" "github.com/rocket-pool/smartnode/shared/types/api" cfgtypes "github.com/rocket-pool/smartnode/shared/types/config" - "github.com/rocket-pool/smartnode/shared/utils/log" ) // This is a proxy for multiple ETH clients, providing natural fallback support if one of them fails. diff --git a/shared/services/proposals/network-tree-manager.go b/shared/services/proposals/network-tree-manager.go index b0c5f8eb7..d436b28a5 100644 --- a/shared/services/proposals/network-tree-manager.go +++ b/shared/services/proposals/network-tree-manager.go @@ -11,9 +11,9 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/rocket-pool/smartnode/bindings/types" + log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services/config" cfgtypes "github.com/rocket-pool/smartnode/shared/types/config" - "github.com/rocket-pool/smartnode/shared/utils/log" ) const ( diff --git a/shared/services/proposals/node-tree-manager.go b/shared/services/proposals/node-tree-manager.go index 58c5126b6..50f2872f6 100644 --- a/shared/services/proposals/node-tree-manager.go +++ b/shared/services/proposals/node-tree-manager.go @@ -11,9 +11,9 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/rocket-pool/smartnode/bindings/types" + log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services/config" cfgtypes "github.com/rocket-pool/smartnode/shared/types/config" - "github.com/rocket-pool/smartnode/shared/utils/log" ) const ( diff --git a/shared/services/proposals/proposal-manager.go b/shared/services/proposals/proposal-manager.go index c7f3e1bfc..5c59de334 100644 --- a/shared/services/proposals/proposal-manager.go +++ b/shared/services/proposals/proposal-manager.go @@ -9,10 +9,10 @@ import ( "github.com/rocket-pool/smartnode/bindings/dao/protocol" "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/types" + log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/config" "github.com/rocket-pool/smartnode/shared/services/state" - "github.com/rocket-pool/smartnode/shared/utils/log" ) type ProposalManager struct { diff --git a/shared/services/proposals/vi-snapshot-manager.go b/shared/services/proposals/vi-snapshot-manager.go index c2d94b779..30fec1ae2 100644 --- a/shared/services/proposals/vi-snapshot-manager.go +++ b/shared/services/proposals/vi-snapshot-manager.go @@ -16,9 +16,9 @@ import ( "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/shared" + log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services/config" cfgtypes "github.com/rocket-pool/smartnode/shared/types/config" - "github.com/rocket-pool/smartnode/shared/utils/log" ) const ( diff --git a/shared/services/rewards/generator-impl-v11.go b/shared/services/rewards/generator-impl-v11.go index fe426946e..a4d3922bd 100644 --- a/shared/services/rewards/generator-impl-v11.go +++ b/shared/services/rewards/generator-impl-v11.go @@ -18,13 +18,13 @@ import ( rptypes "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" rpstate "github.com/rocket-pool/smartnode/bindings/utils/state" + log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/config" "github.com/rocket-pool/smartnode/shared/services/rewards/fees" "github.com/rocket-pool/smartnode/shared/services/rewards/ssz_types" sszbig "github.com/rocket-pool/smartnode/shared/services/rewards/ssz_types/big" "github.com/rocket-pool/smartnode/shared/services/state" - "github.com/rocket-pool/smartnode/shared/utils/log" ) // Implementation for tree generator ruleset v9 diff --git a/shared/services/rewards/generator-impl-v9-v10.go b/shared/services/rewards/generator-impl-v9-v10.go index cb6b59d1f..8a65fb930 100644 --- a/shared/services/rewards/generator-impl-v9-v10.go +++ b/shared/services/rewards/generator-impl-v9-v10.go @@ -17,13 +17,13 @@ import ( "github.com/rocket-pool/smartnode/bindings/rewards" rptypes "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" + log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/config" "github.com/rocket-pool/smartnode/shared/services/rewards/fees" "github.com/rocket-pool/smartnode/shared/services/rewards/ssz_types" sszbig "github.com/rocket-pool/smartnode/shared/services/rewards/ssz_types/big" "github.com/rocket-pool/smartnode/shared/services/state" - "github.com/rocket-pool/smartnode/shared/utils/log" ) // Implementation for tree generator ruleset v9 diff --git a/shared/services/rewards/generator.go b/shared/services/rewards/generator.go index 09840ce8a..9fabf38f8 100644 --- a/shared/services/rewards/generator.go +++ b/shared/services/rewards/generator.go @@ -10,11 +10,11 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ipfs/go-cid" + log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/config" "github.com/rocket-pool/smartnode/shared/services/state" cfgtypes "github.com/rocket-pool/smartnode/shared/types/config" - "github.com/rocket-pool/smartnode/shared/utils/log" ) // Settings diff --git a/shared/services/rewards/mock_v11_test.go b/shared/services/rewards/mock_v11_test.go index 44214d456..4ba54fcbc 100644 --- a/shared/services/rewards/mock_v11_test.go +++ b/shared/services/rewards/mock_v11_test.go @@ -16,10 +16,10 @@ import ( rptypes "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/bindings/utils/eth" + log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/rewards/test" "github.com/rocket-pool/smartnode/shared/services/rewards/test/assets" - "github.com/rocket-pool/smartnode/shared/utils/log" ) func TestMockIntervalDefaultsTreegenv11(tt *testing.T) { diff --git a/shared/services/state/manager.go b/shared/services/state/manager.go index a67502105..0998c3b70 100644 --- a/shared/services/state/manager.go +++ b/shared/services/state/manager.go @@ -8,9 +8,9 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/rocket-pool/smartnode/bindings/rocketpool" + log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/config" - "github.com/rocket-pool/smartnode/shared/utils/log" ) type NetworkStateManager struct { diff --git a/shared/utils/validator/fee-recipient.go b/shared/utils/validator/fee-recipient.go index 6781cd45d..a1e656d13 100644 --- a/shared/utils/validator/fee-recipient.go +++ b/shared/utils/validator/fee-recipient.go @@ -12,9 +12,9 @@ import ( "github.com/docker/docker/api/types/container" "github.com/docker/docker/client" + log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/config" - "github.com/rocket-pool/smartnode/shared/utils/log" ) // Settings diff --git a/treegen/tree-gen.go b/treegen/tree-gen.go index 8dd42f796..da418a338 100644 --- a/treegen/tree-gen.go +++ b/treegen/tree-gen.go @@ -21,6 +21,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/rewards" "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/utils/eth" + log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/beacon/client" @@ -28,7 +29,6 @@ import ( rprewards "github.com/rocket-pool/smartnode/shared/services/rewards" "github.com/rocket-pool/smartnode/shared/services/state" cfgtypes "github.com/rocket-pool/smartnode/shared/types/config" - "github.com/rocket-pool/smartnode/shared/utils/log" ) const ( From b2f4583d6fc118ce053b7f826736c82e86713c3e Mon Sep 17 00:00:00 2001 From: Jacob Shufro Date: Sat, 25 Jul 2026 15:44:31 -0400 Subject: [PATCH 08/12] Remove shared/utils/math --- bindings/dao/proposals.go | 8 +- bindings/legacy/v1.0.0/rewards/rewards.go | 8 +- bindings/legacy/v1.1.0/node/deposit.go | 6 +- bindings/legacy/v1.2.0/network/balances.go | 4 +- bindings/legacy/v1.3.1/node/deposit.go | 10 +-- bindings/legacy/v1.3.1/protocol/node.go | 6 +- bindings/minipool/minipool-contract-v2.go | 4 +- bindings/minipool/minipool-contract-v3.go | 4 +- bindings/network/balances.go | 4 +- bindings/network/fees.go | 6 +- bindings/node/deposit.go | 6 +- bindings/node/node.go | 7 +- bindings/settings/protocol/auction.go | 6 +- bindings/settings/protocol/inflation.go | 4 +- bindings/settings/protocol/network.go | 16 ++-- bindings/settings/protocol/node.go | 6 +- bindings/settings/protocol/proposals.go | 6 +- bindings/settings/protocol/rewards.go | 4 +- bindings/settings/trustednode/members.go | 8 +- bindings/tokens/reth.go | 6 +- bindings/transactions/gaslimit/gas.go | 13 ++- bindings/utils/state/network.go | 8 +- rocketpool-cli/auction/bid-lot.go | 20 ++--- rocketpool-cli/auction/claim-lot.go | 5 +- rocketpool-cli/auction/lots.go | 26 +++--- rocketpool-cli/auction/recover-lot.go | 5 +- rocketpool-cli/auction/status.go | 10 +-- rocketpool-cli/claims/claim-all.go | 73 ++++++++-------- rocketpool-cli/cli/validation.go | 4 +- rocketpool-cli/megapool/claim.go | 7 +- rocketpool-cli/megapool/deposit.go | 34 ++++---- rocketpool-cli/megapool/distribute.go | 4 +- rocketpool-cli/megapool/reduce-bond.go | 15 ++-- rocketpool-cli/megapool/repay-debt.go | 11 ++- rocketpool-cli/megapool/status.go | 25 +++--- rocketpool-cli/minipool/close.go | 21 +++-- rocketpool-cli/minipool/distribute.go | 23 +++-- rocketpool-cli/minipool/refund.go | 5 +- rocketpool-cli/minipool/rescue-dissolved.go | 15 ++-- rocketpool-cli/minipool/status.go | 23 +++-- rocketpool-cli/network/dao-proposals.go | 8 +- rocketpool-cli/network/rpl-price.go | 6 +- rocketpool-cli/node/claim-rewards.go | 29 ++++--- .../node/claim-unclaimed-rewards.go | 9 +- rocketpool-cli/node/distributor.go | 4 +- rocketpool-cli/node/rewards.go | 4 +- rocketpool-cli/node/rpl-withdrawal-address.go | 4 +- rocketpool-cli/node/stake-rpl.go | 36 ++++---- rocketpool-cli/node/status.go | 50 ++++++----- rocketpool-cli/node/swap-rpl.go | 14 ++-- rocketpool-cli/node/withdraw-credit.go | 14 ++-- rocketpool-cli/node/withdraw-eth.go | 14 ++-- rocketpool-cli/node/withdraw-rpl.go | 56 ++++++------- rocketpool-cli/odao/get-settings.go | 6 +- rocketpool-cli/odao/join.go | 10 +-- rocketpool-cli/odao/members.go | 6 +- rocketpool-cli/odao/penalise-megapool.go | 9 +- rocketpool-cli/odao/propose-kick.go | 13 ++- rocketpool-cli/odao/propose-settings.go | 7 +- rocketpool-cli/pdao/claim-bonds.go | 4 +- rocketpool-cli/pdao/get-settings.go | 64 +++++++------- rocketpool-cli/pdao/percentages.go | 8 +- rocketpool-cli/pdao/proposals.go | 16 ++-- rocketpool-cli/pdao/propose-settings.go | 4 +- rocketpool-cli/pdao/status.go | 11 ++- rocketpool-cli/pdao/vote-proposal.go | 14 ++-- rocketpool-cli/queue/assign-deposits.go | 4 +- rocketpool-cli/queue/status.go | 6 +- rocketpool/api/auction/utils.go | 4 +- rocketpool/api/debug/validators.go | 14 ++-- rocketpool/api/megapool/status.go | 4 +- rocketpool/api/minipool/close.go | 4 +- rocketpool/api/minipool/distribute.go | 4 +- rocketpool/api/minipool/rescue-dissolved.go | 6 +- rocketpool/api/minipool/utils.go | 6 +- rocketpool/api/network/stats.go | 16 ++-- rocketpool/api/node/claim-rewards.go | 8 +- rocketpool/api/node/create-vacant-minipool.go | 4 +- rocketpool/api/node/distributor.go | 4 +- rocketpool/api/node/rewards.go | 35 ++++---- rocketpool/api/node/send.go | 14 ++-- rocketpool/api/node/status.go | 14 ++-- rocketpool/api/odao/propose-kick.go | 7 +- rocketpool/api/pdao/percentages.go | 4 +- .../node/collectors/demand-collector.go | 10 +-- rocketpool/node/collectors/node-collector.go | 83 +++++++++---------- .../node/collectors/performance-collector.go | 10 +-- rocketpool/node/collectors/rpl-collector.go | 10 +-- .../collectors/smoothing-pool-collector.go | 4 +- .../node/collectors/snapshot-collector.go | 4 +- .../node/collectors/trusted-node-collector.go | 4 +- rocketpool/node/defend-challenge-exit.go | 8 +- rocketpool/node/defend-pdao-props.go | 8 +- rocketpool/node/distribute-minipools.go | 14 ++-- rocketpool/node/notify-final-balance.go | 8 +- rocketpool/node/notify-validator-exit.go | 8 +- .../node/prestake-megapool-validator.go | 8 +- rocketpool/node/provision-express-tickets.go | 8 +- rocketpool/node/set-latest-delegate.go | 8 +- rocketpool/node/stake-megapool-validator.go | 8 +- rocketpool/node/verify-pdao-props.go | 8 +- rocketpool/watchtower/challenge-exit.go | 6 +- .../watchtower/check-solo-migrations.go | 10 +-- .../dissolve-invalid-credentials.go | 6 +- .../dissolve-timed-out-megapool-validators.go | 6 +- .../dissolve-timed-out-minipools.go | 6 +- .../watchtower/finalize-pdao-proposals.go | 6 +- rocketpool/watchtower/respond-challenges.go | 6 +- .../watchtower/submit-network-balances.go | 54 ++++++------ .../submit-network-balances_test.go | 36 ++++---- .../submit-rewards-tree-stateless.go | 7 +- rocketpool/watchtower/submit-rpl-price.go | 41 +++++---- .../watchtower/submit-scrub-minipools.go | 8 +- shared/{utils => }/math/math.go | 9 +- {bindings/utils/eth => shared/math}/units.go | 2 +- shared/services/gas/gas.go | 38 ++++----- shared/services/rewards/generator-impl-v11.go | 38 ++++----- .../services/rewards/generator-impl-v9-v10.go | 22 ++--- shared/services/rewards/mock_v11_test.go | 8 +- shared/services/rewards/rewards-file-v1.go | 4 +- shared/services/rewards/test/mock.go | 14 ++-- shared/services/services.go | 10 +-- shared/services/state/network-state.go | 8 +- shared/types/eth2/fork/deneb/state_deneb.go | 2 +- .../types/eth2/fork/electra/state_electra.go | 2 +- shared/types/eth2/fork/fulu/state_fulu.go | 2 +- shared/types/eth2/generic/validator.go | 2 +- treegen/tree-gen.go | 6 +- 128 files changed, 787 insertions(+), 837 deletions(-) rename shared/{utils => }/math/math.go (70%) rename {bindings/utils/eth => shared/math}/units.go (99%) diff --git a/bindings/dao/proposals.go b/bindings/dao/proposals.go index a1a75dd87..4764434c8 100644 --- a/bindings/dao/proposals.go +++ b/bindings/dao/proposals.go @@ -11,8 +11,8 @@ import ( "github.com/rocket-pool/smartnode/bindings/rocketpool" rptypes "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/bindings/utils/strings" + "github.com/rocket-pool/smartnode/shared/math" ) // Settings @@ -537,7 +537,7 @@ func GetProposalVotesRequired(rp *rocketpool.RocketPool, proposalId uint64, opts if err := rocketDAOProposal.Call(opts, votesRequired, "getVotesRequired", big.NewInt(int64(proposalId))); err != nil { return 0, fmt.Errorf("error getting proposal %d votes required: %w", proposalId, err) } - return eth.WeiToEth(*votesRequired), nil + return math.WeiToEth(*votesRequired), nil } func GetProposalVotesFor(rp *rocketpool.RocketPool, proposalId uint64, opts *bind.CallOpts) (float64, error) { rocketDAOProposal, err := getRocketDAOProposal(rp, opts) @@ -548,7 +548,7 @@ func GetProposalVotesFor(rp *rocketpool.RocketPool, proposalId uint64, opts *bin if err := rocketDAOProposal.Call(opts, votesFor, "getVotesFor", big.NewInt(int64(proposalId))); err != nil { return 0, fmt.Errorf("error getting proposal %d votes for: %w", proposalId, err) } - return eth.WeiToEth(*votesFor), nil + return math.WeiToEth(*votesFor), nil } func GetProposalVotesAgainst(rp *rocketpool.RocketPool, proposalId uint64, opts *bind.CallOpts) (float64, error) { rocketDAOProposal, err := getRocketDAOProposal(rp, opts) @@ -559,7 +559,7 @@ func GetProposalVotesAgainst(rp *rocketpool.RocketPool, proposalId uint64, opts if err := rocketDAOProposal.Call(opts, votesAgainst, "getVotesAgainst", big.NewInt(int64(proposalId))); err != nil { return 0, fmt.Errorf("error getting proposal %d votes against: %w", proposalId, err) } - return eth.WeiToEth(*votesAgainst), nil + return math.WeiToEth(*votesAgainst), nil } func GetProposalIsCancelled(rp *rocketpool.RocketPool, proposalId uint64, opts *bind.CallOpts) (bool, error) { rocketDAOProposal, err := getRocketDAOProposal(rp, opts) diff --git a/bindings/legacy/v1.0.0/rewards/rewards.go b/bindings/legacy/v1.0.0/rewards/rewards.go index c5ed27749..57b3df471 100644 --- a/bindings/legacy/v1.0.0/rewards/rewards.go +++ b/bindings/legacy/v1.0.0/rewards/rewards.go @@ -11,7 +11,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/shared/math" ) // Get whether a claims contract is enabled @@ -39,7 +39,7 @@ func getClaimRewardsPerc(claimsContract *rocketpool.Contract, claimsName string, if err := claimsContract.Call(opts, claimRewardsPerc, "getClaimRewardsPerc", claimerAddress); err != nil { return 0, fmt.Errorf("error getting %s claim rewards percent for %s: %w", claimsName, claimerAddress.Hex(), err) } - return eth.WeiToEth(*claimRewardsPerc), nil + return math.WeiToEth(*claimRewardsPerc), nil } // Get the total amount of rewards available to a claimer @@ -128,7 +128,7 @@ func GetNodeOperatorRewardsPercent(rp *rocketpool.RocketPool, opts *bind.CallOpt if err := rocketRewardsPool.Call(opts, perc, "getClaimingContractPerc", "rocketClaimNode"); err != nil { return 0, fmt.Errorf("error getting node operator rewards percent: %w", err) } - return eth.WeiToEth(*perc), nil + return math.WeiToEth(*perc), nil } // Get the percent of checkpoint rewards that goes to ODAO members @@ -141,7 +141,7 @@ func GetTrustedNodeOperatorRewardsPercent(rp *rocketpool.RocketPool, opts *bind. if err := rocketRewardsPool.Call(opts, perc, "getClaimingContractPerc", "rocketClaimTrustedNode"); err != nil { return 0, fmt.Errorf("error getting trusted node operator rewards percent: %w", err) } - return eth.WeiToEth(*perc), nil + return math.WeiToEth(*perc), nil } // Get contracts diff --git a/bindings/legacy/v1.1.0/node/deposit.go b/bindings/legacy/v1.1.0/node/deposit.go index 5c3fdd389..26670e372 100644 --- a/bindings/legacy/v1.1.0/node/deposit.go +++ b/bindings/legacy/v1.1.0/node/deposit.go @@ -12,7 +12,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" rptypes "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/shared/math" ) // Estimate the gas of Deposit @@ -21,7 +21,7 @@ func EstimateDepositGas(rp *rocketpool.RocketPool, minimumNodeFee float64, valid if err != nil { return gaslimit.Limits{}, err } - return rocketNodeDeposit.GetTransactionGasInfo(opts, "deposit", eth.EthToWei(minimumNodeFee), validatorPubkey[:], validatorSignature[:], depositDataRoot, salt, expectedMinipoolAddress) + return rocketNodeDeposit.GetTransactionGasInfo(opts, "deposit", math.EthToWei(minimumNodeFee), validatorPubkey[:], validatorSignature[:], depositDataRoot, salt, expectedMinipoolAddress) } // Make a node deposit @@ -30,7 +30,7 @@ func Deposit(rp *rocketpool.RocketPool, minimumNodeFee float64, validatorPubkey if err != nil { return nil, err } - tx, err := rocketNodeDeposit.Transact(opts, "deposit", eth.EthToWei(minimumNodeFee), validatorPubkey[:], validatorSignature[:], depositDataRoot, salt, expectedMinipoolAddress) + tx, err := rocketNodeDeposit.Transact(opts, "deposit", math.EthToWei(minimumNodeFee), validatorPubkey[:], validatorSignature[:], depositDataRoot, salt, expectedMinipoolAddress) if err != nil { return nil, fmt.Errorf("error making node deposit: %w", err) } diff --git a/bindings/legacy/v1.2.0/network/balances.go b/bindings/legacy/v1.2.0/network/balances.go index 9752cea82..d2fb27933 100644 --- a/bindings/legacy/v1.2.0/network/balances.go +++ b/bindings/legacy/v1.2.0/network/balances.go @@ -10,7 +10,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/shared/math" ) // Get the block number which network balances are current for @@ -88,7 +88,7 @@ func GetETHUtilizationRate(rp *rocketpool.RocketPool, opts *bind.CallOpts, legac if err := rocketNetworkBalances.Call(opts, ethUtilizationRate, "getETHUtilizationRate"); err != nil { return 0, fmt.Errorf("Could not get network ETH utilization rate: %w", err) } - return eth.WeiToEth(*ethUtilizationRate), nil + return math.WeiToEth(*ethUtilizationRate), nil } // Estimate the gas of SubmitBalances diff --git a/bindings/legacy/v1.3.1/node/deposit.go b/bindings/legacy/v1.3.1/node/deposit.go index ce8f8fd25..a0da9b70a 100644 --- a/bindings/legacy/v1.3.1/node/deposit.go +++ b/bindings/legacy/v1.3.1/node/deposit.go @@ -12,7 +12,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" rptypes "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/shared/math" ) // Estimate the gas of Deposit @@ -21,7 +21,7 @@ func EstimateDepositGas(rp *rocketpool.RocketPool, bondAmount *big.Int, minimumN if err != nil { return gaslimit.Limits{}, err } - return rocketNodeDeposit.GetTransactionGasInfo(opts, "deposit", bondAmount, eth.EthToWei(minimumNodeFee), validatorPubkey[:], validatorSignature[:], depositDataRoot, salt, expectedMinipoolAddress) + return rocketNodeDeposit.GetTransactionGasInfo(opts, "deposit", bondAmount, math.EthToWei(minimumNodeFee), validatorPubkey[:], validatorSignature[:], depositDataRoot, salt, expectedMinipoolAddress) } // Make a node deposit @@ -30,7 +30,7 @@ func Deposit(rp *rocketpool.RocketPool, bondAmount *big.Int, minimumNodeFee floa if err != nil { return nil, err } - tx, err := rocketNodeDeposit.Transact(opts, "deposit", bondAmount, eth.EthToWei(minimumNodeFee), validatorPubkey[:], validatorSignature[:], depositDataRoot, salt, expectedMinipoolAddress) + tx, err := rocketNodeDeposit.Transact(opts, "deposit", bondAmount, math.EthToWei(minimumNodeFee), validatorPubkey[:], validatorSignature[:], depositDataRoot, salt, expectedMinipoolAddress) if err != nil { return nil, fmt.Errorf("error making node deposit: %w", err) } @@ -43,7 +43,7 @@ func EstimateDepositWithCreditGas(rp *rocketpool.RocketPool, bondAmount *big.Int if err != nil { return gaslimit.Limits{}, err } - return rocketNodeDeposit.GetTransactionGasInfo(opts, "depositWithCredit", bondAmount, eth.EthToWei(minimumNodeFee), validatorPubkey[:], validatorSignature[:], depositDataRoot, salt, expectedMinipoolAddress) + return rocketNodeDeposit.GetTransactionGasInfo(opts, "depositWithCredit", bondAmount, math.EthToWei(minimumNodeFee), validatorPubkey[:], validatorSignature[:], depositDataRoot, salt, expectedMinipoolAddress) } // Make a node deposit by using the credit balance @@ -52,7 +52,7 @@ func DepositWithCredit(rp *rocketpool.RocketPool, bondAmount *big.Int, minimumNo if err != nil { return nil, err } - tx, err := rocketNodeDeposit.Transact(opts, "depositWithCredit", bondAmount, eth.EthToWei(minimumNodeFee), validatorPubkey[:], validatorSignature[:], depositDataRoot, salt, expectedMinipoolAddress) + tx, err := rocketNodeDeposit.Transact(opts, "depositWithCredit", bondAmount, math.EthToWei(minimumNodeFee), validatorPubkey[:], validatorSignature[:], depositDataRoot, salt, expectedMinipoolAddress) if err != nil { return nil, fmt.Errorf("error making node deposit with credit: %w", err) } diff --git a/bindings/legacy/v1.3.1/protocol/node.go b/bindings/legacy/v1.3.1/protocol/node.go index 27845e26c..27977fe40 100644 --- a/bindings/legacy/v1.3.1/protocol/node.go +++ b/bindings/legacy/v1.3.1/protocol/node.go @@ -12,7 +12,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/shared/math" ) // Config @@ -32,7 +32,7 @@ func GetMinimumPerMinipoolStake(rp *rocketpool.RocketPool, opts *bind.CallOpts) if err := nodeSettingsContract.Call(opts, value, "getMinimumPerMinipoolStake"); err != nil { return 0, fmt.Errorf("error getting minimum RPL stake per minipool: %w", err) } - return eth.WeiToEth(*value), nil + return math.WeiToEth(*value), nil } func ProposeMinimumPerMinipoolStake(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", MinimumPerMinipoolStakeSettingPath), NodeSettingsContractName, MinimumPerMinipoolStakeSettingPath, value, blockNumber, treeNodes, opts) @@ -64,7 +64,7 @@ func GetMaximumPerMinipoolStake(rp *rocketpool.RocketPool, opts *bind.CallOpts) if err := nodeSettingsContract.Call(opts, value, "getMaximumPerMinipoolStake"); err != nil { return 0, fmt.Errorf("error getting maximum RPL stake per minipool: %w", err) } - return eth.WeiToEth(*value), nil + return math.WeiToEth(*value), nil } func ProposeMaximumPerMinipoolStake(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", MaximumPerMinipoolStakeSettingPath), NodeSettingsContractName, MaximumPerMinipoolStakeSettingPath, value, blockNumber, treeNodes, opts) diff --git a/bindings/minipool/minipool-contract-v2.go b/bindings/minipool/minipool-contract-v2.go index 695903822..64e1ac4cb 100644 --- a/bindings/minipool/minipool-contract-v2.go +++ b/bindings/minipool/minipool-contract-v2.go @@ -18,7 +18,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/storage" "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" rptypes "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/shared/math" ) const ( @@ -236,7 +236,7 @@ func (mp *minipool_v2) GetNodeFee(opts *bind.CallOpts) (float64, error) { if err := mp.Contract.Call(opts, nodeFee, "getNodeFee"); err != nil { return 0, fmt.Errorf("error getting minipool %s node fee: %w", mp.Address.Hex(), err) } - return eth.WeiToEth(*nodeFee), nil + return math.WeiToEth(*nodeFee), nil } func (mp *minipool_v2) GetNodeFeeRaw(opts *bind.CallOpts) (*big.Int, error) { nodeFee := new(*big.Int) diff --git a/bindings/minipool/minipool-contract-v3.go b/bindings/minipool/minipool-contract-v3.go index fcd640e53..99852cd58 100644 --- a/bindings/minipool/minipool-contract-v3.go +++ b/bindings/minipool/minipool-contract-v3.go @@ -18,7 +18,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/storage" "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" rptypes "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/shared/math" ) const ( @@ -248,7 +248,7 @@ func (mp *minipool_v3) GetNodeFee(opts *bind.CallOpts) (float64, error) { if err := mp.Contract.Call(opts, nodeFee, "getNodeFee"); err != nil { return 0, fmt.Errorf("error getting minipool %s node fee: %w", mp.Address.Hex(), err) } - return eth.WeiToEth(*nodeFee), nil + return math.WeiToEth(*nodeFee), nil } func (mp *minipool_v3) GetNodeFeeRaw(opts *bind.CallOpts) (*big.Int, error) { nodeFee := new(*big.Int) diff --git a/bindings/network/balances.go b/bindings/network/balances.go index 4c11d6676..8558687db 100644 --- a/bindings/network/balances.go +++ b/bindings/network/balances.go @@ -11,7 +11,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/logs" "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/shared/math" ) // Info for a balances updated event @@ -99,7 +99,7 @@ func GetETHUtilizationRate(rp *rocketpool.RocketPool, opts *bind.CallOpts) (floa if err := rocketNetworkBalances.Call(opts, ethUtilizationRate, "getETHUtilizationRate"); err != nil { return 0, fmt.Errorf("error getting network ETH utilization rate: %w", err) } - return eth.WeiToEth(*ethUtilizationRate), nil + return math.WeiToEth(*ethUtilizationRate), nil } // Estimate the gas of SubmitBalances diff --git a/bindings/network/fees.go b/bindings/network/fees.go index e8f78c3d6..b1cd0c4e3 100644 --- a/bindings/network/fees.go +++ b/bindings/network/fees.go @@ -8,7 +8,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/rocket-pool/smartnode/bindings/rocketpool" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/shared/math" ) // Get the current network node demand in ETH @@ -34,7 +34,7 @@ func GetNodeFee(rp *rocketpool.RocketPool, opts *bind.CallOpts) (float64, error) if err := rocketNetworkFees.Call(opts, nodeFee, "getNodeFee"); err != nil { return 0, fmt.Errorf("error getting network node fee: %w", err) } - return eth.WeiToEth(*nodeFee), nil + return math.WeiToEth(*nodeFee), nil } // Get the network node fee for a node demand value @@ -47,7 +47,7 @@ func GetNodeFeeByDemand(rp *rocketpool.RocketPool, nodeDemand *big.Int, opts *bi if err := rocketNetworkFees.Call(opts, nodeFee, "getNodeFeeByDemand", nodeDemand); err != nil { return 0, fmt.Errorf("error getting node fee by node demand: %w", err) } - return eth.WeiToEth(*nodeFee), nil + return math.WeiToEth(*nodeFee), nil } // Get contracts diff --git a/bindings/node/deposit.go b/bindings/node/deposit.go index 129563ede..e6157935b 100644 --- a/bindings/node/deposit.go +++ b/bindings/node/deposit.go @@ -12,7 +12,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" rptypes "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/shared/math" ) type NodeDeposit struct { @@ -134,7 +134,7 @@ func EstimateCreateVacantMinipoolGas(rp *rocketpool.RocketPool, bondAmount *big. if err != nil { return gaslimit.Limits{}, err } - return rocketNodeDeposit.GetTransactionGasInfo(opts, "createVacantMinipool", bondAmount, eth.EthToWei(minimumNodeFee), validatorPubkey[:], salt, expectedMinipoolAddress, currentBalance) + return rocketNodeDeposit.GetTransactionGasInfo(opts, "createVacantMinipool", bondAmount, math.EthToWei(minimumNodeFee), validatorPubkey[:], salt, expectedMinipoolAddress, currentBalance) } // Make a vacant minipool for solo staker migration @@ -143,7 +143,7 @@ func CreateVacantMinipool(rp *rocketpool.RocketPool, bondAmount *big.Int, minimu if err != nil { return nil, err } - tx, err := rocketNodeDeposit.Transact(opts, "createVacantMinipool", bondAmount, eth.EthToWei(minimumNodeFee), validatorPubkey[:], salt, expectedMinipoolAddress, currentBalance) + tx, err := rocketNodeDeposit.Transact(opts, "createVacantMinipool", bondAmount, math.EthToWei(minimumNodeFee), validatorPubkey[:], salt, expectedMinipoolAddress, currentBalance) if err != nil { return nil, fmt.Errorf("error creating vacant minipool: %w", err) } diff --git a/bindings/node/node.go b/bindings/node/node.go index 40dfa2e47..4920dc768 100644 --- a/bindings/node/node.go +++ b/bindings/node/node.go @@ -2,7 +2,6 @@ package node import ( "fmt" - "math" "math/big" "sync" "time" @@ -14,9 +13,9 @@ import ( "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/storage" "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" - "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/bindings/utils/multicall" "github.com/rocket-pool/smartnode/bindings/utils/strings" + "github.com/rocket-pool/smartnode/shared/math" ) // Settings @@ -474,7 +473,7 @@ func GetNodeAverageFee(rp *rocketpool.RocketPool, nodeAddress common.Address, op if err := rocketNodeManager.Call(opts, avgFee, "getAverageNodeFee", nodeAddress); err != nil { return 0, fmt.Errorf("error getting node %s average fee: %w", nodeAddress.Hex(), err) } - return eth.WeiToEth(*avgFee), nil + return math.WeiToEth(*avgFee), nil } // Get a node's average minipool fee @@ -761,7 +760,7 @@ func GetUnclaimedRewards(rp *rocketpool.RocketPool, nodeAddress common.Address, if err := rocketNodeManager.Call(opts, unclaimedRewards, "getUnclaimedRewards", nodeAddress); err != nil { return 0, fmt.Errorf("error getting node %s's unclaimed rewards: %w", nodeAddress.Hex(), err) } - return eth.WeiToEth(*unclaimedRewards), nil + return math.WeiToEth(*unclaimedRewards), nil } // Get the amount of unclaimed ETH rewards for a given node operator diff --git a/bindings/settings/protocol/auction.go b/bindings/settings/protocol/auction.go index f0c4e5662..a05599442 100644 --- a/bindings/settings/protocol/auction.go +++ b/bindings/settings/protocol/auction.go @@ -13,7 +13,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/shared/math" ) // Config @@ -133,7 +133,7 @@ func GetLotStartingPriceRatio(rp *rocketpool.RocketPool, opts *bind.CallOpts) (f if err := auctionSettingsContract.Call(opts, value, "getStartingPriceRatio"); err != nil { return 0, fmt.Errorf("error getting lot starting price ratio: %w", err) } - return eth.WeiToEth(*value), nil + return math.WeiToEth(*value), nil } // The starting price relative to current ETH price, as a fraction @@ -165,7 +165,7 @@ func GetLotReservePriceRatio(rp *rocketpool.RocketPool, opts *bind.CallOpts) (fl if err := auctionSettingsContract.Call(opts, value, "getReservePriceRatio"); err != nil { return 0, fmt.Errorf("error getting lot reserve price ratio: %w", err) } - return eth.WeiToEth(*value), nil + return math.WeiToEth(*value), nil } // The reserve price relative to current ETH price, as a fraction diff --git a/bindings/settings/protocol/inflation.go b/bindings/settings/protocol/inflation.go index 6c279df6b..28057521f 100644 --- a/bindings/settings/protocol/inflation.go +++ b/bindings/settings/protocol/inflation.go @@ -8,7 +8,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/rocket-pool/smartnode/bindings/rocketpool" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/shared/math" ) // Config @@ -26,7 +26,7 @@ func GetInflationIntervalRate(rp *rocketpool.RocketPool, opts *bind.CallOpts) (f if err := inflationSettingsContract.Call(opts, value, "getInflationIntervalRate"); err != nil { return 0, fmt.Errorf("error getting inflation rate: %w", err) } - return eth.WeiToEth(*value), nil + return math.WeiToEth(*value), nil } // RPL inflation rate per interval diff --git a/bindings/settings/protocol/network.go b/bindings/settings/protocol/network.go index f103a83d6..801d9eb5e 100644 --- a/bindings/settings/protocol/network.go +++ b/bindings/settings/protocol/network.go @@ -13,7 +13,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/shared/math" ) // Config @@ -51,7 +51,7 @@ func GetNodeConsensusThreshold(rp *rocketpool.RocketPool, opts *bind.CallOpts) ( if err := networkSettingsContract.Call(opts, value, "getNodeConsensusThreshold"); err != nil { return 0, fmt.Errorf("error getting trusted node consensus threshold: %w", err) } - return eth.WeiToEth(*value), nil + return math.WeiToEth(*value), nil } // The threshold of trusted nodes that must reach consensus on oracle data to commit it @@ -159,7 +159,7 @@ func GetMinimumNodeFee(rp *rocketpool.RocketPool, opts *bind.CallOpts) (float64, if err := networkSettingsContract.Call(opts, value, "getMinimumNodeFee"); err != nil { return 0, fmt.Errorf("error getting minimum node fee: %w", err) } - return eth.WeiToEth(*value), nil + return math.WeiToEth(*value), nil } // Minimum node commission rate @@ -191,7 +191,7 @@ func GetTargetNodeFee(rp *rocketpool.RocketPool, opts *bind.CallOpts) (float64, if err := networkSettingsContract.Call(opts, value, "getTargetNodeFee"); err != nil { return 0, fmt.Errorf("error getting target node fee: %w", err) } - return eth.WeiToEth(*value), nil + return math.WeiToEth(*value), nil } // Target node commission rate @@ -223,7 +223,7 @@ func GetMaximumNodeFee(rp *rocketpool.RocketPool, opts *bind.CallOpts) (float64, if err := networkSettingsContract.Call(opts, value, "getMaximumNodeFee"); err != nil { return 0, fmt.Errorf("error getting maximum node fee: %w", err) } - return eth.WeiToEth(*value), nil + return math.WeiToEth(*value), nil } // Maximum node commission rate @@ -274,7 +274,7 @@ func GetTargetRethCollateralRate(rp *rocketpool.RocketPool, opts *bind.CallOpts) if err := networkSettingsContract.Call(opts, value, "getTargetRethCollateralRate"); err != nil { return 0, fmt.Errorf("error getting target rETH contract collateralization rate: %w", err) } - return eth.WeiToEth(*value), nil + return math.WeiToEth(*value), nil } // The target collateralization rate for the rETH contract as a fraction @@ -306,7 +306,7 @@ func GetNetworkPenaltyThreshold(rp *rocketpool.RocketPool, opts *bind.CallOpts) if err := networkSettingsContract.Call(opts, value, "getNodePenaltyThreshold"); err != nil { return 0, fmt.Errorf("error getting network penalty threshold: %w", err) } - return eth.WeiToEth(*value), nil + return math.WeiToEth(*value), nil } // The number of oDAO members that have to vote for a penalty expressed as a percentage @@ -338,7 +338,7 @@ func GetNetworkPenaltyPerRate(rp *rocketpool.RocketPool, opts *bind.CallOpts) (f if err := networkSettingsContract.Call(opts, value, "getPerPenaltyRate"); err != nil { return 0, fmt.Errorf("error getting network penalty per rate: %w", err) } - return eth.WeiToEth(*value), nil + return math.WeiToEth(*value), nil } // The amount a node operator is penalised for each penalty as a percentage diff --git a/bindings/settings/protocol/node.go b/bindings/settings/protocol/node.go index f54eea473..a7b327544 100644 --- a/bindings/settings/protocol/node.go +++ b/bindings/settings/protocol/node.go @@ -12,7 +12,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/shared/math" ) // Config @@ -113,7 +113,7 @@ func GetMinimumLegacyRPLStake(rp *rocketpool.RocketPool, opts *bind.CallOpts) (f if err := nodeSettingsContract.Call(opts, value, "getMinimumLegacyRPLStake"); err != nil { return 0, fmt.Errorf("error getting minimum legacy RPL stake per node: %w", err) } - return eth.WeiToEth(*value), nil + return math.WeiToEth(*value), nil } func ProposeMinimumLecacyRPLStake(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", MinimumLegacyRplStakePath), NodeSettingsContractName, MinimumLegacyRplStakePath, value, blockNumber, treeNodes, opts) @@ -145,7 +145,7 @@ func GetReducedBond(rp *rocketpool.RocketPool, opts *bind.CallOpts) (float64, er if err := nodeSettingsContract.Call(opts, value, "getReducedBond"); err != nil { return 0, fmt.Errorf("error getting reduced bond variable: %w", err) } - return eth.WeiToEth(*value), nil + return math.WeiToEth(*value), nil } func ProposeReducedBond(rp *rocketpool.RocketPool, value *big.Int, blockNumber uint32, treeNodes []types.VotingTreeNode, opts *bind.TransactOpts) (uint64, common.Hash, error) { return protocol.ProposeSetUint(rp, fmt.Sprintf("set %s", ReducedBondSettingPath), NodeSettingsContractName, ReducedBondSettingPath, value, blockNumber, treeNodes, opts) diff --git a/bindings/settings/protocol/proposals.go b/bindings/settings/protocol/proposals.go index 2f583822b..c31031044 100644 --- a/bindings/settings/protocol/proposals.go +++ b/bindings/settings/protocol/proposals.go @@ -13,7 +13,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/shared/math" ) // Config @@ -174,7 +174,7 @@ func GetProposalQuorum(rp *rocketpool.RocketPool, opts *bind.CallOpts) (float64, if err := proposalsSettingsContract.Call(opts, value, "getProposalQuorum"); err != nil { return 0, fmt.Errorf("error getting proposal quorum: %w", err) } - return eth.WeiToEth(*value), nil + return math.WeiToEth(*value), nil } // The minimum amount of voting power a proposal needs to succeed @@ -206,7 +206,7 @@ func GetProposalVetoQuorum(rp *rocketpool.RocketPool, opts *bind.CallOpts) (floa if err := proposalsSettingsContract.Call(opts, value, "getProposalVetoQuorum"); err != nil { return 0, fmt.Errorf("error getting proposal veto quorum: %w", err) } - return eth.WeiToEth(*value), nil + return math.WeiToEth(*value), nil } // The amount of voting power vetoing a proposal require to veto it diff --git a/bindings/settings/protocol/rewards.go b/bindings/settings/protocol/rewards.go index 2650add4d..ce73c4053 100644 --- a/bindings/settings/protocol/rewards.go +++ b/bindings/settings/protocol/rewards.go @@ -13,7 +13,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/shared/math" ) // Config @@ -104,7 +104,7 @@ func GetRewardsClaimersPercTotal(rp *rocketpool.RocketPool, opts *bind.CallOpts) if err := rewardsSettingsContract.Call(opts, value, "getRewardsClaimersPercTotal"); err != nil { return 0, fmt.Errorf("error getting rewards claimers total percent: %w", err) } - return eth.WeiToEth(*value), nil + return math.WeiToEth(*value), nil } // Rewards claim interval time diff --git a/bindings/settings/trustednode/members.go b/bindings/settings/trustednode/members.go index 3f71a2977..10d5e47e2 100644 --- a/bindings/settings/trustednode/members.go +++ b/bindings/settings/trustednode/members.go @@ -11,7 +11,7 @@ import ( trustednodedao "github.com/rocket-pool/smartnode/bindings/dao/trustednode" "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/shared/math" ) // Config @@ -36,13 +36,13 @@ func GetQuorum(rp *rocketpool.RocketPool, opts *bind.CallOpts) (float64, error) if err := membersSettingsContract.Call(opts, value, "getQuorum"); err != nil { return 0, fmt.Errorf("error getting member quorum threshold: %w", err) } - return eth.WeiToEth(*value), nil + return math.WeiToEth(*value), nil } func ProposeQuorum(rp *rocketpool.RocketPool, value float64, opts *bind.TransactOpts) (uint64, common.Hash, error) { - return trustednodedao.ProposeSetUint(rp, fmt.Sprintf("set %s", QuorumSettingPath), MembersSettingsContractName, QuorumSettingPath, eth.EthToWei(value), opts) + return trustednodedao.ProposeSetUint(rp, fmt.Sprintf("set %s", QuorumSettingPath), MembersSettingsContractName, QuorumSettingPath, math.EthToWei(value), opts) } func EstimateProposeQuorumGas(rp *rocketpool.RocketPool, value float64, opts *bind.TransactOpts) (gaslimit.Limits, error) { - return trustednodedao.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", QuorumSettingPath), MembersSettingsContractName, QuorumSettingPath, eth.EthToWei(value), opts) + return trustednodedao.EstimateProposeSetUintGas(rp, fmt.Sprintf("set %s", QuorumSettingPath), MembersSettingsContractName, QuorumSettingPath, math.EthToWei(value), opts) } // RPL bond required for a member diff --git a/bindings/tokens/reth.go b/bindings/tokens/reth.go index cd6acbd70..42fa52684 100644 --- a/bindings/tokens/reth.go +++ b/bindings/tokens/reth.go @@ -10,7 +10,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/shared/math" ) // @@ -147,7 +147,7 @@ func GetRETHExchangeRate(rp *rocketpool.RocketPool, opts *bind.CallOpts) (float6 if err := rocketTokenRETH.Call(opts, exchangeRate, "getExchangeRate"); err != nil { return 0, fmt.Errorf("error getting rETH exchange rate: %w", err) } - return eth.WeiToEth(*exchangeRate), nil + return math.WeiToEth(*exchangeRate), nil } // Get the total amount of ETH collateral available for rETH trades @@ -173,7 +173,7 @@ func GetRETHCollateralRate(rp *rocketpool.RocketPool, opts *bind.CallOpts) (floa if err := rocketTokenRETH.Call(opts, collateralRate, "getCollateralRate"); err != nil { return 0, fmt.Errorf("error getting rETH collateral rate: %w", err) } - return eth.WeiToEth(*collateralRate), nil + return math.WeiToEth(*collateralRate), nil } // Estimate the gas of BurnRETH diff --git a/bindings/transactions/gaslimit/gas.go b/bindings/transactions/gaslimit/gas.go index 1cc29c646..fe370cd69 100644 --- a/bindings/transactions/gaslimit/gas.go +++ b/bindings/transactions/gaslimit/gas.go @@ -3,9 +3,8 @@ package gaslimit import ( "math/big" - "github.com/rocket-pool/smartnode/bindings/utils/eth" log "github.com/rocket-pool/smartnode/shared/logger" - "github.com/rocket-pool/smartnode/shared/utils/math" + "github.com/rocket-pool/smartnode/shared/math" ) // Response for gas limits from network and from user request @@ -31,11 +30,11 @@ func (l Limits) Check(checkThreshold bool, gasThresholdGwei float64, logger *log return true } - gasThresholdWei := math.RoundUp(gasThresholdGwei*eth.WeiPerGwei, 0) + gasThresholdWei := math.RoundUp(gasThresholdGwei*math.WeiPerGwei, 0) gasThreshold := new(big.Int).SetUint64(uint64(gasThresholdWei)) if maxFeeWei.Cmp(gasThreshold) != -1 { logger.Printlnf("Current network gas price is %.2f Gwei, which is not lower than the set threshold of %.2f Gwei. "+ - "Aborting the transaction.", eth.WeiToGwei(maxFeeWei), gasThresholdGwei) + "Aborting the transaction.", math.WeiToGwei(maxFeeWei), gasThresholdGwei) return false } @@ -57,9 +56,9 @@ func (l Limits) Print(logger *log.ColorLogger, maxFeeWei *big.Int, gasLimit uint totalGasWei := new(big.Int).Mul(maxFeeWei, gas) totalSafeGasWei := new(big.Int).Mul(maxFeeWei, safeGas) logger.Printlnf("This transaction will use a max fee of %.6f Gwei, for a total of up to %.6f - %.6f ETH.", - eth.WeiToGwei(maxFeeWei), - math.RoundDown(eth.WeiToEth(totalGasWei), 6), - math.RoundDown(eth.WeiToEth(totalSafeGasWei), 6)) + math.WeiToGwei(maxFeeWei), + math.RoundDown(math.WeiToEth(totalGasWei), 6), + math.RoundDown(math.WeiToEth(totalSafeGasWei), 6)) } func (l Limits) PrintAndCheck(checkThreshold bool, gasThresholdGwei float64, logger *log.ColorLogger, maxFeeWei *big.Int, gasLimit uint64) bool { diff --git a/bindings/utils/state/network.go b/bindings/utils/state/network.go index 4d6596743..8e90363bd 100644 --- a/bindings/utils/state/network.go +++ b/bindings/utils/state/network.go @@ -11,8 +11,8 @@ import ( "github.com/rocket-pool/smartnode/bindings/minipool" "github.com/rocket-pool/smartnode/bindings/rocketpool" - "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/bindings/utils/multicall" + "github.com/rocket-pool/smartnode/shared/math" ) const ( @@ -203,9 +203,9 @@ func NewNetworkDetails(rp *rocketpool.RocketPool, contracts *NetworkContracts) ( details.PricesSubmissionFrequency = pricesSubmissionFrequency.Uint64() details.BalancesSubmissionFrequency = balancesSubmissionFrequency.Uint64() - details.ETHUtilizationRate = eth.WeiToEth(ethUtilizationRate) - details.RETHExchangeRate = eth.WeiToEth(rETHExchangeRate) - details.NodeFee = eth.WeiToEth(nodeFee) + details.ETHUtilizationRate = math.WeiToEth(ethUtilizationRate) + details.RETHExchangeRate = math.WeiToEth(rETHExchangeRate) + details.NodeFee = math.WeiToEth(nodeFee) details.BalancesBlock = balancesBlock.Uint64() details.MinipoolLaunchTimeout = minipoolLaunchTimeout details.PromotionScrubPeriod = convertToDuration(promotionScrubPeriodSeconds) diff --git a/rocketpool-cli/auction/bid-lot.go b/rocketpool-cli/auction/bid-lot.go index e68a35995..fb8a60aab 100644 --- a/rocketpool-cli/auction/bid-lot.go +++ b/rocketpool-cli/auction/bid-lot.go @@ -5,14 +5,12 @@ import ( "math/big" "strconv" - "github.com/rocket-pool/smartnode/bindings/utils/eth" - cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" - "github.com/rocket-pool/smartnode/shared/utils/math" ) func bidOnLot(lot, amount string, yes bool) error { @@ -72,7 +70,7 @@ func bidOnLot(lot, amount string, yes bool) error { // Prompt for lot selection options := make([]string, len(openLots)) for li, lot := range openLots { - options[li] = fmt.Sprintf("lot %d (%.6f RPL available @ %.6f ETH per RPL)", lot.Details.Index, math.RoundDown(eth.WeiToEth(lot.Details.RemainingRPLAmount), 6), math.RoundDown(eth.WeiToEth(lot.Details.CurrentPrice), 6)) + options[li] = fmt.Sprintf("lot %d (%.6f RPL available @ %.6f ETH per RPL)", lot.Details.Index, math.RoundDown(math.WeiToEth(lot.Details.RemainingRPLAmount), 6), math.RoundDown(math.WeiToEth(lot.Details.CurrentPrice), 6)) } selected, _ := prompt.Select("Please select a lot to bid on:", options) selectedLot = openLots[selected] @@ -87,7 +85,7 @@ func bidOnLot(lot, amount string, yes bool) error { var tmp big.Int var maxAmount big.Int tmp.Mul(selectedLot.Details.RemainingRPLAmount, selectedLot.Details.CurrentPrice) - maxAmount.Quo(&tmp, eth.EthToWei(1)) + maxAmount.Quo(&tmp, math.EthToWei(1)) amountWei = &maxAmount } else if amount != "" { @@ -97,7 +95,7 @@ func bidOnLot(lot, amount string, yes bool) error { if err != nil { return fmt.Errorf("Invalid bid amount '%s': %w", amount, err) } - amountWei = eth.EthToWei(bidAmount) + amountWei = math.EthToWei(bidAmount) } else { @@ -105,10 +103,10 @@ func bidOnLot(lot, amount string, yes bool) error { var tmp big.Int var maxAmount big.Int tmp.Mul(selectedLot.Details.RemainingRPLAmount, selectedLot.Details.CurrentPrice) - maxAmount.Quo(&tmp, eth.EthToWei(1)) + maxAmount.Quo(&tmp, math.EthToWei(1)) // Prompt for maximum amount - if prompt.Confirm("Would you like to bid the maximum amount of ETH (%.6f ETH)?", math.RoundDown(eth.WeiToEth(&maxAmount), 6)) { + if prompt.Confirm("Would you like to bid the maximum amount of ETH (%.6f ETH)?", math.RoundDown(math.WeiToEth(&maxAmount), 6)) { amountWei = &maxAmount } else { @@ -118,7 +116,7 @@ func bidOnLot(lot, amount string, yes bool) error { if err != nil { return fmt.Errorf("Invalid bid amount '%s': %w", inputAmount, err) } - amountWei = eth.EthToWei(bidAmount) + amountWei = math.EthToWei(bidAmount) } @@ -144,7 +142,7 @@ func bidOnLot(lot, amount string, yes bool) error { } // Prompt for confirmation - if prompt.Declined(yes, "Are you sure you want to bid %.6f ETH on lot %d? Bids are final and non-refundable.", math.RoundDown(eth.WeiToEth(amountWei), 6), selectedLot.Details.Index) { + if prompt.Declined(yes, "Are you sure you want to bid %.6f ETH on lot %d? Bids are final and non-refundable.", math.RoundDown(math.WeiToEth(amountWei), 6), selectedLot.Details.Index) { fmt.Println("Cancelled.") return nil } @@ -162,7 +160,7 @@ func bidOnLot(lot, amount string, yes bool) error { } // Log & return - fmt.Printf("Successfully bid %.6f ETH on lot %d.\n", math.RoundDown(eth.WeiToEth(amountWei), 6), selectedLot.Details.Index) + fmt.Printf("Successfully bid %.6f ETH on lot %d.\n", math.RoundDown(math.WeiToEth(amountWei), 6), selectedLot.Details.Index) return nil } diff --git a/rocketpool-cli/auction/claim-lot.go b/rocketpool-cli/auction/claim-lot.go index 2560fd5f4..271f4bb83 100644 --- a/rocketpool-cli/auction/claim-lot.go +++ b/rocketpool-cli/auction/claim-lot.go @@ -5,14 +5,13 @@ import ( "strconv" "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" - "github.com/rocket-pool/smartnode/bindings/utils/eth" cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" - "github.com/rocket-pool/smartnode/shared/utils/math" ) func claimFromLot(lot string, yes bool) error { @@ -78,7 +77,7 @@ func claimFromLot(lot string, yes bool) error { options := make([]string, len(claimableLots)+1) options[0] = "All available lots" for li, lot := range claimableLots { - options[li+1] = fmt.Sprintf("lot %d (%.6f ETH bid @ %.6f ETH per RPL)", lot.Details.Index, math.RoundDown(eth.WeiToEth(lot.Details.AddressBidAmount), 6), math.RoundDown(eth.WeiToEth(lot.Details.CurrentPrice), 6)) + options[li+1] = fmt.Sprintf("lot %d (%.6f ETH bid @ %.6f ETH per RPL)", lot.Details.Index, math.RoundDown(math.WeiToEth(lot.Details.AddressBidAmount), 6), math.RoundDown(math.WeiToEth(lot.Details.CurrentPrice), 6)) } selected, _ := prompt.Select("Please select a lot to claim RPL from:", options) diff --git a/rocketpool-cli/auction/lots.go b/rocketpool-cli/auction/lots.go index d1bea51ae..e219d5444 100644 --- a/rocketpool-cli/auction/lots.go +++ b/rocketpool-cli/auction/lots.go @@ -4,11 +4,9 @@ import ( "fmt" "math/big" - "github.com/rocket-pool/smartnode/bindings/utils/eth" - + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" - "github.com/rocket-pool/smartnode/shared/utils/math" ) func getLots() error { @@ -77,14 +75,14 @@ func getLots() error { fmt.Printf("Lot ID: %d\n", lot.Details.Index) fmt.Printf("Start block: %d\n", lot.Details.StartBlock) fmt.Printf("End block: %d\n", lot.Details.EndBlock) - fmt.Printf("RPL starting price: %.6f\n", math.RoundDown(eth.WeiToEth(lot.Details.StartPrice), 6)) - fmt.Printf("RPL reserve price: %.6f\n", math.RoundDown(eth.WeiToEth(lot.Details.ReservePrice), 6)) - fmt.Printf("RPL current price: %.6f\n", math.RoundDown(eth.WeiToEth(lot.Details.CurrentPrice), 6)) - fmt.Printf("Total RPL amount: %.6f\n", math.RoundDown(eth.WeiToEth(lot.Details.TotalRPLAmount), 6)) - fmt.Printf("Claimed RPL amount: %.6f\n", math.RoundDown(eth.WeiToEth(lot.Details.ClaimedRPLAmount), 6)) - fmt.Printf("Remaining RPL amount: %.6f\n", math.RoundDown(eth.WeiToEth(lot.Details.RemainingRPLAmount), 6)) - fmt.Printf("Total ETH bid: %.6f\n", math.RoundDown(eth.WeiToEth(lot.Details.TotalBidAmount), 6)) - fmt.Printf("ETH bid by node: %.6f\n", math.RoundDown(eth.WeiToEth(lot.Details.AddressBidAmount), 6)) + fmt.Printf("RPL starting price: %.6f\n", math.RoundDown(math.WeiToEth(lot.Details.StartPrice), 6)) + fmt.Printf("RPL reserve price: %.6f\n", math.RoundDown(math.WeiToEth(lot.Details.ReservePrice), 6)) + fmt.Printf("RPL current price: %.6f\n", math.RoundDown(math.WeiToEth(lot.Details.CurrentPrice), 6)) + fmt.Printf("Total RPL amount: %.6f\n", math.RoundDown(math.WeiToEth(lot.Details.TotalRPLAmount), 6)) + fmt.Printf("Claimed RPL amount: %.6f\n", math.RoundDown(math.WeiToEth(lot.Details.ClaimedRPLAmount), 6)) + fmt.Printf("Remaining RPL amount: %.6f\n", math.RoundDown(math.WeiToEth(lot.Details.RemainingRPLAmount), 6)) + fmt.Printf("Total ETH bid: %.6f\n", math.RoundDown(math.WeiToEth(lot.Details.TotalBidAmount), 6)) + fmt.Printf("ETH bid by node: %.6f\n", math.RoundDown(math.WeiToEth(lot.Details.AddressBidAmount), 6)) if lot.Details.Cleared { fmt.Printf("Cleared: yes\n") if lot.Details.RemainingRPLAmount.Cmp(big.NewInt(0)) == 0 { @@ -107,21 +105,21 @@ func getLots() error { if len(claimableLots) > 0 { fmt.Printf("%d lot(s) you have bid on have RPL available to claim:\n", len(claimableLots)) for _, lot := range claimableLots { - fmt.Printf("- lot %d (%.6f ETH bid @ %.6f ETH per RPL)\n", lot.Details.Index, math.RoundDown(eth.WeiToEth(lot.Details.AddressBidAmount), 6), math.RoundDown(eth.WeiToEth(lot.Details.CurrentPrice), 6)) + fmt.Printf("- lot %d (%.6f ETH bid @ %.6f ETH per RPL)\n", lot.Details.Index, math.RoundDown(math.WeiToEth(lot.Details.AddressBidAmount), 6), math.RoundDown(math.WeiToEth(lot.Details.CurrentPrice), 6)) } fmt.Println("") } if len(biddableLots) > 0 { fmt.Printf("%d lot(s) are open for bidding:\n", len(biddableLots)) for _, lot := range biddableLots { - fmt.Printf("- lot %d (%.6f RPL available @ %.6f ETH per RPL)\n", lot.Details.Index, math.RoundDown(eth.WeiToEth(lot.Details.RemainingRPLAmount), 6), math.RoundDown(eth.WeiToEth(lot.Details.CurrentPrice), 6)) + fmt.Printf("- lot %d (%.6f RPL available @ %.6f ETH per RPL)\n", lot.Details.Index, math.RoundDown(math.WeiToEth(lot.Details.RemainingRPLAmount), 6), math.RoundDown(math.WeiToEth(lot.Details.CurrentPrice), 6)) } fmt.Println("") } if len(recoverableLots) > 0 { fmt.Printf("%d lot(s) have unclaimed RPL ready to recover:\n", len(recoverableLots)) for _, lot := range recoverableLots { - fmt.Printf("- lot %d (%.6f RPL unclaimed)\n", lot.Details.Index, math.RoundDown(eth.WeiToEth(lot.Details.RemainingRPLAmount), 6)) + fmt.Printf("- lot %d (%.6f RPL unclaimed)\n", lot.Details.Index, math.RoundDown(math.WeiToEth(lot.Details.RemainingRPLAmount), 6)) } fmt.Println("") } diff --git a/rocketpool-cli/auction/recover-lot.go b/rocketpool-cli/auction/recover-lot.go index 2856c58c5..4eb8ffc9f 100644 --- a/rocketpool-cli/auction/recover-lot.go +++ b/rocketpool-cli/auction/recover-lot.go @@ -5,14 +5,13 @@ import ( "strconv" "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" - "github.com/rocket-pool/smartnode/bindings/utils/eth" cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" - "github.com/rocket-pool/smartnode/shared/utils/math" ) func recoverRplFromLot(lot string, yes bool) error { @@ -78,7 +77,7 @@ func recoverRplFromLot(lot string, yes bool) error { options := make([]string, len(recoverableLots)+1) options[0] = "All available lots" for li, lot := range recoverableLots { - options[li+1] = fmt.Sprintf("lot %d (%.6f RPL unclaimed)", lot.Details.Index, math.RoundDown(eth.WeiToEth(lot.Details.RemainingRPLAmount), 6)) + options[li+1] = fmt.Sprintf("lot %d (%.6f RPL unclaimed)", lot.Details.Index, math.RoundDown(math.WeiToEth(lot.Details.RemainingRPLAmount), 6)) } selected, _ := prompt.Select("Please select a lot to recover unclaimed RPL from:", options) diff --git a/rocketpool-cli/auction/status.go b/rocketpool-cli/auction/status.go index e8ab07219..3fbbffa0f 100644 --- a/rocketpool-cli/auction/status.go +++ b/rocketpool-cli/auction/status.go @@ -3,10 +3,8 @@ package auction import ( "fmt" - "github.com/rocket-pool/smartnode/bindings/utils/eth" - + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - "github.com/rocket-pool/smartnode/shared/utils/math" ) func getStatus() error { @@ -27,9 +25,9 @@ func getStatus() error { // Print & return fmt.Printf( "A total of %.6f RPL is up for auction, with %.6f RPL currently allotted and %.6f RPL remaining.\n", - math.RoundDown(eth.WeiToEth(status.TotalRPLBalance), 6), - math.RoundDown(eth.WeiToEth(status.AllottedRPLBalance), 6), - math.RoundDown(eth.WeiToEth(status.RemainingRPLBalance), 6)) + math.RoundDown(math.WeiToEth(status.TotalRPLBalance), 6), + math.RoundDown(math.WeiToEth(status.AllottedRPLBalance), 6), + math.RoundDown(math.WeiToEth(status.RemainingRPLBalance), 6)) if status.LotCounts.ClaimAvailable > 0 { fmt.Printf("%d lot(s) you have bid on have RPL available to claim!\n", status.LotCounts.ClaimAvailable) } diff --git a/rocketpool-cli/claims/claim-all.go b/rocketpool-cli/claims/claim-all.go index 493970d70..49f22736d 100644 --- a/rocketpool-cli/claims/claim-all.go +++ b/rocketpool-cli/claims/claim-all.go @@ -11,14 +11,13 @@ import ( "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" - "github.com/rocket-pool/smartnode/shared/utils/math" ) // pendingClaim represents a single category of rewards that can be claimed. @@ -38,12 +37,12 @@ func (c pendingClaim) valueString() string { switch { case hasRpl && hasEth: return fmt.Sprintf("%.6f RPL + %.6f ETH", - math.RoundDown(eth.WeiToEth(c.rplValue), 6), - math.RoundDown(eth.WeiToEth(c.ethValue), 6)) + math.RoundDown(math.WeiToEth(c.rplValue), 6), + math.RoundDown(math.WeiToEth(c.ethValue), 6)) case hasEth: - return fmt.Sprintf("%.6f ETH", math.RoundDown(eth.WeiToEth(c.ethValue), 6)) + return fmt.Sprintf("%.6f ETH", math.RoundDown(math.WeiToEth(c.ethValue), 6)) case hasRpl: - return fmt.Sprintf("%.6f RPL", math.RoundDown(eth.WeiToEth(c.rplValue), 6)) + return fmt.Sprintf("%.6f RPL", math.RoundDown(math.WeiToEth(c.rplValue), 6)) default: return "" } @@ -117,10 +116,10 @@ func claimAll(restakeAmount string, statusOnly bool, yes bool) error { } else { megapoolTotal := new(big.Int).Add(pendingRewards.RewardSplit.NodeRewards, pendingRewards.RefundValue) if megapoolTotal.Cmp(big.NewInt(0)) > 0 { - fmt.Printf(" Node share: %.6f ETH\n", math.RoundDown(eth.WeiToEth(pendingRewards.RewardSplit.NodeRewards), 6)) + fmt.Printf(" Node share: %.6f ETH\n", math.RoundDown(math.WeiToEth(pendingRewards.RewardSplit.NodeRewards), 6)) if pendingRewards.RefundValue.Cmp(big.NewInt(0)) > 0 { - fmt.Printf(" Refund value: %.6f ETH\n", math.RoundDown(eth.WeiToEth(pendingRewards.RefundValue), 6)) - fmt.Printf(" Total: %.6f ETH\n", math.RoundDown(eth.WeiToEth(megapoolTotal), 6)) + fmt.Printf(" Refund value: %.6f ETH\n", math.RoundDown(math.WeiToEth(pendingRewards.RefundValue), 6)) + fmt.Printf(" Total: %.6f ETH\n", math.RoundDown(math.WeiToEth(megapoolTotal), 6)) } fmt.Println() @@ -174,7 +173,7 @@ func claimAll(restakeAmount string, statusOnly bool, yes bool) error { color.YellowPrintf(" Could not check fee distributor balance: %s\n", err) fmt.Println() } else { - balance := eth.WeiToEth(canDistResp.Balance) + balance := math.WeiToEth(canDistResp.Balance) if balance == 0 { fmt.Println(" No balance in fee distributor.") fmt.Println() @@ -185,7 +184,7 @@ func claimAll(restakeAmount string, statusOnly bool, yes bool) error { fmt.Printf(" rETH stakers share: %.6f ETH\n", math.RoundDown(rEthShare, 6)) fmt.Println() - nodeShareWei := eth.EthToWei(canDistResp.NodeShare) + nodeShareWei := math.EthToWei(canDistResp.NodeShare) totalEthWei.Add(totalEthWei, nodeShareWei) gasLimits := canDistResp.GasLimits @@ -242,14 +241,14 @@ func claimAll(restakeAmount string, statusOnly bool, yes bool) error { second := eligibleMinipools[j] var firstAmt, secondAmt float64 if first.Status == types.Dissolved { - firstAmt = eth.WeiToEth(first.Balance) + firstAmt = math.WeiToEth(first.Balance) } else { - firstAmt = eth.WeiToEth(first.NodeShareOfBalance) + eth.WeiToEth(first.Refund) + firstAmt = math.WeiToEth(first.NodeShareOfBalance) + math.WeiToEth(first.Refund) } if second.Status == types.Dissolved { - secondAmt = eth.WeiToEth(second.Balance) + secondAmt = math.WeiToEth(second.Balance) } else { - secondAmt = eth.WeiToEth(second.NodeShareOfBalance) + eth.WeiToEth(second.Refund) + secondAmt = math.WeiToEth(second.NodeShareOfBalance) + math.WeiToEth(second.Refund) } return firstAmt > secondAmt }) @@ -257,18 +256,18 @@ func claimAll(restakeAmount string, statusOnly bool, yes bool) error { mpTotalEth := new(big.Int) for _, mp := range eligibleMinipools { if mp.Status == types.Dissolved { - fmt.Printf(" %s: %.6f ETH (dissolved, all to you)\n", mp.Address.Hex(), math.RoundDown(eth.WeiToEth(mp.Balance), 6)) + fmt.Printf(" %s: %.6f ETH (dissolved, all to you)\n", mp.Address.Hex(), math.RoundDown(math.WeiToEth(mp.Balance), 6)) mpTotalEth.Add(mpTotalEth, mp.Balance) } else { nodeAmount := new(big.Int).Add(mp.NodeShareOfBalance, mp.Refund) fmt.Printf(" %s: %.6f ETH (your share) + %.6f ETH (refund)\n", mp.Address.Hex(), - math.RoundDown(eth.WeiToEth(mp.NodeShareOfBalance), 6), - math.RoundDown(eth.WeiToEth(mp.Refund), 6)) + math.RoundDown(math.WeiToEth(mp.NodeShareOfBalance), 6), + math.RoundDown(math.WeiToEth(mp.Refund), 6)) mpTotalEth.Add(mpTotalEth, nodeAmount) } } - fmt.Printf(" Total from %d minipool(s): %.6f ETH\n", len(eligibleMinipools), math.RoundDown(eth.WeiToEth(mpTotalEth), 6)) + fmt.Printf(" Total from %d minipool(s): %.6f ETH\n", len(eligibleMinipools), math.RoundDown(math.WeiToEth(mpTotalEth), 6)) fmt.Println() totalEthWei.Add(totalEthWei, mpTotalEth) @@ -382,12 +381,12 @@ func claimAll(restakeAmount string, statusOnly bool, yes bool) error { rpl := new(big.Int).Add(&interval.CollateralRplAmount.Int, &interval.ODaoRplAmount.Int) ethAmt := new(big.Int).Add(&interval.SmoothingPoolEthAmount.Int, &interval.VoterShareEth.Int) fmt.Printf(" Interval %d: %.6f RPL, %.6f ETH\n", interval.Index, - math.RoundDown(eth.WeiToEth(rpl), 6), - math.RoundDown(eth.WeiToEth(ethAmt), 6)) + math.RoundDown(math.WeiToEth(rpl), 6), + math.RoundDown(math.WeiToEth(ethAmt), 6)) } fmt.Printf(" Total: %.6f RPL + %.6f ETH\n\n", - math.RoundDown(eth.WeiToEth(prTotalRpl), 6), - math.RoundDown(eth.WeiToEth(prTotalEth), 6)) + math.RoundDown(math.WeiToEth(prTotalRpl), 6), + math.RoundDown(math.WeiToEth(prTotalEth), 6)) totalRplWei.Add(totalRplWei, prTotalRpl) totalEthWei.Add(totalEthWei, prTotalEth) @@ -401,7 +400,7 @@ func claimAll(restakeAmount string, statusOnly bool, yes bool) error { } else if restakeAmount != "" { stakeAmt, parseErr := strconv.ParseFloat(restakeAmount, 64) if parseErr == nil && stakeAmt > 0 { - periodicRestakeAmount = eth.EthToWei(stakeAmt) + periodicRestakeAmount = math.EthToWei(stakeAmt) if periodicRestakeAmount.Cmp(prTotalRpl) > 0 { periodicRestakeAmount = prTotalRpl } @@ -450,7 +449,7 @@ func claimAll(restakeAmount string, statusOnly bool, yes bool) error { return fmt.Errorf("transaction was submitted but failed on-chain: %w", err) } if periodicRestakeAmount != nil { - color.GreenPrintf("Successfully claimed rewards and restaked %.6f RPL.\n", eth.WeiToEth(periodicRestakeAmount)) + color.GreenPrintf("Successfully claimed rewards and restaked %.6f RPL.\n", math.WeiToEth(periodicRestakeAmount)) } else { color.GreenPrintln("Successfully claimed periodic rewards.") } @@ -489,7 +488,7 @@ func claimAll(restakeAmount string, statusOnly bool, yes bool) error { fmt.Println(" No unclaimed rewards.") fmt.Println() } else { - fmt.Printf(" Unclaimed rewards: %.6f ETH\n", math.RoundDown(eth.WeiToEth(nodeStatus.UnclaimedRewards), 6)) + fmt.Printf(" Unclaimed rewards: %.6f ETH\n", math.RoundDown(math.WeiToEth(nodeStatus.UnclaimedRewards), 6)) fmt.Println(" (Rewards distributed previously but not yet sent to withdrawal address)") fmt.Println() totalEthWei.Add(totalEthWei, nodeStatus.UnclaimedRewards) @@ -542,7 +541,7 @@ func claimAll(restakeAmount string, statusOnly bool, yes bool) error { } else { creditBalance := nodeStatus.CreditBalance fmt.Printf(" Credit balance: %.6f ETH (the equivalent amount in rETH will be transferred to %s)\n", - math.RoundDown(eth.WeiToEth(creditBalance), 6), nodeStatus.PrimaryWithdrawalAddress) + math.RoundDown(math.WeiToEth(creditBalance), 6), nodeStatus.PrimaryWithdrawalAddress) totalEthWei.Add(totalEthWei, creditBalance) canWithdraw, canErr := rp.CanNodeWithdrawCredit(creditBalance) @@ -579,7 +578,7 @@ func claimAll(restakeAmount string, statusOnly bool, yes bool) error { if _, err = rp.WaitForTransaction(response.TxHash); err != nil { return fmt.Errorf("transaction was submitted but failed on-chain: %w", err) } - color.GreenPrintf("Successfully withdrew %.6f credit as rETH.\n", math.RoundDown(eth.WeiToEth(withdrawAmount), 6)) + color.GreenPrintf("Successfully withdrew %.6f credit as rETH.\n", math.RoundDown(math.WeiToEth(withdrawAmount), 6)) return nil }, }) @@ -596,7 +595,7 @@ func claimAll(restakeAmount string, statusOnly bool, yes bool) error { fmt.Println() } else { ethOnBehalf := nodeStatus.EthOnBehalfBalance - fmt.Printf(" Staked ETH on behalf: %.6f ETH\n", math.RoundDown(eth.WeiToEth(ethOnBehalf), 6)) + fmt.Printf(" Staked ETH on behalf: %.6f ETH\n", math.RoundDown(math.WeiToEth(ethOnBehalf), 6)) fmt.Println() totalEthWei.Add(totalEthWei, ethOnBehalf) @@ -636,7 +635,7 @@ func claimAll(restakeAmount string, statusOnly bool, yes bool) error { if _, err = rp.WaitForTransaction(response.TxHash); err != nil { return fmt.Errorf("transaction was submitted but failed on-chain: %w", err) } - color.GreenPrintf("Successfully withdrew %.6f staked ETH.\n", math.RoundDown(eth.WeiToEth(withdrawAmount), 6)) + color.GreenPrintf("Successfully withdrew %.6f staked ETH.\n", math.RoundDown(math.WeiToEth(withdrawAmount), 6)) return nil }, }) @@ -665,11 +664,11 @@ func claimAll(restakeAmount string, statusOnly bool, yes bool) error { pdaoRplTotal.Add(pdaoRplTotal, bondTotal) fmt.Printf(" Proposal %d: %.6f RPL (unlock) + %.6f RPL (reward)\n", bond.ProposalID, - math.RoundDown(eth.WeiToEth(bond.UnlockAmount), 6), - math.RoundDown(eth.WeiToEth(bond.RewardAmount), 6)) + math.RoundDown(math.WeiToEth(bond.UnlockAmount), 6), + math.RoundDown(math.WeiToEth(bond.RewardAmount), 6)) } fmt.Printf(" Total: %.6f RPL from %d proposal(s)\n\n", - math.RoundDown(eth.WeiToEth(pdaoRplTotal), 6), len(bondsResponse.ClaimableBonds)) + math.RoundDown(math.WeiToEth(pdaoRplTotal), 6), len(bondsResponse.ClaimableBonds)) totalRplWei.Add(totalRplWei, pdaoRplTotal) // Accumulate gas @@ -728,8 +727,8 @@ func claimAll(restakeAmount string, statusOnly bool, yes bool) error { color.GreenPrintf("============================================================\n") color.GreenPrintf(" Totals \n") color.GreenPrintf("============================================================\n") - fmt.Printf(" ETH: %.6f\n", math.RoundDown(eth.WeiToEth(totalEthWei), 6)) - fmt.Printf(" RPL: %.6f\n\n", math.RoundDown(eth.WeiToEth(totalRplWei), 6)) + fmt.Printf(" ETH: %.6f\n", math.RoundDown(math.WeiToEth(totalEthWei), 6)) + fmt.Printf(" RPL: %.6f\n\n", math.RoundDown(math.WeiToEth(totalRplWei), 6)) if statusOnly { if len(claims) > 0 { @@ -807,7 +806,7 @@ func claimAll(restakeAmount string, statusOnly bool, yes bool) error { if !periodicRestakeResolved && periodicClaimRpl != nil { for i := range selectedClaims { if selectedClaims[i].id == periodicID { - availableRpl := eth.WeiToEth(periodicClaimRpl) + availableRpl := math.WeiToEth(periodicClaimRpl) amountOptions := []string{ "None (do not restake any RPL)", fmt.Sprintf("All %.6f RPL", availableRpl), @@ -830,7 +829,7 @@ func claimAll(restakeAmount string, statusOnly bool, yes bool) error { } else if stakeAmount > availableRpl { fmt.Println("Amount must be less than or equal to the RPL available to claim.") } else { - periodicRestakeAmount = eth.EthToWei(stakeAmount) + periodicRestakeAmount = math.EthToWei(stakeAmount) break } } diff --git a/rocketpool-cli/cli/validation.go b/rocketpool-cli/cli/validation.go index b350c4885..9e052293c 100644 --- a/rocketpool-cli/cli/validation.go +++ b/rocketpool-cli/cli/validation.go @@ -14,9 +14,9 @@ import ( "github.com/urfave/cli/v3" "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" hexutils "github.com/rocket-pool/smartnode/shared/hex" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/passwords" ) @@ -402,7 +402,7 @@ func ValidateFloat(rawEnabled bool, name string, value string, isFraction bool, floatValue = val } - trueVal := eth.EthToWei(floatValue) + trueVal := math.EthToWei(floatValue) fmt.Println("Your value will be multiplied by 10^18 to be used in the contracts, which results in:") fmt.Println() fmt.Printf("\t[%s]\n", trueVal.String()) diff --git a/rocketpool-cli/megapool/claim.go b/rocketpool-cli/megapool/claim.go index 5e89f50d0..1e65e5d4a 100644 --- a/rocketpool-cli/megapool/claim.go +++ b/rocketpool-cli/megapool/claim.go @@ -4,12 +4,11 @@ import ( "fmt" "math/big" - "github.com/rocket-pool/smartnode/bindings/utils/eth" cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - "github.com/rocket-pool/smartnode/shared/utils/math" ) func claim(yes bool) error { @@ -27,9 +26,9 @@ func claim(yes bool) error { } if megapoolDetails.Megapool.RefundValue != nil && megapoolDetails.Megapool.RefundValue.Cmp(big.NewInt(0)) > 0 { - fmt.Printf("You have %.6f ETH of megapool refund to claim.\n", math.RoundDown(eth.WeiToEth(megapoolDetails.Megapool.RefundValue), 6)) + fmt.Printf("You have %.6f ETH of megapool refund to claim.\n", math.RoundDown(math.WeiToEth(megapoolDetails.Megapool.RefundValue), 6)) if megapoolDetails.Megapool.NodeDebt != nil && megapoolDetails.Megapool.NodeDebt.Cmp(big.NewInt(0)) > 0 { - fmt.Printf("You have %.6f ETH of node debt to repay. This will be deducted from your refund.\n\n", math.RoundDown(eth.WeiToEth(megapoolDetails.Megapool.NodeDebt), 6)) + fmt.Printf("You have %.6f ETH of node debt to repay. This will be deducted from your refund.\n\n", math.RoundDown(math.WeiToEth(megapoolDetails.Megapool.NodeDebt), 6)) } } else { fmt.Println("You have no megapool refund to claim.") diff --git a/rocketpool-cli/megapool/deposit.go b/rocketpool-cli/megapool/deposit.go index 6eb0def10..ba4e02c7f 100644 --- a/rocketpool-cli/megapool/deposit.go +++ b/rocketpool-cli/megapool/deposit.go @@ -7,15 +7,13 @@ import ( "golang.org/x/sync/errgroup" - "github.com/rocket-pool/smartnode/bindings/utils/eth" - cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" - "github.com/rocket-pool/smartnode/shared/utils/math" ) // Config @@ -119,17 +117,17 @@ func nodeMegapoolDeposit(count uint64, expressTickets int64, yes bool) error { lastBondAdded = bondRequirementResponse.BondRequirement // Find the bond requirement for the next validator nextBondRequirement := bondRequirementResponse.BondRequirement.Sub(bondRequirementResponse.BondRequirement, bondedEth) - if nextBondRequirement.Cmp(eth.EthToWei(1)) < 0 { - nextBondRequirement = eth.EthToWei(1) - } else if nextBondRequirement.Cmp(eth.EthToWei(32)) > 0 { - nextBondRequirement = eth.EthToWei(32) + if nextBondRequirement.Cmp(math.EthToWei(1)) < 0 { + nextBondRequirement = math.EthToWei(1) + } else if nextBondRequirement.Cmp(math.EthToWei(32)) > 0 { + nextBondRequirement = math.EthToWei(32) } totalBondRequirement = totalBondRequirement.Add(totalBondRequirement, nextBondRequirement) } - totalBondRequirementEth := eth.WeiToEth(totalBondRequirement) + totalBondRequirementEth := math.WeiToEth(totalBondRequirement) // Show the node bond and the total bond requirement - fmt.Printf("The node is currently bonded with %.2f ETH.\n", eth.WeiToEth(megapoolBondedEth)) + fmt.Printf("The node is currently bonded with %.2f ETH.\n", math.WeiToEth(megapoolBondedEth)) fmt.Printf("The total bond requirement is %.2f ETH.\n", totalBondRequirementEth) fmt.Println() @@ -193,12 +191,12 @@ func nodeMegapoolDeposit(count uint64, expressTickets int64, yes bool) error { fmt.Println("The node has debt. You must repay the debt before creating a new validator. Use the `rocketpool megapool repay-debt` command to repay the debt.") } if canDeposit.InsufficientBalanceWithoutCredit { - nodeBalance := eth.WeiToEth(canDeposit.NodeBalance) - fmt.Printf("There is not enough ETH in the staking pool (%.2f ETH available) to use your credit balance and you don't have enough ETH in your wallet (%.6f ETH) to cover the remaining deposit amount. If you want to continue creating a megapool validator, you will either need to wait for the staking pool to have more ETH deposited or add more ETH to your node wallet.", eth.WeiToEth(canDeposit.DepositBalance), nodeBalance) + nodeBalance := math.WeiToEth(canDeposit.NodeBalance) + fmt.Printf("There is not enough ETH in the staking pool (%.2f ETH available) to use your credit balance and you don't have enough ETH in your wallet (%.6f ETH) to cover the remaining deposit amount. If you want to continue creating a megapool validator, you will either need to wait for the staking pool to have more ETH deposited or add more ETH to your node wallet.", math.WeiToEth(canDeposit.DepositBalance), nodeBalance) } if canDeposit.InsufficientBalance { - nodeBalance := eth.WeiToEth(canDeposit.NodeBalance) - creditBalance := eth.WeiToEth(canDeposit.CreditBalance) + nodeBalance := math.WeiToEth(canDeposit.NodeBalance) + creditBalance := math.WeiToEth(canDeposit.CreditBalance) fmt.Printf("The node's balance of %.6f ETH and credit balance of %.6f ETH are not enough to create %d megapool validator(s) with a total %.1f ETH bond.", nodeBalance, creditBalance, count, totalBondRequirementEth) @@ -214,7 +212,7 @@ func nodeMegapoolDeposit(count uint64, expressTickets int64, yes bool) error { useCreditBalance := false totalAmountWei := totalBondRequirement - fmt.Printf("Your credit balance is %.2f ETH. (Credit in addition to ETH staked on your behalf).\n", eth.WeiToEth(canDeposit.CreditBalance)) + fmt.Printf("Your credit balance is %.2f ETH. (Credit in addition to ETH staked on your behalf).\n", math.WeiToEth(canDeposit.CreditBalance)) if canDeposit.CreditBalance.Cmp(big.NewInt(0)) > 0 { if canDeposit.CanUseCredit { useCreditBalance = true @@ -222,9 +220,9 @@ func nodeMegapoolDeposit(count uint64, expressTickets int64, yes bool) error { usableCredit := canDeposit.UsableCreditBalance remainingAmount := big.NewInt(0).Sub(totalAmountWei, usableCredit) if remainingAmount.Cmp(big.NewInt(0)) > 0 { - fmt.Printf("This deposit will use %.6f ETH from your credit balance plus ETH staked on your behalf and %.6f ETH from your node wallet.\n\n", eth.WeiToEth(usableCredit), eth.WeiToEth(remainingAmount)) + fmt.Printf("This deposit will use %.6f ETH from your credit balance plus ETH staked on your behalf and %.6f ETH from your node wallet.\n\n", math.WeiToEth(usableCredit), math.WeiToEth(remainingAmount)) } else { - fmt.Printf("This deposit will use %.6f ETH from your credit balance plus ETH staked on your behalf and will not require any ETH from your node wallet.\n\n", eth.WeiToEth(usableCredit)) + fmt.Printf("This deposit will use %.6f ETH from your credit balance plus ETH staked on your behalf and will not require any ETH from your node wallet.\n\n", math.WeiToEth(usableCredit)) } } else { color.YellowPrintln("NOTE: Your credit balance cannot currently be used to create a new megapool validator.") @@ -270,7 +268,7 @@ func nodeMegapoolDeposit(count uint64, expressTickets int64, yes bool) error { // Prompt for confirmation if prompt.Declined(yes, "You are about to deposit %.6f ETH to create %d new megapool validator(s).\n%s", - math.RoundDown(eth.WeiToEth(totalBondRequirement), 6), + math.RoundDown(math.WeiToEth(totalBondRequirement), 6), count, color.Yellow("ARE YOU SURE YOU WANT TO DO THIS?"), ) { @@ -294,7 +292,7 @@ func nodeMegapoolDeposit(count uint64, expressTickets int64, yes bool) error { // Log & return fmt.Printf("The node deposit of %.6f ETH total was made successfully!\n", - math.RoundDown(eth.WeiToEth(totalBondRequirement), 6)) + math.RoundDown(math.WeiToEth(totalBondRequirement), 6)) fmt.Printf("Validator pubkeys:\n") for i, pubkey := range response.ValidatorPubkeys { fmt.Printf(" %d. %s\n", i+1, pubkey.Hex()) diff --git a/rocketpool-cli/megapool/distribute.go b/rocketpool-cli/megapool/distribute.go index 21df76488..65c868760 100644 --- a/rocketpool-cli/megapool/distribute.go +++ b/rocketpool-cli/megapool/distribute.go @@ -4,9 +4,9 @@ import ( "fmt" "math/big" - "github.com/rocket-pool/smartnode/bindings/utils/eth" cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" @@ -76,7 +76,7 @@ func distribute(yes bool) error { return nil } // Print rewards - fmt.Printf("You're about to claim pending rewards from the megapool. The rewards will be distributed to the node's withdrawal address. The node share of rewards is %.4f ETH and the refund value is %.4f ETH.", eth.WeiToEth(pendingRewards.RewardSplit.NodeRewards), eth.WeiToEth(pendingRewards.RefundValue)) + fmt.Printf("You're about to claim pending rewards from the megapool. The rewards will be distributed to the node's withdrawal address. The node share of rewards is %.4f ETH and the refund value is %.4f ETH.", math.WeiToEth(pendingRewards.RewardSplit.NodeRewards), math.WeiToEth(pendingRewards.RefundValue)) fmt.Println() // Assign max fees diff --git a/rocketpool-cli/megapool/reduce-bond.go b/rocketpool-cli/megapool/reduce-bond.go index fc44c65f5..73692b802 100644 --- a/rocketpool-cli/megapool/reduce-bond.go +++ b/rocketpool-cli/megapool/reduce-bond.go @@ -4,12 +4,11 @@ import ( "fmt" "strconv" - "github.com/rocket-pool/smartnode/bindings/utils/eth" cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - "github.com/rocket-pool/smartnode/shared/utils/math" ) func reduceBond(yes bool) error { @@ -27,14 +26,14 @@ func reduceBond(yes bool) error { } fmt.Printf("Current active validators: %d\n", megapoolDetails.Megapool.ActiveValidatorCount) - fmt.Printf("Current megapool bond: %.6f ETH\n", math.RoundDown(eth.WeiToEth(megapoolDetails.Megapool.NodeBond), 6)) - fmt.Printf("Current bond requirements for active validators: %.6f ETH\n", math.RoundDown(eth.WeiToEth(megapoolDetails.Megapool.BondRequirement), 6)) + fmt.Printf("Current megapool bond: %.6f ETH\n", math.RoundDown(math.WeiToEth(megapoolDetails.Megapool.NodeBond), 6)) + fmt.Printf("Current bond requirements for active validators: %.6f ETH\n", math.RoundDown(math.WeiToEth(megapoolDetails.Megapool.BondRequirement), 6)) fmt.Println() var amount float64 // If current node bond is higher than the bond requirement, ask if the user wants to reduce the bond if megapoolDetails.Megapool.NodeBond.Cmp(megapoolDetails.Megapool.BondRequirement) > 0 { - maxAmountInEth := eth.WeiToEth(megapoolDetails.Megapool.NodeBond.Sub(megapoolDetails.Megapool.NodeBond, megapoolDetails.Megapool.BondRequirement)) + maxAmountInEth := math.WeiToEth(megapoolDetails.Megapool.NodeBond.Sub(megapoolDetails.Megapool.NodeBond, megapoolDetails.Megapool.BondRequirement)) fmt.Printf("You have %.6f of excess bond.\n", maxAmountInEth) if prompt.Confirm("Do you want to reduce %.6f ETH of your node bond?", maxAmountInEth) { // Convert maxAmountInEth to string @@ -52,7 +51,7 @@ func reduceBond(yes bool) error { return nil } - amountWei := eth.EthToWei(amount) + amountWei := math.EthToWei(amount) // Check megapool debt can be repaid canReduceBond, err := rp.CanReduceBond(amountWei) if err != nil { @@ -73,7 +72,7 @@ func reduceBond(yes bool) error { } // Prompt for confirmation - if prompt.Declined(yes, "Are you sure you want to reduce %.6f of the megapool bond?", math.RoundDown(eth.WeiToEth(amountWei), 6)) { + if prompt.Declined(yes, "Are you sure you want to reduce %.6f of the megapool bond?", math.RoundDown(math.WeiToEth(amountWei), 6)) { fmt.Println("Cancelled.") return nil } @@ -91,7 +90,7 @@ func reduceBond(yes bool) error { } // Log & return - fmt.Printf("Successfully reduced %.6f of megapool bond.\n", math.RoundDown(eth.WeiToEth(amountWei), 6)) + fmt.Printf("Successfully reduced %.6f of megapool bond.\n", math.RoundDown(math.WeiToEth(amountWei), 6)) return nil } diff --git a/rocketpool-cli/megapool/repay-debt.go b/rocketpool-cli/megapool/repay-debt.go index f5bdb33e5..d152314c8 100644 --- a/rocketpool-cli/megapool/repay-debt.go +++ b/rocketpool-cli/megapool/repay-debt.go @@ -5,12 +5,11 @@ import ( "math/big" "strconv" - "github.com/rocket-pool/smartnode/bindings/utils/eth" cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - "github.com/rocket-pool/smartnode/shared/utils/math" ) func repayDebt(yes bool) error { @@ -27,7 +26,7 @@ func repayDebt(yes bool) error { return err } if megapoolDetails.Megapool.NodeDebt != nil && megapoolDetails.Megapool.NodeDebt.Cmp(big.NewInt(0)) > 0 { - fmt.Printf("You have %.6f ETH of megapool debt.\n", math.RoundDown(eth.WeiToEth(megapoolDetails.Megapool.NodeDebt), 6)) + fmt.Printf("You have %.6f ETH of megapool debt.\n", math.RoundDown(math.WeiToEth(megapoolDetails.Megapool.NodeDebt), 6)) } else { fmt.Println("You have no megapool debt.") return nil @@ -41,7 +40,7 @@ func repayDebt(yes bool) error { return fmt.Errorf("Invalid amount '%s': %w\n", amountStr, err) } - amountWei := eth.EthToWei(amount) + amountWei := math.EthToWei(amount) // Check megapool debt can be repaid canRepay, err := rp.CanRepayDebt(amountWei) if err != nil { @@ -65,7 +64,7 @@ func repayDebt(yes bool) error { } // Prompt for confirmation - if prompt.Declined(yes, "Are you sure you want to repay %.6f ETH of megapool debt?", math.RoundDown(eth.WeiToEth(amountWei), 6)) { + if prompt.Declined(yes, "Are you sure you want to repay %.6f ETH of megapool debt?", math.RoundDown(math.WeiToEth(amountWei), 6)) { fmt.Println("Cancelled.") return nil } @@ -83,7 +82,7 @@ func repayDebt(yes bool) error { } // Log & return - fmt.Printf("Successfully repaid %.6f ETH of megapool debt.\n", math.RoundDown(eth.WeiToEth(amountWei), 6)) + fmt.Printf("Successfully repaid %.6f ETH of megapool debt.\n", math.RoundDown(math.WeiToEth(amountWei), 6)) return nil } diff --git a/rocketpool-cli/megapool/status.go b/rocketpool-cli/megapool/status.go index 52f056839..f73b26b9e 100644 --- a/rocketpool-cli/megapool/status.go +++ b/rocketpool-cli/megapool/status.go @@ -5,13 +5,12 @@ import ( "math/big" "sort" - "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/shared/types/api" cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - "github.com/rocket-pool/smartnode/shared/utils/math" ) func getStatus() error { @@ -96,30 +95,30 @@ func getStatus() error { if !status.Megapool.DelegateExpired { totalBond := new(big.Int).Mul(status.Megapool.NodeBond, big.NewInt(8)) rpBond := new(big.Int).Sub(totalBond, status.Megapool.NodeBond) - fmt.Printf("The megapool has %6f node bonded ETH.\n", math.RoundDown(eth.WeiToEth(status.Megapool.NodeBond), 6)) - fmt.Printf("The megapool has %6f of protocol bonded ETH for a total of %6f of ETH capital.\n", math.RoundDown(eth.WeiToEth(rpBond), 6), math.RoundDown(eth.WeiToEth(totalBond), 6)) - fmt.Printf("Megapool balance (EL): %6f ETH\n", math.RoundDown(eth.WeiToEth(status.Megapool.Balances.ETH), 6)) + fmt.Printf("The megapool has %6f node bonded ETH.\n", math.RoundDown(math.WeiToEth(status.Megapool.NodeBond), 6)) + fmt.Printf("The megapool has %6f of protocol bonded ETH for a total of %6f of ETH capital.\n", math.RoundDown(math.WeiToEth(rpBond), 6), math.RoundDown(math.WeiToEth(totalBond), 6)) + fmt.Printf("Megapool balance (EL): %6f ETH\n", math.RoundDown(math.WeiToEth(status.Megapool.Balances.ETH), 6)) if status.Megapool.NodeDebt.Cmp(big.NewInt(0)) > 0 { - fmt.Printf("The megapool debt is %.6f ETH.\n", math.RoundDown(eth.WeiToEth(status.Megapool.NodeDebt), 6)) + fmt.Printf("The megapool debt is %.6f ETH.\n", math.RoundDown(math.WeiToEth(status.Megapool.NodeDebt), 6)) } if status.Megapool.RefundValue.Cmp(big.NewInt(0)) > 0 { - fmt.Printf("The megapool refund value is %.6f ETH.\n", math.RoundDown(eth.WeiToEth(status.Megapool.RefundValue), 6)) + fmt.Printf("The megapool refund value is %.6f ETH.\n", math.RoundDown(math.WeiToEth(status.Megapool.RefundValue), 6)) } if status.Megapool.ExitingValidatorCount > 0 { fmt.Printf("The megapool has %d validators exiting. You'll be able to see claimable rewards once the exit process is completed.", status.Megapool.ExitingValidatorCount) fmt.Println() } else { if status.Megapool.PendingRewards.Cmp(big.NewInt(0)) > 0 { - fmt.Printf("The megapool has %.6f ETH in pending rewards to claim.\n", math.RoundDown(eth.WeiToEth(status.Megapool.PendingRewardSplit.NodeRewards), 6)) + fmt.Printf("The megapool has %.6f ETH in pending rewards to claim.\n", math.RoundDown(math.WeiToEth(status.Megapool.PendingRewardSplit.NodeRewards), 6)) } else { fmt.Println("The megapool does not have any pending rewards to claim.") } } - fmt.Printf("Beacon balance (CL): %6f ETH\n", math.RoundDown(eth.WeiToEth(beaconBalances.TotalBeaconBalance), 6)) - fmt.Printf("Your portion: %6f ETH\n", math.RoundDown(eth.WeiToEth(beaconBalances.NodeShareOfCLBalance), 6)) + fmt.Printf("Beacon balance (CL): %6f ETH\n", math.RoundDown(math.WeiToEth(beaconBalances.TotalBeaconBalance), 6)) + fmt.Printf("Your portion: %6f ETH\n", math.RoundDown(math.WeiToEth(beaconBalances.NodeShareOfCLBalance), 6)) - networkCommission := math.RoundDown(eth.WeiToEth(status.Megapool.NodeShare)*100, 6) - effectiveNodeShare := math.RoundDown(eth.WeiToEth(status.Megapool.RevenueSplit.NodeShare)*100, 6) + networkCommission := math.RoundDown(math.WeiToEth(status.Megapool.NodeShare)*100, 6) + effectiveNodeShare := math.RoundDown(math.WeiToEth(status.Megapool.RevenueSplit.NodeShare)*100, 6) fmt.Printf("Current network commission: %.6f%%\n", networkCommission) if networkCommission != effectiveNodeShare { @@ -224,7 +223,7 @@ func printValidatorDetails(validator api.MegapoolValidatorDetails, status string fmt.Printf("Validator active: no\n") } - beaconBalance := math.RoundDown(eth.WeiToEth(big.NewInt(int64(validator.BeaconStatus.Balance*uint64(eth.WeiPerGwei)))), 6) + beaconBalance := math.RoundDown(math.WeiToEth(big.NewInt(int64(validator.BeaconStatus.Balance*uint64(math.WeiPerGwei)))), 6) if status == "Staking" { fmt.Printf("Megapool Validator ID: %d\n", validator.ValidatorId) diff --git a/rocketpool-cli/minipool/close.go b/rocketpool-cli/minipool/close.go index 7c2867122..31048d05b 100644 --- a/rocketpool-cli/minipool/close.go +++ b/rocketpool-cli/minipool/close.go @@ -9,16 +9,15 @@ import ( "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" - "github.com/rocket-pool/smartnode/shared/utils/math" ) func closeMinipools(minipool string, confirmSlashing, yes, bundle bool) error { @@ -157,9 +156,9 @@ func closeMinipools(minipool string, confirmSlashing, yes, bundle bool) error { options[0] = "All available minipools" for mi, minipool := range closableMinipools { if minipool.MinipoolStatus == types.Dissolved { - options[mi+1] = fmt.Sprintf("%s (%.6f ETH will be returned)", minipool.Address.Hex(), math.RoundDown(eth.WeiToEth(minipool.Balance), 6)) + options[mi+1] = fmt.Sprintf("%s (%.6f ETH will be returned)", minipool.Address.Hex(), math.RoundDown(math.WeiToEth(minipool.Balance), 6)) } else { - options[mi+1] = fmt.Sprintf("%s (%.6f ETH available, %.6f ETH is yours plus a refund of %.6f ETH)", minipool.Address.Hex(), math.RoundDown(eth.WeiToEth(minipool.Balance), 6), math.RoundDown(eth.WeiToEth(minipool.NodeShare), 6), math.RoundDown(eth.WeiToEth(minipool.Refund), 6)) + options[mi+1] = fmt.Sprintf("%s (%.6f ETH available, %.6f ETH is yours plus a refund of %.6f ETH)", minipool.Address.Hex(), math.RoundDown(math.WeiToEth(minipool.Balance), 6), math.RoundDown(math.WeiToEth(minipool.NodeShare), 6), math.RoundDown(math.WeiToEth(minipool.Refund), 6)) } } selected, _ := prompt.Select("Please select a minipool to close:", options) @@ -192,9 +191,9 @@ func closeMinipools(minipool string, confirmSlashing, yes, bundle bool) error { } // Force confirmation of slashable minipools - eight := eth.EthToWei(8) - yellowThreshold := eth.EthToWei(31.5) - thirtyTwo := eth.EthToWei(32) + eight := math.EthToWei(8) + yellowThreshold := math.EthToWei(31.5) + thirtyTwo := math.EthToWei(32) for _, minipool := range selectedMinipools { // Dissolved minipools can always be closed if minipool.MinipoolStatus == types.Dissolved { @@ -204,14 +203,14 @@ func closeMinipools(minipool string, confirmSlashing, yes, bundle bool) error { distributableBalance := big.NewInt(0).Sub(minipool.Balance, minipool.Refund) // If it's under 8, it shouldn't be closed, and must be distributed. if distributableBalance.Cmp(eight) < 0 { - fmt.Printf("Cannot close minipool %s: it has an effective balance of %.6f ETH which is too low to close the minipool. Please run `rocketpool minipool distribute-balance` on it instead.\n", minipool.Address.Hex(), math.RoundDown(eth.WeiToEth(distributableBalance), 6)) + fmt.Printf("Cannot close minipool %s: it has an effective balance of %.6f ETH which is too low to close the minipool. Please run `rocketpool minipool distribute-balance` on it instead.\n", minipool.Address.Hex(), math.RoundDown(math.WeiToEth(distributableBalance), 6)) return nil } // If there isn't enough eth to pay back rETH holders, warn that RPL and ETH will both be penalized if distributableBalance.Cmp(minipool.UserDepositBalance) < 0 { // Less than the user deposit balance, ETH + RPL will be slashed - color.RedPrintf("WARNING: Minipool %s has a distributable balance of %.6f ETH which is lower than the amount borrowed from the staking pool (%.6f ETH).\n", minipool.Address.Hex(), math.RoundDown(eth.WeiToEth(distributableBalance), 6), math.RoundDown(eth.WeiToEth(minipool.UserDepositBalance), 6)) + color.RedPrintf("WARNING: Minipool %s has a distributable balance of %.6f ETH which is lower than the amount borrowed from the staking pool (%.6f ETH).\n", minipool.Address.Hex(), math.RoundDown(math.WeiToEth(distributableBalance), 6), math.RoundDown(math.WeiToEth(minipool.UserDepositBalance), 6)) color.RedPrintln("Please visit the Rocket Pool Discord's #support channel (https://discord.gg/rocketpool) if you are not expecting this.") if !confirmSlashing { fmt.Println() @@ -229,7 +228,7 @@ func closeMinipools(minipool string, confirmSlashing, yes, bundle bool) error { if distributableBalance.Cmp(yellowThreshold) < 0 { // More than the user deposit balance but less than 31.5, ETH will be slashed with a red warning - if !prompt.ConfirmWithIAgree("%s", color.RedSprintf("WARNING: Minipool %s has a distributable balance of %.6f ETH. Closing it in this state WILL RESULT in a loss of ETH. You will only receive %.6f ETH back. Please confirm you understand this and want to continue closing the minipool.", minipool.Address.Hex(), math.RoundDown(eth.WeiToEth(distributableBalance), 6), math.RoundDown(eth.WeiToEth(minipool.NodeShare), 6))) { + if !prompt.ConfirmWithIAgree("%s", color.RedSprintf("WARNING: Minipool %s has a distributable balance of %.6f ETH. Closing it in this state WILL RESULT in a loss of ETH. You will only receive %.6f ETH back. Please confirm you understand this and want to continue closing the minipool.", minipool.Address.Hex(), math.RoundDown(math.WeiToEth(distributableBalance), 6), math.RoundDown(math.WeiToEth(minipool.NodeShare), 6))) { fmt.Println("Cancelled.") return nil } @@ -238,7 +237,7 @@ func closeMinipools(minipool string, confirmSlashing, yes, bundle bool) error { } if distributableBalance.Cmp(thirtyTwo) < 0 { // More than 31.5 but less than 32, ETH will be slashed with a yellow warning - if !prompt.ConfirmYellow("WARNING: Minipool %s has a distributable balance of %.6f ETH. Closing it in this state WILL RESULT in a loss of ETH. You will only receive %.6f ETH back. Please confirm you understand this and want to continue closing the minipool.", minipool.Address.Hex(), math.RoundDown(eth.WeiToEth(distributableBalance), 6), math.RoundDown(eth.WeiToEth(minipool.NodeShare), 6)) { + if !prompt.ConfirmYellow("WARNING: Minipool %s has a distributable balance of %.6f ETH. Closing it in this state WILL RESULT in a loss of ETH. You will only receive %.6f ETH back. Please confirm you understand this and want to continue closing the minipool.", minipool.Address.Hex(), math.RoundDown(math.WeiToEth(distributableBalance), 6), math.RoundDown(math.WeiToEth(minipool.NodeShare), 6)) { fmt.Println("Cancelled.") return nil } diff --git a/rocketpool-cli/minipool/distribute.go b/rocketpool-cli/minipool/distribute.go index 3ea26df50..f77e1c2dd 100644 --- a/rocketpool-cli/minipool/distribute.go +++ b/rocketpool-cli/minipool/distribute.go @@ -10,15 +10,14 @@ import ( "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" - "github.com/rocket-pool/smartnode/shared/utils/math" ) const ( @@ -45,7 +44,7 @@ func distributeBalance(minipool string, threshold float64, yes bool) error { versionTooLowMinipools := []api.MinipoolBalanceDistributionDetails{} balanceLessThanRefundMinipools := []api.MinipoolBalanceDistributionDetails{} balanceTooBigMinipools := []api.MinipoolBalanceDistributionDetails{} - finalizationAmount := eth.EthToWei(finalizationThreshold) + finalizationAmount := math.EthToWei(finalizationThreshold) for _, mp := range details.Details { if mp.CanDistribute { @@ -105,9 +104,9 @@ func distributeBalance(minipool string, threshold float64, yes bool) error { for _, mp := range eligibleMinipools { var amount float64 if mp.Status == types.Dissolved { - amount = math.RoundDown(eth.WeiToEth(mp.Balance), 6) + amount = math.RoundDown(math.WeiToEth(mp.Balance), 6) } else { - amount = math.RoundDown(eth.WeiToEth(mp.NodeShareOfBalance), 6) + math.RoundDown(eth.WeiToEth(mp.Refund), 6) + amount = math.RoundDown(math.WeiToEth(mp.NodeShareOfBalance), 6) + math.RoundDown(math.WeiToEth(mp.Refund), 6) } if amount > threshold { @@ -129,16 +128,16 @@ func distributeBalance(minipool string, threshold float64, yes bool) error { var firstAmount float64 if firstDetails.Status == types.Dissolved { - firstAmount = math.RoundDown(eth.WeiToEth(firstDetails.Balance), 6) + firstAmount = math.RoundDown(math.WeiToEth(firstDetails.Balance), 6) } else { - firstAmount = math.RoundDown(eth.WeiToEth(firstDetails.NodeShareOfBalance), 6) + math.RoundDown(eth.WeiToEth(firstDetails.Refund), 6) + firstAmount = math.RoundDown(math.WeiToEth(firstDetails.NodeShareOfBalance), 6) + math.RoundDown(math.WeiToEth(firstDetails.Refund), 6) } var secondAmount float64 if secondDetails.Status == types.Dissolved { - secondAmount = math.RoundDown(eth.WeiToEth(secondDetails.Balance), 6) + secondAmount = math.RoundDown(math.WeiToEth(secondDetails.Balance), 6) } else { - secondAmount = math.RoundDown(eth.WeiToEth(secondDetails.NodeShareOfBalance), 6) + math.RoundDown(eth.WeiToEth(secondDetails.Refund), 6) + secondAmount = math.RoundDown(math.WeiToEth(secondDetails.NodeShareOfBalance), 6) + math.RoundDown(math.WeiToEth(secondDetails.Refund), 6) } // Sort highest-to-lowest @@ -166,13 +165,13 @@ func distributeBalance(minipool string, threshold float64, yes bool) error { // Prompt for minipool selection options := make([]string, len(eligibleMinipools)+1) - options[0] = fmt.Sprintf("All available minipools (%.6f ETH available, %.6f ETH goes to you plus a refund of %.6f ETH)", math.RoundDown(eth.WeiToEth(totalEthAvailable), 6), math.RoundDown(eth.WeiToEth(totalEthShare), 6), math.RoundDown(eth.WeiToEth(totalRefund), 6)) + options[0] = fmt.Sprintf("All available minipools (%.6f ETH available, %.6f ETH goes to you plus a refund of %.6f ETH)", math.RoundDown(math.WeiToEth(totalEthAvailable), 6), math.RoundDown(math.WeiToEth(totalEthShare), 6), math.RoundDown(math.WeiToEth(totalRefund), 6)) for mi, minipool := range eligibleMinipools { if minipool.Status == types.Dissolved { // Dissolved minipools are a special case - options[mi+1] = fmt.Sprintf("%s (%.6f ETH available, all of which goes to you)", minipool.Address.Hex(), math.RoundDown(eth.WeiToEth(minipool.Balance), 6)) + options[mi+1] = fmt.Sprintf("%s (%.6f ETH available, all of which goes to you)", minipool.Address.Hex(), math.RoundDown(math.WeiToEth(minipool.Balance), 6)) } else { - options[mi+1] = fmt.Sprintf("%s (%.6f ETH available, %.6f ETH goes to you plus a refund of %.6f ETH)", minipool.Address.Hex(), math.RoundDown(eth.WeiToEth(minipool.Balance), 6), math.RoundDown(eth.WeiToEth(minipool.NodeShareOfBalance), 6), math.RoundDown(eth.WeiToEth(minipool.Refund), 6)) + options[mi+1] = fmt.Sprintf("%s (%.6f ETH available, %.6f ETH goes to you plus a refund of %.6f ETH)", minipool.Address.Hex(), math.RoundDown(math.WeiToEth(minipool.Balance), 6), math.RoundDown(math.WeiToEth(minipool.NodeShareOfBalance), 6), math.RoundDown(math.WeiToEth(minipool.Refund), 6)) } } selected, _ := prompt.Select("Please select a minipool to distribute the balance of:", options) diff --git a/rocketpool-cli/minipool/refund.go b/rocketpool-cli/minipool/refund.go index 946bd1c90..5d9f5b9b5 100644 --- a/rocketpool-cli/minipool/refund.go +++ b/rocketpool-cli/minipool/refund.go @@ -7,14 +7,13 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" - "github.com/rocket-pool/smartnode/bindings/utils/eth" cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" - "github.com/rocket-pool/smartnode/shared/utils/math" ) func refundMinipools(minipool string, yes bool) error { @@ -54,7 +53,7 @@ func refundMinipools(minipool string, yes bool) error { options := make([]string, len(refundableMinipools)+1) options[0] = "All available minipools" for mi, minipool := range refundableMinipools { - options[mi+1] = fmt.Sprintf("%s (%.6f ETH to claim)", minipool.Address.Hex(), math.RoundDown(eth.WeiToEth(minipool.Node.RefundBalance), 6)) + options[mi+1] = fmt.Sprintf("%s (%.6f ETH to claim)", minipool.Address.Hex(), math.RoundDown(math.WeiToEth(minipool.Node.RefundBalance), 6)) } selected, _ := prompt.Select("Please select a minipool to refund ETH from:", options) diff --git a/rocketpool-cli/minipool/rescue-dissolved.go b/rocketpool-cli/minipool/rescue-dissolved.go index 69df76971..01c1c722e 100644 --- a/rocketpool-cli/minipool/rescue-dissolved.go +++ b/rocketpool-cli/minipool/rescue-dissolved.go @@ -9,16 +9,15 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" - "github.com/rocket-pool/smartnode/shared/utils/math" ) func rescueDissolved(minipool string, amount string, noSend bool, yes bool) error { @@ -50,7 +49,7 @@ func rescueDissolved(minipool string, amount string, noSend bool, yes bool) erro if depositAmountEth < 1 { return fmt.Errorf("The minimum amount you can deposit to the Beacon deposit contract is 1 ETH.") } - depositAmount = eth.EthToWei(depositAmountEth) + depositAmount = math.EthToWei(depositAmountEth) } rescuableMinipools := []api.MinipoolRescueDissolvedDetails{} @@ -58,7 +57,7 @@ func rescueDissolved(minipool string, amount string, noSend bool, yes bool) erro balanceCompletedMinipools := []api.MinipoolRescueDissolvedDetails{} invalidBeaconStateMinipools := []api.MinipoolRescueDissolvedDetails{} - fullDepositAmount := eth.EthToWei(32) + fullDepositAmount := math.EthToWei(32) for _, mp := range details.Details { if mp.IsFinalized { // Ignore minipools that are already closed @@ -139,7 +138,7 @@ func rescueDissolved(minipool string, amount string, noSend bool, yes bool) erro localRescueAmount := big.NewInt(0) localRescueAmount.Sub(fullDepositAmount, minipool.BeaconBalance) rescueAmounts[mi] = localRescueAmount - rescueAmountFloats[mi] = math.RoundDown(eth.WeiToEth(localRescueAmount), 6) + rescueAmountFloats[mi] = math.RoundDown(math.WeiToEth(localRescueAmount), 6) options[mi] = fmt.Sprintf("%s (requires %.6f more ETH)", minipool.Address.Hex(), rescueAmountFloats[mi]) } selected, _ := prompt.Select("Please select a minipool to refund ETH from:", options) @@ -158,7 +157,7 @@ func rescueDissolved(minipool string, amount string, noSend bool, yes bool) erro selectedMinipool = &rescuableMinipools[i] rescueAmount = big.NewInt(0) rescueAmount.Sub(fullDepositAmount, selectedMinipool.BeaconBalance) - rescueAmountFloat = math.RoundDown(eth.WeiToEth(rescueAmount), 6) + rescueAmountFloat = math.RoundDown(math.WeiToEth(rescueAmount), 6) break } } @@ -187,7 +186,7 @@ func rescueDissolved(minipool string, amount string, noSend bool, yes bool) erro depositAmount = rescueAmount depositAmountFloat = rescueAmountFloat case 1: - depositAmount = eth.EthToWei(1) + depositAmount = math.EthToWei(1) depositAmountFloat = 1 } @@ -203,7 +202,7 @@ func rescueDissolved(minipool string, amount string, noSend bool, yes bool) erro if depositAmountEth < 1 { return fmt.Errorf("The minimum amount you can deposit to the Beacon deposit contract is 1 ETH.") } - depositAmount = eth.EthToWei(depositAmountEth) + depositAmount = math.EthToWei(depositAmountEth) depositAmountFloat = depositAmountEth } diff --git a/rocketpool-cli/minipool/status.go b/rocketpool-cli/minipool/status.go index d63c28d82..cd466fa74 100644 --- a/rocketpool-cli/minipool/status.go +++ b/rocketpool-cli/minipool/status.go @@ -7,14 +7,13 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" "github.com/rocket-pool/smartnode/shared/hex" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" - "github.com/rocket-pool/smartnode/shared/utils/math" ) func getStatus(includeFinalized bool) error { @@ -119,14 +118,14 @@ func getStatus(includeFinalized bool) error { if len(refundableMinipools) > 0 { fmt.Printf("%d minipool(s) have refunds available:\n", len(refundableMinipools)) for _, minipool := range refundableMinipools { - fmt.Printf("- %s (%.6f ETH to claim)\n", minipool.Address.Hex(), math.RoundDown(eth.WeiToEth(minipool.Node.RefundBalance), 6)) + fmt.Printf("- %s (%.6f ETH to claim)\n", minipool.Address.Hex(), math.RoundDown(math.WeiToEth(minipool.Node.RefundBalance), 6)) } fmt.Println("") } if len(closeableMinipools) > 0 { fmt.Printf("%d dissolved minipool(s) can be closed:\n", len(closeableMinipools)) for _, minipool := range closeableMinipools { - fmt.Printf("- %s (%.6f ETH to claim)\n", minipool.Address.Hex(), math.RoundDown(eth.WeiToEth(minipool.Balances.ETH), 6)) + fmt.Printf("- %s (%.6f ETH to claim)\n", minipool.Address.Hex(), math.RoundDown(math.WeiToEth(minipool.Balances.ETH), 6)) } fmt.Println("") } @@ -161,7 +160,7 @@ func printMinipoolDetails(minipool api.MinipoolDetails, latestDelegate common.Ad fmt.Printf("Status: %s\n", minipool.Status.Status.String()) fmt.Printf("Status updated: %s\n", minipool.Status.StatusTime.Format(cliutils.TimeFormat)) fmt.Printf("Node fee: %f%%\n", minipool.Node.Fee*100) - fmt.Printf("Node deposit: %.6f ETH\n", math.RoundDown(eth.WeiToEth(minipool.Node.DepositBalance), 6)) + fmt.Printf("Node deposit: %.6f ETH\n", math.RoundDown(math.WeiToEth(minipool.Node.DepositBalance), 6)) // Queue position if minipool.Queue.Position != 0 { @@ -173,14 +172,14 @@ func printMinipoolDetails(minipool api.MinipoolDetails, latestDelegate common.Ad totalRewards := big.NewInt(0).Add(minipool.NodeShareOfETHBalance, minipool.Node.RefundBalance) if minipool.User.DepositAssigned { fmt.Printf("RP ETH assigned: %s\n", minipool.User.DepositAssignedTime.Format(cliutils.TimeFormat)) - fmt.Printf("RP deposit: %.6f ETH\n", math.RoundDown(eth.WeiToEth(minipool.User.DepositBalance), 6)) + fmt.Printf("RP deposit: %.6f ETH\n", math.RoundDown(math.WeiToEth(minipool.User.DepositBalance), 6)) } else { fmt.Printf("RP ETH assigned: no\n") } - fmt.Printf("Minipool Balance (EL): %.6f ETH\n", math.RoundDown(eth.WeiToEth(minipool.Balances.ETH), 6)) - fmt.Printf("Your portion: %.6f ETH\n", math.RoundDown(eth.WeiToEth(minipool.NodeShareOfETHBalance), 6)) - fmt.Printf("Available refund: %.6f ETH\n", math.RoundDown(eth.WeiToEth(minipool.Node.RefundBalance), 6)) - fmt.Printf("Total EL rewards: %.6f ETH\n", math.RoundDown(eth.WeiToEth(totalRewards), 6)) + fmt.Printf("Minipool Balance (EL): %.6f ETH\n", math.RoundDown(math.WeiToEth(minipool.Balances.ETH), 6)) + fmt.Printf("Your portion: %.6f ETH\n", math.RoundDown(math.WeiToEth(minipool.NodeShareOfETHBalance), 6)) + fmt.Printf("Available refund: %.6f ETH\n", math.RoundDown(math.WeiToEth(minipool.Node.RefundBalance), 6)) + fmt.Printf("Total EL rewards: %.6f ETH\n", math.RoundDown(math.WeiToEth(totalRewards), 6)) } // Validator details - prelaunch and staking minipools @@ -194,8 +193,8 @@ func printMinipoolDetails(minipool api.MinipoolDetails, latestDelegate common.Ad } else { fmt.Printf("Validator active: no\n") } - fmt.Printf("Beacon balance (CL): %.6f ETH\n", math.RoundDown(eth.WeiToEth(minipool.Validator.Balance), 6)) - fmt.Printf("Your portion: %.6f ETH\n", math.RoundDown(eth.WeiToEth(minipool.Validator.NodeBalance), 6)) + fmt.Printf("Beacon balance (CL): %.6f ETH\n", math.RoundDown(math.WeiToEth(minipool.Validator.Balance), 6)) + fmt.Printf("Your portion: %.6f ETH\n", math.RoundDown(math.WeiToEth(minipool.Validator.NodeBalance), 6)) } else { fmt.Printf("Validator seen: no\n") } diff --git a/rocketpool-cli/network/dao-proposals.go b/rocketpool-cli/network/dao-proposals.go index b4f1cc262..54cf0a5b6 100644 --- a/rocketpool-cli/network/dao-proposals.go +++ b/rocketpool-cli/network/dao-proposals.go @@ -8,9 +8,9 @@ import ( "github.com/ethereum/go-ethereum/common" - "github.com/rocket-pool/smartnode/bindings/utils/eth" cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/rocketpool" ) @@ -146,15 +146,15 @@ func getActiveDAOProposals() error { default: fmt.Println("The node has a voting delegate of", color.LightBlue(snapshotProposalsResponse.OnchainVotingDelegateFormatted), "which can represent it when voting on Rocket Pool onchain governance proposals.") } - fmt.Printf("The node's local voting power: %.10f\n", eth.WeiToEth(snapshotProposalsResponse.VotingPower)) + fmt.Printf("The node's local voting power: %.10f\n", math.WeiToEth(snapshotProposalsResponse.VotingPower)) if snapshotProposalsResponse.IsNodeRegistered { - fmt.Printf("Total voting power delegated to the node: %.10f\n", eth.WeiToEth(snapshotProposalsResponse.TotalDelegatedVp)) + fmt.Printf("Total voting power delegated to the node: %.10f\n", math.WeiToEth(snapshotProposalsResponse.TotalDelegatedVp)) } else { fmt.Println("The node must register using 'rocketpool node register' to be eligible to receive delegated voting power.") } - fmt.Printf("Network total initialized voting power: %.4f\n", eth.WeiToEth(snapshotProposalsResponse.SumVotingPower)) + fmt.Printf("Network total initialized voting power: %.4f\n", math.WeiToEth(snapshotProposalsResponse.SumVotingPower)) fmt.Println() return nil diff --git a/rocketpool-cli/network/rpl-price.go b/rocketpool-cli/network/rpl-price.go index fce8932da..fdab9416e 100644 --- a/rocketpool-cli/network/rpl-price.go +++ b/rocketpool-cli/network/rpl-price.go @@ -3,10 +3,8 @@ package network import ( "fmt" - "github.com/rocket-pool/smartnode/bindings/utils/eth" - + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - "github.com/rocket-pool/smartnode/shared/utils/math" ) func getRplPrice() error { @@ -25,7 +23,7 @@ func getRplPrice() error { } // Print & return - fmt.Printf("The current network RPL price is %.6f ETH.\n", math.RoundDown(eth.WeiToEth(response.RplPrice), 6)) + fmt.Printf("The current network RPL price is %.6f ETH.\n", math.RoundDown(math.WeiToEth(response.RplPrice), 6)) fmt.Printf("Prices last updated at block: %d\n", response.RplPriceBlock) return nil diff --git a/rocketpool-cli/node/claim-rewards.go b/rocketpool-cli/node/claim-rewards.go index 585187ddc..2fea2441d 100644 --- a/rocketpool-cli/node/claim-rewards.go +++ b/rocketpool-cli/node/claim-rewards.go @@ -9,11 +9,10 @@ import ( "github.com/ethereum/go-ethereum/common" - "github.com/rocket-pool/smartnode/bindings/utils/eth" - cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/gas" rprewards "github.com/rocket-pool/smartnode/shared/services/rewards" "github.com/rocket-pool/smartnode/shared/services/rocketpool" @@ -113,13 +112,13 @@ func nodeClaimRewards(restakeAmountFlag string, yes bool) error { totalVoterShareEth := big.NewInt(0) for _, intervalInfo := range rewardsInfoResponse.UnclaimedIntervals { fmt.Printf("Rewards for Interval %d (%s to %s):\n", intervalInfo.Index, intervalInfo.StartTime.Local(), intervalInfo.EndTime.Local()) - fmt.Printf("\tStaking: %.6f RPL\n", eth.WeiToEth(&intervalInfo.CollateralRplAmount.Int)) + fmt.Printf("\tStaking: %.6f RPL\n", math.WeiToEth(&intervalInfo.CollateralRplAmount.Int)) if intervalInfo.ODaoRplAmount.Cmp(big.NewInt(0)) == 1 { - fmt.Printf("\tOracle DAO: %.6f RPL\n", eth.WeiToEth(&intervalInfo.ODaoRplAmount.Int)) + fmt.Printf("\tOracle DAO: %.6f RPL\n", math.WeiToEth(&intervalInfo.ODaoRplAmount.Int)) } - fmt.Printf("\tSmoothing Pool: %.6f ETH\n\n", eth.WeiToEth(&intervalInfo.SmoothingPoolEthAmount.Int)) - fmt.Printf("\tVoter Share: %.6f ETH\n", eth.WeiToEth(&intervalInfo.VoterShareEth.Int)) - fmt.Printf("\tTotal: %.6f ETH\n\n", eth.WeiToEth(&intervalInfo.TotalEthAmount.Int)) + fmt.Printf("\tSmoothing Pool: %.6f ETH\n\n", math.WeiToEth(&intervalInfo.SmoothingPoolEthAmount.Int)) + fmt.Printf("\tVoter Share: %.6f ETH\n", math.WeiToEth(&intervalInfo.VoterShareEth.Int)) + fmt.Printf("\tTotal: %.6f ETH\n\n", math.WeiToEth(&intervalInfo.TotalEthAmount.Int)) totalRpl.Add(totalRpl, &intervalInfo.CollateralRplAmount.Int) totalRpl.Add(totalRpl, &intervalInfo.ODaoRplAmount.Int) @@ -128,9 +127,9 @@ func nodeClaimRewards(restakeAmountFlag string, yes bool) error { } fmt.Println("Total Pending Rewards:") - fmt.Printf("\t%.6f RPL\n", eth.WeiToEth(totalRpl)) - fmt.Printf("\t%.6f Smoothing Pool ETH\n", eth.WeiToEth(totalSmoothingEth)) - fmt.Printf("\t%.6f Voter Share ETH\n\n", eth.WeiToEth(totalVoterShareEth)) + fmt.Printf("\t%.6f RPL\n", math.WeiToEth(totalRpl)) + fmt.Printf("\t%.6f Smoothing Pool ETH\n", math.WeiToEth(totalSmoothingEth)) + fmt.Printf("\t%.6f Voter Share ETH\n\n", math.WeiToEth(totalVoterShareEth)) // Get the list of intervals to claim var indices []uint64 @@ -194,7 +193,7 @@ func nodeClaimRewards(restakeAmountFlag string, yes bool) error { } } } - fmt.Printf("With this selection, you will claim %.6f RPL and %.6f ETH.\n\n", eth.WeiToEth(claimRpl), eth.WeiToEth(claimEth)) + fmt.Printf("With this selection, you will claim %.6f RPL and %.6f ETH.\n\n", math.WeiToEth(claimRpl), math.WeiToEth(claimEth)) // Get restake amount restakeAmountWei, err := getRestakeAmount(restakeAmountFlag, yes, rewardsInfoResponse, claimRpl) @@ -268,8 +267,8 @@ func getRestakeAmount(restakeAmountFlag string, yes bool, rewardsInfoResponse ap currentBorrowedCollateral := float64(0) totalBondedCollateral := float64(0) totalBorrowedCollateral := float64(0) - currentRplStake := eth.WeiToEth(rewardsInfoResponse.RplStake) - availableRpl := eth.WeiToEth(claimRpl) + currentRplStake := math.WeiToEth(rewardsInfoResponse.RplStake) + availableRpl := math.WeiToEth(claimRpl) // Print info about autostaking RPL total := currentRplStake + availableRpl @@ -309,7 +308,7 @@ func getRestakeAmount(restakeAmountFlag string, yes bool, rewardsInfoResponse ap restakeAmountWei = claimRpl } else { fmt.Printf("Automatically restaking %.6f RPL, which will bring you to a total of %.6f RPL staked (%.2f%% borrowed collateral, %.2f%% bonded collateral).\n", stakeAmount, total, totalBorrowedCollateral*100, totalBondedCollateral*100) - restakeAmountWei = eth.EthToWei(stakeAmount) + restakeAmountWei = math.EthToWei(stakeAmount) } } else if yes { // Ignore automatic restaking if `-y` is specified but `-a` isn't @@ -340,7 +339,7 @@ func getRestakeAmount(restakeAmountFlag string, yes bool, rewardsInfoResponse ap } else if stakeAmount > availableRpl { fmt.Println("Amount must be less than the RPL available to claim.") } else { - restakeAmountWei = eth.EthToWei(stakeAmount) + restakeAmountWei = math.EthToWei(stakeAmount) break } } diff --git a/rocketpool-cli/node/claim-unclaimed-rewards.go b/rocketpool-cli/node/claim-unclaimed-rewards.go index 8ff75f71d..c49007627 100644 --- a/rocketpool-cli/node/claim-unclaimed-rewards.go +++ b/rocketpool-cli/node/claim-unclaimed-rewards.go @@ -4,13 +4,12 @@ import ( "fmt" "math/big" - "github.com/rocket-pool/smartnode/bindings/utils/eth" cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - "github.com/rocket-pool/smartnode/shared/utils/math" ) func claimUnclaimedRewards(yes bool) error { @@ -31,7 +30,7 @@ func claimUnclaimedRewards(yes bool) error { // Show unclaimed rewards status fmt.Printf("The node's withdrawal address is %s\n", status.PrimaryWithdrawalAddress) if status.UnclaimedRewards != nil && status.UnclaimedRewards.Cmp(big.NewInt(0)) > 0 { - fmt.Printf("You have %.6f ETH in unclaimed rewards.\n", math.RoundDown(eth.WeiToEth(status.UnclaimedRewards), 6)) + fmt.Printf("You have %.6f ETH in unclaimed rewards.\n", math.RoundDown(math.WeiToEth(status.UnclaimedRewards), 6)) fmt.Printf("Your node %s's rewards were distributed, but the withdrawal address (at the time of distribution) was unable to accept ETH. ", color.LightBlue(status.AccountAddress.String())) fmt.Println("Before continuing, please use the command `rocketpool node set-primary-withdrawal-address` to configure an address that can accept ETH") @@ -55,7 +54,7 @@ func claimUnclaimedRewards(yes bool) error { } // Prompt for confirmation - if prompt.Declined(yes, "Are you sure you want to claim %.6f ETH in unclaimed rewards?", math.RoundDown(eth.WeiToEth(status.UnclaimedRewards), 6)) { + if prompt.Declined(yes, "Are you sure you want to claim %.6f ETH in unclaimed rewards?", math.RoundDown(math.WeiToEth(status.UnclaimedRewards), 6)) { fmt.Println("Cancelled.") return nil } @@ -73,7 +72,7 @@ func claimUnclaimedRewards(yes bool) error { } // Log & return - fmt.Printf("Successfully claimed %.6f ETH in unclaimed rewards.\n", math.RoundDown(eth.WeiToEth(status.UnclaimedRewards), 6)) + fmt.Printf("Successfully claimed %.6f ETH in unclaimed rewards.\n", math.RoundDown(math.WeiToEth(status.UnclaimedRewards), 6)) return nil } diff --git a/rocketpool-cli/node/distributor.go b/rocketpool-cli/node/distributor.go index 7bce3fca6..1faafe9c2 100644 --- a/rocketpool-cli/node/distributor.go +++ b/rocketpool-cli/node/distributor.go @@ -3,9 +3,9 @@ package node import ( "fmt" - "github.com/rocket-pool/smartnode/bindings/utils/eth" cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" ) @@ -98,7 +98,7 @@ func distribute(yes bool) error { return err } - balance := eth.WeiToEth(canDistributeResponse.Balance) + balance := math.WeiToEth(canDistributeResponse.Balance) if balance == 0 { fmt.Printf("Your fee distributor does not have any ETH.") return nil diff --git a/rocketpool-cli/node/rewards.go b/rocketpool-cli/node/rewards.go index d155f3f5d..57aeb0609 100644 --- a/rocketpool-cli/node/rewards.go +++ b/rocketpool-cli/node/rewards.go @@ -5,10 +5,10 @@ import ( "math/big" "time" - "github.com/rocket-pool/smartnode/bindings/utils/eth" cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" + "github.com/rocket-pool/smartnode/shared/math" rprewards "github.com/rocket-pool/smartnode/shared/services/rewards" "github.com/rocket-pool/smartnode/shared/services/rocketpool" ) @@ -95,7 +95,7 @@ func getRewards(yes bool) error { // NodeBond and NodeShareOfCLBalance are nil for nodes without a megapool (legacy minipools only). if beaconBalances.NodeBond != nil && beaconBalances.NodeShareOfCLBalance != nil { megapoolUnskimmedRewards := new(big.Int).Sub(beaconBalances.NodeBond, beaconBalances.NodeShareOfCLBalance) - rewards.BeaconRewards = rewards.BeaconRewards + eth.WeiToEth(megapoolUnskimmedRewards) + rewards.BeaconRewards = rewards.BeaconRewards + math.WeiToEth(megapoolUnskimmedRewards) } fmt.Println("=== ETH ===") diff --git a/rocketpool-cli/node/rpl-withdrawal-address.go b/rocketpool-cli/node/rpl-withdrawal-address.go index f4d4c5d51..5e9d4f556 100644 --- a/rocketpool-cli/node/rpl-withdrawal-address.go +++ b/rocketpool-cli/node/rpl-withdrawal-address.go @@ -7,10 +7,10 @@ import ( "github.com/ethereum/go-ethereum/common" - "github.com/rocket-pool/smartnode/bindings/utils/eth" cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" ) @@ -122,7 +122,7 @@ func setRPLWithdrawalAddress(withdrawalAddressOrENS string, yes, force bool) err // Prompt for confirmation if canResponse.RPLStake.Cmp(common.Big0) == 1 { - color.YellowPrintf("NOTE: You currently have %.6f RPL staked. Withdrawing it will *no longer* send it to your primary withdrawal address. It will be sent to the new RPL withdrawal address instead. Please verify you have control over that address before confirming this!\n", eth.WeiToEth(canResponse.RPLStake)) + color.YellowPrintf("NOTE: You currently have %.6f RPL staked. Withdrawing it will *no longer* send it to your primary withdrawal address. It will be sent to the new RPL withdrawal address instead. Please verify you have control over that address before confirming this!\n", math.WeiToEth(canResponse.RPLStake)) } if prompt.Declined(yes, "Are you sure you want to set your node's RPL withdrawal address to %s?", withdrawalAddressString) { fmt.Println("Cancelled.") diff --git a/rocketpool-cli/node/stake-rpl.go b/rocketpool-cli/node/stake-rpl.go index 3d2fd2bff..e2efc70d6 100644 --- a/rocketpool-cli/node/stake-rpl.go +++ b/rocketpool-cli/node/stake-rpl.go @@ -6,13 +6,11 @@ import ( "strconv" "strings" - "github.com/rocket-pool/smartnode/bindings/utils/eth" - cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - "github.com/rocket-pool/smartnode/shared/utils/math" ) // Config @@ -40,9 +38,9 @@ func nodeStakeRpl(amount string, swap bool, yes bool) error { fmt.Println() // Show current RPL balances - fmt.Printf("The node has a balance of %.6f RPL.\n\n", math.RoundDown(eth.WeiToEth(status.AccountBalances.RPL), 6)) + fmt.Printf("The node has a balance of %.6f RPL.\n\n", math.RoundDown(math.WeiToEth(status.AccountBalances.RPL), 6)) if status.AccountBalances.FixedSupplyRPL.Cmp(big.NewInt(0)) > 0 { - fmt.Printf("The node has a balance of %.6f old RPL which can be swapped for new RPL.\n\n", math.RoundDown(eth.WeiToEth(status.AccountBalances.FixedSupplyRPL), 6)) + fmt.Printf("The node has a balance of %.6f old RPL which can be swapped for new RPL.\n\n", math.RoundDown(math.WeiToEth(status.AccountBalances.FixedSupplyRPL), 6)) } // If a custom nonce is set, print the multi-transaction warning @@ -55,7 +53,7 @@ func nodeStakeRpl(amount string, swap bool, yes bool) error { if status.AccountBalances.FixedSupplyRPL.Cmp(big.NewInt(0)) > 0 { // Confirm swapping RPL - if swap || prompt.Confirm("The node has a balance of %.6f old RPL. Would you like to swap it for new RPL before staking?", math.RoundDown(eth.WeiToEth(status.AccountBalances.FixedSupplyRPL), 6)) { + if swap || prompt.Confirm("The node has a balance of %.6f old RPL. Would you like to swap it for new RPL before staking?", math.RoundDown(math.WeiToEth(status.AccountBalances.FixedSupplyRPL), 6)) { // Check allowance allowance, err := rp.GetNodeSwapRplAllowance() @@ -133,7 +131,7 @@ func nodeStakeRpl(amount string, swap bool, yes bool) error { } // Prompt for confirmation - if prompt.Declined(yes, "Are you sure you want to swap %.6f old RPL for new RPL?", math.RoundDown(eth.WeiToEth(status.AccountBalances.FixedSupplyRPL), 6)) { + if prompt.Declined(yes, "Are you sure you want to swap %.6f old RPL for new RPL?", math.RoundDown(math.WeiToEth(status.AccountBalances.FixedSupplyRPL), 6)) { fmt.Println("Cancelled.") return nil } @@ -151,7 +149,7 @@ func nodeStakeRpl(amount string, swap bool, yes bool) error { } // Log - fmt.Printf("Successfully swapped %.6f old RPL for new RPL.\n", math.RoundDown(eth.WeiToEth(status.AccountBalances.FixedSupplyRPL), 6)) + fmt.Printf("Successfully swapped %.6f old RPL for new RPL.\n", math.RoundDown(math.WeiToEth(status.AccountBalances.FixedSupplyRPL), 6)) fmt.Println("") // If a custom nonce is set, increment it for the next transaction @@ -174,7 +172,7 @@ func nodeStakeRpl(amount string, swap bool, yes bool) error { var amountWei *big.Int var stakePercent float64 // Borrow amount for a new megapool validator - ethBorrowed := new(big.Int).Sub(eth.EthToWei(32), status.ReducedBond) + ethBorrowed := new(big.Int).Sub(math.EthToWei(32), status.ReducedBond) // Amount flag custom percentage input if strings.HasSuffix(amount, "%") { @@ -182,7 +180,7 @@ func nodeStakeRpl(amount string, swap bool, yes bool) error { if err != nil { return fmt.Errorf("Invalid stake amount '%s': %w", amount, err) } - amountWei = rplStakePerValidator(ethBorrowed, eth.EthToWei(stakePercent/100), rplPrice.RplPrice) + amountWei = rplStakePerValidator(ethBorrowed, math.EthToWei(stakePercent/100), rplPrice.RplPrice) } else if amount == "all" { // Set amount to node's entire RPL balance @@ -194,7 +192,7 @@ func nodeStakeRpl(amount string, swap bool, yes bool) error { if err != nil { return fmt.Errorf("Invalid stake amount '%s': %w", amount, err) } - amountWei = eth.EthToWei(stakeAmount) + amountWei = math.EthToWei(stakeAmount) } else { // Get the RPL stake amounts for 5,10,15% borrowed ETH per Validator @@ -206,10 +204,10 @@ func nodeStakeRpl(amount string, swap bool, yes bool) error { // Prompt for amount option amountOptions := []string{ - fmt.Sprintf("5%% of borrowed ETH (%.6f RPL) for one validator?", math.RoundUp(eth.WeiToEth(fivePercentBorrowedRplStake), 6)), - fmt.Sprintf("10%% of borrowed ETH (%.6f RPL) for one validator?", math.RoundUp(eth.WeiToEth(tenPercentBorrowedRplStake), 6)), - fmt.Sprintf("15%% of borrowed ETH (%.6f RPL) for one validator?", math.RoundUp(eth.WeiToEth(fifteenPercentBorrowedRplStake), 6)), - fmt.Sprintf("Your entire RPL balance (%.6f RPL)?", math.RoundDown(eth.WeiToEth(&rplBalance), 6)), + fmt.Sprintf("5%% of borrowed ETH (%.6f RPL) for one validator?", math.RoundUp(math.WeiToEth(fivePercentBorrowedRplStake), 6)), + fmt.Sprintf("10%% of borrowed ETH (%.6f RPL) for one validator?", math.RoundUp(math.WeiToEth(tenPercentBorrowedRplStake), 6)), + fmt.Sprintf("15%% of borrowed ETH (%.6f RPL) for one validator?", math.RoundUp(math.WeiToEth(fifteenPercentBorrowedRplStake), 6)), + fmt.Sprintf("Your entire RPL balance (%.6f RPL)?", math.RoundDown(math.WeiToEth(&rplBalance), 6)), "A custom amount", } selected, _ := prompt.Select("Please choose an amount of RPL to stake:", amountOptions) @@ -233,13 +231,13 @@ func nodeStakeRpl(amount string, swap bool, yes bool) error { if err != nil { return fmt.Errorf("Invalid stake amount '%s': %w", inputAmountOrPercent, err) } - amountWei = rplStakePerValidator(ethBorrowed, eth.EthToWei(stakePercent/100), rplPrice.RplPrice) + amountWei = rplStakePerValidator(ethBorrowed, math.EthToWei(stakePercent/100), rplPrice.RplPrice) } else { stakeAmount, err := strconv.ParseFloat(inputAmountOrPercent, 64) if err != nil { return fmt.Errorf("Invalid stake amount '%s': %w", inputAmountOrPercent, err) } - amountWei = eth.EthToWei(stakeAmount) + amountWei = math.EthToWei(stakeAmount) } } } @@ -322,7 +320,7 @@ func nodeStakeRpl(amount string, swap bool, yes bool) error { // Prompt for confirmation if prompt.Declined(yes, "Are you sure you want to stake %.6f RPL? You may request to unstake your staked RPL at any time. The unstaked RPL will be withdrawable after an unstaking period of %s.", - math.RoundDown(eth.WeiToEth(amountWei), 6), + math.RoundDown(math.WeiToEth(amountWei), 6), status.UnstakingPeriodDuration) { fmt.Println("Cancelled.") return nil @@ -341,7 +339,7 @@ func nodeStakeRpl(amount string, swap bool, yes bool) error { } // Log & return - fmt.Printf("Successfully staked %.6f RPL.\n", math.RoundDown(eth.WeiToEth(amountWei), 6)) + fmt.Printf("Successfully staked %.6f RPL.\n", math.RoundDown(math.WeiToEth(amountWei), 6)) return nil } diff --git a/rocketpool-cli/node/status.go b/rocketpool-cli/node/status.go index 1f1dfad1b..cac5e7a02 100644 --- a/rocketpool-cli/node/status.go +++ b/rocketpool-cli/node/status.go @@ -10,13 +10,11 @@ import ( "github.com/ethereum/go-ethereum/common" - "github.com/rocket-pool/smartnode/bindings/utils/eth" - "github.com/rocket-pool/smartnode/addons/rescue_node" cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - "github.com/rocket-pool/smartnode/shared/utils/math" ) const ( @@ -80,17 +78,17 @@ func getStatus() error { fmt.Printf( "The node %s has a balance of %.6f ETH, %.6f RPL, and %.6f rETH.\n", color.LightBlue(status.AccountAddressFormatted), - math.RoundDown(eth.WeiToEth(status.AccountBalances.ETH), 6), - math.RoundDown(eth.WeiToEth(status.AccountBalances.RPL), 6), - math.RoundDown(eth.WeiToEth(status.AccountBalances.RETH), 6)) + math.RoundDown(math.WeiToEth(status.AccountBalances.ETH), 6), + math.RoundDown(math.WeiToEth(status.AccountBalances.RPL), 6), + math.RoundDown(math.WeiToEth(status.AccountBalances.RETH), 6)) if status.AccountBalances.FixedSupplyRPL.Cmp(big.NewInt(0)) > 0 { - fmt.Printf("The node has a balance of %.6f old RPL which can be swapped for new RPL.\n", math.RoundDown(eth.WeiToEth(status.AccountBalances.FixedSupplyRPL), 6)) + fmt.Printf("The node has a balance of %.6f old RPL which can be swapped for new RPL.\n", math.RoundDown(math.WeiToEth(status.AccountBalances.FixedSupplyRPL), 6)) } fmt.Printf( "The node has %.6f ETH in its credit balance and %.6f ETH staked on its behalf. %.6f can be used to make new validators.\n", - math.RoundDown(eth.WeiToEth(status.CreditBalance), 6), - math.RoundDown(eth.WeiToEth(status.EthOnBehalfBalance), 6), - math.RoundDown(eth.WeiToEth(status.UsableCreditAndEthOnBehalfBalance), 6), + math.RoundDown(math.WeiToEth(status.CreditBalance), 6), + math.RoundDown(math.WeiToEth(status.EthOnBehalfBalance), 6), + math.RoundDown(math.WeiToEth(status.UsableCreditAndEthOnBehalfBalance), 6), ) // Registered node details @@ -108,10 +106,10 @@ func getStatus() error { fmt.Printf("The node has a megapool deployed at %s.\n", color.LightBlue(status.MegapoolAddress.Hex())) fmt.Printf("The megapool has %d validators.\n", status.MegapoolActiveValidatorCount) if status.MegapoolNodeDebt.Cmp(big.NewInt(0)) > 0 { - fmt.Printf("The megapool debt is %.6f ETH.\n", math.RoundDown(eth.WeiToEth(status.MegapoolNodeDebt), 6)) + fmt.Printf("The megapool debt is %.6f ETH.\n", math.RoundDown(math.WeiToEth(status.MegapoolNodeDebt), 6)) } if status.MegapoolRefundValue.Cmp(big.NewInt(0)) > 0 { - fmt.Printf("The megapool refund value is %.6f ETH.\n", math.RoundDown(eth.WeiToEth(status.MegapoolRefundValue), 6)) + fmt.Printf("The megapool refund value is %.6f ETH.\n", math.RoundDown(math.WeiToEth(status.MegapoolRefundValue), 6)) } } else { fmt.Println("The node does not have a megapool deployed yet.") @@ -210,7 +208,7 @@ func getStatus() error { fmt.Print("The node is allowed to lock RPL to create governance proposals/challenges.\n") if status.NodeRPLLocked.Cmp(big.NewInt(0)) != 0 { fmt.Printf("The node currently has %.6f RPL locked.\n", - math.RoundDown(eth.WeiToEth(status.NodeRPLLocked), 6)) + math.RoundDown(math.WeiToEth(status.NodeRPLLocked), 6)) } } else { @@ -224,8 +222,8 @@ func getStatus() error { fmt.Printf( "The node's primary withdrawal address %s has a balance of %.6f ETH and %.6f RPL.\n", color.LightBlue(status.PrimaryWithdrawalAddressFormatted), - math.RoundDown(eth.WeiToEth(status.PrimaryWithdrawalBalances.ETH), 6), - math.RoundDown(eth.WeiToEth(status.PrimaryWithdrawalBalances.RPL), 6)) + math.RoundDown(math.WeiToEth(status.PrimaryWithdrawalBalances.ETH), 6), + math.RoundDown(math.WeiToEth(status.PrimaryWithdrawalBalances.RPL), 6)) } else { color.YellowPrintln("The node's primary withdrawal address has not been changed, so ETH rewards and minipool withdrawals will be sent to the node itself.") color.YellowPrintln("Consider changing this to a cold wallet address that you control using the `set-withdrawal-address` command.") @@ -249,8 +247,8 @@ func getStatus() error { fmt.Printf( "The node's RPL withdrawal address %s has a balance of %.6f ETH and %.6f RPL.\n", color.LightBlue(status.RPLWithdrawalAddressFormatted), - math.RoundDown(eth.WeiToEth(status.RPLWithdrawalBalances.ETH), 6), - math.RoundDown(eth.WeiToEth(status.RPLWithdrawalBalances.RPL), 6)) + math.RoundDown(math.WeiToEth(status.RPLWithdrawalBalances.ETH), 6), + math.RoundDown(math.WeiToEth(status.RPLWithdrawalBalances.RPL), 6)) } fmt.Println("") if status.PendingRPLWithdrawalAddress.Hex() != blankAddress.Hex() { @@ -261,7 +259,7 @@ func getStatus() error { // Fee distributor details color.GreenPrintln("=== Fee Distributor and Smoothing Pool ===") - fmt.Printf("The node's fee distributor %s has a balance of %.6f ETH.\n", color.LightBlue(status.FeeRecipientInfo.FeeDistributorAddress.Hex()), math.RoundDown(eth.WeiToEth(status.FeeDistributorBalance), 6)) + fmt.Printf("The node's fee distributor %s has a balance of %.6f ETH.\n", color.LightBlue(status.FeeRecipientInfo.FeeDistributorAddress.Hex()), math.RoundDown(math.WeiToEth(status.FeeDistributorBalance), 6)) if cfg.IsNativeMode && !status.FeeRecipientInfo.IsInSmoothingPool && !status.FeeRecipientInfo.IsInOptOutCooldown { color.YellowPrintln("NOTE: You are in Native Mode; you MUST ensure that your Validator Client is using this address as its fee recipient!") } @@ -309,18 +307,18 @@ func getStatus() error { color.GreenPrintln("=== RPL Stake ===") fmt.Println("NOTE: The following figures take *any pending bond reductions* into account.") fmt.Println() - fmt.Printf("The node has a total stake of %.6f RPL.\n", math.RoundDown(eth.WeiToEth(status.TotalRplStake), 6)) + fmt.Printf("The node has a total stake of %.6f RPL.\n", math.RoundDown(math.WeiToEth(status.TotalRplStake), 6)) if status.BorrowedCollateralRatio > 0 { fmt.Printf("This is currently %.2f%% of its borrowed ETH and %.2f%% of its bonded ETH.\n", status.BorrowedCollateralRatio*100, status.BondedCollateralRatio*100) } - fmt.Printf("The node has %.6f megapool staked RPL.\n", math.RoundDown(eth.WeiToEth(status.RplStakeMegapool), 6)) + fmt.Printf("The node has %.6f megapool staked RPL.\n", math.RoundDown(math.WeiToEth(status.RplStakeMegapool), 6)) if status.RplStakeLegacy != nil && status.RplStakeLegacy.Cmp(big.NewInt(0)) != 0 { - fmt.Printf("The node has %6f legacy staked RPL.\n", math.RoundDown(eth.WeiToEth(status.RplStakeLegacy), 6)) - fmt.Printf("The node has a total stake (legacy minipool RPL plus megapool RPL) of %.6f RPL.\n", math.RoundDown(eth.WeiToEth(status.TotalRplStake), 6)) + fmt.Printf("The node has %6f legacy staked RPL.\n", math.RoundDown(math.WeiToEth(status.RplStakeLegacy), 6)) + fmt.Printf("The node has a total stake (legacy minipool RPL plus megapool RPL) of %.6f RPL.\n", math.RoundDown(math.WeiToEth(status.TotalRplStake), 6)) if status.RplStakeLegacy.Cmp(status.RplStakeThreshold) > 1 { fmt.Printf( - "You can withdraw down to %.6f Legacy RPL (%.0f%% of borrowed eth)\n", math.RoundDown(eth.WeiToEth(status.RplStakeThreshold), 6), (status.RplStakeThresholdFraction)*100) + "You can withdraw down to %.6f Legacy RPL (%.0f%% of borrowed eth)\n", math.RoundDown(math.WeiToEth(status.RplStakeThreshold), 6), (status.RplStakeThresholdFraction)*100) } } var unstakingPeriodEnd time.Time @@ -337,9 +335,9 @@ func getStatus() error { // Check if unstaking period passed considering the last unstake time unstakingPeriodEnd = status.LastRPLUnstakeTime.Add(status.UnstakingPeriodDuration) if unstakingPeriodEnd.After(status.LatestBlockTime) { - fmt.Printf("Your node has %.6f RPL unstaking. That amount will be withdrawable on %s.\n", math.RoundDown(eth.WeiToEth(status.UnstakingRPL), 6), unstakingPeriodEnd.Format(cliutils.TimeFormat)) + fmt.Printf("Your node has %.6f RPL unstaking. That amount will be withdrawable on %s.\n", math.RoundDown(math.WeiToEth(status.UnstakingRPL), 6), unstakingPeriodEnd.Format(cliutils.TimeFormat)) } else { - fmt.Printf("Your node has %.6f RPL unstaked. That amount is currently withdrawable.\n", math.RoundDown(eth.WeiToEth(status.UnstakingRPL), 6)) + fmt.Printf("Your node has %.6f RPL unstaked. That amount is currently withdrawable.\n", math.RoundDown(math.WeiToEth(status.UnstakingRPL), 6)) } } @@ -358,7 +356,7 @@ func getStatus() error { maxAmount.Set(status.RplStakeMegapool) } - fmt.Printf("You have %.6f RPL staked on your megapool and can request to unstake up to %.6f RPL\n", math.RoundDown(eth.WeiToEth(status.RplStakeMegapool), 6), math.RoundDown(eth.WeiToEth(&maxAmount), 6)) + fmt.Printf("You have %.6f RPL staked on your megapool and can request to unstake up to %.6f RPL\n", math.RoundDown(math.WeiToEth(status.RplStakeMegapool), 6), math.RoundDown(math.WeiToEth(&maxAmount), 6)) fmt.Println() diff --git a/rocketpool-cli/node/swap-rpl.go b/rocketpool-cli/node/swap-rpl.go index e5e8d5fd6..c50d09b82 100644 --- a/rocketpool-cli/node/swap-rpl.go +++ b/rocketpool-cli/node/swap-rpl.go @@ -5,13 +5,11 @@ import ( "math/big" "strconv" - "github.com/rocket-pool/smartnode/bindings/utils/eth" - cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - "github.com/rocket-pool/smartnode/shared/utils/math" ) func nodeSwapRpl(amount string, yes bool) error { @@ -41,7 +39,7 @@ func nodeSwapRpl(amount string, yes bool) error { if err != nil { return fmt.Errorf("Invalid swap amount '%s': %w", amount, err) } - amountWei = eth.EthToWei(swapAmount) + amountWei = math.EthToWei(swapAmount) } else { @@ -53,7 +51,7 @@ func nodeSwapRpl(amount string, yes bool) error { entireAmount := status.AccountBalances.FixedSupplyRPL // Prompt for entire amount - if prompt.Confirm("Would you like to swap your entire old RPL balance (%.6f RPL)?", math.RoundDown(eth.WeiToEth(entireAmount), 6)) { + if prompt.Confirm("Would you like to swap your entire old RPL balance (%.6f RPL)?", math.RoundDown(math.WeiToEth(entireAmount), 6)) { amountWei = entireAmount } else { @@ -63,7 +61,7 @@ func nodeSwapRpl(amount string, yes bool) error { if err != nil { return fmt.Errorf("Invalid swap amount '%s': %w", inputAmount, err) } - amountWei = eth.EthToWei(swapAmount) + amountWei = math.EthToWei(swapAmount) } @@ -145,7 +143,7 @@ func nodeSwapRpl(amount string, yes bool) error { } // Prompt for confirmation - if prompt.Declined(yes, "Are you sure you want to swap %.6f old RPL for new RPL?", math.RoundDown(eth.WeiToEth(amountWei), 6)) { + if prompt.Declined(yes, "Are you sure you want to swap %.6f old RPL for new RPL?", math.RoundDown(math.WeiToEth(amountWei), 6)) { fmt.Println("Cancelled.") return nil } @@ -163,7 +161,7 @@ func nodeSwapRpl(amount string, yes bool) error { } // Log & return - fmt.Printf("Successfully swapped %.6f old RPL for new RPL.\n", math.RoundDown(eth.WeiToEth(amountWei), 6)) + fmt.Printf("Successfully swapped %.6f old RPL for new RPL.\n", math.RoundDown(math.WeiToEth(amountWei), 6)) return nil } diff --git a/rocketpool-cli/node/withdraw-credit.go b/rocketpool-cli/node/withdraw-credit.go index 43bc42622..b04980b24 100644 --- a/rocketpool-cli/node/withdraw-credit.go +++ b/rocketpool-cli/node/withdraw-credit.go @@ -5,13 +5,11 @@ import ( "math/big" "strconv" - "github.com/rocket-pool/smartnode/bindings/utils/eth" - cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - "github.com/rocket-pool/smartnode/shared/utils/math" ) func nodeWithdrawCredit(amount string, yes bool) error { @@ -48,14 +46,14 @@ func nodeWithdrawCredit(amount string, yes bool) error { if err != nil { return fmt.Errorf("Invalid withdrawal amount '%s': %w", amount, err) } - amountWei = eth.EthToWei(withdrawalAmount) + amountWei = math.EthToWei(withdrawalAmount) } else { // Get maximum withdrawable amount maxAmount := status.CreditBalance // Prompt for maximum amount - if prompt.Confirm("You have %.6f ETH of credit that you can withdraw, receiving the equivalent amount in rETH on the node withdrawal address (%s).\n\n Would you like to withdraw the maximum amount of credit?", math.RoundDown(eth.WeiToEth(maxAmount), 6), status.PrimaryWithdrawalAddress) { + if prompt.Confirm("You have %.6f ETH of credit that you can withdraw, receiving the equivalent amount in rETH on the node withdrawal address (%s).\n\n Would you like to withdraw the maximum amount of credit?", math.RoundDown(math.WeiToEth(maxAmount), 6), status.PrimaryWithdrawalAddress) { amountWei = maxAmount } else { @@ -65,7 +63,7 @@ func nodeWithdrawCredit(amount string, yes bool) error { if err != nil { return fmt.Errorf("Invalid withdrawal amount '%s': %w", inputAmount, err) } - amountWei = eth.EthToWei(withdrawalAmount) + amountWei = math.EthToWei(withdrawalAmount) } @@ -90,7 +88,7 @@ func nodeWithdrawCredit(amount string, yes bool) error { } // Prompt for confirmation - if prompt.Declined(yes, "Are you sure you want to withdraw %.6f of credit?", math.RoundDown(eth.WeiToEth(amountWei), 6)) { + if prompt.Declined(yes, "Are you sure you want to withdraw %.6f of credit?", math.RoundDown(math.WeiToEth(amountWei), 6)) { fmt.Println("Cancelled.") return nil } @@ -108,7 +106,7 @@ func nodeWithdrawCredit(amount string, yes bool) error { } // Log & return - fmt.Printf("Successfully withdrew %.6f credit. The equivalent amount of rETH has been transferred to the node withdrawal address (%s).\n", math.RoundDown(eth.WeiToEth(amountWei), 6), status.PrimaryWithdrawalAddress) + fmt.Printf("Successfully withdrew %.6f credit. The equivalent amount of rETH has been transferred to the node withdrawal address (%s).\n", math.RoundDown(math.WeiToEth(amountWei), 6), status.PrimaryWithdrawalAddress) return nil } diff --git a/rocketpool-cli/node/withdraw-eth.go b/rocketpool-cli/node/withdraw-eth.go index ec02578ad..1785d9b19 100644 --- a/rocketpool-cli/node/withdraw-eth.go +++ b/rocketpool-cli/node/withdraw-eth.go @@ -5,13 +5,11 @@ import ( "math/big" "strconv" - "github.com/rocket-pool/smartnode/bindings/utils/eth" - cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - "github.com/rocket-pool/smartnode/shared/utils/math" ) func nodeWithdrawEth(amount string, yes bool) error { @@ -43,7 +41,7 @@ func nodeWithdrawEth(amount string, yes bool) error { if err != nil { return fmt.Errorf("Invalid withdrawal amount '%s': %w", amount, err) } - amountWei = eth.EthToWei(withdrawalAmount) + amountWei = math.EthToWei(withdrawalAmount) } else { @@ -56,7 +54,7 @@ func nodeWithdrawEth(amount string, yes bool) error { // Get maximum withdrawable amount maxAmount := status.EthOnBehalfBalance // Prompt for maximum amount - if prompt.Confirm("Would you like to withdraw the maximum amount of staked ETH (%.6f ETH)?", math.RoundDown(eth.WeiToEth(maxAmount), 6)) { + if prompt.Confirm("Would you like to withdraw the maximum amount of staked ETH (%.6f ETH)?", math.RoundDown(math.WeiToEth(maxAmount), 6)) { amountWei = maxAmount } else { @@ -66,7 +64,7 @@ func nodeWithdrawEth(amount string, yes bool) error { if err != nil { return fmt.Errorf("Invalid withdrawal amount '%s': %w", inputAmount, err) } - amountWei = eth.EthToWei(withdrawalAmount) + amountWei = math.EthToWei(withdrawalAmount) } @@ -94,7 +92,7 @@ func nodeWithdrawEth(amount string, yes bool) error { } // Prompt for confirmation - if prompt.Declined(yes, "Are you sure you want to withdraw %.6f ETH?", math.RoundDown(eth.WeiToEth(amountWei), 6)) { + if prompt.Declined(yes, "Are you sure you want to withdraw %.6f ETH?", math.RoundDown(math.WeiToEth(amountWei), 6)) { fmt.Println("Cancelled.") return nil } @@ -112,7 +110,7 @@ func nodeWithdrawEth(amount string, yes bool) error { } // Log & return - fmt.Printf("Successfully withdrew %.6f staked ETH.\n", math.RoundDown(eth.WeiToEth(amountWei), 6)) + fmt.Printf("Successfully withdrew %.6f staked ETH.\n", math.RoundDown(math.WeiToEth(amountWei), 6)) return nil } diff --git a/rocketpool-cli/node/withdraw-rpl.go b/rocketpool-cli/node/withdraw-rpl.go index 4351da3a7..90252c36f 100644 --- a/rocketpool-cli/node/withdraw-rpl.go +++ b/rocketpool-cli/node/withdraw-rpl.go @@ -7,14 +7,12 @@ import ( "strconv" "time" - "github.com/rocket-pool/smartnode/bindings/utils/eth" - cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - "github.com/rocket-pool/smartnode/shared/utils/math" ) func nodeWithdrawRpl(amount string, yes bool) error { @@ -51,9 +49,9 @@ func nodeWithdrawRpl(amount string, yes bool) error { fmt.Println() fmt.Println() - fmt.Printf("Your node has %.6f RPL on its legacy stake (previously associated to minipools) and %.6f RPL staked on its megapool.", math.RoundDown(eth.WeiToEth(status.RplStakeLegacy), 6), math.RoundDown(eth.WeiToEth(status.RplStakeMegapool), 6)) + fmt.Printf("Your node has %.6f RPL on its legacy stake (previously associated to minipools) and %.6f RPL staked on its megapool.", math.RoundDown(math.WeiToEth(status.RplStakeLegacy), 6), math.RoundDown(math.WeiToEth(status.RplStakeMegapool), 6)) fmt.Println() - fmt.Printf("Your node currently has %.6f RPL locked on pDAO proposals.", math.RoundDown(eth.WeiToEth(status.NodeRPLLocked), 6)) + fmt.Printf("Your node currently has %.6f RPL locked on pDAO proposals.", math.RoundDown(math.WeiToEth(status.NodeRPLLocked), 6)) fmt.Println() fmt.Printf("Your node's RPL withdrawal address is %s.\n", color.LightBlue(status.RPLWithdrawalAddress.String())) fmt.Println() @@ -69,9 +67,9 @@ func nodeWithdrawRpl(amount string, yes bool) error { // Print unstaking RPL details if !cooldownPassed && hasUnstakingRPL { - fmt.Printf("You have %.6f RPL currently unstaking until %s (%s from now).\n", math.RoundDown(eth.WeiToEth(status.UnstakingRPL), 6), unstakingPeriodEnd.Format(cliutils.TimeFormat), timeUntilUnstakingPeriodEnd.String()) + fmt.Printf("You have %.6f RPL currently unstaking until %s (%s from now).\n", math.RoundDown(math.WeiToEth(status.UnstakingRPL), 6), unstakingPeriodEnd.Format(cliutils.TimeFormat), timeUntilUnstakingPeriodEnd.String()) } else { - fmt.Printf("You have %.6f RPL unstaked and ready to be withdrawn to your RPL withdrawal address.\n", eth.WeiToEth(status.UnstakingRPL)) + fmt.Printf("You have %.6f RPL unstaked and ready to be withdrawn to your RPL withdrawal address.\n", math.WeiToEth(status.UnstakingRPL)) } // Prompt for a selection @@ -106,7 +104,7 @@ func nodeWithdrawRpl(amount string, yes bool) error { } // Prompt for confirmation - if prompt.Declined(yes, "Are you sure you want to withdraw %.6f unstaked RPL?", math.RoundDown(eth.WeiToEth(status.UnstakingRPL), 6)) { + if prompt.Declined(yes, "Are you sure you want to withdraw %.6f unstaked RPL?", math.RoundDown(math.WeiToEth(status.UnstakingRPL), 6)) { fmt.Println("Cancelled.") return nil } @@ -123,7 +121,7 @@ func nodeWithdrawRpl(amount string, yes bool) error { return err } - fmt.Printf("Successfully withdrew %.6f unstaked RPL.\n", math.RoundDown(eth.WeiToEth(status.UnstakingRPL), 6)) + fmt.Printf("Successfully withdrew %.6f unstaked RPL.\n", math.RoundDown(math.WeiToEth(status.UnstakingRPL), 6)) return nil } @@ -131,12 +129,12 @@ func nodeWithdrawRpl(amount string, yes bool) error { notifyUnstakingRPLStatus := func() { // Inform users that their unstaked RPL will be withdrawn before staked RPL is moved to unstaking if cooldownPassed && hasUnstakingRPL { - fmt.Printf("You have %.6f RPL unstaked and ready to be withdrawn to your RPL withdrawal address. Requesting to unstake more RPL will automatically withdraw %.6f RPL to the RPL withdrawal address.\n", eth.WeiToEth(status.UnstakingRPL), eth.WeiToEth(status.UnstakingRPL)) + fmt.Printf("You have %.6f RPL unstaked and ready to be withdrawn to your RPL withdrawal address. Requesting to unstake more RPL will automatically withdraw %.6f RPL to the RPL withdrawal address.\n", math.WeiToEth(status.UnstakingRPL), math.WeiToEth(status.UnstakingRPL)) fmt.Println() } // Inform users that the unstaking period will reset if they make another unstaking request if !cooldownPassed && hasUnstakingRPL { - fmt.Printf("You have %.6f RPL currently unstaking until %s (%s from now).\n", math.RoundDown(eth.WeiToEth(status.UnstakingRPL), 6), unstakingPeriodEnd.Format(cliutils.TimeFormat), timeUntilUnstakingPeriodEnd.String()) + fmt.Printf("You have %.6f RPL currently unstaking until %s (%s from now).\n", math.RoundDown(math.WeiToEth(status.UnstakingRPL), 6), unstakingPeriodEnd.Format(cliutils.TimeFormat), timeUntilUnstakingPeriodEnd.String()) color.YellowPrintln("Requesting to unstake additional RPL will reset the unstaking period.") color.YellowPrintf("The unstaking period is %s.\n", unstakingDurationString) @@ -173,7 +171,7 @@ func nodeWithdrawRpl(amount string, yes bool) error { // Print warning messages if applicable notifyUnstakingRPLStatus() - fmt.Printf("You have %.6f RPL staked on your megapool and can request to unstake up to %.6f RPL.\n", math.RoundDown(eth.WeiToEth(status.RplStakeMegapool), 6), math.RoundDown(eth.WeiToEth(&maxAmount), 6)) + fmt.Printf("You have %.6f RPL staked on your megapool and can request to unstake up to %.6f RPL.\n", math.RoundDown(math.WeiToEth(status.RplStakeMegapool), 6), math.RoundDown(math.WeiToEth(&maxAmount), 6)) // Prompt for maximum amount if prompt.Confirm("Would you like to unstake the maximum amount of staked RPL?") { amountWei = &maxAmount @@ -184,7 +182,7 @@ func nodeWithdrawRpl(amount string, yes bool) error { if err != nil { return fmt.Errorf("Invalid unstake amount '%s': %w", inputAmount, err) } - amountWei = eth.EthToWei(withdrawalAmount) + amountWei = math.EthToWei(withdrawalAmount) } // Check if RPL can be unstaked @@ -209,7 +207,7 @@ func nodeWithdrawRpl(amount string, yes bool) error { } // Prompt for confirmation - if prompt.Declined(yes, "Are you sure you want to unstake %.6f RPL?", math.RoundDown(eth.WeiToEth(amountWei), 6)) { + if prompt.Declined(yes, "Are you sure you want to unstake %.6f RPL?", math.RoundDown(math.WeiToEth(amountWei), 6)) { fmt.Println("Cancelled.") return nil } @@ -227,7 +225,7 @@ func nodeWithdrawRpl(amount string, yes bool) error { } // Log & return - fmt.Printf("Successfully unstaked %.6f RPL.\n", math.RoundDown(eth.WeiToEth(amountWei), 6)) + fmt.Printf("Successfully unstaked %.6f RPL.\n", math.RoundDown(math.WeiToEth(amountWei), 6)) return nil } @@ -257,9 +255,9 @@ func nodeWithdrawRpl(amount string, yes bool) error { // Print warning messages if applicable notifyUnstakingRPLStatus() - fmt.Printf("You have %.6f legacy RPL and can request to unstake up to %.6f RPL.\n", math.RoundDown(eth.WeiToEth(status.RplStakeLegacy), 6), math.RoundDown(eth.WeiToEth(&maxAmount), 6)) + fmt.Printf("You have %.6f legacy RPL and can request to unstake up to %.6f RPL.\n", math.RoundDown(math.WeiToEth(status.RplStakeLegacy), 6), math.RoundDown(math.WeiToEth(&maxAmount), 6)) // Prompt for maximum amount - if prompt.Confirm("Would you like to unstake the maximum amount of legacy RPL (%.6f RPL)?", math.RoundDown(eth.WeiToEth(&maxAmount), 6)) { + if prompt.Confirm("Would you like to unstake the maximum amount of legacy RPL (%.6f RPL)?", math.RoundDown(math.WeiToEth(&maxAmount), 6)) { amountWei = &maxAmount } else { // Prompt for custom amount @@ -268,12 +266,12 @@ func nodeWithdrawRpl(amount string, yes bool) error { if err != nil { return fmt.Errorf("Invalid withdrawal amount '%s': %w", inputAmount, err) } - amountWei = eth.EthToWei(withdrawalAmount) + amountWei = math.EthToWei(withdrawalAmount) } } else { fmt.Printf("Cannot unstake legacy RPL - you have %.6f legacy RPL, but are not allowed to unstake below %.6f RPL (%d%% of borrowed ETH).\n", - math.RoundDown(eth.WeiToEth(status.RplStakeLegacy), 6), - math.RoundDown(eth.WeiToEth(status.RplStakeThreshold), 6), + math.RoundDown(math.WeiToEth(status.RplStakeLegacy), 6), + math.RoundDown(math.WeiToEth(status.RplStakeThreshold), 6), uint32(status.RplStakeThresholdFraction*100), ) return nil @@ -305,7 +303,7 @@ func nodeWithdrawRpl(amount string, yes bool) error { } // Prompt for confirmation - if prompt.Declined(yes, "Are you sure you want to unstake %.6f legacy RPL? This may decrease your node's RPL rewards.", math.RoundDown(eth.WeiToEth(amountWei), 6)) { + if prompt.Declined(yes, "Are you sure you want to unstake %.6f legacy RPL? This may decrease your node's RPL rewards.", math.RoundDown(math.WeiToEth(amountWei), 6)) { fmt.Println("Cancelled.") return nil } @@ -323,7 +321,7 @@ func nodeWithdrawRpl(amount string, yes bool) error { } // Log & return - fmt.Printf("Successfully unstaked %.6f legacy RPL.\n", math.RoundDown(eth.WeiToEth(amountWei), 6)) + fmt.Printf("Successfully unstaked %.6f legacy RPL.\n", math.RoundDown(math.WeiToEth(amountWei), 6)) return nil } @@ -348,7 +346,7 @@ func nodeWithdrawRpl(amount string, yes bool) error { if err != nil { return fmt.Errorf("Invalid withdrawal amount '%s': %w", amount, err) } - amountWei = eth.EthToWei(withdrawalAmount) + amountWei = math.EthToWei(withdrawalAmount) } else { @@ -364,7 +362,7 @@ func nodeWithdrawRpl(amount string, yes bool) error { maxAmount.Sub(&maxAmount, status.NodeRPLLocked) if maxAmount.Sign() == 1 { // Prompt for maximum amount - if prompt.Confirm("Would you like to withdraw the maximum amount of staked RPL (%.6f RPL)?", math.RoundDown(eth.WeiToEth(&maxAmount), 6)) { + if prompt.Confirm("Would you like to withdraw the maximum amount of staked RPL (%.6f RPL)?", math.RoundDown(math.WeiToEth(&maxAmount), 6)) { amountWei = &maxAmount } else { @@ -374,13 +372,13 @@ func nodeWithdrawRpl(amount string, yes bool) error { if err != nil { return fmt.Errorf("Invalid withdrawal amount '%s': %w", inputAmount, err) } - amountWei = eth.EthToWei(withdrawalAmount) + amountWei = math.EthToWei(withdrawalAmount) } } else { fmt.Printf("Cannot withdraw staked RPL - you have %.6f RPL staked, but are not allowed to withdraw below %.6f RPL (%d%% collateral).\n", - math.RoundDown(eth.WeiToEth(status.TotalRplStake), 6), - math.RoundDown(eth.WeiToEth(status.RplStakeThreshold), 6), + math.RoundDown(math.WeiToEth(status.TotalRplStake), 6), + math.RoundDown(math.WeiToEth(status.RplStakeThreshold), 6), uint32(status.RplStakeThresholdFraction*100), ) return nil @@ -416,7 +414,7 @@ func nodeWithdrawRpl(amount string, yes bool) error { } // Prompt for confirmation - if prompt.Declined(yes, "Are you sure you want to withdraw %.6f staked RPL? This may decrease your node's RPL rewards.", math.RoundDown(eth.WeiToEth(amountWei), 6)) { + if prompt.Declined(yes, "Are you sure you want to withdraw %.6f staked RPL? This may decrease your node's RPL rewards.", math.RoundDown(math.WeiToEth(amountWei), 6)) { fmt.Println("Cancelled.") return nil } @@ -434,6 +432,6 @@ func nodeWithdrawRpl(amount string, yes bool) error { } // Log & return - fmt.Printf("Successfully withdrew %.6f staked RPL.\n", math.RoundDown(eth.WeiToEth(amountWei), 6)) + fmt.Printf("Successfully withdrew %.6f staked RPL.\n", math.RoundDown(math.WeiToEth(amountWei), 6)) return nil } diff --git a/rocketpool-cli/odao/get-settings.go b/rocketpool-cli/odao/get-settings.go index 957211318..f7b0cc654 100644 --- a/rocketpool-cli/odao/get-settings.go +++ b/rocketpool-cli/odao/get-settings.go @@ -4,7 +4,7 @@ import ( "fmt" "time" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/rocketpool" ) @@ -25,11 +25,11 @@ func getMemberSettings() error { // Log & return fmt.Printf("ODAO Voting Quorum Threshold: %f%%\n", response.Quorum*100) - fmt.Printf("Required Member RPL Bond: %f RPL\n", eth.WeiToEth(response.RPLBond)) + fmt.Printf("Required Member RPL Bond: %f RPL\n", math.WeiToEth(response.RPLBond)) fmt.Printf("Max Number of Unbonded Minipools: %d\n", response.MinipoolUnbondedMax) fmt.Printf("Consecutive Challenge Cooldown: %d Blocks\n", response.ChallengeCooldown) fmt.Printf("Challenge Meeting Window: %d Blocks\n", response.ChallengeWindow) - fmt.Printf("Cost for Non-members to Challenge Members: %f ETH\n", eth.WeiToEth(response.ChallengeCost)) + fmt.Printf("Cost for Non-members to Challenge Members: %f ETH\n", math.WeiToEth(response.ChallengeCost)) return nil } diff --git a/rocketpool-cli/odao/join.go b/rocketpool-cli/odao/join.go index 72415f64d..8d5b73cad 100644 --- a/rocketpool-cli/odao/join.go +++ b/rocketpool-cli/odao/join.go @@ -4,13 +4,11 @@ import ( "fmt" "math/big" - "github.com/rocket-pool/smartnode/bindings/utils/eth" - cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - "github.com/rocket-pool/smartnode/shared/utils/math" ) func join(yes bool, swap bool) error { @@ -37,7 +35,7 @@ func join(yes bool, swap bool) error { if status.AccountBalances.FixedSupplyRPL.Cmp(big.NewInt(0)) > 0 { // Confirm swapping RPL - if swap || prompt.Confirm("The node has a balance of %.6f old RPL. Would you like to swap it for new RPL before transferring your bond?", math.RoundDown(eth.WeiToEth(status.AccountBalances.FixedSupplyRPL), 6)) { + if swap || prompt.Confirm("The node has a balance of %.6f old RPL. Would you like to swap it for new RPL before transferring your bond?", math.RoundDown(math.WeiToEth(status.AccountBalances.FixedSupplyRPL), 6)) { // Check allowance allowance, err := rp.GetNodeSwapRplAllowance() @@ -115,7 +113,7 @@ func join(yes bool, swap bool) error { } // Prompt for confirmation - if prompt.Declined(yes, "Are you sure you want to swap %.6f old RPL for new RPL?", math.RoundDown(eth.WeiToEth(status.AccountBalances.FixedSupplyRPL), 6)) { + if prompt.Declined(yes, "Are you sure you want to swap %.6f old RPL for new RPL?", math.RoundDown(math.WeiToEth(status.AccountBalances.FixedSupplyRPL), 6)) { fmt.Println("Cancelled.") return nil } @@ -133,7 +131,7 @@ func join(yes bool, swap bool) error { } // Log - fmt.Printf("Successfully swapped %.6f old RPL for new RPL.\n", math.RoundDown(eth.WeiToEth(status.AccountBalances.FixedSupplyRPL), 6)) + fmt.Printf("Successfully swapped %.6f old RPL for new RPL.\n", math.RoundDown(math.WeiToEth(status.AccountBalances.FixedSupplyRPL), 6)) fmt.Println("") // If a custom nonce is set, increment it for the next transaction diff --git a/rocketpool-cli/odao/members.go b/rocketpool-cli/odao/members.go index 7105475ff..4ccf4d044 100644 --- a/rocketpool-cli/odao/members.go +++ b/rocketpool-cli/odao/members.go @@ -3,11 +3,9 @@ package odao import ( "fmt" - "github.com/rocket-pool/smartnode/bindings/utils/eth" - cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - "github.com/rocket-pool/smartnode/shared/utils/math" ) func getMembers() error { @@ -40,7 +38,7 @@ func getMembers() error { fmt.Printf("Node address: %s\n", member.Address.Hex()) fmt.Printf("Joined at: %s\n", cliutils.GetDateTimeString(member.JoinedTime)) fmt.Printf("Last proposal: %s\n", cliutils.GetDateTimeString(member.LastProposalTime)) - fmt.Printf("RPL bond amount: %.6f\n", math.RoundDown(eth.WeiToEth(member.RPLBondAmount), 6)) + fmt.Printf("RPL bond amount: %.6f\n", math.RoundDown(math.WeiToEth(member.RPLBondAmount), 6)) fmt.Printf("Unbonded minipools: %d\n", member.UnbondedValidatorCount) fmt.Printf("\n") } diff --git a/rocketpool-cli/odao/penalise-megapool.go b/rocketpool-cli/odao/penalise-megapool.go index f10e7e5bc..b226f56c9 100644 --- a/rocketpool-cli/odao/penalise-megapool.go +++ b/rocketpool-cli/odao/penalise-megapool.go @@ -7,12 +7,11 @@ import ( "github.com/ethereum/go-ethereum/common" - "github.com/rocket-pool/smartnode/bindings/utils/eth" cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - "github.com/rocket-pool/smartnode/shared/utils/math" ) func penaliseMegapool(megapoolAddress common.Address, block *big.Int, yes bool) error { @@ -31,7 +30,7 @@ func penaliseMegapool(megapoolAddress common.Address, block *big.Int, yes bool) return fmt.Errorf("Invalid amount '%s': %w\n", amountStr, err) } - amountWei := eth.EthToWei(amount) + amountWei := math.EthToWei(amount) // Check megapool debt can be repaid canPenalise, err := rp.CanPenaliseMegapool(megapoolAddress, block, amountWei) if err != nil { @@ -49,7 +48,7 @@ func penaliseMegapool(megapoolAddress common.Address, block *big.Int, yes bool) } // Prompt for confirmation - if prompt.Declined(yes, "Are you sure you want to penalise %.6f megapool %s at block %s?", math.RoundDown(eth.WeiToEth(amountWei), 6), megapoolAddress, block) { + if prompt.Declined(yes, "Are you sure you want to penalise %.6f megapool %s at block %s?", math.RoundDown(math.WeiToEth(amountWei), 6), megapoolAddress, block) { fmt.Println("Cancelled.") return nil } @@ -67,7 +66,7 @@ func penaliseMegapool(megapoolAddress common.Address, block *big.Int, yes bool) } // Log & return - fmt.Printf("Successfully penalised megapool %s with %.6f debt.\n", megapoolAddress, math.RoundDown(eth.WeiToEth(amountWei), 6)) + fmt.Printf("Successfully penalised megapool %s with %.6f debt.\n", megapoolAddress, math.RoundDown(math.WeiToEth(amountWei), 6)) return nil } diff --git a/rocketpool-cli/odao/propose-kick.go b/rocketpool-cli/odao/propose-kick.go index bef687c05..c3fbc38fc 100644 --- a/rocketpool-cli/odao/propose-kick.go +++ b/rocketpool-cli/odao/propose-kick.go @@ -9,13 +9,12 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/rocket-pool/smartnode/bindings/dao/trustednode" - "github.com/rocket-pool/smartnode/bindings/utils/eth" cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - "github.com/rocket-pool/smartnode/shared/utils/math" ) func proposeKick(member, fine string, yes bool) error { @@ -75,17 +74,17 @@ func proposeKick(member, fine string, yes bool) error { if err != nil { return fmt.Errorf("Invalid fine amount '%s': %w", fine, err) } - fineAmountWei = eth.EthToWei(fineAmount) + fineAmountWei = math.EthToWei(fineAmount) } else { // Prompt for custom amount - inputAmount := prompt.Prompt(fmt.Sprintf("Please enter an RPL fine amount to propose (max %.6f RPL):", math.RoundDown(eth.WeiToEth(selectedMember.RPLBondAmount), 6)), "^\\d+(\\.\\d+)?$", "Invalid amount") + inputAmount := prompt.Prompt(fmt.Sprintf("Please enter an RPL fine amount to propose (max %.6f RPL):", math.RoundDown(math.WeiToEth(selectedMember.RPLBondAmount), 6)), "^\\d+(\\.\\d+)?$", "Invalid amount") fineAmount, err := strconv.ParseFloat(inputAmount, 64) if err != nil { return fmt.Errorf("Invalid fine amount '%s': %w", inputAmount, err) } - fineAmountWei = eth.EthToWei(fineAmount) + fineAmountWei = math.EthToWei(fineAmount) } @@ -100,7 +99,7 @@ func proposeKick(member, fine string, yes bool) error { fmt.Println("The node must wait for the proposal cooldown period to pass before making another proposal.") } if canPropose.InsufficientRplBond { - fmt.Printf("The fine amount of %.6f RPL is greater than the member's bond of %.6f RPL.\n", math.RoundDown(eth.WeiToEth(fineAmountWei), 6), math.RoundDown(eth.WeiToEth(selectedMember.RPLBondAmount), 6)) + fmt.Printf("The fine amount of %.6f RPL is greater than the member's bond of %.6f RPL.\n", math.RoundDown(math.WeiToEth(fineAmountWei), 6), math.RoundDown(math.WeiToEth(selectedMember.RPLBondAmount), 6)) } return nil } @@ -130,7 +129,7 @@ func proposeKick(member, fine string, yes bool) error { } // Log & return - fmt.Printf("Successfully submitted a kick proposal with ID %d for node %s, with a fine of %.6f RPL.\n", response.ProposalId, selectedMember.Address.Hex(), math.RoundDown(eth.WeiToEth(fineAmountWei), 6)) + fmt.Printf("Successfully submitted a kick proposal with ID %d for node %s, with a fine of %.6f RPL.\n", response.ProposalId, selectedMember.Address.Hex(), math.RoundDown(math.WeiToEth(fineAmountWei), 6)) return nil } diff --git a/rocketpool-cli/odao/propose-settings.go b/rocketpool-cli/odao/propose-settings.go index 9f8c2674d..dd969ca2b 100644 --- a/rocketpool-cli/odao/propose-settings.go +++ b/rocketpool-cli/odao/propose-settings.go @@ -4,10 +4,9 @@ import ( "fmt" "time" - "github.com/rocket-pool/smartnode/bindings/utils/eth" - cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" ) @@ -74,7 +73,7 @@ func proposeSettingMembersRplBond(bondAmountEth float64, yes bool) error { defer rp.Close() // Check if proposal can be made - canPropose, err := rp.CanProposeTNDAOSettingMembersRplBond(eth.EthToWei(bondAmountEth)) + canPropose, err := rp.CanProposeTNDAOSettingMembersRplBond(math.EthToWei(bondAmountEth)) if err != nil { return err } @@ -99,7 +98,7 @@ func proposeSettingMembersRplBond(bondAmountEth float64, yes bool) error { } // Submit proposal - response, err := rp.ProposeTNDAOSettingMembersRplBond(eth.EthToWei(bondAmountEth)) + response, err := rp.ProposeTNDAOSettingMembersRplBond(math.EthToWei(bondAmountEth)) if err != nil { return err } diff --git a/rocketpool-cli/pdao/claim-bonds.go b/rocketpool-cli/pdao/claim-bonds.go index d5d7a8b17..cced4d630 100644 --- a/rocketpool-cli/pdao/claim-bonds.go +++ b/rocketpool-cli/pdao/claim-bonds.go @@ -6,10 +6,10 @@ import ( "strconv" "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" - "github.com/rocket-pool/smartnode/bindings/utils/eth" cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" @@ -71,7 +71,7 @@ func claimBonds(proposal string, yes bool) error { options := make([]string, len(claimableBonds)+1) options[0] = "All available proposals" for pi, bond := range claimableBonds { - options[pi+1] = fmt.Sprintf("Proposal %d (proposer: %t, unlockable: %.2f RPL, rewards: %.2f RPL)", bond.ProposalID, bond.IsProposer, eth.WeiToEth(bond.UnlockAmount), eth.WeiToEth(bond.RewardAmount)) + options[pi+1] = fmt.Sprintf("Proposal %d (proposer: %t, unlockable: %.2f RPL, rewards: %.2f RPL)", bond.ProposalID, bond.IsProposer, math.WeiToEth(bond.UnlockAmount), math.WeiToEth(bond.RewardAmount)) } selected, _ := prompt.Select("Please select a proposal to unlock bonds / claim rewards from:", options) diff --git a/rocketpool-cli/pdao/get-settings.go b/rocketpool-cli/pdao/get-settings.go index e86261183..633b832a7 100644 --- a/rocketpool-cli/pdao/get-settings.go +++ b/rocketpool-cli/pdao/get-settings.go @@ -3,7 +3,7 @@ package pdao import ( "fmt" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/rocketpool" ) @@ -25,29 +25,29 @@ func getSettings() error { fmt.Println("== Auction Settings ==") fmt.Printf("\tCreating New Lot Enabled: %t\n", response.Auction.IsCreateLotEnabled) fmt.Printf("\tBidding on Lots Enabled: %t\n", response.Auction.IsBidOnLotEnabled) - fmt.Printf("\tMin ETH per Lot: %.6f ETH\n", eth.WeiToEth(response.Auction.LotMinimumEthValue)) - fmt.Printf("\tMax ETH per Lot: %.6f ETH\n", eth.WeiToEth(response.Auction.LotMaximumEthValue)) + fmt.Printf("\tMin ETH per Lot: %.6f ETH\n", math.WeiToEth(response.Auction.LotMinimumEthValue)) + fmt.Printf("\tMax ETH per Lot: %.6f ETH\n", math.WeiToEth(response.Auction.LotMaximumEthValue)) fmt.Printf("\tLot Duration: %s\n", response.Auction.LotDuration) - fmt.Printf("\tStarting Price Ratio: %.2f%%\n", eth.WeiToEth(response.Auction.LotStartingPriceRatio)*100) - fmt.Printf("\tReserve Price Ratio: %.2f%%\n", eth.WeiToEth(response.Auction.LotReservePriceRatio)*100) + fmt.Printf("\tStarting Price Ratio: %.2f%%\n", math.WeiToEth(response.Auction.LotStartingPriceRatio)*100) + fmt.Printf("\tReserve Price Ratio: %.2f%%\n", math.WeiToEth(response.Auction.LotReservePriceRatio)*100) fmt.Println() // Deposit fmt.Println("== Deposit Settings ==") fmt.Printf("\tPool Deposits Enabled: %t\n", response.Deposit.IsDepositingEnabled) fmt.Printf("\tDeposit Assignments Enabled: %t\n", response.Deposit.AreDepositAssignmentsEnabled) - fmt.Printf("\tMin Pool Deposit: %.6f ETH\n", eth.WeiToEth(response.Deposit.MinimumDeposit)) - fmt.Printf("\tMax Deposit Pool Size: %.6f ETH\n", eth.WeiToEth(response.Deposit.MaximumDepositPoolSize)) + fmt.Printf("\tMin Pool Deposit: %.6f ETH\n", math.WeiToEth(response.Deposit.MinimumDeposit)) + fmt.Printf("\tMax Deposit Pool Size: %.6f ETH\n", math.WeiToEth(response.Deposit.MaximumDepositPoolSize)) fmt.Printf("\tMax Total Assigns Per Deposit: %d\n", response.Deposit.MaximumAssignmentsPerDeposit) fmt.Printf("\tMax Socialized Assigns Per Deposit: %d\n", response.Deposit.MaximumSocialisedAssignmentsPerDeposit) - fmt.Printf("\tDeposit Fee: %.2f%%\n", eth.WeiToEth(response.Deposit.DepositFee)*100) + fmt.Printf("\tDeposit Fee: %.2f%%\n", math.WeiToEth(response.Deposit.DepositFee)*100) fmt.Printf("\tExpress Queue Rate: %d\n", response.Deposit.ExpressQueueRate) fmt.Printf("\tExpress Queue Tickets Provision: %d\n", response.Deposit.ExpressQueueTicketsBaseProvision) fmt.Println() // Inflation fmt.Println("== Inflation Settings ==") - fmt.Printf("\tInterval Rate: %.6f\n", eth.WeiToEth(response.Inflation.IntervalRate)) + fmt.Printf("\tInterval Rate: %.6f\n", math.WeiToEth(response.Inflation.IntervalRate)) fmt.Printf("\tInterval Start: %s\n", response.Inflation.StartTime) fmt.Println() @@ -66,25 +66,25 @@ func getSettings() error { // Network fmt.Println("== Network Settings ==") - fmt.Printf("\toDAO Consensus Quorum: %.2f%%\n", eth.WeiToEth(response.Network.OracleDaoConsensusThreshold)*100) - fmt.Printf("\tNode Penalty Quorum: %.2f%%\n", eth.WeiToEth(response.Network.NodePenaltyThreshold)*100) - fmt.Printf("\tPenalty Size: %.2f%%\n", eth.WeiToEth(response.Network.PerPenaltyRate)*100) + fmt.Printf("\toDAO Consensus Quorum: %.2f%%\n", math.WeiToEth(response.Network.OracleDaoConsensusThreshold)*100) + fmt.Printf("\tNode Penalty Quorum: %.2f%%\n", math.WeiToEth(response.Network.NodePenaltyThreshold)*100) + fmt.Printf("\tPenalty Size: %.2f%%\n", math.WeiToEth(response.Network.PerPenaltyRate)*100) fmt.Printf("\tBalance Submission Enabled: %t\n", response.Network.IsSubmitBalancesEnabled) fmt.Printf("\tBalance Submission Freq: %s\n", response.Network.SubmitBalancesFrequency) fmt.Printf("\tPrice Submission Enabled: %t\n", response.Network.IsSubmitPricesEnabled) fmt.Printf("\tPrice Submission Freq: %s\n", response.Network.SubmitPricesFrequency) - fmt.Printf("\tMin Commission: %.2f%%\n", eth.WeiToEth(response.Network.MinimumNodeFee)*100) - fmt.Printf("\tTarget Commission: %.2f%%\n", eth.WeiToEth(response.Network.TargetNodeFee)*100) - fmt.Printf("\tMax Commission: %.2f%%\n", eth.WeiToEth(response.Network.MaximumNodeFee)*100) - fmt.Printf("\tCommission Demand Range: %.6f ETH\n", eth.WeiToEth(response.Network.NodeFeeDemandRange)) - fmt.Printf("\trETH Collateral Target: %.2f%%\n", eth.WeiToEth(response.Network.TargetRethCollateralRate)*100) + fmt.Printf("\tMin Commission: %.2f%%\n", math.WeiToEth(response.Network.MinimumNodeFee)*100) + fmt.Printf("\tTarget Commission: %.2f%%\n", math.WeiToEth(response.Network.TargetNodeFee)*100) + fmt.Printf("\tMax Commission: %.2f%%\n", math.WeiToEth(response.Network.MaximumNodeFee)*100) + fmt.Printf("\tCommission Demand Range: %.6f ETH\n", math.WeiToEth(response.Network.NodeFeeDemandRange)) + fmt.Printf("\trETH Collateral Target: %.2f%%\n", math.WeiToEth(response.Network.TargetRethCollateralRate)*100) fmt.Printf("\tRewards Submission Enabled: %t\n", response.Network.IsSubmitRewardsEnabled) - fmt.Printf("\tNode Commission Share: %.2f%%\n", eth.WeiToEth(response.Network.NodeCommissionShare)*100) - fmt.Printf("\tNode Commission Share Security Council Adder: %.2f%%\n", eth.WeiToEth(response.Network.NodeCommissionShareSecurityCouncilAdder)*100) - fmt.Printf("\tVoter Share: %.2f%%\n", eth.WeiToEth(response.Network.VoterShare)*100) - fmt.Printf("\tProtocol DAO Share: %.2f%%\n", eth.WeiToEth(response.Network.ProtocolDAOShare)*100) - fmt.Printf("\tMax Commission Share Security Council Adder: %.2f%%\n", eth.WeiToEth(response.Network.MaxNodeShareSecurityCouncilAdder)*100) - fmt.Printf("\tMax rETH balance delta: %.2f%%\n", eth.WeiToEth(response.Network.MaxRethBalanceDelta)*100) + fmt.Printf("\tNode Commission Share: %.2f%%\n", math.WeiToEth(response.Network.NodeCommissionShare)*100) + fmt.Printf("\tNode Commission Share Security Council Adder: %.2f%%\n", math.WeiToEth(response.Network.NodeCommissionShareSecurityCouncilAdder)*100) + fmt.Printf("\tVoter Share: %.2f%%\n", math.WeiToEth(response.Network.VoterShare)*100) + fmt.Printf("\tProtocol DAO Share: %.2f%%\n", math.WeiToEth(response.Network.ProtocolDAOShare)*100) + fmt.Printf("\tMax Commission Share Security Council Adder: %.2f%%\n", math.WeiToEth(response.Network.MaxNodeShareSecurityCouncilAdder)*100) + fmt.Printf("\tMax rETH balance delta: %.2f%%\n", math.WeiToEth(response.Network.MaxRethBalanceDelta)*100) fmt.Printf("\tAllow listed controllers: %v\n", response.Network.AllowListedControllers) fmt.Println() @@ -105,11 +105,11 @@ func getSettings() error { fmt.Printf("\tVoting Window (Phase 2): %s\n", response.Proposals.VotePhase2Time) fmt.Printf("\tVoting Start Delay: %s\n", response.Proposals.VoteDelayTime) fmt.Printf("\tExecute Window: %s\n", response.Proposals.ExecuteTime) - fmt.Printf("\tBond per Proposal: %.6f RPL\n", eth.WeiToEth(response.Proposals.ProposalBond)) - fmt.Printf("\tBond per Challenge: %.6f RPL\n", eth.WeiToEth(response.Proposals.ChallengeBond)) + fmt.Printf("\tBond per Proposal: %.6f RPL\n", math.WeiToEth(response.Proposals.ProposalBond)) + fmt.Printf("\tBond per Challenge: %.6f RPL\n", math.WeiToEth(response.Proposals.ChallengeBond)) fmt.Printf("\tChallenge Response Time: %s\n", response.Proposals.ChallengePeriod) - fmt.Printf("\tQuorum: %.2f%%\n", eth.WeiToEth(response.Proposals.Quorum)*100) - fmt.Printf("\tVeto Quorum: %.2f%%\n", eth.WeiToEth(response.Proposals.VetoQuorum)*100) + fmt.Printf("\tQuorum: %.2f%%\n", math.WeiToEth(response.Proposals.Quorum)*100) + fmt.Printf("\tVeto Quorum: %.2f%%\n", math.WeiToEth(response.Proposals.VetoQuorum)*100) fmt.Printf("\tTarget Block Age Limit: %d Blocks\n", response.Proposals.MaxBlockAge) fmt.Println() @@ -120,7 +120,7 @@ func getSettings() error { // Security fmt.Println("== Security Settings ==") - fmt.Printf("\tMember Quorum: %.2f%%\n", eth.WeiToEth(response.Security.MembersQuorum)*100) + fmt.Printf("\tMember Quorum: %.2f%%\n", math.WeiToEth(response.Security.MembersQuorum)*100) fmt.Printf("\tMember Leave Time: %s\n", response.Security.MembersLeaveTime) fmt.Printf("\tProposal Vote Time: %s\n", response.Security.ProposalVoteTime) fmt.Printf("\tProposal Execute Time: %s\n", response.Security.ProposalExecuteTime) @@ -130,13 +130,13 @@ func getSettings() error { // Megapool fmt.Println("== Megapool Settings ==") fmt.Printf("\tTime Before Dissolve: %s\n", response.Megapool.TimeBeforeDissolve) - fmt.Printf("\tDissolve Penalty: %.6f ETH\n", eth.WeiToEth(response.Megapool.DissolvePenalty)) - fmt.Printf("\tMax ETH penalty: %.6f ETH\n", eth.WeiToEth(response.Megapool.MaximumEthPenalty)) + fmt.Printf("\tDissolve Penalty: %.6f ETH\n", math.WeiToEth(response.Megapool.DissolvePenalty)) + fmt.Printf("\tMax ETH penalty: %.6f ETH\n", math.WeiToEth(response.Megapool.MaximumEthPenalty)) fmt.Printf("\tNotify Threshold: %d Epochs\n", response.Megapool.NotifyThreshold) - fmt.Printf("\tLate Notify Fine: %.6f ETH\n", eth.WeiToEth(response.Megapool.LateNotifyFine)) + fmt.Printf("\tLate Notify Fine: %.6f ETH\n", math.WeiToEth(response.Megapool.LateNotifyFine)) fmt.Printf("\tUser Distribute Delay: %d Epochs\n", response.Megapool.UserDistributeDelay) fmt.Printf("\tUser Distribute Delay with Shortfall: %d Epochs\n", response.Megapool.UserDistributeDelayWithShortfall) - fmt.Printf("\tPenalty Threshold: %.2f%%\n", eth.WeiToEth(response.Megapool.PenaltyThreshold)*100) + fmt.Printf("\tPenalty Threshold: %.2f%%\n", math.WeiToEth(response.Megapool.PenaltyThreshold)*100) return nil } diff --git a/rocketpool-cli/pdao/percentages.go b/rocketpool-cli/pdao/percentages.go index a3f0788d2..7dddeac75 100644 --- a/rocketpool-cli/pdao/percentages.go +++ b/rocketpool-cli/pdao/percentages.go @@ -3,9 +3,9 @@ package pdao import ( "fmt" - "github.com/rocket-pool/smartnode/bindings/utils/eth" cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" ) @@ -25,9 +25,9 @@ func getRewardsPercentages() error { } // Print the settings - fmt.Printf("Node Operators: %.2f%% (%s)\n", eth.WeiToEth(response.Node)*100, response.Node.String()) - fmt.Printf("Oracle DAO: %.2f%% (%s)\n", eth.WeiToEth(response.OracleDao)*100, response.OracleDao.String()) - fmt.Printf("Protocol DAO: %.2f%% (%s)\n", eth.WeiToEth(response.ProtocolDao)*100, response.ProtocolDao.String()) + fmt.Printf("Node Operators: %.2f%% (%s)\n", math.WeiToEth(response.Node)*100, response.Node.String()) + fmt.Printf("Oracle DAO: %.2f%% (%s)\n", math.WeiToEth(response.OracleDao)*100, response.OracleDao.String()) + fmt.Printf("Protocol DAO: %.2f%% (%s)\n", math.WeiToEth(response.ProtocolDao)*100, response.ProtocolDao.String()) return nil } diff --git a/rocketpool-cli/pdao/proposals.go b/rocketpool-cli/pdao/proposals.go index 696833cf2..3f7633dc4 100644 --- a/rocketpool-cli/pdao/proposals.go +++ b/rocketpool-cli/pdao/proposals.go @@ -3,18 +3,16 @@ package pdao import ( "encoding/hex" "fmt" - "math" "slices" "strings" "time" "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" utilsStrings "github.com/rocket-pool/smartnode/bindings/utils/strings" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" - utilsMath "github.com/rocket-pool/smartnode/shared/utils/math" ) func filterProposalState(state string, stateFilter string) bool { @@ -162,14 +160,14 @@ func getProposal(id uint64) error { } // Vote details - votingPowerFor := utilsMath.RoundDown(eth.WeiToEth(proposal.VotingPowerFor), 2) - votingPowerRequired := utilsMath.RoundUp(eth.WeiToEth(proposal.VotingPowerRequired), 2) - votingPowerToVeto := utilsMath.RoundDown(eth.WeiToEth(proposal.VotingPowerToVeto), 2) - vetoQuorum := utilsMath.RoundUp(eth.WeiToEth(proposal.VetoQuorum), 2) + votingPowerFor := math.RoundDown(math.WeiToEth(proposal.VotingPowerFor), 2) + votingPowerRequired := math.RoundUp(math.WeiToEth(proposal.VotingPowerRequired), 2) + votingPowerToVeto := math.RoundDown(math.WeiToEth(proposal.VotingPowerToVeto), 2) + vetoQuorum := math.RoundUp(math.WeiToEth(proposal.VetoQuorum), 2) fmt.Printf("Voting power for: %.2f / %.2f (%.2f%%)\n", votingPowerFor, votingPowerRequired, votingPowerFor/votingPowerRequired*100) - fmt.Printf("Voting power against: %.2f\n", utilsMath.RoundDown(eth.WeiToEth(proposal.VotingPowerAgainst), 2)) + fmt.Printf("Voting power against: %.2f\n", math.RoundDown(math.WeiToEth(proposal.VotingPowerAgainst), 2)) fmt.Printf("Against with veto: %.2f / %2.f (%.2f%%)\n", votingPowerToVeto, vetoQuorum, votingPowerToVeto/vetoQuorum*100) - fmt.Printf("Voting power abstained: %.2f\n", utilsMath.RoundDown(eth.WeiToEth(proposal.VotingPowerAbstained), 2)) + fmt.Printf("Voting power abstained: %.2f\n", math.RoundDown(math.WeiToEth(proposal.VotingPowerAbstained), 2)) if proposal.NodeVoteDirection != types.VoteDirection_NoVote { fmt.Printf("Node has voted: %s\n", types.VoteDirections[proposal.NodeVoteDirection]) } else { diff --git a/rocketpool-cli/pdao/propose-settings.go b/rocketpool-cli/pdao/propose-settings.go index 07caad445..1efe0dfd7 100644 --- a/rocketpool-cli/pdao/propose-settings.go +++ b/rocketpool-cli/pdao/propose-settings.go @@ -6,10 +6,10 @@ import ( "time" "github.com/rocket-pool/smartnode/bindings/settings/protocol" - "github.com/rocket-pool/smartnode/bindings/utils/eth" protocol131 "github.com/rocket-pool/smartnode/bindings/legacy/v1.3.1/protocol" cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" @@ -409,7 +409,7 @@ func proposeSetting(contract string, setting string, value string, yes bool) err fmt.Println("Cannot propose setting update:") if canPropose.InsufficientRpl { fmt.Printf("You do not have enough RPL staked but unlocked to make another proposal (unlocked: %.6f RPL, required: %.6f RPL).\n", - eth.WeiToEth(big.NewInt(0).Sub(canPropose.StakedRpl, canPropose.LockedRpl)), eth.WeiToEth(canPropose.ProposalBond), + math.WeiToEth(big.NewInt(0).Sub(canPropose.StakedRpl, canPropose.LockedRpl)), math.WeiToEth(canPropose.ProposalBond), ) } if canPropose.IsRplLockingDisallowed { diff --git a/rocketpool-cli/pdao/status.go b/rocketpool-cli/pdao/status.go index cb80e4f81..8a68b2c08 100644 --- a/rocketpool-cli/pdao/status.go +++ b/rocketpool-cli/pdao/status.go @@ -8,13 +8,12 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/bindings/utils/strings" cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" - "github.com/rocket-pool/smartnode/shared/utils/math" ) const ( @@ -103,15 +102,15 @@ func getStatus() error { default: fmt.Printf("The node has a voting delegate of %s which can represent it when voting on Rocket Pool onchain governance proposals.\n", color.LightBlue(response.OnchainVotingDelegateFormatted)) } - fmt.Printf("The node's local voting power: %.10f\n", eth.WeiToEth(response.VotingPower)) + fmt.Printf("The node's local voting power: %.10f\n", math.WeiToEth(response.VotingPower)) if response.IsNodeRegistered { - fmt.Printf("Total voting power delegated to the node: %.10f\n", eth.WeiToEth(response.TotalDelegatedVp)) + fmt.Printf("Total voting power delegated to the node: %.10f\n", math.WeiToEth(response.TotalDelegatedVp)) } else { fmt.Print("The node must register using 'rocketpool node register' to be eligible to receive delegated voting power.\n") } - fmt.Printf("Network total initialized voting power: %.10f\n", eth.WeiToEth(response.SumVotingPower)) + fmt.Printf("Network total initialized voting power: %.10f\n", math.WeiToEth(response.SumVotingPower)) fmt.Println("") // Claimable Bonds Status: @@ -120,7 +119,7 @@ func getStatus() error { fmt.Print("The node is allowed to lock RPL to create governance proposals/challenges.\n") if response.NodeRPLLocked.Cmp(big.NewInt(0)) != 0 { fmt.Printf("The node currently has %.6f RPL locked.\n", - math.RoundDown(eth.WeiToEth(response.NodeRPLLocked), 6)) + math.RoundDown(math.WeiToEth(response.NodeRPLLocked), 6)) } } else { diff --git a/rocketpool-cli/pdao/vote-proposal.go b/rocketpool-cli/pdao/vote-proposal.go index 0e7f706e3..f1c15d2bb 100644 --- a/rocketpool-cli/pdao/vote-proposal.go +++ b/rocketpool-cli/pdao/vote-proposal.go @@ -6,10 +6,10 @@ import ( "time" "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" @@ -90,11 +90,11 @@ func voteOnProposal(proposal, voteDirectionFlag string, yes bool) error { proposal.Message, proposal.PayloadStr, endTime, - eth.WeiToEth(proposal.VotingPowerRequired), - eth.WeiToEth(proposal.VotingPowerFor), - eth.WeiToEth(proposal.VotingPowerAgainst), - eth.WeiToEth(proposal.VotingPowerAbstained), - eth.WeiToEth(proposal.VotingPowerToVeto), + math.WeiToEth(proposal.VotingPowerRequired), + math.WeiToEth(proposal.VotingPowerFor), + math.WeiToEth(proposal.VotingPowerAgainst), + math.WeiToEth(proposal.VotingPowerAbstained), + math.WeiToEth(proposal.VotingPowerToVeto), proposal.ProposerAddress) } selected, _ := prompt.Select("Please select a proposal to vote on:", options) @@ -162,7 +162,7 @@ func voteOnProposal(proposal, voteDirectionFlag string, yes bool) error { } // Print the voting power - fmt.Printf("\n\nYour voting power on this proposal: %.10f\n\n", eth.WeiToEth(canVote.VotingPower)) + fmt.Printf("\n\nYour voting power on this proposal: %.10f\n\n", math.WeiToEth(canVote.VotingPower)) // Assign max fees err = gas.AssignMaxFeeAndLimit(canVote.GasLimits, rp, yes) diff --git a/rocketpool-cli/queue/assign-deposits.go b/rocketpool-cli/queue/assign-deposits.go index 53102461c..5b4015476 100644 --- a/rocketpool-cli/queue/assign-deposits.go +++ b/rocketpool-cli/queue/assign-deposits.go @@ -5,9 +5,9 @@ import ( "math/big" "strconv" - "github.com/rocket-pool/smartnode/bindings/utils/eth" cliutils "github.com/rocket-pool/smartnode/rocketpool-cli/cli" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/rocketpool" ) @@ -31,7 +31,7 @@ func assignDeposits(yes bool) error { return err } - validatorDeposit := eth.EthToWei(32) + validatorDeposit := math.EthToWei(32) if queueDetails.TotalLength == 0 { fmt.Println("There are no validators waiting in the queue.") return nil diff --git a/rocketpool-cli/queue/status.go b/rocketpool-cli/queue/status.go index 8298cdd07..61a72cd3b 100644 --- a/rocketpool-cli/queue/status.go +++ b/rocketpool-cli/queue/status.go @@ -3,11 +3,9 @@ package queue import ( "fmt" - "github.com/rocket-pool/smartnode/bindings/utils/eth" - + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" - "github.com/rocket-pool/smartnode/shared/utils/math" ) func getStatus() error { @@ -26,7 +24,7 @@ func getStatus() error { } // Print & return - fmt.Printf("The deposit pool has a balance of %.6f ETH.\n", math.RoundDown(eth.WeiToEth(status.DepositPoolBalance), 6)) + fmt.Printf("The deposit pool has a balance of %.6f ETH.\n", math.RoundDown(math.WeiToEth(status.DepositPoolBalance), 6)) var queueDetails api.GetQueueDetailsResponse // Get the express ticket count diff --git a/rocketpool/api/auction/utils.go b/rocketpool/api/auction/utils.go index bea9ee13e..c1f740ec8 100644 --- a/rocketpool/api/auction/utils.go +++ b/rocketpool/api/auction/utils.go @@ -11,8 +11,8 @@ import ( "github.com/rocket-pool/smartnode/bindings/network" "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/settings/protocol" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/types/api" ) @@ -96,7 +96,7 @@ func getSufficientRemainingRPLForLot(rp *rocketpool.RocketPool) (bool, error) { // Calculate lot minimum RPL amount var tmp big.Int var lotMinimumRplAmount big.Int - tmp.Mul(lotMinimumEthValue, eth.EthToWei(1)) + tmp.Mul(lotMinimumEthValue, math.EthToWei(1)) lotMinimumRplAmount.Quo(&tmp, rplPrice) // Return diff --git a/rocketpool/api/debug/validators.go b/rocketpool/api/debug/validators.go index 9629339be..a2b3aa6de 100644 --- a/rocketpool/api/debug/validators.go +++ b/rocketpool/api/debug/validators.go @@ -15,7 +15,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/minipool" "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/utils/rp" @@ -182,7 +182,7 @@ func getMinipoolBalanceDetails(rp *rocketpool.RocketPool, minipoolAddress common } // Get user balance at block - blockBalance := eth.GweiToWei(float64(validator.Balance)) + blockBalance := math.GweiToWei(float64(validator.Balance)) userBalance, err := mp.CalculateUserShare(blockBalance, opts) if err != nil { return err @@ -201,7 +201,7 @@ func getMinipoolBalanceDetails(rp *rocketpool.RocketPool, minipoolAddress common if status == types.Initialized || status == types.Prelaunch { // Use user deposit balance if initialized or prelaunch userBalance = userDepositBalance - blockBalance = eth.EthToWei(32) + blockBalance = math.EthToWei(32) nodeBalance.Sub(blockBalance, userBalance) } else if status == types.Dissolved { userBalance = big.NewInt(0) @@ -210,7 +210,7 @@ func getMinipoolBalanceDetails(rp *rocketpool.RocketPool, minipoolAddress common } else if !validator.Exists || validator.ActivationEpoch >= blockEpoch { // Use user deposit balance if validator not yet active on beacon chain at block userBalance = userDepositBalance - blockBalance = eth.EthToWei(32) + blockBalance = math.EthToWei(32) nodeBalance.Sub(blockBalance, userBalance) } @@ -219,9 +219,9 @@ func getMinipoolBalanceDetails(rp *rocketpool.RocketPool, minipoolAddress common validator.Pubkey.Hex(), validator.ActivationEpoch, nodeFee, - eth.WeiToEth(blockBalance), - eth.WeiToEth(nodeBalance), - eth.WeiToEth(userBalance), + math.WeiToEth(blockBalance), + math.WeiToEth(nodeBalance), + math.WeiToEth(userBalance), types.MinipoolStatuses[status], finalised, validator.ExitEpoch > blockEpoch, diff --git a/rocketpool/api/megapool/status.go b/rocketpool/api/megapool/status.go index 24d3459f6..7c5ac3250 100644 --- a/rocketpool/api/megapool/status.go +++ b/rocketpool/api/megapool/status.go @@ -9,7 +9,7 @@ import ( "github.com/urfave/cli/v3" "github.com/rocket-pool/smartnode/bindings/megapool" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/types/api" ) @@ -234,7 +234,7 @@ func getValidatorMapAndBalances(c *cli.Command) (*api.MegapoolValidatorMapAndRew // Store map in the api response response.MegapoolValidatorMap = statusValidators - weiPerGwei := big.NewInt(int64(eth.WeiPerGwei)) + weiPerGwei := big.NewInt(int64(math.WeiPerGwei)) totalBeaconBalanceWei := new(big.Int).SetUint64(totalBeaconBalance) totalEffectiveBeaconBalanceWei := new(big.Int).SetUint64(totalEffectiveBeaconBalance) totalBeaconBalanceWei = totalBeaconBalanceWei.Mul(totalBeaconBalanceWei, weiPerGwei) diff --git a/rocketpool/api/minipool/close.go b/rocketpool/api/minipool/close.go index f35129e4d..9cb4ceb0f 100644 --- a/rocketpool/api/minipool/close.go +++ b/rocketpool/api/minipool/close.go @@ -15,8 +15,8 @@ import ( "github.com/rocket-pool/smartnode/bindings/node" "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/flashbots" @@ -240,7 +240,7 @@ func getMinipoolCloseDetails(rp *rocketpool.RocketPool, minipoolAddress common.A } // Ignore minipools with an effective balance lower than v3 rewards-vs-exit cap - eight := eth.EthToWei(8) + eight := math.EthToWei(8) if effectiveBalance.Cmp(eight) == -1 { details.CanClose = false return details, nil diff --git a/rocketpool/api/minipool/distribute.go b/rocketpool/api/minipool/distribute.go index 36c025273..62deb5709 100644 --- a/rocketpool/api/minipool/distribute.go +++ b/rocketpool/api/minipool/distribute.go @@ -12,8 +12,8 @@ import ( "github.com/rocket-pool/smartnode/bindings/minipool" "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/types/api" ) @@ -143,7 +143,7 @@ func getDistributeBalanceDetails(c *cli.Command) (*api.GetDistributeBalanceDetai // Ignore minipools with an effective balance higher than v3 rewards-vs-exit cap distributableBalance := big.NewInt(0).Sub(minipoolDetails.Balance, minipoolDetails.Refund) - eight := eth.EthToWei(8) + eight := math.EthToWei(8) if distributableBalance.Cmp(eight) >= 0 { minipoolDetails.CanDistribute = false return nil diff --git a/rocketpool/api/minipool/rescue-dissolved.go b/rocketpool/api/minipool/rescue-dissolved.go index b3a4f513c..c74fd99b5 100644 --- a/rocketpool/api/minipool/rescue-dissolved.go +++ b/rocketpool/api/minipool/rescue-dissolved.go @@ -14,8 +14,8 @@ import ( "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" rptypes "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/contracts" @@ -174,7 +174,7 @@ func getMinipoolRescueDissolvedDetails(rp *rocketpool.RocketPool, w wallet.Walle details.BeaconBalance = big.NewInt(0).Mul(beaconBalanceGwei, big.NewInt(1e9)) // Make sure it doesn't already have 32 ETH in it - requiredBalance := eth.EthToWei(32) + requiredBalance := math.EthToWei(32) if details.BeaconBalance.Cmp(requiredBalance) >= 0 { details.CanRescue = false return details, nil @@ -184,7 +184,7 @@ func getMinipoolRescueDissolvedDetails(rp *rocketpool.RocketPool, w wallet.Walle details.CanRescue = true // Get the simulated deposit TX - one := eth.EthToWei(1) + one := math.EthToWei(1) opts, err := w.GetNodeAccountTransactor() if err != nil { return api.MinipoolRescueDissolvedDetails{}, err diff --git a/rocketpool/api/minipool/utils.go b/rocketpool/api/minipool/utils.go index 66b757321..07a3ac30b 100644 --- a/rocketpool/api/minipool/utils.go +++ b/rocketpool/api/minipool/utils.go @@ -16,8 +16,8 @@ import ( "github.com/rocket-pool/smartnode/bindings/settings/trustednode" "github.com/rocket-pool/smartnode/bindings/tokens" "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/types/api" rputils "github.com/rocket-pool/smartnode/shared/utils/rp" @@ -330,10 +330,10 @@ func getMinipoolValidatorDetails(rp *rocketpool.RocketPool, minipoolDetails api. } // Set validator balance - details.Balance = eth.GweiToWei(float64(validator.Balance)) + details.Balance = math.GweiToWei(float64(validator.Balance)) // Get expected node balance - blockBalance := eth.GweiToWei(float64(validator.Balance)) + blockBalance := math.GweiToWei(float64(validator.Balance)) nodeBalance, err := mp.CalculateNodeShare(blockBalance, nil) if err != nil { return api.ValidatorDetails{}, err diff --git a/rocketpool/api/network/stats.go b/rocketpool/api/network/stats.go index ed74ef071..feee94601 100644 --- a/rocketpool/api/network/stats.go +++ b/rocketpool/api/network/stats.go @@ -13,9 +13,9 @@ import ( "github.com/rocket-pool/smartnode/bindings/network" "github.com/rocket-pool/smartnode/bindings/node" "github.com/rocket-pool/smartnode/bindings/tokens" - "github.com/rocket-pool/smartnode/bindings/utils/eth" rpstate "github.com/rocket-pool/smartnode/bindings/utils/state" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/types/api" ) @@ -41,7 +41,7 @@ func getStats(c *cli.Command) (*api.NetworkStatsResponse, error) { wg.Go(func() error { balance, err := deposit.GetBalance(rp, nil) if err == nil { - response.DepositPoolBalance = eth.WeiToEth(balance) + response.DepositPoolBalance = math.WeiToEth(balance) } return err }) @@ -50,7 +50,7 @@ func getStats(c *cli.Command) (*api.NetworkStatsResponse, error) { wg.Go(func() error { minipoolQueueCapacity, err := minipool.GetQueueCapacity(rp, nil) if err == nil { - response.MinipoolCapacity = eth.WeiToEth(minipoolQueueCapacity.Total) + response.MinipoolCapacity = math.WeiToEth(minipoolQueueCapacity.Total) } return err }) @@ -107,7 +107,7 @@ func getStats(c *cli.Command) (*api.NetworkStatsResponse, error) { wg.Go(func() error { rplPrice, err := network.GetRPLPrice(rp, nil) if err == nil { - response.RplPrice = eth.WeiToEth(rplPrice) + response.RplPrice = math.WeiToEth(rplPrice) } return err }) @@ -116,7 +116,7 @@ func getStats(c *cli.Command) (*api.NetworkStatsResponse, error) { wg.Go(func() error { totalStaked, err := node.GetTotalStakedRPL(rp, nil) if err == nil { - response.TotalRplStaked = eth.WeiToEth(totalStaked) + response.TotalRplStaked = math.WeiToEth(totalStaked) } return err }) @@ -125,7 +125,7 @@ func getStats(c *cli.Command) (*api.NetworkStatsResponse, error) { wg.Go(func() error { megapoolStaked, err := node.GetTotalMegapoolStakedRPL(rp, nil) if err == nil { - response.TotalMegapoolRplStaked = eth.WeiToEth(megapoolStaked) + response.TotalMegapoolRplStaked = math.WeiToEth(megapoolStaked) } return err }) @@ -134,7 +134,7 @@ func getStats(c *cli.Command) (*api.NetworkStatsResponse, error) { wg.Go(func() error { legacyStaked, err := node.GetTotalLegacyStakedRPL(rp, nil) if err == nil { - response.TotalLegacyRplStaked = eth.WeiToEth(legacyStaked) + response.TotalLegacyRplStaked = math.WeiToEth(legacyStaked) } return err }) @@ -171,7 +171,7 @@ func getStats(c *cli.Command) (*api.NetworkStatsResponse, error) { return fmt.Errorf("error getting smoothing pool balance: %w", err) } - response.SmoothingPoolBalance = eth.WeiToEth(smoothingPoolBalance) + response.SmoothingPoolBalance = math.WeiToEth(smoothingPoolBalance) return nil }) diff --git a/rocketpool/api/node/claim-rewards.go b/rocketpool/api/node/claim-rewards.go index 131574c9c..1ee5f8d0c 100644 --- a/rocketpool/api/node/claim-rewards.go +++ b/rocketpool/api/node/claim-rewards.go @@ -18,7 +18,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/config" rprewards "github.com/rocket-pool/smartnode/shared/services/rewards" @@ -173,20 +173,20 @@ func getRewardsInfo(c *cli.Command) (*api.NodeGetRewardsInfoResponse, error) { } // bonded eth = total validators * 32 - borrowed - totalBorrowedEth := eth.WeiToEth(response.EthBorrowed) + eth.WeiToEth(response.PendingBorrowAmount) + totalBorrowedEth := math.WeiToEth(response.EthBorrowed) + math.WeiToEth(response.PendingBorrowAmount) totalBondedEth := float64(totalActiveValidators)*32.0 - totalBorrowedEth // Calculate collateral ratios if totalBondedEth <= 0 { response.BondedCollateralRatio = 0 } else { - response.BondedCollateralRatio = eth.WeiToEth(response.RplPrice) * eth.WeiToEth(response.RplStake) / totalBondedEth + response.BondedCollateralRatio = math.WeiToEth(response.RplPrice) * math.WeiToEth(response.RplStake) / totalBondedEth } if totalBorrowedEth <= 0 { response.BorrowedCollateralRatio = 0 } else { - response.BorrowedCollateralRatio = eth.WeiToEth(response.RplPrice) * eth.WeiToEth(response.RplStake) / totalBorrowedEth + response.BorrowedCollateralRatio = math.WeiToEth(response.RplPrice) * math.WeiToEth(response.RplStake) / totalBorrowedEth } } diff --git a/rocketpool/api/node/create-vacant-minipool.go b/rocketpool/api/node/create-vacant-minipool.go index 5f0d2623e..3c8573eb2 100644 --- a/rocketpool/api/node/create-vacant-minipool.go +++ b/rocketpool/api/node/create-vacant-minipool.go @@ -16,7 +16,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/settings/protocol" "github.com/rocket-pool/smartnode/bindings/settings/trustednode" rptypes "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/types/api" @@ -106,7 +106,7 @@ func canCreateVacantMinipool(c *cli.Command, amountWei *big.Int, minNodeFee floa } // Check data - validatorEthWei := eth.EthToWei(ValidatorEth) + validatorEthWei := math.EthToWei(ValidatorEth) matchRequest := big.NewInt(0).Sub(validatorEthWei, amountWei) availableToMatch := big.NewInt(0).Sub(ethMatchedLimit, ethMatched) diff --git a/rocketpool/api/node/distributor.go b/rocketpool/api/node/distributor.go index 60f423ff5..6ea64125d 100644 --- a/rocketpool/api/node/distributor.go +++ b/rocketpool/api/node/distributor.go @@ -10,8 +10,8 @@ import ( "golang.org/x/sync/errgroup" "github.com/rocket-pool/smartnode/bindings/node" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/types/api" ) @@ -176,7 +176,7 @@ func canDistribute(c *cli.Command) (*api.NodeCanDistributeResponse, error) { if err != nil { return fmt.Errorf("error getting node share for distributor %s: %w", distributorAddress.Hex(), err) } - response.NodeShare = eth.WeiToEth(nodeShareRaw) + response.NodeShare = math.WeiToEth(nodeShareRaw) return nil }) diff --git a/rocketpool/api/node/rewards.go b/rocketpool/api/node/rewards.go index c7e004e6e..675b27064 100644 --- a/rocketpool/api/node/rewards.go +++ b/rocketpool/api/node/rewards.go @@ -2,7 +2,6 @@ package node import ( "fmt" - "math" "math/big" "time" @@ -16,8 +15,8 @@ import ( "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/tokens" "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" rpstate "github.com/rocket-pool/smartnode/bindings/utils/state" + "github.com/rocket-pool/smartnode/shared/math" "github.com/urfave/cli/v3" "golang.org/x/sync/errgroup" @@ -87,7 +86,7 @@ func getMinipoolBalanceDetails(rp *rocketpool.RocketPool, minipoolAddress common if err != nil { return minipoolBalanceDetails{}, err } - blockBalance := eth.GweiToWei(float64(validator.Balance)) + blockBalance := math.GweiToWei(float64(validator.Balance)) // Data var wg errgroup.Group @@ -285,10 +284,10 @@ func getRewards(c *cli.Command) (*api.NodeRewardsResponse, error) { } if err == nil { - response.CumulativeRplRewards = eth.WeiToEth(rplRewards) - response.UnclaimedRplRewards = eth.WeiToEth(unclaimedRplRewardsWei) - response.CumulativeEthRewards = eth.WeiToEth(ethRewards) - response.UnclaimedEthRewards = eth.WeiToEth(unclaimedEthRewardsWei) + response.CumulativeRplRewards = math.WeiToEth(rplRewards) + response.UnclaimedRplRewards = math.WeiToEth(unclaimedRplRewardsWei) + response.CumulativeEthRewards = math.WeiToEth(ethRewards) + response.UnclaimedEthRewards = math.WeiToEth(unclaimedEthRewardsWei) } return err }) @@ -315,7 +314,7 @@ func getRewards(c *cli.Command) (*api.NodeRewardsResponse, error) { wg.Go(func() error { stake, err := node.GetNodeStakedRPL(rp, nodeAccount.Address, nil) if err == nil { - response.TotalRplStake = eth.WeiToEth(stake) + response.TotalRplStake = math.WeiToEth(stake) } return err }) @@ -358,7 +357,7 @@ func getRewards(c *cli.Command) (*api.NodeRewardsResponse, error) { // Get the node operator rewards percent wg.Go(func() error { nodeOperatorRewardsPercentRaw, err := rewards.GetNodeOperatorRewardsPercent(rp, nil) - nodeOperatorRewardsPercent = eth.WeiToEth(nodeOperatorRewardsPercentRaw) + nodeOperatorRewardsPercent = math.WeiToEth(nodeOperatorRewardsPercentRaw) if err != nil { return err } @@ -396,21 +395,21 @@ func getRewards(c *cli.Command) (*api.NodeRewardsResponse, error) { return nil, err } for _, minipool := range minipoolDetails { - totalDepositBalance += eth.WeiToEth(minipool.nodeDeposit) - totalNodeShare += eth.WeiToEth(minipool.nodeBalance) + totalDepositBalance += math.WeiToEth(minipool.nodeDeposit) + totalNodeShare += math.WeiToEth(minipool.nodeBalance) } response.BeaconRewards = totalNodeShare - totalDepositBalance // Calculate the estimated rewards rewardsIntervalDays := response.RewardsInterval.Seconds() / (60 * 60 * 24) - inflationPerDay := eth.WeiToEth(inflationInterval) - totalRplAtNextCheckpoint := (math.Pow(inflationPerDay, float64(rewardsIntervalDays)) - 1) * eth.WeiToEth(totalRplSupply) + inflationPerDay := math.WeiToEth(inflationInterval) + totalRplAtNextCheckpoint := (math.Pow(inflationPerDay, float64(rewardsIntervalDays)) - 1) * math.WeiToEth(totalRplSupply) if totalRplAtNextCheckpoint < 0 { totalRplAtNextCheckpoint = 0 } if totalEffectiveStake.Cmp(big.NewInt(0)) == 1 { - response.EstimatedRewards = response.EffectiveRplStake / eth.WeiToEth(totalEffectiveStake) * totalRplAtNextCheckpoint * nodeOperatorRewardsPercent + response.EstimatedRewards = response.EffectiveRplStake / math.WeiToEth(totalEffectiveStake) * totalRplAtNextCheckpoint * nodeOperatorRewardsPercent } if response.Trusted { @@ -456,8 +455,8 @@ func getRewards(c *cli.Command) (*api.NodeRewardsResponse, error) { } if err == nil { - response.CumulativeTrustedRplRewards = eth.WeiToEth(rplRewards) - response.UnclaimedTrustedRplRewards = eth.WeiToEth(unclaimedRplRewardsWei) + response.CumulativeTrustedRplRewards = math.WeiToEth(rplRewards) + response.UnclaimedTrustedRplRewards = math.WeiToEth(unclaimedRplRewardsWei) } return err }) @@ -475,7 +474,7 @@ func getRewards(c *cli.Command) (*api.NodeRewardsResponse, error) { // Get the trusted node operator rewards percent wg2.Go(func() error { trustedNodeOperatorRewardsPercentRaw, err := rewards.GetTrustedNodeOperatorRewardsPercent(rp, nil) - trustedNodeOperatorRewardsPercent = eth.WeiToEth(trustedNodeOperatorRewardsPercentRaw) + trustedNodeOperatorRewardsPercent = math.WeiToEth(trustedNodeOperatorRewardsPercentRaw) if err != nil { return err } @@ -486,7 +485,7 @@ func getRewards(c *cli.Command) (*api.NodeRewardsResponse, error) { wg2.Go(func() error { bond, err := trustednode.GetMemberRPLBondAmount(rp, nodeAccount.Address, nil) if err == nil { - response.TrustedRplBond = eth.WeiToEth(bond) + response.TrustedRplBond = math.WeiToEth(bond) } return err }) diff --git a/rocketpool/api/node/send.go b/rocketpool/api/node/send.go index 47bc06ef3..1cd2444cf 100644 --- a/rocketpool/api/node/send.go +++ b/rocketpool/api/node/send.go @@ -14,7 +14,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/erc20" "github.com/rocket-pool/smartnode/bindings/tokens" "github.com/rocket-pool/smartnode/bindings/transactions" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/types/api" @@ -104,7 +104,7 @@ func canNodeSend(c *cli.Command, amountRaw float64, token string, to common.Addr return nil, fmt.Errorf("error creating ERC20 contract binding: %w", err) } - amountWei := eth.EthToWeiWithDecimals(amountRaw, contract.Decimals) + amountWei := math.EthToWeiWithDecimals(amountRaw, contract.Decimals) response.TokenName = contract.Name response.TokenSymbol = contract.Symbol @@ -114,7 +114,7 @@ func canNodeSend(c *cli.Command, amountRaw float64, token string, to common.Addr return nil, fmt.Errorf("error getting ERC20 balance: %w", err) } - response.Balance = eth.WeiToEthWithDecimals(balance, contract.Decimals) + response.Balance = math.WeiToEthWithDecimals(balance, contract.Decimals) response.InsufficientBalance = (amountWei.Cmp(balance) > 0) // Get the gas info @@ -125,7 +125,7 @@ func canNodeSend(c *cli.Command, amountRaw float64, token string, to common.Addr response.GasLimits = gasLimits } else { // Handle well-known token types - amountWei := eth.EthToWei(amountRaw) + amountWei := math.EthToWei(amountRaw) var balanceWei *big.Int switch token { case "eth": @@ -197,7 +197,7 @@ func canNodeSend(c *cli.Command, amountRaw float64, token string, to common.Addr response.GasLimits = gasLimits } - response.Balance = eth.WeiToEth(balanceWei) + response.Balance = math.WeiToEth(balanceWei) } // Update & return response @@ -236,7 +236,7 @@ func nodeSend(c *cli.Command, amountRaw float64, token string, to common.Address return nil, fmt.Errorf("error creating ERC20 contract binding: %w", err) } - amountWei := eth.EthToWeiWithDecimals(amountRaw, contract.Decimals) + amountWei := math.EthToWeiWithDecimals(amountRaw, contract.Decimals) tx, err := contract.Transfer(to, amountWei, opts) if err != nil { @@ -244,7 +244,7 @@ func nodeSend(c *cli.Command, amountRaw float64, token string, to common.Address } response.TxHash = tx.Hash() } else { - amountWei := eth.EthToWei(amountRaw) + amountWei := math.EthToWei(amountRaw) // Handle token type switch token { case "eth": diff --git a/rocketpool/api/node/status.go b/rocketpool/api/node/status.go index 04ee6458c..d341461cc 100644 --- a/rocketpool/api/node/status.go +++ b/rocketpool/api/node/status.go @@ -21,10 +21,10 @@ import ( "github.com/rocket-pool/smartnode/bindings/settings/protocol" "github.com/rocket-pool/smartnode/bindings/tokens" "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" mp "github.com/rocket-pool/smartnode/rocketpool/api/minipool" "github.com/rocket-pool/smartnode/rocketpool/api/pdao" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/types/api" @@ -437,8 +437,8 @@ func getStatus(c *cli.Command) (*api.NodeStatusResponse, error) { return nil, err } - response.BondedCollateralRatio = eth.WeiToEth(rplPrice) * eth.WeiToEth(response.TotalRplStake) / (float64(totalActiveValidators)*32.0 - eth.WeiToEth(response.EthBorrowed) - eth.WeiToEth(response.PendingBorrowAmount)) - response.BorrowedCollateralRatio = eth.WeiToEth(rplPrice) * eth.WeiToEth(response.TotalRplStake) / (eth.WeiToEth(response.EthBorrowed) + eth.WeiToEth(response.PendingBorrowAmount)) + response.BondedCollateralRatio = math.WeiToEth(rplPrice) * math.WeiToEth(response.TotalRplStake) / (float64(totalActiveValidators)*32.0 - math.WeiToEth(response.EthBorrowed) - math.WeiToEth(response.PendingBorrowAmount)) + response.BorrowedCollateralRatio = math.WeiToEth(rplPrice) * math.WeiToEth(response.TotalRplStake) / (math.WeiToEth(response.EthBorrowed) + math.WeiToEth(response.PendingBorrowAmount)) // Calculate the "eligible" info (ignoring pending bond reductions) based on the Beacon Chain _, _, pendingEligibleBorrowedEth, pendingEligibleBondedEth, err := getTrueBorrowAndBondAmounts(rp, bc, nodeAccount.Address) @@ -452,18 +452,18 @@ func getStatus(c *cli.Command) (*api.NodeStatusResponse, error) { response.PendingMaximumRplStake = pendingTrueMaximumStake - pendingEligibleBondedEthFloat := eth.WeiToEth(pendingEligibleBondedEth) + pendingEligibleBondedEthFloat := math.WeiToEth(pendingEligibleBondedEth) if pendingEligibleBondedEthFloat == 0 { response.PendingBondedCollateralRatio = 0 } else { - response.PendingBondedCollateralRatio = eth.WeiToEth(rplPrice) * eth.WeiToEth(response.TotalRplStake) / pendingEligibleBondedEthFloat + response.PendingBondedCollateralRatio = math.WeiToEth(rplPrice) * math.WeiToEth(response.TotalRplStake) / pendingEligibleBondedEthFloat } - pendingEligibleBorrowedEthFloat := eth.WeiToEth(pendingEligibleBorrowedEth) + pendingEligibleBorrowedEthFloat := math.WeiToEth(pendingEligibleBorrowedEth) if pendingEligibleBorrowedEthFloat == 0 { response.PendingBorrowedCollateralRatio = 0 } else { - response.PendingBorrowedCollateralRatio = eth.WeiToEth(rplPrice) * eth.WeiToEth(response.TotalRplStake) / pendingEligibleBorrowedEthFloat + response.PendingBorrowedCollateralRatio = math.WeiToEth(rplPrice) * math.WeiToEth(response.TotalRplStake) / pendingEligibleBorrowedEthFloat } } else { response.BorrowedCollateralRatio = -1 diff --git a/rocketpool/api/odao/propose-kick.go b/rocketpool/api/odao/propose-kick.go index 3f37a89ef..5ba1f581a 100644 --- a/rocketpool/api/odao/propose-kick.go +++ b/rocketpool/api/odao/propose-kick.go @@ -10,11 +10,10 @@ import ( "golang.org/x/sync/errgroup" "github.com/rocket-pool/smartnode/bindings/dao/trustednode" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/types/api" - "github.com/rocket-pool/smartnode/shared/utils/math" ) func canProposeKick(c *cli.Command, memberAddress common.Address, fineAmountWei *big.Int) (*api.CanProposeTNDAOKickResponse, error) { @@ -74,7 +73,7 @@ func canProposeKick(c *cli.Command, memberAddress common.Address, fineAmountWei if err != nil { return err } - message := fmt.Sprintf("kick %s (%s) with %.6f RPL fine", memberId, memberUrl, math.RoundDown(eth.WeiToEth(fineAmountWei), 6)) + message := fmt.Sprintf("kick %s (%s) with %.6f RPL fine", memberId, memberUrl, math.RoundDown(math.WeiToEth(fineAmountWei), 6)) gasLimits, err := trustednode.EstimateProposeKickMemberGas(rp, message, memberAddress, fineAmountWei, opts) if err == nil { response.GasLimits = gasLimits @@ -130,7 +129,7 @@ func proposeKick(c *cli.Command, memberAddress common.Address, fineAmountWei *bi } // Submit proposal - message := fmt.Sprintf("kick %s (%s) with %.6f RPL fine", memberId, memberUrl, math.RoundDown(eth.WeiToEth(fineAmountWei), 6)) + message := fmt.Sprintf("kick %s (%s) with %.6f RPL fine", memberId, memberUrl, math.RoundDown(math.WeiToEth(fineAmountWei), 6)) proposalId, hash, err := trustednode.ProposeKickMember(rp, message, memberAddress, fineAmountWei, opts) if err != nil { return nil, err diff --git a/rocketpool/api/pdao/percentages.go b/rocketpool/api/pdao/percentages.go index e579cdb9e..ff0a95188 100644 --- a/rocketpool/api/pdao/percentages.go +++ b/rocketpool/api/pdao/percentages.go @@ -11,7 +11,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/dao/protocol" rpnode "github.com/rocket-pool/smartnode/bindings/node" psettings "github.com/rocket-pool/smartnode/bindings/settings/protocol" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/types/api" ) @@ -44,7 +44,7 @@ func getRewardsPercentages(c *cli.Command) (*api.PDAOGetRewardsPercentagesRespon func canProposeRewardsPercentages(c *cli.Command, node *big.Int, odao *big.Int, pdao *big.Int) (*api.PDAOCanProposeRewardsPercentagesResponse, error) { // Validate sum of percentages == 100% - one := eth.EthToWei(1) + one := math.EthToWei(1) sum := big.NewInt(0).Set(node) sum.Add(sum, odao) sum.Add(sum, pdao) diff --git a/rocketpool/node/collectors/demand-collector.go b/rocketpool/node/collectors/demand-collector.go index c6eda8046..6a67ff37d 100644 --- a/rocketpool/node/collectors/demand-collector.go +++ b/rocketpool/node/collectors/demand-collector.go @@ -4,7 +4,7 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/rocket-pool/smartnode/bindings/rocketpool" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/shared/math" ) const namespace = "rocketpool" @@ -83,10 +83,10 @@ func (collector *DemandCollector) Collect(channel chan<- prometheus.Metric) { return } - balanceFloat := eth.WeiToEth(state.NetworkDetails.DepositPoolBalance) - excessFloat := eth.WeiToEth(state.NetworkDetails.DepositPoolExcess) - totalFloat := eth.WeiToEth(state.NetworkDetails.QueueCapacity.Total) - effectiveFloat := eth.WeiToEth(state.NetworkDetails.QueueCapacity.Effective) + balanceFloat := math.WeiToEth(state.NetworkDetails.DepositPoolBalance) + excessFloat := math.WeiToEth(state.NetworkDetails.DepositPoolExcess) + totalFloat := math.WeiToEth(state.NetworkDetails.QueueCapacity.Total) + effectiveFloat := math.WeiToEth(state.NetworkDetails.QueueCapacity.Effective) queueLength := float64(state.NetworkDetails.QueueLength.Uint64()) channel <- prometheus.MustNewConstMetric( diff --git a/rocketpool/node/collectors/node-collector.go b/rocketpool/node/collectors/node-collector.go index a72b33fd0..d0b502ca9 100644 --- a/rocketpool/node/collectors/node-collector.go +++ b/rocketpool/node/collectors/node-collector.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "log" - "math" "math/big" "time" @@ -15,7 +14,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/deposit" "github.com/rocket-pool/smartnode/bindings/megapool" "github.com/rocket-pool/smartnode/bindings/rocketpool" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/config" @@ -419,37 +418,37 @@ func (collector *NodeCollector) Collect(channel chan<- prometheus.Metric) { // Sync var wg errgroup.Group - nodeLegacyStakedRpl := eth.WeiToEth(nd.LegacyStakedRPL) // TODO: update all metrics to account for saturn - nodeMegapoolStakedRpl := eth.WeiToEth(nd.MegapoolStakedRPL) - effectiveStakedRpl := eth.WeiToEth(nd.EffectiveRPLStake) - megapoolQueueBond := eth.WeiToEth(megapoolDetails.NodeQueuedBond) + nodeLegacyStakedRpl := math.WeiToEth(nd.LegacyStakedRPL) // TODO: update all metrics to account for saturn + nodeMegapoolStakedRpl := math.WeiToEth(nd.MegapoolStakedRPL) + effectiveStakedRpl := math.WeiToEth(nd.EffectiveRPLStake) + megapoolQueueBond := math.WeiToEth(megapoolDetails.NodeQueuedBond) rewardsInterval := state.NetworkDetails.IntervalDuration inflationInterval := state.NetworkDetails.RPLInflationIntervalRate totalRplSupply := state.NetworkDetails.RPLTotalSupply - nodeOperatorRewardsPercent := eth.WeiToEth(state.NetworkDetails.NodeOperatorRewardsPercent) + nodeOperatorRewardsPercent := math.WeiToEth(state.NetworkDetails.NodeOperatorRewardsPercent) previousIntervalTotalNodeWeight := big.NewInt(0) - ethBalance := eth.WeiToEth(nd.BalanceETH) - oldRplBalance := eth.WeiToEth(nd.BalanceOldRPL) - newRplBalance := eth.WeiToEth(nd.BalanceRPL) - rethBalance := eth.WeiToEth(nd.BalanceRETH) + ethBalance := math.WeiToEth(nd.BalanceETH) + oldRplBalance := math.WeiToEth(nd.BalanceOldRPL) + newRplBalance := math.WeiToEth(nd.BalanceRPL) + rethBalance := math.WeiToEth(nd.BalanceRETH) eligibleBorrowedEth := state.GetMinipoolEligibleBorrowedEth(nd) var activeMinipoolCount float64 rplPriceRaw := state.NetworkDetails.RplPrice - rplPrice := eth.WeiToEth(rplPriceRaw) + rplPrice := math.WeiToEth(rplPriceRaw) var beaconHead beacon.BeaconHead unclaimedEthRewards := float64(0) unclaimedRplRewards := float64(0) lowETHBalanceThreshold := collector.cfg.Alertmanager.LowETHBalanceThreshold.Value.(float64) - megapoolEthBalance := eth.WeiToEth(megapoolDetails.EthBalance) - nodeDebt := eth.WeiToEth(megapoolDetails.NodeDebt) + megapoolEthBalance := math.WeiToEth(megapoolDetails.EthBalance) + nodeDebt := math.WeiToEth(megapoolDetails.NodeDebt) megapoolValidatorCount := float64(megapoolDetails.ValidatorCount) megapoolActiveValidatorCount := float64(megapoolDetails.ActiveValidatorCount) megapoolLockedValidatorCount := float64(megapoolDetails.LockedValidatorCount) megapoolNodeExpressTicketCount := float64(megapoolDetails.NodeExpressTicketCount) - megapoolRefundValue := eth.WeiToEth(megapoolDetails.RefundValue) - megapoolNodeBond := eth.WeiToEth(megapoolDetails.NodeBond) - megapoolUserCapital := eth.WeiToEth(megapoolDetails.UserCapital) - megapoolAssignedValue := eth.WeiToEth(megapoolDetails.AssignedValue) + megapoolRefundValue := math.WeiToEth(megapoolDetails.RefundValue) + megapoolNodeBond := math.WeiToEth(megapoolDetails.NodeBond) + megapoolUserCapital := math.WeiToEth(megapoolDetails.UserCapital) + megapoolAssignedValue := math.WeiToEth(megapoolDetails.AssignedValue) megapoolDelegateExpiry := float64(megapoolDetails.DelegateExpiry) megapoolPubkeys := state.MegapoolToPubkeysMap[megapoolAddress] megapoolBeaconBalanceTotal := big.NewInt(0) @@ -541,10 +540,10 @@ func (collector *NodeCollector) Collect(channel chan<- prometheus.Metric) { return fmt.Errorf("Error getting latest block header: %w", err) } - collector.cumulativeRewards += eth.WeiToEth(newRewards) - collector.cumulativeClaimedEthRewards += eth.WeiToEth(newClaimedEthRewards) - unclaimedRplRewards = eth.WeiToEth(unclaimedRplWei) - unclaimedEthRewards = eth.WeiToEth(unclaimedEthWei) + collector.cumulativeRewards += math.WeiToEth(newRewards) + collector.cumulativeClaimedEthRewards += math.WeiToEth(newClaimedEthRewards) + unclaimedRplRewards = math.WeiToEth(unclaimedRplWei) + unclaimedEthRewards = math.WeiToEth(unclaimedEthWei) collector.nextRewardsStartBlock = big.NewInt(0).Add(header.Number, big.NewInt(1)) return nil @@ -643,10 +642,10 @@ func (collector *NodeCollector) Collect(channel chan<- prometheus.Metric) { if err != nil { return fmt.Errorf("Error getting megapool pending rewards: %w", err) } - megapoolPendingRewardsNode = eth.WeiToEth(mpPendingRewards.NodeRewards) - megapoolPendingRewardsVoter = eth.WeiToEth(mpPendingRewards.VoterRewards) - megapoolPendingRewardsPDAO = eth.WeiToEth(mpPendingRewards.ProtocolDAORewards) - megapoolPendingRewardsReth = eth.WeiToEth(mpPendingRewards.RethRewards) + megapoolPendingRewardsNode = math.WeiToEth(mpPendingRewards.NodeRewards) + megapoolPendingRewardsVoter = math.WeiToEth(mpPendingRewards.VoterRewards) + megapoolPendingRewardsPDAO = math.WeiToEth(mpPendingRewards.ProtocolDAORewards) + megapoolPendingRewardsReth = math.WeiToEth(mpPendingRewards.RethRewards) currentEpoch := state.BeaconConfig.SlotToEpoch(state.BeaconSlotNumber) totalEffectiveBeaconBalance := big.NewInt(0) @@ -666,18 +665,18 @@ func (collector *NodeCollector) Collect(channel chan<- prometheus.Metric) { if currentEpoch <= validator.ActivationEpoch { continue } - megapoolBeaconBalanceTotal.Add(megapoolBeaconBalanceTotal, eth.GweiToWei(float64(validator.Balance))) - totalEffectiveBeaconBalance.Add(totalEffectiveBeaconBalance, eth.GweiToWei(float64(validator.EffectiveBalance))) + megapoolBeaconBalanceTotal.Add(megapoolBeaconBalanceTotal, math.GweiToWei(float64(validator.Balance))) + totalEffectiveBeaconBalance.Add(totalEffectiveBeaconBalance, math.GweiToWei(float64(validator.EffectiveBalance))) } - megapoolBeaconBalance = eth.WeiToEth(megapoolBeaconBalanceTotal) + megapoolBeaconBalance = math.WeiToEth(megapoolBeaconBalanceTotal) if megapoolBeaconBalanceTotal.Cmp(totalEffectiveBeaconBalance) > 0 { toBeSkimmed := big.NewInt(0).Sub(megapoolBeaconBalanceTotal, totalEffectiveBeaconBalance) rewardsSplit, err := mp.CalculateRewards(toBeSkimmed, nil) if err != nil { return fmt.Errorf("Error calculating megapool rewards: %w", err) } - nodeShareofBeaconBalance = eth.WeiToEth(big.NewInt(0).Add(rewardsSplit.NodeRewards, megapoolDetails.NodeBond)) + nodeShareofBeaconBalance = math.WeiToEth(big.NewInt(0).Add(rewardsSplit.NodeRewards, megapoolDetails.NodeBond)) } return nil @@ -726,7 +725,7 @@ func (collector *NodeCollector) Collect(channel chan<- prometheus.Metric) { // Pending bond reducton bonded.Set(mpd.ReduceBondValue) } - borrowed := big.NewInt(0).Sub(eth.EthToWei(32), bonded) + borrowed := big.NewInt(0).Sub(math.EthToWei(32), bonded) pendingBorrowedEth.Add(pendingBorrowedEth, borrowed) pendingBondedEth.Add(pendingBondedEth, bonded) @@ -748,12 +747,12 @@ func (collector *NodeCollector) Collect(channel chan<- prometheus.Metric) { rewardableBondedEth.Add(rewardableBondedEth, bonded) } - rewardableStakeFloat := eth.WeiToEth(nd.LegacyStakedRPL) + rewardableStakeFloat := math.WeiToEth(nd.LegacyStakedRPL) // Calculate the estimated rewards rewardsIntervalDays := rewardsInterval.Seconds() / (60 * 60 * 24) - inflationPerDay := eth.WeiToEth(inflationInterval) - totalRplAtNextCheckpoint := (math.Pow(inflationPerDay, float64(rewardsIntervalDays)) - 1) * eth.WeiToEth(totalRplSupply) + inflationPerDay := math.WeiToEth(inflationInterval) + totalRplAtNextCheckpoint := (math.Pow(inflationPerDay, float64(rewardsIntervalDays)) - 1) * math.WeiToEth(totalRplSupply) if totalRplAtNextCheckpoint < 0 { totalRplAtNextCheckpoint = 0 } @@ -795,25 +794,25 @@ func (collector *NodeCollector) Collect(channel chan<- prometheus.Metric) { for _, minipool := range minipools { validator, exists := state.MinipoolValidatorDetails[minipool.Pubkey] if exists { - totalBeaconBalance += eth.GweiToEth(validator.Balance) + totalBeaconBalance += math.GweiToEth(validator.Balance) } - totalDepositBalance += eth.WeiToEth(minipool.NodeDepositBalance) - totalNodeShare += eth.WeiToEth(minipool.NodeShareOfBeaconBalance) + totalDepositBalance += math.WeiToEth(minipool.NodeDepositBalance) + totalNodeShare += math.WeiToEth(minipool.NodeShareOfBeaconBalance) } totalMinipoolBalance := float64(0) totalMinipoolShare := float64(0) totalRefundBalance := float64(0) for _, minipool := range minipools { - totalMinipoolBalance += eth.WeiToEth(minipool.DistributableBalance) - totalMinipoolShare += eth.WeiToEth(minipool.NodeShareOfBalance) - totalRefundBalance += eth.WeiToEth(minipool.NodeRefundBalance) + totalMinipoolBalance += math.WeiToEth(minipool.DistributableBalance) + totalMinipoolShare += math.WeiToEth(minipool.NodeShareOfBalance) + totalRefundBalance += math.WeiToEth(minipool.NodeRefundBalance) } // RPL collateral // Use the total staked RPL (legacy + megapool) totalStakedRpl := nodeLegacyStakedRpl + nodeMegapoolStakedRpl - totalBondedEthFloat := eth.WeiToEth(pendingBondedEth) + eth.WeiToEth(nd.MegapoolEthBonded) + totalBondedEthFloat := math.WeiToEth(pendingBondedEth) + math.WeiToEth(nd.MegapoolEthBonded) var bondedCollateralRatio float64 if totalBondedEthFloat == 0 { bondedCollateralRatio = 0 @@ -821,7 +820,7 @@ func (collector *NodeCollector) Collect(channel chan<- prometheus.Metric) { bondedCollateralRatio = rplPrice * totalStakedRpl / totalBondedEthFloat } - totalBorrowedEthFloat := eth.WeiToEth(pendingBorrowedEth) + eth.WeiToEth(nd.MegapoolETHBorrowed) + totalBorrowedEthFloat := math.WeiToEth(pendingBorrowedEth) + math.WeiToEth(nd.MegapoolETHBorrowed) var borrowedCollateralRatio float64 if totalBorrowedEthFloat == 0 { borrowedCollateralRatio = 0 diff --git a/rocketpool/node/collectors/performance-collector.go b/rocketpool/node/collectors/performance-collector.go index 9c38b0e26..19297f0f8 100644 --- a/rocketpool/node/collectors/performance-collector.go +++ b/rocketpool/node/collectors/performance-collector.go @@ -4,7 +4,7 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/rocket-pool/smartnode/bindings/rocketpool" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/shared/math" ) // Represents the collector for the Performance metrics @@ -90,11 +90,11 @@ func (collector *PerformanceCollector) Collect(channel chan<- prometheus.Metric) } ethUtilizationRate := state.NetworkDetails.ETHUtilizationRate - balanceFloat := eth.WeiToEth(state.NetworkDetails.StakingETHBalance) + balanceFloat := math.WeiToEth(state.NetworkDetails.StakingETHBalance) exchangeRate := state.NetworkDetails.RETHExchangeRate - tvlFloat := eth.WeiToEth(state.NetworkDetails.TotalETHBalance) - rETHBalance := eth.WeiToEth(state.NetworkDetails.RETHBalance) - rethFloat := eth.WeiToEth(state.NetworkDetails.TotalRETHSupply) + tvlFloat := math.WeiToEth(state.NetworkDetails.TotalETHBalance) + rETHBalance := math.WeiToEth(state.NetworkDetails.RETHBalance) + rethFloat := math.WeiToEth(state.NetworkDetails.TotalRETHSupply) channel <- prometheus.MustNewConstMetric( collector.ethUtilizationRate, prometheus.GaugeValue, ethUtilizationRate) diff --git a/rocketpool/node/collectors/rpl-collector.go b/rocketpool/node/collectors/rpl-collector.go index e19f792e4..37f78aceb 100644 --- a/rocketpool/node/collectors/rpl-collector.go +++ b/rocketpool/node/collectors/rpl-collector.go @@ -4,7 +4,7 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/rocket-pool/smartnode/bindings/rocketpool" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/config" ) @@ -95,10 +95,10 @@ func (collector *RplCollector) Collect(channel chan<- prometheus.Metric) { return } - rplPriceFloat := eth.WeiToEth(state.NetworkDetails.RplPrice) - totalValueStakedFloat := eth.WeiToEth(state.NetworkDetails.TotalRPLStake) - totalNetworkLegacyStakedRpl := eth.WeiToEth(state.NetworkDetails.TotalLegacyStakedRpl) - totalNetworkMegapoolStakedRpl := eth.WeiToEth(state.NetworkDetails.TotalNetworkMegapoolStakedRpl) + rplPriceFloat := math.WeiToEth(state.NetworkDetails.RplPrice) + totalValueStakedFloat := math.WeiToEth(state.NetworkDetails.TotalRPLStake) + totalNetworkLegacyStakedRpl := math.WeiToEth(state.NetworkDetails.TotalLegacyStakedRpl) + totalNetworkMegapoolStakedRpl := math.WeiToEth(state.NetworkDetails.TotalNetworkMegapoolStakedRpl) lastCheckpoint := state.NetworkDetails.IntervalStart rewardsInterval := state.NetworkDetails.IntervalDuration nextRewardsTime := float64(lastCheckpoint.Add(rewardsInterval).Unix()) * 1000 diff --git a/rocketpool/node/collectors/smoothing-pool-collector.go b/rocketpool/node/collectors/smoothing-pool-collector.go index 4a9c8cd5e..342597471 100644 --- a/rocketpool/node/collectors/smoothing-pool-collector.go +++ b/rocketpool/node/collectors/smoothing-pool-collector.go @@ -4,7 +4,7 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/rocket-pool/smartnode/bindings/rocketpool" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services" ) @@ -54,7 +54,7 @@ func (collector *SmoothingPoolCollector) Collect(channel chan<- prometheus.Metri return } - ethBalanceOnSmoothingPool := eth.WeiToEth(state.NetworkDetails.SmoothingPoolBalance) + ethBalanceOnSmoothingPool := math.WeiToEth(state.NetworkDetails.SmoothingPoolBalance) channel <- prometheus.MustNewConstMetric( collector.ethBalanceOnSmoothingPool, prometheus.GaugeValue, ethBalanceOnSmoothingPool) diff --git a/rocketpool/node/collectors/snapshot-collector.go b/rocketpool/node/collectors/snapshot-collector.go index cceccd728..ccec891b2 100644 --- a/rocketpool/node/collectors/snapshot-collector.go +++ b/rocketpool/node/collectors/snapshot-collector.go @@ -12,8 +12,8 @@ import ( "github.com/rocket-pool/smartnode/bindings/network" "github.com/rocket-pool/smartnode/bindings/rocketpool" - "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/rocketpool/api/pdao" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/config" "github.com/rocket-pool/smartnode/shared/services/contracts" @@ -280,7 +280,7 @@ func getVotingPower(propMgr *proposals.ProposalManager, blockNumber uint32, addr return 0, fmt.Errorf("error getting voting power: %w", err) } - return eth.WeiToEth(totalDelegatedVP), nil + return math.WeiToEth(totalDelegatedVP), nil } func (collector *SnapshotCollector) collectVotes(votedProposals *api.SnapshotVotedProposals) { diff --git a/rocketpool/node/collectors/trusted-node-collector.go b/rocketpool/node/collectors/trusted-node-collector.go index 9388d1c8b..0e0c75859 100644 --- a/rocketpool/node/collectors/trusted-node-collector.go +++ b/rocketpool/node/collectors/trusted-node-collector.go @@ -17,7 +17,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/tokens" "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/config" ) @@ -235,7 +235,7 @@ func (collector *TrustedNodeCollector) Collect(channel chan<- prometheus.Metric) return fmt.Errorf("Error getting node balances: %w", err) } lock.Lock() - ethBalances[id] = eth.WeiToEth(balances.ETH) + ethBalances[id] = math.WeiToEth(balances.ETH) lock.Unlock() return nil } diff --git a/rocketpool/node/defend-challenge-exit.go b/rocketpool/node/defend-challenge-exit.go index a79179378..10be87187 100644 --- a/rocketpool/node/defend-challenge-exit.go +++ b/rocketpool/node/defend-challenge-exit.go @@ -13,9 +13,9 @@ import ( "github.com/rocket-pool/smartnode/bindings/transactions" "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" log "github.com/rocket-pool/smartnode/shared/logger" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/config" @@ -72,7 +72,7 @@ func newDefendChallengeExit(c *cli.Command, logger log.ColorLogger) (*defendChal if maxFeeGwei == 0 { maxFee = nil } else { - maxFee = eth.GweiToWei(maxFeeGwei) + maxFee = math.GweiToWei(maxFeeGwei) } // Get the user-requested max fee @@ -80,9 +80,9 @@ func newDefendChallengeExit(c *cli.Command, logger log.ColorLogger) (*defendChal var priorityFee *big.Int if priorityFeeGwei == 0 { logger.Printlnf("WARNING: priority fee was missing or 0, setting a default of %.2f.", rpgas.DefaultPriorityFeeGwei) - priorityFee = eth.GweiToWei(rpgas.DefaultPriorityFeeGwei) + priorityFee = math.GweiToWei(rpgas.DefaultPriorityFeeGwei) } else { - priorityFee = eth.GweiToWei(priorityFeeGwei) + priorityFee = math.GweiToWei(priorityFeeGwei) } // Return task diff --git a/rocketpool/node/defend-pdao-props.go b/rocketpool/node/defend-pdao-props.go index 1db5278de..6fe99331c 100644 --- a/rocketpool/node/defend-pdao-props.go +++ b/rocketpool/node/defend-pdao-props.go @@ -13,8 +13,8 @@ import ( "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/transactions" "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" log "github.com/rocket-pool/smartnode/shared/logger" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/config" @@ -75,7 +75,7 @@ func newDefendPdaoProps(c *cli.Command, logger log.ColorLogger) (*defendPdaoProp if maxFeeGwei == 0 { maxFee = nil } else { - maxFee = eth.GweiToWei(maxFeeGwei) + maxFee = math.GweiToWei(maxFeeGwei) } // Get the user-requested priority fee @@ -83,9 +83,9 @@ func newDefendPdaoProps(c *cli.Command, logger log.ColorLogger) (*defendPdaoProp var priorityFee *big.Int if priorityFeeGwei == 0 { logger.Printlnf("WARNING: priority fee was missing or 0, setting a default of %.2f.", rpgas.DefaultPriorityFeeGwei) - priorityFee = eth.GweiToWei(rpgas.DefaultPriorityFeeGwei) + priorityFee = math.GweiToWei(rpgas.DefaultPriorityFeeGwei) } else { - priorityFee = eth.GweiToWei(priorityFeeGwei) + priorityFee = math.GweiToWei(priorityFeeGwei) } // Get the event interval size diff --git a/rocketpool/node/distribute-minipools.go b/rocketpool/node/distribute-minipools.go index 79b1cc22d..2f16467ed 100644 --- a/rocketpool/node/distribute-minipools.go +++ b/rocketpool/node/distribute-minipools.go @@ -13,8 +13,8 @@ import ( "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/transactions" rptypes "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" rpstate "github.com/rocket-pool/smartnode/bindings/utils/state" + "github.com/rocket-pool/smartnode/shared/math" log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services" @@ -93,7 +93,7 @@ func newDistributeMinipools(c *cli.Command, logger log.ColorLogger) (*distribute if maxFeeGwei == 0 { maxFee = nil } else { - maxFee = eth.GweiToWei(maxFeeGwei) + maxFee = math.GweiToWei(maxFeeGwei) } // Get the user-requested max fee @@ -101,9 +101,9 @@ func newDistributeMinipools(c *cli.Command, logger log.ColorLogger) (*distribute var priorityFee *big.Int if priorityFeeGwei == 0 { logger.Printlnf("WARNING: priority fee was missing or 0, setting a default of %.2f.", rpgas.DefaultPriorityFeeGwei) - priorityFee = eth.GweiToWei(rpgas.DefaultPriorityFeeGwei) + priorityFee = math.GweiToWei(rpgas.DefaultPriorityFeeGwei) } else { - priorityFee = eth.GweiToWei(priorityFeeGwei) + priorityFee = math.GweiToWei(priorityFeeGwei) } // Return task @@ -116,9 +116,9 @@ func newDistributeMinipools(c *cli.Command, logger log.ColorLogger) (*distribute bc: bc, d: d, gasThreshold: gasThreshold, - distributeThreshold: eth.EthToWei(distributeThreshold), + distributeThreshold: math.EthToWei(distributeThreshold), disabled: disabled, - eight: eth.EthToWei(8), + eight: math.EthToWei(8), maxFee: maxFee, maxPriorityFee: priorityFee, gasLimit: 0, @@ -214,7 +214,7 @@ func (t *distributeMinipools) getDistributableMinipools(nodeAddress common.Addre func (t *distributeMinipools) distributeMinipool(mpd *rpstate.NativeMinipoolDetails, callOpts *bind.CallOpts) (bool, error) { // Log - t.log.Printlnf("Distributing minipool %s (total balance of %.6f ETH)...", mpd.MinipoolAddress.Hex(), eth.WeiToEth(mpd.Balance)) + t.log.Printlnf("Distributing minipool %s (total balance of %.6f ETH)...", mpd.MinipoolAddress.Hex(), math.WeiToEth(mpd.Balance)) mp, err := minipool.NewMinipoolFromVersion(t.rp, mpd.MinipoolAddress, mpd.Version, callOpts) if err != nil { diff --git a/rocketpool/node/notify-final-balance.go b/rocketpool/node/notify-final-balance.go index 47c933388..6a517d3a2 100644 --- a/rocketpool/node/notify-final-balance.go +++ b/rocketpool/node/notify-final-balance.go @@ -12,9 +12,9 @@ import ( "github.com/rocket-pool/smartnode/bindings/megapool" "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/transactions" - "github.com/rocket-pool/smartnode/bindings/utils/eth" log "github.com/rocket-pool/smartnode/shared/logger" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/config" @@ -71,7 +71,7 @@ func newNotifyFinalBalance(c *cli.Command, logger log.ColorLogger) (*notifyFinal if maxFeeGwei == 0 { maxFee = nil } else { - maxFee = eth.GweiToWei(maxFeeGwei) + maxFee = math.GweiToWei(maxFeeGwei) } // Get the user-requested max fee @@ -79,9 +79,9 @@ func newNotifyFinalBalance(c *cli.Command, logger log.ColorLogger) (*notifyFinal var priorityFee *big.Int if priorityFeeGwei == 0 { logger.Printlnf("WARNING: priority fee was missing or 0, setting a default of %.2f.", rpgas.DefaultPriorityFeeGwei) - priorityFee = eth.GweiToWei(rpgas.DefaultPriorityFeeGwei) + priorityFee = math.GweiToWei(rpgas.DefaultPriorityFeeGwei) } else { - priorityFee = eth.GweiToWei(priorityFeeGwei) + priorityFee = math.GweiToWei(priorityFeeGwei) } // Return task diff --git a/rocketpool/node/notify-validator-exit.go b/rocketpool/node/notify-validator-exit.go index b7ed0bc33..5976d77f4 100644 --- a/rocketpool/node/notify-validator-exit.go +++ b/rocketpool/node/notify-validator-exit.go @@ -12,9 +12,9 @@ import ( "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/transactions" "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" log "github.com/rocket-pool/smartnode/shared/logger" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/config" @@ -74,7 +74,7 @@ func newNotifyValidatorExit(c *cli.Command, logger log.ColorLogger) (*notifyVali if maxFeeGwei == 0 { maxFee = nil } else { - maxFee = eth.GweiToWei(maxFeeGwei) + maxFee = math.GweiToWei(maxFeeGwei) } // Get the user-requested max fee @@ -82,9 +82,9 @@ func newNotifyValidatorExit(c *cli.Command, logger log.ColorLogger) (*notifyVali var priorityFee *big.Int if priorityFeeGwei == 0 { logger.Printlnf("WARNING: priority fee was missing or 0, setting a default of %.2f.", rpgas.DefaultPriorityFeeGwei) - priorityFee = eth.GweiToWei(rpgas.DefaultPriorityFeeGwei) + priorityFee = math.GweiToWei(rpgas.DefaultPriorityFeeGwei) } else { - priorityFee = eth.GweiToWei(priorityFeeGwei) + priorityFee = math.GweiToWei(priorityFeeGwei) } // Return task diff --git a/rocketpool/node/prestake-megapool-validator.go b/rocketpool/node/prestake-megapool-validator.go index 24b27a796..952640139 100644 --- a/rocketpool/node/prestake-megapool-validator.go +++ b/rocketpool/node/prestake-megapool-validator.go @@ -14,9 +14,9 @@ import ( "github.com/rocket-pool/smartnode/bindings/megapool" "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/transactions" - "github.com/rocket-pool/smartnode/bindings/utils/eth" log "github.com/rocket-pool/smartnode/shared/logger" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/config" rpgas "github.com/rocket-pool/smartnode/shared/services/gas" @@ -68,7 +68,7 @@ func newPrestakeMegapoolValidator(c *cli.Command, logger log.ColorLogger) (*pres if maxFeeGwei == 0 { maxFee = nil } else { - maxFee = eth.GweiToWei(maxFeeGwei) + maxFee = math.GweiToWei(maxFeeGwei) } // Get the user-requested max fee @@ -76,9 +76,9 @@ func newPrestakeMegapoolValidator(c *cli.Command, logger log.ColorLogger) (*pres var priorityFee *big.Int if priorityFeeGwei == 0 { logger.Printlnf("WARNING: priority fee was missing or 0, setting a default of %.2f.", rpgas.DefaultPriorityFeeGwei) - priorityFee = eth.GweiToWei(rpgas.DefaultPriorityFeeGwei) + priorityFee = math.GweiToWei(rpgas.DefaultPriorityFeeGwei) } else { - priorityFee = eth.GweiToWei(priorityFeeGwei) + priorityFee = math.GweiToWei(priorityFeeGwei) } autoAssignmentDelay := cfg.Smartnode.AutoAssignmentDelay.Value.(uint16) diff --git a/rocketpool/node/provision-express-tickets.go b/rocketpool/node/provision-express-tickets.go index 3f4dd8721..d14975b24 100644 --- a/rocketpool/node/provision-express-tickets.go +++ b/rocketpool/node/provision-express-tickets.go @@ -10,9 +10,9 @@ import ( "github.com/rocket-pool/smartnode/bindings/node" "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/transactions" - "github.com/rocket-pool/smartnode/bindings/utils/eth" log "github.com/rocket-pool/smartnode/shared/logger" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/config" rpgas "github.com/rocket-pool/smartnode/shared/services/gas" @@ -70,7 +70,7 @@ func newProvisionExpressTickets(c *cli.Command, logger log.ColorLogger) (*provis if maxFeeGwei == 0 { maxFee = nil } else { - maxFee = eth.GweiToWei(maxFeeGwei) + maxFee = math.GweiToWei(maxFeeGwei) } // Get the user-requested priority fee @@ -78,9 +78,9 @@ func newProvisionExpressTickets(c *cli.Command, logger log.ColorLogger) (*provis var priorityFee *big.Int if priorityFeeGwei == 0 { logger.Printlnf("WARNING: priority fee was missing or 0, setting a default of %.2f.", rpgas.DefaultPriorityFeeGwei) - priorityFee = eth.GweiToWei(rpgas.DefaultPriorityFeeGwei) + priorityFee = math.GweiToWei(rpgas.DefaultPriorityFeeGwei) } else { - priorityFee = eth.GweiToWei(priorityFeeGwei) + priorityFee = math.GweiToWei(priorityFeeGwei) } // Return task diff --git a/rocketpool/node/set-latest-delegate.go b/rocketpool/node/set-latest-delegate.go index 706675431..d02abc5b4 100644 --- a/rocketpool/node/set-latest-delegate.go +++ b/rocketpool/node/set-latest-delegate.go @@ -13,8 +13,8 @@ import ( "github.com/rocket-pool/smartnode/bindings/minipool" "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/transactions" - "github.com/rocket-pool/smartnode/bindings/utils/eth" rpstate "github.com/rocket-pool/smartnode/bindings/utils/state" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/alerting" log "github.com/rocket-pool/smartnode/shared/logger" @@ -73,7 +73,7 @@ func newSetUseLatestDelegate(c *cli.Command, logger log.ColorLogger) (*setUseLat if maxFeeGwei == 0 { maxFee = nil } else { - maxFee = eth.GweiToWei(maxFeeGwei) + maxFee = math.GweiToWei(maxFeeGwei) } // Get the user-requested max fee @@ -81,9 +81,9 @@ func newSetUseLatestDelegate(c *cli.Command, logger log.ColorLogger) (*setUseLat var priorityFee *big.Int if priorityFeeGwei == 0 { logger.Printlnf("WARNING: priority fee was missing or 0, setting a default of %.2f.", rpgas.DefaultPriorityFeeGwei) - priorityFee = eth.GweiToWei(rpgas.DefaultPriorityFeeGwei) + priorityFee = math.GweiToWei(rpgas.DefaultPriorityFeeGwei) } else { - priorityFee = eth.GweiToWei(priorityFeeGwei) + priorityFee = math.GweiToWei(priorityFeeGwei) } gasThreshold := cfg.Smartnode.AutoTxGasThreshold.Value.(float64) diff --git a/rocketpool/node/stake-megapool-validator.go b/rocketpool/node/stake-megapool-validator.go index ae8af4a68..49c0b732c 100644 --- a/rocketpool/node/stake-megapool-validator.go +++ b/rocketpool/node/stake-megapool-validator.go @@ -12,9 +12,9 @@ import ( "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/transactions" "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" log "github.com/rocket-pool/smartnode/shared/logger" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/config" @@ -73,7 +73,7 @@ func newStakeMegapoolValidator(c *cli.Command, logger log.ColorLogger) (*stakeMe if maxFeeGwei == 0 { maxFee = nil } else { - maxFee = eth.GweiToWei(maxFeeGwei) + maxFee = math.GweiToWei(maxFeeGwei) } // Get the user-requested max fee @@ -81,9 +81,9 @@ func newStakeMegapoolValidator(c *cli.Command, logger log.ColorLogger) (*stakeMe var priorityFee *big.Int if priorityFeeGwei == 0 { logger.Printlnf("WARNING: priority fee was missing or 0, setting a default of %.2f.", rpgas.DefaultPriorityFeeGwei) - priorityFee = eth.GweiToWei(rpgas.DefaultPriorityFeeGwei) + priorityFee = math.GweiToWei(rpgas.DefaultPriorityFeeGwei) } else { - priorityFee = eth.GweiToWei(priorityFeeGwei) + priorityFee = math.GweiToWei(priorityFeeGwei) } // Return task diff --git a/rocketpool/node/verify-pdao-props.go b/rocketpool/node/verify-pdao-props.go index c25a18ca4..fedb7546c 100644 --- a/rocketpool/node/verify-pdao-props.go +++ b/rocketpool/node/verify-pdao-props.go @@ -13,8 +13,8 @@ import ( "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/transactions" "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" log "github.com/rocket-pool/smartnode/shared/logger" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/config" @@ -109,7 +109,7 @@ func newVerifyPdaoProps(c *cli.Command, logger log.ColorLogger) (*verifyPdaoProp if maxFeeGwei == 0 { maxFee = nil } else { - maxFee = eth.GweiToWei(maxFeeGwei) + maxFee = math.GweiToWei(maxFeeGwei) } // Get the user-requested priority fee @@ -117,9 +117,9 @@ func newVerifyPdaoProps(c *cli.Command, logger log.ColorLogger) (*verifyPdaoProp var priorityFee *big.Int if priorityFeeGwei == 0 { logger.Printlnf("WARNING: priority fee was missing or 0, setting a default of %.2f.", rpgas.DefaultPriorityFeeGwei) - priorityFee = eth.GweiToWei(rpgas.DefaultPriorityFeeGwei) + priorityFee = math.GweiToWei(rpgas.DefaultPriorityFeeGwei) } else { - priorityFee = eth.GweiToWei(priorityFeeGwei) + priorityFee = math.GweiToWei(priorityFeeGwei) } // Get the event interval size diff --git a/rocketpool/watchtower/challenge-exit.go b/rocketpool/watchtower/challenge-exit.go index 261785d48..a01ffeef0 100644 --- a/rocketpool/watchtower/challenge-exit.go +++ b/rocketpool/watchtower/challenge-exit.go @@ -11,9 +11,9 @@ import ( "github.com/rocket-pool/smartnode/bindings/settings/protocol" "github.com/rocket-pool/smartnode/bindings/transactions" "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/rocketpool/watchtower/utils" log "github.com/rocket-pool/smartnode/shared/logger" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/config" "github.com/rocket-pool/smartnode/shared/services/state" @@ -145,14 +145,14 @@ func (t *challengeValidatorsExiting) challengeValidatorsExiting(state *state.Net } // Print the gas info - maxFee := eth.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) + maxFee := math.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) if !gasLimits.PrintAndCheck(false, 0, &t.log, maxFee, 0) { return nil } // Set the gas settings opts.GasFeeCap = maxFee - opts.GasTipCap = eth.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) + opts.GasTipCap = math.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) opts.GasLimit = gasLimits.Safe // Challenge diff --git a/rocketpool/watchtower/check-solo-migrations.go b/rocketpool/watchtower/check-solo-migrations.go index 61ecbc963..3ab814d87 100644 --- a/rocketpool/watchtower/check-solo-migrations.go +++ b/rocketpool/watchtower/check-solo-migrations.go @@ -15,9 +15,9 @@ import ( "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/transactions" "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/rocketpool/watchtower/utils" log "github.com/rocket-pool/smartnode/shared/logger" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/config" @@ -141,7 +141,7 @@ func (t *checkSoloMigrations) run(state *state.NetworkState) error { func (t *checkSoloMigrations) checkSoloMigrations(state *state.NetworkState) error { t.printMessage(fmt.Sprintf("Checking for Beacon slot %d (EL block %d)", state.BeaconSlotNumber, state.ElBlockNumber)) - oneGwei := eth.GweiToWei(1) + oneGwei := math.GweiToWei(1) scrubThreshold := time.Duration(state.NetworkDetails.PromotionScrubPeriod.Seconds()*soloMigrationCheckThreshold) * time.Second genesisTime := time.Unix(int64(state.BeaconConfig.GenesisTime), 0) @@ -158,7 +158,7 @@ func (t *checkSoloMigrations) checkSoloMigrations(state *state.NetworkState) err // Go through each minipool threshold := uint64(32000000000) - buffer := uint64(migrationBalanceBuffer * eth.WeiPerGwei) + buffer := uint64(migrationBalanceBuffer * math.WeiPerGwei) for _, mpd := range state.MinipoolDetails { if mpd.Status == types.Dissolved { // Ignore minipools that are already dissolved @@ -287,14 +287,14 @@ func (t *checkSoloMigrations) scrubVacantMinipool(address common.Address, reason } // Print the gas info - maxFee := eth.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) + maxFee := math.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) if !gasLimits.PrintAndCheck(false, 0, &t.log, maxFee, 0) { return } // Set the gas settings opts.GasFeeCap = maxFee - opts.GasTipCap = eth.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) + opts.GasTipCap = math.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) opts.GasLimit = gasLimits.Safe // Cancel the reduction diff --git a/rocketpool/watchtower/dissolve-invalid-credentials.go b/rocketpool/watchtower/dissolve-invalid-credentials.go index 15187d523..12e801892 100644 --- a/rocketpool/watchtower/dissolve-invalid-credentials.go +++ b/rocketpool/watchtower/dissolve-invalid-credentials.go @@ -9,9 +9,9 @@ import ( "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/transactions" "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/rocketpool/watchtower/utils" log "github.com/rocket-pool/smartnode/shared/logger" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/config" "github.com/rocket-pool/smartnode/shared/services/state" @@ -175,14 +175,14 @@ func (t *dissolveInvalidCredentials) dissolveMegapoolValidator(validator megapoo } // Print the gas info - maxFee := eth.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) + maxFee := math.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) if !gasLimits.PrintAndCheck(false, 0, &t.log, maxFee, 0) { return } // Set the gas settings opts.GasFeeCap = maxFee - opts.GasTipCap = eth.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) + opts.GasTipCap = math.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) opts.GasLimit = gasLimits.Safe // Dissolve diff --git a/rocketpool/watchtower/dissolve-timed-out-megapool-validators.go b/rocketpool/watchtower/dissolve-timed-out-megapool-validators.go index cab1c78c7..50cc30e48 100644 --- a/rocketpool/watchtower/dissolve-timed-out-megapool-validators.go +++ b/rocketpool/watchtower/dissolve-timed-out-megapool-validators.go @@ -10,9 +10,9 @@ import ( "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/settings/protocol" "github.com/rocket-pool/smartnode/bindings/transactions" - "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/rocketpool/watchtower/utils" log "github.com/rocket-pool/smartnode/shared/logger" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/config" "github.com/rocket-pool/smartnode/shared/services/state" @@ -127,14 +127,14 @@ func (t *dissolveTimedOutMegapoolValidators) dissolveMegapoolValidator(validator } // Print the gas info - maxFee := eth.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) + maxFee := math.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) if !gasLimits.PrintAndCheck(false, 0, &t.log, maxFee, 0) { return nil } // Set the gas settings opts.GasFeeCap = maxFee - opts.GasTipCap = eth.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) + opts.GasTipCap = math.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) opts.GasLimit = gasLimits.Safe // Dissolve diff --git a/rocketpool/watchtower/dissolve-timed-out-minipools.go b/rocketpool/watchtower/dissolve-timed-out-minipools.go index 6b4f91649..130ad3e07 100644 --- a/rocketpool/watchtower/dissolve-timed-out-minipools.go +++ b/rocketpool/watchtower/dissolve-timed-out-minipools.go @@ -12,10 +12,10 @@ import ( "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/transactions" rptypes "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/rocketpool/watchtower/utils" log "github.com/rocket-pool/smartnode/shared/logger" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/config" "github.com/rocket-pool/smartnode/shared/services/state" @@ -152,14 +152,14 @@ func (t *dissolveTimedOutMinipools) dissolveMinipool(mp minipool.Minipool) error } // Print the gas info - maxFee := eth.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) + maxFee := math.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) if !gasLimits.PrintAndCheck(false, 0, &t.log, maxFee, 0) { return nil } // Set the gas settings opts.GasFeeCap = maxFee - opts.GasTipCap = eth.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) + opts.GasTipCap = math.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) opts.GasLimit = gasLimits.Safe // Dissolve diff --git a/rocketpool/watchtower/finalize-pdao-proposals.go b/rocketpool/watchtower/finalize-pdao-proposals.go index f30f1143d..e3012ba0e 100644 --- a/rocketpool/watchtower/finalize-pdao-proposals.go +++ b/rocketpool/watchtower/finalize-pdao-proposals.go @@ -9,10 +9,10 @@ import ( "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/transactions" "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/rocketpool/watchtower/utils" log "github.com/rocket-pool/smartnode/shared/logger" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/config" "github.com/rocket-pool/smartnode/shared/services/state" @@ -122,14 +122,14 @@ func (t *finalizePdaoProposals) finalizeProposal(propID uint64) error { } // Print the gas info - maxFee := eth.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) + maxFee := math.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) if !gasLimits.PrintAndCheck(false, 0, &t.log, maxFee, 0) { return nil } // Set the gas settings opts.GasFeeCap = maxFee - opts.GasTipCap = eth.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) + opts.GasTipCap = math.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) opts.GasLimit = gasLimits.Safe // Dissolve diff --git a/rocketpool/watchtower/respond-challenges.go b/rocketpool/watchtower/respond-challenges.go index a74a0e43c..d5521285e 100644 --- a/rocketpool/watchtower/respond-challenges.go +++ b/rocketpool/watchtower/respond-challenges.go @@ -8,10 +8,10 @@ import ( "github.com/rocket-pool/smartnode/bindings/dao/trustednode" "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/transactions" - "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/rocketpool/watchtower/utils" log "github.com/rocket-pool/smartnode/shared/logger" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/config" "github.com/rocket-pool/smartnode/shared/services/state" @@ -99,14 +99,14 @@ func (t *respondChallenges) run() error { } // Print the gas info - maxFee := eth.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) + maxFee := math.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) if !gasLimits.PrintAndCheck(false, 0, &t.log, maxFee, 0) { return nil } // Set the gas settings opts.GasFeeCap = maxFee - opts.GasTipCap = eth.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) + opts.GasTipCap = math.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) opts.GasLimit = gasLimits.Safe // Respond to challenge diff --git a/rocketpool/watchtower/submit-network-balances.go b/rocketpool/watchtower/submit-network-balances.go index d3a7951b7..a778b305e 100644 --- a/rocketpool/watchtower/submit-network-balances.go +++ b/rocketpool/watchtower/submit-network-balances.go @@ -21,8 +21,8 @@ import ( "github.com/rocket-pool/smartnode/bindings/transactions" "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" rptypes "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" rpstate "github.com/rocket-pool/smartnode/bindings/utils/state" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/bindings/settings/protocol" "github.com/rocket-pool/smartnode/rocketpool/watchtower/utils" @@ -275,16 +275,16 @@ func (t *submitNetworkBalances) run(state *state.NetworkState) error { } // Log - t.log.Printlnf("Deposit pool balance: %.12f", eth.WeiToEth(balances.DepositPool)) - t.log.Printlnf("Node credit balance: %.12f", eth.WeiToEth(balances.NodeCreditBalance)) - t.log.Printlnf("Total minipool user balance: %.12f", eth.WeiToEth(balances.MinipoolsTotal)) - t.log.Printlnf("Staking minipool user balance: %.12f", eth.WeiToEth(balances.MinipoolsStaking)) - t.log.Printlnf("Fee distributor user balance: %.12f", eth.WeiToEth(balances.DistributorShareTotal)) - t.log.Printlnf("Total megapool user balance: %.12f", eth.WeiToEth(balances.MegapoolsUserShareTotal)) - t.log.Printlnf("Staking megapool user balance: %.12f", eth.WeiToEth(balances.MegapoolStaking)) - t.log.Printlnf("Smoothing pool user balance: %.12f", eth.WeiToEth(balances.SmoothingPoolShare)) - t.log.Printlnf("rETH contract balance: %.12f", eth.WeiToEth(balances.RETHContract)) - t.log.Printlnf("rETH token supply: %.12f", eth.WeiToEth(balances.RETHSupply)) + t.log.Printlnf("Deposit pool balance: %.12f", math.WeiToEth(balances.DepositPool)) + t.log.Printlnf("Node credit balance: %.12f", math.WeiToEth(balances.NodeCreditBalance)) + t.log.Printlnf("Total minipool user balance: %.12f", math.WeiToEth(balances.MinipoolsTotal)) + t.log.Printlnf("Staking minipool user balance: %.12f", math.WeiToEth(balances.MinipoolsStaking)) + t.log.Printlnf("Fee distributor user balance: %.12f", math.WeiToEth(balances.DistributorShareTotal)) + t.log.Printlnf("Total megapool user balance: %.12f", math.WeiToEth(balances.MegapoolsUserShareTotal)) + t.log.Printlnf("Staking megapool user balance: %.12f", math.WeiToEth(balances.MegapoolStaking)) + t.log.Printlnf("Smoothing pool user balance: %.12f", math.WeiToEth(balances.SmoothingPoolShare)) + t.log.Printlnf("rETH contract balance: %.12f", math.WeiToEth(balances.RETHContract)) + t.log.Printlnf("rETH token supply: %.12f", math.WeiToEth(balances.RETHSupply)) var maxRethDelta *big.Int t.log.Printlnf("Checking if total ETH needs to be limited due to max Reth ratio delta...") @@ -297,7 +297,7 @@ func (t *submitNetworkBalances) run(state *state.NetworkState) error { balances.calculateTotalEthAndRethRate(maxRethDelta, lastSubmissionRate) if balances.OriginalTotalBalanceWei.Cmp(balances.ClampedTotalBalanceWei) != 0 { - t.log.Printlnf("Total ETH submission needs to be limited due to max Reth ratio delta: %.6f -> %.6f", eth.WeiToEth(balances.OriginalTotalBalanceWei), eth.WeiToEth(balances.ClampedTotalBalanceWei)) + t.log.Printlnf("Total ETH submission needs to be limited due to max Reth ratio delta: %.6f -> %.6f", math.WeiToEth(balances.OriginalTotalBalanceWei), math.WeiToEth(balances.ClampedTotalBalanceWei)) } // The staked balance cannot be greater than the total ETH balance if balances.ClampedTotalBalanceWei.Cmp(balances.TotalStaking) < 0 { @@ -347,7 +347,7 @@ func (t *submitNetworkBalances) run(state *state.NetworkState) error { func (b *networkBalances) applyMaxRethDelta(maxRethDelta *big.Int, lastSubmissionRate float64) { - lastSubmissionRateWei := eth.EthToWei(lastSubmissionRate) + lastSubmissionRateWei := math.EthToWei(lastSubmissionRate) actualRatioChangeWei := new(big.Int).Sub(b.OriginalRatioWei, lastSubmissionRateWei) @@ -585,7 +585,7 @@ func (t *submitNetworkBalances) getMegapoolBalanceDetails(megapoolAddress common // Pre-stake if megapoolValidatorInfo.ValidatorInfo.InPrestake { - megapoolBeaconBalanceTotal.Add(megapoolBeaconBalanceTotal, eth.MilliEthToWei(float64(megapoolValidatorInfo.ValidatorInfo.LastRequestedValue))) + megapoolBeaconBalanceTotal.Add(megapoolBeaconBalanceTotal, math.MilliEthToWei(float64(megapoolValidatorInfo.ValidatorInfo.LastRequestedValue))) continue } @@ -605,13 +605,13 @@ func (t *submitNetworkBalances) getMegapoolBalanceDetails(megapoolAddress common return megapoolBalanceDetails, fmt.Errorf("error finding withdrawal for validator %d: %w", validatorIndex, err) } // Track the withdrawn balance so we can discount it from the pending rewards on the contract - totalWithdrawnBalance.Add(totalWithdrawnBalance, eth.GweiToWei(float64(withdrawal.Amount))) + totalWithdrawnBalance.Add(totalWithdrawnBalance, math.GweiToWei(float64(withdrawal.Amount))) // Add the withdrawn balance to the beacon balance so its user share is not ignored - megapoolBeaconBalanceTotal.Add(megapoolBeaconBalanceTotal, eth.GweiToWei(float64(withdrawal.Amount))) + megapoolBeaconBalanceTotal.Add(megapoolBeaconBalanceTotal, math.GweiToWei(float64(withdrawal.Amount))) } else { // Not withdrawn yet, treat it as a staking validator - megapoolBeaconBalanceTotal.Add(megapoolBeaconBalanceTotal, eth.GweiToWei(float64(megapoolValidatorDetails.Balance))) - megapoolStakingBalance.Add(megapoolStakingBalance, eth.GweiToWei(float64(megapoolValidatorDetails.Balance))) + megapoolBeaconBalanceTotal.Add(megapoolBeaconBalanceTotal, math.GweiToWei(float64(megapoolValidatorDetails.Balance))) + megapoolStakingBalance.Add(megapoolStakingBalance, math.GweiToWei(float64(megapoolValidatorDetails.Balance))) megapoolStakingBalance.Sub(megapoolStakingBalance, state.NetworkDetails.ReducedBond) } continue @@ -620,11 +620,11 @@ func (t *submitNetworkBalances) getMegapoolBalanceDetails(megapoolAddress common // Staked if megapoolValidatorInfo.ValidatorInfo.Staked { if megapoolValidatorDetails.ActivationEpoch == FarFutureEpoch || megapoolValidatorDetails.ActivationEpoch > blockEpoch { - megapoolBeaconBalanceTotal.Add(megapoolBeaconBalanceTotal, eth.MilliEthToWei(float64(megapoolValidatorInfo.ValidatorInfo.DepositValue))) + megapoolBeaconBalanceTotal.Add(megapoolBeaconBalanceTotal, math.MilliEthToWei(float64(megapoolValidatorInfo.ValidatorInfo.DepositValue))) } else { - megapoolBeaconBalanceTotal.Add(megapoolBeaconBalanceTotal, eth.GweiToWei(float64(megapoolValidatorDetails.Balance))) + megapoolBeaconBalanceTotal.Add(megapoolBeaconBalanceTotal, math.GweiToWei(float64(megapoolValidatorDetails.Balance))) if megapoolValidatorDetails.ActivationEpoch < blockEpoch && megapoolValidatorDetails.ExitEpoch > blockEpoch { - megapoolStakingBalance.Add(megapoolStakingBalance, eth.GweiToWei(float64(megapoolValidatorDetails.Balance))) + megapoolStakingBalance.Add(megapoolStakingBalance, math.GweiToWei(float64(megapoolValidatorDetails.Balance))) megapoolStakingBalance.Sub(megapoolStakingBalance, state.NetworkDetails.ReducedBond) } } @@ -694,7 +694,7 @@ func (t *submitNetworkBalances) getMinipoolBalanceDetails(mpd *rpstate.NativeMin // "Broken" LEBs with the Redstone delegates report their total balance minus their node deposit balance if mpd.DepositType == rptypes.Variable && mpd.Version == 2 { brokenBalance := big.NewInt(0).Set(mpd.Balance) - brokenBalance.Add(brokenBalance, eth.GweiToWei(float64(validator.Balance))) + brokenBalance.Add(brokenBalance, math.GweiToWei(float64(validator.Balance))) brokenBalance.Sub(brokenBalance, mpd.NodeRefundBalance) brokenBalance.Sub(brokenBalance, mpd.NodeDepositBalance) return validatorBalanceDetails{ @@ -715,7 +715,7 @@ func (t *submitNetworkBalances) getMinipoolBalanceDetails(mpd *rpstate.NativeMin if userDepositBalance.Cmp(big.NewInt(0)) == 0 && mpType == rptypes.Full { return validatorBalanceDetails{ IsStaking: (validator.ExitEpoch > blockEpoch), - UserBalance: big.NewInt(0).Sub(userBalance, eth.EthToWei(16)), // Remove 16 ETH from the user balance for full minipools in the refund queue + UserBalance: big.NewInt(0).Sub(userBalance, math.EthToWei(16)), // Remove 16 ETH from the user balance for full minipools in the refund queue } } return validatorBalanceDetails{ @@ -738,10 +738,10 @@ func (b *networkBalances) calculateTotalEthAndRethRate(maxRethDelta *big.Int, la totalEth.Add(totalEth, b.DistributorShareTotal) totalEth.Add(totalEth, b.SmoothingPoolShare) - ratio := eth.WeiToEth(totalEth) / eth.WeiToEth(b.RETHSupply) + ratio := math.WeiToEth(totalEth) / math.WeiToEth(b.RETHSupply) b.OriginalTotalBalanceWei = totalEth - b.OriginalRatioWei = eth.EthToWei(ratio) + b.OriginalRatioWei = math.EthToWei(ratio) b.TotalStaking = big.NewInt(0).Add(b.MinipoolsStaking, b.MegapoolStaking) // Apply the max Reth delta @@ -778,14 +778,14 @@ func (t *submitNetworkBalances) submitBalances(balances networkBalances) error { } // Print the gas info - maxFee := eth.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) + maxFee := math.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) if !gasLimits.PrintAndCheck(false, 0, t.log, maxFee, 0) { return nil } // Set the gas settings opts.GasFeeCap = maxFee - opts.GasTipCap = eth.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) + opts.GasTipCap = math.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) opts.GasLimit = gasLimits.Safe var hash common.Hash // Submit balances diff --git a/rocketpool/watchtower/submit-network-balances_test.go b/rocketpool/watchtower/submit-network-balances_test.go index 3de5170b5..2d9e14a2d 100644 --- a/rocketpool/watchtower/submit-network-balances_test.go +++ b/rocketpool/watchtower/submit-network-balances_test.go @@ -15,9 +15,9 @@ import ( "github.com/rocket-pool/smartnode/bindings/rocketpool" rptypes "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" rpstate "github.com/rocket-pool/smartnode/bindings/utils/state" "github.com/rocket-pool/smartnode/rocketpool/watchtower/utils" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/state" ) @@ -71,12 +71,12 @@ func makeParentBeaconRoot(slot uint64) common.Hash { func TestApplyMaxRethDelta_NoClampNeeded(t *testing.T) { b := newNetworkBalances() b.OriginalTotalBalanceWei = ethToWei(1000) - b.OriginalRatioWei = eth.EthToWei(1.05) + b.OriginalRatioWei = math.EthToWei(1.05) // Last rate is 1.04, new is 1.05: delta = 0.01 lastRate := 1.04 // Max delta is 0.02 ETH in wei — larger than actual change, so no clamp - maxDelta := eth.EthToWei(0.02) + maxDelta := math.EthToWei(0.02) b.applyMaxRethDelta(maxDelta, lastRate) @@ -92,15 +92,15 @@ func TestApplyMaxRethDelta_ClampUpwardIncrease(t *testing.T) { b := newNetworkBalances() // Ratio jumped from 1.00 to 1.10 — a 0.10 increase lastRate := 1.00 - b.OriginalRatioWei = eth.EthToWei(1.10) + b.OriginalRatioWei = math.EthToWei(1.10) b.OriginalTotalBalanceWei = ethToWei(1100) // arbitrary consistent total // Max allowed delta is 0.05 - maxDelta := eth.EthToWei(0.05) + maxDelta := math.EthToWei(0.05) b.applyMaxRethDelta(maxDelta, lastRate) - expectedClampedRatio := new(big.Int).Add(eth.EthToWei(lastRate), maxDelta) // 1.05 + expectedClampedRatio := new(big.Int).Add(math.EthToWei(lastRate), maxDelta) // 1.05 if b.ClampedRatioWei.Cmp(expectedClampedRatio) != 0 { t.Errorf("clamped ratio: got %s, want %s", b.ClampedRatioWei, expectedClampedRatio) } @@ -114,15 +114,15 @@ func TestApplyMaxRethDelta_ClampDownwardDecrease(t *testing.T) { b := newNetworkBalances() // Ratio dropped from 1.10 to 1.00 — a 0.10 decrease lastRate := 1.10 - b.OriginalRatioWei = eth.EthToWei(1.00) + b.OriginalRatioWei = math.EthToWei(1.00) b.OriginalTotalBalanceWei = ethToWei(1000) // Max allowed delta is 0.05 - maxDelta := eth.EthToWei(0.05) + maxDelta := math.EthToWei(0.05) b.applyMaxRethDelta(maxDelta, lastRate) - expectedClampedRatio := new(big.Int).Sub(eth.EthToWei(lastRate), maxDelta) // 1.05 + expectedClampedRatio := new(big.Int).Sub(math.EthToWei(lastRate), maxDelta) // 1.05 if b.ClampedRatioWei.Cmp(expectedClampedRatio) != 0 { t.Errorf("clamped ratio: got %s, want %s", b.ClampedRatioWei, expectedClampedRatio) } @@ -136,9 +136,9 @@ func TestApplyMaxRethDelta_ExactlyAtBoundary(t *testing.T) { // Delta == maxDelta exactly: should NOT clamp (boundary is exclusive via >) b := newNetworkBalances() lastRate := 1.00 - b.OriginalRatioWei = eth.EthToWei(1.05) + b.OriginalRatioWei = math.EthToWei(1.05) b.OriginalTotalBalanceWei = ethToWei(1050) - maxDelta := eth.EthToWei(0.05) // exactly matches the change + maxDelta := math.EthToWei(0.05) // exactly matches the change b.applyMaxRethDelta(maxDelta, lastRate) @@ -150,9 +150,9 @@ func TestApplyMaxRethDelta_ExactlyAtBoundary(t *testing.T) { func TestApplyMaxRethDelta_ZeroRatioChange(t *testing.T) { b := newNetworkBalances() lastRate := 1.05 - b.OriginalRatioWei = eth.EthToWei(1.05) + b.OriginalRatioWei = math.EthToWei(1.05) b.OriginalTotalBalanceWei = ethToWei(1050) - maxDelta := eth.EthToWei(0.01) + maxDelta := math.EthToWei(0.01) b.applyMaxRethDelta(maxDelta, lastRate) @@ -181,7 +181,7 @@ func TestCalculateTotalEthAndRethRate_BasicSummation(t *testing.T) { // Expected total = 100+200+150+50+30+20 - 10 = 540 expectedTotal := ethToWei(540) - maxDelta := eth.EthToWei(999) // large enough to never clamp + maxDelta := math.EthToWei(999) // large enough to never clamp b.calculateTotalEthAndRethRate(maxDelta, 0) if b.OriginalTotalBalanceWei.Cmp(expectedTotal) != 0 { @@ -195,7 +195,7 @@ func TestCalculateTotalEthAndRethRate_NodeCreditIsSubtracted(t *testing.T) { b.RETHSupply = ethToWei(400) b.NodeCreditBalance = ethToWei(100) - maxDelta := eth.EthToWei(999) + maxDelta := math.EthToWei(999) b.calculateTotalEthAndRethRate(maxDelta, 0) // 500 - 100 = 400 @@ -211,7 +211,7 @@ func TestCalculateTotalEthAndRethRate_TotalStakingAggregated(t *testing.T) { b.MegapoolStaking = ethToWei(200) b.RETHSupply = ethToWei(1) - maxDelta := eth.EthToWei(999) + maxDelta := math.EthToWei(999) b.calculateTotalEthAndRethRate(maxDelta, 0) expected := ethToWei(500) @@ -226,10 +226,10 @@ func TestCalculateTotalEthAndRethRate_RatioCalculation(t *testing.T) { b.DepositPool = ethToWei(1100) b.RETHSupply = ethToWei(1000) - maxDelta := eth.EthToWei(999) // no clamp + maxDelta := math.EthToWei(999) // no clamp b.calculateTotalEthAndRethRate(maxDelta, 1.0) - expectedRatio := eth.EthToWei(1.1) + expectedRatio := math.EthToWei(1.1) // Allow 1 wei of rounding tolerance diff := new(big.Int).Abs(new(big.Int).Sub(b.OriginalRatioWei, expectedRatio)) if diff.Cmp(big.NewInt(2)) > 0 { diff --git a/rocketpool/watchtower/submit-rewards-tree-stateless.go b/rocketpool/watchtower/submit-rewards-tree-stateless.go index 7c1b07661..5f7183deb 100644 --- a/rocketpool/watchtower/submit-rewards-tree-stateless.go +++ b/rocketpool/watchtower/submit-rewards-tree-stateless.go @@ -4,7 +4,6 @@ import ( "context" "encoding/hex" "fmt" - "math" "math/big" "os" "sync" @@ -22,10 +21,10 @@ import ( "github.com/rocket-pool/smartnode/bindings/tokens" "github.com/rocket-pool/smartnode/bindings/transactions" "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" - "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/rocketpool/watchtower/utils" hexutil "github.com/rocket-pool/smartnode/shared/hex" log "github.com/rocket-pool/smartnode/shared/logger" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/config" @@ -428,13 +427,13 @@ func (t *submitRewardsTree_Stateless) submitRewardsSnapshot(index *big.Int, cons } // Print the gas info - maxFee := eth.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) + maxFee := math.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) if !gasLimits.PrintAndCheck(false, 0, t.log, maxFee, 0) { return false, nil } opts.GasFeeCap = maxFee - opts.GasTipCap = eth.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) + opts.GasTipCap = math.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) opts.GasLimit = gasLimits.Safe var hash common.Hash diff --git a/rocketpool/watchtower/submit-rpl-price.go b/rocketpool/watchtower/submit-rpl-price.go index 8b25ca29e..ce9811dcb 100644 --- a/rocketpool/watchtower/submit-rpl-price.go +++ b/rocketpool/watchtower/submit-rpl-price.go @@ -24,17 +24,16 @@ import ( "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/transactions" "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" - "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/rocketpool/watchtower/utils" log "github.com/rocket-pool/smartnode/shared/logger" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/config" rpgas "github.com/rocket-pool/smartnode/shared/services/gas" "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" - mathutils "github.com/rocket-pool/smartnode/shared/utils/math" ) const ( @@ -503,7 +502,7 @@ func (t *submitRplPrice) run(state *state.NetworkState) error { } // Log - t.log.Printlnf("RPL price: %.6f ETH", mathutils.RoundDown(eth.WeiToEth(rplPrice), 6)) + t.log.Printlnf("RPL price: %.6f ETH", math.RoundDown(math.WeiToEth(rplPrice), 6)) submissionTimestamp := uint64(nextSubmissionTime.Unix()) @@ -635,8 +634,8 @@ func (t *submitRplPrice) getRplTwap(blockNumber uint64) (*big.Int, error) { tick := big.NewInt(0).Sub(response.TickCumulatives[1], response.TickCumulatives[0]) tick.Div(tick, big.NewInt(int64(interval))) // tick = (cumulative[1] - cumulative[0]) / interval - base := eth.EthToWei(1.0001) // 1.0001e18 - one := eth.EthToWei(1) // 1e18 + base := math.EthToWei(1.0001) // 1.0001e18 + one := math.EthToWei(1) // 1e18 numerator := big.NewInt(0).Exp(base, tick, nil) // 1.0001e18 ^ tick numerator.Mul(numerator, one) @@ -675,14 +674,14 @@ func (t *submitRplPrice) submitRplPrice(blockNumber uint64, slotTimestamp uint64 } // Print the gas info - maxFee := eth.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) + maxFee := math.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) if !gasLimits.PrintAndCheck(false, 0, t.log, maxFee, 0) { return nil } // Set the gas settings opts.GasFeeCap = maxFee - opts.GasTipCap = eth.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) + opts.GasTipCap = math.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) opts.GasLimit = gasLimits.Safe var hash common.Hash @@ -795,14 +794,14 @@ func (t *submitRplPrice) submitOptimismPrice() error { } // Print the gas info - maxFee := eth.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) + maxFee := math.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) if !gasLimits.PrintAndCheck(false, 0, t.log, maxFee, 0) { return nil } // Set the gas settings opts.GasFeeCap = maxFee - opts.GasTipCap = eth.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) + opts.GasTipCap = math.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) opts.GasLimit = gasLimits.Safe t.log.Println("Submitting rate to Optimism...") @@ -916,14 +915,14 @@ func (t *submitRplPrice) submitPolygonPrice() error { } // Print the gas info - maxFee := eth.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) + maxFee := math.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) if !gasLimits.PrintAndCheck(false, 0, t.log, maxFee, 0) { return nil } // Set the gas settings opts.GasFeeCap = maxFee - opts.GasTipCap = eth.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) + opts.GasTipCap = math.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) opts.GasLimit = gasLimits.Safe t.log.Println("Submitting rate to Polygon...") @@ -1032,7 +1031,7 @@ func (t *submitRplPrice) submitArbitrumPrice(priceMessengerAddress string) error bufferMultiplier := big.NewInt(4) dataLength := big.NewInt(36) arbitrumGasLimit := big.NewInt(40000) - arbitrumMaxFeePerGas := eth.GweiToWei(0.1) + arbitrumMaxFeePerGas := math.GweiToWei(0.1) // Gas limit calculation on Arbitrum maxSubmissionCost := big.NewInt(6) @@ -1060,14 +1059,14 @@ func (t *submitRplPrice) submitArbitrumPrice(priceMessengerAddress string) error } // Print the gas info - maxFee := eth.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) + maxFee := math.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) if !gasLimits.PrintAndCheck(false, 0, t.log, maxFee, 0) { return nil } // Set the gas settings opts.GasFeeCap = maxFee - opts.GasTipCap = eth.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) + opts.GasTipCap = math.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) opts.GasLimit = gasLimits.Safe t.log.Println("Submitting rate to Arbitrum %s...", priceMessengerAddress) @@ -1170,10 +1169,10 @@ func (t *submitRplPrice) submitZkSyncEraPrice() error { // Constants for zkSync Era l1GasPerPubdataByte := big.NewInt(17) - fairL2GasPrice := eth.GweiToWei(0.5) + fairL2GasPrice := math.GweiToWei(0.5) l2GasLimit := big.NewInt(750000) gasPerPubdataByte := big.NewInt(800) - maxFee := eth.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) + maxFee := math.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) // Value calculation on zkSync Era pubdataPrice := big.NewInt(0).Mul(l1GasPerPubdataByte, maxFee) @@ -1206,7 +1205,7 @@ func (t *submitRplPrice) submitZkSyncEraPrice() error { // Set the gas settings opts.GasFeeCap = maxFee - opts.GasTipCap = eth.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) + opts.GasTipCap = math.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) opts.GasLimit = gasLimits.Safe t.log.Println("Submitting rate to zkSync Era...") @@ -1320,14 +1319,14 @@ func (t *submitRplPrice) submitBasePrice() error { } // Print the gas info - maxFee := eth.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) + maxFee := math.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) if !gasLimits.PrintAndCheck(false, 0, t.log, maxFee, 0) { return nil } // Set the gas settings opts.GasFeeCap = maxFee - opts.GasTipCap = eth.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) + opts.GasTipCap = math.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) opts.GasLimit = gasLimits.Safe t.log.Println("Submitting rate to Base...") @@ -1466,14 +1465,14 @@ func (t *submitRplPrice) submitScrollPrice() error { } // Print the gas info - maxFee := eth.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) + maxFee := math.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) if !gasLimits.PrintAndCheck(false, 0, t.log, maxFee, 0) { return nil } // Set the gas settings opts.GasFeeCap = maxFee - opts.GasTipCap = eth.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) + opts.GasTipCap = math.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) opts.GasLimit = gasLimits.Safe t.log.Println("Submitting rate to Scroll...") diff --git a/rocketpool/watchtower/submit-scrub-minipools.go b/rocketpool/watchtower/submit-scrub-minipools.go index 074389f5f..53aae7470 100644 --- a/rocketpool/watchtower/submit-scrub-minipools.go +++ b/rocketpool/watchtower/submit-scrub-minipools.go @@ -18,7 +18,6 @@ import ( "github.com/rocket-pool/smartnode/bindings/transactions" "github.com/rocket-pool/smartnode/bindings/types" rputils "github.com/rocket-pool/smartnode/bindings/utils" - "github.com/rocket-pool/smartnode/bindings/utils/eth" rpstate "github.com/rocket-pool/smartnode/bindings/utils/state" ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" @@ -27,6 +26,7 @@ import ( "github.com/rocket-pool/smartnode/rocketpool/watchtower/collectors" "github.com/rocket-pool/smartnode/rocketpool/watchtower/utils" log "github.com/rocket-pool/smartnode/shared/logger" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/config" @@ -371,7 +371,7 @@ func (t *submitScrubMinipools) verifyPrestakeEvents() { minipoolsToScrub := []minipool.Minipool{} - weiPerGwei := big.NewInt(int64(eth.WeiPerGwei)) + weiPerGwei := big.NewInt(int64(math.WeiPerGwei)) for minipool := range t.it.minipools { // Get the MinipoolPrestaked event prestakeData, err := minipool.GetPrestakeEvent(t.it.eventLogInterval, nil) @@ -578,14 +578,14 @@ func (t *submitScrubMinipools) submitVoteScrubMinipool(mp minipool.Minipool) err } // Print the gas info - maxFee := eth.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) + maxFee := math.GweiToWei(utils.GetWatchtowerMaxFee(t.cfg)) if !gasLimits.PrintAndCheck(false, 0, &t.log, maxFee, 0) { return nil } // Set the gas settings opts.GasFeeCap = maxFee - opts.GasTipCap = eth.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) + opts.GasTipCap = math.GweiToWei(utils.GetWatchtowerPrioFee(t.cfg)) opts.GasLimit = gasLimits.Safe // Dissolve diff --git a/shared/utils/math/math.go b/shared/math/math.go similarity index 70% rename from shared/utils/math/math.go rename to shared/math/math.go index 69628d362..a8843f78c 100644 --- a/shared/utils/math/math.go +++ b/shared/math/math.go @@ -5,14 +5,19 @@ import ( "math/bits" ) +var Ceil = math.Ceil +var Floor = math.Floor +var Pow = math.Pow +var Abs = math.Abs + // Round a float64 down to a number of places func RoundDown(val float64, places int) float64 { - return math.Floor(val*math.Pow10(places)) / math.Pow10(places) + return Floor(val*math.Pow10(places)) / math.Pow10(places) } // Round a float64 up to a number of places func RoundUp(val float64, places int) float64 { - return math.Ceil(val*math.Pow10(places)) / math.Pow10(places) + return Ceil(val*math.Pow10(places)) / math.Pow10(places) } func GetPowerOfTwoCeil(x uint64) uint64 { diff --git a/bindings/utils/eth/units.go b/shared/math/units.go similarity index 99% rename from bindings/utils/eth/units.go rename to shared/math/units.go index bf86781a5..2650fe93a 100644 --- a/bindings/utils/eth/units.go +++ b/shared/math/units.go @@ -1,4 +1,4 @@ -package eth +package math import ( "math" diff --git a/shared/services/gas/gas.go b/shared/services/gas/gas.go index fac5827b9..5710069dd 100644 --- a/shared/services/gas/gas.go +++ b/shared/services/gas/gas.go @@ -8,9 +8,9 @@ import ( "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" - "github.com/rocket-pool/smartnode/bindings/utils/eth" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/config" "github.com/rocket-pool/smartnode/shared/services/gas/etherscan" rpsvc "github.com/rocket-pool/smartnode/shared/services/rocketpool" @@ -44,7 +44,7 @@ func (g *Gas) GetMaxGasCostEth(gasLimits gaslimit.Limits) float64 { if g.gasLimit != 0 { limit = g.gasLimit } - return g.maxFeeGwei / eth.WeiPerGwei * float64(limit) + return g.maxFeeGwei / math.WeiPerGwei * float64(limit) } func GetMaxFeeAndLimit(gasLimits gaslimit.Limits, rp *rpsvc.Client, headless bool) (Gas, error) { @@ -62,20 +62,20 @@ func GetMaxFeeAndLimit(gasLimits gaslimit.Limits, rp *rpsvc.Client, headless boo // Get the max fee - prioritize the CLI arguments, default to the config file setting if maxFeeGwei == 0 { - maxFee := eth.GweiToWei(cfg.Smartnode.ManualMaxFee.Value.(float64)) + maxFee := math.GweiToWei(cfg.Smartnode.ManualMaxFee.Value.(float64)) if maxFee != nil && maxFee.Uint64() != 0 { - maxFeeGwei = eth.WeiToGwei(maxFee) + maxFeeGwei = math.WeiToGwei(maxFee) } } // Get the priority fee - prioritize the CLI arguments, default to the config file setting if maxPriorityFeeGwei == 0 { - maxPriorityFee := eth.GweiToWei(cfg.Smartnode.PriorityFee.Value.(float64)) + maxPriorityFee := math.GweiToWei(cfg.Smartnode.PriorityFee.Value.(float64)) if maxPriorityFee == nil || maxPriorityFee.Uint64() == 0 { color.YellowPrintln("NOTE: max priority fee not set or set to 0, defaulting to 2 gwei") maxPriorityFeeGwei = 2 } else { - maxPriorityFeeGwei = eth.WeiToGwei(maxPriorityFee) + maxPriorityFeeGwei = math.WeiToGwei(maxPriorityFee) } } @@ -86,10 +86,10 @@ func GetMaxFeeAndLimit(gasLimits gaslimit.Limits, rp *rpsvc.Client, headless boo var lowLimit float64 var highLimit float64 if gasLimit == 0 { - lowLimit = maxFeeGwei / eth.WeiPerGwei * float64(gasLimits.Estimated) - highLimit = maxFeeGwei / eth.WeiPerGwei * float64(gasLimits.Safe) + lowLimit = maxFeeGwei / math.WeiPerGwei * float64(gasLimits.Estimated) + highLimit = maxFeeGwei / math.WeiPerGwei * float64(gasLimits.Safe) } else { - lowLimit = maxFeeGwei / eth.WeiPerGwei * float64(gasLimit) + lowLimit = maxFeeGwei / math.WeiPerGwei * float64(gasLimit) highLimit = lowLimit } color.YellowPrintf("Total cost: %.4f to %.4f ETH\n", lowLimit, highLimit) @@ -100,7 +100,7 @@ func GetMaxFeeAndLimit(gasLimits gaslimit.Limits, rp *rpsvc.Client, headless boo if err != nil { return Gas{}, err } - maxFeeGwei = eth.WeiToGwei(maxFeeWei) + maxFeeGwei = math.WeiToGwei(maxFeeWei) } else { // Try to get the latest gas prices from Etherscan gasData, err := etherscan.GetGasPrices() @@ -110,9 +110,9 @@ func GetMaxFeeAndLimit(gasLimits gaslimit.Limits, rp *rpsvc.Client, headless boo return Gas{}, err } gasData = etherscan.GasFeeSuggestion{ - SlowGwei: eth.WeiToGwei(gasPrice.GasPrice), - StandardGwei: eth.WeiToGwei(gasPrice.GasPrice) * 1.1, - FastGwei: eth.WeiToGwei(gasPrice.GasPrice) * 1.2, + SlowGwei: math.WeiToGwei(gasPrice.GasPrice), + StandardGwei: math.WeiToGwei(gasPrice.GasPrice) * 1.1, + FastGwei: math.WeiToGwei(gasPrice.GasPrice) * 1.2, } } @@ -132,7 +132,7 @@ func GetMaxFeeAndLimit(gasLimits gaslimit.Limits, rp *rpsvc.Client, headless boo return Gas{}, fmt.Errorf("Priority fee cannot be greater than max fee.") } // Verify the node has enough ETH to use this max fee - maxFee := eth.GweiToWei(maxFeeGwei) + maxFee := math.GweiToWei(maxFeeGwei) ethRequired := big.NewInt(0) if gasLimit != 0 { ethRequired.Mul(maxFee, big.NewInt(int64(gasLimit))) @@ -145,7 +145,7 @@ func GetMaxFeeAndLimit(gasLimits gaslimit.Limits, rp *rpsvc.Client, headless boo color.YellowPrintln("Please ensure your node wallet has enough ETH to pay for this transaction.") fmt.Println() } else if response.Balance.Cmp(ethRequired) < 0 { - return Gas{}, fmt.Errorf("Your node has %.6f ETH in its wallet, which is not enough to pay for this transaction with a max fee of %.4f gwei; you require at least %.6f more ETH.", eth.WeiToEth(response.Balance), maxFeeGwei, eth.WeiToEth(big.NewInt(0).Sub(ethRequired, response.Balance))) + return Gas{}, fmt.Errorf("Your node has %.6f ETH in its wallet, which is not enough to pay for this transaction with a max fee of %.4f gwei; you require at least %.6f more ETH.", math.WeiToEth(response.Balance), maxFeeGwei, math.WeiToEth(big.NewInt(0).Sub(ethRequired, response.Balance))) } return Gas{maxFeeGwei, maxPriorityFeeGwei, gasLimit}, nil @@ -172,7 +172,7 @@ func GetHeadlessMaxFeeWeiWithLatestBlock(cfg *config.RocketPoolConfig, rp *rocke etherscanData, err := etherscan.GetGasPrices() if err == nil { - return eth.GweiToWei(etherscanData.FastGwei), nil + return math.GweiToWei(etherscanData.FastGwei), nil } return nil, fmt.Errorf("error getting gas estimates. You can try again later or specify fees manually using --maxFee and --maxPrioFee.") } @@ -180,7 +180,7 @@ func GetHeadlessMaxFeeWeiWithLatestBlock(cfg *config.RocketPoolConfig, rp *rocke func handleEtherscanGasPrices(gasSuggestion etherscan.GasFeeSuggestion, gasLimits gaslimit.Limits, priorityFee float64, gasLimit uint64) float64 { fastGwei := gasSuggestion.FastGwei + priorityFee - fastEth := fastGwei / eth.WeiPerGwei + fastEth := fastGwei / math.WeiPerGwei var fastLowLimit float64 var fastHighLimit float64 @@ -193,7 +193,7 @@ func handleEtherscanGasPrices(gasSuggestion etherscan.GasFeeSuggestion, gasLimit } standardGwei := gasSuggestion.StandardGwei + priorityFee - standardEth := standardGwei / eth.WeiPerGwei + standardEth := standardGwei / math.WeiPerGwei var standardLowLimit float64 var standardHighLimit float64 @@ -206,7 +206,7 @@ func handleEtherscanGasPrices(gasSuggestion etherscan.GasFeeSuggestion, gasLimit } slowGwei := gasSuggestion.SlowGwei + priorityFee - slowEth := slowGwei / eth.WeiPerGwei + slowEth := slowGwei / math.WeiPerGwei var slowLowLimit float64 var slowHighLimit float64 diff --git a/shared/services/rewards/generator-impl-v11.go b/shared/services/rewards/generator-impl-v11.go index a4d3922bd..c2933089c 100644 --- a/shared/services/rewards/generator-impl-v11.go +++ b/shared/services/rewards/generator-impl-v11.go @@ -16,9 +16,9 @@ import ( "github.com/rocket-pool/smartnode/bindings/rewards" rptypes "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" rpstate "github.com/rocket-pool/smartnode/bindings/utils/state" log "github.com/rocket-pool/smartnode/shared/logger" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/config" "github.com/rocket-pool/smartnode/shared/services/rewards/fees" @@ -294,7 +294,7 @@ func (r *treeGeneratorImpl_v11) calculateNodeRplRewards( // Calculates the RPL rewards for the given interval func (r *treeGeneratorImpl_v11) calculateRplRewards() error { pendingRewards := r.networkState.NetworkDetails.PendingRPLRewards - r.log.Printlnf("%s Pending RPL rewards: %s (%.3f)", r.logPrefix, pendingRewards.String(), eth.WeiToEth(pendingRewards)) + r.log.Printlnf("%s Pending RPL rewards: %s (%.3f)", r.logPrefix, pendingRewards.String(), math.WeiToEth(pendingRewards)) if pendingRewards.Cmp(common.Big0) == 0 { return fmt.Errorf("there are no pending RPL rewards, so this interval cannot be used for rewards submission") } @@ -304,14 +304,14 @@ func (r *treeGeneratorImpl_v11) calculateRplRewards() error { pDaoRewards := big.NewInt(0) pDaoRewards.Mul(pendingRewards, pDaoPercent) pDaoRewards.Div(pDaoRewards, oneEth) - r.log.Printlnf("%s Expected Protocol DAO rewards: %s (%.3f)", r.logPrefix, pDaoRewards.String(), eth.WeiToEth(pDaoRewards)) + r.log.Printlnf("%s Expected Protocol DAO rewards: %s (%.3f)", r.logPrefix, pDaoRewards.String(), math.WeiToEth(pDaoRewards)) // Get node operator rewards nodeOpPercent := r.networkState.NetworkDetails.NodeOperatorRewardsPercent totalNodeRewards := big.NewInt(0) totalNodeRewards.Mul(pendingRewards, nodeOpPercent) totalNodeRewards.Div(totalNodeRewards, oneEth) - r.log.Printlnf("%s Approx. total collateral RPL rewards: %s (%.3f)", r.logPrefix, totalNodeRewards.String(), eth.WeiToEth(totalNodeRewards)) + r.log.Printlnf("%s Approx. total collateral RPL rewards: %s (%.3f)", r.logPrefix, totalNodeRewards.String(), math.WeiToEth(totalNodeRewards)) // Calculate the RPIP-30 weight of each node, scaling by their participation in this interval nodeWeights, totalNodeWeight, err := r.networkState.CalculateNodeWeights() @@ -381,7 +381,7 @@ func (r *treeGeneratorImpl_v11) calculateRplRewards() error { } else { // In this situation, none of the nodes in the network had eligible rewards so send it all to the pDAO pDaoRewards.Add(pDaoRewards, totalNodeRewards) - r.log.Printlnf("%s None of the nodes were eligible for collateral rewards, sending everything to the pDAO; now at %s (%.3f)", r.logPrefix, pDaoRewards.String(), eth.WeiToEth(pDaoRewards)) + r.log.Printlnf("%s None of the nodes were eligible for collateral rewards, sending everything to the pDAO; now at %s (%.3f)", r.logPrefix, pDaoRewards.String(), math.WeiToEth(pDaoRewards)) } // Handle Oracle DAO rewards @@ -389,7 +389,7 @@ func (r *treeGeneratorImpl_v11) calculateRplRewards() error { totalODaoRewards := big.NewInt(0) totalODaoRewards.Mul(pendingRewards, oDaoPercent) totalODaoRewards.Div(totalODaoRewards, oneEth) - r.log.Printlnf("%s Total Oracle DAO RPL rewards: %s (%.3f)", r.logPrefix, totalODaoRewards.String(), eth.WeiToEth(totalODaoRewards)) + r.log.Printlnf("%s Total Oracle DAO RPL rewards: %s (%.3f)", r.logPrefix, totalODaoRewards.String(), math.WeiToEth(totalODaoRewards)) oDaoDetails := r.networkState.OracleDaoMemberDetails @@ -488,8 +488,8 @@ func (r *treeGeneratorImpl_v11) calculateEthRewards(checkBeaconPerformance bool) // Get the Smoothing Pool contract's balance r.smoothingPoolBalance = r.networkState.NetworkDetails.SmoothingPoolBalance - r.log.Printlnf("%s Smoothing Pool Balance:\t%s\t(%.3f)", r.logPrefix, r.smoothingPoolBalance.String(), eth.WeiToEth(r.smoothingPoolBalance)) - r.log.Printlnf("%s Voter Share from Megapools not in the smoothing pool:\t%s\t(%.3f)", r.logPrefix, r.networkState.NetworkDetails.PendingVoterShareEth.String(), eth.WeiToEth(r.networkState.NetworkDetails.PendingVoterShareEth)) + r.log.Printlnf("%s Smoothing Pool Balance:\t%s\t(%.3f)", r.logPrefix, r.smoothingPoolBalance.String(), math.WeiToEth(r.smoothingPoolBalance)) + r.log.Printlnf("%s Voter Share from Megapools not in the smoothing pool:\t%s\t(%.3f)", r.logPrefix, r.networkState.NetworkDetails.PendingVoterShareEth.String(), math.WeiToEth(r.networkState.NetworkDetails.PendingVoterShareEth)) if r.rewardsFile.Index == 0 { // This is the first interval, Smoothing Pool rewards are ignored on the first interval since it doesn't have a discrete start time @@ -994,11 +994,11 @@ func (r *treeGeneratorImpl_v11) calculateNodeRewards() (*nodeRewards, error) { } } } else { - r.log.Printlnf("%s Smoothing Pool has %s (%.3f) Pool Staker ETH before bonuses which is enough for %s (%.3f) in bonuses.", r.logPrefix, remainingBalance.String(), eth.WeiToEth(remainingBalance), totalConsensusBonus.String(), eth.WeiToEth(totalConsensusBonus)) + r.log.Printlnf("%s Smoothing Pool has %s (%.3f) Pool Staker ETH before bonuses which is enough for %s (%.3f) in bonuses.", r.logPrefix, remainingBalance.String(), math.WeiToEth(remainingBalance), totalConsensusBonus.String(), math.WeiToEth(totalConsensusBonus)) } } else { // No bonuses to distribute - r.log.Printlnf("%s Smoothing Pool has %s (%.3f) Pool Staker ETH before bonuses. No consensus bonuses to distribute.", r.logPrefix, remainingBalance.String(), eth.WeiToEth(remainingBalance)) + r.log.Printlnf("%s Smoothing Pool has %s (%.3f) Pool Staker ETH before bonuses. No consensus bonuses to distribute.", r.logPrefix, remainingBalance.String(), math.WeiToEth(remainingBalance)) } } @@ -1029,21 +1029,21 @@ func (r *treeGeneratorImpl_v11) calculateNodeRewards() (*nodeRewards, error) { truePoolStakerAmount.Sub(truePoolStakerAmount, pdaoEth) truePoolStakerAmount.Sub(truePoolStakerAmount, trueVoterEth) - r.log.Printlnf("%s Smoothing Pool ETH: \t%s\t(%.3f)", r.logPrefix, r.smoothingPoolBalance.String(), eth.WeiToEth(r.smoothingPoolBalance)) - r.log.Printlnf("%s Pool staker ETH: \t%s\t(%.3f)", r.logPrefix, truePoolStakerAmount.String(), eth.WeiToEth(truePoolStakerAmount)) - r.log.Printlnf("%s Node Op Eth: \t%s\t(%.3f)", r.logPrefix, trueNodeOperatorAmount.String(), eth.WeiToEth(trueNodeOperatorAmount)) - r.log.Printlnf("%s '--> minipool attestations:\t%s\t(%.3f)", r.logPrefix, totalEthForMinipools.String(), eth.WeiToEth(totalEthForMinipools)) - r.log.Printlnf("%s '----------------> bonuses:\t%s\t(%.3f)", r.logPrefix, totalEthForBonuses.String(), eth.WeiToEth(totalEthForBonuses)) - r.log.Printlnf("%s '--> megapool attestations:\t%s\t(%.3f)", r.logPrefix, totalEthForMegapools.String(), eth.WeiToEth(totalEthForMegapools)) - r.log.Printlnf("%s Voter Share: \t%s\t(%.3f)", r.logPrefix, trueVoterEth.String(), eth.WeiToEth(trueVoterEth)) - r.log.Printlnf("%s PDAO ETH: \t%s\t(%.3f)", r.logPrefix, pdaoEth.String(), eth.WeiToEth(pdaoEth)) + r.log.Printlnf("%s Smoothing Pool ETH: \t%s\t(%.3f)", r.logPrefix, r.smoothingPoolBalance.String(), math.WeiToEth(r.smoothingPoolBalance)) + r.log.Printlnf("%s Pool staker ETH: \t%s\t(%.3f)", r.logPrefix, truePoolStakerAmount.String(), math.WeiToEth(truePoolStakerAmount)) + r.log.Printlnf("%s Node Op Eth: \t%s\t(%.3f)", r.logPrefix, trueNodeOperatorAmount.String(), math.WeiToEth(trueNodeOperatorAmount)) + r.log.Printlnf("%s '--> minipool attestations:\t%s\t(%.3f)", r.logPrefix, totalEthForMinipools.String(), math.WeiToEth(totalEthForMinipools)) + r.log.Printlnf("%s '----------------> bonuses:\t%s\t(%.3f)", r.logPrefix, totalEthForBonuses.String(), math.WeiToEth(totalEthForBonuses)) + r.log.Printlnf("%s '--> megapool attestations:\t%s\t(%.3f)", r.logPrefix, totalEthForMegapools.String(), math.WeiToEth(totalEthForMegapools)) + r.log.Printlnf("%s Voter Share: \t%s\t(%.3f)", r.logPrefix, trueVoterEth.String(), math.WeiToEth(trueVoterEth)) + r.log.Printlnf("%s PDAO ETH: \t%s\t(%.3f)", r.logPrefix, pdaoEth.String(), math.WeiToEth(pdaoEth)) // Sum the actual values to determine how much eth is distributed toBeDistributed := big.NewInt(0) toBeDistributed.Add(toBeDistributed, truePoolStakerAmount) toBeDistributed.Add(toBeDistributed, trueNodeOperatorAmount) toBeDistributed.Add(toBeDistributed, trueVoterEth) toBeDistributed.Add(toBeDistributed, pdaoEth) - r.log.Printlnf("%s TOTAL to be distributed: \t%s\t(%.3f)", r.logPrefix, toBeDistributed.String(), eth.WeiToEth(toBeDistributed)) + r.log.Printlnf("%s TOTAL to be distributed: \t%s\t(%.3f)", r.logPrefix, toBeDistributed.String(), math.WeiToEth(toBeDistributed)) r.log.Printlnf("%s (error = %s wei)", r.logPrefix, delta.String()) return &nodeRewards{ diff --git a/shared/services/rewards/generator-impl-v9-v10.go b/shared/services/rewards/generator-impl-v9-v10.go index 8a65fb930..5386b402a 100644 --- a/shared/services/rewards/generator-impl-v9-v10.go +++ b/shared/services/rewards/generator-impl-v9-v10.go @@ -16,8 +16,8 @@ import ( "github.com/rocket-pool/smartnode/bindings/rewards" rptypes "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" log "github.com/rocket-pool/smartnode/shared/logger" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/config" "github.com/rocket-pool/smartnode/shared/services/rewards/fees" @@ -259,7 +259,7 @@ func (r *treeGeneratorImpl_v9_v10) calculateNodeRplRewards( // Calculates the RPL rewards for the given interval func (r *treeGeneratorImpl_v9_v10) calculateRplRewards() error { pendingRewards := r.networkState.NetworkDetails.PendingRPLRewards - r.log.Printlnf("%s Pending RPL rewards: %s (%.3f)", r.logPrefix, pendingRewards.String(), eth.WeiToEth(pendingRewards)) + r.log.Printlnf("%s Pending RPL rewards: %s (%.3f)", r.logPrefix, pendingRewards.String(), math.WeiToEth(pendingRewards)) if pendingRewards.Cmp(common.Big0) == 0 { return fmt.Errorf("there are no pending RPL rewards, so this interval cannot be used for rewards submission") } @@ -269,14 +269,14 @@ func (r *treeGeneratorImpl_v9_v10) calculateRplRewards() error { pDaoRewards := big.NewInt(0) pDaoRewards.Mul(pendingRewards, pDaoPercent) pDaoRewards.Div(pDaoRewards, oneEth) - r.log.Printlnf("%s Expected Protocol DAO rewards: %s (%.3f)", r.logPrefix, pDaoRewards.String(), eth.WeiToEth(pDaoRewards)) + r.log.Printlnf("%s Expected Protocol DAO rewards: %s (%.3f)", r.logPrefix, pDaoRewards.String(), math.WeiToEth(pDaoRewards)) // Get node operator rewards nodeOpPercent := r.networkState.NetworkDetails.NodeOperatorRewardsPercent totalNodeRewards := big.NewInt(0) totalNodeRewards.Mul(pendingRewards, nodeOpPercent) totalNodeRewards.Div(totalNodeRewards, oneEth) - r.log.Printlnf("%s Approx. total collateral RPL rewards: %s (%.3f)", r.logPrefix, totalNodeRewards.String(), eth.WeiToEth(totalNodeRewards)) + r.log.Printlnf("%s Approx. total collateral RPL rewards: %s (%.3f)", r.logPrefix, totalNodeRewards.String(), math.WeiToEth(totalNodeRewards)) // Calculate the RPIP-30 weight of each node, scaling by their participation in this interval nodeWeights, totalNodeWeight, err := r.networkState.CalculateNodeWeights() @@ -346,7 +346,7 @@ func (r *treeGeneratorImpl_v9_v10) calculateRplRewards() error { } else { // In this situation, none of the nodes in the network had eligible rewards so send it all to the pDAO pDaoRewards.Add(pDaoRewards, totalNodeRewards) - r.log.Printlnf("%s None of the nodes were eligible for collateral rewards, sending everything to the pDAO; now at %s (%.3f)", r.logPrefix, pDaoRewards.String(), eth.WeiToEth(pDaoRewards)) + r.log.Printlnf("%s None of the nodes were eligible for collateral rewards, sending everything to the pDAO; now at %s (%.3f)", r.logPrefix, pDaoRewards.String(), math.WeiToEth(pDaoRewards)) } // Handle Oracle DAO rewards @@ -354,7 +354,7 @@ func (r *treeGeneratorImpl_v9_v10) calculateRplRewards() error { totalODaoRewards := big.NewInt(0) totalODaoRewards.Mul(pendingRewards, oDaoPercent) totalODaoRewards.Div(totalODaoRewards, oneEth) - r.log.Printlnf("%s Total Oracle DAO RPL rewards: %s (%.3f)", r.logPrefix, totalODaoRewards.String(), eth.WeiToEth(totalODaoRewards)) + r.log.Printlnf("%s Total Oracle DAO RPL rewards: %s (%.3f)", r.logPrefix, totalODaoRewards.String(), math.WeiToEth(totalODaoRewards)) oDaoDetails := r.networkState.OracleDaoMemberDetails @@ -450,7 +450,7 @@ func (r *treeGeneratorImpl_v9_v10) calculateEthRewards(checkBeaconPerformance bo // Get the Smoothing Pool contract's balance r.smoothingPoolBalance = r.networkState.NetworkDetails.SmoothingPoolBalance - r.log.Printlnf("%s Smoothing Pool Balance: %s (%.3f)", r.logPrefix, r.smoothingPoolBalance.String(), eth.WeiToEth(r.smoothingPoolBalance)) + r.log.Printlnf("%s Smoothing Pool Balance: %s (%.3f)", r.logPrefix, r.smoothingPoolBalance.String(), math.WeiToEth(r.smoothingPoolBalance)) if r.rewardsFile.Index == 0 { // This is the first interval, Smoothing Pool rewards are ignored on the first interval since it doesn't have a discrete start time @@ -770,10 +770,10 @@ func (r *treeGeneratorImpl_v9_v10) calculateNodeRewards() (*big.Int, *big.Int, * // Calculate the staking pool share and the node op share poolStakerShareBeforeBonuses := big.NewInt(0).Sub(r.smoothingPoolBalance, totalNodeOpShare) - r.log.Printlnf("%s Pool staker ETH before bonuses: %s (%.3f)", r.logPrefix, poolStakerShareBeforeBonuses.String(), eth.WeiToEth(poolStakerShareBeforeBonuses)) - r.log.Printlnf("%s Pool staker ETH after bonuses: %s (%.3f)", r.logPrefix, truePoolStakerAmount.String(), eth.WeiToEth(truePoolStakerAmount)) - r.log.Printlnf("%s Node Op ETH before bonuses: %s (%.3f)", r.logPrefix, totalNodeOpShare.String(), eth.WeiToEth(totalNodeOpShare)) - r.log.Printlnf("%s Node Op ETH after bonuses: %s (%.3f)", r.logPrefix, totalEthForMinipools.String(), eth.WeiToEth(totalEthForMinipools)) + r.log.Printlnf("%s Pool staker ETH before bonuses: %s (%.3f)", r.logPrefix, poolStakerShareBeforeBonuses.String(), math.WeiToEth(poolStakerShareBeforeBonuses)) + r.log.Printlnf("%s Pool staker ETH after bonuses: %s (%.3f)", r.logPrefix, truePoolStakerAmount.String(), math.WeiToEth(truePoolStakerAmount)) + r.log.Printlnf("%s Node Op ETH before bonuses: %s (%.3f)", r.logPrefix, totalNodeOpShare.String(), math.WeiToEth(totalNodeOpShare)) + r.log.Printlnf("%s Node Op ETH after bonuses: %s (%.3f)", r.logPrefix, totalEthForMinipools.String(), math.WeiToEth(totalEthForMinipools)) r.log.Printlnf("%s (error = %s wei)", r.logPrefix, delta.String()) r.log.Printlnf("%s Adjusting pool staker ETH to %s to account for truncation", r.logPrefix, truePoolStakerAmount.String()) diff --git a/shared/services/rewards/mock_v11_test.go b/shared/services/rewards/mock_v11_test.go index 4ba54fcbc..cbebfddef 100644 --- a/shared/services/rewards/mock_v11_test.go +++ b/shared/services/rewards/mock_v11_test.go @@ -15,8 +15,8 @@ import ( "github.com/fatih/color" rptypes "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" log "github.com/rocket-pool/smartnode/shared/logger" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/rewards/test" "github.com/rocket-pool/smartnode/shared/services/rewards/test/assets" @@ -64,15 +64,15 @@ func TestMockIntervalDefaultsTreegenv11(tt *testing.T) { nodeSummary := history.GetNodeSummary() customBalanceNodes := nodeSummary.MustGetClass(tt, "single_eight_eth_opted_in_quarter") for _, node := range customBalanceNodes { - node.Minipools[0].SPWithdrawals = eth.EthToWei(0.75) + node.Minipools[0].SPWithdrawals = math.EthToWei(0.75) } customBalanceNodes = nodeSummary.MustGetClass(tt, "single_eight_eth_opted_out_three_quarters") for _, node := range customBalanceNodes { - node.Minipools[0].SPWithdrawals = eth.EthToWei(0.75) + node.Minipools[0].SPWithdrawals = math.EthToWei(0.75) } customBalanceNodes = nodeSummary.MustGetClass(tt, "single_bond_reduction") for _, node := range customBalanceNodes { - node.Minipools[0].SPWithdrawals = eth.EthToWei(0.5) + node.Minipools[0].SPWithdrawals = math.EthToWei(0.5) } history.SetWithdrawals(t.bc) diff --git a/shared/services/rewards/rewards-file-v1.go b/shared/services/rewards/rewards-file-v1.go index 9bcb63018..6b3e17029 100644 --- a/shared/services/rewards/rewards-file-v1.go +++ b/shared/services/rewards/rewards-file-v1.go @@ -12,7 +12,7 @@ import ( "github.com/wealdtech/go-merkletree/keccak256" "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/shared/math" ) type MinipoolPerformanceFile_v1 struct { @@ -111,7 +111,7 @@ func (p *MinipoolPerformance_v1) GetMissingAttestationSlots() []uint64 { return p.MissingAttestationSlots } func (p *MinipoolPerformance_v1) GetEthEarned() *big.Int { - return eth.EthToWei(p.EthEarned) + return math.EthToWei(p.EthEarned) } func (p *MinipoolPerformance_v1) GetBonusEthEarned() *big.Int { return big.NewInt(0) diff --git a/shared/services/rewards/test/mock.go b/shared/services/rewards/test/mock.go index 3bc207d4d..c4cf66efd 100644 --- a/shared/services/rewards/test/mock.go +++ b/shared/services/rewards/test/mock.go @@ -12,8 +12,8 @@ import ( "github.com/rocket-pool/smartnode/bindings/megapool" rprewards "github.com/rocket-pool/smartnode/bindings/rewards" "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" rpstate "github.com/rocket-pool/smartnode/bindings/utils/state" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/state" ) @@ -84,9 +84,9 @@ type MockMinipool struct { type BondSize *big.Int var ( - BondSizeEightEth = BondSize(eth.EthToWei(8)) - BondSizeSixteenEth = BondSize(eth.EthToWei(16)) - _bondSizeThirtyTwoEth = BondSize(eth.EthToWei(32)) + BondSizeEightEth = BondSize(math.EthToWei(8)) + BondSizeSixteenEth = BondSize(math.EthToWei(16)) + _bondSizeThirtyTwoEth = BondSize(math.EthToWei(32)) ) func (h *MockHistory) GetNewDefaultMockMinipool(bondSize BondSize) *MockMinipool { @@ -259,7 +259,7 @@ func (h *MockHistory) GetNewDefaultMockNode(params *NewMockNodeParams) *MockNode } out.RplStake = big.NewInt(params.CollateralRpl) - out.RplStake.Mul(out.RplStake, eth.EthToWei(1)) + out.RplStake.Mul(out.RplStake, math.EthToWei(1)) // Opt nodes in an epoch before the start of the interval if params.SmoothingPool { @@ -517,7 +517,7 @@ func (h *MockHistory) GetDefaultMockNodes() []*MockNode { CollateralRpl: 10, }) node.Minipools[0].LastBondReductionTime = h.BeaconConfig.GetSlotTime(h.BeaconConfig.FirstSlotOfEpoch(h.StartEpoch + (h.EndEpoch-h.StartEpoch)/2)) - node.Minipools[0].LastBondReductionPrevValue = big.NewInt(0).Mul(big.NewInt(16), eth.EthToWei(1)) + node.Minipools[0].LastBondReductionPrevValue = big.NewInt(0).Mul(big.NewInt(16), math.EthToWei(1)) // Say it was 20% for fun node.Minipools[0].LastBondReductionPrevNodeFee, _ = big.NewInt(0).SetString("200000000000000000", 10) node.Notes = "Node with one 16-eth that does a bond reduction to 8 eth halfway through the interval" @@ -712,7 +712,7 @@ func (h *MockHistory) GetEndNetworkState() *state.NetworkState { ethBorrowingLimit.Div(ethBorrowingLimit, h.NetworkDetails.MinCollateralFraction) collateralisationRatio := big.NewInt(0) if node.borrowedEth.Sign() > 0 { - collateralisationRatio.Div(node.bondedEth, big.NewInt(0).Add(big.NewInt(0).Mul(node.bondedEth, eth.EthToWei(1)), node.borrowedEth)) + collateralisationRatio.Div(node.bondedEth, big.NewInt(0).Add(big.NewInt(0).Mul(node.bondedEth, math.EthToWei(1)), node.borrowedEth)) } // Create the node details diff --git a/shared/services/services.go b/shared/services/services.go index 821d3687e..f419dc23c 100644 --- a/shared/services/services.go +++ b/shared/services/services.go @@ -16,7 +16,7 @@ import ( "github.com/urfave/cli/v3" "github.com/rocket-pool/smartnode/bindings/rocketpool" - "github.com/rocket-pool/smartnode/bindings/utils/eth" + "github.com/rocket-pool/smartnode/shared/math" rpSettings "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/services/beacon" @@ -105,12 +105,12 @@ func GetNodeAccountTransactorFromRequest(c *cli.Command, r *http.Request) (*bind } if maxFeeStr := r.FormValue("maxFee"); maxFeeStr != "" { if maxFeeGwei, parseErr := strconv.ParseFloat(maxFeeStr, 64); parseErr == nil && maxFeeGwei > 0 { - opts.GasFeeCap = eth.GweiToWei(maxFeeGwei) + opts.GasFeeCap = math.GweiToWei(maxFeeGwei) } } if maxPrioFeeStr := r.FormValue("maxPrioFee"); maxPrioFeeStr != "" { if maxPrioFeeGwei, parseErr := strconv.ParseFloat(maxPrioFeeStr, 64); parseErr == nil && maxPrioFeeGwei > 0 { - opts.GasTipCap = eth.GweiToWei(maxPrioFeeGwei) + opts.GasTipCap = math.GweiToWei(maxPrioFeeGwei) } } if gasLimitStr := r.FormValue("gasLimit"); gasLimitStr != "" { @@ -282,7 +282,7 @@ func getWallet(c *cli.Command, cfg *config.RocketPoolConfig, pm *passwords.Passw maxFeeFloat = cfg.Smartnode.ManualMaxFee.Value.(float64) } if maxFeeFloat != 0 { - maxFee = eth.GweiToWei(maxFeeFloat) + maxFee = math.GweiToWei(maxFeeFloat) } var maxPriorityFee *big.Int @@ -291,7 +291,7 @@ func getWallet(c *cli.Command, cfg *config.RocketPoolConfig, pm *passwords.Passw maxPriorityFeeFloat = cfg.Smartnode.PriorityFee.Value.(float64) } if maxPriorityFeeFloat != 0 { - maxPriorityFee = eth.GweiToWei(maxPriorityFeeFloat) + maxPriorityFee = math.GweiToWei(maxPriorityFeeFloat) } chainId := cfg.Smartnode.GetChainID() diff --git a/shared/services/state/network-state.go b/shared/services/state/network-state.go index 52e03f3c8..067fb99f9 100644 --- a/shared/services/state/network-state.go +++ b/shared/services/state/network-state.go @@ -13,8 +13,8 @@ import ( "github.com/rocket-pool/smartnode/bindings/dao/protocol" "github.com/rocket-pool/smartnode/bindings/megapool" "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/bindings/utils/eth" rpstate "github.com/rocket-pool/smartnode/bindings/utils/state" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/beacon" ) @@ -377,7 +377,7 @@ func (m *NetworkStateManager) createNetworkState(slotNumber uint64, nodeAddresse if !validator.Exists { beaconBalances[i] = big.NewInt(0) } else { - beaconBalances[i] = eth.GweiToWei(float64(validator.Balance)) + beaconBalances[i] = math.GweiToWei(float64(validator.Balance)) } } err = rpstate.CalculateCompleteMinipoolShares(m.rp, contracts, mpds, beaconBalances) @@ -561,8 +561,8 @@ func (s *NetworkState) GetMegapoolEligibleBorrowedEth(node *rpstate.NativeNodeDe continue } - validatorTotalEth := big.NewInt(0).Set(eth.MilliEthToWei(float64(megapoolValidatorInfo.ValidatorInfo.LastRequestedValue))) - validatorBondedEth := big.NewInt(0).Set(eth.MilliEthToWei(float64(megapoolValidatorInfo.ValidatorInfo.LastRequestedBond))) + validatorTotalEth := big.NewInt(0).Set(math.MilliEthToWei(float64(megapoolValidatorInfo.ValidatorInfo.LastRequestedValue))) + validatorBondedEth := big.NewInt(0).Set(math.MilliEthToWei(float64(megapoolValidatorInfo.ValidatorInfo.LastRequestedBond))) validatorUserEth := big.NewInt(0).Sub(validatorTotalEth, validatorBondedEth) eligibleBorrowedEth.Sub(eligibleBorrowedEth, validatorUserEth) } diff --git a/shared/types/eth2/fork/deneb/state_deneb.go b/shared/types/eth2/fork/deneb/state_deneb.go index 47ae40898..8dd327f38 100644 --- a/shared/types/eth2/fork/deneb/state_deneb.go +++ b/shared/types/eth2/fork/deneb/state_deneb.go @@ -7,8 +7,8 @@ import ( "reflect" "sync/atomic" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/types/eth2/generic" - "github.com/rocket-pool/smartnode/shared/utils/math" ) const beaconStateChunkCeil uint64 = 32 diff --git a/shared/types/eth2/fork/electra/state_electra.go b/shared/types/eth2/fork/electra/state_electra.go index c412a42b3..55e649f4e 100644 --- a/shared/types/eth2/fork/electra/state_electra.go +++ b/shared/types/eth2/fork/electra/state_electra.go @@ -7,8 +7,8 @@ import ( "reflect" "sync/atomic" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/types/eth2/generic" - "github.com/rocket-pool/smartnode/shared/utils/math" ) const beaconStateChunkCeil uint64 = 64 diff --git a/shared/types/eth2/fork/fulu/state_fulu.go b/shared/types/eth2/fork/fulu/state_fulu.go index f98024f5f..e40230986 100644 --- a/shared/types/eth2/fork/fulu/state_fulu.go +++ b/shared/types/eth2/fork/fulu/state_fulu.go @@ -7,8 +7,8 @@ import ( "reflect" "sync/atomic" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/types/eth2/generic" - "github.com/rocket-pool/smartnode/shared/utils/math" ) const beaconStateChunkCeil uint64 = 64 diff --git a/shared/types/eth2/generic/validator.go b/shared/types/eth2/generic/validator.go index eb6268651..9940c6cd5 100644 --- a/shared/types/eth2/generic/validator.go +++ b/shared/types/eth2/generic/validator.go @@ -1,7 +1,7 @@ package generic import ( - "github.com/rocket-pool/smartnode/shared/utils/math" + "github.com/rocket-pool/smartnode/shared/math" ) func GetGeneralizedIndexForValidator(index uint64, validatorsArrayIndex uint64) uint64 { diff --git a/treegen/tree-gen.go b/treegen/tree-gen.go index da418a338..45e0e031f 100644 --- a/treegen/tree-gen.go +++ b/treegen/tree-gen.go @@ -20,8 +20,8 @@ import ( "github.com/rocket-pool/smartnode/bindings/rewards" "github.com/rocket-pool/smartnode/bindings/rocketpool" - "github.com/rocket-pool/smartnode/bindings/utils/eth" log "github.com/rocket-pool/smartnode/shared/logger" + "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/beacon/client" @@ -588,8 +588,8 @@ func (g *treeGenerator) approximateRethSpRewards() error { if err != nil { return fmt.Errorf("error approximating rETH stakers' share of the Smoothing Pool: %w", err) } - g.log.Printlnf("Total ETH in the Smoothing Pool: %s wei (%.6f ETH)", smoothingPoolBalance.String(), eth.WeiToEth(smoothingPoolBalance)) - g.log.Printlnf("rETH stakers's share: %s wei (%.6f ETH)", rETHShare.String(), eth.WeiToEth(rETHShare)) + g.log.Printlnf("Total ETH in the Smoothing Pool: %s wei (%.6f ETH)", smoothingPoolBalance.String(), math.WeiToEth(smoothingPoolBalance)) + g.log.Printlnf("rETH stakers's share: %s wei (%.6f ETH)", rETHShare.String(), math.WeiToEth(rETHShare)) return nil } From 6ddf63d5dbf489a8f9e20fa11e8f56129a018f52 Mon Sep 17 00:00:00 2001 From: Jacob Shufro Date: Sat, 25 Jul 2026 15:47:55 -0400 Subject: [PATCH 09/12] Remove shared/utils/net --- shared/utils/net/net.go | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 shared/utils/net/net.go diff --git a/shared/utils/net/net.go b/shared/utils/net/net.go deleted file mode 100644 index 26215adea..000000000 --- a/shared/utils/net/net.go +++ /dev/null @@ -1,14 +0,0 @@ -package net - -import ( - "fmt" - "regexp" -) - -// Add a default port to a host address -func DefaultPort(host string, port string) string { - if !regexp.MustCompile(`:\d+$`).MatchString(host) { - return fmt.Sprintf("%s:%s", host, port) - } - return host -} From 6f9046c335f33122195442386f1e9d7b914a52e1 Mon Sep 17 00:00:00 2001 From: Jacob Shufro Date: Sat, 25 Jul 2026 16:13:23 -0400 Subject: [PATCH 10/12] Remove shared/utils/rp --- rocketpool/api/debug/validators.go | 5 +- rocketpool/api/minipool/utils.go | 76 ++++++++++- rocketpool/api/node/check-collateral.go | 18 ++- rocketpool/api/node/claim-rewards.go | 3 +- rocketpool/api/node/rewards.go | 4 +- rocketpool/api/node/status.go | 6 +- .../feerecipient}/fee-recipient.go | 12 +- rocketpool/node/manage-fee-recipient.go | 4 +- shared/services/config/rocket-pool-config.go | 64 +++++++++ shared/services/rocketpool/client.go | 49 +++++-- shared/services/services.go | 3 +- shared/types/api/node.go | 4 +- shared/utils/rp/config.go | 126 ------------------ shared/utils/rp/minipools.go | 90 ------------- shared/utils/rp/node.go | 72 ---------- 15 files changed, 212 insertions(+), 324 deletions(-) rename {shared/utils/rp => rocketpool/feerecipient}/fee-recipient.go (91%) delete mode 100644 shared/utils/rp/config.go delete mode 100644 shared/utils/rp/minipools.go delete mode 100644 shared/utils/rp/node.go diff --git a/rocketpool/api/debug/validators.go b/rocketpool/api/debug/validators.go index a2b3aa6de..32fb1b2ab 100644 --- a/rocketpool/api/debug/validators.go +++ b/rocketpool/api/debug/validators.go @@ -18,7 +18,8 @@ import ( "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/beacon" - "github.com/rocket-pool/smartnode/shared/utils/rp" + + mpApi "github.com/rocket-pool/smartnode/rocketpool/api/minipool" ) const MinipoolBalanceDetailsBatchSize = 20 @@ -91,7 +92,7 @@ func ExportValidators(c *cli.Command) error { } // Get minipool validator statuses - validators, err := rp.GetMinipoolValidators(rpl, bc, addresses, opts, &beacon.ValidatorStatusOptions{Epoch: &blockEpoch}) + validators, err := mpApi.GetMinipoolValidators(rpl, bc, addresses, opts, &beacon.ValidatorStatusOptions{Epoch: &blockEpoch}) if err != nil { return err } diff --git a/rocketpool/api/minipool/utils.go b/rocketpool/api/minipool/utils.go index 07a3ac30b..ef7951fd3 100644 --- a/rocketpool/api/minipool/utils.go +++ b/rocketpool/api/minipool/utils.go @@ -7,6 +7,7 @@ import ( "math/big" "time" + "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "golang.org/x/sync/errgroup" @@ -20,11 +21,11 @@ import ( "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/types/api" - rputils "github.com/rocket-pool/smartnode/shared/utils/rp" ) // Settings const MinipoolDetailsBatchSize = 10 +const MinipoolPubkeyBatchSize = 50 // Validate that a minipool belongs to a node func validateMinipoolOwner(mp minipool.Minipool, nodeAddress common.Address) error { @@ -86,7 +87,7 @@ func GetNodeMinipoolDetails(rp *rocketpool.RocketPool, bc beacon.Client, nodeAdd } // Get minipool validator statuses - validators, err := rputils.GetMinipoolValidators(rp, bc, addresses, nil, nil) + validators, err := GetMinipoolValidators(rp, bc, addresses, nil, nil) if err != nil { return []api.MinipoolDetails{}, err } @@ -344,3 +345,74 @@ func getMinipoolValidatorDetails(rp *rocketpool.RocketPool, minipoolDetails api. return details, nil } + +func GetMinipoolValidators(rp *rocketpool.RocketPool, bc beacon.Client, addresses []common.Address, callOpts *bind.CallOpts, validatorStatusOpts *beacon.ValidatorStatusOptions) (map[common.Address]beacon.ValidatorStatus, error) { + + // Load minipool validator pubkeys in batches + pubkeys := make([]types.ValidatorPubkey, len(addresses)) + for bsi := 0; bsi < len(addresses); bsi += MinipoolPubkeyBatchSize { + + // Get batch start & end index + msi := bsi + mei := min(bsi+MinipoolPubkeyBatchSize, len(addresses)) + + // Load details + var wg errgroup.Group + for mi := msi; mi < mei; mi++ { + mi := mi + wg.Go(func() error { + address := addresses[mi] + pubkey, err := minipool.GetMinipoolPubkey(rp, address, callOpts) + if err == nil { + pubkeys[mi] = pubkey + } + return err + }) + } + if err := wg.Wait(); err != nil { + return map[common.Address]beacon.ValidatorStatus{}, err + } + + } + + // Filter out null and duplicate pubkeys + filteredPubkeys := []types.ValidatorPubkey{} + for _, pubkey := range pubkeys { + if bytes.Equal(pubkey.Bytes(), types.ValidatorPubkey{}.Bytes()) { + continue + } + isDuplicate := false + for _, pk := range filteredPubkeys { + if bytes.Equal(pubkey.Bytes(), pk.Bytes()) { + isDuplicate = true + break + } + } + if isDuplicate { + continue + } + filteredPubkeys = append(filteredPubkeys, pubkey) + } + + // Get validator statuses + statuses, err := bc.GetValidatorStatuses(filteredPubkeys, validatorStatusOpts) + if err != nil { + return map[common.Address]beacon.ValidatorStatus{}, err + } + + // Build validator map + validators := make(map[common.Address]beacon.ValidatorStatus) + for mi := 0; mi < len(addresses); mi++ { + address := addresses[mi] + pubkey := pubkeys[mi] + status, ok := statuses[pubkey] + if !ok { + status = beacon.ValidatorStatus{} + } + validators[address] = status + } + + // Return + return validators, nil + +} diff --git a/rocketpool/api/node/check-collateral.go b/rocketpool/api/node/check-collateral.go index 4f032aa51..00d84bbe1 100644 --- a/rocketpool/api/node/check-collateral.go +++ b/rocketpool/api/node/check-collateral.go @@ -1,13 +1,17 @@ package node import ( + "fmt" "math/big" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" "github.com/urfave/cli/v3" + "github.com/rocket-pool/smartnode/bindings/node" + "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/types/api" - rputils "github.com/rocket-pool/smartnode/shared/utils/rp" ) func checkCollateral(c *cli.Command) (*api.CheckCollateralResponse, error) { @@ -34,7 +38,7 @@ func checkCollateral(c *cli.Command) (*api.CheckCollateralResponse, error) { } // Check collateral - response.EthBorrowed, response.EthBorrowedLimit, response.PendingBorrowAmount, err = rputils.CheckCollateral(rp, nodeAccount.Address, nil) + response.EthBorrowed, response.EthBorrowedLimit, response.PendingBorrowAmount, err = CheckCollateral(rp, nodeAccount.Address, nil) if err != nil { return nil, err } @@ -46,3 +50,13 @@ func checkCollateral(c *cli.Command) (*api.CheckCollateralResponse, error) { return &response, nil } + +// Checks the given node's current borrowed ETH, its limit on borrowed ETH, and how much ETH is preparing to be borrowed by pending bond reductions +func CheckCollateral(rp *rocketpool.RocketPool, nodeAddress common.Address, opts *bind.CallOpts) (ethBorrowed *big.Int, ethBorrowedLimit *big.Int, pendingBorrowAmount *big.Int, err error) { + ethBorrowed, err = node.GetNodeETHBorrowed(rp, nodeAddress, opts) + if err != nil { + return nil, nil, nil, fmt.Errorf("error getting node's borrowed ETH amount: %w", err) + } + + return +} diff --git a/rocketpool/api/node/claim-rewards.go b/rocketpool/api/node/claim-rewards.go index 1ee5f8d0c..c5e5fa85b 100644 --- a/rocketpool/api/node/claim-rewards.go +++ b/rocketpool/api/node/claim-rewards.go @@ -23,7 +23,6 @@ import ( "github.com/rocket-pool/smartnode/shared/services/config" rprewards "github.com/rocket-pool/smartnode/shared/services/rewards" "github.com/rocket-pool/smartnode/shared/types/api" - rputils "github.com/rocket-pool/smartnode/shared/utils/rp" ) func getRewardsInfo(c *cli.Command) (*api.NodeGetRewardsInfoResponse, error) { @@ -163,7 +162,7 @@ func getRewardsInfo(c *cli.Command) (*api.NodeGetRewardsInfoResponse, error) { var wg2 errgroup.Group wg2.Go(func() error { var err error - response.EthBorrowed, response.EthBorrowLimit, response.PendingBorrowAmount, err = rputils.CheckCollateral(rp, nodeAccount.Address, nil) + response.EthBorrowed, response.EthBorrowLimit, response.PendingBorrowAmount, err = CheckCollateral(rp, nodeAccount.Address, nil) return err }) diff --git a/rocketpool/api/node/rewards.go b/rocketpool/api/node/rewards.go index 675b27064..196568635 100644 --- a/rocketpool/api/node/rewards.go +++ b/rocketpool/api/node/rewards.go @@ -21,11 +21,11 @@ import ( "github.com/urfave/cli/v3" "golang.org/x/sync/errgroup" + mpApi "github.com/rocket-pool/smartnode/rocketpool/api/minipool" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/beacon" rprewards "github.com/rocket-pool/smartnode/shared/services/rewards" "github.com/rocket-pool/smartnode/shared/types/api" - rputils "github.com/rocket-pool/smartnode/shared/utils/rp" ) // Settings @@ -41,7 +41,7 @@ type minipoolBalanceDetails struct { func getBeaconBalances(rp *rocketpool.RocketPool, bc beacon.Client, addresses []common.Address, beaconHead beacon.BeaconHead, opts *bind.CallOpts) ([]minipoolBalanceDetails, error) { // Get minipool validator statuses - validators, err := rputils.GetMinipoolValidators(rp, bc, addresses, opts, &beacon.ValidatorStatusOptions{Epoch: &beaconHead.Epoch}) + validators, err := mpApi.GetMinipoolValidators(rp, bc, addresses, opts, &beacon.ValidatorStatusOptions{Epoch: &beaconHead.Epoch}) if err != nil { return []minipoolBalanceDetails{}, err } diff --git a/rocketpool/api/node/status.go b/rocketpool/api/node/status.go index d341461cc..4fd73d72e 100644 --- a/rocketpool/api/node/status.go +++ b/rocketpool/api/node/status.go @@ -24,12 +24,12 @@ import ( mp "github.com/rocket-pool/smartnode/rocketpool/api/minipool" "github.com/rocket-pool/smartnode/rocketpool/api/pdao" + "github.com/rocket-pool/smartnode/rocketpool/feerecipient" "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/types/api" cfgtypes "github.com/rocket-pool/smartnode/shared/types/config" - rputils "github.com/rocket-pool/smartnode/shared/utils/rp" ) func getStatus(c *cli.Command) (*api.NodeStatusResponse, error) { @@ -276,7 +276,7 @@ func getStatus(c *cli.Command) (*api.NodeStatusResponse, error) { wg.Go(func() error { var err error - response.EthBorrowed, response.EthBorrowedLimit, response.PendingBorrowAmount, err = rputils.CheckCollateral(rp, nodeAccount.Address, nil) + response.EthBorrowed, response.EthBorrowedLimit, response.PendingBorrowAmount, err = CheckCollateral(rp, nodeAccount.Address, nil) return err }) @@ -364,7 +364,7 @@ func getStatus(c *cli.Command) (*api.NodeStatusResponse, error) { }) wg.Go(func() error { var err error - feeRecipientInfo, err := rputils.GetFeeRecipientInfoWithoutState(rp, bc, nodeAccount.Address, nil) + feeRecipientInfo, err := feerecipient.GetDetailsWithoutState(rp, bc, nodeAccount.Address, nil) if err == nil { response.FeeRecipientInfo = *feeRecipientInfo response.FeeDistributorBalance, err = rp.Client.BalanceAt(context.Background(), feeRecipientInfo.FeeDistributorAddress, nil) diff --git a/shared/utils/rp/fee-recipient.go b/rocketpool/feerecipient/fee-recipient.go similarity index 91% rename from shared/utils/rp/fee-recipient.go rename to rocketpool/feerecipient/fee-recipient.go index 220129612..94572cdf9 100644 --- a/shared/utils/rp/fee-recipient.go +++ b/rocketpool/feerecipient/fee-recipient.go @@ -1,4 +1,4 @@ -package rp +package feerecipient import ( "fmt" @@ -14,7 +14,7 @@ import ( "github.com/rocket-pool/smartnode/shared/services/state" ) -type FeeRecipientInfo struct { +type Details struct { SmoothingPoolAddress common.Address `json:"smoothingPoolAddress"` FeeDistributorAddress common.Address `json:"feeDistributorAddress"` MegapoolAddress common.Address `json:"megapoolAddress"` @@ -25,9 +25,9 @@ type FeeRecipientInfo struct { OptOutEpoch uint64 `json:"optOutEpoch"` } -func GetFeeRecipientInfo(rp *rocketpool.RocketPool, bc beacon.Client, nodeAddress common.Address, state *state.NetworkState) (*FeeRecipientInfo, error) { +func GetDetails(rp *rocketpool.RocketPool, bc beacon.Client, nodeAddress common.Address, state *state.NetworkState) (*Details, error) { - info := &FeeRecipientInfo{ + info := &Details{ IsInOptOutCooldown: false, OptOutEpoch: 0, } @@ -77,8 +77,8 @@ func GetFeeRecipientInfo(rp *rocketpool.RocketPool, bc beacon.Client, nodeAddres } -func GetFeeRecipientInfoWithoutState(rp *rocketpool.RocketPool, bc beacon.Client, nodeAddress common.Address, opts *bind.CallOpts) (*FeeRecipientInfo, error) { - info := &FeeRecipientInfo{ +func GetDetailsWithoutState(rp *rocketpool.RocketPool, bc beacon.Client, nodeAddress common.Address, opts *bind.CallOpts) (*Details, error) { + info := &Details{ IsInOptOutCooldown: false, OptOutEpoch: 0, } diff --git a/rocketpool/node/manage-fee-recipient.go b/rocketpool/node/manage-fee-recipient.go index 1bc1a410b..dfad4663f 100644 --- a/rocketpool/node/manage-fee-recipient.go +++ b/rocketpool/node/manage-fee-recipient.go @@ -8,6 +8,7 @@ import ( "github.com/urfave/cli/v3" "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/rocketpool/feerecipient" log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services" @@ -17,7 +18,6 @@ import ( rpsvc "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" - rputils "github.com/rocket-pool/smartnode/shared/utils/rp" "github.com/rocket-pool/smartnode/shared/utils/validator" ) @@ -105,7 +105,7 @@ func (m *manageFeeRecipient) run(state *state.NetworkState) error { } // Get the fee recipient info for the node - feeRecipientInfo, err := rputils.GetFeeRecipientInfo(m.rp, m.bc, nodeAccount.Address, state) + feeRecipientInfo, err := feerecipient.GetDetails(m.rp, m.bc, nodeAccount.Address, state) if err != nil { return fmt.Errorf("error getting fee recipient info: %w", err) } diff --git a/shared/services/config/rocket-pool-config.go b/shared/services/config/rocket-pool-config.go index 8ded2a909..e4f6bea93 100644 --- a/shared/services/config/rocket-pool-config.go +++ b/shared/services/config/rocket-pool-config.go @@ -1,7 +1,9 @@ package config import ( + "errors" "fmt" + "io/fs" "net" "net/url" "os" @@ -197,6 +199,68 @@ func LoadFromFile(path string) (*RocketPoolConfig, error) { } +func (cfg *RocketPoolConfig) Save(directory, filename string) error { + path := filepath.Join(directory, filename) + + settings := cfg.Serialize() + configBytes, err := yaml.Marshal(settings) + if err != nil { + return fmt.Errorf("could not serialize settings file: %w", err) + } + + // Make a tmp file + // The empty string directs CreateTemp to use the OS's $TMPDIR (or GetTempPath) on windows + // The * in the second string is replaced with random characters by CreateTemp + f, err := os.CreateTemp(directory, ".tmp-"+filename+"-*") + if err != nil { + if errors.Is(err, fs.ErrExist) { + return fmt.Errorf("could not create file to save config to disk... do you need to clean your tmpdir (%s)?: %w", os.TempDir(), err) + } + + return fmt.Errorf("could not create file to save config to disk: %w", err) + } + // Clean up the temporary files + // This prevents us from filling up `directory` with partially written files on failure + // If the file is successfully written, it fails with an error since it will be renamed + // before it is deleted, which we explicitly ignore / don't care about. + defer func() { + // Clean up tmp files, if any found + oldFiles, err := filepath.Glob(filepath.Join(directory, ".tmp-"+filename+"-*")) + if err != nil { + // Only possible error is ErrBadPattern, which we should catch + // during development, since the pattern is a comptime constant. + panic(err.Error()) + } + + for _, match := range oldFiles { + _ = os.RemoveAll(match) + } + }() + + // Save the serialized settings to the temporary file + if _, err := f.Write(configBytes); err != nil { + return fmt.Errorf("could not write Rocket Pool config to %s: %w", shellescape.Quote(path), err) + } + + // Close the file for writing + if err := f.Close(); err != nil { + return fmt.Errorf("error saving Rocket Pool config to %s: %w", shellescape.Quote(path), err) + } + + // Rename the temp file to overwrite the actual file. + // On Unix systems this operation is atomic and won't fail if the disk is now full + if err := os.Rename(f.Name(), path); err != nil { + return fmt.Errorf("error replacing old Rocket Pool config with %s: %w", f.Name(), err) + } + + // Just in case the rename didn't overwrite (and preserve the perms of) the original file, set them now. + if err := os.Chmod(path, 0664); err != nil { + return fmt.Errorf("error updating permissions of %s: %w", path, err) + } + + return nil +} + // Creates a new Rocket Pool configuration instance func NewRocketPoolConfig(rpDir string, isNativeMode bool) *RocketPoolConfig { diff --git a/shared/services/rocketpool/client.go b/shared/services/rocketpool/client.go index 53502f009..834b0fbc9 100644 --- a/shared/services/rocketpool/client.go +++ b/shared/services/rocketpool/client.go @@ -35,7 +35,6 @@ import ( "github.com/rocket-pool/smartnode/shared/services/rocketpool/template" "github.com/rocket-pool/smartnode/shared/types/api" cfgtypes "github.com/rocket-pool/smartnode/shared/types/config" - "github.com/rocket-pool/smartnode/shared/utils/rp" ) // Config @@ -45,11 +44,10 @@ const ( PrometheusConfigTemplate string = "prometheus.tmpl" PrometheusFile string = "prometheus.yml" - templatesDir string = "templates" - overrideDir string = "override" - runtimeDir string = "runtime" - defaultFeeRecipientFile string = "fr-default.tmpl" - defaultNativeFeeRecipientFile string = "fr-default-env.tmpl" + templatesDir string = "templates" + overrideDir string = "override" + runtimeDir string = "runtime" + upgradeFlagFile string = ".firstrun" nethermindAdminUrl string = "http://127.0.0.1:7434" pruneStarterContainerSuffix string = "_nm_prune_starter" @@ -204,7 +202,7 @@ func (c *Client) LoadConfig() (*config.RocketPoolConfig, bool, error) { return nil, false, fmt.Errorf("error expanding settings file path: %w", err) } - cfg, err := rp.LoadConfigFromFile(expandedPath) + cfg, err := config.LoadFromFile(expandedPath) if err != nil { return nil, false, err } @@ -226,7 +224,7 @@ func (c *Client) LoadBackupConfig() (*config.RocketPoolConfig, error) { return nil, fmt.Errorf("error expanding backup settings file path: %w", err) } - return rp.LoadConfigFromFile(expandedPath) + return config.LoadFromFile(expandedPath) } // Save the config @@ -235,7 +233,27 @@ func (c *Client) SaveConfig(cfg *config.RocketPoolConfig) error { if err != nil { return err } - return rp.SaveConfig(cfg, settingsFileDirectoryPath, SettingsFile) + return cfg.Save(settingsFileDirectoryPath, SettingsFile) +} + +// Remove the upgrade flag file +func removeUpgradeFlagFile(configDir string) error { + + // Check for the upgrade flag file + upgradeFilePath := filepath.Join(configDir, upgradeFlagFile) + _, err := os.Stat(upgradeFilePath) + if os.IsNotExist(err) { + return nil + } + + // Delete the upgrade flag file + err = os.Remove(upgradeFilePath) + if err != nil { + return fmt.Errorf("error removing upgrade flag file: %w", err) + } + + return nil + } // Remove the upgrade flag file @@ -244,7 +262,16 @@ func (c *Client) RemoveUpgradeFlagFile() error { if err != nil { return err } - return rp.RemoveUpgradeFlagFile(expandedPath) + return removeUpgradeFlagFile(expandedPath) +} + +// Checks if this is the first run of the configurator after an install +func isFirstRun(configDir string) bool { + upgradeFilePath := filepath.Join(configDir, upgradeFlagFile) + + // Load the config normally if the upgrade flag file isn't there + _, err := os.Stat(upgradeFilePath) + return !os.IsNotExist(err) } // Returns whether or not this is the first run of the configurator since a previous installation @@ -253,7 +280,7 @@ func (c *Client) IsFirstRun() (bool, error) { if err != nil { return false, fmt.Errorf("error expanding settings file path: %w", err) } - return rp.IsFirstRun(expandedPath), nil + return isFirstRun(expandedPath), nil } // Load the Prometheus template, do a template variable substitution, and save it diff --git a/shared/services/services.go b/shared/services/services.go index f419dc23c..83364af31 100644 --- a/shared/services/services.go +++ b/shared/services/services.go @@ -31,7 +31,6 @@ import ( prkeystore "github.com/rocket-pool/smartnode/shared/services/wallet/keystore/prysm" tkkeystore "github.com/rocket-pool/smartnode/shared/services/wallet/keystore/teku" "github.com/rocket-pool/smartnode/shared/types/eth2" - "github.com/rocket-pool/smartnode/shared/utils/rp" ) // Config @@ -253,7 +252,7 @@ func getConfig(c *cli.Command) (*config.RocketPoolConfig, error) { } } expanded := os.ExpandEnv(settingsFile) - cfg, err = rp.LoadConfigFromFile(expanded) + cfg, err = config.LoadFromFile(expanded) if cfg == nil && err == nil { err = fmt.Errorf("settings file [%s] not found", expanded) } diff --git a/shared/types/api/node.go b/shared/types/api/node.go index 7055e4922..143e0296d 100644 --- a/shared/types/api/node.go +++ b/shared/types/api/node.go @@ -11,8 +11,8 @@ import ( "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" rptypes "github.com/rocket-pool/smartnode/bindings/types" "github.com/rocket-pool/smartnode/rocketpool-cli/cli/color" + "github.com/rocket-pool/smartnode/rocketpool/feerecipient" "github.com/rocket-pool/smartnode/shared/services/rewards" - "github.com/rocket-pool/smartnode/shared/utils/rp" ) type NodeStatusResponse struct { @@ -72,7 +72,7 @@ type NodeStatusResponse struct { Finalised int `json:"finalised"` } `json:"minipoolCounts"` IsFeeDistributorInitialized bool `json:"isFeeDistributorInitialized"` - FeeRecipientInfo rp.FeeRecipientInfo `json:"feeRecipientInfo"` + FeeRecipientInfo feerecipient.Details `json:"feeRecipientInfo"` FeeDistributorBalance *big.Int `json:"feeDistributorBalance"` PenalizedMinipools map[common.Address]uint64 `json:"penalizedMinipools"` SnapshotResponse struct { diff --git a/shared/utils/rp/config.go b/shared/utils/rp/config.go deleted file mode 100644 index 7680fc776..000000000 --- a/shared/utils/rp/config.go +++ /dev/null @@ -1,126 +0,0 @@ -package rp - -import ( - "errors" - "fmt" - "io/fs" - "os" - "path/filepath" - - "github.com/alessio/shellescape" - "gopkg.in/yaml.v2" - - "github.com/rocket-pool/smartnode/shared/services/config" -) - -const ( - upgradeFlagFile string = ".firstrun" -) - -// Loads a config without updating it if it exists -func LoadConfigFromFile(path string) (*config.RocketPoolConfig, error) { - _, err := os.Stat(path) - if os.IsNotExist(err) { - return nil, nil - } - - cfg, err := config.LoadFromFile(path) - if err != nil { - return nil, err - } - - return cfg, nil -} - -// Saves a config and removes the upgrade flag file -func SaveConfig(cfg *config.RocketPoolConfig, directory, filename string) error { - path := filepath.Join(directory, filename) - - settings := cfg.Serialize() - configBytes, err := yaml.Marshal(settings) - if err != nil { - return fmt.Errorf("could not serialize settings file: %w", err) - } - - // Make a tmp file - // The empty string directs CreateTemp to use the OS's $TMPDIR (or GetTempPath) on windows - // The * in the second string is replaced with random characters by CreateTemp - f, err := os.CreateTemp(directory, ".tmp-"+filename+"-*") - if err != nil { - if errors.Is(err, fs.ErrExist) { - return fmt.Errorf("could not create file to save config to disk... do you need to clean your tmpdir (%s)?: %w", os.TempDir(), err) - } - - return fmt.Errorf("could not create file to save config to disk: %w", err) - } - // Clean up the temporary files - // This prevents us from filling up `directory` with partially written files on failure - // If the file is successfully written, it fails with an error since it will be renamed - // before it is deleted, which we explicitly ignore / don't care about. - defer func() { - // Clean up tmp files, if any found - oldFiles, err := filepath.Glob(filepath.Join(directory, ".tmp-"+filename+"-*")) - if err != nil { - // Only possible error is ErrBadPattern, which we should catch - // during development, since the pattern is a comptime constant. - panic(err.Error()) - } - - for _, match := range oldFiles { - _ = os.RemoveAll(match) - } - }() - - // Save the serialized settings to the temporary file - if _, err := f.Write(configBytes); err != nil { - return fmt.Errorf("could not write Rocket Pool config to %s: %w", shellescape.Quote(path), err) - } - - // Close the file for writing - if err := f.Close(); err != nil { - return fmt.Errorf("error saving Rocket Pool config to %s: %w", shellescape.Quote(path), err) - } - - // Rename the temp file to overwrite the actual file. - // On Unix systems this operation is atomic and won't fail if the disk is now full - if err := os.Rename(f.Name(), path); err != nil { - return fmt.Errorf("error replacing old Rocket Pool config with %s: %w", f.Name(), err) - } - - // Just in case the rename didn't overwrite (and preserve the perms of) the original file, set them now. - if err := os.Chmod(path, 0664); err != nil { - return fmt.Errorf("error updating permissions of %s: %w", path, err) - } - - return nil - -} - -// Checks if this is the first run of the configurator after an install -func IsFirstRun(configDir string) bool { - upgradeFilePath := filepath.Join(configDir, upgradeFlagFile) - - // Load the config normally if the upgrade flag file isn't there - _, err := os.Stat(upgradeFilePath) - return !os.IsNotExist(err) -} - -// Remove the upgrade flag file -func RemoveUpgradeFlagFile(configDir string) error { - - // Check for the upgrade flag file - upgradeFilePath := filepath.Join(configDir, upgradeFlagFile) - _, err := os.Stat(upgradeFilePath) - if os.IsNotExist(err) { - return nil - } - - // Delete the upgrade flag file - err = os.Remove(upgradeFilePath) - if err != nil { - return fmt.Errorf("error removing upgrade flag file: %w", err) - } - - return nil - -} diff --git a/shared/utils/rp/minipools.go b/shared/utils/rp/minipools.go deleted file mode 100644 index 9d4739878..000000000 --- a/shared/utils/rp/minipools.go +++ /dev/null @@ -1,90 +0,0 @@ -package rp - -import ( - "bytes" - - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - "golang.org/x/sync/errgroup" - - "github.com/rocket-pool/smartnode/bindings/minipool" - "github.com/rocket-pool/smartnode/bindings/rocketpool" - "github.com/rocket-pool/smartnode/bindings/types" - - "github.com/rocket-pool/smartnode/shared/services/beacon" -) - -// Settings -const MinipoolPubkeyBatchSize = 50 - -// Get minipool validator statuses -func GetMinipoolValidators(rp *rocketpool.RocketPool, bc beacon.Client, addresses []common.Address, callOpts *bind.CallOpts, validatorStatusOpts *beacon.ValidatorStatusOptions) (map[common.Address]beacon.ValidatorStatus, error) { - - // Load minipool validator pubkeys in batches - pubkeys := make([]types.ValidatorPubkey, len(addresses)) - for bsi := 0; bsi < len(addresses); bsi += MinipoolPubkeyBatchSize { - - // Get batch start & end index - msi := bsi - mei := min(bsi+MinipoolPubkeyBatchSize, len(addresses)) - - // Load details - var wg errgroup.Group - for mi := msi; mi < mei; mi++ { - mi := mi - wg.Go(func() error { - address := addresses[mi] - pubkey, err := minipool.GetMinipoolPubkey(rp, address, callOpts) - if err == nil { - pubkeys[mi] = pubkey - } - return err - }) - } - if err := wg.Wait(); err != nil { - return map[common.Address]beacon.ValidatorStatus{}, err - } - - } - - // Filter out null and duplicate pubkeys - filteredPubkeys := []types.ValidatorPubkey{} - for _, pubkey := range pubkeys { - if bytes.Equal(pubkey.Bytes(), types.ValidatorPubkey{}.Bytes()) { - continue - } - isDuplicate := false - for _, pk := range filteredPubkeys { - if bytes.Equal(pubkey.Bytes(), pk.Bytes()) { - isDuplicate = true - break - } - } - if isDuplicate { - continue - } - filteredPubkeys = append(filteredPubkeys, pubkey) - } - - // Get validator statuses - statuses, err := bc.GetValidatorStatuses(filteredPubkeys, validatorStatusOpts) - if err != nil { - return map[common.Address]beacon.ValidatorStatus{}, err - } - - // Build validator map - validators := make(map[common.Address]beacon.ValidatorStatus) - for mi := 0; mi < len(addresses); mi++ { - address := addresses[mi] - pubkey := pubkeys[mi] - status, ok := statuses[pubkey] - if !ok { - status = beacon.ValidatorStatus{} - } - validators[address] = status - } - - // Return - return validators, nil - -} diff --git a/shared/utils/rp/node.go b/shared/utils/rp/node.go deleted file mode 100644 index ed88c2931..000000000 --- a/shared/utils/rp/node.go +++ /dev/null @@ -1,72 +0,0 @@ -package rp - -import ( - "bytes" - "context" - "fmt" - "math/big" - - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - - "github.com/rocket-pool/smartnode/bindings/minipool" - "github.com/rocket-pool/smartnode/bindings/node" - "github.com/rocket-pool/smartnode/bindings/rocketpool" - "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/shared/services/beacon" -) - -func GetNodeValidatorIndices(rp *rocketpool.RocketPool, ec rocketpool.ExecutionClient, bc beacon.Client, nodeAddress common.Address) ([]string, error) { - // Get current block number so all subsequent queries are done at same point in time - blockNumber, err := ec.BlockNumber(context.Background()) - if err != nil { - return nil, fmt.Errorf("Error getting block number: %w", err) - } - - // Setup call opts - blockNumberBig := big.NewInt(0).SetUint64(blockNumber) - callOpts := bind.CallOpts{BlockNumber: blockNumberBig} - - // Get list of pubkeys for this given node - pubkeys, err := minipool.GetNodeValidatingMinipoolPubkeys(rp, nodeAddress, &callOpts) - if err != nil { - return nil, err - } - - // Remove zero pubkeys - zeroPubkey := types.ValidatorPubkey{} - filteredPubkeys := []types.ValidatorPubkey{} - for _, pubkey := range pubkeys { - if !bytes.Equal(pubkey[:], zeroPubkey[:]) { - filteredPubkeys = append(filteredPubkeys, pubkey) - } - } - pubkeys = filteredPubkeys - - // Get validator statuses by pubkeys - statuses, err := bc.GetValidatorStatuses(pubkeys, nil) - if err != nil { - return nil, fmt.Errorf("Error getting validator statuses: %w", err) - } - - // Enumerate validators statuses and fill indices array - validatorIndices := make([]string, len(statuses)+1) - - i := 0 - for _, status := range statuses { - validatorIndices[i] = status.Index - i++ - } - - return validatorIndices, nil -} - -// Checks the given node's current borrowed ETH, its limit on borrowed ETH, and how much ETH is preparing to be borrowed by pending bond reductions -func CheckCollateral(rp *rocketpool.RocketPool, nodeAddress common.Address, opts *bind.CallOpts) (ethBorrowed *big.Int, ethBorrowedLimit *big.Int, pendingBorrowAmount *big.Int, err error) { - ethBorrowed, err = node.GetNodeETHBorrowed(rp, nodeAddress, opts) - if err != nil { - return nil, nil, nil, fmt.Errorf("error getting node's borrowed ETH amount: %w", err) - } - - return -} From 254ee90b53e2689bc57946ef50ed5387c5e27378 Mon Sep 17 00:00:00 2001 From: Jacob Shufro Date: Sat, 25 Jul 2026 16:14:53 -0400 Subject: [PATCH 11/12] Remove shared/utils/term --- {shared/utils => rocketpool-cli/cli}/term/term_unix.go | 0 {shared/utils => rocketpool-cli/cli}/term/term_windows.go | 0 rocketpool-cli/wallet/init.go | 2 +- 3 files changed, 1 insertion(+), 1 deletion(-) rename {shared/utils => rocketpool-cli/cli}/term/term_unix.go (100%) rename {shared/utils => rocketpool-cli/cli}/term/term_windows.go (100%) diff --git a/shared/utils/term/term_unix.go b/rocketpool-cli/cli/term/term_unix.go similarity index 100% rename from shared/utils/term/term_unix.go rename to rocketpool-cli/cli/term/term_unix.go diff --git a/shared/utils/term/term_windows.go b/rocketpool-cli/cli/term/term_windows.go similarity index 100% rename from shared/utils/term/term_windows.go rename to rocketpool-cli/cli/term/term_windows.go diff --git a/rocketpool-cli/wallet/init.go b/rocketpool-cli/wallet/init.go index 77f87ee8f..a26f62191 100644 --- a/rocketpool-cli/wallet/init.go +++ b/rocketpool-cli/wallet/init.go @@ -4,8 +4,8 @@ import ( "fmt" promptcli "github.com/rocket-pool/smartnode/rocketpool-cli/cli/prompt" + "github.com/rocket-pool/smartnode/rocketpool-cli/cli/term" "github.com/rocket-pool/smartnode/shared/services/rocketpool" - "github.com/rocket-pool/smartnode/shared/utils/term" ) func initWallet(password string, confirmMnemonicFlag bool, derivationPath string, secureSession bool) error { From 72ce7f1755fb2eea78ca841b97c98f235021f5b1 Mon Sep 17 00:00:00 2001 From: Jacob Shufro Date: Sat, 25 Jul 2026 16:19:00 -0400 Subject: [PATCH 12/12] Remove shared/utils/validator --- rocketpool/api/megapool/exit-validator.go | 2 +- rocketpool/api/minipool/change-withdrawal-creds.go | 2 +- rocketpool/api/minipool/exit.go | 2 +- rocketpool/api/minipool/import-key.go | 2 +- rocketpool/api/minipool/rescue-dissolved.go | 2 +- rocketpool/api/minipool/stake.go | 2 +- rocketpool/api/node/deposit.go | 2 +- rocketpool/api/node/smoothing-pool.go | 2 +- rocketpool/api/service/restart-vc.go | 2 +- rocketpool/node/manage-fee-recipient.go | 2 +- rocketpool/node/stake-megapool-validator.go | 2 +- {shared/utils => rocketpool}/validator/bls.go | 0 {shared/utils => rocketpool}/validator/deposit-data.go | 0 {shared/utils => rocketpool}/validator/fee-recipient.go | 0 {shared/utils => rocketpool}/validator/set-withdrawal-creds.go | 0 {shared/utils => rocketpool}/validator/voluntary-exit.go | 0 shared/services/wallet/validator.go | 2 +- 17 files changed, 12 insertions(+), 12 deletions(-) rename {shared/utils => rocketpool}/validator/bls.go (100%) rename {shared/utils => rocketpool}/validator/deposit-data.go (100%) rename {shared/utils => rocketpool}/validator/fee-recipient.go (100%) rename {shared/utils => rocketpool}/validator/set-withdrawal-creds.go (100%) rename {shared/utils => rocketpool}/validator/voluntary-exit.go (100%) diff --git a/rocketpool/api/megapool/exit-validator.go b/rocketpool/api/megapool/exit-validator.go index 5a2e87800..87132e9a3 100644 --- a/rocketpool/api/megapool/exit-validator.go +++ b/rocketpool/api/megapool/exit-validator.go @@ -6,9 +6,9 @@ import ( "github.com/rocket-pool/smartnode/bindings/megapool" "github.com/rocket-pool/smartnode/bindings/types" + "github.com/rocket-pool/smartnode/rocketpool/validator" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/types/api" - "github.com/rocket-pool/smartnode/shared/utils/validator" ) func canExitValidator(c *cli.Command, validatorId uint32) (*api.CanExitValidatorResponse, error) { diff --git a/rocketpool/api/minipool/change-withdrawal-creds.go b/rocketpool/api/minipool/change-withdrawal-creds.go index 9164edcf9..8584b7393 100644 --- a/rocketpool/api/minipool/change-withdrawal-creds.go +++ b/rocketpool/api/minipool/change-withdrawal-creds.go @@ -12,10 +12,10 @@ import ( "github.com/rocket-pool/smartnode/bindings/minipool" "github.com/rocket-pool/smartnode/bindings/types" + "github.com/rocket-pool/smartnode/rocketpool/validator" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/types/api" - "github.com/rocket-pool/smartnode/shared/utils/validator" ) const ( diff --git a/rocketpool/api/minipool/exit.go b/rocketpool/api/minipool/exit.go index 2b3d67c72..69c9f5793 100644 --- a/rocketpool/api/minipool/exit.go +++ b/rocketpool/api/minipool/exit.go @@ -8,9 +8,9 @@ import ( "github.com/rocket-pool/smartnode/bindings/minipool" "github.com/rocket-pool/smartnode/bindings/types" + "github.com/rocket-pool/smartnode/rocketpool/validator" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/types/api" - "github.com/rocket-pool/smartnode/shared/utils/validator" ) func canExitMinipool(c *cli.Command, minipoolAddress common.Address) (*api.CanExitMinipoolResponse, error) { diff --git a/rocketpool/api/minipool/import-key.go b/rocketpool/api/minipool/import-key.go index 02d1f76af..cfaee36b2 100644 --- a/rocketpool/api/minipool/import-key.go +++ b/rocketpool/api/minipool/import-key.go @@ -11,9 +11,9 @@ import ( "github.com/rocket-pool/smartnode/bindings/minipool" "github.com/rocket-pool/smartnode/bindings/types" + "github.com/rocket-pool/smartnode/rocketpool/validator" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/types/api" - "github.com/rocket-pool/smartnode/shared/utils/validator" ) func importKey(c *cli.Command, minipoolAddress common.Address, mnemonic string) (*api.ImportKeyResponse, error) { diff --git a/rocketpool/api/minipool/rescue-dissolved.go b/rocketpool/api/minipool/rescue-dissolved.go index c74fd99b5..7a270a938 100644 --- a/rocketpool/api/minipool/rescue-dissolved.go +++ b/rocketpool/api/minipool/rescue-dissolved.go @@ -15,13 +15,13 @@ import ( "github.com/rocket-pool/smartnode/bindings/transactions/gaslimit" rptypes "github.com/rocket-pool/smartnode/bindings/types" + "github.com/rocket-pool/smartnode/rocketpool/validator" "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/services/contracts" "github.com/rocket-pool/smartnode/shared/services/wallet" "github.com/rocket-pool/smartnode/shared/types/api" - "github.com/rocket-pool/smartnode/shared/utils/validator" ) func getMinipoolRescueDissolvedDetailsForNode(c *cli.Command) (*api.GetMinipoolRescueDissolvedDetailsForNodeResponse, error) { diff --git a/rocketpool/api/minipool/stake.go b/rocketpool/api/minipool/stake.go index 74907c9dc..834f01551 100644 --- a/rocketpool/api/minipool/stake.go +++ b/rocketpool/api/minipool/stake.go @@ -13,9 +13,9 @@ import ( "github.com/rocket-pool/smartnode/bindings/settings/trustednode" rptypes "github.com/rocket-pool/smartnode/bindings/types" + "github.com/rocket-pool/smartnode/rocketpool/validator" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/types/api" - "github.com/rocket-pool/smartnode/shared/utils/validator" ) func canStakeMinipool(c *cli.Command, minipoolAddress common.Address) (*api.CanStakeMinipoolResponse, error) { diff --git a/rocketpool/api/node/deposit.go b/rocketpool/api/node/deposit.go index 9dab21f7d..31eef5389 100644 --- a/rocketpool/api/node/deposit.go +++ b/rocketpool/api/node/deposit.go @@ -24,10 +24,10 @@ import ( eth2types "github.com/wealdtech/go-eth2-types/v2" "github.com/rocket-pool/smartnode/bindings/megapool" + "github.com/rocket-pool/smartnode/rocketpool/validator" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/beacon" "github.com/rocket-pool/smartnode/shared/types/api" - "github.com/rocket-pool/smartnode/shared/utils/validator" ) const ( diff --git a/rocketpool/api/node/smoothing-pool.go b/rocketpool/api/node/smoothing-pool.go index dcb3bd381..2e9d6c983 100644 --- a/rocketpool/api/node/smoothing-pool.go +++ b/rocketpool/api/node/smoothing-pool.go @@ -11,10 +11,10 @@ import ( "github.com/rocket-pool/smartnode/bindings/node" "github.com/rocket-pool/smartnode/bindings/rewards" rocketpoolapi "github.com/rocket-pool/smartnode/bindings/rocketpool" + "github.com/rocket-pool/smartnode/rocketpool/validator" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/types/api" - "github.com/rocket-pool/smartnode/shared/utils/validator" ) func getSmoothingPoolRegistrationStatus(c *cli.Command) (*api.GetSmoothingPoolRegistrationStatusResponse, error) { diff --git a/rocketpool/api/service/restart-vc.go b/rocketpool/api/service/restart-vc.go index 26d595cac..d9bffd188 100644 --- a/rocketpool/api/service/restart-vc.go +++ b/rocketpool/api/service/restart-vc.go @@ -5,9 +5,9 @@ import ( "github.com/urfave/cli/v3" + "github.com/rocket-pool/smartnode/rocketpool/validator" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/types/api" - "github.com/rocket-pool/smartnode/shared/utils/validator" ) // Restarts the Validator client diff --git a/rocketpool/node/manage-fee-recipient.go b/rocketpool/node/manage-fee-recipient.go index dfad4663f..5aa0c2553 100644 --- a/rocketpool/node/manage-fee-recipient.go +++ b/rocketpool/node/manage-fee-recipient.go @@ -10,6 +10,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/rocketpool" "github.com/rocket-pool/smartnode/rocketpool/feerecipient" + "github.com/rocket-pool/smartnode/rocketpool/validator" log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/services" "github.com/rocket-pool/smartnode/shared/services/alerting" @@ -18,7 +19,6 @@ import ( rpsvc "github.com/rocket-pool/smartnode/shared/services/rocketpool" "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" - "github.com/rocket-pool/smartnode/shared/utils/validator" ) // Manage fee recipient task diff --git a/rocketpool/node/stake-megapool-validator.go b/rocketpool/node/stake-megapool-validator.go index 49c0b732c..1124fc47b 100644 --- a/rocketpool/node/stake-megapool-validator.go +++ b/rocketpool/node/stake-megapool-validator.go @@ -13,6 +13,7 @@ import ( "github.com/rocket-pool/smartnode/bindings/transactions" "github.com/rocket-pool/smartnode/bindings/types" + "github.com/rocket-pool/smartnode/rocketpool/validator" log "github.com/rocket-pool/smartnode/shared/logger" "github.com/rocket-pool/smartnode/shared/math" "github.com/rocket-pool/smartnode/shared/services" @@ -22,7 +23,6 @@ import ( "github.com/rocket-pool/smartnode/shared/services/state" "github.com/rocket-pool/smartnode/shared/services/wallet" "github.com/rocket-pool/smartnode/shared/types/eth2" - "github.com/rocket-pool/smartnode/shared/utils/validator" ) // Stake megapool validator task diff --git a/shared/utils/validator/bls.go b/rocketpool/validator/bls.go similarity index 100% rename from shared/utils/validator/bls.go rename to rocketpool/validator/bls.go diff --git a/shared/utils/validator/deposit-data.go b/rocketpool/validator/deposit-data.go similarity index 100% rename from shared/utils/validator/deposit-data.go rename to rocketpool/validator/deposit-data.go diff --git a/shared/utils/validator/fee-recipient.go b/rocketpool/validator/fee-recipient.go similarity index 100% rename from shared/utils/validator/fee-recipient.go rename to rocketpool/validator/fee-recipient.go diff --git a/shared/utils/validator/set-withdrawal-creds.go b/rocketpool/validator/set-withdrawal-creds.go similarity index 100% rename from shared/utils/validator/set-withdrawal-creds.go rename to rocketpool/validator/set-withdrawal-creds.go diff --git a/shared/utils/validator/voluntary-exit.go b/rocketpool/validator/voluntary-exit.go similarity index 100% rename from shared/utils/validator/voluntary-exit.go rename to rocketpool/validator/voluntary-exit.go diff --git a/shared/services/wallet/validator.go b/shared/services/wallet/validator.go index 8146d529e..c69f1c4b6 100644 --- a/shared/services/wallet/validator.go +++ b/shared/services/wallet/validator.go @@ -11,7 +11,7 @@ import ( eth2util "github.com/wealdtech/go-eth2-util" "github.com/rocket-pool/smartnode/bindings/types" - "github.com/rocket-pool/smartnode/shared/utils/validator" + "github.com/rocket-pool/smartnode/rocketpool/validator" ) // Config