MEMES / memes.py
Ethscriptions's picture
Update memes.py
6394ab5 verified
import pandas as pd
import requests
import streamlit as st
import streamlit_shadcn_ui as ui
import base64
import os
buy_data = [
{"数量(个)": "250,000", "单价(CKB)": "1.1"},
{"数量(个)": "200,000", "单价(CKB)": "1.05"},
{"数量(个)": "100,000", "单价(CKB)": "1"},
{"数量(个)": "60,000", "单价(CKB)": "0.5"},
{"数量(个)": "630,000", "单价(CKB)": "0.2"},
{"数量(个)": "1,100,000", "单价(CKB)": "0.1"},
{"数量(个)": "", "单价(CKB)": ""},
{"数量(个)": "", "单价(CKB)": ""},
{"数量(个)": "", "单价(CKB)": ""},
{"数量(个)": "", "单价(CKB)": ""}
]
sale_data = [
{"数量(个)": "100,000", "单价(CKB)": "4"},
{"数量(个)": "50,000", "单价(CKB)": "4.5"},
{"数量(个)": "100,000", "单价(CKB)": "5"},
{"数量(个)": "200,000", "单价(CKB)": "10"},
{"数量(个)": "", "单价(CKB)": ""},
{"数量(个)": "", "单价(CKB)": ""},
{"数量(个)": "", "单价(CKB)": ""},
{"数量(个)": "", "单价(CKB)": ""},
{"数量(个)": "", "单价(CKB)": ""},
{"数量(个)": "", "单价(CKB)": ""}
]
my_style = '''
<style>
.tag {
display: inline-block;
padding: 2px 6px;
background-color: #f2f2f2; /* 默认的背景颜色 */
border-radius: 5px; /* 圆角效果 */
margin: 0 2px;
transition: background-color 0.3s; /* 平滑的颜色过渡效果 */
}
.tag:hover {
background-color: #83F14C; /* 鼠标经过时的背景颜色 */
}
.tag:active {
background-color: #cffd51; /* 鼠标按下时的背景颜色 */
}
</style>
'''
# 图片Base64
def image_to_base64(img_path):
with open(img_path, "rb") as image_file:
return base64.b64encode(image_file.read()).decode()
def get_ckb_price():
params = {
'account_no': 'ckb',
}
headers = {
'authority': 'api.joy.id',
'accept': 'application/json, text/plain, */*',
'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8',
'cache-control': 'no-cache',
'dnt': '1',
'origin': 'https://app.joy.id',
'pragma': 'no-cache',
'referer': 'https://app.joy.id/',
'sec-ch-ua': '"Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"macOS"',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'same-site',
'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',
}
try:
response = requests.get(
'https://api.joy.id/api/v1/wallet/accounts/ckb1qrgqep8saj8agswr30pls73hra28ry8jlnlc3ejzh3dl2ju7xxpjxqgqq878t5gcqw9gp3nf07lwz853ses6dxadhgef3vf0',
params=params, headers=headers,
)
response.raise_for_status()
print(response.json())
data = response.json()
if "accounts" in data and len(data["accounts"]) > 0 and "estimated_value" in data["accounts"][0]:
return data["accounts"][0]["estimated_value"]
else:
return 0
except requests.exceptions.RequestException as e:
return 0
def get_memes_info():
try:
response = requests.get('https://api.omiga.io/api/v1/ckb_inscriptions/launchpad')
if response.status_code != 200:
return ["Error", "Error"]
data = response.json()['data']['details']
rebase_supply = data['rebase_supply'] // 100000000
addresses_count = data['addresses_count']
return [rebase_supply, addresses_count]
except Exception as e:
print("Exception occurred: ", e)
return ["Error", "Error"]
st.set_page_config(page_title="Omiga - MEMES OTC", page_icon="👻", layout='centered', initial_sidebar_state='auto')
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)
st.subheader(' ', anchor=False, divider='gray')
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)
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)
data_info = get_memes_info()
ckb_price = get_ckb_price()
cols = st.columns(3)
with cols[0]:
ui.metric_card(title="总供应量", content="21,000,000", description="理论上的最大供应量", key="card1")
with cols[1]:
ui.metric_card(title="重铸进度", content=f"{data_info[0]:,}", description="当前重铸进度(流通量)", key="card2")
with cols[2]:
ui.metric_card(title="持币地址", content=f"{data_info[1]:,}", description="当前持币的地址数量", key="card3")
cols = st.columns(3)
with cols[0]:
ui.metric_card(title="最近成交价 (CKB)", content="4", description="场外交易最新价格", key="card4")
with cols[1]:
ui.metric_card(title="总交易量 (CKB)", content="1,181,000", description="场外交易的总交易量", key="card5")
with cols[2]:
ui.metric_card(title="预计市值 (USDT)", content=f"{(float(ckb_price) * int(data_info[0]) / 1000):,.0f}", description="当前预计的总市值", key="card6")
st.markdown("#### 订单信息")
orders = ui.tabs(options=['购买订单', '出售订单'], default_value='购买订单', key="orders")
if orders == "购买订单":
buy_df = pd.DataFrame(buy_data)
st.dataframe(buy_df, use_container_width=True, hide_index=True)
if orders == "出售订单":
sale_df = pd.DataFrame(sale_data)
st.dataframe(sale_df, use_container_width=True, hide_index=True)
chat = ui.tabs(options=['微信群聊', '电报私聊'], default_value='微信群聊', key="chat")
if chat == "微信群聊":
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)
if chat == "电报私聊":
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)
st.markdown("#### OTC 流程")
st.markdown('''1. 交易双方协商并达成价格一致,交易在小群中进行;
2. 买家首先将相应的 CKB 转入担保账户;
3. 到账后,卖家将指定数量的 MEMES 转账给买家;
4. 最后,担保将买家的CKB支付给卖家,完成交易。
''')
st.markdown("#### OTC 费用")
st.markdown('''- 交易总额的 3% ,具体是买卖双方平分,所以每一方需支付 1.5%;
- 买家需承担 $MEMES 每次转账时附带的 144CKB 的费用。''')
st.markdown("#### 社交信息")
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>
<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>
<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>
钱包推荐:<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>
买入 $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>
''', unsafe_allow_html=True)