Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
python_open_ai
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
haojie
python_open_ai
Commits
8824f6b0
Commit
8824f6b0
authored
Apr 10, 2023
by
lei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
a61d5385
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
12 deletions
+19
-12
Helper.py
+19
-12
No files found.
Helper.py
View file @
8824f6b0
...
@@ -17,7 +17,7 @@ from aredis import StrictRedis, ConnectionPool
...
@@ -17,7 +17,7 @@ from aredis import StrictRedis, ConnectionPool
from
web3._utils.abi
import
get_abi_output_types
,
map_abi_data
from
web3._utils.abi
import
get_abi_output_types
,
map_abi_data
from
web3._utils.normalizers
import
BASE_RETURN_NORMALIZERS
from
web3._utils.normalizers
import
BASE_RETURN_NORMALIZERS
uni256Max
=
2
**
256
uni256Max
=
2
**
256
class
RedisConnSingleton
(
object
):
class
RedisConnSingleton
(
object
):
...
@@ -31,7 +31,8 @@ class RedisConnSingleton(object):
...
@@ -31,7 +31,8 @@ class RedisConnSingleton(object):
:param kwargs:
:param kwargs:
"""
"""
if
cls
.
_instance
is
None
:
if
cls
.
_instance
is
None
:
cls
.
_instance
=
redis
.
ConnectionPool
(
max_connections
=
1000
,
host
=
'114.132.50.141'
,
port
=
6379
,
db
=
0
,
password
=
'lhj123456'
)
cls
.
_instance
=
redis
.
ConnectionPool
(
max_connections
=
1000
,
host
=
'42.194.143.229'
,
port
=
6379
,
db
=
0
,
password
=
'a123456,a'
)
return
cls
.
_instance
return
cls
.
_instance
...
@@ -46,7 +47,8 @@ class RedisConnectionPoolSingleton(object):
...
@@ -46,7 +47,8 @@ class RedisConnectionPoolSingleton(object):
:param kwargs:
:param kwargs:
"""
"""
if
cls
.
_instance
is
None
:
if
cls
.
_instance
is
None
:
cls
.
_instance
=
ConnectionPool
(
max_connections
=
1000
,
host
=
'114.132.50.141'
,
port
=
6379
,
db
=
0
,
password
=
'lhj123456'
)
cls
.
_instance
=
ConnectionPool
(
max_connections
=
1000
,
host
=
'42.194.143.229'
,
port
=
6379
,
db
=
0
,
password
=
'a123456,a'
)
return
cls
.
_instance
return
cls
.
_instance
...
@@ -190,13 +192,15 @@ class RedisCon:
...
@@ -190,13 +192,15 @@ class RedisCon:
class
Helper
:
class
Helper
:
"""公共基础类"""
"""公共基础类"""
@staticmethod
@staticmethod
def
getProxyLst
():
def
getProxyLst
():
"""获取代理列表"""
"""获取代理列表"""
proxy_lst
=
list
()
proxy_lst
=
list
()
for
i
in
range
(
5
):
for
i
in
range
(
5
):
try
:
try
:
response
=
requests
.
get
(
"https://proxy.webshare.io/api/v2/proxy/list/download/pgewrawzvvqtzwdzjfdfswvkwcjasmofoucnfyyq/-/any/username/direct/-/"
)
.
text
response
=
requests
.
get
(
"https://proxy.webshare.io/api/v2/proxy/list/download/pgewrawzvvqtzwdzjfdfswvkwcjasmofoucnfyyq/-/any/username/direct/-/"
)
.
text
a
=
response
.
split
(
'
\r\n
'
)
a
=
response
.
split
(
'
\r\n
'
)
proxy_lst
=
a
[:
-
1
]
proxy_lst
=
a
[:
-
1
]
proxy_lst
=
list
(
map
(
lambda
x
:
x
.
split
(
":"
),
proxy_lst
))
proxy_lst
=
list
(
map
(
lambda
x
:
x
.
split
(
":"
),
proxy_lst
))
...
@@ -946,10 +950,10 @@ class Helper:
...
@@ -946,10 +950,10 @@ class Helper:
:param pDecimals
:param pDecimals
:param web_async
:param web_async
"""
"""
busd_bsc
=
"0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56"
# BUSD (bsc)
busd_bsc
=
"0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56"
# BUSD (bsc)
weth_bsc
=
"0x2170Ed0880ac9A755fd29B2688956BD959F933F8"
# ETH (bsc)
weth_bsc
=
"0x2170Ed0880ac9A755fd29B2688956BD959F933F8"
# ETH (bsc)
wbtc_bsc
=
"0x7130d2A12B9BCbFAe4f2634d864A1Ee1Ce3Ead9c"
# BTCB (bsc)
wbtc_bsc
=
"0x7130d2A12B9BCbFAe4f2634d864A1Ee1Ce3Ead9c"
# BTCB (bsc)
router_bsc
=
"0x10ED43C718714eb63d5aA57B78B54704E256024E"
# pancakeSwapV2Router
router_bsc
=
"0x10ED43C718714eb63d5aA57B78B54704E256024E"
# pancakeSwapV2Router
redis_con
=
StrictRedis
(
connection_pool
=
RedisConnectionPoolSingleton
())
redis_con
=
StrictRedis
(
connection_pool
=
RedisConnectionPoolSingleton
())
rate
=
await
redis_con
.
get
(
f
'{redisKey}:rate:'
+
pSymbol
+
'-U'
)
rate
=
await
redis_con
.
get
(
f
'{redisKey}:rate:'
+
pSymbol
+
'-U'
)
opType
=
[
'opt'
,
'can'
]
opType
=
[
'opt'
,
'can'
]
...
@@ -1100,7 +1104,8 @@ class Helper:
...
@@ -1100,7 +1104,8 @@ class Helper:
return
amountIn
,
amountOut
return
amountIn
,
amountOut
@staticmethod
@staticmethod
async
def
get_usd_price_V2
(
p_token
,
p_token_d
,
p_token_symbol
,
price
,
usd_token
,
uToken
,
redisKey
,
Router
,
uDecimals
,
web_async
):
async
def
get_usd_price_V2
(
p_token
,
p_token_d
,
p_token_symbol
,
price
,
usd_token
,
uToken
,
redisKey
,
Router
,
uDecimals
,
web_async
):
"""
"""
get usd price
get usd price
...
@@ -1124,7 +1129,8 @@ class Helper:
...
@@ -1124,7 +1129,8 @@ class Helper:
return
usd_price
return
usd_price
@staticmethod
@staticmethod
async
def
get_token_detail
(
p_token
,
p_token_d
,
p_token_symbol
,
pool_address
,
usd_token
,
wToken
,
wDecimals
,
uToken
,
uDecimals
,
redisKey
,
Router
,
swapType
,
p_amount
,
web_async
):
async
def
get_token_detail
(
p_token
,
p_token_d
,
p_token_symbol
,
pool_address
,
usd_token
,
wToken
,
wDecimals
,
uToken
,
uDecimals
,
redisKey
,
Router
,
swapType
,
p_amount
,
web_async
):
"""
"""
get token info
get token info
...
@@ -1212,7 +1218,8 @@ class Helper:
...
@@ -1212,7 +1218,8 @@ class Helper:
await
Helper
.
task_list
(
'chain:holderQueue'
,
json
.
dumps
(
data_
))
await
Helper
.
task_list
(
'chain:holderQueue'
,
json
.
dumps
(
data_
))
else
:
else
:
await
Helper
.
task_list
(
'chain:holderQueue'
,
json
.
dumps
(
data_
))
await
Helper
.
task_list
(
'chain:holderQueue'
,
json
.
dumps
(
data_
))
await
Helper
.
redis_data
(
data
,
token_detail
,
ts_
,
redisKey
,
public_token
,
chainId
,
stable
,
search_table
,
web_async
)
await
Helper
.
redis_data
(
data
,
token_detail
,
ts_
,
redisKey
,
public_token
,
chainId
,
stable
,
search_table
,
web_async
)
@staticmethod
@staticmethod
def
get_time
():
def
get_time
():
...
@@ -1467,7 +1474,7 @@ class Helper:
...
@@ -1467,7 +1474,7 @@ class Helper:
:return:
:return:
"""
"""
bsc
=
"https://rpc.ankr.com/bsc"
bsc
=
"https://rpc.ankr.com/bsc"
# proxy = Helper.aiohttp_proxy_pool()
# proxy = Helper.aiohttp_proxy_pool()
# request_kwargs={"proxy": proxy}
# request_kwargs={"proxy": proxy}
web_async
=
Web3
(
Web3
.
AsyncHTTPProvider
(
bsc
),
modules
=
{
'eth'
:
(
AsyncEth
,)},
web_async
=
Web3
(
Web3
.
AsyncHTTPProvider
(
bsc
),
modules
=
{
'eth'
:
(
AsyncEth
,)},
middlewares
=
[])
middlewares
=
[])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment