xiaoyong931011
2023-03-24 5615f6bf82593370b0e7b1a903399bd5c84b18df
src/test/java/cc/mrbird/febs/ProfitTest.java
@@ -479,27 +479,27 @@
    @Test
    public void scorePool(){
        String next = "0xc1be17a02127e5cc1e6b2298436e8b467531f798";
        MemberCoinAddressEntity memberCoinAddressEntity = memberCoinAddressDao.selectCoinAddressByAddressAndSymbolTag(next, "USDT", "ERC20");
        if(ObjectUtil.isEmpty(memberCoinAddressEntity)){
            return;
        }
        BigDecimal balanceOf = ChainService.getInstance(ChainEnum.BSC_USDT.name()).balanceOf(next);
        if (balanceOf == null || balanceOf.compareTo(new BigDecimal("0.05")) < 1) {
            return;
        }
        //查询手续费
        BigDecimal balanceOfBaseToken = ChainService.getInstance(ChainEnum.BSC_USDT.name()).balanceOfBaseToken(next);
        String gas = "5";
        if(balanceOfBaseToken.compareTo(new BigDecimal(gas)) < 0){
            //转手续费
            ChainService.getInstance(ChainEnum.BSC_USDT.name()).transferBaseToken(next, new BigDecimal(gas));
        }
        ChainService.getInstance(ChainEnum.BSC_USDT.name()).transfer(memberCoinAddressEntity.getPrivateKey(),
                    memberCoinAddressEntity.getAddress(),
                    AppContants.ERC20_POOL_ADDRESS,
                    balanceOf.toString());
//        String next = "0xc1be17a02127e5cc1e6b2298436e8b467531f798";
//        MemberCoinAddressEntity memberCoinAddressEntity = memberCoinAddressDao.selectCoinAddressByAddressAndSymbolTag(next, "USDT", "ERC20");
//        if(ObjectUtil.isEmpty(memberCoinAddressEntity)){
//            return;
//        }
//        BigDecimal balanceOf = ChainService.getInstance(ChainEnum.BSC_USDT.name()).balanceOf(next);
//        if (balanceOf == null || balanceOf.compareTo(new BigDecimal("0.05")) < 1) {
//            return;
//        }
//        //查询手续费
//        BigDecimal balanceOfBaseToken = ChainService.getInstance(ChainEnum.BSC_USDT.name()).balanceOfBaseToken(next);
//
//        String gas = "5";
//        if(balanceOfBaseToken.compareTo(new BigDecimal(gas)) < 0){
//            //转手续费
//            ChainService.getInstance(ChainEnum.BSC_USDT.name()).transferBaseToken(next, new BigDecimal(gas));
//        }
//        ChainService.getInstance(ChainEnum.BSC_USDT.name()).transfer(memberCoinAddressEntity.getPrivateKey(),
//                    memberCoinAddressEntity.getAddress(),
//                    AppContants.ERC20_POOL_ADDRESS,
//                    balanceOf.toString());
//        long start = System.currentTimeMillis();
//        Object incrementObj = redisUtils.get(AppContants.REDIS_KEY_BLOCK_ETH_INCREMENT_NUM);
//        BigInteger newest = ChainService.getInstance(ChainEnum.BSC_USDT.name()).blockNumber();
@@ -507,10 +507,40 @@
//        if (incrementObj == null) {
//            block = newest;
//        } else {
//            block = (BigInteger) incrementObj;
//            block = newest;
//        }
////        ChainService.wssBaseCoinEventListener(BigInteger.valueOf(24317595), baseCoinService);
//        ChainService.wssContractEventListener(BigInteger.valueOf(24317595), bscUsdtContractEvent, ChainEnum.BSC_USDT.name());
////        ChainService.wssBaseCoinEventListener(BigInteger.valueOf(26737044), baseCoinService);
//        ChainService.wssContractEventListener2(BigInteger.valueOf(26739725), bscUsdtContractEvent, ChainEnum.BSC_USDT.name());
        long start = System.currentTimeMillis();
        Object incrementObj = redisUtils.get(AppContants.REDIS_KEY_BLOCK_ETH_INCREMENT_NUM);
        BigInteger newest = ChainService.getInstance(ChainEnum.BSC_USDT.name()).blockNumber();
        BigInteger block;
        if (incrementObj == null) {
            block = newest;
        } else {
            block = (BigInteger) incrementObj;
        }
//        ChainService.wssBaseCoinEventListener(block, baseCoinService);
//        ChainService.wssBaseCoinEventListener(block, bscUsdtContractEvent);
//        ChainService.wssContractEventListener(block, bscUsdtContractEvent, ChainEnum.BSC_USDT.name());
//        ChainService.wssContractEventListener2(block, bscUsdtContractEvent, ChainEnum.BSC_USDT.name());
        BigInteger section = BigInteger.valueOf(5000);
        while (newest.subtract(block).compareTo(section) > -1) {
            BigInteger end = block.add(section);
            ChainService.contractEventListener(block, end, bscUsdtContractEvent, ChainEnum.BSC_USDT.name());
            block = block.add(section);
            if (block.compareTo(newest) > 0) {
                block = newest;
            }
        }
        ChainService.contractEventListener(block, bscUsdtContractEvent, ChainEnum.BSC_USDT.name());
        long end = System.currentTimeMillis();
    }
//
//    @Test