<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>撒酒狂歌</title>
        <link>https://paragraph.com/@0xd74e84f97ef3ea7fe9be2ebdaced17e11ecfc9a8</link>
        <description>twitter：kyle_1711</description>
        <lastBuildDate>Sun, 16 Aug 2026 17:03:03 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>en</language>
        <image>
            <title>撒酒狂歌</title>
            <url>https://storage.googleapis.com/papyrus_images/285717ab1a055e7573b3849f40874b4d4485f04726256c30fc801a3f81918aba.jpg</url>
            <link>https://paragraph.com/@0xd74e84f97ef3ea7fe9be2ebdaced17e11ecfc9a8</link>
        </image>
        <copyright>All rights reserved</copyright>
        <item>
            <title><![CDATA[将@Whale Alert警报消息发送到微信]]></title>
            <link>https://paragraph.com/@0xd74e84f97ef3ea7fe9be2ebdaced17e11ecfc9a8/whale-alert</link>
            <guid>C5CY30PbeXGlwI5PyMiL</guid>
            <pubDate>Mon, 20 Jun 2022 15:29:09 GMT</pubDate>
            <description><![CDATA[前言有段时间没写博客了，这段时间主要在做以下几件事情： 1、锻炼，周末的时候约了高中的好友去爬山。太久没锻炼了，累趴下了😅，还是要多练练。 2、无意间看到了雷公的视频，对我触动很大，不论是一级还是二级市场，都需要注重心态、技术。 3、趁着Gas低，交互了几个项目。 4、上班😄不上班没饭吃，肚子饿正题最开始有这个想法来源于：想把tg上订阅的Foresight News的bot消息转发到微信，这样有几个好处： 1、上班可以光明正大的看快讯 2、微信相当于聚合器，接收多路的消息。只要打开微信，就能收到我关注的消息，而不是群聊的垃圾信息。 … 但是目前还没搞定，tg的教程没怎么看明白。网上的教程基本都是微信转发到tg的，因为tg的服务器上文件是永久保存的，比化腾良心多了。 刚好推特上关注了@Whale Alert，这是一个产品，专门监控链上巨鲸大额转账的，刚好有开放的API（一定是特别的缘分），思路就是：申请免费api（虽然有限制，但是要啥自行车）—— 将返回的结果发送到企业微信（个人微信消息推送挺严格的，所以另辟蹊径，反正两者是可以绑定的） 我关注了很多大V，当看一个工具好不好用的...]]></description>
            <content:encoded><![CDATA[<h2 id="h-" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">前言</h2><p>有段时间没写博客了，这段时间主要在做以下几件事情：</p><p>1、锻炼，周末的时候约了高中的好友去爬山。太久没锻炼了，累趴下了😅，还是要多练练。</p><p>2、无意间看到了雷公的视频，对我触动很大，不论是一级还是二级市场，都需要注重心态、技术。</p><p>3、趁着Gas低，交互了几个项目。</p><p>4、上班😄不上班没饭吃，肚子饿</p><h2 id="h-" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">正题</h2><p>最开始有这个想法来源于：想把tg上订阅的Foresight News的bot消息转发到微信，这样有几个好处：</p><p>1、上班可以光明正大的看快讯</p><p>2、微信相当于聚合器，接收多路的消息。只要打开微信，就能收到我关注的消息，而不是群聊的垃圾信息。</p><p>…</p><p>但是目前还没搞定，tg的教程没怎么看明白。网上的教程基本都是微信转发到tg的，因为tg的服务器上文件是永久保存的，比化腾良心多了。</p><p>刚好推特上关注了@Whale Alert，这是一个产品，专门监控链上巨鲸大额转账的，刚好有开放的API（一定是特别的缘分），思路就是：申请免费api（虽然有限制，但是要啥自行车）—— 将返回的结果发送到企业微信（个人微信消息推送挺严格的，所以另辟蹊径，反正两者是可以绑定的）</p><p>我关注了很多大V，当看一个工具好不好用的时候，我通常会看共同关注，这些大v消息肯定是比我灵敏多了。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/5db679f46e2826a572d8bb48da957285cf12a5b76b390b3a1931c0c23756b350.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>@Whale Alert API文档，其中免费账号的限制的内容。</p><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://docs.whale-alert.io/#introduction">https://docs.whale-alert.io/#introduction</a></p><p>直接上代码吧。都写注释了</p><p><strong>先pip安装依赖，其他都自带了。就这两个</strong></p><pre data-type="codeBlock" text="pip install ntplib
pip install requests
"><code></code></pre><p><strong>main.py</strong></p><pre data-type="codeBlock" text="# -*- coding : utf-8 -*-
import os
import time
import ntplib
import json
import configparser
import requests
from send_msgs_to_wechat import SendWeiXinWork

config_path = os.path.join(&quot;properties.conf&quot;)
# 获取配置文件对象
cf = configparser.ConfigParser()
# 读取配置
cf.read(config_path, encoding=&apos;utf-8&apos;)

# 本地测试，开代理
os.environ[&quot;http_proxy&quot;] = &quot;http://127.0.0.1:10810&quot;
os.environ[&quot;https_proxy&quot;] = &quot;http://127.0.0.1:10810&quot;

# 创建发送消息对象
SendWeiXinWork = SendWeiXinWork()


# 从ntp服务器获取时间。防止运行的机器时间不对
def get_timestamp_from_ntp():
    ntp_url = &apos;pool.ntp.org&apos;
    # noinspection PyBroadException
    try:
       ntp_client = ntplib.NTPClient()
       response_outside = ntp_client.request(ntp_url).tx_time
       start_timestamp = round(response_outside)
       return start_timestamp
   except Exception as exc:
       return round(time.time())


def main():
    # 发送警报的数组
    msgs = []

    # 时间阈值
    time_windows = 60

    # e.g https://api.whale-alert.io/v1/transactions?api_key=&apos;申请的key&apos;&amp;min_value=500000&amp;start=1655707296

    # 警报的最小价值
    min_value = 5000000
    api_key = cf.get(&quot;Whale Alert&quot;, &quot;api_key&quot;)
    base_url = &apos;https://api.whale-alert.io/v1/transactions?&apos;
    base_scan_url = &apos;https://whale-alert.io/transaction&apos;

    # 从ntp服务器获取时间。防止运行的机器时间不对
    # 减去窗口时间time_windows，相当于从前一分钟的时间作为开始时间
    start_timestamp = get_timestamp_from_ntp() - time_windows

    print(start_timestamp)

    # 拼接需要访问的url和参数。
    url = base_url + &apos;api_key&apos; + &apos;=&apos; + api_key + &apos;&amp;&apos; + &apos;min_value&apos; + &apos;=&apos; + str(min_value) + &apos;&amp;&apos; + &apos;start&apos; + &apos;=&apos; + str(
        start_timestamp)

    response = requests.get(url)

    resp_dict = json.loads(response.text)

    #  判断状态是否是success并且数据条数要大于0
    if &apos;success&apos;.__eq__(resp_dict[&apos;result&apos;]) and resp_dict[&apos;count&apos;] &gt; 0:
        transactions = resp_dict[&apos;transactions&apos;]
        if len(transactions) &gt; 0:
            for transaction in transactions:
                # 在哪条链上
                blockchain = transaction[&apos;blockchain&apos;]

                # 代币名称
                symbol = transaction[&apos;symbol&apos;]

                # 交易类型
                transaction_type = transaction[&apos;transaction_type&apos;]

                # 交易hash
                transaction_hash = transaction[&apos;hash&apos;]

                # 发送地址
                from_address = transaction[&apos;from&apos;][&apos;address&apos;]

                # 发送地址所属
                from_owner = transaction[&apos;from&apos;].get(&apos;owner&apos;, &apos;Unknown&apos;)

                # 发送地址所属类型
                from_owner_type = transaction[&apos;from&apos;].get(&apos;owner_type&apos;, &apos;Unknown&apos;)

                # 接收地址
                to_address = transaction[&apos;to&apos;][&apos;address&apos;]

                # 接收地址所属
                to_owner = transaction[&apos;to&apos;].get(&apos;owner&apos;, &apos;Unknown&apos;)

                # 接收地址所属类型
                to_owner_type = transaction[&apos;to&apos;].get(&apos;owner_type&apos;, &apos;Unknown&apos;)

                # 交易时间戳
                transaction_timestamp = transaction[&apos;timestamp&apos;]
                transaction_date = time.strftime(&apos;%Y-%m-%d %H:%M:%S&apos;, time.localtime(transaction_timestamp))

                # 币本位总数
                transaction_amount = str(transaction[&apos;amount&apos;]) + &apos; &apos; + symbol

                # 以usd计算价值
                transaction_amount_usd = str(transaction[&apos;amount_usd&apos;]) + &apos; &apos; + &apos;usd&apos;

                # 转账次数
                transaction_count = transaction[&apos;transaction_count&apos;]

                msg = &apos;区块链名称&apos; + &apos;: &apos; + blockchain + &apos;\n&apos; + &apos;符号&apos; + &apos;: &apos; + symbol + &apos;\n&apos; + &apos;交易类型&apos; + &apos;: &apos; + transaction_type + &apos;\n&apos; + &apos;交易hash&apos; + &apos;: &apos; + transaction_hash + &apos;\n&apos; + &apos;交易发起者地址&apos; + &apos;: &apos; + from_address + &apos;\n&apos; + &apos;交易发起者地址所属&apos; + &apos;: &apos; + from_owner + &apos;\n&apos; + &apos;交易发起者地址所属类型&apos; + &apos;: &apos; + from_owner_type + &apos;\n&apos; + &apos;交易接收地址&apos; + &apos;: &apos; + to_address + &apos;\n&apos; + &apos;交易接收地址所属&apos; + &apos;: &apos; + to_owner + &apos;\n&apos; + &apos;交易接收地址所属类型&apos; + &apos;: &apos; + to_owner_type + &apos;\n&apos; + &apos;交易发生时间&apos; + &apos;: &apos; + transaction_date + &apos;\n&apos; + &apos;币本位总额&apos; + &apos;: &apos; + str(transaction_amount) + &apos;\n&apos; + &apos;币本位价值usd总额&apos; + &apos;: &apos; + str(transaction_amount_usd) + &apos;\n&apos; + &apos;交易转账次数&apos; + &apos;: &apos; + str(transaction_count) + &apos;\n&apos; + &apos;区块链浏览器详情&apos; + &apos;: &apos; + base_scan_url + &apos;/&apos; + blockchain + &apos;/&apos; + transaction_hash
                msgs.append(msg)

    if len(msgs) &gt; 0:
        # 发送到微信
        for msg in msgs:
            # 1 代表往企业总群发
            SendWeiXinWork.send_message(&quot;1&quot;, str(msg))
            print(msg)


if __name__ == &apos;__main__&apos;:
    main()
"><code># <span class="hljs-operator">-</span><span class="hljs-operator">*</span><span class="hljs-operator">-</span> coding : utf<span class="hljs-number">-8</span> <span class="hljs-operator">-</span><span class="hljs-operator">*</span><span class="hljs-operator">-</span>
<span class="hljs-keyword">import</span> <span class="hljs-title">os</span>
<span class="hljs-title"><span class="hljs-keyword">import</span></span> <span class="hljs-title">time</span>
<span class="hljs-title"><span class="hljs-keyword">import</span></span> <span class="hljs-title">ntplib</span>
<span class="hljs-title"><span class="hljs-keyword">import</span></span> <span class="hljs-title">json</span>
<span class="hljs-title"><span class="hljs-keyword">import</span></span> <span class="hljs-title">configparser</span>
<span class="hljs-title"><span class="hljs-keyword">import</span></span> <span class="hljs-title">requests</span>
<span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-title">send_msgs_to_wechat</span> <span class="hljs-title"><span class="hljs-keyword">import</span></span> <span class="hljs-title">SendWeiXinWork</span>

<span class="hljs-title">config_path</span> <span class="hljs-operator">=</span> <span class="hljs-title">os</span>.<span class="hljs-title">path</span>.<span class="hljs-title">join</span>(<span class="hljs-string">"properties.conf"</span>)
# 获取配置文件对象
<span class="hljs-title">cf</span> <span class="hljs-operator">=</span> <span class="hljs-title">configparser</span>.<span class="hljs-title">ConfigParser</span>()
# 读取配置
<span class="hljs-title">cf</span>.<span class="hljs-title">read</span>(<span class="hljs-title">config_path</span>, <span class="hljs-title">encoding</span><span class="hljs-operator">=</span><span class="hljs-string">'utf-8'</span>)

# 本地测试，开代理
<span class="hljs-title">os</span>.<span class="hljs-title">environ</span>[<span class="hljs-string">"http_proxy"</span>] <span class="hljs-operator">=</span> <span class="hljs-string">"http://127.0.0.1:10810"</span>
<span class="hljs-title">os</span>.<span class="hljs-title">environ</span>[<span class="hljs-string">"https_proxy"</span>] <span class="hljs-operator">=</span> <span class="hljs-string">"http://127.0.0.1:10810"</span>

# 创建发送消息对象
<span class="hljs-title">SendWeiXinWork</span> <span class="hljs-operator">=</span> <span class="hljs-title">SendWeiXinWork</span>()


# 从<span class="hljs-title">ntp</span>服务器获取时间。防止运行的机器时间不对
<span class="hljs-title">def</span> <span class="hljs-title">get_timestamp_from_ntp</span>():
    <span class="hljs-title">ntp_url</span> <span class="hljs-operator">=</span> <span class="hljs-string">'pool.ntp.org'</span>
    # <span class="hljs-title">noinspection</span> <span class="hljs-title">PyBroadException</span>
    <span class="hljs-title"><span class="hljs-keyword">try</span></span>:
       <span class="hljs-title">ntp_client</span> <span class="hljs-operator">=</span> <span class="hljs-title">ntplib</span>.<span class="hljs-title">NTPClient</span>()
       <span class="hljs-title">response_outside</span> <span class="hljs-operator">=</span> <span class="hljs-title">ntp_client</span>.<span class="hljs-title">request</span>(<span class="hljs-title">ntp_url</span>).<span class="hljs-title">tx_time</span>
       <span class="hljs-title">start_timestamp</span> <span class="hljs-operator">=</span> <span class="hljs-title">round</span>(<span class="hljs-title">response_outside</span>)
       <span class="hljs-title"><span class="hljs-keyword">return</span></span> <span class="hljs-title">start_timestamp</span>
   <span class="hljs-title">except</span> <span class="hljs-title">Exception</span> <span class="hljs-title"><span class="hljs-keyword">as</span></span> <span class="hljs-title">exc</span>:
       <span class="hljs-title"><span class="hljs-keyword">return</span></span> <span class="hljs-title">round</span>(<span class="hljs-title">time</span>.<span class="hljs-title">time</span>())


<span class="hljs-title">def</span> <span class="hljs-title">main</span>():
    # 发送警报的数组
    <span class="hljs-title">msgs</span> <span class="hljs-operator">=</span> []

    # 时间阈值
    <span class="hljs-title">time_windows</span> <span class="hljs-operator">=</span> 60

    # <span class="hljs-title">e</span>.<span class="hljs-title">g</span> <span class="hljs-title">https</span>:<span class="hljs-comment">//api.whale-alert.io/v1/transactions?api_key='申请的key'&#x26;min_value=500000&#x26;start=1655707296</span>

    # 警报的最小价值
    <span class="hljs-title">min_value</span> <span class="hljs-operator">=</span> 5000000
    <span class="hljs-title">api_key</span> <span class="hljs-operator">=</span> <span class="hljs-title">cf</span>.<span class="hljs-title">get</span>(<span class="hljs-string">"Whale Alert"</span>, <span class="hljs-string">"api_key"</span>)
    <span class="hljs-title">base_url</span> <span class="hljs-operator">=</span> <span class="hljs-string">'https://api.whale-alert.io/v1/transactions?'</span>
    <span class="hljs-title">base_scan_url</span> <span class="hljs-operator">=</span> <span class="hljs-string">'https://whale-alert.io/transaction'</span>

    # 从<span class="hljs-title">ntp</span>服务器获取时间。防止运行的机器时间不对
    # 减去窗口时间<span class="hljs-title">time_windows</span>，相当于从前一分钟的时间作为开始时间
    <span class="hljs-title">start_timestamp</span> <span class="hljs-operator">=</span> <span class="hljs-title">get_timestamp_from_ntp</span>() <span class="hljs-operator">-</span> <span class="hljs-title">time_windows</span>

    <span class="hljs-title">print</span>(<span class="hljs-title">start_timestamp</span>)

    # 拼接需要访问的<span class="hljs-title">url</span>和参数。
    <span class="hljs-title">url</span> <span class="hljs-operator">=</span> <span class="hljs-title">base_url</span> <span class="hljs-operator">+</span> <span class="hljs-string">'api_key'</span> <span class="hljs-operator">+</span> <span class="hljs-string">'='</span> <span class="hljs-operator">+</span> <span class="hljs-title">api_key</span> <span class="hljs-operator">+</span> <span class="hljs-string">'&#x26;'</span> <span class="hljs-operator">+</span> <span class="hljs-string">'min_value'</span> <span class="hljs-operator">+</span> <span class="hljs-string">'='</span> <span class="hljs-operator">+</span> <span class="hljs-title">str</span>(<span class="hljs-title">min_value</span>) <span class="hljs-operator">+</span> <span class="hljs-string">'&#x26;'</span> <span class="hljs-operator">+</span> <span class="hljs-string">'start'</span> <span class="hljs-operator">+</span> <span class="hljs-string">'='</span> <span class="hljs-operator">+</span> <span class="hljs-title">str</span>(
        <span class="hljs-title">start_timestamp</span>)

    <span class="hljs-title">response</span> <span class="hljs-operator">=</span> <span class="hljs-title">requests</span>.<span class="hljs-title">get</span>(<span class="hljs-title">url</span>)

    <span class="hljs-title">resp_dict</span> <span class="hljs-operator">=</span> <span class="hljs-title">json</span>.<span class="hljs-title">loads</span>(<span class="hljs-title">response</span>.<span class="hljs-title">text</span>)

    #  判断状态是否是<span class="hljs-title">success</span>并且数据条数要大于0
    <span class="hljs-title"><span class="hljs-keyword">if</span></span> <span class="hljs-string">'success'</span>.<span class="hljs-title">__eq__</span>(<span class="hljs-title">resp_dict</span>[<span class="hljs-string">'result'</span>]) <span class="hljs-title">and</span> <span class="hljs-title">resp_dict</span>[<span class="hljs-string">'count'</span>] <span class="hljs-operator">></span> 0:
        <span class="hljs-title">transactions</span> <span class="hljs-operator">=</span> <span class="hljs-title">resp_dict</span>[<span class="hljs-string">'transactions'</span>]
        <span class="hljs-title"><span class="hljs-keyword">if</span></span> <span class="hljs-title">len</span>(<span class="hljs-title">transactions</span>) <span class="hljs-operator">></span> 0:
            <span class="hljs-title"><span class="hljs-keyword">for</span></span> <span class="hljs-title">transaction</span> <span class="hljs-title">in</span> <span class="hljs-title">transactions</span>:
                # 在哪条链上
                <span class="hljs-title">blockchain</span> <span class="hljs-operator">=</span> <span class="hljs-title">transaction</span>[<span class="hljs-string">'blockchain'</span>]

                # 代币名称
                <span class="hljs-title">symbol</span> <span class="hljs-operator">=</span> <span class="hljs-title">transaction</span>[<span class="hljs-string">'symbol'</span>]

                # 交易类型
                <span class="hljs-title">transaction_type</span> <span class="hljs-operator">=</span> <span class="hljs-title">transaction</span>[<span class="hljs-string">'transaction_type'</span>]

                # 交易<span class="hljs-title">hash</span>
                <span class="hljs-title">transaction_hash</span> <span class="hljs-operator">=</span> <span class="hljs-title">transaction</span>[<span class="hljs-string">'hash'</span>]

                # 发送地址
                <span class="hljs-title">from_address</span> <span class="hljs-operator">=</span> <span class="hljs-title">transaction</span>[<span class="hljs-string">'from'</span>][<span class="hljs-string">'address'</span>]

                # 发送地址所属
                <span class="hljs-title">from_owner</span> <span class="hljs-operator">=</span> <span class="hljs-title">transaction</span>[<span class="hljs-string">'from'</span>].<span class="hljs-title">get</span>(<span class="hljs-string">'owner'</span>, <span class="hljs-string">'Unknown'</span>)

                # 发送地址所属类型
                <span class="hljs-title">from_owner_type</span> <span class="hljs-operator">=</span> <span class="hljs-title">transaction</span>[<span class="hljs-string">'from'</span>].<span class="hljs-title">get</span>(<span class="hljs-string">'owner_type'</span>, <span class="hljs-string">'Unknown'</span>)

                # 接收地址
                <span class="hljs-title">to_address</span> <span class="hljs-operator">=</span> <span class="hljs-title">transaction</span>[<span class="hljs-string">'to'</span>][<span class="hljs-string">'address'</span>]

                # 接收地址所属
                <span class="hljs-title">to_owner</span> <span class="hljs-operator">=</span> <span class="hljs-title">transaction</span>[<span class="hljs-string">'to'</span>].<span class="hljs-title">get</span>(<span class="hljs-string">'owner'</span>, <span class="hljs-string">'Unknown'</span>)

                # 接收地址所属类型
                <span class="hljs-title">to_owner_type</span> <span class="hljs-operator">=</span> <span class="hljs-title">transaction</span>[<span class="hljs-string">'to'</span>].<span class="hljs-title">get</span>(<span class="hljs-string">'owner_type'</span>, <span class="hljs-string">'Unknown'</span>)

                # 交易时间戳
                <span class="hljs-title">transaction_timestamp</span> <span class="hljs-operator">=</span> <span class="hljs-title">transaction</span>[<span class="hljs-string">'timestamp'</span>]
                <span class="hljs-title">transaction_date</span> <span class="hljs-operator">=</span> <span class="hljs-title">time</span>.<span class="hljs-title">strftime</span>(<span class="hljs-string">'%Y-%m-%d %H:%M:%S'</span>, <span class="hljs-title">time</span>.<span class="hljs-title">localtime</span>(<span class="hljs-title">transaction_timestamp</span>))

                # 币本位总数
                <span class="hljs-title">transaction_amount</span> <span class="hljs-operator">=</span> <span class="hljs-title">str</span>(<span class="hljs-title">transaction</span>[<span class="hljs-string">'amount'</span>]) <span class="hljs-operator">+</span> <span class="hljs-string">' '</span> <span class="hljs-operator">+</span> <span class="hljs-title">symbol</span>

                # 以<span class="hljs-title">usd</span>计算价值
                <span class="hljs-title">transaction_amount_usd</span> <span class="hljs-operator">=</span> <span class="hljs-title">str</span>(<span class="hljs-title">transaction</span>[<span class="hljs-string">'amount_usd'</span>]) <span class="hljs-operator">+</span> <span class="hljs-string">' '</span> <span class="hljs-operator">+</span> <span class="hljs-string">'usd'</span>

                # 转账次数
                <span class="hljs-title">transaction_count</span> <span class="hljs-operator">=</span> <span class="hljs-title">transaction</span>[<span class="hljs-string">'transaction_count'</span>]

                <span class="hljs-title"><span class="hljs-built_in">msg</span></span> <span class="hljs-operator">=</span> <span class="hljs-string">'区块链名称'</span> <span class="hljs-operator">+</span> <span class="hljs-string">': '</span> <span class="hljs-operator">+</span> <span class="hljs-title">blockchain</span> <span class="hljs-operator">+</span> <span class="hljs-string">'\n'</span> <span class="hljs-operator">+</span> <span class="hljs-string">'符号'</span> <span class="hljs-operator">+</span> <span class="hljs-string">': '</span> <span class="hljs-operator">+</span> <span class="hljs-title">symbol</span> <span class="hljs-operator">+</span> <span class="hljs-string">'\n'</span> <span class="hljs-operator">+</span> <span class="hljs-string">'交易类型'</span> <span class="hljs-operator">+</span> <span class="hljs-string">': '</span> <span class="hljs-operator">+</span> <span class="hljs-title">transaction_type</span> <span class="hljs-operator">+</span> <span class="hljs-string">'\n'</span> <span class="hljs-operator">+</span> <span class="hljs-string">'交易hash'</span> <span class="hljs-operator">+</span> <span class="hljs-string">': '</span> <span class="hljs-operator">+</span> <span class="hljs-title">transaction_hash</span> <span class="hljs-operator">+</span> <span class="hljs-string">'\n'</span> <span class="hljs-operator">+</span> <span class="hljs-string">'交易发起者地址'</span> <span class="hljs-operator">+</span> <span class="hljs-string">': '</span> <span class="hljs-operator">+</span> <span class="hljs-title">from_address</span> <span class="hljs-operator">+</span> <span class="hljs-string">'\n'</span> <span class="hljs-operator">+</span> <span class="hljs-string">'交易发起者地址所属'</span> <span class="hljs-operator">+</span> <span class="hljs-string">': '</span> <span class="hljs-operator">+</span> <span class="hljs-title">from_owner</span> <span class="hljs-operator">+</span> <span class="hljs-string">'\n'</span> <span class="hljs-operator">+</span> <span class="hljs-string">'交易发起者地址所属类型'</span> <span class="hljs-operator">+</span> <span class="hljs-string">': '</span> <span class="hljs-operator">+</span> <span class="hljs-title">from_owner_type</span> <span class="hljs-operator">+</span> <span class="hljs-string">'\n'</span> <span class="hljs-operator">+</span> <span class="hljs-string">'交易接收地址'</span> <span class="hljs-operator">+</span> <span class="hljs-string">': '</span> <span class="hljs-operator">+</span> <span class="hljs-title">to_address</span> <span class="hljs-operator">+</span> <span class="hljs-string">'\n'</span> <span class="hljs-operator">+</span> <span class="hljs-string">'交易接收地址所属'</span> <span class="hljs-operator">+</span> <span class="hljs-string">': '</span> <span class="hljs-operator">+</span> <span class="hljs-title">to_owner</span> <span class="hljs-operator">+</span> <span class="hljs-string">'\n'</span> <span class="hljs-operator">+</span> <span class="hljs-string">'交易接收地址所属类型'</span> <span class="hljs-operator">+</span> <span class="hljs-string">': '</span> <span class="hljs-operator">+</span> <span class="hljs-title">to_owner_type</span> <span class="hljs-operator">+</span> <span class="hljs-string">'\n'</span> <span class="hljs-operator">+</span> <span class="hljs-string">'交易发生时间'</span> <span class="hljs-operator">+</span> <span class="hljs-string">': '</span> <span class="hljs-operator">+</span> <span class="hljs-title">transaction_date</span> <span class="hljs-operator">+</span> <span class="hljs-string">'\n'</span> <span class="hljs-operator">+</span> <span class="hljs-string">'币本位总额'</span> <span class="hljs-operator">+</span> <span class="hljs-string">': '</span> <span class="hljs-operator">+</span> <span class="hljs-title">str</span>(<span class="hljs-title">transaction_amount</span>) <span class="hljs-operator">+</span> <span class="hljs-string">'\n'</span> <span class="hljs-operator">+</span> <span class="hljs-string">'币本位价值usd总额'</span> <span class="hljs-operator">+</span> <span class="hljs-string">': '</span> <span class="hljs-operator">+</span> <span class="hljs-title">str</span>(<span class="hljs-title">transaction_amount_usd</span>) <span class="hljs-operator">+</span> <span class="hljs-string">'\n'</span> <span class="hljs-operator">+</span> <span class="hljs-string">'交易转账次数'</span> <span class="hljs-operator">+</span> <span class="hljs-string">': '</span> <span class="hljs-operator">+</span> <span class="hljs-title">str</span>(<span class="hljs-title">transaction_count</span>) <span class="hljs-operator">+</span> <span class="hljs-string">'\n'</span> <span class="hljs-operator">+</span> <span class="hljs-string">'区块链浏览器详情'</span> <span class="hljs-operator">+</span> <span class="hljs-string">': '</span> <span class="hljs-operator">+</span> <span class="hljs-title">base_scan_url</span> <span class="hljs-operator">+</span> <span class="hljs-string">'/'</span> <span class="hljs-operator">+</span> <span class="hljs-title">blockchain</span> <span class="hljs-operator">+</span> <span class="hljs-string">'/'</span> <span class="hljs-operator">+</span> <span class="hljs-title">transaction_hash</span>
                <span class="hljs-title">msgs</span>.<span class="hljs-title">append</span>(<span class="hljs-title"><span class="hljs-built_in">msg</span></span>)

    <span class="hljs-title"><span class="hljs-keyword">if</span></span> <span class="hljs-title">len</span>(<span class="hljs-title">msgs</span>) <span class="hljs-operator">></span> 0:
        # 发送到微信
        <span class="hljs-title"><span class="hljs-keyword">for</span></span> <span class="hljs-title"><span class="hljs-built_in">msg</span></span> <span class="hljs-title">in</span> <span class="hljs-title">msgs</span>:
            # 1 代表往企业总群发
            <span class="hljs-title">SendWeiXinWork</span>.<span class="hljs-title">send_message</span>(<span class="hljs-string">"1"</span>, <span class="hljs-title">str</span>(<span class="hljs-title"><span class="hljs-built_in">msg</span></span>))
            <span class="hljs-title">print</span>(<span class="hljs-title"><span class="hljs-built_in">msg</span></span>)


<span class="hljs-title"><span class="hljs-keyword">if</span></span> <span class="hljs-title">__name__</span> <span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-string">'__main__'</span>:
    <span class="hljs-title">main</span>()
</code></pre><p>注：代码里面当转账数额 &gt; 500K 才会预警，要修改的话，改# 警报的最小价值 min_value = 5000000 这个参数。免费账号最小是500K。</p><p><strong>send_msgs_to_wechat.py</strong></p><pre data-type="codeBlock" text="# -*- coding : utf-8 -*-
# @DATE:2022/6/20 16:47
import requests, configparser, os

config_path = os.path.join(&quot;properties.conf&quot;)
# 获取配置文件对象
cf = configparser.ConfigParser()
# 读取配置
cf.read(config_path, encoding=&apos;utf-8&apos;)

# os.environ[&quot;http_proxy&quot;] = &quot;http://127.0.0.1:10810&quot;
# os.environ[&quot;https_proxy&quot;] = &quot;http://127.0.0.1:10810&quot;


class SendWeiXinWork():
    def __init__(self):
        self.CORP_ID = cf.get(&quot;Wei Xin&quot;, &quot;CORP_ID&quot;)  # 企业号的标识
        self.SECRET = cf.get(&quot;Wei Xin&quot;, &quot;SECRET&quot;)  # 管理组凭证密钥
        self.AGENT_ID = cf.get(&quot;Wei Xin&quot;, &quot;AGENT_ID&quot;)  # 应用ID
        self.token = self.get_token()

    def get_token(self):
        url = &quot;https://qyapi.weixin.qq.com/cgi-bin/gettoken&quot;
        data = {
            &quot;corpid&quot;: self.CORP_ID,
            &quot;corpsecret&quot;: self.SECRET
        }
        req = requests.get(url=url, params=data)
        res = req.json()
        if res[&quot;errmsg&quot;] == &quot;ok&quot;:
            return res[&quot;access_token&quot;]
        else:
            return res

    def send_message(self, to_user, content):
        url = &quot;https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=%s&quot; % self.token
        data = {
            # &quot;touser&quot;: to_user,  # 发送个人就填用户账号
            &quot;toparty&quot;: to_user,  # 发送组内成员就填部门ID
            &quot;msgtype&quot;: &quot;text&quot;,
            &quot;agentid&quot;: self.AGENT_ID,
            &quot;text&quot;: {&quot;content&quot;: content},
            &quot;safe&quot;: &quot;0&quot;
        }

        req = requests.post(url=url, json=data)
        res = req.json()
        if res[&quot;errmsg&quot;] == &quot;ok&quot;:
            print(&quot;send message sucessed&quot;)
            return &quot;send message sucessed&quot;
        else:
            return res


# if __name__ == &apos;__main__&apos;:
#     # 创建发送消息对象
#     SendWeiXinWork = SendWeiXinWork()
#     SendWeiXinWork.send_message(&quot;1&quot;, &apos;a&apos; + &apos;\n&apos; + &apos;b&apos;)
"><code># <span class="hljs-operator">-</span><span class="hljs-operator">*</span><span class="hljs-operator">-</span> coding : utf<span class="hljs-number">-8</span> <span class="hljs-operator">-</span><span class="hljs-operator">*</span><span class="hljs-operator">-</span>
# @DATE:<span class="hljs-number">2022</span><span class="hljs-operator">/</span><span class="hljs-number">6</span><span class="hljs-operator">/</span><span class="hljs-number">20</span> <span class="hljs-number">16</span>:<span class="hljs-number">47</span>
<span class="hljs-keyword">import</span> <span class="hljs-title">requests</span>, <span class="hljs-title">configparser</span>, <span class="hljs-title">os</span>

<span class="hljs-title">config_path</span> <span class="hljs-operator">=</span> <span class="hljs-title">os</span>.<span class="hljs-title">path</span>.<span class="hljs-title">join</span>(<span class="hljs-string">"properties.conf"</span>)
# 获取配置文件对象
<span class="hljs-title">cf</span> <span class="hljs-operator">=</span> <span class="hljs-title">configparser</span>.<span class="hljs-title">ConfigParser</span>()
# 读取配置
<span class="hljs-title">cf</span>.<span class="hljs-title">read</span>(<span class="hljs-title">config_path</span>, <span class="hljs-title">encoding</span><span class="hljs-operator">=</span><span class="hljs-string">'utf-8'</span>)

# <span class="hljs-title">os</span>.<span class="hljs-title">environ</span>[<span class="hljs-string">"http_proxy"</span>] <span class="hljs-operator">=</span> <span class="hljs-string">"http://127.0.0.1:10810"</span>
# <span class="hljs-title">os</span>.<span class="hljs-title">environ</span>[<span class="hljs-string">"https_proxy"</span>] <span class="hljs-operator">=</span> <span class="hljs-string">"http://127.0.0.1:10810"</span>


<span class="hljs-title">class</span> <span class="hljs-title">SendWeiXinWork</span>():
    <span class="hljs-title">def</span> <span class="hljs-title">__init__</span>(<span class="hljs-title"><span class="hljs-built_in">self</span></span>):
        <span class="hljs-title"><span class="hljs-built_in">self</span></span>.<span class="hljs-title">CORP_ID</span> <span class="hljs-operator">=</span> <span class="hljs-title">cf</span>.<span class="hljs-title">get</span>(<span class="hljs-string">"Wei Xin"</span>, <span class="hljs-string">"CORP_ID"</span>)  # 企业号的标识
        <span class="hljs-title"><span class="hljs-built_in">self</span></span>.<span class="hljs-title">SECRET</span> <span class="hljs-operator">=</span> <span class="hljs-title">cf</span>.<span class="hljs-title">get</span>(<span class="hljs-string">"Wei Xin"</span>, <span class="hljs-string">"SECRET"</span>)  # 管理组凭证密钥
        <span class="hljs-title"><span class="hljs-built_in">self</span></span>.<span class="hljs-title">AGENT_ID</span> <span class="hljs-operator">=</span> <span class="hljs-title">cf</span>.<span class="hljs-title">get</span>(<span class="hljs-string">"Wei Xin"</span>, <span class="hljs-string">"AGENT_ID"</span>)  # 应用<span class="hljs-title">ID</span>
        <span class="hljs-title"><span class="hljs-built_in">self</span></span>.<span class="hljs-title">token</span> <span class="hljs-operator">=</span> <span class="hljs-title"><span class="hljs-built_in">self</span></span>.<span class="hljs-title">get_token</span>()

    <span class="hljs-title">def</span> <span class="hljs-title">get_token</span>(<span class="hljs-title"><span class="hljs-built_in">self</span></span>):
        <span class="hljs-title">url</span> <span class="hljs-operator">=</span> <span class="hljs-string">"https://qyapi.weixin.qq.com/cgi-bin/gettoken"</span>
        <span class="hljs-title">data</span> <span class="hljs-operator">=</span> {
            <span class="hljs-string">"corpid"</span>: <span class="hljs-title"><span class="hljs-built_in">self</span></span>.<span class="hljs-title">CORP_ID</span>,
            <span class="hljs-string">"corpsecret"</span>: <span class="hljs-title"><span class="hljs-built_in">self</span></span>.<span class="hljs-title">SECRET</span>
        }
        <span class="hljs-title">req</span> <span class="hljs-operator">=</span> <span class="hljs-title">requests</span>.<span class="hljs-title">get</span>(<span class="hljs-title">url</span><span class="hljs-operator">=</span><span class="hljs-title">url</span>, <span class="hljs-title">params</span><span class="hljs-operator">=</span><span class="hljs-title">data</span>)
        <span class="hljs-title">res</span> <span class="hljs-operator">=</span> <span class="hljs-title">req</span>.<span class="hljs-title">json</span>()
        <span class="hljs-title"><span class="hljs-keyword">if</span></span> <span class="hljs-title">res</span>[<span class="hljs-string">"errmsg"</span>] <span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-string">"ok"</span>:
            <span class="hljs-title"><span class="hljs-keyword">return</span></span> <span class="hljs-title">res</span>[<span class="hljs-string">"access_token"</span>]
        <span class="hljs-title"><span class="hljs-keyword">else</span></span>:
            <span class="hljs-title"><span class="hljs-keyword">return</span></span> <span class="hljs-title">res</span>

    <span class="hljs-title">def</span> <span class="hljs-title">send_message</span>(<span class="hljs-title"><span class="hljs-built_in">self</span></span>, <span class="hljs-title">to_user</span>, <span class="hljs-title">content</span>):
        <span class="hljs-title">url</span> <span class="hljs-operator">=</span> <span class="hljs-string">"https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=%s"</span> <span class="hljs-operator">%</span> <span class="hljs-title"><span class="hljs-built_in">self</span></span>.<span class="hljs-title">token</span>
        <span class="hljs-title">data</span> <span class="hljs-operator">=</span> {
            # <span class="hljs-string">"touser"</span>: <span class="hljs-title">to_user</span>,  # 发送个人就填用户账号
            <span class="hljs-string">"toparty"</span>: <span class="hljs-title">to_user</span>,  # 发送组内成员就填部门<span class="hljs-title">ID</span>
            <span class="hljs-string">"msgtype"</span>: <span class="hljs-string">"text"</span>,
            <span class="hljs-string">"agentid"</span>: <span class="hljs-title"><span class="hljs-built_in">self</span></span>.<span class="hljs-title">AGENT_ID</span>,
            <span class="hljs-string">"text"</span>: {<span class="hljs-string">"content"</span>: <span class="hljs-title">content</span>},
            <span class="hljs-string">"safe"</span>: <span class="hljs-string">"0"</span>
        }

        <span class="hljs-title">req</span> <span class="hljs-operator">=</span> <span class="hljs-title">requests</span>.<span class="hljs-title">post</span>(<span class="hljs-title">url</span><span class="hljs-operator">=</span><span class="hljs-title">url</span>, <span class="hljs-title">json</span><span class="hljs-operator">=</span><span class="hljs-title">data</span>)
        <span class="hljs-title">res</span> <span class="hljs-operator">=</span> <span class="hljs-title">req</span>.<span class="hljs-title">json</span>()
        <span class="hljs-title"><span class="hljs-keyword">if</span></span> <span class="hljs-title">res</span>[<span class="hljs-string">"errmsg"</span>] <span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-string">"ok"</span>:
            <span class="hljs-title">print</span>(<span class="hljs-string">"send message sucessed"</span>)
            <span class="hljs-title"><span class="hljs-keyword">return</span></span> <span class="hljs-string">"send message sucessed"</span>
        <span class="hljs-title"><span class="hljs-keyword">else</span></span>:
            <span class="hljs-title"><span class="hljs-keyword">return</span></span> <span class="hljs-title">res</span>


# <span class="hljs-title"><span class="hljs-keyword">if</span></span> <span class="hljs-title">__name__</span> <span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-string">'__main__'</span>:
#     # 创建发送消息对象
#     <span class="hljs-title">SendWeiXinWork</span> <span class="hljs-operator">=</span> <span class="hljs-title">SendWeiXinWork</span>()
#     <span class="hljs-title">SendWeiXinWork</span>.<span class="hljs-title">send_message</span>(<span class="hljs-string">"1"</span>, <span class="hljs-string">'a'</span> <span class="hljs-operator">+</span> <span class="hljs-string">'\n'</span> <span class="hljs-operator">+</span> <span class="hljs-string">'b'</span>)
</code></pre><p><strong>properties.conf</strong></p><p>这里面主要放申请的key什么的。</p><pre data-type="codeBlock" text="[Whale Alert]
api_key = &apos;你申请的key&apos;

[Wei Xin]
XXX = &apos;&apos;
"><code><span class="hljs-section">[Whale Alert]</span>
<span class="hljs-attr">api_key</span> = <span class="hljs-string">'你申请的key'</span>

<span class="hljs-section">[Wei Xin]</span>
<span class="hljs-attr">XXX</span> = <span class="hljs-string">''</span>
</code></pre><p>注：关于企业微信的申请和发送消息。我就不写了，也是参考下面这位大佬的。</p><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.jb51.net/article/244955.htm">https://www.jb51.net/article/244955.htm</a></p><p><strong>效果图</strong></p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/ed6cce9966e3d6bf8ea6542c52b05ba5796777a89f7d8b7645f7eb44a7551509.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>后面就是部署到服务器上，然后定时调度就行了。这个教程后面出，今天还有其他事情要忙。</p><p>需要提的是：</p><p>1、CentOS7 上默认安装的python版本是2.X的。本篇中用的是3.7，所以需要重新软链接到python3。<strong>切记不要把2.X删掉，要不然yum就用不了了</strong></p><p>2、调度器用自带的crontab 就行。</p>]]></content:encoded>
            <author>0xd74e84f97ef3ea7fe9be2ebdaced17e11ecfc9a8@newsletter.paragraph.com (撒酒狂歌)</author>
            <enclosure url="https://storage.googleapis.com/papyrus_images/b245266822d62559e5ba53c7bb25955bad2ab69c9fa164992e660baa7ab148d4.png" length="0" type="image/png"/>
        </item>
        <item>
            <title><![CDATA[分析dune上Charm计算Uniswap v3 LP 操作策略Alpha Vault TVL的计算逻辑]]></title>
            <link>https://paragraph.com/@0xd74e84f97ef3ea7fe9be2ebdaced17e11ecfc9a8/dune-charm-uniswap-v3-lp-alpha-vault-tvl</link>
            <guid>iJ2Fj7QYht7RoVwvpfrO</guid>
            <pubDate>Thu, 09 Jun 2022 17:26:53 GMT</pubDate>
            <description><![CDATA[一：首先需要了解Alpha Vault是什么以及操作流程 uniswap v3集中流动性： 集中流动性意味着LP（流动性提供者）可以根据自己的意愿向任何价格范围/价格变动提供流动性，这导致流动性在价格变动中不平衡。 不同价格范围的流动性深度不同，深度不同导致获取的收益不同。 根据当前价格和目标价格范围，存在以下三种情况 （1）当前价格在目标价格区间 1、当前价格是目标价格范围的中心 当价格范围为[8，12]时，当前价格= 10。LP在相同价值的两个代币中提供流动性 2、当前价格不是目标价格范围的中心 LP仍然必须在两个代币中提供流动性，而每个代币的数量取决于当前价格和价格范围之间的距离 （2）当前价格 < 目标价格区间最小值 （3）当前价格 > 目标价格区间最大值 在情况2和3中，只需要或允许两个代币中的一个。 理解如何发现价格： x * y = k x和y代表两种代币的数量，k是常量 x相对于y的价格是 y / x，这意味着1单位X可以获得多少Y，反之亦然,y相对于x的价格是x/y。 为了X的价格上涨，y必须增加，x必须减少。 举例： 假设流LPs打算在高于当前价格x=10的区...]]></description>
            <content:encoded><![CDATA[<p>一：首先需要了解Alpha Vault是什么以及操作流程</p><p>uniswap v3集中流动性： 集中流动性意味着LP（流动性提供者）可以根据自己的意愿向任何价格范围/价格变动提供流动性，这导致流动性在价格变动中不平衡。</p><p>不同价格范围的流动性深度不同，深度不同导致获取的收益不同。</p><p>根据当前价格和目标价格范围，存在以下三种情况 （1）当前价格在目标价格区间 1、当前价格是目标价格范围的中心 当价格范围为[8，12]时，当前价格= 10。LP在相同价值的两个代币中提供流动性</p><p>2、当前价格不是目标价格范围的中心 LP仍然必须在两个代币中提供流动性，而每个代币的数量取决于当前价格和价格范围之间的距离</p><p>（2）当前价格 &lt; 目标价格区间最小值 （3）当前价格 &gt; 目标价格区间最大值 在情况2和3中，只需要或允许两个代币中的一个。 理解如何发现价格： x * y = k x和y代表两种代币的数量，k是常量 x相对于y的价格是 y / x，这意味着1单位X可以获得多少Y，反之亦然,y相对于x的价格是x/y。 为了X的价格上涨，y必须增加，x必须减少。</p><p>举例： 假设流LPs打算在高于当前价格x=10的区间——[15.625, 17.313]提供流动性。 （虽然没写，但是y的价格应该是1） 一个x = 1000 / 100 = 10个y</p><p>100(x) * 1000(y) = 100000(k)</p><p>当x价格上涨到15.625时，理解为：一个x可以换15.625个y了 80(x) * 1250(y) = 100000(k)</p><p>当x价格上涨到17.313时，理解为：一个x可以换17.313个y了 76(x) * 1315.789(y) = 100000(k)</p><p>X的价格进一步走高的唯一方法是进一步增加y和减少x</p><p>因此，要提供 [15.625, 17.313] 范围内的流动性，只需准备 80 - 76 = 4 个X。如果价格超过17.313，则 LP 的所有4个 X 都被交换为1315.789 - 1250 = 65.798 Y，然后 LP 与资金池不再有任何关系，因为他/她的流动性已经耗尽。</p><p>如果价格保持在该范围内: x的个数将在76~80之间摆动，y同理。只有当代币变得更有价值时，它才会被交换为价值较低的代币。</p><p>Alpha Vault： 自动为管理Uniswap V3上的流动性。集中流动性以获得更高的收益率，并定期被动再平衡以减少无常损失。 当两种资产变得不平衡且无法将其全部投入机枪池时，Vault 首先将两种资产的最大可用量投入机枪池中，然后再用有结余的一种资产投下另一个范围定单 。</p><p>被动再平衡</p><p>举例： 最初我们拥有的资产 50％ 为 ETH，另外 50％ 为 USDC。 一天后，随着 ETH 价格下跌，我们获得了更多的 ETH，而 USDC 减少了。</p><p>ETH 价格 = 3000 美元 : (50% ETH, 50% USDC) ETH 价格 = 2500 美元 : (70% ETH, 30% USDC) -&gt; 资产全部取出 现在，假设我们可以在当前价格范围内输入机枪池的两者最大金额为 30％ ETH 和 30％ USDC。</p><p>Vault 的工作是先提取所有流动性，然后投下由 30％ ETH、 30％ USDC 组成的基础订单和由 40％ ETH，0 USDC 组成的限价 / 重新平衡订单。</p><p>基础订单 : (30% ETH, 30% USDC) -&gt; 按当前价格范围下单 限价 / 重新平衡订单 : (40% ETH, 0 USDC) -&gt; 下单的价格范围 ≥ 现价 , 例如 : (2500, 2600), 这样当价格上涨时 ETH 可以被兑换成 USDC。</p><p>如果 ETH 有结余，以高于当前价格的区间值投入 ETH。</p><p>同样，如果我们有 USDC 结余，则将结余的 USDC 投入价格 ≤ 当前价格的范围内，这样当价格下跌时，可以将 USDC 兑换为 ETH。</p><p>限价 / 重新平衡订单的作用是避免直接 swapping （将 20％ ETH 兑换成 20％USDC），那样做会导致被收取 0.1〜1％ 的交易费，而是要通过提供流动性自然地发生 swapping，这样不花一分钱手续费，甚至还可以赚取交易费。</p><p><strong>又产生了一个问题：如果ETH一直跌，不上涨。按上面的限价单就无法成交了（下单的价格范围 ≥ ETH现价）</strong></p><p>二：SQL分析</p><pre data-type="codeBlock" text="-- Uniswap v3 LP 操作策略——Alpha Vault
-- postgresql 在一条sql语句中使用多个with。就是这个写法，不用纠结。

-- 交易对临时表
-- 1、用户将资产存入到vault里面，所以关联交易对mint事件表的时候，资产的所有者相当于vault的合约地址
-- 2、交易对mint事件表中contract_address字段的地址是Uniswap V3: USDT的合约。
-- 3、工厂创建池事件表中contract_address字段的地址其实指的是提供流动性后nft的合约。pool地址才是交易对的合约地址
-- 4、串联下：用户存入到Vault，Vault作为owner和sender将资产发送到Uniswap V3: USDT的合约，通过合约地址即可拿到交易对两个token的地址。
WITH pairs AS (
    SELECT
        charm.contract_address AS vault, 
        fac_pool.token0,
        fac_pool.token1 
    FROM
        charm.&quot;AlphaVault_evt_Deposit&quot; charm       -- Alpha Vault 存入事件表
        INNER JOIN uniswap_v3.&quot;Pair_evt_Mint&quot; AS uni  -- 交易对mint事件表
            ON charm.contract_address = uni.owner
        INNER JOIN uniswap_v3.&quot;Factory_evt_PoolCreated&quot; AS fac_pool  -- 工厂创建池事件表
            ON uni.contract_address = pool 
    GROUP BY  -- 等于去重效果
        1,
        2,
        3 
    ),
-- 	存入与提取临时表
-- 用了union all，相当于将几个查询的结果合并到一起（用union all的时候，列数需要相同）。只要读懂一个select的逻辑，就都明白了。
    deposits_and_withdrawals AS (
-- 以下开始是计算token存入的逻辑。
    SELECT
        evt_block_time,
        amount0 / 10 ^ decimals * price AS amount   -- 10^6表示的是10的6次方。prices库usd表有decimal字段，申明了小数点精度
    FROM
        charm.&quot;AlphaVault_evt_Deposit&quot; charm
        INNER JOIN pairs ON vault = charm.contract_address      -- 通过合约地址关联上面的pairs表，从pairs表得到token地址。
        INNER JOIN prices.usd p ON token0 = p.contract_address  -- 用tonken地址关联，从prices库中的usd表取出token的价格
        AND date_trunc ( &apos;minute&apos;, evt_block_time ) = MINUTE 		-- MINUTE是prices库中的usd表字段。相当于交易发生时候的token价格
        
    UNION ALL
    
    SELECT
        evt_block_time,
        amount1 / 10 ^ decimals * price 
    FROM
        charm.&quot;AlphaVault_evt_Deposit&quot; charm
        INNER JOIN pairs ON vault = charm.contract_address
        INNER JOIN prices.usd p ON token1 = p.contract_address 
        AND date_trunc ( &apos;minute&apos;, evt_block_time ) = MINUTE 
        
    UNION ALL
    
-- 	以下开始是计算token提现的逻辑。所以amount为负数
    SELECT
        evt_block_time,
        - amount0 / 10 ^ decimals * price 
    FROM
        charm.&quot;AlphaVault_evt_Withdraw&quot; charm
        INNER JOIN pairs ON vault = charm.contract_address
        INNER JOIN prices.usd p ON token0 = p.contract_address 
        AND date_trunc ( &apos;minute&apos;, evt_block_time ) = MINUTE 
        
    UNION ALL
    
    SELECT
        evt_block_time,
        - amount1 / 10 ^ decimals * price 
    FROM
        charm.&quot;AlphaVault_evt_Withdraw&quot; charm
        INNER JOIN pairs ON vault = charm.contract_address
        INNER JOIN prices.usd p ON token1 = p.contract_address 
        AND date_trunc ( &apos;minute&apos;, evt_block_time ) = MINUTE 
    ) 
    
-- 根据上面的”临时表“求和
SELECT
    evt_block_time,
    -- 这个over跟hive里面应该是一样的。属于开窗函数。相当于根据时间排序。hive里面经常搭配partition by使用。比如一个班的同学考试成绩排名
    sum( amount ) OVER ( ORDER BY evt_block_time )  
FROM
    deposits_and_withdrawals
"><code><span class="hljs-comment">-- Uniswap v3 LP 操作策略——Alpha Vault</span>
<span class="hljs-comment">-- postgresql 在一条sql语句中使用多个with。就是这个写法，不用纠结。</span>

<span class="hljs-comment">-- 交易对临时表</span>
<span class="hljs-comment">-- 1、用户将资产存入到vault里面，所以关联交易对mint事件表的时候，资产的所有者相当于vault的合约地址</span>
<span class="hljs-comment">-- 2、交易对mint事件表中contract_address字段的地址是Uniswap V3: USDT的合约。</span>
<span class="hljs-comment">-- 3、工厂创建池事件表中contract_address字段的地址其实指的是提供流动性后nft的合约。pool地址才是交易对的合约地址</span>
<span class="hljs-comment">-- 4、串联下：用户存入到Vault，Vault作为owner和sender将资产发送到Uniswap V3: USDT的合约，通过合约地址即可拿到交易对两个token的地址。</span>
<span class="hljs-keyword">WITH</span> pairs <span class="hljs-keyword">AS</span> (
    <span class="hljs-keyword">SELECT</span>
        charm.contract_address <span class="hljs-keyword">AS</span> vault, 
        fac_pool.token0,
        fac_pool.token1 
    <span class="hljs-keyword">FROM</span>
        charm."AlphaVault_evt_Deposit" charm       <span class="hljs-comment">-- Alpha Vault 存入事件表</span>
        <span class="hljs-keyword">INNER</span> <span class="hljs-keyword">JOIN</span> uniswap_v3."Pair_evt_Mint" <span class="hljs-keyword">AS</span> uni  <span class="hljs-comment">-- 交易对mint事件表</span>
            <span class="hljs-keyword">ON</span> charm.contract_address <span class="hljs-operator">=</span> uni.owner
        <span class="hljs-keyword">INNER</span> <span class="hljs-keyword">JOIN</span> uniswap_v3."Factory_evt_PoolCreated" <span class="hljs-keyword">AS</span> fac_pool  <span class="hljs-comment">-- 工厂创建池事件表</span>
            <span class="hljs-keyword">ON</span> uni.contract_address <span class="hljs-operator">=</span> pool 
    <span class="hljs-keyword">GROUP</span> <span class="hljs-keyword">BY</span>  <span class="hljs-comment">-- 等于去重效果</span>
        <span class="hljs-number">1</span>,
        <span class="hljs-number">2</span>,
        <span class="hljs-number">3</span> 
    ),
<span class="hljs-comment">-- 	存入与提取临时表</span>
<span class="hljs-comment">-- 用了union all，相当于将几个查询的结果合并到一起（用union all的时候，列数需要相同）。只要读懂一个select的逻辑，就都明白了。</span>
    deposits_and_withdrawals <span class="hljs-keyword">AS</span> (
<span class="hljs-comment">-- 以下开始是计算token存入的逻辑。</span>
    <span class="hljs-keyword">SELECT</span>
        evt_block_time,
        amount0 <span class="hljs-operator">/</span> <span class="hljs-number">10</span> <span class="hljs-operator">^</span> decimals <span class="hljs-operator">*</span> price <span class="hljs-keyword">AS</span> amount   <span class="hljs-comment">-- 10^6表示的是10的6次方。prices库usd表有decimal字段，申明了小数点精度</span>
    <span class="hljs-keyword">FROM</span>
        charm."AlphaVault_evt_Deposit" charm
        <span class="hljs-keyword">INNER</span> <span class="hljs-keyword">JOIN</span> pairs <span class="hljs-keyword">ON</span> vault <span class="hljs-operator">=</span> charm.contract_address      <span class="hljs-comment">-- 通过合约地址关联上面的pairs表，从pairs表得到token地址。</span>
        <span class="hljs-keyword">INNER</span> <span class="hljs-keyword">JOIN</span> prices.usd p <span class="hljs-keyword">ON</span> token0 <span class="hljs-operator">=</span> p.contract_address  <span class="hljs-comment">-- 用tonken地址关联，从prices库中的usd表取出token的价格</span>
        <span class="hljs-keyword">AND</span> date_trunc ( <span class="hljs-string">'minute'</span>, evt_block_time ) <span class="hljs-operator">=</span> <span class="hljs-keyword">MINUTE</span> 		<span class="hljs-comment">-- MINUTE是prices库中的usd表字段。相当于交易发生时候的token价格</span>
        
    <span class="hljs-keyword">UNION</span> <span class="hljs-keyword">ALL</span>
    
    <span class="hljs-keyword">SELECT</span>
        evt_block_time,
        amount1 <span class="hljs-operator">/</span> <span class="hljs-number">10</span> <span class="hljs-operator">^</span> decimals <span class="hljs-operator">*</span> price 
    <span class="hljs-keyword">FROM</span>
        charm."AlphaVault_evt_Deposit" charm
        <span class="hljs-keyword">INNER</span> <span class="hljs-keyword">JOIN</span> pairs <span class="hljs-keyword">ON</span> vault <span class="hljs-operator">=</span> charm.contract_address
        <span class="hljs-keyword">INNER</span> <span class="hljs-keyword">JOIN</span> prices.usd p <span class="hljs-keyword">ON</span> token1 <span class="hljs-operator">=</span> p.contract_address 
        <span class="hljs-keyword">AND</span> date_trunc ( <span class="hljs-string">'minute'</span>, evt_block_time ) <span class="hljs-operator">=</span> <span class="hljs-keyword">MINUTE</span> 
        
    <span class="hljs-keyword">UNION</span> <span class="hljs-keyword">ALL</span>
    
<span class="hljs-comment">-- 	以下开始是计算token提现的逻辑。所以amount为负数</span>
    <span class="hljs-keyword">SELECT</span>
        evt_block_time,
        <span class="hljs-operator">-</span> amount0 <span class="hljs-operator">/</span> <span class="hljs-number">10</span> <span class="hljs-operator">^</span> decimals <span class="hljs-operator">*</span> price 
    <span class="hljs-keyword">FROM</span>
        charm."AlphaVault_evt_Withdraw" charm
        <span class="hljs-keyword">INNER</span> <span class="hljs-keyword">JOIN</span> pairs <span class="hljs-keyword">ON</span> vault <span class="hljs-operator">=</span> charm.contract_address
        <span class="hljs-keyword">INNER</span> <span class="hljs-keyword">JOIN</span> prices.usd p <span class="hljs-keyword">ON</span> token0 <span class="hljs-operator">=</span> p.contract_address 
        <span class="hljs-keyword">AND</span> date_trunc ( <span class="hljs-string">'minute'</span>, evt_block_time ) <span class="hljs-operator">=</span> <span class="hljs-keyword">MINUTE</span> 
        
    <span class="hljs-keyword">UNION</span> <span class="hljs-keyword">ALL</span>
    
    <span class="hljs-keyword">SELECT</span>
        evt_block_time,
        <span class="hljs-operator">-</span> amount1 <span class="hljs-operator">/</span> <span class="hljs-number">10</span> <span class="hljs-operator">^</span> decimals <span class="hljs-operator">*</span> price 
    <span class="hljs-keyword">FROM</span>
        charm."AlphaVault_evt_Withdraw" charm
        <span class="hljs-keyword">INNER</span> <span class="hljs-keyword">JOIN</span> pairs <span class="hljs-keyword">ON</span> vault <span class="hljs-operator">=</span> charm.contract_address
        <span class="hljs-keyword">INNER</span> <span class="hljs-keyword">JOIN</span> prices.usd p <span class="hljs-keyword">ON</span> token1 <span class="hljs-operator">=</span> p.contract_address 
        <span class="hljs-keyword">AND</span> date_trunc ( <span class="hljs-string">'minute'</span>, evt_block_time ) <span class="hljs-operator">=</span> <span class="hljs-keyword">MINUTE</span> 
    ) 
    
<span class="hljs-comment">-- 根据上面的”临时表“求和</span>
<span class="hljs-keyword">SELECT</span>
    evt_block_time,
    <span class="hljs-comment">-- 这个over跟hive里面应该是一样的。属于开窗函数。相当于根据时间排序。hive里面经常搭配partition by使用。比如一个班的同学考试成绩排名</span>
    <span class="hljs-built_in">sum</span>( amount ) <span class="hljs-keyword">OVER</span> ( <span class="hljs-keyword">ORDER</span> <span class="hljs-keyword">BY</span> evt_block_time )  
<span class="hljs-keyword">FROM</span>
    deposits_and_withdrawals
</code></pre><p>deposits_and_withdrawals 里面用了多次前面with as创建的表pairs。相当于子查询，非常影响效率，我想是因为dune不给用户创建临时表的权限吧。要不然创建只在当前session生效的临时表，会比子查询快多了。</p>]]></content:encoded>
            <author>0xd74e84f97ef3ea7fe9be2ebdaced17e11ecfc9a8@newsletter.paragraph.com (撒酒狂歌)</author>
        </item>
        <item>
            <title><![CDATA[python爬取区块链浏览器上的交易列表数据]]></title>
            <link>https://paragraph.com/@0xd74e84f97ef3ea7fe9be2ebdaced17e11ecfc9a8/python</link>
            <guid>GKO1z9au0B5OWHPoMk6K</guid>
            <pubDate>Fri, 03 Jun 2022 14:00:53 GMT</pubDate>
            <description><![CDATA[前言2022年6月3日 端午节安康。 今天主要分享如何利用爬虫爬取区块链浏览器上的交易列表数据。原因dune上没有bsc链上的转账明细数据表。Footprint Analytics上现有的bsc_transactions表transfer_type粒度不够。环境python 3.7 数据存储：mysql 5.7 缓存：redis 6.2.6 开发工具：pycharm思路（1）所有协议、合约、swap地址转账信息全爬不太实际，对存储要求比较高。所以针对需要分析的协议，专门去爬取对应智能合约转账是个不错的选择。 （2）区块链浏览器肯定是有反爬机制的。所以在代理选择上，要选择国外的代理。国内的代理都访问不到，具体原因你懂的。本文中不涉及代理部分，因为国外的代理厂家之前没有了解过。不过即使是上代理，对代码层面改动也比较小 （3）采用了urllib同步请求 + 范围内随机时长程序休眠。减少了被风控的概率。但是也降低了爬虫的效率。 后面再研究用scrapy或异步请求 [1] [1] 同步：请求发送后，需要接受到返回的消息后，才进行下一次发送。异步：不需要等接收到返回的消息。实现找到需要爬取合...]]></description>
            <content:encoded><![CDATA[<h1 id="h-" class="text-4xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">前言</h1><p>2022年6月3日 端午节安康。</p><p>今天主要分享如何利用爬虫爬取区块链浏览器上的交易列表数据。</p><h1 id="h-" class="text-4xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">原因</h1><p>dune上没有bsc链上的转账明细数据表。Footprint Analytics上现有的bsc_transactions表transfer_type粒度不够。</p><h1 id="h-" class="text-4xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">环境</h1><p>python 3.7</p><p>数据存储：mysql 5.7</p><p>缓存：redis 6.2.6</p><p>开发工具：pycharm</p><h1 id="h-" class="text-4xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">思路</h1><p>（1）所有协议、合约、swap地址转账信息全爬不太实际，对存储要求比较高。所以针对需要分析的协议，专门去爬取对应智能合约转账是个不错的选择。</p><p>（2）区块链浏览器肯定是有反爬机制的。所以在代理选择上，要选择国外的代理。国内的代理都访问不到，具体原因你懂的。<strong>本文中不涉及代理部分，因为国外的代理厂家之前没有了解过。不过即使是上代理，对代码层面改动也比较小</strong></p><p>（3）采用了urllib同步请求 + 范围内随机时长程序休眠。减少了被风控的概率。但是也降低了爬虫的效率。</p><p><strong>后面再研究用scrapy或异步请求</strong> [1]</p><p>[1] 同步：请求发送后，需要接受到返回的消息后，才进行下一次发送。异步：不需要等接收到返回的消息。</p><h1 id="h-" class="text-4xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">实现</h1><p>找到需要爬取合约的具体地址：</p><p>第一页</p><pre data-type="codeBlock" text="http://bscscan.com/txs?a=0xbd3bd95529e0784ad973fd14928eedf3678cfad8
"><code>http://bscscan.com/txs?<span class="hljs-attr">a</span>=<span class="hljs-number">0</span>xbd3bd95529e0784ad973fd14928eedf3678cfad8
</code></pre><p>第二页</p><pre data-type="codeBlock" text="
https://bscscan.com/txs?a=0xbd3bd95529e0784ad973fd14928eedf3678cfad8&amp;p=2
"><code>
https://bscscan.com/txs?<span class="hljs-attr">a</span>=<span class="hljs-number">0</span>xbd3bd95529e0784ad973fd14928eedf3678cfad8&#x26;p=<span class="hljs-number">2</span>
</code></pre><p>第三页</p><pre data-type="codeBlock" text="
https://bscscan.com/txs?a=0xbd3bd95529e0784ad973fd14928eedf3678cfad8&amp;p=3
"><code>
https://bscscan.com/txs?<span class="hljs-attr">a</span>=<span class="hljs-number">0</span>xbd3bd95529e0784ad973fd14928eedf3678cfad8&#x26;p=<span class="hljs-number">3</span>
</code></pre><p>....</p><p>可以知道 p = ？就代表页数。</p><p>然后F12 点击“网络”，刷新界面，查看网络请求信息。</p><p>主要查看，网页上显示的数据，是哪个文件响应的。以什么方式响应的，请求方法是什么</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/1c4b421cdee3b57a0519d398f4c156d857148039faf58d3d3e36a18ef47e7224.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/7aa8448b799731fd41c6791dc58aaed997e540ef79391dd6ccbebe0759b342f9.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>如何验证呢，就是找一个txn_hash在响应的数据里面按ctrl + f去搜索，搜索到了说明肯定是这个文件返回的。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/7d462ee62d8e7d94ea823fc551b50d566f16908b310e05b41508c9ee1597730d.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>查看响应的数据，是html的格式。在python里面，处理html数据，个人常用的是xpath（当然，如果更擅长BeautifulSoup也可以）</p><p>在python里面安装相关的依赖</p><pre data-type="codeBlock" text="
pip install lxml ‐i https://pypi.douban.com/simple
"><code>
<span class="hljs-selector-tag">pip</span> <span class="hljs-selector-tag">install</span> <span class="hljs-selector-tag">lxml</span> ‐<span class="hljs-selector-tag">i</span> <span class="hljs-selector-tag">https</span>:<span class="hljs-comment">//pypi.douban.com/simple</span>
</code></pre><p>同时在浏览器上安装xpath插件，它能更好的帮助我们获到网页中元素的位置</p><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://chrome.google.com/webstore/detail/xpath-helper/hgimnogjllphhhkhlmebbmlgjoejdpjl">XPath Helper - Chrome 网上应用店 (google.com)</a></p><p>然后就可以通过插件去定位了，返回的结果是list</p><p>**注：**浏览器看到的网页都是浏览器帮我们渲染好的。存在在浏览器中能定位到数据，但是代码中取不到值的情况，这时候可以通过鼠标右键-查看网页源码，然后搜索实现</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/223b149c2a1e9a0079b3a5f4fbbc307f30555d8c2de78b4e3670c2a5e3911e1c.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/5d1ab4befd986addea2af94b5ca47ce999550f9161f47a232183b46c1c2e1787.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><pre data-type="codeBlock" text="# 请求和xpath定位具体实现代码：
def start_spider(page_number):
    url_base = &apos;http://bscscan.com
/txs?a=0xbd3bd95529e0784ad973fd14928eedf3678cfad8&amp;&apos;
​
    # 请求头
    headers = {
        &apos;User-Agent&apos;: &apos;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36&apos;,
        &apos;referer&apos;: &apos;https://bscscan.com/txs?a=0xbd3bd95529e0784ad973fd14928eedf3678cfad8&apos;
    }
​
    # 需要传入的参数
    data = {
        &apos;p&apos;: page_number
    }
​
    # 将参数转为Unicode编码格式
    unicode_data = urllib.parse.urlencode(data)
​
    # 拼接网址
    # http://bscscan.com/txs?a=0xbd3bd95529e0784ad973fd14928eedf3678cfad8
    url = url_base + unicode_data
​
    # 自定义request对象
    request = urllib.request.Request(url=url, headers=headers)
​
    # 模拟浏览器发送请求
    response = urllib.request.urlopen(request)
​
    # 将返回的数据利用lxml转为
    tree = etree.HTML(response.read().decode(&apos;utf‐8&apos;))
​
    # //div[@id=&apos;paywall_mask&apos;]//tbody//td//span/a[@class=&apos;myFnExpandBox_searchVal&apos;]/text()
    txn_hash_list = tree.xpath(&quot;//div[@id=&apos;paywall_mask&apos;]//tbody//td//span/a[@class=&apos;myFnExpandBox_searchVal&apos;]/text()&quot;)
​
    # //div[@id=&apos;paywall_mask&apos;]//tbody//td//span[@class=&apos;u-label u-label--xs u-label--info rounded text-dark text-center&apos;]/text()
    method_list = tree.xpath(
        &quot;//div[@id=&apos;paywall_mask&apos;]//tbody//td//span[@class=&apos;u-label u-label--xs u-label--info rounded text-dark text-center&apos;]/text()&quot;)
​
    # //div[@id=&apos;paywall_mask&apos;]//tbody//td[@class=&apos;d-none d-sm-table-cell&apos;]//text()
    block_list = tree.xpath(&quot;//div[@id=&apos;paywall_mask&apos;]//tbody//td[@class=&apos;d-none d-sm-table-cell&apos;]//text()&quot;)
​
    # //div[@id=&apos;paywall_mask&apos;]//tbody//td[@class=&apos;showAge &apos;]/span/@title
    age_list = tree.xpath(&quot;//div[@id=&apos;paywall_mask&apos;]//tbody//td[@class=&apos;showAge &apos;]/span/@title&quot;)
​
    # //div[@id=&apos;paywall_mask&apos;]//tbody//td/span[@class=&apos;hash-tag text-truncate&apos;]/@title
    from_list = tree.xpath(
        &quot;//div[@id=&apos;paywall_mask&apos;]//tbody//td/span[@class=&apos;hash-tag text-truncate&apos;]/@title&quot;)
​
    # //div[@id=&apos;paywall_mask&apos;]//tbody//td[@class=&apos;text-center&apos;]/span/text()
    transfer_type_list = tree.xpath(&quot;//div[@id=&apos;paywall_mask&apos;]//tbody//td[@class=&apos;text-center&apos;]/span/text()&quot;)
​
    # //div[@id=&apos;paywall_mask&apos;]//tbody//td/span/span[@class=&apos;hash-tag text-truncate&apos;]//text()
    to_list = tree.xpath(&quot;//div[@id=&apos;paywall_mask&apos;]//tbody//td/span/span[@class=&apos;hash-tag text-truncate&apos;]//text()&quot;)
​
    # //div[@id=&apos;paywall_mask&apos;]//tbody//td/span[@class=&apos;small text-secondary&apos;]/text()[2]
    transfer_free_list = tree.xpath(
        &quot;//div[@id=&apos;paywall_mask&apos;]//tbody//td/span[@class=&apos;small text-secondary&apos;]/text()[2]&quot;)
"><code># 请求和xpath定位具体实现代码：
def start_spider(page_number):
    url_base <span class="hljs-operator">=</span> <span class="hljs-string">'http://bscscan.com
/txs?a=0xbd3bd95529e0784ad973fd14928eedf3678cfad8&#x26;'</span>
​
    # 请求头
    headers <span class="hljs-operator">=</span> {
        <span class="hljs-string">'User-Agent'</span>: <span class="hljs-string">'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36'</span>,
        <span class="hljs-string">'referer'</span>: <span class="hljs-string">'https://bscscan.com/txs?a=0xbd3bd95529e0784ad973fd14928eedf3678cfad8'</span>
    }
​
    # 需要传入的参数
    data <span class="hljs-operator">=</span> {
        <span class="hljs-string">'p'</span>: page_number
    }
​
    # 将参数转为Unicode编码格式
    unicode_data <span class="hljs-operator">=</span> urllib.parse.urlencode(data)
​
    # 拼接网址
    # http:<span class="hljs-comment">//bscscan.com/txs?a=0xbd3bd95529e0784ad973fd14928eedf3678cfad8</span>
    url <span class="hljs-operator">=</span> url_base <span class="hljs-operator">+</span> unicode_data
​
    # 自定义request对象
    request <span class="hljs-operator">=</span> urllib.request.Request(url<span class="hljs-operator">=</span>url, headers<span class="hljs-operator">=</span>headers)
​
    # 模拟浏览器发送请求
    response <span class="hljs-operator">=</span> urllib.request.urlopen(request)
​
    # 将返回的数据利用lxml转为
    tree <span class="hljs-operator">=</span> etree.HTML(response.read().decode(<span class="hljs-string">'utf‐8'</span>))
​
    # <span class="hljs-comment">//div[@id='paywall_mask']//tbody//td//span/a[@class='myFnExpandBox_searchVal']/text()</span>
    txn_hash_list <span class="hljs-operator">=</span> tree.xpath(<span class="hljs-string">"//div[@id='paywall_mask']//tbody//td//span/a[@class='myFnExpandBox_searchVal']/text()"</span>)
​
    # <span class="hljs-comment">//div[@id='paywall_mask']//tbody//td//span[@class='u-label u-label--xs u-label--info rounded text-dark text-center']/text()</span>
    method_list <span class="hljs-operator">=</span> tree.xpath(
        <span class="hljs-string">"//div[@id='paywall_mask']//tbody//td//span[@class='u-label u-label--xs u-label--info rounded text-dark text-center']/text()"</span>)
​
    # <span class="hljs-comment">//div[@id='paywall_mask']//tbody//td[@class='d-none d-sm-table-cell']//text()</span>
    block_list <span class="hljs-operator">=</span> tree.xpath(<span class="hljs-string">"//div[@id='paywall_mask']//tbody//td[@class='d-none d-sm-table-cell']//text()"</span>)
​
    # <span class="hljs-comment">//div[@id='paywall_mask']//tbody//td[@class='showAge ']/span/@title</span>
    age_list <span class="hljs-operator">=</span> tree.xpath(<span class="hljs-string">"//div[@id='paywall_mask']//tbody//td[@class='showAge ']/span/@title"</span>)
​
    # <span class="hljs-comment">//div[@id='paywall_mask']//tbody//td/span[@class='hash-tag text-truncate']/@title</span>
    from_list <span class="hljs-operator">=</span> tree.xpath(
        <span class="hljs-string">"//div[@id='paywall_mask']//tbody//td/span[@class='hash-tag text-truncate']/@title"</span>)
​
    # <span class="hljs-comment">//div[@id='paywall_mask']//tbody//td[@class='text-center']/span/text()</span>
    transfer_type_list <span class="hljs-operator">=</span> tree.xpath(<span class="hljs-string">"//div[@id='paywall_mask']//tbody//td[@class='text-center']/span/text()"</span>)
​
    # <span class="hljs-comment">//div[@id='paywall_mask']//tbody//td/span/span[@class='hash-tag text-truncate']//text()</span>
    to_list <span class="hljs-operator">=</span> tree.xpath(<span class="hljs-string">"//div[@id='paywall_mask']//tbody//td/span/span[@class='hash-tag text-truncate']//text()"</span>)
​
    # <span class="hljs-comment">//div[@id='paywall_mask']//tbody//td/span[@class='small text-secondary']/text()[2]</span>
    transfer_free_list <span class="hljs-operator">=</span> tree.xpath(
        <span class="hljs-string">"//div[@id='paywall_mask']//tbody//td/span[@class='small text-secondary']/text()[2]"</span>)
</code></pre><p>然后就是利用redis，对txn_hash去重，去重的原因是防止一条数据被爬到了多次</p><pre data-type="codeBlock" text="def add_txn_hash_to_redis(txn_hash):
    red = redis.Redis(host=&apos;根据你自己的配置&apos;, port=6379, db=0)
    res = red.sadd(&apos;txn_hash:txn_set&apos;, get_md5(txn_hash))
    # 如果返回0，这说明插入不成功，表示有重复
    if res == 0:
        return False
    else:
        return True
​
​
# 将mmsi进行哈希，用哈希去重更快
def get_md5(txn_hash):
    md5 = hashlib.md5()
    md5.update(txn_hash.encode(&apos;utf-8&apos;))
    return md5.hexdigest()
"><code>def add_txn_hash_to_redis(txn_hash):
    red <span class="hljs-operator">=</span> redis.Redis(host<span class="hljs-operator">=</span><span class="hljs-string">'根据你自己的配置'</span>, port<span class="hljs-operator">=</span><span class="hljs-number">6379</span>, db<span class="hljs-operator">=</span><span class="hljs-number">0</span>)
    res <span class="hljs-operator">=</span> red.sadd(<span class="hljs-string">'txn_hash:txn_set'</span>, get_md5(txn_hash))
    # 如果返回<span class="hljs-number">0</span>，这说明插入不成功，表示有重复
    <span class="hljs-keyword">if</span> res <span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-number">0</span>:
        <span class="hljs-keyword">return</span> False
    <span class="hljs-keyword">else</span>:
        <span class="hljs-keyword">return</span> True
​
​
# 将mmsi进行哈希，用哈希去重更快
def get_md5(txn_hash):
    md5 <span class="hljs-operator">=</span> hashlib.md5()
    md5.update(txn_hash.encode(<span class="hljs-string">'utf-8'</span>))
    <span class="hljs-keyword">return</span> md5.hexdigest()
</code></pre><p>最后一个需要考虑的问题：交易是在增量了，也就是说，当前第二页的数据，很可能过会就到第三页去了。对此我的策略是不管页数的变动。一直往下爬。全量爬完了，再从第一页爬新增加的交易。直到遇到第一次全量爬取的txn_hash</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/b67748b58ca00d79897c19338ccff82a49529c1b893b37d2c3863b0b9d8cd0a3.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>最后就是存入到数据库了。这个没啥好说的。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/701c527a2ee7dbdc357ff5176aa954ad6ccbe82730b12ff9db617c6aa55e96e0.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>以上就可以拿到转账列表中的txn_hash，后面还要写一个爬虫深入列表里面，通过txn_hash去爬取详情页面的信息。这个就下个文章再说，代码还没写完。</p><p>今天就写到这里。拜拜ヾ(•ω•`)o</p>]]></content:encoded>
            <author>0xd74e84f97ef3ea7fe9be2ebdaced17e11ecfc9a8@newsletter.paragraph.com (撒酒狂歌)</author>
        </item>
        <item>
            <title><![CDATA[DeFi流动性之IZUMI白皮书中文与个人思考]]></title>
            <link>https://paragraph.com/@0xd74e84f97ef3ea7fe9be2ebdaced17e11ecfc9a8/defi-izumi</link>
            <guid>dT0zvvhZPgirhZsfMvrQ</guid>
            <pubDate>Mon, 30 May 2022 15:38:00 GMT</pubDate>
            <description><![CDATA[概述介绍izumi Finance 是首个为部署在以太坊链上的去中心化交易所Uniswap V3版本提供可编程流动性即服务的基础设施。 （LaaS：Infrastructure as a Service的缩写，意思是基础设施即服务。指把IT基础设施作为一种服务通过网络对外提供，并根据用户对资源的实际使用量或占用量进行计费的一种服务模式。在这种服务模型中，普通用户不用自己构建一个数据中心等硬件设施，而是通过租用的方式，利用 Internet从IaaS服务提供商获得计算机基础设施服务，包括服务器、存储和网络等服务）。【1】 同时，izumi通过内置的去中心化交易所将流动性服务提供到多条公链上。它将帮助在Uniswap V3版本上提供流动性的流动性提供者获取额外的流动性挖矿奖励和交易费用。另一方面，izumi将高效和持久的帮助DeFi协议吸引更多的流动性。 izumi通过LiquidBox使协议能够在特定价格范围内分配激励奖励，从而达到提高激励效率的目的。同时，流动性提供者可以以资本效率赚取更多的交易费用，并获得相关协议提供的额外激励。如：稳定币矿池仅在狭窄的价格范围内发放激励奖励（0...]]></description>
            <content:encoded><![CDATA[<h1 id="h-" class="text-4xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">概述</h1><h2 id="h-" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">介绍</h2><p>izumi Finance 是首个为部署在以太坊链上的去中心化交易所Uniswap V3版本提供可编程流动性即服务的基础设施。</p><p>（LaaS：Infrastructure as a Service的缩写，意思是基础设施即服务。指把IT基础设施作为一种服务通过网络对外提供，并根据用户对资源的实际使用量或占用量进行计费的一种服务模式。在这种服务模型中，普通用户不用自己构建一个数据中心等硬件设施，而是通过租用的方式，利用 Internet从IaaS服务提供商获得计算机基础设施服务，包括服务器、存储和网络等服务）。【1】</p><p>同时，izumi通过内置的去中心化交易所将流动性服务提供到多条公链上。它将帮助在Uniswap V3版本上提供流动性的流动性提供者获取额外的流动性挖矿奖励和交易费用。另一方面，izumi将高效和持久的帮助DeFi协议吸引更多的流动性。</p><p>izumi通过LiquidBox使协议能够在特定价格范围内分配激励奖励，从而达到提高激励效率的目的。同时，流动性提供者可以以资本效率赚取更多的交易费用，并获得相关协议提供的额外激励。如：稳定币矿池仅在狭窄的价格范围内发放激励奖励（0.99~1.01）。</p><p>izumi通过提供结构化的激励和自研模块解决了“pool 2 困境” 的问题，同时为流动性提供者提供非无常的损失流动性挖掘。</p><p>【1】来源于百度百科：<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://baike.baidu.com/item/IaaS">https://baike.baidu.com/item/IaaS</a></p><h2 id="h-laas" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">流动性即服务 （LaaS） 路线图：</h2><p>a. Uniswap V3上的LaaS：<strong>LiquidBox</strong></p><p>izumi Finance LiquidBox通过Uniswap v3 LP NFT提供可编程流动性挖掘（LM）工具，使协议能够在特定价格范围内精确有效地提供激励，从而优化流动性分配并鼓励用户抵押Uniswap V3 LP代币以获得额外奖励。</p><p>b. 多链上的离散化流动性AMM：<strong>iZiSwap</strong></p><p>将Uniswap V3等集中式流动性服务扩展到多链。iZiSwap将支持限价订单，并且它将与订单簿和Uniswap V3兼容，从而提高多链的资本效率。</p><p>c. 桥梁上的集中流动性服务：<strong>C-AMM桥梁</strong></p><p>多链时代需要快速、去中心化、自动再平衡的跨链桥。 izumi 的 C-AMM 桥使跨链交易成本低于 1 分钟，且 Gas 费低。跨链安全将由去中心化和透明的多验证者中继网络来保证。</p><p><strong>个人思考：</strong></p><p>老实说，简介大概意思明白了。但是很多单词不好翻译，比如non-impermanent loss liquidity mining，用软件翻译出来是“非永久性丧失流动性的采矿”</p><p>路线图是看明白了，一共要做三个部分，分别是</p><p>（1）Eth链上uniswap lp nft的流动性，类似convex和crv，去convex质押curve平台的crv获取convex平台的token、手续费等额外的收益。</p><p>（2）dex，挖金矿的铲子，不用多说。</p><p>（3）跨链桥，跨链桥是属于技术难度比较高的，毕竟很多时候经常看到消息说某某跨年桥被盗了。主要实现我记得有三种，原子互换、中继链或侧链实现的流动性聚合、验证人。</p><p>3.1 原子互换（hash time lock）</p><p>点对点跨链，如从eth转到polygen，提交需求后，会匹配一个流动性节点，将想要跨链的资产转移到流动性节点的eth地址，当节点收到资产后，会锁定资产并且在将流动性节点在polygen节点上的资产转移到用户的polygen钱包中。</p><p>总结：安全高，流动性割裂</p><p>产品：cBridge 1.0</p><p>3.2 中继链或侧链实现的流动性聚合</p><p>部署侧链或中继链，有自己相对独立的安全、共识机制，并且部署了不同的智能合约在多个链上。鼓励用户在不同链上提供流动性以获取token等奖励。</p><p>总结：不同链的流动性集中都可以通过链去智能管理，支持跨链的类型比原子交换的多，并且有独立的经济模型。</p><p>合约和链之前的漏洞会产生相互影响</p><p>产品：cBridge 2.0、hop、anyswap</p><p>3.3 验证人机制</p><p>和第二类在不同链上部署合约相似，区别在于多链上智能合约的集中管。理是由多签地址或者少数人管理的模式。</p><p>验证人相对少造成交易成本低，速度快。因为验证人少，所以用户使用是建立在验证人不会作恶的情况上。</p><p>产品：heco和bsc的桥（多签方式作为验证人）</p><h1 id="h-liquidbox" class="text-4xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">LiquidBox</h1><h2 id="h-liquidbox" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">什么是LiquidBox</h2><p>izumi 团队首先提出并实施了基于 Uniswap V3 NFT LP 代币的流动性挖矿方案“LiquidBox”。与传统的V2可替代LP代币直接质押挖矿不同，在LiquidBox中设计流动性挖矿激励计划时，协议可以明确设置被激励的LP代币的价值范围。并且用户将V3 LP代币质押到izumi协议后，izumi的LiquidBox会自动判断LP代币的价值范围是否在项目方设定的流动性激励价值范围内。如果在该范围内，LiquidBox 将根据激励方案为流动性提供者发放流动性挖矿代币奖励。</p><h2 id="h-uniswap-v3-nft" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">什么是Uniswap V3 NFT？</h2><p>与Uniswap V2仅允许LP在从0到无穷大的全价范围内提供流动性相比，Uniswap V3允许LP在一定的价格范围内。LP在增加流动性后收到NFT（不可替代令牌），并且由于头寸的不可替代性，费用收入被单独存储并作为支付费用给代币持有者</p><h2 id="h-liquidbox" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">为什么协议需要LiquidBox来获得流动性？</h2><p>注：这里说的是LiquidBox几种不同类型的可编程的流动性挖矿模型</p><p>项目各方可以基于Uniswap V3建立货币对和流动性池，通过在有限范围内提供奖励和在不同价格范围内提供不同的奖励来更有效地吸引流动性。</p><p><strong>选项1：“集中流动性挖掘模式”，稳定币和挂钩资产的固定奖励价格范围</strong></p><p>izumi LiquidBox能够在某些价格范围内分发流动性挖掘激励代币，例如[0.95，1.05]，以保持稳定币或挂钩资产的价格稳定。</p><p>每个在（0.95p，1.05p）价格范围内的块，都将从稳定币和挂钩资产发行人那里获得10个代币。</p><p>izumi评估（0.95p，1.05p）价格范围内的总有效流动性，并根据每个LP持有的比例线性分配激励。激励措施将流动性吸引到这个价格范围内，从而实现最小的滑点。</p><p>图片地址：</p><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://lh4.googleusercontent.com/XvhU0lCq3YboluYhRO8GZsem-_FPEV6jsH7Ryv1400e-UBZphTXJFKeXIWiWMPnz0fAl0O8im8vPGnoDff8F0F_Yfe0WqL0OkSzRlad71VABUrLXMlgUUYOGhoY5nw">https://lh4.googleusercontent.com/XvhU0lCq3YboluYhRO8GZsem-_FPEV6jsH7Ryv1400e-UBZphTXJFKeXIWiWMPnz0fAl0O8im8vPGnoDff8F0F_Yfe0WqL0OkSzRlad71VABUrLXMlgUUYOGhoY5nw</a></p><p><em>注：</em></p><p><em>如果LP在过度覆盖的价格范围内提供流动性（0.95p，1.05p），则仅将（0.95p，1.05p）内的流动性计算为激励分配的权重;</em></p><p><em>如果LP提供的NFT价格范围在（0.95p，1.05p）内，例如（0.98p，1.02p），则应用权重惩罚因子。</em></p><p>分析：与xy=k模型相比，0.95-1.05区间的资本效率高出50倍以上，只需要五分之一的TVL和相同滑点的激励。</p><p><strong>个人思考</strong></p><p>1、解读集中流动性意味着更高的无常损失</p><p>稳定币波动区间有限，收取的手续费与当前提供在该范围内的流动性正相关。</p><p>2、james文章所属中，“基于不同项目方对于币价波动幅度的不同需求”的理解</p><p>因为是LP限制了区间，对于价格波动大的币，如果区间设置过小，则不能拿到所有的流动性激励。设置过大，则减小了资金使用效率。尽可能将资金集中在成交量大的区间以获取高的激励奖励。项目方可以通过调整区间的奖励，去提升币价。</p><p>3、注部分内容</p><p>当提供LP的区间包裹了（0.95p，1.05p）这个范围，权重仅计算（0.95p，1.05p）的</p><p>当提供LP的区间介于（0.95p，1.05p）区间内，不能获取到百分百的权重，会有部分惩罚权重</p><p>4、只有选项1：“集中流动性挖掘模式”是需要在uniswp上有LP NFT。</p><p><strong>选项2：新兴资产的“单边非无常损失挖掘模型”，使价格持续上涨时流动性挖掘更具吸引力</strong></p><p>izumi LiquidBox允许在当前价格范围内进行流动性挖掘激励代币，以补偿相应时间间隔内价格变化造成的无常损失。</p><p>与传统的xy=k模型类似，LP将一半USDC和一半项目代币放入LiquidBox中，一键开始流动性挖掘。【1】</p><p>然而，为了避免传统xy=k模型（即LP将所有USDC作为潜在买单，将项目代币作为潜在卖单组交易对放入流动性池）造成的“池2困境”，导致流动性提供者在项目代币上涨时被动出售其项目代币从而遭受无常损失。也增加了项目方的被动抛售压力，阻碍了价格上涨，造成了“双输”的局面。</p><p>LiquidBox创新了基于Uniswap V3的“单边非无常亏损”模型，将USDC放入（Pa，Pc）价格的流动性区间，略低于当前价格的Pc【2】，并将项目代币放入质押挖矿而不是交易池（即将高于Pc作为潜在卖家），从而创建了一个“买强于卖出”的模型， 这更有利于价格上涨。</p><p>图片地址：</p><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://1156263563-files.gitbook.io/%5C~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnbFrz9ebdFK9k9KnHCnY%2Fuploads%2F7VzHYNp1eUR444IzKVJU%2FMG63.jpeg?alt=media&amp;token=ce57e6ad-8ffc-41a3-98b2-4b15f07add72">https://1156263563-files.gitbook.io/\~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnbFrz9ebdFK9k9KnHCnY%2Fuploads%2F7VzHYNp1eUR444IzKVJU%2FMG63.jpeg?alt=media&amp;token=ce57e6ad-8ffc-41a3-98b2-4b15f07add72</a></p><p>例如，如果XYZ代币的当前价格为3 USDC/个，LP将一键将1000个XYZ和3000个USDC存入izumi平台进行挖矿，并获得总本金的90%APR（类似于Sushiswap xy =k模型）。</p><p>izumi通过在Uniswap V3上（0，3）价格范围内放置3000个USDC来管理，当XYZ价格下跌用USDC形成购买订单。1000个XYZ被放置在izumi质押模块中以锁定流动性（质押部分不在Uniswap V3中），在XYZ价格上涨时不会被动出售，从而不会对项目方造成无常损失或被动抛售压力。</p><p>分析：当价格上涨时，没有无常损失；当价格下跌时，LP的无常损失百分比（Pa=0）与xy=k相同。项目的总体分布式激励与 xy=k 模型中相同。在上升周期中，被动卖出流动性较低，而在下降周期中，买入支撑位是一致的（如果Pa大于0，则购买力也会增强）。【3】</p><p><strong>个人思考：</strong></p><p>【1】&quot;the LP also puts half value of the USDC and half value of the project tokens into the izumi LiquidBox&quot;,按举例理解</p><p>【2】Pa &lt;= price &lt; Pc</p><p>【3】我是理解为：3000USDC，在XYZ价格下跌的时候，会买入XYZ，变相提供流动性。1000XYZ不会被动出售，可以由用户主动出售。项目方的无常损失就类似与terra的挤兑，大家都想跑，项目方和做市商亏了不少。</p><p>Pa=0意味着，LPs手上全是XYZ，没有USDC了。</p><p>上升周期，因为是质押了，所以抛压小了 = 被动卖出流动性较低。</p><p>如果Pa大于0，则购买力也会增强 = XYZ跌的越多，买的越多，直到USDC没了，或者Pa = 0</p><p><strong>选项3：“主动区间挖矿”模型激励非稳定代币围绕当前价格提供动态流动性。</strong></p><p>从本质上讲，该项目激励流动性提供者围绕当前价格提供有效流动性，并且项目所有者奖励的百分比是通过计算他们积极提供有效流动性的时间来计算的。</p><p><strong>选项4：“与交易费用成比例的额外奖励模式”，用于激励专业做市商的协议</strong></p><p>在流动性提供者质押Uniswap V3 NFT到izumi LiquidBox之后，izumi 分析该 LP NFT 在整个质押期间赚取的交易费用，并提供项目提供的额外激励。【1】</p><p>例如，用户提供XYZ-USDC流动性，生成LP NFT，并将其抵押在LiquidBox中，项目所有者在此期间提供额外的1倍的费用奖励。当用户在取出 NFT 并领取佣金时，将获得 30 XYZ 和 90 USDC，并且他可以从 LiquidBox 获得额外的 60 XYZ 奖励。</p><p>分析：该方案相当于项目方为专业做市商提供额外补贴，让专业做市商即使在前期代币低市值导致不够收益无法弥补交易费的情况下，也可以动态调整仓位至当前价格区间，做市商可以获得交易费用乘数以实现盈利。</p><p>原因是在 Uniswap V3 中，Taker （吃单）费用无法分配给特定的 Maker（挂单）（LP），因此，只要做市商不提供超过 50% 的有效流动性且无法达成合谋——做市商虚假交易（既充当吃单又充当做市商）的费用成本高于平台奖励。所以，这种虚假交易是没有动机的。</p><p><strong>个人思考：</strong></p><p>【1】“After staking Uniswap V3 NFT in the izumi LiquidBox for liquidity providers or LPs” liquidity providers 和 LPs都表示流动性提供者</p><p><strong>选项 5：“锁定期单侧挖矿模式”，用于看跌卖出期权</strong></p><p>流动性提供者可以在 Uniswap V3 上将流动性置于低于 当前价格Pc 的价格范围内，并锁定 LP NFT 一段时间，这本质上相当于在价格下跌时提供被动购买支持。从金融产品的角度来看，它接近于看跌期权，既可以作为项目方出资为社区购买的公共产品，也可以作为借贷平台用来对冲清算购买的保险产品。【1】</p><p>例如，如果XYZ=3USDC，LP在（1.5，2.4）价格范围内放置了10000 USDC的流动性并锁定头寸30天，则LP可以在锁定结束时获得10k*24%（APR）（*1/12）= 200USDC相当于XYZ的奖励（66.7pcs）</p><p>图像链接：</p><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://lh3.googleusercontent.com/McP1L0aYwS_blpFxiJCiDifKuAaGx0P80Jg8ctMiLCyVhwqK_JI3f5Gsg4M-duJQpk_i96Tf44n3oKmM0lbxwmWMiOswyh9OGnNUAhNpocPqQCMCzZJTuzH9pls7pQ">https://lh3.googleusercontent.com/McP1L0aYwS_blpFxiJCiDifKuAaGx0P80Jg8ctMiLCyVhwqK_JI3f5Gsg4M-duJQpk_i96Tf44n3oKmM0lbxwmWMiOswyh9OGnNUAhNpocPqQCMCzZJTuzH9pls7pQ</a></p><p>分析：当价格上涨或不低于2.4时，LP不会产生无常损失，这相当于单一代币收益APR = 24%;</p><p>当价格跌破2.4时，LP获得挖矿奖励，但承担无常损失。</p><p><em>注：项目侧奖励的APR可使用BSM期权公式计算，并随波动性、锁定时间、无风险利率等因素进行动态调整。每个周期都有限制，先到先得。</em>【3】</p><p><strong>个人思考</strong></p><p>【1】short put，就是看好股票不能跌过目标价，卖出认沽期权，是看多。</p><p>卖出者获得权利金（权利金来自买入看跌期权），若买入看跌期权者执行合约，卖出方必须以特定价格向期权买入方买入一定数量的股票。当投资者预期股票价格上涨时，他往往卖出看跌期权。</p><p>权利金：是期权的买方为获取期权合约所赋予的权利而必须支付给卖方的费用</p><p>【3】BSM期权公式</p><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://zhuanlan.zhihu.com/p/256356619?utm_source=wechat_session">https://zhuanlan.zhihu.com/p/256356619?utm_source=wechat_session</a></p><h1 id="h-liquidbox" class="text-4xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">如何使用LiquidBox进行流动性挖掘？</h1><p>假设您的项目已在Uniswap V3上列出，现在您希望激励特定价格范围的流动性。为了做到这一点，您希望用您的代币激励您的社区，并使流动性提供商能够获得额外的奖励，为此您需要izumi。</p><p>这个过程非常简单：</p><p>1）填写izumi激励池申请表<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://forms.gle/vY4pDWup7jLvb1Ru8">这里</a>.</p><p>2）izumi团队将与您联系以启动入职流程。</p><p>3）您支付每个池10,000美元的费用，以iZi代币支付。（免费至2022年1月底）</p><p>4）付款和信息提交后，我们部署。</p><p>如果您有任何疑问，请随时通过Discord和电子邮件与我们联系。</p><p>dc：<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://discord.com/invite/vUFpSwxTzz">https://discord.com/invite/vUFpSwxTzz</a></p><p>电子邮件：<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="mailto:contact@izumi.finance">contact@izumi.finance</a></p><h2 id="h-" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">这个过程是如何展开的？</h2><p>基于izumi的激励机制，项目团队需要决定一些关于UniV3流动性挖矿计划的细节，如激励价格范围、项目持续时间和激励代币数量等。如果您对这些参数有任何疑问，请随时与izumi团队联系，我们将根据项目情况提供建议。</p><p>然后项目团队需要填写izumi激励池申请表，这需要更多信息。</p><p>发送后，izumi的团队成员将与您联系以确认详细信息，解决任何问题并启动入职流程。</p><h2 id="h-" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">接下来会发生什么？</h2><p>入职流程完成后，用户将能够在 Uniswap V3 上提供流动性，并直接在 izumi 主网站上的项目专用池中质押 LP NFT。这些流动性提供者将获得您的项目代币和额外的 iZi 代币的奖励。详细说明请阅读【教程】。用户可以在激励计划期间的任何时间以及在所有奖励分配后，根据需要提取他们的 Uni V3 LP NFT</p><h1 id="h-izumi-yuan" class="text-4xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">iZUMi 债券（美元）</h1><p>iUSD或iZUMi Bond USD 百分之百由iZUMi的抵押品和未来收入支持。iUSD与美元1：1挂钩，由iZUMi Finance发行，并作为债券出售给私人投资者，为iZUMi生态系统的未来发展筹集资金。</p><p>每周 25% 的 iZiSwap 收入将发送至 iZUMi 财政部，用于在二级市场回购 iUSD，直到 iUSD 价格升至 0.996 USDT 以上。如果 iUSD 价格连续 4 周低于 0.996 USDT，iZUMi 承诺在下周内使用国库基金回购并销毁 iUSD。 iUSD 的供应量永远不会超过 iZUMi 国库的总价值，以保证安全和透明。</p><h2 id="h-iusd" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">iUSD 的使用案例</h2><ul><li><p><strong>赌注赚取</strong> 每个人都可以以6%-20%的年利率投注或耕种iUSD，利息来自iZiSwap收取的交易费用，为零售用户提供稳定的收入产品</p></li><li><p><strong>有激励措施的贸易</strong></p><p>为了增加iUSD的流动性，iZiSwap将激励与iUSD相关的交易对，包括农业激励和交易费用现金返还。</p></li></ul><h2 id="h-iusd" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">如何买卖 iUSD</h2><p>投资者可以通过两种方式购买iUSD：私人销售和二级市场。参与私人销售至少需要100万美元的安置。买家还可以在DEX上交换iUSD。【1】</p><p>私人销售的投资者有权根据协议将iUSD兑换成美元。所有iUSD持有者都可以在多链上以USDT或以DEX的价格出售iUSD。</p><p>【1】购买债券需要100w刀以上。</p><h1 id="h-" class="text-4xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">代币经济学</h1><h2 id="h-token" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">token详情</h2><p>a. 代币标准: ERC-20 Token on Ethereum</p><p>b. 股票代码: iZi</p><p>c. 总量: 20亿 iZi tokens</p><p>d. Ethereum Contract: 0x9ad37205d608B8b219e6a2573f922094CEc5c200 BSC(Binance) Contract: 0x60D01EC2D5E98Ac51C8B4cF84DfCCE98D527c747 Polygon Contract: 0x60D01EC2D5E98Ac51C8B4cF84DfCCE98D527c747 Arbitrum Contract: 0x60D01EC2D5E98Ac51C8B4cF84DfCCE98D527c747</p><h2 id="h-token" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">token分配</h2><p>图片地址：</p><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://1156263563-files.gitbook.io/%5C~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnbFrz9ebdFK9k9KnHCnY%2Fuploads%2Fw8nqS1ff6edxFZ5cjzqW%2Fizumi_-01.jpg?alt=media&amp;token=a0f9844e-2988-41b1-9a2d-801668018d35">https://1156263563-files.gitbook.io/\~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnbFrz9ebdFK9k9KnHCnY%2Fuploads%2Fw8nqS1ff6edxFZ5cjzqW%2Fizumi_-01.jpg?alt=media&amp;token=a0f9844e-2988-41b1-9a2d-801668018d35</a></p><h2 id="h-" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">流通计划</h2><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/e01f14c711f3d1fa7ce3eeaa88b668c35a44baa1ede4fe58edc89cb7655b9ded.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><h3 id="h-2022-1-veizi" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">提案名称：2022-1 推广veiZi的提案</h3><p><strong>提案详情：</strong></p><ol><li><p><em>所有投资者都将收到veiZi，而不是未来12个月的未投资iZi。</em></p></li><li><p><em>所有veiZi将根据SAFT分发计划的最终发布日期设置为2023年3月20日解锁。</em></p></li></ol><p><strong>归属时间表的变化：</strong></p><p>该提案将影响归属时间表的三个部分：私募，团队和伙伴关系。所有这些应该发布的iZi代币将在未来12个月内被锁定为veiZi。这些 veiZi 将于 2023 年 3 月 20 日解锁。</p><h3 id="h-" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">各链的池和发行</h3><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://docs.izumi.finance/tokens/tokenomics#pools-and-emission">https://docs.izumi.finance/tokens/tokenomics#pools-and-emission</a></p><h2 id="h-izi-ve-izi" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">iZi 和 ve-iZi</h2><h3 id="h-izi" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">iZi 令牌</h3><p>iZi令牌是iZUMi 平台的实用型令牌，可用于支付跨链交易费用，激励池设置和其他工具的使用。此外，用户需要抵押iZi令牌才能获得ve-iZi令牌，这是iZUMi 平台的治理令牌，使持有者有资格获得一系列利益并参与治理。</p><p><strong>iZUMi DAO veNFT（veiZi）</strong></p><p>注意：当平台开始与iZUMi社区的DAO治理时，iZUMi Finance将推出veNFT。</p><p><strong>1、什么是iZUMi DAO veNFT（veiZi）？</strong></p><ul><li><p>iZUMi DAO veNFT（veiZi）是iZUMi Finance的治理令牌。</p></li><li><p>veiZi旨在充分代表iZUMi Finance的治理权利。</p></li><li><p>veiZi，由锁定的iZi数量和时间计算，描述了投票权。</p></li></ul><p>veiZi与ERC721标准兼容，该标准可以像其他NFT一样转移和交易。</p><p><strong>2、如何计算veiZi的投票权？</strong></p><ul><li><p>x1：锁定号码 （iZi）</p></li><li><p>x2：锁定时间剩余（块），最长4年</p></li><li><p>veiZi 投票权 =x1 * (x2 / 4)</p></li></ul><p>注意：此算法将 veiZi 的投票权设置为金额和时间加权，这适用于表示社区成员对 iZUMi Finance 的支持和信心。</p><p><strong>3、veiZi的功能是什么？</strong></p><ul><li><p>投票：</p></li></ul><p>将采用DAO治理和二次投票来确定关键问题。每个周期的iZi排放量将根据veiZi投票权确定和分配。veiZi的所有者可以将投票权委托给另一个地址。</p><ul><li><p>质押：</p></li></ul><p>平台收入的50%将用于回购iZi，并根据每月的投票权发送给veiZi持有者。在前4年，每年将向veiZi持有者发送4000万iZi质押奖励。</p><ul><li><p>提高：</p></li></ul><p>随着NFT的质押，veiZi将用于将LiquidBox池的APR提高到2.5倍。提升机制将通过取两个值中的较小金额来计算您的收入权重。第一个值很简单，它是用户在iZUMi平台上从UniV3 LP NFT计算的vliquidity量。此金额是您的最大收入权重。</p><p>min((vliquidity∗40/100)+(Totalvliquidity∗VotingPower/VotingTotal∗(100−40)/100）,vliquidity)min（（vliquidity∗40/100）+（Total vliquidity∗Voting Power/Voting Total∗（100−40）/100），vliquidity）min（（vliquidity∗40/100)+(Totalvliquidity∗VotingPower/VotingTotal∗（100−40）/100），vliquidity)</p><p>注意：此算法是根据曲线增强算法设计的。</p><p><strong>4、如何获得 veiZi？</strong></p><ul><li><p>任何地址都可以通过在一定的锁定时间内锁定iZi来创建veiZi。</p></li><li><p>任何地址都可以转移或接收veNFT，这意味着veNFT可以在像Opensea这样的NFT市场上进行交易。</p></li><li><p>任何地址都可以将iZi添加到任何veiZi中，而不会影响锁定时间</p></li><li><p>如果 B 的锁定时间长于 A，则任何地址都可以将 A veNFT 与 B veNFT 组合在一起，并且 A 的锁定编号将被添加到 B 的中。</p></li><li><p>只有所有者的地址可以将锁定时间延长至4年，不支持提前解锁。</p></li></ul><p><strong>5、如何赎回veiZi？</strong></p><p>用户可以赎回veiZi并在达到锁定时间（块）后重新锁定iZi。</p><ol><li><p>如何使用您的地址使用/抵押 veiZi？</p></li></ol><ul><li><p>质押：每个地址都可以押注一个且只有一个 veiZi。</p></li><li><p>取消积分可在您领取所有奖励后随时使用。如果您在领取农业池奖励之前取消了veiZi，则由于取消了提升，您的农业奖励可能会减少。</p></li></ul><p>6、你为什么需要veiZi？</p><ul><li><p>veiZi减少了iZi在二级市场的流通量</p></li><li><p>veiZi每个月都可以获得质押奖励，使其成为一种有息资产。</p></li><li><p>下注一次veiZi，它可以无限次使用，以提高农业池的奖励。</p></li><li><p>不用担心锁定iZi的流动性。veiZi可以在主流的NFT市场进行交易，比如Opensea。</p></li></ul><h2 id="h-" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">路线图</h2><p><strong>2021年第四季度</strong></p><ul><li><p>推出基于Uniswap V3的Liquidbox;</p></li><li><p>离散化流动性AMM研究;</p></li></ul><p><strong>2022年第一季度</strong></p><ul><li><p>向其他协议提供流动性即服务（双重挖矿收益）;</p></li><li><p>将LiquidBox扩展到多链;</p></li><li><p>启动 ve-iZi 和排放治理;</p></li></ul><p><strong>2022年第二季度</strong></p><ul><li><p>在多链上推出内置AMM;</p></li></ul><p><strong>2022年第三季度</strong></p><ul><li><p>iZiBAR中的更多工具;</p></li><li><p>构建合作伙伴生态系统;</p></li></ul><p><strong>2022年第四季度</strong></p><ul><li><p>Dao治理;</p></li></ul><h2 id="h-faq" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">后面部分为FAQ问题解答以及操作指南</h2><p>FAQ：<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://docs.izumi.finance/faq/iziswap-fee-tier-and-fee-distribution">https://docs.izumi.finance/faq/iziswap-fee-tier-and-fee-distribution</a></p><p>指南：<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://docs.izumi.finance/tutorial/iziswap-guide">https://docs.izumi.finance/tutorial/iziswap-guide</a></p>]]></content:encoded>
            <author>0xd74e84f97ef3ea7fe9be2ebdaced17e11ecfc9a8@newsletter.paragraph.com (撒酒狂歌)</author>
        </item>
        <item>
            <title><![CDATA[一：Linux入门之安装VM虚拟机和CentOS7]]></title>
            <link>https://paragraph.com/@0xd74e84f97ef3ea7fe9be2ebdaced17e11ecfc9a8/linux-vm-centos7</link>
            <guid>pBWqmohhFvIcZlbwU3Ru</guid>
            <pubDate>Fri, 27 May 2022 07:44:45 GMT</pubDate>
            <description><![CDATA[一：前言Linux作为一个开源的系统，经常被安装在服务器上。对比于windows，有着定制化程度高、稳定性好、命令行强大等特性。 对于技术上的学习，用于需要理论+实操。如果单重视理论知识而不动手操作，则永远不会体验到Liunx的如丝般顺滑。当然，其他技术也是如此。二：安装VMware虚拟机软件将系统装在虚拟机上有两个好处，一：与真实环境隔离，不使用时不影响。二：虚拟机环境可随时删除，重装。 VMware软件和CentOS7光盘镜像ISO文件下载 https://drive.google.com/file/d/1ZBu8M2oeP_i9ERHO0ycC_hFwzIrj9UhQ/view?usp=sharing https://drive.google.com/file/d/14FOz55jBdIZ_n98jjyvz6LEOgrmCC4pZ/view?usp=sharing 软件打开首页点击创建新的虚拟机按钮下一步选择CentOS7 ISO。文件路径尽量不要使用中文。填写虚拟机名称和选择虚拟机文件存放路径选择cpu核数选择内存大小选择网络连接方式默认即可，下一步默认即可，下一步选择创...]]></description>
            <content:encoded><![CDATA[<h3 id="h-" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">一：前言</h3><p>Linux作为一个开源的系统，经常被安装在服务器上。对比于windows，有着定制化程度高、稳定性好、命令行强大等特性。</p><p>对于技术上的学习，用于需要理论+实操。如果单重视理论知识而不动手操作，则永远不会体验到Liunx的如丝般顺滑。当然，其他技术也是如此。</p><h3 id="h-vmware" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">二：安装VMware虚拟机软件</h3><p>将系统装在虚拟机上有两个好处，一：与真实环境隔离，不使用时不影响。二：虚拟机环境可随时删除，重装。</p><p>VMware软件和CentOS7光盘镜像ISO文件下载</p><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://drive.google.com/file/d/1ZBu8M2oeP_i9ERHO0ycC_hFwzIrj9UhQ/view?usp=sharing">https://drive.google.com/file/d/1ZBu8M2oeP_i9ERHO0ycC_hFwzIrj9UhQ/view?usp=sharing</a></p><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://drive.google.com/file/d/14FOz55jBdIZ_n98jjyvz6LEOgrmCC4pZ/view?usp=sharing">https://drive.google.com/file/d/14FOz55jBdIZ_n98jjyvz6LEOgrmCC4pZ/view?usp=sharing</a></p><p>软件打开首页</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/c0c5349f803775a69bdbae77f14640d2ae743e92494f0d8f9ca5c7fa8ecb1c46.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>点击创建新的虚拟机按钮</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/1526538aa9aafa55e40371e4fa5e5b94cb0045bdc25c4cc7f30bc263ec1ad9e9.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>下一步</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/933f5f303c66fccaa542c56fc3f90b402fdeddd8698063922c6297a47417a817.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>选择CentOS7 ISO。文件路径尽量不要使用中文。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/6e5587e09f487f4c6963cc926e85fefa7ca336ff8e869a4ab8c8d210c757cff6.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>填写虚拟机名称和选择虚拟机文件存放路径</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/333bf831ce03709881f60fd4e562bc5d0e1bd9ae102d7a8eaff5c41d748d3961.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/d87853c6cae23266eea779b894b718cc1125358d39d7f9711d7712a90ab402f4.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>选择cpu核数</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/6908b30419020338eacbbecc75eb71adfe3487ed9f6403897aeb55acdc26c3b2.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>选择内存大小</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/e6246e2d00de2130101b51b79210b07567ff3e37a73c56489ea889e9f357060f.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>选择网络连接方式</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/0d7b7a128eaba934bac025beb18a8d15ad7c0e40f6e2a54f3814d4d7dbff084c.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>默认即可，下一步</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/6a85dcc428bfc2a318bf8552f60398f56677c3b4b7bef4538dd7a6b8f1d9364b.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>默认即可，下一步</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/f2888e1ce4f5464962b3511af89dcc3b12062a5d9e99a7e7c93516cb7c190280.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>选择创建新的磁盘</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/478b900652352c98a2e8d682cd066e3f0b2615a6d1dfa14830a14ac0070d04ea.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>选择磁盘大小，选择虚拟磁盘存储为单个文件</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/6b8938709c8e581a44c904cc6d6385acbd12bf7b253811330f00194576ac40bd.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>默认即可，下一步</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/d27e0c923a5da69a5b5bcd7f16bb0de898fd4f730b0f7c6c22cad50f9ec5c9ac.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>完成</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/7ead6d06dfbf2ad611bd65a3f14d71c785b96939ccc5463a3ac02f1f97719c36.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>回车开始安装</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/dd9f3996511a19af7b603585da6f2b536b3c321cc0ebe44f86ed9b6a5401a121.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>点击回车</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/3467c1469a98be967b7d27c07422cd37b8e98e0cf6acc6de80d04c4be5c706f7.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>等待进度条读取到100%</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/88aa71701bf0ac2429869e52ec3e73dee1c42fedc0690703b3cd87e47b3613f2.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>等待进入安装界面</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/61d7dc81a52cd04d1f37d024d8c33f9f5fef7338dae933092675dcf2067d702b.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p><strong>注意：</strong></p><p><strong>以下界面都是在鼠标虚拟机内部点击，需要通过按Ctrl + Alt释放鼠标才可以正常操作点击真实的系统</strong></p><p>选择中文</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/79a895b399ba041f54a9788551964ba36efc6496fcd7cdacb9fde52933e87133.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>简体中文</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/950e153060b58900e26d881cbb9c40dee1301f0e8943e2f514471d83f9aec8f5.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>直接鼠标点击虚拟机内部按钮就行。退出虚拟机按Ctrl + Alt</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/c5dedb7ac4f7e16be95b2e5b7f4fe9a1e5742a041f750627a46af2a8747cf440.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/4cd555e0d226c8c6751df6ce37efb0c0e10297098c48081b9730888d594cc5a8.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>关闭KDUMP</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/4c0d1011e6b9c22296449c1e902b255c16e1e579d6042b0343be031d549b79f7.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>去掉✔后点击完成</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/15a71251426fd5e3baf5b79b2d692c81078e0c37062df4bb0200317010cfce0e.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>设置主机名，具体网络设置会在后续教程，因为要设置成静态ip，方便每次通过shell客户端去连接。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/f7fe001453263b394c360b7e6b09b99c4c9c188991c35a55344ba69ab6a06582.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>设置自定义分区</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/af47feb7aa4d632f35ade970175cf1382e85ac12dd189179221fbf64fcfbb29c.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>选择”我要配置分区“，然后点击完成</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/91d393c763ad745b50b9ad2504a761125f33603a453a48db5e51507816c6bd0c.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>点击添加</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/79bc9ab3b157f2bb0ad67c79d2769f78f05dcc0de659007b4855362abf633b7d.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>添加/boot分区，主要存放启动文件</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/a5886261dd65152b967d06093221ff1c1bdaaecc2fc024b735a759b14b2ad0d2.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>添加/home分区，存放非root用户文件。root用户目录在~下</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/06f241e74e5240c8683c3bf0873a848ce75391c4506d220aa5f26e0d22dd85d9.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>设置swap交换分区。当内存不足的时候，会把一部分硬盘空间虚拟成内存使用,从而解决内存容量不足的情况。当然，影响性能。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/85cda8d8cc1285affff6268478494c2883183ba01da73131ff7e3d19a33dd7ab.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>剩下的空间全部给/目录。企业开发中，还有一个/data分区，数据和软件系统分离，保证数据安全。但是这里是学习，就不做了。</p><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://m.php.cn/article/484666.html">在linux中，根目录“/”是位于文件系统目录结构的顶层，是最顶层的目录，所有的文件和目录都置于根目录“/”之下；根目录“/”下面还有“/bin”，“/home”，“/usr”等子目录。</a></p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/2ecf725c95c206c8f43b900e2a71a4950657f0f0231e9693c56c824f2640fee4.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>点击完成</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/2db5cc57dc46bb5c4fcc9e621dbc26dac06395acd45b45c27c9a9554c0538b99.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>接受更改</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/4ecb81e0f5b5142e5416023775f0cd9e7ef315f650b0671f1c0891a54c1d601f.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>点击开始安装</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/1fc55a96958ddc3d7de7104bb5f5ccef1c9af7f0600ba55badf24d2d15cf70f2.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>修改root密码</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/8617507d2c397ed0c09cf649204781589b9f95bd2209e20513222358f1154ea0.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/b19943b1a709539b7042ee8507326b65119a1cc0f7faf909fff59a53d3ccd807.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/b367df10cd352d94183a33f92449b383336a5ef56a256f043ce8ffa5f921fcbd.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>等进度条完成后点击重启按钮</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/5f3e2ab767e60acc95e3ad5cf567b345661562d2677aa6c28a7a44a97b35e3ee.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>回车即可</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/db9e70897ef69ca2d23d10bb9d25237f3b3efde8a1196142dd5b5dcd29b10af1.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>显示登陆界面即是完成安装</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/f70025abdcdfdbefa088568f10353beda572b7ade54c6253c976f23ff6648a0a.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>用root密码登陆，输入</p><pre data-type="codeBlock" text="sync # 将所有未写的系统缓冲区写到磁盘中
poweroff # 关机时同时关闭电源。关机命令在7之前还有halt、shutdown，因为7采用了systemd管理，都是以符号链接到/bin/systemctl的，所以7之后就没区别了。
"><code><span class="hljs-built_in">sync</span> <span class="hljs-comment"># 将所有未写的系统缓冲区写到磁盘中</span>
poweroff <span class="hljs-comment"># 关机时同时关闭电源。关机命令在7之前还有halt、shutdown，因为7采用了systemd管理，都是以符号链接到/bin/systemctl的，所以7之后就没区别了。</span>
</code></pre><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/eac1512bcd6dc7837c9d3c7fe053c85631935824a01edb25a79fe28e26c0f5c3.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure>]]></content:encoded>
            <author>0xd74e84f97ef3ea7fe9be2ebdaced17e11ecfc9a8@newsletter.paragraph.com (撒酒狂歌)</author>
        </item>
    </channel>
</rss>