| | |
| | | */
|
| | | public static final String REDIS_KEY_MINE_TRANSFER_POOL_TRADE_CNT = "MINE_TRANSFER_POOL_TRADE_CNT";
|
| | |
|
| | | public static final String REDIS_KEY_BLOCK_COIN_NUM = "BLOCK_COIN_NUM";
|
| | | public static final String REDIS_KEY_BLOCK_USDT_NUM = "BLOCK_USDT_NUM";
|
| | |
|
| | |
|
| | | public static final String DIC_TYPE_DISTRIBUTE_PROP = "DISTRIBUTE_PROP";
|
| | | public static final String DIC_TYPE_SYSTEM_SETTING = "SYSTEM_SETTING";
|
| | | public static final String DIC_TYPE_SLIP_POINT_SETTING = "SLIP_POINT_SETTING";
|
| | |
|
| | | public static final String DIC_VALUE_MINI_HOLD_COIN_LIMIT = "MINI_HOLD_COIN_LIMIT";
|
| | | public static final String DIC_VALUE_SYSTEM_START_TARGET = "SYSTEM_START_TARGET";
|
| | | public static final String DIC_VALUE_SYSTEM_SOURCE_POOL_VOL = "SYSTEM_SOURCE_POOL_VOL";
|
| | | public static final String DIC_VALUE_SYSTEM_NODE_CNT_LIMIT = "SYSTEM_NODE_CNT_LIMIT";
|
| | |
|
| | | public static final String DESTROY_ADDRESS = "0x0000000000000000000000000000000000000000";
|
| | | }
|
| | |
| | | |
| | | /** |
| | | * 币安 usdt合约 |
| | | * 0x55d398326f99059fF775485246999027B3197955 |
| | | */ |
| | | BSC_USDT("BSC", "0x971c09aA9735EB98459B17EC8b48932D24CbB931", |
| | | "0x5f38d0e63157f535fc21f89ea13ec3cd245691c20795c1d2cb60233b3ba7bb47", |
| | | "https://bsc-dataseed1.ninicoin.io", |
| | | "0x55d398326f99059fF775485246999027B3197955", |
| | | "https://data-seed-prebsc-2-s2.binance.org:8545", |
| | | "0x337610d27c682E347C9cD60BD4b3b107C9d34dDd", |
| | | ""), |
| | | |
| | | /** |
| | |
| | | */ |
| | | BSC_TFC("BSC", "0x977a9ddfb965a9a3416fa72ca7f91c4949c18f25", |
| | | "0xefe98e00cd227b6322e892c82fcbd8eadf119c3188b7e574bc624f65405d61bf", |
| | | "https://bsc-dataseed1.ninicoin.io", |
| | | "0x6c6835e60e7dbad7a60112a6371271e8eb79ee68", |
| | | "https://data-seed-prebsc-2-s2.binance.org:8545", |
| | | "0xdd92ea2f41d807a60b29004bf7db807d8ac09212", |
| | | ""), |
| | | |
| | | /** |
| | |
| | | */ |
| | | BSC_TFC_SOURCE("BSC", "0x977a9ddfb965a9a3416fa72ca7f91c4949c18f25", |
| | | "0xefe98e00cd227b6322e892c82fcbd8eadf119c3188b7e574bc624f65405d61bf", |
| | | "https://bsc-dataseed1.ninicoin.io", |
| | | "0x6c6835e60e7dbad7a60112a6371271e8eb79ee68", |
| | | "https://data-seed-prebsc-2-s2.binance.org:8545", |
| | | "0xdd92ea2f41d807a60b29004bf7db807d8ac09212", |
| | | ""), |
| | | |
| | | /** |
| | | * 源池U |
| | | */ |
| | | BSC_USDT_SOURCE("BSC", "0x977a9ddfb965a9a3416fa72ca7f91c4949c18f25", |
| | | "0xefe98e00cd227b6322e892c82fcbd8eadf119c3188b7e574bc624f65405d61bf", |
| | | "https://bsc-dataseed1.ninicoin.io", |
| | | "0x55d398326f99059fF775485246999027B3197955", |
| | | BSC_USDT_SOURCE("BSC", "0x4EbDCA102623b46a47042D580dddAdE2a53D057F", |
| | | "0x81c2c02d0c106c1e32ab060a37f6eb279c0649c30ea5cc1c4951e6a8dd4e963c", |
| | | "https://data-seed-prebsc-2-s2.binance.org:8545", |
| | | "0x337610d27c682E347C9cD60BD4b3b107C9d34dDd", |
| | | ""), |
| | | |
| | | /** |
| | | * 铸池币 |
| | | */ |
| | | BSC_TFC_MAKE("BSC", "0x977a9ddfb965a9a3416fa72ca7f91c4949c18f25", |
| | | "0xefe98e00cd227b6322e892c82fcbd8eadf119c3188b7e574bc624f65405d61bf", |
| | | "https://bsc-dataseed1.ninicoin.io", |
| | | "0x6c6835e60e7dbad7a60112a6371271e8eb79ee68", |
| | | BSC_TFC_MAKE("BSC", "0xBae24dAa3aB94cfF8114a16A4267D769b3a651F8", |
| | | "0xc0cabaf5f1fce227e5f1b8a7f83a5dc28972389ffc59559d7852ce8d27c3bec4", |
| | | "https://data-seed-prebsc-2-s2.binance.org:8545", |
| | | "0xdd92ea2f41d807a60b29004bf7db807d8ac09212", |
| | | ""), |
| | | |
| | | /** |
| | | * 技术池 |
| | | */ |
| | | BSC_TFC_TECH("BSC", "0x977a9ddfb965a9a3416fa72ca7f91c4949c18f25", |
| | | BSC_TFC_TECH("BSC", "0xD998DA7362360eFC6daDFEd6E9a32E70640d7600", |
| | | "", |
| | | "https://bsc-dataseed1.ninicoin.io", |
| | | "0x6c6835e60e7dbad7a60112a6371271e8eb79ee68", |
| | | "https://data-seed-prebsc-2-s2.binance.org:8545", |
| | | "0xdd92ea2f41d807a60b29004bf7db807d8ac09212", |
| | | ""); |
| | | |
| | | private String chain; |
| | |
| | | * 账号类型 admin normal |
| | | */ |
| | | private String accountType; |
| | | |
| | | private BigDecimal usdtBalance; |
| | | } |
| | |
| | | void setNewestPrice(PriceSettingDto priceSettingDto); |
| | | |
| | | DappMemberEntity insertMember(String address, String refererId); |
| | | |
| | | DappMemberEntity insertMember(String address, String refererId, String chainType, String accountType); |
| | | } |
| | |
| | | package cc.mrbird.febs.dapp.service.impl; |
| | | |
| | | import cc.mrbird.febs.common.contants.AppContants; |
| | | import cc.mrbird.febs.common.utils.RedisUtils; |
| | | import cc.mrbird.febs.common.utils.ShareCodeUtil; |
| | | import cc.mrbird.febs.dapp.chain.ChainEnum; |
| | | import cc.mrbird.febs.dapp.chain.ChainService; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.web3j.utils.Numeric; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | |
| | | @Resource |
| | | private DappFundFlowDao dappFundFlowDao; |
| | | |
| | | @Resource |
| | | private RedisUtils redisUtils; |
| | | |
| | | private final String ADDRESS = "0x977a9ddfb965a9a3416fa72ca7f91c4949c18f25"; |
| | | |
| | | public static void main(String[] args) { |
| | | System.out.println(Numeric.toBigInt("0x12e4e85")); |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public void compile(EthUsdtContract.TransferEventResponse e) { |
| | | int decimals = ChainService.getInstance(ChainEnum.BSC_TFC.name()).decimals(); |
| | | if (e.to != null) { |
| | | redisUtils.set(AppContants.REDIS_KEY_BLOCK_COIN_NUM, e.log.getBlockNumber()); |
| | | int decimals = ChainService.getInstance(ChainEnum.BSC_TFC.name()).decimals(); |
| | | |
| | | // 合约创建时,同时创建地址 |
| | | if ("0x0000000000000000000000000000000000000000".equals(e.from)) { |
| | | DappMemberEntity toMember = dappMemberDao.selectByAddress(e.to, null); |
| | | if (toMember == null) { |
| | | toMember = dappMemberService.insertMember(e.to, "0"); |
| | | toMember = dappMemberService.insertMember(e.to, "0", "BSC", "admin"); |
| | | } |
| | | return; |
| | | } |
| | |
| | | import cc.mrbird.febs.dapp.entity.DappFundFlowEntity; |
| | | import cc.mrbird.febs.dapp.entity.DappMemberEntity; |
| | | import cc.mrbird.febs.dapp.entity.DappOnlineTransferEntity; |
| | | import cc.mrbird.febs.dapp.entity.DataDictionaryCustom; |
| | | import cc.mrbird.febs.dapp.mapper.DappFundFlowDao; |
| | | import cc.mrbird.febs.dapp.mapper.DappMemberDao; |
| | | import cc.mrbird.febs.dapp.mapper.DappOnlineTransferDao; |
| | | import cc.mrbird.febs.dapp.mapper.DataDictionaryCustomMapper; |
| | | import cc.mrbird.febs.dapp.service.DappMemberService; |
| | | import cc.mrbird.febs.rabbit.producer.ChainProducer; |
| | | import cn.hutool.core.util.StrUtil; |
| | |
| | | |
| | | @Resource |
| | | private DappOnlineTransferDao dappOnlineTransferDao; |
| | | @Resource |
| | | private DataDictionaryCustomMapper dataDictionaryCustomMapper; |
| | | |
| | | |
| | | @Override |
| | | public void compile(EthUsdtContract.TransferEventResponse e) { |
| | | ContractChainService sourceUsdtInstance = ChainService.getInstance(ChainEnum.BSC_USDT.name()); |
| | | int decimals = sourceUsdtInstance.decimals(); |
| | | int tfcDecimals = ChainService.getInstance(ChainEnum.BSC_TFC.name()).decimals(); |
| | | if (e.to == null) { |
| | | return; |
| | | } |
| | | |
| | | redisUtils.set(AppContants.REDIS_KEY_BLOCK_USDT_NUM, e.log.getBlockNumber()); |
| | | // 判断对方打款地址是否为源池地址 |
| | | if (ChainEnum.BSC_TFC_SOURCE.getAddress().equals(e.to)) { |
| | | ContractChainService sourceUsdtInstance = ChainService.getInstance(ChainEnum.BSC_USDT.name()); |
| | | int decimals = sourceUsdtInstance.decimals(); |
| | | int tfcDecimals = ChainService.getInstance(ChainEnum.BSC_TFC.name()).decimals(); |
| | | |
| | | if (e.from.equals("0xaa25aa7a19f9c426e07dee59b12f944f4d9f1dd3")) { |
| | | return; |
| | | } |
| | | |
| | | DappMemberEntity fromMember = dappMemberService.findByAddress(e.from, null); |
| | | // 如果此时fromMember为null,则说明该用户未经过转账绑定关系,而是直接注册并购买币,则将关系绑定到顶级账户 |
| | | if (fromMember == null) { |
| | |
| | | chainProducer.sendOnlineTransfer(JSONObject.toJSONString(map)); |
| | | } |
| | | |
| | | DataDictionaryCustom dic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(AppContants.DIC_TYPE_SYSTEM_SETTING, AppContants.DIC_VALUE_SYSTEM_START_TARGET); |
| | | BigDecimal target = new BigDecimal(dic.getValue()); |
| | | |
| | | // 若源池中的USDT达到或超过8万U,则启动整个系统 |
| | | BigDecimal balance = sourceUsdtInstance.balanceOf(ChainEnum.BSC_USDT_SOURCE.getAddress()); |
| | | if (BigDecimal.valueOf(80000).compareTo(balance) < 1) { |
| | | if (target.compareTo(balance) < 1) { |
| | | redisUtils.set(AppContants.SYSTEM_START_FLAG, "start"); |
| | | } |
| | | } |
| | |
| | | import cc.mrbird.febs.common.utils.LoginUserUtil; |
| | | import cc.mrbird.febs.common.utils.RedisUtils; |
| | | import cc.mrbird.febs.common.utils.ShareCodeUtil; |
| | | import cc.mrbird.febs.dapp.chain.ChainEnum; |
| | | import cc.mrbird.febs.dapp.chain.ChainService; |
| | | import cc.mrbird.febs.dapp.chain.ContractChainService; |
| | | import cc.mrbird.febs.dapp.dto.ApproveDto; |
| | | import cc.mrbird.febs.dapp.dto.ConnectDto; |
| | | import cc.mrbird.febs.dapp.dto.PriceSettingDto; |
| | | import cc.mrbird.febs.dapp.entity.DappMemberEntity; |
| | | import cc.mrbird.febs.dapp.entity.DappTransferRecordEntity; |
| | | import cc.mrbird.febs.dapp.entity.DappWalletCoinEntity; |
| | | import cc.mrbird.febs.dapp.entity.DappWalletMineEntity; |
| | | import cc.mrbird.febs.dapp.mapper.DappMemberDao; |
| | | import cc.mrbird.febs.dapp.mapper.DappTransferRecordDao; |
| | | import cc.mrbird.febs.dapp.mapper.DappWalletCoinDao; |
| | | import cc.mrbird.febs.dapp.mapper.DappWalletMineDao; |
| | | import cc.mrbird.febs.dapp.entity.*; |
| | | import cc.mrbird.febs.dapp.mapper.*; |
| | | import cc.mrbird.febs.dapp.service.DappMemberService; |
| | | import cc.mrbird.febs.system.entity.User; |
| | | import cn.hutool.core.collection.CollUtil; |
| | |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | |
| | | private final DappWalletMineDao dappWalletMineDao; |
| | | private final DappTransferRecordDao dappTransferRecordDao; |
| | | private final RedisUtils redisUtils; |
| | | private final DataDictionaryCustomMapper dataDictionaryCustomMapper; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | |
| | | @Override |
| | | public DappMemberEntity insertMember(String address, String refererId) { |
| | | |
| | | return insertMember(address, refererId, "BSC", "normal"); |
| | | } |
| | | |
| | | @Override |
| | | public DappMemberEntity insertMember(String address, String refererId, String chainType, String accountType) { |
| | | DappMemberEntity member = new DappMemberEntity(); |
| | | member.setAddress(address); |
| | | member.setChainType(chainType); |
| | | member.setAccountType(accountType); |
| | | member.setBalance(ChainService.getInstance(ChainEnum.BSC_TFC.name()).balanceOf(address)); |
| | | member.setUsdtBalance(ChainService.getInstance(ChainEnum.BSC_USDT.name()).balanceOf(address)); |
| | | |
| | | DataDictionaryCustom dic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(AppContants.DIC_TYPE_SYSTEM_SETTING, AppContants.DIC_VALUE_SYSTEM_NODE_CNT_LIMIT); |
| | | int nodeCntLimit = Integer.parseInt(dic.getValue()); |
| | | |
| | | List<DappMemberEntity> memberCount = dappMemberDao.selectList(null); |
| | | if (memberCount.size() <= (nodeCntLimit + 4)) { |
| | | member.setNodeType(1); |
| | | } else { |
| | | member.setNodeType(2); |
| | | } |
| | | |
| | | dappMemberDao.insert(member); |
| | | |
| | |
| | | package cc.mrbird.febs.job; |
| | | |
| | | import cc.mrbird.febs.common.contants.AppContants; |
| | | import cc.mrbird.febs.common.utils.RedisUtils; |
| | | import cc.mrbird.febs.dapp.chain.ChainEnum; |
| | | import cc.mrbird.febs.dapp.chain.ChainService; |
| | | import cc.mrbird.febs.dapp.chain.ContractEventService; |
| | |
| | | @Autowired |
| | | private ContractEventService bscUsdtContractEvent; |
| | | |
| | | @Autowired |
| | | private RedisUtils redisUtils; |
| | | |
| | | @PostConstruct |
| | | public void chainListenerJob() { |
| | | log.info("监听打开"); |
| | | // ChainService.contractEventListener(new BigInteger("18097238"), bscUsdtContractEvent, ChainEnum.BSC_USDT.name()); |
| | | // ChainService.contractEventListener(new BigInteger("18097238"), bscCoinContractEvent, ChainEnum.BSC_TFC.name()); |
| | | BigInteger usdtBlock; |
| | | BigInteger coinBlock; |
| | | Object usdt = redisUtils.get(AppContants.REDIS_KEY_BLOCK_USDT_NUM); |
| | | if (usdt == null) { |
| | | usdtBlock = new BigInteger("19811973"); |
| | | } else { |
| | | usdtBlock = (BigInteger) usdt; |
| | | } |
| | | |
| | | Object coin = redisUtils.get(AppContants.REDIS_KEY_BLOCK_COIN_NUM); |
| | | if (coin == null) { |
| | | coinBlock = new BigInteger("19811973"); |
| | | } else { |
| | | coinBlock = (BigInteger) coin; |
| | | } |
| | | |
| | | ChainService.contractEventListener(usdtBlock, bscUsdtContractEvent, ChainEnum.BSC_USDT.name()); |
| | | ChainService.contractEventListener(coinBlock, bscCoinContractEvent, ChainEnum.BSC_TFC.name()); |
| | | } |
| | | } |
| | |
| | | import cc.mrbird.febs.common.utils.RedisUtils; |
| | | import cc.mrbird.febs.dapp.chain.ChainEnum; |
| | | import cc.mrbird.febs.dapp.chain.ChainService; |
| | | import cc.mrbird.febs.dapp.entity.DataDictionaryCustom; |
| | | import cc.mrbird.febs.dapp.mapper.DataDictionaryCustomMapper; |
| | | import cc.mrbird.febs.dapp.service.DappSystemService; |
| | | import cc.mrbird.febs.dapp.vo.RedisTransferPoolVo; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | |
| | |
| | | private RedisUtils redisUtils; |
| | | @Autowired |
| | | private DappSystemService systemService; |
| | | @Resource |
| | | private DataDictionaryCustomMapper dataDictionaryCustomMapper; |
| | | |
| | | // 最低容量(百分比) |
| | | private final BigDecimal volProp = new BigDecimal("0.5"); |
| | | |
| | | private final BigDecimal basic_vol = BigDecimal.valueOf(1200000); |
| | | |
| | | /** |
| | | * 中转池容量计算 |
| | |
| | | @Scheduled(cron = "0 0 0 * * ?") |
| | | public void transferPoolVol() { |
| | | log.info("中转池容量"); |
| | | |
| | | // 源池初始化容量 |
| | | DataDictionaryCustom dic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(AppContants.DIC_TYPE_SYSTEM_SETTING, AppContants.DIC_VALUE_SYSTEM_SOURCE_POOL_VOL); |
| | | BigDecimal basicVol = new BigDecimal(dic.getValue()); |
| | | |
| | | Object o = redisUtils.get(AppContants.REDIS_KEY_TRANSFER_POOL_VOL); |
| | | if (o == null) { |
| | | RedisTransferPoolVo transferPool= new RedisTransferPoolVo(); |
| | | BigDecimal total = basic_vol.multiply(volProp.divide(BigDecimal.valueOf(100), 4, RoundingMode.HALF_UP)); |
| | | BigDecimal total = basicVol.multiply(volProp.divide(BigDecimal.valueOf(100), 4, RoundingMode.HALF_UP)); |
| | | transferPool.setTodayVol(total); |
| | | transferPool.setTodayProp(volProp); |
| | | transferPool.setFinishCnt(0); |
| | |
| | | transferPool.setFinishCnt(finishCnt); |
| | | } |
| | | |
| | | BigDecimal total = basic_vol.multiply(targetProp.divide(BigDecimal.valueOf(100), 4, RoundingMode.HALF_UP)); |
| | | BigDecimal total = basicVol.multiply(targetProp.divide(BigDecimal.valueOf(100), 4, RoundingMode.HALF_UP)); |
| | | transferPool.setTodayVol(total); |
| | | transferPool.setUnFinishCnt(0); |
| | | redisUtils.set(AppContants.REDIS_KEY_TRANSFER_POOL_VOL_REMAIN, total); |
| | |
| | | transferPool.setUnFinishCnt(unFinishCnt); |
| | | } |
| | | BigDecimal aa = targetProp.divide(BigDecimal.valueOf(100), 4, RoundingMode.HALF_UP); |
| | | BigDecimal total = basic_vol.multiply(aa); |
| | | BigDecimal total = basicVol.multiply(aa); |
| | | transferPool.setTodayVol(total); |
| | | redisUtils.set(AppContants.REDIS_KEY_TRANSFER_POOL_VOL_REMAIN, total); |
| | | } |