Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
batphonghan committed Feb 26, 2024
1 parent caef917 commit 20e162d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 7 additions & 1 deletion stader-lib/sdutility/sd-utility.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions stader-lib/utils/eth/units.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
}

Expand Down

0 comments on commit 20e162d

Please sign in to comment.