Spaces:
Paused
Paused
Ethscriptions
commited on
Commit
•
0bead10
1
Parent(s):
b00c577
Upload memes.py
Browse files
memes.py
ADDED
@@ -0,0 +1,178 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pandas as pd
|
2 |
+
import requests
|
3 |
+
import streamlit as st
|
4 |
+
import streamlit_shadcn_ui as ui
|
5 |
+
import base64
|
6 |
+
import os
|
7 |
+
|
8 |
+
|
9 |
+
buy_data = [
|
10 |
+
{"数量(个)": "20,000", "单价(CKB)": "1.1"},
|
11 |
+
{"数量(个)": "210,000", "单价(CKB)": "1"},
|
12 |
+
{"数量(个)": "60,000", "单价(CKB)": "0.5"},
|
13 |
+
{"数量(个)": "630,000", "单价(CKB)": "0.2"},
|
14 |
+
{"数量(个)": "1,100,000", "单价(CKB)": "0.1"},
|
15 |
+
{"数量(个)": "2,300,000", "单价(CKB)": "0.08"},
|
16 |
+
{"数量(个)": "100,000", "单价(CKB)": "0.03"},
|
17 |
+
{"数量(个)": "100,000", "单价(CKB)": "0.005"},
|
18 |
+
{"数量(个)": "", "单价(CKB)": ""},
|
19 |
+
{"数量(个)": "", "单价(CKB)": ""}
|
20 |
+
]
|
21 |
+
|
22 |
+
sale_data = [
|
23 |
+
{"数量(个)": "20,000", "单价(CKB)": "2"},
|
24 |
+
{"数量(个)": "100,000", "单价(CKB)": "5"},
|
25 |
+
{"数量(个)": "200,000", "单价(CKB)": "10"},
|
26 |
+
{"数量(个)": "", "单价(CKB)": ""},
|
27 |
+
{"数量(个)": "", "单价(CKB)": ""},
|
28 |
+
{"数量(个)": "", "单价(CKB)": ""},
|
29 |
+
{"数量(个)": "", "单价(CKB)": ""},
|
30 |
+
{"数量(个)": "", "单价(CKB)": ""},
|
31 |
+
{"数量(个)": "", "单价(CKB)": ""},
|
32 |
+
{"数量(个)": "", "单价(CKB)": ""}
|
33 |
+
]
|
34 |
+
|
35 |
+
my_style = '''
|
36 |
+
<style>
|
37 |
+
.tag {
|
38 |
+
display: inline-block;
|
39 |
+
padding: 2px 6px;
|
40 |
+
background-color: #f2f2f2; /* 默认的背景颜色 */
|
41 |
+
border-radius: 5px; /* 圆角效果 */
|
42 |
+
margin: 0 2px;
|
43 |
+
transition: background-color 0.3s; /* 平滑的颜色过渡效果 */
|
44 |
+
}
|
45 |
+
|
46 |
+
.tag:hover {
|
47 |
+
background-color: #cffd51; /* 鼠标经过时的背景颜色 */
|
48 |
+
}
|
49 |
+
|
50 |
+
.tag:active {
|
51 |
+
background-color: #cffd51; /* 鼠标按下时的背景颜色 */
|
52 |
+
}
|
53 |
+
</style>
|
54 |
+
'''
|
55 |
+
|
56 |
+
|
57 |
+
# 图片Base64
|
58 |
+
def image_to_base64(img_path):
|
59 |
+
with open(img_path, "rb") as image_file:
|
60 |
+
return base64.b64encode(image_file.read()).decode()
|
61 |
+
|
62 |
+
|
63 |
+
def get_ckb_price():
|
64 |
+
params = {
|
65 |
+
'account_no': 'ckb',
|
66 |
+
}
|
67 |
+
|
68 |
+
headers = {
|
69 |
+
'authority': 'api.joy.id',
|
70 |
+
'accept': 'application/json, text/plain, */*',
|
71 |
+
'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8',
|
72 |
+
'cache-control': 'no-cache',
|
73 |
+
'dnt': '1',
|
74 |
+
'origin': 'https://app.joy.id',
|
75 |
+
'pragma': 'no-cache',
|
76 |
+
'referer': 'https://app.joy.id/',
|
77 |
+
'sec-ch-ua': '"Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"',
|
78 |
+
'sec-ch-ua-mobile': '?0',
|
79 |
+
'sec-ch-ua-platform': '"macOS"',
|
80 |
+
'sec-fetch-dest': 'empty',
|
81 |
+
'sec-fetch-mode': 'cors',
|
82 |
+
'sec-fetch-site': 'same-site',
|
83 |
+
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
|
84 |
+
}
|
85 |
+
|
86 |
+
try:
|
87 |
+
response = requests.get(
|
88 |
+
'https://api.joy.id/api/v1/wallet/accounts/ckb1qrgqep8saj8agswr30pls73hra28ry8jlnlc3ejzh3dl2ju7xxpjxqgqq878t5gcqw9gp3nf07lwz853ses6dxadhgef3vf0',
|
89 |
+
params=params, headers=headers,
|
90 |
+
)
|
91 |
+
response.raise_for_status()
|
92 |
+
print(response.json())
|
93 |
+
data = response.json()
|
94 |
+
if "accounts" in data and len(data["accounts"]) > 0 and "estimated_value" in data["accounts"][0]:
|
95 |
+
return data["accounts"][0]["estimated_value"]
|
96 |
+
else:
|
97 |
+
return 0
|
98 |
+
except requests.exceptions.RequestException as e:
|
99 |
+
return 0
|
100 |
+
|
101 |
+
|
102 |
+
def get_memes_info():
|
103 |
+
try:
|
104 |
+
response = requests.get('https://api.omiga.io/api/v1/ckb_inscriptions/launchpad')
|
105 |
+
if response.status_code != 200:
|
106 |
+
return ["Error", "Error"]
|
107 |
+
|
108 |
+
data = response.json()['data']['details']
|
109 |
+
rebase_supply = data['rebase_supply'] // 100000000
|
110 |
+
addresses_count = data['addresses_count']
|
111 |
+
return [rebase_supply, addresses_count]
|
112 |
+
|
113 |
+
except Exception as e:
|
114 |
+
print("Exception occurred: ", e)
|
115 |
+
return ["Error", "Error"]
|
116 |
+
|
117 |
+
st.set_page_config(page_title="Omiga - MEMES OTC", page_icon="👻", layout='centered', initial_sidebar_state='auto')
|
118 |
+
|
119 |
+
|
120 |
+
st.markdown(f'# <a href="https://ckb.meme" target="_self"><img src="data:image/jpeg;base64,{image_to_base64(os.path.join("img", "logo_ghost.png"))}" alt="Image" width="114px" height="36px" style="border-radius: 8px;"/></a> MEMES 场外交易', unsafe_allow_html=True)
|
121 |
+
st.subheader(' ', anchor=False, divider='gray')
|
122 |
+
|
123 |
+
st.markdown(f'{my_style}<span class="tag"><a href="https://omiga.io/" target="_blank" style="text-decoration: none;"><img src="data:image/jpeg;base64,{image_to_base64(os.path.join("img", "ghost.png"))}" alt="Image" width="20px" height="20px" style="border-radius: 3px;"/> Omiga</span></a> 是建立在 <span class="tag"><a href="https://nervos.org/" target="_blank" style="text-decoration: none;"><img src="data:image/jpeg;base64,{image_to_base64(os.path.join("img", "CKB.jpg"))}" alt="Image" width="20px" height="20px" style="border-radius: 3px;"/> Nervos CKB</span></a>(Common Knowledge Base)区块链���的一项创新性铭文协议。通过精心设计,旨在突破传统,为用户提供更公平、更高效的代币铸造和管理体验;<span class="tag"><a href="https://omiga.io/launchpad" target="_blank" style="text-decoration: none;"><img src="data:image/jpeg;base64,{image_to_base64(os.path.join("img", "memes.png"))}" alt="Image" width="20px" height="20px" style="border-radius: 3px;"/> MEMES</span></a> 是 CKB 链上 Omiga 协议第一个代币铭文。', unsafe_allow_html=True)
|
124 |
+
|
125 |
+
st.markdown(f'#### <img src="data:image/jpeg;base64,{image_to_base64(os.path.join("img", "memes.png"))}" alt="Image" width="32px" height="32px" style="border-radius: 8px;"/> $MEMES 基础信息', unsafe_allow_html=True)
|
126 |
+
|
127 |
+
data_info = get_memes_info()
|
128 |
+
ckb_price = get_ckb_price()
|
129 |
+
cols = st.columns(3)
|
130 |
+
with cols[0]:
|
131 |
+
ui.metric_card(title="总供应量", content="21,000,000", description="理论上的最大供应量", key="card1")
|
132 |
+
with cols[1]:
|
133 |
+
ui.metric_card(title="重铸进度", content=f"{data_info[0]:,}", description="当前重铸进度,即流通量", key="card2")
|
134 |
+
with cols[2]:
|
135 |
+
ui.metric_card(title="持币地址", content=f"{data_info[1]:,}", description="当前持币的地址数量", key="card3")
|
136 |
+
|
137 |
+
cols = st.columns(3)
|
138 |
+
with cols[0]:
|
139 |
+
ui.metric_card(title="最近成交价 (CKB)", content="1", description="场外交易最新价格", key="card4")
|
140 |
+
with cols[1]:
|
141 |
+
ui.metric_card(title="总交易量 (CKB)", content="636,000", description="场外交易的总交易量", key="card5")
|
142 |
+
with cols[2]:
|
143 |
+
ui.metric_card(title="预计市值 (USDT)", content=f"{(float(ckb_price) * int(data_info[0]) / 1000):,.0f}", description="当前预计的总市值", key="card6")
|
144 |
+
|
145 |
+
st.markdown("#### 订单信息")
|
146 |
+
orders = ui.tabs(options=['购买订单', '出售订单'], default_value='购买订单', key="orders")
|
147 |
+
if orders == "购买订单":
|
148 |
+
buy_df = pd.DataFrame(buy_data)
|
149 |
+
st.dataframe(buy_df, use_container_width=True, hide_index=True)
|
150 |
+
if orders == "出售订单":
|
151 |
+
sale_df = pd.DataFrame(sale_data)
|
152 |
+
st.dataframe(sale_df, use_container_width=True, hide_index=True)
|
153 |
+
|
154 |
+
chat = ui.tabs(options=['微信群聊', '电报私聊'], default_value='微信群聊', key="chat")
|
155 |
+
if chat == "微信群聊":
|
156 |
+
st.markdown(f'<a href="https://weixin.qq.com/g/AwYAADKAzCELuHOyjDcdH61fczkeht0RZC8xc_Q6F5gqpNfL6uTNIRtGaUh4HC-Y" target="_blank"><img src="data:image/jpeg;base64,{image_to_base64(os.path.join("img", "wechat_qr.png"))}" alt="Image" style="max-width: 100%; width: 50%; height: auto; border-radius: 10px; display: block; box-shadow: 5px 5px 15px rgba(0,0,0,0.3);"/></a>', unsafe_allow_html=True)
|
157 |
+
if chat == "电报私聊":
|
158 |
+
st.markdown(f'<a href="https://t.me/nervosckb" target="_blank"><img src="data:image/jpeg;base64,{image_to_base64(os.path.join("img", "telegram_qr.png"))}" alt="Image" style="max-width: 100%; width: 50%; height: auto; border-radius: 10px; display: block; box-shadow: 5px 5px 15px rgba(0,0,0,0.3);"/></a>', unsafe_allow_html=True)
|
159 |
+
st.markdown("#### 交易流程")
|
160 |
+
st.markdown('''1. 交易双方协商并达成价格一致,交易在小群中进行;
|
161 |
+
2. 买家首先将相应的 CKB 转入担保账户;
|
162 |
+
3. 到账后,卖家将指定数量的 MEMES 转账给买家;
|
163 |
+
4. 最后,担保将买家的CKB支付给卖家,完成交易。
|
164 |
+
''')
|
165 |
+
st.markdown("#### 交易费用")
|
166 |
+
st.markdown('''- 交易总额的 3% ,具体是买卖双方平分,所以每一方需支付 1.5%;
|
167 |
+
- 买家需承担 MEMES 每次转账时附带的 144CKB 的费用。''')
|
168 |
+
|
169 |
+
st.markdown("#### 社交信息")
|
170 |
+
|
171 |
+
st.markdown(f'''<span class="tag"><a href="https://omiga.io" target="_blank" style="text-decoration: none;"><img src="data:image/jpeg;base64,{image_to_base64(os.path.join("img", "ghost.png"))}" alt="Image" width="20px" height="20px" style="border-radius: 3px;" /> omiga.io</span></a>
|
172 |
+
<span class="tag"><a href="https://x.com/OmigaHQ" target="_blank" style="text-decoration: none;"><img src="data:image/svg+xml;base64,{image_to_base64(os.path.join("img", "x.svg"))}" alt="Image" width="20px" height="20px" style="border-radius: 3px;" /> @OmigaHQ</span></a>
|
173 |
+
<span class="tag"><a href="https://t.me/omigackb" target="_blank" style="text-decoration: none;"><img src="data:image/svg+xml;base64,{image_to_base64(os.path.join("img", "telegram.svg"))}" alt="Image" width="20px" height="20px" style="border-radius: 3px;" /> @omigackb</span></a>
|
174 |
+
|
175 |
+
钱包推荐:<span class="tag"><a href="https://app.joy.id" target="_blank" style="text-decoration: none;"><img src="data:image/jpeg;base64,{image_to_base64(os.path.join("img", "joyid.jpg"))}" alt="Image" width="20px" height="20px" style="border-radius: 3px;" /> JoyID</span></a>
|
176 |
+
|
177 |
+
买入 CKB 推荐:<span class="tag"><a href="https://binance.com" target="_blank" style="text-decoration: none;"><img src="data:image/jpeg;base64,{image_to_base64(os.path.join("img", "binance.jpg"))}" alt="Image" width="20px" height="20px" style="border-radius: 3px;" /> Binance</span></a> <span class="tag"><a href="https://htx.com" target="_blank" style="text-decoration: none;"><img src="data:image/jpeg;base64,{image_to_base64(os.path.join("img", "htx.jpg"))}" alt="Image" width="20px" height="20px" style="border-radius: 3px;" /> HTX</span></a> <span class="tag"><a href="https://kucoin.com" target="_blank" style="text-decoration: none;"><img src="data:image/jpeg;base64,{image_to_base64(os.path.join("img", "kucoin.jpg"))}" alt="Image" width="20px" height="20px" style="border-radius: 3px;" /> KuCoin</span></a>
|
178 |
+
''', unsafe_allow_html=True)
|