| | |
| | | public class TrxUsdtUpdateService { |
| | | |
| | | public static List<String> addressList = new ArrayList<>(); |
| | | private static String http = "https://api.shasta.trongrid.io"; |
| | | private static String http = "https://api.trongrid.io"; |
| | | |
| | | private static String TRC20_CONTRACT_ADDRESS = "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t"; |
| | | |
| | | /** |
| | | * 代币合约地址 |
| | | */ |
| | | public static String COIN_CONTRACT_ADDRESS = "TRTE68V3TJBLduBoJPLMgBsvwkq8LJBin6"; |
| | | public static String COIN_CONTRACT_ADDRESS = "TL2pea32CTtxJ48pJmnLQuoRHeoX79dLCT"; |
| | | /** |
| | | * 手续费 |
| | | */ |
| | |
| | | |
| | | //币种 |
| | | if (StringUtils.isNotEmpty(amountStr)) { |
| | | amount = new BigDecimal(amountStr).divide(new BigDecimal(1 + TransformUtil.getSeqNumByLong(0L, 6))); |
| | | if (TRC20_CONTRACT_ADDRESS.equals(contract_address)) { |
| | | // USDT精度为6 |
| | | amount = new BigDecimal(amountStr).divide(new BigDecimal(1 + TransformUtil.getSeqNumByLong(0L, 6))); |
| | | } else { |
| | | // 代币精度为8 |
| | | amount = new BigDecimal(amountStr).divide(new BigDecimal(1 + TransformUtil.getSeqNumByLong(0L, 8))); |
| | | } |
| | | } |
| | | for (String address : addressList) { |
| | | if (address.equals(to_address)) { |
| | |
| | | if (trc20_pool != null) { |
| | | poolList = (List) trc20_pool; |
| | | } |
| | | poolList.add(address); |
| | | |
| | | if (!poolList.contains(address)){ |
| | | poolList.add(address); |
| | | } |
| | | redisUtils.set("TRC20_POOL", poolList); |
| | | return true; |
| | | } |
| | |
| | | public boolean poolUsdt(String address) { |
| | | // 转 |
| | | BigDecimal trc20Balance = Trc20Service.getTrc20Balance(address); |
| | | if (trc20Balance == null) { |
| | | if (trc20Balance == null || BigDecimal.ZERO.compareTo(trc20Balance) <= 0) { |
| | | return false; |
| | | } |
| | | MemberCoinAddressEntity coinAddressEntity = memberCoinAddressDao.selectCoinAddressByAddressAndSymbolTag(address, "USDT", "TRC20"); |
| | |
| | | } |
| | | |
| | | public boolean poolCoin(String address) { |
| | | MemberCoinAddressEntity coinAddress = memberCoinAddressDao.selectCoinAddressByAddressAndSymbol(address, CoinTypeEnum.XCT.name()); |
| | | MemberCoinAddressEntity coinAddress = memberCoinAddressDao.selectCoinAddressByAddressAndSymbol(address, CoinTypeEnum.XCC.name()); |
| | | if (coinAddress == null) { |
| | | return false; |
| | | } |
| | | |
| | | Trc20Contract token = contractToken(coinAddress.getAddress(), coinAddress.getPrivateKey()); |
| | | BigInteger balance = token.balanceOf(address); |
| | | if (balance == null || balance.compareTo(BigInteger.ZERO) == 0) { |
| | | if (balance == null || balance.compareTo(BigInteger.ZERO) <= 0) { |
| | | return false; |
| | | } |
| | | |
| | |
| | | * @return |
| | | */ |
| | | public Trc20Contract contractToken(String address, String privateKey) { |
| | | ApiWrapper wrapper = ApiWrapper.ofShasta(privateKey); |
| | | ApiWrapper wrapper = ApiWrapper.ofMainnet(privateKey, Trc20Service.API_KEY); |
| | | Contract trc20Contract = wrapper.getContract(COIN_CONTRACT_ADDRESS); |
| | | return new Trc20Contract(trc20Contract, address, wrapper); |
| | | } |