소스 검색

token为lp时的容错

skyfffire 3 년 전
부모
커밋
ad0908f192
1개의 변경된 파일12개의 추가작업 그리고 6개의 파일을 삭제
  1. 12 6
      src/main/java/controller/EthMevController.java

+ 12 - 6
src/main/java/controller/EthMevController.java

@@ -206,14 +206,20 @@ public class EthMevController extends Controller {
 
                     if (tokenObj != null) {
                         JSONObject tokenObjDataObj = JSONObject.parseObject(tokenObj.getStr("data"));
-                        tradeInfo.put("tokenSymbol", tokenObjDataObj.getString("symbol"));
 
-                        BigDecimal amount = tradeInfo.getBigDecimal("amount");
-                        BigDecimal ten = new BigDecimal("10");
-                        int decimals = tokenObjDataObj.getInteger("decimals");
+                        if (tokenObjDataObj.getString("LP") == null) {
+                            tradeInfo.put("tokenSymbol", tokenObjDataObj.getString("symbol"));
 
-                        BigDecimal realAmount = amount.divide(ten.pow(decimals));
-                        tradeInfo.put("amount", realAmount.doubleValue());
+                            BigDecimal amount = tradeInfo.getBigDecimal("amount");
+                            BigDecimal ten = new BigDecimal("10");
+                            int decimals = tokenObjDataObj.getInteger("decimals");
+
+                            BigDecimal realAmount = amount.divide(ten.pow(decimals));
+                            tradeInfo.put("amount", realAmount.doubleValue());
+                        } else {
+                            tradeInfo.put("tokenSymbol", tokenObjDataObj.getString("name"));
+                            tradeInfo.put("amount", 1);
+                        }
                     } else if (tradeInfo.getString("token").equals("0xeth")) {
                         tradeInfo.put("tokenSymbol", "Ethereum");