Skip to content

Commit

Permalink
fix USDT-OKC20 coin address total balance check.
Browse files Browse the repository at this point in the history
update
  • Loading branch information
jiangjinyuan committed Aug 15, 2023
1 parent e47fa70 commit c3075b4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cmd/checkbalance/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,8 @@ func VerifyCoinAddressTotalBalance(validator *common.AddressBalanceValidator, co
return
}
coinAmount, _ := decimal.NewFromString(amount)
// USDC-OKC20 precision is 18, convert to 6
if coinTemp == "USDC-OKC20" {
// USDC-OKC20/USDT-OKC20 precision is 18, convert to 6
if coinTemp == "USDC-OKC20" || coinTemp == "USDT-OKC20" {
coinAmountDecimal, _ := decimal.NewFromString(convertCoinBalanceToBaseUnit(coinTemp, coinAmount.String(), -1))
totalBalance = totalBalance.Add(coinAmountDecimal.Mul(decimal.NewFromInt(1000000)))
} else {
Expand All @@ -310,7 +310,8 @@ func VerifyCoinAddressTotalBalance(validator *common.AddressBalanceValidator, co
}

// convert coin balance to base unit
toalBalance := convertCoinBalanceToBaseUnit(coin, totalBalance.String(), -1)
dCoin := common.PorCoinUnitMap[strings.ToUpper(coin)]
toalBalance := convertCoinBalanceToBaseUnit(dCoin, totalBalance.String(), -1)
// compare
if isCoinBalanceEqual(toalBalance, totalPorBalance.String()) {
log.Infof("verify coin %s total address balance success, in chain balance: %s, in por balance: %s", coin, toalBalance, totalPorBalance.String())
Expand Down

0 comments on commit c3075b4

Please sign in to comment.