From 3a4632c2ed5084bff6790ec7e28e7854a54dc195 Mon Sep 17 00:00:00 2001 From: batphonghan Date: Wed, 10 Jan 2024 17:23:15 +0700 Subject: [PATCH] Inlcuded SdUtilizerLatestBalance in self bond flow --- stader-cli/node/utilize-sd.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/stader-cli/node/utilize-sd.go b/stader-cli/node/utilize-sd.go index b93c5cbef..39d4c88ba 100644 --- a/stader-cli/node/utilize-sd.go +++ b/stader-cli/node/utilize-sd.go @@ -148,9 +148,15 @@ Maximum utilization amount: %s func PromptChooseSelfBondAmount(sdStatus *api.SdStatusResponse) (*big.Int, error) { - amountToCollateralRemain := new(big.Int).Sub(sdStatus.SdCollateralRequireAmount, sdStatus.SdCollateralCurrentAmount) + totalCollateral := new(big.Int).Add(sdStatus.SdCollateralCurrentAmount, sdStatus.SdUtilizerLatestBalance) - sdRewardEligibleRemain := new(big.Int).Sub(sdStatus.SdRewardEligible, sdStatus.SdCollateralCurrentAmount) + amountToCollateralRemain := new(big.Int).Sub(sdStatus.SdCollateralRequireAmount, totalCollateral) + + sdRewardEligibleRemain := new(big.Int).Sub(sdStatus.SdRewardEligible, totalCollateral) + + if amountToCollateralRemain.Cmp(big.NewInt(0)) < 0 { + amountToCollateralRemain = big.NewInt(0) + } minSd := eth.WeiToEth(amountToCollateralRemain) maxSd := eth.WeiToEth(sdRewardEligibleRemain)