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 = ''' ''' # 图片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'# Image MEMES 场外交易', unsafe_allow_html=True) st.subheader(' ', anchor=False, divider='gray') st.markdown(f'{my_style}Image Omiga 是建立在 Image Nervos CKB(Common Knowledge Base)区块链上的一项创新性铭文协议。通过精心设计,旨在突破传统,为用户提供更公平、更高效的代币铸造和管理体验;Image MEMES 是 CKB 链上 Omiga 协议第一个代币铭文。', unsafe_allow_html=True) st.markdown(f'#### Image $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'Image', unsafe_allow_html=True) if chat == "电报私聊": st.markdown(f'Image', 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'''Image omiga.io Image @OmigaHQ Image @omigackb 钱包推荐:Image JoyID 买入 $CKB 推荐:Image Binance Image HTX Image KuCoin ''', unsafe_allow_html=True)