diff --git a/stader-lib/sdutility/sd-utility.go b/stader-lib/sdutility/sd-utility.go index 486481b8..b1f15625 100644 --- a/stader-lib/sdutility/sd-utility.go +++ b/stader-lib/sdutility/sd-utility.go @@ -19,10 +19,12 @@ func GetPoolAvailableSDBalance(sp *stader.SDUtilityPoolContractManager, opts *bi if err != nil { return nil, err } + sdRequestedForWithdraw, err := GetSdRequestedForWithdraw(sp, opts) if err != nil { return nil, err } + utilityPoolBalance, err := GetUtilityPoolBalance(sp, opts) if err != nil { return nil, err @@ -81,6 +83,10 @@ func RepayFullAmount(sp *stader.SDUtilityPoolContractManager, opts *bind.Transac func SDMaxUtilizableAmount(sp *stader.SDUtilityPoolContractManager, sdc *stader.SdCollateralContractManager, numValidators *big.Int, opts *bind.CallOpts) (*big.Int, error) { maxThreshold, err := sp.SDUtilityPool.MaxETHWorthOfSDPerValidator(opts) + if err != nil { + return nil, err + } + ethAmount := new(big.Int).Mul(maxThreshold, numValidators) sdAmount, err := sdc.SdCollateral.ConvertETHToSD(opts, ethAmount) @@ -115,7 +121,7 @@ func GetUserData(sp *stader.SDUtilityPoolContractManager, address common.Address return &userData, nil } -func AlreadyLiquidated(sp *stader.SDUtilityPoolContractManager, address common.Address, opts *bind.CallOpts) (bool, error) { +func AlreadyLiquidated(sp *stader.SDUtilityPoolContractManager, address common.Address, _opts *bind.CallOpts) (bool, error) { liquidationIndex, err := LiquidationIndexByOperator(sp, address, nil) if err != nil { return false, err diff --git a/stader-lib/utils/eth/units.go b/stader-lib/utils/eth/units.go index 526f293a..3f6a15c3 100644 --- a/stader-lib/utils/eth/units.go +++ b/stader-lib/utils/eth/units.go @@ -38,6 +38,7 @@ func DisplayAmountInUnits(wei *big.Int, denom string) string { if denom == "sd" { gweiDenom = " gwei SD" } + regDenom := " ETH" if denom == "sd" { regDenom = " SD" @@ -46,9 +47,11 @@ func DisplayAmountInUnits(wei *big.Int, denom string) string { if wei == nil { return "" } + if wei.Cmp(big.NewInt(Threshold)) < 0 && wei.Cmp(big.NewInt(0)) != 0 { return strconv.FormatFloat(WeiToGwei(wei), 'f', 6, 64) + gweiDenom } + return strconv.FormatFloat(WeiToEth(wei), 'f', 6, 64) + regDenom }