| 
					
				 | 
			
			
				@@ -12,7 +12,7 @@ WITHDRAWFEEUSD = 0.5 #提现手续费,标的是usdt单位 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 WITHDRAWCOUNTBYFEE = 2 #提现所需对应手续费token数量的倍数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-TOKENPRICE = 'TOKENPRICE' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+TOKENPRICE = 'TOKENPRICE_' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 TOKENPRICEDICT = 'TOKENPRICEDICT' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 TOKENWITHDRAW = 'TOKENWITHDRAW' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -30,9 +30,9 @@ REDIS_TEST = 'denet-test.y2slbl.clustercfg.memorydb.us-east-1.amazonaws.com' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 REDIS_ONLINE = 'denet-chain-prod.y2slbl.clustercfg.memorydb.us-east-1.amazonaws.com' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 r = RedisCluster(host=REDIS_ONLINE, port=6379, decode_responses=True, skip_full_coverage_check=True) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-def getTokenList(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+def getTokenList(fp): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     l = [] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    with open('/home/sh/token.txt') as f: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    with open(fp) as f: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     #with open('token.txt') as f: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         for line in f: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             l.append(line.strip()) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -50,10 +50,17 @@ def getPrice(contract): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     response = requests.get(f'https://deep-index.moralis.io/api/v2/erc20/{contract}/price', headers=headers, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             params=params) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    print(contract,response) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     result = response.json() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     print(result) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    usdPrice = result['usdPrice'] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    bnbPrice = int(result['nativePrice']['value'])/1000000000000000000 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    try: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        usdPrice = result['usdPrice'] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        bnbPrice = int(result['nativePrice']['value'])/1000000000000000000 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    except: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if contract == '0xfc9F81B107F51F2383fCE56650fEDB59C5fd59bD': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            usdPrice = 0.24 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            bnbPrice = 0.00074 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     try: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         priceOfBnb = usdPrice/bnbPrice 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     except: 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -61,10 +68,10 @@ def getPrice(contract): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     # print(contract, usdPrice, bnbPrice, priceOfBnb) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     return {'contract':contract, 'usdPrice':usdPrice}, priceOfBnb 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-def getAllPrice(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+def getAllPrice(chain, fp): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     l = [] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     bnbPrice = 0 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    tokenList = getTokenList() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    tokenList = getTokenList(fp) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     for i in tokenList: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         time.sleep(1) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         info, bnb = getPrice(i) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -73,12 +80,12 @@ def getAllPrice(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             bnbPrice = bnb 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     l.append({'contract':BNBCONTRACT, 'usdPrice':bnbPrice}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     l.append({'contract':DEPROCONTRACT, 'usdPrice':DEPROPRICE}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    r.set(TOKENPRICE, json.dumps({'tokenPrice':l})) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    r.set(TOKENPRICE+chain, json.dumps({'tokenPrice':l})) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     return l 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-def getWithdrawFees(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+def getWithdrawFees(chain, fp): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     l = [] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    priceList = getAllPrice() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    priceList = getAllPrice(chain, fp) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     for i in priceList: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        print(i) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        contract = i['contract'] 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -88,7 +95,7 @@ def getWithdrawFees(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     r.set(TOKENWITHDRAW, json.dumps({'tokenWithdraw':l})) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     return l 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-getWithdrawFees() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+getWithdrawFees("BSC", '/home/sh/token.txt') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 print(r.get(TOKENPRICE)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 print(r.get(TOKENWITHDRAW)) 
			 |