use of wannabit.io.cosmostaion.dao.Cw20Assets in project cosmostation-android by cosmostation.
the class WDp method allAssetToUserCurrency.
public static BigDecimal allAssetToUserCurrency(BaseChain baseChain, BaseData baseData) {
BigDecimal totalValue = BigDecimal.ZERO;
if (isGRPC(baseChain)) {
for (Coin coin : baseData.mGrpcBalance) {
if (coin.denom.equals(mainDenom(baseChain))) {
BigDecimal amount = baseData.getAllMainAsset(mainDenom(baseChain));
BigDecimal assetValue = userCurrencyValue(baseData, coin.denom, amount, mainDivideDecimal(baseChain));
totalValue = totalValue.add(assetValue);
} else if (baseChain.equals(COSMOS_MAIN) && coin.denom.startsWith("pool")) {
BigDecimal amount = baseData.getAvailable(coin.denom);
BigDecimal assetValue = userCurrencyValue(baseData, coin.denom, amount, 6);
totalValue = totalValue.add(assetValue);
} else if (baseChain.equals(OSMOSIS_MAIN) && coin.denom.equals(TOKEN_ION) || baseChain.equals(CRESCENT_MAIN) && coin.denom.equals(TOKEN_BCRE) || baseChain.equals(NYX_MAIN) && coin.denom.equals(TOKEN_NYM)) {
BigDecimal amount = baseData.getAvailable(coin.denom);
BigDecimal assetValue = userCurrencyValue(baseData, coin.denom, amount, 6);
totalValue = totalValue.add(assetValue);
} else if (baseChain.equals(OSMOSIS_MAIN) && coin.denom.contains("gamm/pool")) {
BigDecimal amount = baseData.getAvailable(coin.denom);
BigDecimal assetValue = userCurrencyValue(baseData, coin.denom, amount, 18);
totalValue = totalValue.add(assetValue);
} else if (baseChain.equals(SIF_MAIN) && coin.denom.startsWith("c")) {
BigDecimal amount = baseData.getAvailable(coin.denom);
int decimal = WUtil.getSifCoinDecimal(baseData, coin.denom);
BigDecimal assetValue = userCurrencyValue(baseData, coin.denom.substring(1), amount, decimal);
totalValue = totalValue.add(assetValue);
} else if (baseChain.equals(EMONEY_MAIN) || coin.denom.startsWith("e")) {
BigDecimal available = baseData.getAvailable(coin.denom);
totalValue = totalValue.add(userCurrencyValue(baseData, coin.denom, available, 6));
} else if (baseChain.equals(KAVA_MAIN) && !coin.isIbc()) {
BigDecimal amount = baseData.getAvailable(coin.denom);
amount = amount.add(baseData.getVesting(coin.denom));
String kavaDenom = WDp.getKavaBaseDenom(coin.denom);
int kavaDecimal = WUtil.getKavaCoinDecimal(baseData, coin.denom);
BigDecimal assetValue = userCurrencyValue(baseData, kavaDenom, amount, kavaDecimal);
totalValue = totalValue.add(assetValue);
} else if (baseChain.equals(GRABRIDGE_MAIN) && coin.denom.startsWith("gravity")) {
Assets assets = baseData.getAsset(coin.denom);
BigDecimal available = baseData.getAvailable(assets.denom);
totalValue = totalValue.add(userCurrencyValue(baseData, assets.origin_symbol, available, assets.decimal));
} else if (baseChain.equals(INJ_MAIN) && coin.denom.startsWith("peggy")) {
Assets assets = baseData.getAsset(coin.denom);
BigDecimal available = baseData.getAvailable(assets.denom);
totalValue = totalValue.add(userCurrencyValue(baseData, assets.origin_symbol, available, assets.decimal));
} else if (coin.isIbc()) {
BigDecimal amount = baseData.getAvailable(coin.denom);
IbcToken ibcToken = baseData.getIbcToken(coin.denom);
if (ibcToken != null && ibcToken.auth) {
BigDecimal assetValue = userCurrencyValue(baseData, ibcToken.base_denom, amount, ibcToken.decimal);
totalValue = totalValue.add(assetValue);
}
}
}
if (baseData.getCw20sGrpc(baseChain).size() > 0) {
for (Cw20Assets assets : baseData.getCw20sGrpc(baseChain)) {
BigDecimal amount = assets.getAmount();
totalValue = totalValue.add(userCurrencyValue(baseData, assets.denom, amount, assets.decimal));
}
}
} else if (baseChain.equals(BNB_MAIN)) {
for (Balance balance : baseData.mBalances) {
if (balance.symbol.equals(mainDenom(baseChain))) {
BigDecimal amount = baseData.getAllBnbTokenAmount(balance.symbol);
BigDecimal assetValue = userCurrencyValue(baseData, TOKEN_BNB, amount, mainDivideDecimal(baseChain));
totalValue = totalValue.add(assetValue);
} else {
BigDecimal amount = baseData.getAllBnbTokenAmount(balance.symbol);
BigDecimal convertAmount = WUtil.getBnbConvertAmount(baseData, balance.symbol, amount);
BigDecimal assetValue = userCurrencyValue(baseData, TOKEN_BNB, convertAmount, mainDivideDecimal(baseChain));
totalValue = totalValue.add(assetValue);
}
}
} else if (baseChain.equals(OKEX_MAIN)) {
for (Balance balance : baseData.mBalances) {
if (balance.symbol.equals(mainDenom(baseChain))) {
BigDecimal amount = baseData.getAllExToken(balance.symbol);
BigDecimal assetValue = userCurrencyValue(baseData, TOKEN_OK, amount, mainDivideDecimal(baseChain));
totalValue = totalValue.add(assetValue);
} else {
BigDecimal convertAmount = convertTokenToOkt(baseData, balance.symbol);
BigDecimal assetValue = userCurrencyValue(baseData, TOKEN_OK, convertAmount, mainDivideDecimal(baseChain));
totalValue = totalValue.add(assetValue);
}
}
} else {
for (Balance balance : baseData.mBalances) {
if (balance.symbol.equals(mainDenom(baseChain))) {
BigDecimal amount = baseData.getAllMainAssetOld(balance.symbol);
BigDecimal assetValue = userCurrencyValue(baseData, balance.symbol, amount, mainDivideDecimal(baseChain));
totalValue = totalValue.add(assetValue);
} else {
}
}
}
return totalValue;
}
Aggregations