KuChain
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Help
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # KuChain API 交互文档 ## KuChain链上API(由DEX运营方调用主链) ### 注册 Dex 用户需要支付一定的 KCS 来注册 Dex 账户 POST `/api/v1/dex` #### 参数 - uniqueName - displayName - websiteUrl - iconUrl - owner - description - defaultFeeRate: 0.001 (0 - 0.001) #### 返回 <!-- - dexId - dexAddr 存放手续费资金池地址 - createdAt --> ### 查询 Dex 信息 GET `/api/v1/dex` #### 参数 - uniqueName - dexId #### 返回 - dexId - dexAddress 存放手续费资金池地址 - uniqueName - displayName - websiteUrl - iconUrl - owner - description - createdAt ### 注册交易对 POST `/api/v1/symbols` #### 参数 - dexId - uniqueCode - displayName - owner - baseAssetId - baseAssetPrecision - quoteAssetId - quoteAssetPrecision #### 返回 <!-- - dexId - uniqueCode - displayName - owner - baseAssetId - baseAssetCode - baseAssetPrecision - quoteAssetId - quoteAssetCode - quoteAssetPrecision - status --> ### 查询交易对 GET `/api/v1/symbols` #### 参数 - symbolId - owner - status #### 返回 - items - symbolId - uniqueCode - displayName - baseAssetId - baseAssetCode - baseAssetPrecision - baseMinSize - quoteAssetId - quoteAssetCode - quoteAssetPrecision - quoteMinSize - owner - status - feeRate - feeSide - settleAssetId - settleAssetCode - settleAssetPrecision - settleDiscountRate - settleAssetAmount ### 启用交易对 POST `/api/v1/symbols/launch` #### 参数 - dexId - symbolId ### 下架交易对 POST `/api/v1/symbols/close` #### 参数 - dexId - symbolId ### 冻结交易对 POST `/api/v1/symbols/freeze` #### 参数 - dexId - symbolId ### 解冻交易对 POST `/api/v1/symbols/unfreeze` #### 参数 - dexId - symbolId <!-- ### 设置交易费规则 交易对启用前才能够设置接口 POST `/api/v1/symbols/fee` #### 参数 - symbolId - feeRate - feeSide #### 返回 同交易对查询 --> ### 修改交易费规则 修改接口只有在交易对冻结的情况下才能修改 UPDATE `/api/v1/symbols/fee` #### 参数 - symbolId - takerFeeRate - makerFeeRate - feeSide - settleAssetId? #### 返回 <!-- - symbolId - uniqueCode - displayName - baseAssetId - baseAssetCode - baseAssetPrecision - baseMinSize - quoteAssetId - quoteAssetCode - quoteAssetPrecision - quoteMinSize - owner - status - takerFeeRate - makerFeeRate - feeSide: base|quote - settleAssetId - settleAssetCode --> ### 设置交易对撮合结算币种(可以有折扣) POST `/api/v1/symbols/settle` #### 参数 - symbolId - settleAssetId? - settleAssetPrecision? - settleDiscountRate? - settleAssetAmount? #### 返回 <!-- - symbolId - settleAssetId - settleAssetCode - settleAssetPrecision - settleDiscountRate - settleAssetAmount --> ### 更新交易对撮合结算币种 UPDATE `/api/v1/symbols/settle` #### 参数 - symbolId - settleAssetId? - settleAssetPrecision? - settleDiscountRate?? - settleAssetAmount? #### 返回 <!-- - symbolId - settleAssetId - settleAssetCode - settleAssetPrecision - settleDiscountRate - settleAssetAmount --> ### 查询手续费资金池 GET `/api/v1/feepool` #### 参数 - dexId #### 返回 - assets - assetId - assetCode - balance ### 提现手续费资金池到DEX创建者账号 POST `/api/v1/feepool/claim` #### 参数 - dexId - assetId - amount? #### 返回 - txId --- ### 提交撮合成功的订单列表(完成链上撮合和清算) POST `/api/v1/execute-orders` #### 参数 - dexId - trxs ## KuChain 撮合引擎相关 API 梳理文档(前端调用渲染网页和进行API交易) ## Markets ### 获得订单薄 level1 GET `/api/v1/market/orderbook/level1` #### 参数 - symbolId #### 返回 - bestAsk - size - price - bestBidSize - bestBid - bestAskSize - bestAsk ### 获得订单薄 level2(聚合) GET `/api/v1/market/orderbook/level2` #### 参数 - symbolId - deepth (20 || 100)? #### 返回 - bids[] - price - size - asks[] - price - size ### 获得订单薄 level3 (非聚合结果) GET `/api/v1/market/orderbook/level3` #### 参数 - symbolId #### 返回 - bids[] - price - size - asks[] - price - size ### 获得全局行情快照 GET `/api/v1/market/allTickers` #### 返回 - time - tickers - symbolId - bid - ask - changeRate - changePrice - high - low - vol - volValue - last ### 获得市场成交历史 GET `/api/v1/market/histories` #### 参数 - symbolId #### 返回 - item - time - price - size - side ### 获得历史蜡烛图数据 GET `/api/v1/market/candles` #### 参数 - type 1min, 3min, 5min, 15min, 30min, 1hour, 2hour, 4hour, 6hour, 8hour, 12hour, 1day, 1week - symbolId - startAt - endAt #### 返回 - time - open - close - high - low - volume - turnover ## Orders ### 下单 POST `/api/v1/order` #### 参数 - dexId - symbolId - address - side - price - amount - type - remark - timeInForce - orderId #### 返回 <!-- - fee - feeAssetId - lastExecutedPrice - lastExecutedQuantity - orderCreateTime - orderId - owner - price - quantity - side - status [Ack, PartialFill, IocNoFill, FullyFill, Canceled, Expired, FailedBlocking, FailedMatching, IocExpire] - symbolId - timeInForce - tradeId - txHash - txTime --> ### 查询订单 GET `/api/v1/orders/{orderID}` #### 参数 - orderId #### 返回 - fee - feeAssetId - lastExecutedPrice - lastExecutedQuantity - orderCreateTime - orderId - owner - price - quantity - side - status [Ack, PartialFill, IocNoFill, FullyFill, Canceled, Expired, FailedBlocking, FailedMatching, IocExpire] - symbolId - timeInForce - tradeId - txHash - txTime ### 取消单个订单 DELETE `/api/v1/orders/{orderID}` #### 参数 - orderId #### 返回 ### 批量取消订单 DELETE `/api/v1/orders` #### 参数 - dexId - address - symbolId? #### 返回 <!-- - cancelledOrderIds --> ### 获得订单列表 GET `/api/v1/orders` #### 参数 - status (active||done)? - symbolId? - side? - address? - startAt? - endAt? - offset - limit #### 返回 - totalzNum - items - fee - feeAssetId - lastExecutedPrice - lastExecutedQuantity - orderCreateTime - owner - price - quantity - side - status - symbolId - timeInForce - tradeId - txHash - txTime - clientOrderId - orderId ### 最近的订单记录 GET `/api/v1/hist-orders` #### 参数 - symbolId - side - startAt - endAt - offset - limit #### 返回 - totalNum - items - fee - feeAssetId - lastExecutedPrice - lastExecutedQuantity - orderCreateTime - orderId - owner - price - funds - size - dealFunds - dealSize - side - status [Ack, PartialFill, IocNoFill, FullyFill, Canceled, Expired, FailedBlocking, FailedMatching, IocExpire] - symbolId - timeInForce - tradeId: 撮合成交id ### 成交记录 GET `/api/v1/fills` #### 参数 - orderId - symbolId - side - startAt - endAt - address - offset - limit #### 返回值 - symbolId - tradeId - orderId - txId - counterOrderId - side - liquidity (taker || maker) - price - size - funds - fee - feeRate - feeAssetId - createdAt ## 问题梳理 - Dex 的接口是否考虑多 Dex 的扩展? 不用,查询所有启用的DEX是链的基础API - 列表相关的接口是否支持分页查询? 理论上需要 - 手续费接口是否需要结合一些具体的治理和链上逻辑去设计(例如之前讨论的如何给不同的节点做优惠) - 手续费抵扣和只收取某种币混合起来设计会不会有性能问题 - 订单创建的 orderId 什么样的规律生成? 建议客户端生成 - 订单创建的内容是否完全由用户定义在签名体中? 理论上是的 - 是否能够支持撮合引擎单次 commit 多条成交到链上,如何控制 commit 频率,保证链的处理性能? - 撮合引擎提交需要一个逻辑,超过阈值应该立即提交,防止单次提交计算量过大

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully