phase 2 points
This commit is contained in:
86
main.py
86
main.py
@@ -182,6 +182,70 @@ def fetch_btc_plus_stats(stage_no=1):
|
|||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
def fetch_phase2_points(address):
|
||||||
|
"""从API获取Phase2积分系统数据"""
|
||||||
|
url = "https://graphql.sft-api.com/graphql"
|
||||||
|
headers = {
|
||||||
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:141.0) Gecko/20100101 Firefox/141.0",
|
||||||
|
"Accept": "*/*",
|
||||||
|
"Accept-Language": "zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3",
|
||||||
|
"Accept-Encoding": "gzip, deflate, br, zstd",
|
||||||
|
"Referer": "https://app.solv.finance/",
|
||||||
|
"content-type": "application/json",
|
||||||
|
"authorization": "dW5kZWZpbmVkfHx1bmRlZmluZWR8fHVuZGVmaW5lZHx8.undefined",
|
||||||
|
"x-amz-user-agent": "aws-amplify/3.0.7",
|
||||||
|
"Origin": "https://app.solv.finance",
|
||||||
|
"DNT": "1",
|
||||||
|
"Connection": "keep-alive",
|
||||||
|
"Sec-Fetch-Dest": "empty",
|
||||||
|
"Sec-Fetch-Mode": "cors",
|
||||||
|
"Sec-Fetch-Site": "cross-site",
|
||||||
|
"Sec-GPC": "1",
|
||||||
|
"Priority": "u=4",
|
||||||
|
}
|
||||||
|
|
||||||
|
query = """
|
||||||
|
query Phase2PointSysAccountInfo($address: String) {
|
||||||
|
phase2PointSysAccountInfo(address: $address) {
|
||||||
|
address
|
||||||
|
isRegistered
|
||||||
|
seedUserInviteCode
|
||||||
|
inviteCode
|
||||||
|
inviteCount
|
||||||
|
totalPointsEarned
|
||||||
|
availablePoints
|
||||||
|
isPointsAccelerationActive
|
||||||
|
todayHoldingTVL
|
||||||
|
todayHoldingAccelerationRatio
|
||||||
|
nextLevelHoldingTVL
|
||||||
|
nextLevelHoldingAccelerationRatio
|
||||||
|
activityCards {
|
||||||
|
type
|
||||||
|
accelerationRatio
|
||||||
|
startTime
|
||||||
|
endTime
|
||||||
|
__typename
|
||||||
|
}
|
||||||
|
isHighestLevel
|
||||||
|
__typename
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
variables = {"address": address}
|
||||||
|
payload = {
|
||||||
|
"operationName": "Phase2PointSysAccountInfo",
|
||||||
|
"query": query,
|
||||||
|
"variables": variables,
|
||||||
|
}
|
||||||
|
|
||||||
|
response = requests.post(url, headers=headers, json=payload)
|
||||||
|
response.raise_for_status()
|
||||||
|
data = response.json()
|
||||||
|
data["timestamp"] = get_current_time()
|
||||||
|
return data
|
||||||
|
|
||||||
|
|
||||||
def save_to_csv(data, filename="btc_plus_rewards.csv"):
|
def save_to_csv(data, filename="btc_plus_rewards.csv"):
|
||||||
"""将数据保存到CSV文件"""
|
"""将数据保存到CSV文件"""
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -213,6 +277,25 @@ def save_to_csv(data, filename="btc_plus_rewards.csv"):
|
|||||||
}
|
}
|
||||||
filename = "btc_plus_allocations.csv"
|
filename = "btc_plus_allocations.csv"
|
||||||
|
|
||||||
|
elif "phase2PointSysAccountInfo" in data.get("data", {}):
|
||||||
|
points_data = data["data"]["phase2PointSysAccountInfo"]
|
||||||
|
row = {
|
||||||
|
"timestamp": timestamp,
|
||||||
|
"address": points_data["address"],
|
||||||
|
"isRegistered": points_data["isRegistered"],
|
||||||
|
"inviteCode": points_data["inviteCode"],
|
||||||
|
"inviteCount": points_data["inviteCount"],
|
||||||
|
"totalPointsEarned": points_data["totalPointsEarned"],
|
||||||
|
"availablePoints": points_data["availablePoints"],
|
||||||
|
"isPointsAccelerationActive": points_data["isPointsAccelerationActive"],
|
||||||
|
"todayHoldingTVL": points_data["todayHoldingTVL"],
|
||||||
|
"todayHoldingAccelerationRatio": points_data["todayHoldingAccelerationRatio"],
|
||||||
|
"nextLevelHoldingTVL": points_data["nextLevelHoldingTVL"],
|
||||||
|
"nextLevelHoldingAccelerationRatio": points_data["nextLevelHoldingAccelerationRatio"],
|
||||||
|
"isHighestLevel": points_data["isHighestLevel"],
|
||||||
|
}
|
||||||
|
filename = "phase2_points.csv"
|
||||||
|
|
||||||
else:
|
else:
|
||||||
stats_data = data["data"]["btcPlusStats"]
|
stats_data = data["data"]["btcPlusStats"]
|
||||||
row = {
|
row = {
|
||||||
@@ -295,6 +378,9 @@ def main_loop():
|
|||||||
stats_data["variables"] = {"stageNo": stage_no}
|
stats_data["variables"] = {"stageNo": stage_no}
|
||||||
save_to_csv(stats_data)
|
save_to_csv(stats_data)
|
||||||
|
|
||||||
|
points_data = fetch_phase2_points(address)
|
||||||
|
save_to_csv(points_data)
|
||||||
|
|
||||||
# 定时Git提交
|
# 定时Git提交
|
||||||
current_time = time.time()
|
current_time = time.time()
|
||||||
if current_time - last_git_time >= GIT_INTERVAL:
|
if current_time - last_git_time >= GIT_INTERVAL:
|
||||||
|
Reference in New Issue
Block a user