diff --git a/rocketpool-cli/auction/status.go b/rocketpool-cli/auction/status.go index 2f4f663b9..dbe506e24 100644 --- a/rocketpool-cli/auction/status.go +++ b/rocketpool-cli/auction/status.go @@ -35,9 +35,9 @@ func getStatus(c *cli.Context) 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(eth.WeiToEth(&status.TotalRPLBalance), 6), + math.RoundDown(eth.WeiToEth(&status.AllottedRPLBalance), 6), + math.RoundDown(eth.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/faucet/status.go b/rocketpool-cli/faucet/status.go index 71a70fbca..11658313f 100644 --- a/rocketpool-cli/faucet/status.go +++ b/rocketpool-cli/faucet/status.go @@ -34,9 +34,9 @@ func getStatus(c *cli.Context) error { } // Print status & return - fmt.Printf("The faucet has a balance of %.6f legacy RPL.\n", math.RoundDown(eth.WeiToEth(status.Balance), 6)) + fmt.Printf("The faucet has a balance of %.6f legacy RPL.\n", math.RoundDown(eth.WeiToEth(&status.Balance), 6)) if status.WithdrawableAmount.Cmp(big.NewInt(0)) > 0 { - fmt.Printf("You can withdraw %.6f legacy RPL (requires a %.6f GoETH fee)!\n", math.RoundDown(eth.WeiToEth(status.WithdrawableAmount), 6), math.RoundDown(eth.WeiToEth(status.WithdrawalFee), 6)) + fmt.Printf("You can withdraw %.6f legacy RPL (requires a %.6f GoETH fee)!\n", math.RoundDown(eth.WeiToEth(&status.WithdrawableAmount), 6), math.RoundDown(eth.WeiToEth(&status.WithdrawalFee), 6)) } else { fmt.Println("You cannot withdraw legacy RPL right now.") } diff --git a/rocketpool-cli/faucet/withdraw-rpl.go b/rocketpool-cli/faucet/withdraw-rpl.go index 202ae20c4..a411ae688 100644 --- a/rocketpool-cli/faucet/withdraw-rpl.go +++ b/rocketpool-cli/faucet/withdraw-rpl.go @@ -71,7 +71,7 @@ func withdrawRpl(c *cli.Context) error { } // Log & return - fmt.Printf("Successfully withdrew %.6f legacy RPL from the faucet.\n", math.RoundDown(eth.WeiToEth(response.Amount), 6)) + fmt.Printf("Successfully withdrew %.6f legacy RPL from the faucet.\n", math.RoundDown(eth.WeiToEth(&response.Amount), 6)) return nil } diff --git a/rocketpool-cli/minipool/close.go b/rocketpool-cli/minipool/close.go index 391943edf..43188072e 100644 --- a/rocketpool-cli/minipool/close.go +++ b/rocketpool-cli/minipool/close.go @@ -66,7 +66,7 @@ func closeMinipools(c *cli.Context) error { if mp.MinipoolVersion < 3 { versionTooLowMinipools = append(versionTooLowMinipools, mp) } - if mp.Balance.Cmp(mp.Refund) == -1 { + if mp.Balance.Cmp(&mp.Refund) == -1 { balanceLessThanRefundMinipools = append(balanceLessThanRefundMinipools, mp) } if mp.MinipoolStatus != types.Dissolved && @@ -114,9 +114,9 @@ func closeMinipools(c *cli.Context) 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(eth.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(eth.WeiToEth(&minipool.Balance), 6), math.RoundDown(eth.WeiToEth(&minipool.NodeShare), 6), math.RoundDown(eth.WeiToEth(&minipool.Refund), 6)) } } selected, _ := cliutils.Select("Please select a minipool to close:", options) @@ -153,11 +153,11 @@ func closeMinipools(c *cli.Context) error { yellowThreshold := eth.EthToWei(31.5) thirtyTwo := eth.EthToWei(32) for _, minipool := range selectedMinipools { - distributableBalance := big.NewInt(0).Sub(minipool.Balance, minipool.Refund) + distributableBalance := big.NewInt(0).Sub(&minipool.Balance, &minipool.Refund) if distributableBalance.Cmp(eight) >= 0 { - if distributableBalance.Cmp(minipool.UserDepositBalance) < 0 { + if distributableBalance.Cmp(&minipool.UserDepositBalance) < 0 { // Less than the user deposit balance, ETH + RPL will be slashed - fmt.Printf("%sWARNING: Minipool %s has a distributable balance of %.6f ETH which is lower than the amount borrowed from the staking pool (%.6f ETH).\nPlease visit the Rocket Pool Discord's #support channel (https://discord.gg/rocketpool) if you are not expecting this.%s\n", colorRed, minipool.Address.Hex(), math.RoundDown(eth.WeiToEth(distributableBalance), 6), math.RoundDown(eth.WeiToEth(minipool.UserDepositBalance), 6), colorReset) + fmt.Printf("%sWARNING: Minipool %s has a distributable balance of %.6f ETH which is lower than the amount borrowed from the staking pool (%.6f ETH).\nPlease visit the Rocket Pool Discord's #support channel (https://discord.gg/rocketpool) if you are not expecting this.%s\n", colorRed, minipool.Address.Hex(), math.RoundDown(eth.WeiToEth(distributableBalance), 6), math.RoundDown(eth.WeiToEth(&minipool.UserDepositBalance), 6), colorReset) if !c.Bool("confirm-slashing") { fmt.Printf("\n%sIf you are *sure* you want to close the minipool anyway, rerun this command with the `--confirm-slashing` flag. Doing so WILL RESULT in both your ETH bond and your RPL collateral being slashed.%s\n", colorRed, colorReset) return nil @@ -169,13 +169,13 @@ func closeMinipools(c *cli.Context) error { } } else 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 !cliutils.ConfirmWithIAgree(fmt.Sprintf("%sWARNING: 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.%s", colorRed, minipool.Address.Hex(), math.RoundDown(eth.WeiToEth(distributableBalance), 6), math.RoundDown(eth.WeiToEth(minipool.NodeShare), 6), colorReset)) { + if !cliutils.ConfirmWithIAgree(fmt.Sprintf("%sWARNING: 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.%s", colorRed, minipool.Address.Hex(), math.RoundDown(eth.WeiToEth(distributableBalance), 6), math.RoundDown(eth.WeiToEth(&minipool.NodeShare), 6), colorReset)) { fmt.Println("Cancelled.") return nil } } else if distributableBalance.Cmp(thirtyTwo) < 0 { // More than 31.5 but less than 32, ETH will be slashed with a yellow warning - if !cliutils.Confirm(fmt.Sprintf("%sWARNING: 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.%s", colorYellow, minipool.Address.Hex(), math.RoundDown(eth.WeiToEth(distributableBalance), 6), math.RoundDown(eth.WeiToEth(minipool.NodeShare), 6), colorReset)) { + if !cliutils.Confirm(fmt.Sprintf("%sWARNING: 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.%s", colorYellow, minipool.Address.Hex(), math.RoundDown(eth.WeiToEth(distributableBalance), 6), math.RoundDown(eth.WeiToEth(&minipool.NodeShare), 6), colorReset)) { fmt.Println("Cancelled.") return nil } diff --git a/rocketpool-cli/minipool/distribute.go b/rocketpool-cli/minipool/distribute.go index 5e2ef8566..03d2df47f 100644 --- a/rocketpool-cli/minipool/distribute.go +++ b/rocketpool-cli/minipool/distribute.go @@ -57,10 +57,10 @@ func distributeBalance(c *cli.Context) error { if mp.MinipoolVersion < 3 { versionTooLowMinipools = append(versionTooLowMinipools, mp) } - if mp.Balance.Cmp(mp.Refund) == -1 { + if mp.Balance.Cmp(&mp.Refund) == -1 { balanceLessThanRefundMinipools = append(balanceLessThanRefundMinipools, mp) } - effectiveBalance := big.NewInt(0).Sub(mp.Balance, mp.Refund) + effectiveBalance := big.NewInt(0).Sub(&mp.Balance, &mp.Refund) if effectiveBalance.Cmp(finalizationAmount) >= 0 { balanceTooBigMinipools = append(balanceTooBigMinipools, mp) } @@ -106,11 +106,11 @@ func distributeBalance(c *cli.Context) error { for _, minipool := range eligibleMinipools { if minipool.Status == types.Dissolved { // Dissolved minipools are a special case - totalEthShare.Add(totalEthShare, minipool.Balance) + totalEthShare.Add(totalEthShare, &minipool.Balance) } else { - totalEthAvailable.Add(totalEthAvailable, minipool.Balance) - totalEthShare.Add(totalEthShare, minipool.NodeShareOfBalance) - totalRefund.Add(totalRefund, minipool.Refund) + totalEthAvailable.Add(totalEthAvailable, &minipool.Balance) + totalEthShare.Add(totalEthShare, &minipool.NodeShareOfBalance) + totalRefund.Add(totalRefund, &minipool.Refund) } } @@ -120,9 +120,9 @@ func distributeBalance(c *cli.Context) error { 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(eth.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(eth.WeiToEth(&minipool.Balance), 6), math.RoundDown(eth.WeiToEth(&minipool.NodeShareOfBalance), 6), math.RoundDown(eth.WeiToEth(&minipool.Refund), 6)) } } selected, _ := cliutils.Select("Please select a minipool to distribute the balance of:", options) diff --git a/rocketpool-cli/minipool/reduce-bond.go b/rocketpool-cli/minipool/reduce-bond.go index 7d4823864..82407c1a6 100644 --- a/rocketpool-cli/minipool/reduce-bond.go +++ b/rocketpool-cli/minipool/reduce-bond.go @@ -167,7 +167,7 @@ func beginReduceBondAmount(c *cli.Context) error { gasInfo = canResponse.GasInfo totalGas += canResponse.GasInfo.EstGasLimit totalSafeGas += canResponse.GasInfo.SafeGasLimit - totalMatchRequest.Add(totalMatchRequest, canResponse.MatchRequest) + totalMatchRequest.Add(totalMatchRequest, &canResponse.MatchRequest) } } gasInfo.EstGasLimit = totalGas @@ -178,8 +178,8 @@ func beginReduceBondAmount(c *cli.Context) error { if err != nil { return fmt.Errorf("error checking the node's total collateral: %w", err) } - totalMatchAvailable := big.NewInt(0).Sub(collateralResponse.EthMatchedLimit, collateralResponse.EthMatched) - totalMatchAvailable.Sub(totalMatchAvailable, collateralResponse.PendingMatchAmount) + totalMatchAvailable := big.NewInt(0).Sub(&collateralResponse.EthMatchedLimit, &collateralResponse.EthMatched) + totalMatchAvailable.Sub(totalMatchAvailable, &collateralResponse.PendingMatchAmount) if totalMatchAvailable.Cmp(totalMatchRequest) < 0 { fmt.Printf("You do not have enough RPL staked to support all of the selected bond reductions.\nYou can borrow %.6f more ETH, but are requesting %.6f ETH with these bond reductions.\nIn total, they would bring you below the minimum RPL staking requirement (including the RPL required for any pending bond reductions you've already started).\nYou will have to stake more RPL first.\n", eth.WeiToEth(totalMatchAvailable), eth.WeiToEth(totalMatchRequest)) return nil @@ -370,7 +370,7 @@ func forceFeeDistribution(c *cli.Context, rp *rocketpool.Client) error { return err } - balance := eth.WeiToEth(canDistributeResponse.Balance) + balance := eth.WeiToEth(&canDistributeResponse.Balance) if balance == 0 { fmt.Println("Your fee distributor does not have any ETH and does not need to be distributed.\n") return nil diff --git a/rocketpool-cli/minipool/rescue-dissolved.go b/rocketpool-cli/minipool/rescue-dissolved.go index 48bc23e0c..64679f911 100644 --- a/rocketpool-cli/minipool/rescue-dissolved.go +++ b/rocketpool-cli/minipool/rescue-dissolved.go @@ -131,7 +131,7 @@ func rescueDissolved(c *cli.Context) error { for mi, minipool := range rescuableMinipools { localRescueAmount := big.NewInt(0) - localRescueAmount.Sub(fullDepositAmount, minipool.BeaconBalance) + localRescueAmount.Sub(fullDepositAmount, &minipool.BeaconBalance) rescueAmounts[mi] = localRescueAmount rescueAmountFloats[mi] = math.RoundDown(eth.WeiToEth(localRescueAmount), 6) options[mi] = fmt.Sprintf("%s (requires %.6f more ETH)", minipool.Address.Hex(), rescueAmountFloats[mi]) @@ -151,7 +151,7 @@ func rescueDissolved(c *cli.Context) error { if bytes.Equal(minipool.Address.Bytes(), selectedAddress.Bytes()) { selectedMinipool = &rescuableMinipools[i] rescueAmount = big.NewInt(0) - rescueAmount.Sub(fullDepositAmount, selectedMinipool.BeaconBalance) + rescueAmount.Sub(fullDepositAmount, &selectedMinipool.BeaconBalance) rescueAmountFloat = math.RoundDown(eth.WeiToEth(rescueAmount), 6) break } diff --git a/rocketpool-cli/minipool/status.go b/rocketpool-cli/minipool/status.go index 915759af8..384699bde 100644 --- a/rocketpool-cli/minipool/status.go +++ b/rocketpool-cli/minipool/status.go @@ -170,7 +170,7 @@ func printMinipoolDetails(minipool api.MinipoolDetails, latestDelegate common.Ad // RP ETH deposit details - prelaunch & staking minipools if minipool.Status.Status == types.Prelaunch || minipool.Status.Status == types.Staking { - totalRewards := big.NewInt(0).Add(minipool.NodeShareOfETHBalance, minipool.Node.RefundBalance) + 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(TimeFormat)) fmt.Printf("RP deposit: %.6f ETH\n", math.RoundDown(eth.WeiToEth(minipool.User.DepositBalance), 6)) @@ -178,7 +178,7 @@ func printMinipoolDetails(minipool api.MinipoolDetails, latestDelegate common.Ad 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("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)) } @@ -194,8 +194,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(eth.WeiToEth(&minipool.Validator.Balance), 6)) + fmt.Printf("Your portion: %.6f ETH\n", math.RoundDown(eth.WeiToEth(&minipool.Validator.NodeBalance), 6)) } else { fmt.Printf("Validator seen: no\n") } diff --git a/rocketpool-cli/network/rpl-price.go b/rocketpool-cli/network/rpl-price.go index 11d4d5bcb..70e2101a9 100644 --- a/rocketpool-cli/network/rpl-price.go +++ b/rocketpool-cli/network/rpl-price.go @@ -33,7 +33,7 @@ func getRplPrice(c *cli.Context) 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(eth.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 3f1ef638a..827e20197 100644 --- a/rocketpool-cli/node/claim-rewards.go +++ b/rocketpool-cli/node/claim-rewards.go @@ -272,8 +272,8 @@ func getRestakeAmount(c *cli.Context, rewardsInfoResponse api.NodeGetRewardsInfo currentBondedCollateral := float64(0) currentBorrowedCollateral := float64(0) rplToMaxCollateral := float64(0) - rplPrice := eth.WeiToEth(rewardsInfoResponse.RplPrice) - currentRplStake := eth.WeiToEth(rewardsInfoResponse.RplStake) + rplPrice := eth.WeiToEth(&rewardsInfoResponse.RplPrice) + currentRplStake := eth.WeiToEth(&rewardsInfoResponse.RplStake) availableRpl := eth.WeiToEth(claimRpl) // Print info about autostaking RPL @@ -283,12 +283,12 @@ func getRestakeAmount(c *cli.Context, rewardsInfoResponse api.NodeGetRewardsInfo if rewardsInfoResponse.ActiveMinipools > 0 { currentBondedCollateral = rewardsInfoResponse.BondedCollateralRatio currentBorrowedCollateral = rewardsInfoResponse.BorrowedCollateralRatio - maxRplRequired := eth.WeiToEth(rewardsInfoResponse.MaximumRplStake) + maxRplRequired := eth.WeiToEth(&rewardsInfoResponse.MaximumRplStake) rplToMaxCollateral = maxRplRequired - currentRplStake bestTotal = availableRpl + currentRplStake - bestBondedCollateral = rplPrice * bestTotal / (float64(rewardsInfoResponse.ActiveMinipools)*32.0 - eth.WeiToEth(rewardsInfoResponse.EthMatched) - eth.WeiToEth(rewardsInfoResponse.PendingMatchAmount)) - bestBorrowedCollateral = rplPrice * bestTotal / (eth.WeiToEth(rewardsInfoResponse.EthMatched) + eth.WeiToEth(rewardsInfoResponse.PendingMatchAmount)) + bestBondedCollateral = rplPrice * bestTotal / (float64(rewardsInfoResponse.ActiveMinipools)*32.0 - eth.WeiToEth(&rewardsInfoResponse.EthMatched) - eth.WeiToEth(&rewardsInfoResponse.PendingMatchAmount)) + bestBorrowedCollateral = rplPrice * bestTotal / (eth.WeiToEth(&rewardsInfoResponse.EthMatched) + eth.WeiToEth(&rewardsInfoResponse.PendingMatchAmount)) fmt.Printf("You currently have %.6f RPL staked (%.2f%% borrowed collateral, %.2f%% bonded collateral).\n", currentRplStake, currentBorrowedCollateral*100, currentBondedCollateral*100) if rplToMaxCollateral <= 0 { @@ -323,8 +323,8 @@ func getRestakeAmount(c *cli.Context, rewardsInfoResponse api.NodeGetRewardsInfo } else if restakeAmountFlag == "all" { // Restake everything with no regard for collateral level total := availableRpl + currentRplStake - totalBondedCollateral := rplPrice * total / (float64(rewardsInfoResponse.ActiveMinipools)*32.0 - eth.WeiToEth(rewardsInfoResponse.EthMatched) - eth.WeiToEth(rewardsInfoResponse.PendingMatchAmount)) - totalBorrowedCollateral := rplPrice * total / (eth.WeiToEth(rewardsInfoResponse.EthMatched) + eth.WeiToEth(rewardsInfoResponse.PendingMatchAmount)) + totalBondedCollateral := rplPrice * total / (float64(rewardsInfoResponse.ActiveMinipools)*32.0 - eth.WeiToEth(&rewardsInfoResponse.EthMatched) - eth.WeiToEth(&rewardsInfoResponse.PendingMatchAmount)) + totalBorrowedCollateral := rplPrice * total / (eth.WeiToEth(&rewardsInfoResponse.EthMatched) + eth.WeiToEth(&rewardsInfoResponse.PendingMatchAmount)) fmt.Printf("Automatically restaking all of the claimable RPL, which will bring you to a total of %.6f RPL staked (%.2f%% borrowed collateral, %.2f%% bonded collateral).\n", total, totalBorrowedCollateral*100, totalBondedCollateral*100) restakeAmountWei = claimRpl } else if restakeAmountFlag != "" { @@ -338,8 +338,8 @@ func getRestakeAmount(c *cli.Context, rewardsInfoResponse api.NodeGetRewardsInfo restakeAmountWei = claimRpl } else { total := stakeAmount + currentRplStake - totalBondedCollateral := rplPrice * total / (float64(rewardsInfoResponse.ActiveMinipools)*32.0 - eth.WeiToEth(rewardsInfoResponse.EthMatched) - eth.WeiToEth(rewardsInfoResponse.PendingMatchAmount)) - totalBorrowedCollateral := rplPrice * total / (eth.WeiToEth(rewardsInfoResponse.EthMatched) + eth.WeiToEth(rewardsInfoResponse.PendingMatchAmount)) + totalBondedCollateral := rplPrice * total / (float64(rewardsInfoResponse.ActiveMinipools)*32.0 - eth.WeiToEth(&rewardsInfoResponse.EthMatched) - eth.WeiToEth(&rewardsInfoResponse.PendingMatchAmount)) + totalBorrowedCollateral := rplPrice * total / (eth.WeiToEth(&rewardsInfoResponse.EthMatched) + eth.WeiToEth(&rewardsInfoResponse.PendingMatchAmount)) 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) } @@ -383,8 +383,8 @@ func getRestakeAmount(c *cli.Context, rewardsInfoResponse api.NodeGetRewardsInfo } else { bestTotal = availableRpl + currentRplStake var collateralString string - bestBondedCollateral = rplPrice * bestTotal / (float64(rewardsInfoResponse.ActiveMinipools)*32.0 - eth.WeiToEth(rewardsInfoResponse.EthMatched) - eth.WeiToEth(rewardsInfoResponse.PendingMatchAmount)) - bestBorrowedCollateral = rplPrice * bestTotal / (eth.WeiToEth(rewardsInfoResponse.EthMatched) + eth.WeiToEth(rewardsInfoResponse.PendingMatchAmount)) + bestBondedCollateral = rplPrice * bestTotal / (float64(rewardsInfoResponse.ActiveMinipools)*32.0 - eth.WeiToEth(&rewardsInfoResponse.EthMatched) - eth.WeiToEth(&rewardsInfoResponse.PendingMatchAmount)) + bestBorrowedCollateral = rplPrice * bestTotal / (eth.WeiToEth(&rewardsInfoResponse.EthMatched) + eth.WeiToEth(&rewardsInfoResponse.PendingMatchAmount)) collateralString = fmt.Sprintf("All %.6f RPL, which will bring you to %.2f%% borrowed collateral (%.2f%% bonded collateral)", availableRpl, bestBorrowedCollateral*100, bestBondedCollateral*100) amountOptions := []string{ "None (do not restake any RPL)", diff --git a/rocketpool-cli/node/deposit.go b/rocketpool-cli/node/deposit.go index 92ff7d342..50b1934aa 100644 --- a/rocketpool-cli/node/deposit.go +++ b/rocketpool-cli/node/deposit.go @@ -162,12 +162,12 @@ func nodeDeposit(c *cli.Context) error { if !canDeposit.CanDeposit { fmt.Println("Cannot make node deposit:") if canDeposit.InsufficientBalanceWithoutCredit { - nodeBalance := eth.WeiToEth(canDeposit.NodeBalance) - fmt.Printf("There is not enough ETH in the staking pool to use your credit balance (it needs at least 1 ETH but only has %.2f ETH) and you don't have enough ETH in your wallet (%.6f ETH) to cover the deposit amount yourself. If you want to continue creating a minipool, 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 := eth.WeiToEth(&canDeposit.NodeBalance) + fmt.Printf("There is not enough ETH in the staking pool to use your credit balance (it needs at least 1 ETH but only has %.2f ETH) and you don't have enough ETH in your wallet (%.6f ETH) to cover the deposit amount yourself. If you want to continue creating a minipool, 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) } if canDeposit.InsufficientBalance { - nodeBalance := eth.WeiToEth(canDeposit.NodeBalance) - creditBalance := eth.WeiToEth(canDeposit.CreditBalance) + nodeBalance := eth.WeiToEth(&canDeposit.NodeBalance) + creditBalance := eth.WeiToEth(&canDeposit.CreditBalance) fmt.Printf("The node's balance of %.6f ETH and credit balance of %.6f ETH are not enough to create a minipool with a %.1f ETH bond.", nodeBalance, creditBalance, amount) } if canDeposit.InsufficientRplStake { @@ -186,19 +186,19 @@ func nodeDeposit(c *cli.Context) error { } useCreditBalance := false - fmt.Printf("You currently have %.2f ETH in your credit balance.\n", eth.WeiToEth(canDeposit.CreditBalance)) + fmt.Printf("You currently have %.2f ETH in your credit balance.\n", eth.WeiToEth(&canDeposit.CreditBalance)) if canDeposit.CreditBalance.Cmp(big.NewInt(0)) > 0 { if canDeposit.CanUseCredit { useCreditBalance = true // Get how much credit to use - remainingAmount := big.NewInt(0).Sub(amountWei, canDeposit.CreditBalance) + remainingAmount := big.NewInt(0).Sub(amountWei, &canDeposit.CreditBalance) if remainingAmount.Cmp(big.NewInt(0)) > 0 { - fmt.Printf("This deposit will use all %.6f ETH from your credit balance and %.6f ETH from your node.\n\n", eth.WeiToEth(canDeposit.CreditBalance), eth.WeiToEth(remainingAmount)) + fmt.Printf("This deposit will use all %.6f ETH from your credit balance and %.6f ETH from your node.\n\n", eth.WeiToEth(&canDeposit.CreditBalance), eth.WeiToEth(remainingAmount)) } else { fmt.Printf("This deposit will use %.6f ETH from your credit balance and will not require any ETH from your node.\n\n", amount) } } else { - fmt.Printf("%sNOTE: Your credit balance *cannot* currently be used to create a new minipool; there is not enough ETH in the staking pool to cover the initial deposit on your behalf (it needs at least 1 ETH but only has %.2f ETH).%s\nIf you want to continue creating this minipool now, you will have to pay for the full bond amount.\n\n", colorYellow, eth.WeiToEth(canDeposit.DepositBalance), colorReset) + fmt.Printf("%sNOTE: Your credit balance *cannot* currently be used to create a new minipool; there is not enough ETH in the staking pool to cover the initial deposit on your behalf (it needs at least 1 ETH but only has %.2f ETH).%s\nIf you want to continue creating this minipool now, you will have to pay for the full bond amount.\n\n", colorYellow, eth.WeiToEth(&canDeposit.DepositBalance), colorReset) // Prompt for confirmation if !(c.Bool("yes") || cliutils.Confirm("Would you like to continue?")) { diff --git a/rocketpool-cli/node/distributor.go b/rocketpool-cli/node/distributor.go index c07f1c247..91ed6fef5 100644 --- a/rocketpool-cli/node/distributor.go +++ b/rocketpool-cli/node/distributor.go @@ -95,7 +95,7 @@ func distribute(c *cli.Context) error { return err } - balance := eth.WeiToEth(canDistributeResponse.Balance) + balance := eth.WeiToEth(&canDistributeResponse.Balance) if balance == 0 { fmt.Printf("Your fee distributor does not have any ETH.") return nil diff --git a/rocketpool-cli/node/stake-rpl.go b/rocketpool-cli/node/stake-rpl.go index c3c0a103b..e9a7d074f 100644 --- a/rocketpool-cli/node/stake-rpl.go +++ b/rocketpool-cli/node/stake-rpl.go @@ -41,7 +41,7 @@ func nodeStakeRpl(c *cli.Context) error { } // Check for fixed-supply RPL balance - rplBalance := *(status.AccountBalances.RPL) + rplBalance := big.NewInt(0).Set(status.AccountBalances.RPL) if status.AccountBalances.FixedSupplyRPL.Cmp(big.NewInt(0)) > 0 { // Confirm swapping RPL @@ -165,7 +165,7 @@ func nodeStakeRpl(c *cli.Context) error { if err != nil { return err } - amountWei = rplPrice.MinPer8EthMinipoolRplStake + amountWei = big.NewInt(0).Set((&rplPrice.MinPer8EthMinipoolRplStake)) } else if c.String("amount") == "max8" { @@ -174,7 +174,7 @@ func nodeStakeRpl(c *cli.Context) error { if err != nil { return err } - amountWei = rplPrice.MaxPer8EthMinipoolRplStake + amountWei = big.NewInt(0).Set(&rplPrice.MaxPer8EthMinipoolRplStake) } else if c.String("amount") == "min16" { @@ -183,7 +183,7 @@ func nodeStakeRpl(c *cli.Context) error { if err != nil { return err } - amountWei = rplPrice.MinPer16EthMinipoolRplStake + amountWei = big.NewInt(0).Set(&rplPrice.MinPer16EthMinipoolRplStake) } else if c.String("amount") == "max16" { @@ -192,12 +192,12 @@ func nodeStakeRpl(c *cli.Context) error { if err != nil { return err } - amountWei = rplPrice.MaxPer16EthMinipoolRplStake + amountWei = big.NewInt(0).Set(&rplPrice.MaxPer16EthMinipoolRplStake) } else if c.String("amount") == "all" { // Set amount to node's entire RPL balance - amountWei = &rplBalance + amountWei = rplBalance } else if c.String("amount") != "" { @@ -215,10 +215,10 @@ func nodeStakeRpl(c *cli.Context) error { if err != nil { return err } - minAmount8 := rplPrice.MinPer8EthMinipoolRplStake - maxAmount8 := rplPrice.MaxPer8EthMinipoolRplStake - minAmount16 := rplPrice.MinPer16EthMinipoolRplStake - maxAmount16 := rplPrice.MaxPer16EthMinipoolRplStake + minAmount8 := &rplPrice.MinPer8EthMinipoolRplStake + maxAmount8 := &rplPrice.MaxPer8EthMinipoolRplStake + minAmount16 := &rplPrice.MinPer16EthMinipoolRplStake + maxAmount16 := &rplPrice.MaxPer16EthMinipoolRplStake // Prompt for amount option amountOptions := []string{ @@ -226,7 +226,7 @@ func nodeStakeRpl(c *cli.Context) error { fmt.Sprintf("The maximum minipool stake amount for an 8-ETH minipool (%.6f RPL)?", math.RoundUp(eth.WeiToEth(maxAmount8), 6)), fmt.Sprintf("The minimum minipool stake amount for a 16-ETH minipool (%.6f RPL)?", math.RoundUp(eth.WeiToEth(minAmount16), 6)), fmt.Sprintf("The maximum minipool stake amount for a 16-ETH minipool (%.6f RPL)?", math.RoundUp(eth.WeiToEth(maxAmount16), 6)), - fmt.Sprintf("Your entire RPL balance (%.6f RPL)?", math.RoundDown(eth.WeiToEth(&rplBalance), 6)), + fmt.Sprintf("Your entire RPL balance (%.6f RPL)?", math.RoundDown(eth.WeiToEth(rplBalance), 6)), "A custom amount", } selected, _ := cliutils.Select("Please choose an amount of RPL to stake:", amountOptions) @@ -240,7 +240,7 @@ func nodeStakeRpl(c *cli.Context) error { case 3: amountWei = maxAmount16 case 4: - amountWei = &rplBalance + amountWei = rplBalance } // Prompt for custom amount diff --git a/rocketpool-cli/node/status.go b/rocketpool-cli/node/status.go index deaf27512..dca6ca2d4 100644 --- a/rocketpool-cli/node/status.go +++ b/rocketpool-cli/node/status.go @@ -70,7 +70,7 @@ func getStatus(c *cli.Context) error { } fmt.Printf( "The node has %.6f ETH in its credit balance, which can be used to make new minipools.\n", - math.RoundDown(eth.WeiToEth(status.CreditBalance), 6), + math.RoundDown(eth.WeiToEth(&status.CreditBalance), 6), ) // Registered node details @@ -199,7 +199,7 @@ func getStatus(c *cli.Context) error { fmt.Printf("The node is not opted into the Smoothing Pool.\nTo learn more about the Smoothing Pool, please visit %s.\n", smoothingPoolLink) } - fmt.Printf("The node's fee distributor %s%s%s has a balance of %.6f ETH.\n", colorBlue, status.FeeRecipientInfo.FeeDistributorAddress.Hex(), colorReset, math.RoundDown(eth.WeiToEth(status.FeeDistributorBalance), 6)) + fmt.Printf("The node's fee distributor %s%s%s has a balance of %.6f ETH.\n", colorBlue, status.FeeRecipientInfo.FeeDistributorAddress.Hex(), colorReset, math.RoundDown(eth.WeiToEth(&status.FeeDistributorBalance), 6)) if cfg.IsNativeMode && !status.FeeRecipientInfo.IsInSmoothingPool && !status.FeeRecipientInfo.IsInOptOutCooldown { fmt.Printf("%sNOTE: You are in Native Mode; you MUST ensure that your Validator Client is using this address as its fee recipient!%s\n", colorYellow, colorReset) } @@ -214,10 +214,10 @@ func getStatus(c *cli.Context) error { fmt.Println("NOTE: The following figures take *any pending bond reductions* into account.\n") fmt.Printf( "The node has a total stake of %.6f RPL and an effective stake of %.6f RPL.\n", - math.RoundDown(eth.WeiToEth(status.RplStake), 6), - math.RoundDown(eth.WeiToEth(status.EffectiveRplStake), 6)) + math.RoundDown(eth.WeiToEth(&status.RplStake), 6), + math.RoundDown(eth.WeiToEth(&status.EffectiveRplStake), 6)) if status.BorrowedCollateralRatio > 0 { - rplTooLow := (status.RplStake.Cmp(status.MinimumRplStake) < 0) + rplTooLow := (status.RplStake.Cmp(&status.MinimumRplStake) < 0) if rplTooLow { fmt.Printf( "This is currently %s%.2f%% of its borrowed ETH%s and %.2f%% of its bonded ETH.\n", @@ -228,23 +228,23 @@ func getStatus(c *cli.Context) error { status.BorrowedCollateralRatio*100, status.BondedCollateralRatio*100) } fmt.Printf( - "It must keep at least %.6f RPL staked to claim RPL rewards (10%% of borrowed ETH).\n", math.RoundDown(eth.WeiToEth(status.MinimumRplStake), 6)) + "It must keep at least %.6f RPL staked to claim RPL rewards (10%% of borrowed ETH).\n", math.RoundDown(eth.WeiToEth(&status.MinimumRplStake), 6)) fmt.Printf( - "It can earn rewards on up to %.6f RPL (150%% of bonded ETH).\n", math.RoundDown(eth.WeiToEth(status.MaximumRplStake), 6)) + "It can earn rewards on up to %.6f RPL (150%% of bonded ETH).\n", math.RoundDown(eth.WeiToEth(&status.MaximumRplStake), 6)) if rplTooLow { - fmt.Printf("%sWARNING: you are currently undercollateralized. You must stake at least %.6f more RPL in order to claim RPL rewards.%s\n", colorRed, math.RoundUp(eth.WeiToEth(big.NewInt(0).Sub(status.MinimumRplStake, status.RplStake)), 6), colorReset) + fmt.Printf("%sWARNING: you are currently undercollateralized. You must stake at least %.6f more RPL in order to claim RPL rewards.%s\n", colorRed, math.RoundUp(eth.WeiToEth(big.NewInt(0).Sub(&status.MinimumRplStake, &status.RplStake)), 6), colorReset) } } fmt.Println() - if status.PendingEffectiveRplStake.Cmp(status.EffectiveRplStake) != 0 { - fmt.Printf("Of this stake, %.6f RPL is eligible for RPL staking rewards.\n", math.RoundDown(eth.WeiToEth(status.PendingEffectiveRplStake), 6)) + if status.PendingEffectiveRplStake.Cmp(&status.EffectiveRplStake) != 0 { + fmt.Printf("Of this stake, %.6f RPL is eligible for RPL staking rewards.\n", math.RoundDown(eth.WeiToEth(&status.PendingEffectiveRplStake), 6)) fmt.Println("Eligibility is determined by the number of minipools you have in the *active* state on the Beacon Chain:\n- Validators in the Beacon Chain queue that have not been activated yet are not eligible.\n- Validators that have been exited are not eligible.") fmt.Println() } - remainingAmount := big.NewInt(0).Sub(status.EthMatchedLimit, status.EthMatched) - remainingAmount.Sub(remainingAmount, status.PendingMatchAmount) + remainingAmount := big.NewInt(0).Sub(&status.EthMatchedLimit, &status.EthMatched) + remainingAmount.Sub(remainingAmount, &status.PendingMatchAmount) remainingAmountEth := int(eth.WeiToEth(remainingAmount)) remainingFor8EB := remainingAmountEth / 24 if remainingFor8EB < 0 { diff --git a/rocketpool-cli/node/withdraw-rpl.go b/rocketpool-cli/node/withdraw-rpl.go index ce830acc8..576cadcdc 100644 --- a/rocketpool-cli/node/withdraw-rpl.go +++ b/rocketpool-cli/node/withdraw-rpl.go @@ -41,8 +41,8 @@ func nodeWithdrawRpl(c *cli.Context) error { // Set amount to maximum withdrawable amount var maxAmount big.Int - if status.RplStake.Cmp(status.MinimumRplStake) > 0 { - maxAmount.Sub(status.RplStake, status.MinimumRplStake) + if status.RplStake.Cmp(&status.MinimumRplStake) > 0 { + maxAmount.Sub(&status.RplStake, &status.MinimumRplStake) } amountWei = &maxAmount @@ -65,7 +65,7 @@ func nodeWithdrawRpl(c *cli.Context) error { // Get maximum withdrawable amount var maxAmount big.Int - maxAmount.Sub(status.RplStake, status.MaximumRplStake) + maxAmount.Sub(&status.RplStake, &status.MaximumRplStake) if maxAmount.Sign() == 1 { // Prompt for maximum amount if cliutils.Confirm(fmt.Sprintf("Would you like to withdraw the maximum amount of staked RPL (%.6f RPL)?", math.RoundDown(eth.WeiToEth(&maxAmount), 6))) { @@ -83,8 +83,8 @@ func nodeWithdrawRpl(c *cli.Context) error { } } else { fmt.Printf("Cannot withdraw staked RPL - you have %.6f RPL staked, but are not allowed to withdraw below %.6f RPL (150%% collateral).\n", - math.RoundDown(eth.WeiToEth(status.RplStake), 6), - math.RoundDown(eth.WeiToEth(status.MaximumRplStake), 6)) + math.RoundDown(eth.WeiToEth(&status.RplStake), 6), + math.RoundDown(eth.WeiToEth(&status.MaximumRplStake), 6)) return nil } diff --git a/rocketpool-cli/odao/get-settings.go b/rocketpool-cli/odao/get-settings.go index 3c2716d7d..b92ce69cd 100644 --- a/rocketpool-cli/odao/get-settings.go +++ b/rocketpool-cli/odao/get-settings.go @@ -34,11 +34,11 @@ func getMemberSettings(c *cli.Context) 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", eth.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", eth.WeiToEth(&response.ChallengeCost)) return nil } diff --git a/rocketpool-cli/queue/status.go b/rocketpool-cli/queue/status.go index 2f2cd725b..95992f0f0 100644 --- a/rocketpool-cli/queue/status.go +++ b/rocketpool-cli/queue/status.go @@ -33,8 +33,8 @@ func getStatus(c *cli.Context) error { } // Print & return - fmt.Printf("The staking pool has a balance of %.6f ETH.\n", math.RoundDown(eth.WeiToEth(status.DepositPoolBalance), 6)) - fmt.Printf("There are %d available minipools with a total capacity of %.6f ETH.\n", status.MinipoolQueueLength, math.RoundDown(eth.WeiToEth(status.MinipoolQueueCapacity), 6)) + fmt.Printf("The staking pool has a balance of %.6f ETH.\n", math.RoundDown(eth.WeiToEth(&status.DepositPoolBalance), 6)) + fmt.Printf("There are %d available minipools with a total capacity of %.6f ETH.\n", status.MinipoolQueueLength, math.RoundDown(eth.WeiToEth(&status.MinipoolQueueCapacity), 6)) return nil } diff --git a/rocketpool/api/auction/status.go b/rocketpool/api/auction/status.go index 64142e85f..0554bba92 100644 --- a/rocketpool/api/auction/status.go +++ b/rocketpool/api/auction/status.go @@ -37,21 +37,21 @@ func getStatus(c *cli.Context) (*api.AuctionStatusResponse, error) { wg.Go(func() error { totalRplBalance, err := auction.GetTotalRPLBalance(rp, nil) if err == nil { - response.TotalRPLBalance = totalRplBalance + response.TotalRPLBalance.Set(totalRplBalance) } return err }) wg.Go(func() error { allottedRplBalance, err := auction.GetAllottedRPLBalance(rp, nil) if err == nil { - response.AllottedRPLBalance = allottedRplBalance + response.AllottedRPLBalance.Set(allottedRplBalance) } return err }) wg.Go(func() error { remainingRplBalance, err := auction.GetRemainingRPLBalance(rp, nil) if err == nil { - response.RemainingRPLBalance = remainingRplBalance + response.RemainingRPLBalance.Set(remainingRplBalance) } return err }) diff --git a/rocketpool/api/faucet/status.go b/rocketpool/api/faucet/status.go index e5740f091..0c8b4f3cd 100644 --- a/rocketpool/api/faucet/status.go +++ b/rocketpool/api/faucet/status.go @@ -49,23 +49,32 @@ func getStatus(c *cli.Context) (*api.FaucetStatusResponse, error) { // Get faucet balance wg.Go(func() error { - var err error - response.Balance, err = f.GetBalance(nil) - return err + balance, err := f.GetBalance(nil) + if err != nil { + return err + } + response.Balance.Set(balance) + return nil }) // Get allowance wg.Go(func() error { - var err error - response.Allowance, err = f.GetAllowanceFor(nil, nodeAccount.Address) - return err + allowance, err := f.GetAllowanceFor(nil, nodeAccount.Address) + if err != nil { + return err + } + response.Allowance.Set(allowance) + return nil }) // Get withdrawal fee wg.Go(func() error { - var err error - response.WithdrawalFee, err = f.WithdrawalFee(nil) - return err + withdrawalFee, err := f.WithdrawalFee(nil) + if err != nil { + return err + } + response.WithdrawalFee.Set(withdrawalFee) + return nil }) // Get current withdrawal period start block @@ -101,10 +110,10 @@ func getStatus(c *cli.Context) (*api.FaucetStatusResponse, error) { } // Get withdrawable amount - if response.Balance.Cmp(response.Allowance) > 0 { - response.WithdrawableAmount = response.Allowance + if response.Balance.Cmp(&response.Allowance) > 0 { + response.WithdrawableAmount.Set(&response.Allowance) } else { - response.WithdrawableAmount = response.Balance + response.WithdrawableAmount.Set(&response.Balance) } // Get reset block diff --git a/rocketpool/api/faucet/withdraw-rpl.go b/rocketpool/api/faucet/withdraw-rpl.go index 0b4d753eb..fcce8fe5a 100644 --- a/rocketpool/api/faucet/withdraw-rpl.go +++ b/rocketpool/api/faucet/withdraw-rpl.go @@ -193,7 +193,7 @@ func withdrawRpl(c *cli.Context) (*api.FaucetWithdrawRplResponse, error) { } else { amount = balance } - response.Amount = amount + response.Amount.Set(amount) // Get transactor opts, err := w.GetNodeAccountTransactor() diff --git a/rocketpool/api/minipool/close.go b/rocketpool/api/minipool/close.go index f33b7fb42..88cea728a 100644 --- a/rocketpool/api/minipool/close.go +++ b/rocketpool/api/minipool/close.go @@ -152,9 +152,6 @@ func getMinipoolCloseDetails(rp *rocketpool.RocketPool, minipoolAddress common.A var details api.MinipoolCloseDetails details.Address = mp.GetAddress() details.MinipoolVersion = mp.GetVersion() - details.Balance = big.NewInt(0) - details.Refund = big.NewInt(0) - details.NodeShare = big.NewInt(0) // Ignore minipools that are too old if details.MinipoolVersion < 3 { @@ -165,19 +162,19 @@ func getMinipoolCloseDetails(rp *rocketpool.RocketPool, minipoolAddress common.A // Get the balance / share info and status details var wg1 errgroup.Group wg1.Go(func() error { - var err error - details.Balance, err = rp.Client.BalanceAt(context.Background(), minipoolAddress, nil) + balance, err := rp.Client.BalanceAt(context.Background(), minipoolAddress, nil) if err != nil { return fmt.Errorf("error getting finalized status of minipool %s: %w", minipoolAddress.Hex(), err) } + details.Balance.Set(balance) return nil }) wg1.Go(func() error { - var err error - details.Refund, err = mp.GetNodeRefundBalance(nil) + refund, err := mp.GetNodeRefundBalance(nil) if err != nil { return fmt.Errorf("error getting refund balance of minipool %s: %w", mp.GetAddress().Hex(), err) } + details.Refund.Set(refund) return nil }) wg1.Go(func() error { @@ -197,11 +194,11 @@ func getMinipoolCloseDetails(rp *rocketpool.RocketPool, minipoolAddress common.A return nil }) wg1.Go(func() error { - var err error - details.UserDepositBalance, err = mp.GetUserDepositBalance(nil) + userDepositBalance, err := mp.GetUserDepositBalance(nil) if err != nil { return fmt.Errorf("error getting user deposit balance of minipool %s: %w", minipoolAddress.Hex(), err) } + details.UserDepositBalance.Set(userDepositBalance) return nil }) @@ -216,14 +213,14 @@ func getMinipoolCloseDetails(rp *rocketpool.RocketPool, minipoolAddress common.A } // Make sure it's in a closeable state - effectiveBalance := big.NewInt(0).Sub(details.Balance, details.Refund) + effectiveBalance := big.NewInt(0).Sub(&details.Balance, &details.Refund) switch details.MinipoolStatus { case types.Dissolved: details.CanClose = true case types.Staking, types.Withdrawable: // Ignore minipools with a balance lower than the refund - if details.Balance.Cmp(details.Refund) == -1 { + if details.Balance.Cmp(&details.Refund) == -1 { details.CanClose = false return details, nil } @@ -257,11 +254,11 @@ func getMinipoolCloseDetails(rp *rocketpool.RocketPool, minipoolAddress common.A // Create another wait group var wg2 errgroup.Group wg2.Go(func() error { - var err error - details.NodeShare, err = mp.CalculateNodeShare(effectiveBalance, nil) + nodeShare, err := mp.CalculateNodeShare(effectiveBalance, nil) if err != nil { return fmt.Errorf("error getting node share of minipool %s: %w", mp.GetAddress().Hex(), err) } + details.NodeShare.Set(nodeShare) return nil }) wg2.Go(func() error { diff --git a/rocketpool/api/minipool/distribute.go b/rocketpool/api/minipool/distribute.go index 6615928da..f278af8d5 100644 --- a/rocketpool/api/minipool/distribute.go +++ b/rocketpool/api/minipool/distribute.go @@ -65,9 +65,6 @@ func getDistributeBalanceDetails(c *cli.Context) (*api.GetDistributeBalanceDetai address := addresses[mi] minipoolDetails := &details[mi] minipoolDetails.Address = address - minipoolDetails.Balance = big.NewInt(0) - minipoolDetails.Refund = big.NewInt(0) - minipoolDetails.NodeShareOfBalance = big.NewInt(0) mp, err := minipool.NewMinipool(rp, address, nil) if err != nil { return fmt.Errorf("error creating binding for minipool %s: %w", address.Hex(), err) @@ -82,19 +79,19 @@ func getDistributeBalanceDetails(c *cli.Context) (*api.GetDistributeBalanceDetai var wg2 errgroup.Group wg2.Go(func() error { - var err error - minipoolDetails.Balance, err = rp.Client.BalanceAt(context.Background(), address, nil) + balance, err := rp.Client.BalanceAt(context.Background(), address, nil) if err != nil { return fmt.Errorf("error getting balance of minipool %s: %w", address.Hex(), err) } + minipoolDetails.Balance.Set(balance) return nil }) wg2.Go(func() error { - var err error - minipoolDetails.Refund, err = mp.GetNodeRefundBalance(nil) + refund, err := mp.GetNodeRefundBalance(nil) if err != nil { return fmt.Errorf("error getting refund balance of minipool %s: %w", address.Hex(), err) } + minipoolDetails.Refund.Set(refund) return nil }) wg2.Go(func() error { @@ -134,13 +131,13 @@ func getDistributeBalanceDetails(c *cli.Context) (*api.GetDistributeBalanceDetai // Handle staking minipools if minipoolDetails.Status == types.Staking { // Ignore minipools with a balance lower than the refund - if minipoolDetails.Balance.Cmp(minipoolDetails.Refund) == -1 { + if minipoolDetails.Balance.Cmp(&minipoolDetails.Refund) == -1 { minipoolDetails.CanDistribute = false return nil } // Ignore minipools with an effective balance higher than v3 rewards-vs-exit cap - distributableBalance := big.NewInt(0).Sub(minipoolDetails.Balance, minipoolDetails.Refund) + distributableBalance := big.NewInt(0).Sub(&minipoolDetails.Balance, &minipoolDetails.Refund) eight := eth.EthToWei(8) if distributableBalance.Cmp(eight) >= 0 { minipoolDetails.CanDistribute = false @@ -148,10 +145,11 @@ func getDistributeBalanceDetails(c *cli.Context) (*api.GetDistributeBalanceDetai } // Get the node share of the balance - minipoolDetails.NodeShareOfBalance, err = mp.CalculateNodeShare(distributableBalance, nil) + nodeShareOfBalance, err := mp.CalculateNodeShare(distributableBalance, nil) if err != nil { return fmt.Errorf("error calculating node share for minipool %s: %w", address.Hex(), err) } + minipoolDetails.NodeShareOfBalance.Set(nodeShareOfBalance) } else if minipoolDetails.Status == types.Dissolved { // Dissolved but non-finalized / non-closed minipools can just have the whole balance sent back to the NO minipoolDetails.NodeShareOfBalance = minipoolDetails.Balance diff --git a/rocketpool/api/minipool/reduce-bond.go b/rocketpool/api/minipool/reduce-bond.go index 3926c2122..c5d747fd5 100644 --- a/rocketpool/api/minipool/reduce-bond.go +++ b/rocketpool/api/minipool/reduce-bond.go @@ -88,7 +88,7 @@ func canBeginReduceBondAmount(c *cli.Context, minipoolAddress common.Address, ne return fmt.Errorf("error getting node deposit balance for minipool %s: %w", minipoolAddress.Hex(), err) } // How much more ETH they're requesting from the staking pool - response.MatchRequest = big.NewInt(0).Sub(nodeDepositAmount, newBondAmountWei) + response.MatchRequest.Set(big.NewInt(0).Sub(nodeDepositAmount, newBondAmountWei)) return nil }) diff --git a/rocketpool/api/minipool/rescue-dissolved.go b/rocketpool/api/minipool/rescue-dissolved.go index b3376d16f..d8ce130b2 100644 --- a/rocketpool/api/minipool/rescue-dissolved.go +++ b/rocketpool/api/minipool/rescue-dissolved.go @@ -107,7 +107,6 @@ func getMinipoolRescueDissolvedDetails(rp *rocketpool.RocketPool, w *wallet.Wall var details api.MinipoolRescueDissolvedDetails details.Address = mp.GetAddress() details.MinipoolVersion = mp.GetVersion() - details.BeaconBalance = big.NewInt(0) // Ignore minipools that are too old if details.MinipoolVersion < 3 { @@ -170,7 +169,7 @@ func getMinipoolRescueDissolvedDetails(rp *rocketpool.RocketPool, w *wallet.Wall return details, nil } beaconBalanceGwei := big.NewInt(0).SetUint64(beaconStatus.Balance) - details.BeaconBalance = big.NewInt(0).Mul(beaconBalanceGwei, big.NewInt(1e9)) + details.BeaconBalance.Set(big.NewInt(0).Mul(beaconBalanceGwei, big.NewInt(1e9))) // Make sure it doesn't already have 32 ETH in it requiredBalance := eth.EthToWei(32) @@ -183,7 +182,7 @@ func getMinipoolRescueDissolvedDetails(rp *rocketpool.RocketPool, w *wallet.Wall details.CanRescue = true // Get the simulated deposit TX - remainingAmount := big.NewInt(0).Sub(requiredBalance, details.BeaconBalance) + remainingAmount := big.NewInt(0).Sub(requiredBalance, &details.BeaconBalance) 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 c1006e8b5..f93dcabad 100644 --- a/rocketpool/api/minipool/utils.go +++ b/rocketpool/api/minipool/utils.go @@ -273,14 +273,13 @@ func getMinipoolDetails(rp *rocketpool.RocketPool, minipoolAddress common.Addres } // Get node share of balance - if details.Balances.ETH.Cmp(details.Node.RefundBalance) == -1 { - details.NodeShareOfETHBalance = big.NewInt(0) - } else { + if details.Balances.ETH.Cmp(details.Node.RefundBalance) != -1 { effectiveBalance := big.NewInt(0).Sub(details.Balances.ETH, details.Node.RefundBalance) - details.NodeShareOfETHBalance, err = mp.CalculateNodeShare(effectiveBalance, nil) + nodeShareOfETHBalance, err := mp.CalculateNodeShare(effectiveBalance, nil) if err != nil { return api.MinipoolDetails{}, fmt.Errorf("error calculating node share: %w", err) } + details.NodeShareOfETHBalance.Set(nodeShareOfETHBalance) } // Get validator details if staking @@ -325,15 +324,13 @@ func getMinipoolValidatorDetails(rp *rocketpool.RocketPool, minipoolDetails api. // use deposit balances if validator not activated if !validatorActivated { - details.Balance = new(big.Int) details.Balance.Add(minipoolDetails.Node.DepositBalance, minipoolDetails.User.DepositBalance) - details.NodeBalance = new(big.Int) details.NodeBalance.Set(minipoolDetails.Node.DepositBalance) return details, nil } // Set validator balance - details.Balance = eth.GweiToWei(float64(validator.Balance)) + details.Balance.Set(eth.GweiToWei(float64(validator.Balance))) // Get expected node balance blockBalance := eth.GweiToWei(float64(validator.Balance)) @@ -341,7 +338,7 @@ func getMinipoolValidatorDetails(rp *rocketpool.RocketPool, minipoolDetails api. if err != nil { return api.ValidatorDetails{}, err } - details.NodeBalance = nodeBalance + details.NodeBalance.Set(nodeBalance) // Return return details, nil diff --git a/rocketpool/api/network/rpl-price.go b/rocketpool/api/network/rpl-price.go index ceefddf17..5419d0a83 100644 --- a/rocketpool/api/network/rpl-price.go +++ b/rocketpool/api/network/rpl-price.go @@ -72,31 +72,31 @@ func getRplPrice(c *cli.Context) (*api.RplPriceResponse, error) { minPer8EthMinipoolRplStake.Mul(_24Eth, minPerMinipoolStake) // Min is 10% of borrowed (24 ETH) minPer8EthMinipoolRplStake.Div(minPer8EthMinipoolRplStake, rplPrice) minPer8EthMinipoolRplStake.Add(minPer8EthMinipoolRplStake, big.NewInt(1)) - response.MinPer8EthMinipoolRplStake = minPer8EthMinipoolRplStake + response.MinPer8EthMinipoolRplStake.Set(minPer8EthMinipoolRplStake) // Max for LEB8s maxPer8EthMinipoolRplStake := big.NewInt(0) maxPer8EthMinipoolRplStake.Mul(_8Eth, maxPerMinipoolStake) // Max is 150% of bonded (8 ETH) maxPer8EthMinipoolRplStake.Div(maxPer8EthMinipoolRplStake, rplPrice) maxPer8EthMinipoolRplStake.Add(maxPer8EthMinipoolRplStake, big.NewInt(1)) - response.MaxPer8EthMinipoolRplStake = maxPer8EthMinipoolRplStake + response.MaxPer8EthMinipoolRplStake.Set(maxPer8EthMinipoolRplStake) // Min for 16s minPer16EthMinipoolRplStake := big.NewInt(0) minPer16EthMinipoolRplStake.Mul(_16Eth, minPerMinipoolStake) // Min is 10% of borrowed (16 ETH) minPer16EthMinipoolRplStake.Div(minPer16EthMinipoolRplStake, rplPrice) minPer16EthMinipoolRplStake.Add(minPer16EthMinipoolRplStake, big.NewInt(1)) - response.MinPer16EthMinipoolRplStake = minPer16EthMinipoolRplStake + response.MinPer16EthMinipoolRplStake.Set(minPer16EthMinipoolRplStake) // Max for 16s maxPer16EthMinipoolRplStake := big.NewInt(0) maxPer16EthMinipoolRplStake.Mul(_16Eth, maxPerMinipoolStake) // Max is 150% of bonded (16 ETH) maxPer16EthMinipoolRplStake.Div(maxPer16EthMinipoolRplStake, rplPrice) maxPer16EthMinipoolRplStake.Add(maxPer16EthMinipoolRplStake, big.NewInt(1)) - response.MaxPer16EthMinipoolRplStake = maxPer16EthMinipoolRplStake + response.MaxPer16EthMinipoolRplStake.Set(maxPer16EthMinipoolRplStake) // Update & return response - response.RplPrice = rplPrice + response.RplPrice.Set(rplPrice) return &response, nil } diff --git a/rocketpool/api/node/balances.go b/rocketpool/api/node/balances.go index 44b9d4f58..378a2b92a 100644 --- a/rocketpool/api/node/balances.go +++ b/rocketpool/api/node/balances.go @@ -32,10 +32,11 @@ func getNodeEthBalance(c *cli.Context) (*api.NodeEthBalanceResponse, error) { return nil, err } - response.Balance, err = ec.BalanceAt(context.Background(), nodeAccount.Address, nil) + balance, err := ec.BalanceAt(context.Background(), nodeAccount.Address, nil) if err != nil { return nil, fmt.Errorf("error getting ETH balance of node %s: %w", nodeAccount.Address.Hex(), err) } + response.Balance.Set(balance) return &response, nil } diff --git a/rocketpool/api/node/check-collateral.go b/rocketpool/api/node/check-collateral.go index af483f79d..4c07375c7 100644 --- a/rocketpool/api/node/check-collateral.go +++ b/rocketpool/api/node/check-collateral.go @@ -33,14 +33,17 @@ func checkCollateral(c *cli.Context) (*api.CheckCollateralResponse, error) { } // Check collateral - response.EthMatched, response.EthMatchedLimit, response.PendingMatchAmount, err = rputils.CheckCollateral(rp, nodeAccount.Address, nil) + ethMatched, ethMatchedLimit, pendingMatchAmount, err := rputils.CheckCollateral(rp, nodeAccount.Address, nil) if err != nil { return nil, err } + response.EthMatched.Set(ethMatched) + response.EthMatchedLimit.Set(ethMatchedLimit) + response.PendingMatchAmount.Set(pendingMatchAmount) // Check if there's sufficient collateral including pending bond reductions - remainingMatch := big.NewInt(0).Sub(response.EthMatchedLimit, response.EthMatched) - remainingMatch.Sub(remainingMatch, response.PendingMatchAmount) + remainingMatch := big.NewInt(0).Sub(&response.EthMatchedLimit, &response.EthMatched) + remainingMatch.Sub(remainingMatch, &response.PendingMatchAmount) response.InsufficientCollateral = (remainingMatch.Cmp(big.NewInt(0)) < 0) return &response, nil diff --git a/rocketpool/api/node/claim-rewards.go b/rocketpool/api/node/claim-rewards.go index bec2013f1..75c2add46 100644 --- a/rocketpool/api/node/claim-rewards.go +++ b/rocketpool/api/node/claim-rewards.go @@ -104,29 +104,44 @@ func getRewardsInfo(c *cli.Context) (*api.NodeGetRewardsInfoResponse, error) { var wg errgroup.Group wg.Go(func() error { - var err error - response.RplStake, err = node.GetNodeRPLStake(rp, nodeAccount.Address, nil) - return err + rplStake, err := node.GetNodeRPLStake(rp, nodeAccount.Address, nil) + if err != nil { + return err + } + response.RplStake.Set(rplStake) + return nil }) wg.Go(func() error { - var err error - response.RplPrice, err = network.GetRPLPrice(rp, nil) - return err + rplPrice, err := network.GetRPLPrice(rp, nil) + if err != nil { + return err + } + response.RplPrice.Set(rplPrice) + return nil }) wg.Go(func() error { - var err error - response.MinimumRplStake, err = node.GetNodeMinimumRPLStake(rp, nodeAccount.Address, nil) - return err + minimumRplStake, err := node.GetNodeMinimumRPLStake(rp, nodeAccount.Address, nil) + if err != nil { + return err + } + response.MinimumRplStake.Set(minimumRplStake) + return nil }) wg.Go(func() error { - var err error - response.MaximumRplStake, err = node.GetNodeMaximumRPLStake(rp, nodeAccount.Address, nil) - return err + maximumRplStake, err := node.GetNodeMaximumRPLStake(rp, nodeAccount.Address, nil) + if err != nil { + return err + } + response.MaximumRplStake.Set(maximumRplStake) + return nil }) wg.Go(func() error { - var err error - response.EffectiveRplStake, err = node.GetNodeEffectiveRPLStake(rp, nodeAccount.Address, nil) - return err + effectiveRplStake, err := node.GetNodeEffectiveRPLStake(rp, nodeAccount.Address, nil) + if err != nil { + return err + } + response.EffectiveRplStake.Set(effectiveRplStake) + return nil }) // Wait for data @@ -149,9 +164,14 @@ func getRewardsInfo(c *cli.Context) (*api.NodeGetRewardsInfoResponse, error) { return err }) wg2.Go(func() error { - var err error - response.EthMatched, response.EthMatchedLimit, response.PendingMatchAmount, err = rputils.CheckCollateral(rp, nodeAccount.Address, nil) - return err + ethMatched, ethMatchedLimit, pendingMatchAmount, err := rputils.CheckCollateral(rp, nodeAccount.Address, nil) + if err != nil { + return err + } + response.EthMatched.Set(ethMatched) + response.EthMatchedLimit.Set(ethMatchedLimit) + response.PendingMatchAmount.Set(pendingMatchAmount) + return nil }) // Wait for data @@ -160,20 +180,20 @@ func getRewardsInfo(c *cli.Context) (*api.NodeGetRewardsInfoResponse, error) { } // Calculate the *real* minimum, including the pending bond reductions - trueMinimumStake := big.NewInt(0).Add(response.EthMatched, response.PendingMatchAmount) + trueMinimumStake := big.NewInt(0).Add(&response.EthMatched, &response.PendingMatchAmount) trueMinimumStake.Mul(trueMinimumStake, minStakeFraction) - trueMinimumStake.Div(trueMinimumStake, response.RplPrice) + trueMinimumStake.Div(trueMinimumStake, &response.RplPrice) // Calculate the *real* maximum, including the pending bond reductions trueMaximumStake := eth.EthToWei(32) trueMaximumStake.Mul(trueMaximumStake, big.NewInt(int64(activeMinipools))) - trueMaximumStake.Sub(trueMaximumStake, response.EthMatched) - trueMaximumStake.Sub(trueMaximumStake, response.PendingMatchAmount) // (32 * activeMinipools - ethMatched - pendingMatch) + trueMaximumStake.Sub(trueMaximumStake, &response.EthMatched) + trueMaximumStake.Sub(trueMaximumStake, &response.PendingMatchAmount) // (32 * activeMinipools - ethMatched - pendingMatch) trueMaximumStake.Mul(trueMaximumStake, maxStakeFraction) - trueMaximumStake.Div(trueMaximumStake, response.RplPrice) + trueMaximumStake.Div(trueMaximumStake, &response.RplPrice) - response.MinimumRplStake = trueMinimumStake - response.MaximumRplStake = trueMaximumStake + response.MinimumRplStake.Set(trueMinimumStake) + response.MaximumRplStake.Set(trueMaximumStake) if response.EffectiveRplStake.Cmp(trueMinimumStake) < 0 { response.EffectiveRplStake.SetUint64(0) @@ -181,8 +201,8 @@ func getRewardsInfo(c *cli.Context) (*api.NodeGetRewardsInfoResponse, error) { response.EffectiveRplStake.Set(trueMaximumStake) } - response.BondedCollateralRatio = eth.WeiToEth(response.RplPrice) * eth.WeiToEth(response.RplStake) / (float64(activeMinipools)*32.0 - eth.WeiToEth(response.EthMatched) - eth.WeiToEth(response.PendingMatchAmount)) - response.BorrowedCollateralRatio = eth.WeiToEth(response.RplPrice) * eth.WeiToEth(response.RplStake) / (eth.WeiToEth(response.EthMatched) + eth.WeiToEth(response.PendingMatchAmount)) + response.BondedCollateralRatio = eth.WeiToEth(&response.RplPrice) * eth.WeiToEth(&response.RplStake) / (float64(activeMinipools)*32.0 - eth.WeiToEth(&response.EthMatched) - eth.WeiToEth(&response.PendingMatchAmount)) + response.BorrowedCollateralRatio = eth.WeiToEth(&response.RplPrice) * eth.WeiToEth(&response.RplStake) / (eth.WeiToEth(&response.EthMatched) + eth.WeiToEth(&response.PendingMatchAmount)) } else { response.BorrowedCollateralRatio = -1 } diff --git a/rocketpool/api/node/claim-rpl.go b/rocketpool/api/node/claim-rpl.go index 27e83cb26..d08fe63af 100644 --- a/rocketpool/api/node/claim-rpl.go +++ b/rocketpool/api/node/claim-rpl.go @@ -50,7 +50,7 @@ func canNodeClaimRpl(c *cli.Context) (*api.CanNodeClaimRplResponse, error) { if err != nil { return nil, fmt.Errorf("Error getting RPL rewards amount: %w", err) } - response.RplAmount = rewardsAmountWei + response.RplAmount.Set(rewardsAmountWei) // Don't claim unless the oDAO has claimed first (prevent known issue yet to be patched in smart contracts) trustedNodeClaimed, err := rewards.GetTrustedNodeTotalClaimed(rp, nil, &legacyRewardsPoolAddress) @@ -58,7 +58,7 @@ func canNodeClaimRpl(c *cli.Context) (*api.CanNodeClaimRplResponse, error) { return nil, fmt.Errorf("Error checking if trusted node has already minted RPL: %w", err) } if trustedNodeClaimed.Cmp(big.NewInt(0)) == 0 { - response.RplAmount = big.NewInt(0) + response.RplAmount.SetUint64(0) } // Get gas estimate diff --git a/rocketpool/api/node/deposit.go b/rocketpool/api/node/deposit.go index afaa0955a..a693b0ba6 100644 --- a/rocketpool/api/node/deposit.go +++ b/rocketpool/api/node/deposit.go @@ -95,7 +95,7 @@ func canNodeDeposit(c *cli.Context, amountWei *big.Int, minNodeFee float64, salt wg1.Go(func() error { ethBalanceWei, err := node.GetNodeDepositCredit(rp, nodeAccount.Address, nil) if err == nil { - response.CreditBalance = ethBalanceWei + response.CreditBalance.Set(ethBalanceWei) } return err }) @@ -104,7 +104,7 @@ func canNodeDeposit(c *cli.Context, amountWei *big.Int, minNodeFee float64, salt wg1.Go(func() error { ethBalanceWei, err := ec.BalanceAt(context.Background(), nodeAccount.Address, nil) if err == nil { - response.NodeBalance = ethBalanceWei + response.NodeBalance.Set(ethBalanceWei) } return err }) @@ -140,11 +140,11 @@ func canNodeDeposit(c *cli.Context, amountWei *big.Int, minNodeFee float64, salt } // Check for insufficient balance - totalBalance := big.NewInt(0).Add(response.NodeBalance, response.CreditBalance) + totalBalance := big.NewInt(0).Add(&response.NodeBalance, &response.CreditBalance) response.InsufficientBalance = (amountWei.Cmp(totalBalance) > 0) // Check if the credit balance can be used - response.DepositBalance = depositPoolBalance + response.DepositBalance.Set(depositPoolBalance) response.CanUseCredit = (depositPoolBalance.Cmp(eth.EthToWei(1)) >= 0) // Check data @@ -179,7 +179,7 @@ func canNodeDeposit(c *cli.Context, amountWei *big.Int, minNodeFee float64, salt // Get how much credit to use if response.CanUseCredit { - remainingAmount := big.NewInt(0).Sub(amountWei, response.CreditBalance) + remainingAmount := big.NewInt(0).Sub(amountWei, &response.CreditBalance) if remainingAmount.Cmp(big.NewInt(0)) > 0 { // Send the remaining amount if the credit isn't enough to cover the whole deposit opts.Value = remainingAmount diff --git a/rocketpool/api/node/distributor.go b/rocketpool/api/node/distributor.go index 27c5e1d4f..c701a12cf 100644 --- a/rocketpool/api/node/distributor.go +++ b/rocketpool/api/node/distributor.go @@ -173,9 +173,12 @@ func canDistribute(c *cli.Context) (*api.NodeCanDistributeResponse, error) { // Get the contract's balance wg.Go(func() error { - var err error - response.Balance, err = rp.Client.BalanceAt(context.Background(), distributorAddress, nil) - return err + balance, err := rp.Client.BalanceAt(context.Background(), distributorAddress, nil) + if err != nil { + return err + } + response.Balance.Set(balance) + return nil }) // Get the node's average fee diff --git a/rocketpool/api/node/smoothing-pool.go b/rocketpool/api/node/smoothing-pool.go index 0f2f7b6a4..03a6e2a6b 100644 --- a/rocketpool/api/node/smoothing-pool.go +++ b/rocketpool/api/node/smoothing-pool.go @@ -222,7 +222,7 @@ func GetSmoothingPoolBalance(rp *rocketpoolapi.RocketPool, ec *services.Executio if err != nil { return nil, err } - response.EthBalance = balanceWei + response.EthBalance.Set(balanceWei) return &response, nil } diff --git a/rocketpool/api/node/stake-rpl.go b/rocketpool/api/node/stake-rpl.go index 3040dd8c1..32d52ad2a 100644 --- a/rocketpool/api/node/stake-rpl.go +++ b/rocketpool/api/node/stake-rpl.go @@ -138,7 +138,7 @@ func allowanceRpl(c *cli.Context) (*api.NodeStakeRplAllowanceResponse, error) { return nil, err } - response.Allowance = allowance + response.Allowance.Set(allowance) return &response, nil } diff --git a/rocketpool/api/node/status.go b/rocketpool/api/node/status.go index 44ff3853d..8dc6960ee 100644 --- a/rocketpool/api/node/status.go +++ b/rocketpool/api/node/status.go @@ -103,35 +103,55 @@ func getStatus(c *cli.Context) (*api.NodeStatusResponse, error) { // Get staking details wg.Go(func() error { - var err error - response.RplStake, err = node.GetNodeRPLStake(rp, nodeAccount.Address, nil) - return err + rplStake, err := node.GetNodeRPLStake(rp, nodeAccount.Address, nil) + if err != nil { + return err + } + response.RplStake.Set(rplStake) + return nil }) wg.Go(func() error { - var err error - response.EffectiveRplStake, err = node.GetNodeEffectiveRPLStake(rp, nodeAccount.Address, nil) - return err + effectiveRplStake, err := node.GetNodeEffectiveRPLStake(rp, nodeAccount.Address, nil) + if err != nil { + return err + } + response.EffectiveRplStake.Set(effectiveRplStake) + return nil }) wg.Go(func() error { - var err error - response.MinimumRplStake, err = node.GetNodeMinimumRPLStake(rp, nodeAccount.Address, nil) - return err + minimumRplStake, err := node.GetNodeMinimumRPLStake(rp, nodeAccount.Address, nil) + if err != nil { + return err + } + response.MinimumRplStake.Set(minimumRplStake) + return nil }) wg.Go(func() error { - var err error - response.MaximumRplStake, err = node.GetNodeMaximumRPLStake(rp, nodeAccount.Address, nil) - return err + maximumRplStake, err := node.GetNodeMaximumRPLStake(rp, nodeAccount.Address, nil) + if err != nil { + return err + } + response.MaximumRplStake.Set(maximumRplStake) + return nil }) wg.Go(func() error { - var err error - response.EthMatched, response.EthMatchedLimit, response.PendingMatchAmount, err = rputils.CheckCollateral(rp, nodeAccount.Address, nil) - return err + ethMatched, ethMatchedLimit, pendingMatchAmount, err := rputils.CheckCollateral(rp, nodeAccount.Address, nil) + if err != nil { + return err + } + response.EthMatched.Set(ethMatched) + response.EthMatchedLimit.Set(ethMatchedLimit) + response.PendingMatchAmount.Set(pendingMatchAmount) + return nil }) wg.Go(func() error { - var err error - response.CreditBalance, err = node.GetNodeDepositCredit(rp, nodeAccount.Address, nil) - return err + creditBalance, err := node.GetNodeDepositCredit(rp, nodeAccount.Address, nil) + if err != nil { + return err + } + response.CreditBalance.Set(creditBalance) + return nil }) // Get active and past votes from Snapshot, but treat errors as non-Fatal @@ -213,13 +233,17 @@ func getStatus(c *cli.Context) (*api.NodeStatusResponse, error) { return err }) wg.Go(func() error { - var err error feeRecipientInfo, err := rputils.GetFeeRecipientInfo(rp, bc, nodeAccount.Address, nil) - if err == nil { - response.FeeRecipientInfo = *feeRecipientInfo - response.FeeDistributorBalance, err = rp.Client.BalanceAt(context.Background(), feeRecipientInfo.FeeDistributorAddress, nil) + if err != nil { + return err } - return err + response.FeeRecipientInfo = *feeRecipientInfo + feeDistributorBalance, err := rp.Client.BalanceAt(context.Background(), feeRecipientInfo.FeeDistributorAddress, nil) + if err != nil { + return err + } + response.FeeDistributorBalance.Set(feeDistributorBalance) + return nil }) // Wait for data @@ -264,20 +288,20 @@ func getStatus(c *cli.Context) (*api.NodeStatusResponse, error) { } // Calculate the *real* minimum, including the pending bond reductions - trueMinimumStake := big.NewInt(0).Add(response.EthMatched, response.PendingMatchAmount) + trueMinimumStake := big.NewInt(0).Add(&response.EthMatched, &response.PendingMatchAmount) trueMinimumStake.Mul(trueMinimumStake, minStakeFraction) trueMinimumStake.Div(trueMinimumStake, rplPrice) // Calculate the *real* maximum, including the pending bond reductions trueMaximumStake := eth.EthToWei(32) trueMaximumStake.Mul(trueMaximumStake, big.NewInt(int64(activeMinipools))) - trueMaximumStake.Sub(trueMaximumStake, response.EthMatched) - trueMaximumStake.Sub(trueMaximumStake, response.PendingMatchAmount) // (32 * activeMinipools - ethMatched - pendingMatch) + trueMaximumStake.Sub(trueMaximumStake, &response.EthMatched) + trueMaximumStake.Sub(trueMaximumStake, &response.PendingMatchAmount) // (32 * activeMinipools - ethMatched - pendingMatch) trueMaximumStake.Mul(trueMaximumStake, maxStakeFraction) trueMaximumStake.Div(trueMaximumStake, rplPrice) - response.MinimumRplStake = trueMinimumStake - response.MaximumRplStake = trueMaximumStake + response.MinimumRplStake.Set(trueMinimumStake) + response.MaximumRplStake.Set(trueMaximumStake) if response.EffectiveRplStake.Cmp(trueMinimumStake) < 0 { response.EffectiveRplStake.SetUint64(0) @@ -285,8 +309,8 @@ func getStatus(c *cli.Context) (*api.NodeStatusResponse, error) { response.EffectiveRplStake.Set(trueMaximumStake) } - response.BondedCollateralRatio = eth.WeiToEth(rplPrice) * eth.WeiToEth(response.RplStake) / (float64(activeMinipools)*32.0 - eth.WeiToEth(response.EthMatched) - eth.WeiToEth(response.PendingMatchAmount)) - response.BorrowedCollateralRatio = eth.WeiToEth(rplPrice) * eth.WeiToEth(response.RplStake) / (eth.WeiToEth(response.EthMatched) + eth.WeiToEth(response.PendingMatchAmount)) + response.BondedCollateralRatio = eth.WeiToEth(rplPrice) * eth.WeiToEth(&response.RplStake) / (float64(activeMinipools)*32.0 - eth.WeiToEth(&response.EthMatched) - eth.WeiToEth(&response.PendingMatchAmount)) + response.BorrowedCollateralRatio = eth.WeiToEth(rplPrice) * eth.WeiToEth(&response.RplStake) / (eth.WeiToEth(&response.EthMatched) + eth.WeiToEth(&response.PendingMatchAmount)) // Calculate the "eligible" info (ignoring pending bond reductions) based on the Beacon Chain _, _, pendingEligibleBorrowedEth, pendingEligibleBondedEth, err := getTrueBorrowAndBondAmounts(rp, bc, nodeAccount.Address) @@ -302,18 +326,18 @@ func getStatus(c *cli.Context) (*api.NodeStatusResponse, error) { pendingTrueMaximumStake := big.NewInt(0).Mul(pendingEligibleBondedEth, maxStakeFraction) pendingTrueMaximumStake.Div(pendingTrueMaximumStake, rplPrice) - response.PendingMinimumRplStake = pendingTrueMinimumStake - response.PendingMaximumRplStake = pendingTrueMaximumStake + response.PendingMinimumRplStake.Set(pendingTrueMinimumStake) + response.PendingMaximumRplStake.Set(pendingTrueMaximumStake) - response.PendingEffectiveRplStake = big.NewInt(0).Set(response.RplStake) + response.PendingEffectiveRplStake.Set(&response.RplStake) if response.PendingEffectiveRplStake.Cmp(pendingTrueMinimumStake) < 0 { response.PendingEffectiveRplStake.SetUint64(0) } else if response.PendingEffectiveRplStake.Cmp(pendingTrueMaximumStake) > 0 { response.PendingEffectiveRplStake.Set(pendingTrueMaximumStake) } - response.PendingBondedCollateralRatio = eth.WeiToEth(rplPrice) * eth.WeiToEth(response.RplStake) / eth.WeiToEth(pendingEligibleBondedEth) - response.PendingBorrowedCollateralRatio = eth.WeiToEth(rplPrice) * eth.WeiToEth(response.RplStake) / eth.WeiToEth(pendingEligibleBorrowedEth) + response.PendingBondedCollateralRatio = eth.WeiToEth(rplPrice) * eth.WeiToEth(&response.RplStake) / eth.WeiToEth(pendingEligibleBondedEth) + response.PendingBorrowedCollateralRatio = eth.WeiToEth(rplPrice) * eth.WeiToEth(&response.RplStake) / eth.WeiToEth(pendingEligibleBorrowedEth) } else { response.BorrowedCollateralRatio = -1 } diff --git a/rocketpool/api/node/swap-rpl.go b/rocketpool/api/node/swap-rpl.go index eea12ff82..a3b0f73b5 100644 --- a/rocketpool/api/node/swap-rpl.go +++ b/rocketpool/api/node/swap-rpl.go @@ -101,7 +101,7 @@ func allowanceFsRpl(c *cli.Context) (*api.NodeSwapRplAllowanceResponse, error) { return nil, err } - response.Allowance = allowance + response.Allowance.Set(allowance) return &response, nil } diff --git a/rocketpool/api/odao/get-settings.go b/rocketpool/api/odao/get-settings.go index 56feb2532..0a01ec25b 100644 --- a/rocketpool/api/odao/get-settings.go +++ b/rocketpool/api/odao/get-settings.go @@ -52,11 +52,11 @@ func getMemberSettings(c *cli.Context) (*api.GetTNDAOMemberSettingsResponse, err } response.Quorum = quorum - response.RPLBond = rplBond + response.RPLBond.Set(rplBond) response.MinipoolUnbondedMax = minipoolUnbondedMax response.ChallengeCooldown = challengeCooldown response.ChallengeWindow = challengeWindow - response.ChallengeCost = challengeCost + response.ChallengeCost.Set(challengeCost) // Return response return &response, nil diff --git a/rocketpool/api/queue/status.go b/rocketpool/api/queue/status.go index b60bef223..2f82fa414 100644 --- a/rocketpool/api/queue/status.go +++ b/rocketpool/api/queue/status.go @@ -29,9 +29,12 @@ func getStatus(c *cli.Context) (*api.QueueStatusResponse, error) { // Get deposit pool balance wg.Go(func() error { - var err error - response.DepositPoolBalance, err = deposit.GetBalance(rp, nil) - return err + depositPoolBalance, err := deposit.GetBalance(rp, nil) + if err != nil { + return err + } + response.DepositPoolBalance.Set(depositPoolBalance) + return nil }) // Get minipool queue length @@ -43,9 +46,12 @@ func getStatus(c *cli.Context) (*api.QueueStatusResponse, error) { // Get minipool queue capacity wg.Go(func() error { - var err error - response.MinipoolQueueCapacity, err = minipool.GetQueueTotalCapacity(rp, nil) - return err + minipoolQueueCapacity, err := minipool.GetQueueTotalCapacity(rp, nil) + if err != nil { + return err + } + response.MinipoolQueueCapacity.Set(minipoolQueueCapacity) + return nil }) // Wait for data diff --git a/shared/services/gas/gas.go b/shared/services/gas/gas.go index f6b1fb8a2..c0789a61d 100644 --- a/shared/services/gas/gas.go +++ b/shared/services/gas/gas.go @@ -115,7 +115,7 @@ func AssignMaxFeeAndLimit(gasInfo rocketpool.GasInfo, rp *rpsvc.Client, headless if err != nil { fmt.Printf("%sWARNING: couldn't check the ETH balance of the node (%s)\nPlease ensure your node wallet has enough ETH to pay for this transaction.%s\n\n", colorYellow, err.Error(), colorReset) } else if response.Balance.Cmp(ethRequired) < 0 { - return 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 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))) } rp.AssignGasSettings(maxFeeGwei, maxPriorityFeeGwei, gasLimit) diff --git a/shared/services/rocketpool/auction.go b/shared/services/rocketpool/auction.go index f22714e35..3afb47064 100644 --- a/shared/services/rocketpool/auction.go +++ b/shared/services/rocketpool/auction.go @@ -21,15 +21,6 @@ func (c *Client) AuctionStatus() (api.AuctionStatusResponse, error) { if response.Error != "" { return api.AuctionStatusResponse{}, fmt.Errorf("Could not get auction status: %s", response.Error) } - if response.TotalRPLBalance == nil { - response.TotalRPLBalance = big.NewInt(0) - } - if response.AllottedRPLBalance == nil { - response.AllottedRPLBalance = big.NewInt(0) - } - if response.RemainingRPLBalance == nil { - response.RemainingRPLBalance = big.NewInt(0) - } return response, nil } diff --git a/shared/services/rocketpool/minipool.go b/shared/services/rocketpool/minipool.go index e829fc963..4e5c9f69a 100644 --- a/shared/services/rocketpool/minipool.go +++ b/shared/services/rocketpool/minipool.go @@ -46,12 +46,6 @@ func (c *Client) MinipoolStatus() (api.MinipoolStatusResponse, error) { if mp.Balances.FixedSupplyRPL == nil { mp.Balances.FixedSupplyRPL = big.NewInt(0) } - if mp.Validator.Balance == nil { - mp.Validator.Balance = big.NewInt(0) - } - if mp.Validator.NodeBalance == nil { - mp.Validator.NodeBalance = big.NewInt(0) - } } return response, nil } diff --git a/shared/services/rocketpool/network.go b/shared/services/rocketpool/network.go index 2b139e445..5c2cf6f34 100644 --- a/shared/services/rocketpool/network.go +++ b/shared/services/rocketpool/network.go @@ -2,7 +2,6 @@ package rocketpool import ( "fmt" - "math/big" "github.com/goccy/go-json" "github.com/rocket-pool/smartnode/shared/types/api" @@ -37,21 +36,7 @@ func (c *Client) RplPrice() (api.RplPriceResponse, error) { if response.Error != "" { return api.RplPriceResponse{}, fmt.Errorf("Could not get network RPL price: %s", response.Error) } - if response.RplPrice == nil { - response.RplPrice = big.NewInt(0) - } - if response.MinPer8EthMinipoolRplStake == nil { - response.MinPer8EthMinipoolRplStake = big.NewInt(0) - } - if response.MaxPer8EthMinipoolRplStake == nil { - response.MaxPer8EthMinipoolRplStake = big.NewInt(0) - } - if response.MinPer16EthMinipoolRplStake == nil { - response.MinPer16EthMinipoolRplStake = big.NewInt(0) - } - if response.MaxPer16EthMinipoolRplStake == nil { - response.MaxPer16EthMinipoolRplStake = big.NewInt(0) - } + return response, nil } diff --git a/shared/services/rocketpool/node.go b/shared/services/rocketpool/node.go index 4c2724d53..a1e9f40f5 100644 --- a/shared/services/rocketpool/node.go +++ b/shared/services/rocketpool/node.go @@ -26,15 +26,6 @@ func (c *Client) NodeStatus() (api.NodeStatusResponse, error) { if response.Error != "" { return api.NodeStatusResponse{}, fmt.Errorf("Could not get node status: %s", response.Error) } - if response.RplStake == nil { - response.RplStake = big.NewInt(0) - } - if response.EffectiveRplStake == nil { - response.EffectiveRplStake = big.NewInt(0) - } - if response.MinimumRplStake == nil { - response.MinimumRplStake = big.NewInt(0) - } if response.AccountBalances.ETH == nil { response.AccountBalances.ETH = big.NewInt(0) } diff --git a/shared/services/rocketpool/odao.go b/shared/services/rocketpool/odao.go index 562a69fc3..186cb8692 100644 --- a/shared/services/rocketpool/odao.go +++ b/shared/services/rocketpool/odao.go @@ -811,12 +811,6 @@ func (c *Client) GetTNDAOMemberSettings() (api.GetTNDAOMemberSettingsResponse, e if response.Error != "" { return api.GetTNDAOMemberSettingsResponse{}, fmt.Errorf("Could not get oracle DAO member settings: %s", response.Error) } - if response.RPLBond == nil { - response.RPLBond = big.NewInt(0) - } - if response.ChallengeCost == nil { - response.ChallengeCost = big.NewInt(0) - } return response, nil } diff --git a/shared/services/rocketpool/queue.go b/shared/services/rocketpool/queue.go index 268c64a0e..b4f5bfdfe 100644 --- a/shared/services/rocketpool/queue.go +++ b/shared/services/rocketpool/queue.go @@ -2,7 +2,6 @@ package rocketpool import ( "fmt" - "math/big" "github.com/goccy/go-json" @@ -22,12 +21,6 @@ func (c *Client) QueueStatus() (api.QueueStatusResponse, error) { if response.Error != "" { return api.QueueStatusResponse{}, fmt.Errorf("Could not get queue status: %s", response.Error) } - if response.DepositPoolBalance == nil { - response.DepositPoolBalance = big.NewInt(0) - } - if response.MinipoolQueueCapacity == nil { - response.MinipoolQueueCapacity = big.NewInt(0) - } return response, nil } diff --git a/shared/types/api/auction.go b/shared/types/api/auction.go index 440e45d5b..04c160316 100644 --- a/shared/types/api/auction.go +++ b/shared/types/api/auction.go @@ -10,12 +10,12 @@ import ( ) type AuctionStatusResponse struct { - Status string `json:"status"` - Error string `json:"error"` - TotalRPLBalance *big.Int `json:"totalRPLBalance"` - AllottedRPLBalance *big.Int `json:"allottedRPLBalance"` - RemainingRPLBalance *big.Int `json:"remainingRPLBalance"` - CanCreateLot bool `json:"canCreateLot"` + Status string `json:"status"` + Error string `json:"error"` + TotalRPLBalance big.Int `json:"totalRPLBalance"` + AllottedRPLBalance big.Int `json:"allottedRPLBalance"` + RemainingRPLBalance big.Int `json:"remainingRPLBalance"` + CanCreateLot bool `json:"canCreateLot"` LotCounts struct { ClaimAvailable int `json:"claimAvailable"` BiddingAvailable int `json:"biddingAvailable"` diff --git a/shared/types/api/faucet.go b/shared/types/api/faucet.go index 142f5c334..37354efe7 100644 --- a/shared/types/api/faucet.go +++ b/shared/types/api/faucet.go @@ -8,13 +8,13 @@ import ( ) type FaucetStatusResponse struct { - Status string `json:"status"` - Error string `json:"error"` - Balance *big.Int `json:"balance"` - Allowance *big.Int `json:"allowance"` - WithdrawableAmount *big.Int `json:"withdrawableAmount"` - WithdrawalFee *big.Int `json:"withdrawalFee"` - ResetsInBlocks uint64 `json:"resetsInBlocks"` + Status string `json:"status"` + Error string `json:"error"` + Balance big.Int `json:"balance"` + Allowance big.Int `json:"allowance"` + WithdrawableAmount big.Int `json:"withdrawableAmount"` + WithdrawalFee big.Int `json:"withdrawalFee"` + ResetsInBlocks uint64 `json:"resetsInBlocks"` } type CanFaucetWithdrawRplResponse struct { @@ -29,6 +29,6 @@ type CanFaucetWithdrawRplResponse struct { type FaucetWithdrawRplResponse struct { Status string `json:"status"` Error string `json:"error"` - Amount *big.Int `json:"amount"` + Amount big.Int `json:"amount"` TxHash common.Hash `json:"txHash"` } diff --git a/shared/types/api/minipool.go b/shared/types/api/minipool.go index 91a54465b..b82655f7c 100644 --- a/shared/types/api/minipool.go +++ b/shared/types/api/minipool.go @@ -27,7 +27,7 @@ type MinipoolDetails struct { Node minipool.NodeDetails `json:"node"` User minipool.UserDetails `json:"user"` Balances tokens.Balances `json:"balances"` - NodeShareOfETHBalance *big.Int `json:"nodeShareOfETHBalance"` + NodeShareOfETHBalance big.Int `json:"nodeShareOfETHBalance"` Validator ValidatorDetails `json:"validator"` CanStake bool `json:"canStake"` CanPromote bool `json:"canPromote"` @@ -46,17 +46,17 @@ type MinipoolDetails struct { ReduceBondCancelled bool `json:"reduceBondCancelled"` } type ValidatorDetails struct { - Exists bool `json:"exists"` - Active bool `json:"active"` - Index string `json:"index"` - Balance *big.Int `json:"balance"` - NodeBalance *big.Int `json:"nodeBalance"` + Exists bool `json:"exists"` + Active bool `json:"active"` + Index string `json:"index"` + Balance big.Int `json:"balance"` + NodeBalance big.Int `json:"nodeBalance"` } type MinipoolBalanceDistributionDetails struct { Address common.Address `json:"address"` - Balance *big.Int `json:"balance"` - Refund *big.Int `json:"refund"` - NodeShareOfBalance *big.Int `json:"nodeShareOfBalance"` + Balance big.Int `json:"balance"` + Refund big.Int `json:"refund"` + NodeShareOfBalance big.Int `json:"nodeShareOfBalance"` MinipoolVersion uint8 `json:"minipoolVersion"` Status types.MinipoolStatus `json:"status"` IsFinalized bool `json:"isFinalized"` @@ -149,11 +149,11 @@ type MinipoolCloseDetails struct { MinipoolVersion uint8 `json:"minipoolVersion"` Distributed bool `json:"distributed"` CanClose bool `json:"canClose"` - Balance *big.Int `json:"balance"` - Refund *big.Int `json:"refund"` - UserDepositBalance *big.Int `json:"userDepositBalance"` + Balance big.Int `json:"balance"` + Refund big.Int `json:"refund"` + UserDepositBalance big.Int `json:"userDepositBalance"` BeaconState beacon.ValidatorState `json:"beaconState"` - NodeShare *big.Int `json:"nodeShare"` + NodeShare big.Int `json:"nodeShare"` GasInfo rocketpool.GasInfo `json:"gasInfo"` } @@ -179,7 +179,7 @@ type CanDistributeBalanceResponse struct { Error string `json:"error"` MinipoolVersion uint8 `json:"minipoolVersion"` MinipoolStatus types.MinipoolStatus `json:"minipoolStatus"` - Balance *big.Int `json:"balance"` + Balance big.Int `json:"balance"` CanDistribute bool `json:"canDistribute"` GasInfo rocketpool.GasInfo `json:"gasInfo"` } @@ -303,7 +303,7 @@ type CanBeginReduceBondAmountResponse struct { MinipoolVersionTooLow bool `json:"minipoolVersionTooLow"` Balance uint64 `json:"balance"` BalanceTooLow bool `json:"balanceTooLow"` - MatchRequest *big.Int `json:"matchRequest"` + MatchRequest big.Int `json:"matchRequest"` BeaconState beacon.ValidatorState `json:"beaconState"` InvalidBeaconState bool `json:"invalidBeaconState"` CanReduce bool `json:"canReduce"` @@ -334,7 +334,7 @@ type MinipoolRescueDissolvedDetails struct { IsFinalized bool `json:"isFinalized"` MinipoolStatus types.MinipoolStatus `json:"minipoolStatus"` MinipoolVersion uint8 `json:"minipoolVersion"` - BeaconBalance *big.Int `json:"beaconBalance"` + BeaconBalance big.Int `json:"beaconBalance"` BeaconState beacon.ValidatorState `json:"beaconState"` GasInfo rocketpool.GasInfo `json:"gasInfo"` } diff --git a/shared/types/api/network.go b/shared/types/api/network.go index 24ffb5e89..e456bc245 100644 --- a/shared/types/api/network.go +++ b/shared/types/api/network.go @@ -16,14 +16,14 @@ type NodeFeeResponse struct { } type RplPriceResponse struct { - Status string `json:"status"` - Error string `json:"error"` - RplPrice *big.Int `json:"rplPrice"` - RplPriceBlock uint64 `json:"rplPriceBlock"` - MinPer8EthMinipoolRplStake *big.Int `json:"minPer8EthMinipoolRplStake"` - MaxPer8EthMinipoolRplStake *big.Int `json:"maxPer8EthMinipoolRplStake"` - MinPer16EthMinipoolRplStake *big.Int `json:"minPer16EthMinipoolRplStake"` - MaxPer16EthMinipoolRplStake *big.Int `json:"maxPer16EthMinipoolRplStake"` + Status string `json:"status"` + Error string `json:"error"` + RplPrice big.Int `json:"rplPrice"` + RplPriceBlock uint64 `json:"rplPriceBlock"` + MinPer8EthMinipoolRplStake big.Int `json:"minPer8EthMinipoolRplStake"` + MaxPer8EthMinipoolRplStake big.Int `json:"maxPer8EthMinipoolRplStake"` + MinPer16EthMinipoolRplStake big.Int `json:"minPer16EthMinipoolRplStake"` + MaxPer16EthMinipoolRplStake big.Int `json:"maxPer16EthMinipoolRplStake"` } type NetworkStatsResponse struct { diff --git a/shared/types/api/node.go b/shared/types/api/node.go index 3ace379f4..cb3377872 100644 --- a/shared/types/api/node.go +++ b/shared/types/api/node.go @@ -27,24 +27,24 @@ type NodeStatusResponse struct { TimezoneLocation string `json:"timezoneLocation"` AccountBalances tokens.Balances `json:"accountBalances"` WithdrawalBalances tokens.Balances `json:"withdrawalBalances"` - RplStake *big.Int `json:"rplStake"` - EffectiveRplStake *big.Int `json:"effectiveRplStake"` - MinimumRplStake *big.Int `json:"minimumRplStake"` - MaximumRplStake *big.Int `json:"maximumRplStake"` + RplStake big.Int `json:"rplStake"` + EffectiveRplStake big.Int `json:"effectiveRplStake"` + MinimumRplStake big.Int `json:"minimumRplStake"` + MaximumRplStake big.Int `json:"maximumRplStake"` BorrowedCollateralRatio float64 `json:"borrowedCollateralRatio"` BondedCollateralRatio float64 `json:"bondedCollateralRatio"` - PendingEffectiveRplStake *big.Int `json:"pendingEffectiveRplStake"` - PendingMinimumRplStake *big.Int `json:"pendingMinimumRplStake"` - PendingMaximumRplStake *big.Int `json:"pendingMaximumRplStake"` + PendingEffectiveRplStake big.Int `json:"pendingEffectiveRplStake"` + PendingMinimumRplStake big.Int `json:"pendingMinimumRplStake"` + PendingMaximumRplStake big.Int `json:"pendingMaximumRplStake"` PendingBorrowedCollateralRatio float64 `json:"pendingBorrowedCollateralRatio"` PendingBondedCollateralRatio float64 `json:"pendingBondedCollateralRatio"` VotingDelegate common.Address `json:"votingDelegate"` VotingDelegateFormatted string `json:"votingDelegateFormatted"` MinipoolLimit uint64 `json:"minipoolLimit"` - EthMatched *big.Int `json:"ethMatched"` - EthMatchedLimit *big.Int `json:"ethMatchedLimit"` - PendingMatchAmount *big.Int `json:"pendingMatchAmount"` - CreditBalance *big.Int `json:"creditBalance"` + EthMatched big.Int `json:"ethMatched"` + EthMatchedLimit big.Int `json:"ethMatchedLimit"` + PendingMatchAmount big.Int `json:"pendingMatchAmount"` + CreditBalance big.Int `json:"creditBalance"` MinipoolCounts struct { Total int `json:"total"` Initialized int `json:"initialized"` @@ -59,7 +59,7 @@ type NodeStatusResponse struct { } `json:"minipoolCounts"` IsFeeDistributorInitialized bool `json:"isFeeDistributorInitialized"` FeeRecipientInfo rp.FeeRecipientInfo `json:"feeRecipientInfo"` - FeeDistributorBalance *big.Int `json:"feeDistributorBalance"` + FeeDistributorBalance big.Int `json:"feeDistributorBalance"` PenalizedMinipools map[common.Address]uint64 `json:"penalizedMinipools"` SnapshotResponse struct { Error string `json:"error"` @@ -153,9 +153,9 @@ type NodeSwapRplSwapResponse struct { SwapTxHash common.Hash `json:"swapTxHash"` } type NodeSwapRplAllowanceResponse struct { - Status string `json:"status"` - Error string `json:"error"` - Allowance *big.Int `json:"allowance"` + Status string `json:"status"` + Error string `json:"error"` + Allowance big.Int `json:"allowance"` } type CanNodeStakeRplResponse struct { @@ -182,9 +182,9 @@ type NodeStakeRplStakeResponse struct { StakeTxHash common.Hash `json:"stakeTxHash"` } type NodeStakeRplAllowanceResponse struct { - Status string `json:"status"` - Error string `json:"error"` - Allowance *big.Int `json:"allowance"` + Status string `json:"status"` + Error string `json:"error"` + Allowance big.Int `json:"allowance"` } type CanSetStakeRplForAllowedResponse struct { @@ -219,10 +219,10 @@ type CanNodeDepositResponse struct { Status string `json:"status"` Error string `json:"error"` CanDeposit bool `json:"canDeposit"` - CreditBalance *big.Int `json:"creditBalance"` - DepositBalance *big.Int `json:"depositBalance"` + CreditBalance big.Int `json:"creditBalance"` + DepositBalance big.Int `json:"depositBalance"` CanUseCredit bool `json:"canUseCredit"` - NodeBalance *big.Int `json:"nodeBalance"` + NodeBalance big.Int `json:"nodeBalance"` InsufficientBalance bool `json:"insufficientBalance"` InsufficientBalanceWithoutCredit bool `json:"insufficientBalanceWithoutCredit"` InsufficientRplStake bool `json:"insufficientRplStake"` @@ -298,7 +298,7 @@ type NodeSyncProgressResponse struct { type CanNodeClaimRplResponse struct { Status string `json:"status"` Error string `json:"error"` - RplAmount *big.Int `json:"rplAmount"` + RplAmount big.Int `json:"rplAmount"` GasInfo rocketpool.GasInfo `json:"gasInfo"` } type NodeClaimRplResponse struct { @@ -389,7 +389,7 @@ type NodeInitializeFeeDistributorResponse struct { type NodeCanDistributeResponse struct { Status string `json:"status"` Error string `json:"error"` - Balance *big.Int `json:"balance"` + Balance big.Int `json:"balance"` AverageNodeFee float64 `json:"averageNodeFee"` GasInfo rocketpool.GasInfo `json:"gasInfo"` } @@ -406,15 +406,15 @@ type NodeGetRewardsInfoResponse struct { ClaimedIntervals []uint64 `json:"claimedIntervals"` UnclaimedIntervals []rewards.IntervalInfo `json:"unclaimedIntervals"` InvalidIntervals []rewards.IntervalInfo `json:"invalidIntervals"` - RplStake *big.Int `json:"rplStake"` - RplPrice *big.Int `json:"rplPrice"` + RplStake big.Int `json:"rplStake"` + RplPrice big.Int `json:"rplPrice"` ActiveMinipools int `json:"activeMinipools"` - EffectiveRplStake *big.Int `json:"effectiveRplStake"` - MinimumRplStake *big.Int `json:"minimumRplStake"` - MaximumRplStake *big.Int `json:"maximumRplStake"` - EthMatched *big.Int `json:"ethMatched"` - EthMatchedLimit *big.Int `json:"ethMatchedLimit"` - PendingMatchAmount *big.Int `json:"pendingMatchAmount"` + EffectiveRplStake big.Int `json:"effectiveRplStake"` + MinimumRplStake big.Int `json:"minimumRplStake"` + MaximumRplStake big.Int `json:"maximumRplStake"` + EthMatched big.Int `json:"ethMatched"` + EthMatchedLimit big.Int `json:"ethMatchedLimit"` + PendingMatchAmount big.Int `json:"pendingMatchAmount"` BorrowedCollateralRatio float64 `json:"borrowedCollateralRatio"` BondedCollateralRatio float64 `json:"bondedCollateralRatio"` } @@ -508,22 +508,22 @@ type SnapshotVotedProposals struct { } `json:"data"` } type SmoothingRewardsResponse struct { - Status string `json:"status"` - Error string `json:"error"` - EthBalance *big.Int `json:"eth_balance"` + Status string `json:"status"` + Error string `json:"error"` + EthBalance big.Int `json:"eth_balance"` } type CheckCollateralResponse struct { - Status string `json:"status"` - Error string `json:"error"` - EthMatched *big.Int `json:"ethMatched"` - EthMatchedLimit *big.Int `json:"ethMatchedLimit"` - PendingMatchAmount *big.Int `json:"pendingMatchAmount"` - InsufficientCollateral bool `json:"insufficientCollateral"` + Status string `json:"status"` + Error string `json:"error"` + EthMatched big.Int `json:"ethMatched"` + EthMatchedLimit big.Int `json:"ethMatchedLimit"` + PendingMatchAmount big.Int `json:"pendingMatchAmount"` + InsufficientCollateral bool `json:"insufficientCollateral"` } type NodeEthBalanceResponse struct { - Status string `json:"status"` - Error string `json:"error"` - Balance *big.Int `json:"balance"` + Status string `json:"status"` + Error string `json:"error"` + Balance big.Int `json:"balance"` } diff --git a/shared/types/api/odao.go b/shared/types/api/odao.go index 0a25b57fc..1a8c21912 100644 --- a/shared/types/api/odao.go +++ b/shared/types/api/odao.go @@ -287,14 +287,14 @@ type ProposeTNDAOSettingBondReductionWindowLengthResponse struct { } type GetTNDAOMemberSettingsResponse struct { - Status string `json:"status"` - Error string `json:"error"` - Quorum float64 `json:"quorum"` - RPLBond *big.Int `json:"rplBond"` - MinipoolUnbondedMax uint64 `json:"minipoolUnbondedMax"` - ChallengeCooldown uint64 `json:"challengeCooldown"` - ChallengeWindow uint64 `json:"challengeWindow"` - ChallengeCost *big.Int `json:"challengeCost"` + Status string `json:"status"` + Error string `json:"error"` + Quorum float64 `json:"quorum"` + RPLBond big.Int `json:"rplBond"` + MinipoolUnbondedMax uint64 `json:"minipoolUnbondedMax"` + ChallengeCooldown uint64 `json:"challengeCooldown"` + ChallengeWindow uint64 `json:"challengeWindow"` + ChallengeCost big.Int `json:"challengeCost"` } type GetTNDAOProposalSettingsResponse struct { Status string `json:"status"` diff --git a/shared/types/api/queue.go b/shared/types/api/queue.go index 7cb90d670..bc7cc7bb0 100644 --- a/shared/types/api/queue.go +++ b/shared/types/api/queue.go @@ -8,11 +8,11 @@ import ( ) type QueueStatusResponse struct { - Status string `json:"status"` - Error string `json:"error"` - DepositPoolBalance *big.Int `json:"depositPoolBalance"` - MinipoolQueueLength uint64 `json:"minipoolQueueLength"` - MinipoolQueueCapacity *big.Int `json:"minipoolQueueCapacity"` + Status string `json:"status"` + Error string `json:"error"` + DepositPoolBalance big.Int `json:"depositPoolBalance"` + MinipoolQueueLength uint64 `json:"minipoolQueueLength"` + MinipoolQueueCapacity big.Int `json:"minipoolQueueCapacity"` } type CanProcessQueueResponse struct {