|
@@ -75,6 +75,8 @@ async function setWeb3apiRateLimit() {
|
|
|
logger.error('setWeb3apiRateLimit error')
|
|
|
}
|
|
|
|
|
|
+// initMasterSDK()
|
|
|
+// initMoralisSecretSDK()
|
|
|
|
|
|
function toJson(code_, obj_, errMsg_) {
|
|
|
return utils.toJson(code_, obj_, errMsg_);
|
|
@@ -338,16 +340,17 @@ async function computeTransferGasFree(obj, my_account_all_coins, tokenPrices) {
|
|
|
}
|
|
|
// });
|
|
|
}
|
|
|
- logger.log('account_config.TOKEN_GAS_LIMIT=', account_config.TOKEN_GAS_LIMIT);
|
|
|
+ var lastTokenPrice = await redis.readRedis(reids_token_config.LAST_TOKEN_PRICE)
|
|
|
|
|
|
- var lastTokenFree = await redis.readRedis(reids_token_config.LAST_TOTAL_TOKEN_FREE)
|
|
|
- logger.log('LAST_TOTAL_TOKEN_FREE=', lastTokenFree);
|
|
|
- if (lastTokenFree && reids_token_config.LAST_TOTAL_TOKEN_FREE && parseInt(lastTokenFree) > 0) {
|
|
|
- tokenGasPrice = parseInt(tokenCount) * parseInt(lastTokenFree);
|
|
|
+ logger.log('LAST_TOKEN_PRICE=', lastTokenPrice);
|
|
|
+
|
|
|
+ if (lastTokenPrice && parseInt(lastTokenPrice) > 0) {
|
|
|
+ tokenGasPrice = parseInt(tokenCount) * parseInt(lastTokenPrice) * parseInt(account_config.TOKEN_GAS_LIMIT);
|
|
|
+ ret_a_gas = lastTokenPrice;
|
|
|
} else {
|
|
|
- tokenGasPrice = parseInt(tokenCount) * parseInt(account_config.TOKEN_GAS_LIMIT) * parseInt(account_config.BNB_GAS_PRICE);
|
|
|
+ tokenGasPrice = parseInt(tokenCount) * parseInt(account_config.TOKEN_GAS_LIMIT) * parseInt(account_config.TOKEN_GAS_PRICE);
|
|
|
+ ret_a_gas = account_config.TOKEN_GAS_PRICE;
|
|
|
}
|
|
|
- ret_a_gas = account_config.BNB_GAS_PRICE;
|
|
|
logger.log('tokenGasPrice=', tokenGasPrice);
|
|
|
}
|
|
|
|
|
@@ -370,14 +373,15 @@ async function computeTransferGasFree(obj, my_account_all_coins, tokenPrices) {
|
|
|
nativeCount = 1;
|
|
|
logger.log('native > 1.0', tokenCount);
|
|
|
|
|
|
- var lastBnbFree = await redis.readRedis(reids_token_config.LAST_TOTAL_BNB_FREE)
|
|
|
- logger.log('LAST_TOTAL_BNB_FREE=', lastBnbFree);
|
|
|
- if (lastBnbFree && parseInt(lastBnbFree) > 0) {
|
|
|
- nativeGasPrice = parseInt(nativeCount) * parseInt(lastBnbFree);
|
|
|
+ var lastBnbPrice = await redis.readRedis(reids_token_config.LAST_BNB_PRICE)
|
|
|
+ logger.log('LAST_BNB_PRICE=', lastBnbPrice);
|
|
|
+ if (lastBnbPrice && parseInt(lastBnbPrice) > 0) {
|
|
|
+ nativeGasPrice = parseInt(nativeCount) * parseInt(lastBnbPrice) * parseInt(account_config.BNB_GAS_LIMIT);
|
|
|
+ ret_a_gas = lastBnbPrice;
|
|
|
} else {
|
|
|
nativeGasPrice = parseInt(nativeCount) * parseInt(account_config.BNB_GAS_LIMIT) * parseInt(account_config.BNB_GAS_PRICE);
|
|
|
+ ret_a_gas = parseInt(account_config.BNB_GAS_PRICE);
|
|
|
}
|
|
|
- ret_a_gas = account_config.BNB_GAS_PRICE;
|
|
|
|
|
|
// var real_native_amount = BigInt(nativeAllBalance) - BigInt(nativeGasPrice) - BigInt(tokenGasPrice);
|
|
|
var real_native_amount = BigInt(nativeAllBalance);
|
|
@@ -648,11 +652,11 @@ const transfer_handle = async (obj) => {
|
|
|
if (ret && obj.contractAddress) {
|
|
|
var tr = getTransferGasFree('token', ret)
|
|
|
logger.debug('cache setkey token LAST_TOTAL_TOKEN_FREE getTransferGasFree', tr)
|
|
|
- redis.redis_set(reids_token_config.LAST_TOTAL_TOKEN_FREE, tr.totalGasFree);
|
|
|
+ redis.redis_set(reids_token_config.LAST_TOKEN_PRICE, tr.gasFee);
|
|
|
} else {
|
|
|
var tr = getTransferGasFree('native', ret)
|
|
|
logger.debug('cache setkey LAST_TOTAL_BNB_FREE getTransferGasFree', tr)
|
|
|
- redis.redis_set(reids_token_config.LAST_TOTAL_BNB_FREE, tr.totalGasFree);
|
|
|
+ redis.redis_set(reids_token_config.LAST_BNB_PRICE, tr.gasFee);
|
|
|
}
|
|
|
} else {
|
|
|
var tm_obj = { ...obj }
|
|
@@ -714,7 +718,7 @@ const collectCoins = async (obj) => {
|
|
|
logParams.addressBalances = { ...my_account_all_coins };
|
|
|
|
|
|
//得到币价格
|
|
|
- if (process.env.NODE_ENV == 'dev') {
|
|
|
+ if (process.env.NODE_ENV != 'dev') {
|
|
|
var test_json = '{"tokenPrice": [{"contract": "0x0000000000000000000000000000000000000000", "usdPrice": 400}, {"contract": "0x03716F32f72c692a0B355fa04639669E3341B94e", "usdPrice": 0.1}]}'
|
|
|
obj.tokenPrices = JSON.parse(test_json);
|
|
|
} else {
|