-
Notifications
You must be signed in to change notification settings - Fork 162
Expand file tree
/
Copy pathstatus.go
More file actions
46 lines (37 loc) · 1.17 KB
/
status.go
File metadata and controls
46 lines (37 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package faucet
import (
"fmt"
"math/big"
"github.com/rocket-pool/rocketpool-go/utils/eth"
"github.com/urfave/cli"
"github.com/rocket-pool/smartnode/shared/services/rocketpool"
cliutils "github.com/rocket-pool/smartnode/shared/utils/cli"
"github.com/rocket-pool/smartnode/shared/utils/math"
)
func getStatus(c *cli.Context) error {
// Get RP client
rp, err := rocketpool.NewClientFromCtx(c)
if err != nil {
return err
}
defer rp.Close()
// Check and assign the EC status
err = cliutils.CheckClientStatus(rp)
if err != nil {
return err
}
// Get faucet status
status, err := rp.FaucetStatus()
if err != nil {
return err
}
// Print status & return
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))
} else {
fmt.Println("You cannot withdraw legacy RPL right now.")
}
fmt.Printf("Allowances reset in %d blocks.\n", status.ResetsInBlocks)
return nil
}