TZ-Connect
      • 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

      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.
      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
    • Engagement control
    • 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 Versions and GitHub Sync Note Insights Sharing URL Help
Menu
Options
Engagement control 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

    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.
    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
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # Krisa* : A Decentralized Prediction Market Platform ( * - Working name; *Krisa* was the original name of the site of the Delphoi shrine to Apollo according to the Homeric hymns. ) *Krisa* is an automated system developed as an open source smart contract for the Tezos blockchain, that allows users to create and participate in binary prediction markets. ## Binary prediction market Prediction markets are exchange-traded markets created for the purpose of trading the outcome of events. The market prices can indicate what the crowd thinks the probability of the event is. A binary prediction market can resolve according two $2$ different outcomes, designated as $yes$ and $no$ answers pertaining to a prediction. Once the answer becomes known, the market is resolved to one of these two outcomes, at which point the correct prediction expires at a price of $100\%$, and the incorrect at $0\%$. ([Wikipedia](https://en.wikipedia.org/wiki/Prediction_market)) In Krisa, the open trading phase of the market is realized using a liquidity pool based on the $x * y = k$ mathematics pioneered by Uniswap v1. This is a decentralized exchange technology, where a single liquidity pool serves as automated market maker, providing exchange of two assets for one another at spot prices based on the built-in mathematics. The fundamental concept is as follows: $$x_0 * y_0 = x_1 * y_1 = k$$ Where $x_0$ and $y_0$ are the original asset amounts in the pool, while $x_1$ and $y_1$ those after the exchange. In reality, a fee is collected on each swap, which means $k$ will in effect slowly grow over time, which provides incentive for keeping liquidity in the pool, for a share of its ownership. An exchange of $\Delta x$ of one asset for $\Delta y$ of the other would thus be described by the following equation, assuming a fee of $0 \leq \rho \lt 1$: $$x_0 * y_0 = (x_0 + (1-\rho)\Delta x) * (y_0 - \Delta y) $$ The swap fee implemented in *Krisa* is in line with the Uniswap fee at $0.3\%$ or $\rho = 0.003$. ([Zhang et al., 2018](https://github.com/runtimeverification/verified-smart-contracts/blob/uniswap/uniswap/x-y-k.pdf)) The liquidity pool in a *Krisa* market allows for the exchange of $yes$ and $no$ tokens for one another, and thus to adjust one's position according to preferences. Entry and exit from the market does not happen through a liquidity pool, but via a fixed price mint / burn mechanic: ### Entering and exiting the market In *Krisa*, the $yes$ and $no$ outcome contracts are represented as FA2 fungible tokens connected to the market in question. In an open market, entering and exiting the market is realized by respectively minting and burning outcome token pairs. Each pair of outcome tokens is nominally equivalent to $1$ currency token specified at market creation, in which the market is denominated. By locking up $1$ currency token in the market, one has the ability to mint a pair consisting of a $yes$ and $no$ tokens. In reality, outcome tokens are discounted by a minting fee, which serves to incentivize market creators to drive traffic to the market, as well as an serving as an additional reward to liquidity providers, to offset the distortions expected at the tail end of a market lifecycle. Thus, the discounted value of an outcome token pair is $(1 - \sigma)$, where $\sigma$ is a different and separate fee from the above mentioned uniswap fee, set in *Krisa* as $5\%$ or $\sigma = 0.05$. In an open market, $Q * (1 - \sigma)$ currency tokens may be unlocked by burning $Q$ pairs of outcome tokens. In order to take an extreme position in the market, and purchase only one of the outcomes for a quantity of $Q$ currency tokens, one must first mint $Q$ pairs of outcomes, and then, through the liquidity pool, swap the total $Q$ of the undesired tokens for desired ones. Thus, the amount of the desired outcome type purchased for $Q$ currency tokens is $Q + Q_{swap}$, where $Q_{swap}$ denominates the output amount of a fixed input swap according to the above described liquidity pool mathematics. ### Market resolution At the creation of a prediction market in Krisa, a Tezos address has to be specified which has the ability to resolve the market (ie. attest to the outcome having become known). For live markets, this address is expected to be a Tezos smart contract, serving as business logic and a transform over the data provided by a trusted on-chain oracle, to ensure reliability and accuracy of the result. Once a market had been resolved, outcome tokens pertaining to the confirmed outcome expire at a price of $1 - \sigma$ in currency tokens, while their counterparts expire at a value of $0$. ## Liquidity seeding and auction phase Given the fact that Uniswap-style liquidity pools perform unpredictably in an anomalous manner at very low liquidity, *Krisa* includes a feature that allows for raising liquidity for a nascent market in a fair manner, maximizing the log utility of bets. After a pre-defined auction period, the auction may be cleared, and bets in the auction converted into positions in the open market. Suppose there are $I$ participants. Auction participant $i$ must provide their estimate probability $0 \le p_i \le 1$ of a $yes$ outcome (the probability of a $no$ outcome implied as $1 - p_i$), as well as locking up a quantity of $Q_i$ currency tokens in their bet. (The following calculations were adapted and simplified from [A. Breitman's 2021 writeup](https://hackmd.io/@murbard/HyPcZ132D) of a multi-outcome prediction market auction.) ### Clearing prices and allocation Allocations are calculated by assuming implicitly trades between participants at a single clearing price, so as to maximize their log utility. Assuming that the clearing price vector is $(P, (1-P))$, and that each participant $i$ ends up with a position of quantities $({q_i}_{yes}, {q_i}_{no})$ in the two outcomes. First, no $yes$ or $no$ tokens are created or destroyed: $$\sum_{i=1}^I {q_i}_{yes} = \sum_{i=1}^I {q_i}_{no} = \sum_{i=1}^I Q_i$$ Second, everyone trades at the clearing price: $$\forall i,~{q_i}_{yes} P + {q_i}_{no} (1 - P) = Q_i$$ Third, expected log utility should be maximized for everyone: $$\forall i,~{p_i} \log {q_i}_{yes} + (1 - {p_i}) \log {q_i}_{no}$$ It's not necessarily obvious that all these constraints can be simulatenously met, but they can. We set the clearing price to the weighted arithmetic average: $$P = \frac{\sum_{i=1}^I {Q_i}~{p_i}}{\sum_{i=1}^I {Q_i}}$$ We set the quantities participants end up with to: $${q_i}_{yes} = Q_i \frac{p_i}{P},~{q_i}_{no} = Q_i \frac{1 - p_i}{1 - P}$$ It can be demonstrated that the results so obtained meet the above defined constraints. For detailed proof, and a proof of incentive compatibility, see ([Breitman, 2021](https://hackmd.io/@murbard/HyPcZ132D)). ### Seeding the liquidity pool As the goal of the auction phase is to collect sufficient liquidity in the pool to make regular trading possible, all auction participants become liquidity providers, and thus co-owners of the market, to the extent of their ability to contribute in the correct proportion of tokens. Let $$g_i = \min ((P~{q_i}_{yes}), ~((1-P){q_i}_{no})).$$ For every participant $i$, the contributions ${C_i}_{yes}$ and ${C_i}_{no}$ will be determined as $${C_i}_{yes} = \frac{g_i}{P}, ~{C_i}_{no} = \frac{g_i}{1-P}$$ Finally, liquidity shares will be allocated to each participant $i$ for their contribution at a ratio of $$\frac{g_i}{\sum_{i=1}^I g_i},$$ which in practice means an allocation of $g_i$ liquidity share tokens to each auction participant $i$, and a total initial supply of liquidity tokens of $\sum_{i=1}^I g_i$. After funding the liquidity pool, each auction participant is left with a number of liquidity share tokens, as well as a number of their more preferred outcome tokens, depending the certainty of their preciction. For a bet of exactly $p_i = \frac{1}{2}$, indicating a lack of preference, the participant is left with no outcome tokens and liquidity share tokens only. ## Fee and reward mechanics For discussion of the reward mechanics built into Uniswap-style liquidity pools through the swap fee $\rho$ described above, see ([Zhang et al., 2018](https://github.com/runtimeverification/verified-smart-contracts/blob/uniswap/uniswap/x-y-k.pdf)). In a prediction market, due to the limited lifespan of the market, and potential market imperfection before resolution happens, there is a chance for the so-called *impermanent loss* to become permanent, which may act as an incentive for participants to prematurely withdraw liquidity from the market. To counterbalance this psychological effect, liquidity providers are allocated reward tokens on a time-proportionate basis. For each participant $i$ holding liquidity share tokens ${S_i}_d$, an equal amount of reward tokens will be (lazily) minted at the inclusion of block $d$. After the market had been resolved, each reward token will correspond to a proportionate share of the liquidity provider reward pool, which is $80\%$ of the total income collected through the mint fee $\sigma$. The remaining $20\%$ of the mint fee income is allocated to the market creator.

    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

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    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