mbarlin
    • Create new note
    • Create a note from template
      • 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
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee
    • 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
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • 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 Sharing URL Create Help
Create Create new note Create a note from template
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
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee
  • 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
    # Risk Prediction Module *Written in Pythonic pseudocode, mapped from a simulation model. This document serves as a guide for implementation. In all cases, SDK code language, structure, and implementation requirements should supercede, with the caveat that the algorithmic property is not compromised.* ## Concept The risk prediction module is a mechanism to obtain information about the perception of an associated variable through crowdsourcing. ![Risk Prediction Block Diagram](https://i.imgur.com/G1t2Qul.png) In this case, holders of an associated token may attest in the positive or negative as a reflection of their belief in the risk variable, $\alpha$. ## State **Risk Prediction Global State** State necessary to maintain legal state of the risk prediction module. | Name| Schema | |-----|----------| | Risk_Prediction| Dict | | Variable Name | Variable Type | Definition| |-----|----------|----| |Claims_0 | uint64 | Number of attestations against $\alpha$ | |Supply_0 | uint64 | Tokens bonded to attest against $\alpha$ | |Claims_1 | uint64 | Number of attestations in favor of $\alpha$ | |Supply_1 | uint64 | Tokens bonded to attest in favor of $\alpha$ | |I_Invariant| Invariant| Risk Prediction Curve Invariant | |kappa, $\kappa$ | sdk.Dec | Multiplicative Inverse of Reserve Ratio | |Price | uint64 | Price associated with the Risk Prediction Curve | |alpha, $\alpha$ |sdk.Dec | Risk factor being attested | **Agent State** State necessary to maintain legal state of agents interacting with the risk prediction module. | Name| Schema | |-----|----------| | Agent_Risk_Prediction| Dict | | Variable Name | Variable Type | Definition| |-----|----------|----| |Address| address | Agent address | |PubKey | pubkey | Agent Public Key | |claims_0 | uint64 | Number of attestations against $\alpha$ | |supply_0 | uint64 | Tokens an agent attests against $\alpha$ | |claims_1 | uint64 | Number of an agent attests in favor of $\alpha$ |supply_1 | uint64 | Tokens an agent attests in favor of $\alpha$ | |supply_free | uint64 | Tokens an agent holds unattested | **Input State** Hook input to Risk Prediction Module from Bonding Curve Module | Variable Name | Variable Type | Definition| |-----|----------|----| |Bonding_Curve| address | Module address | |PubKey | pubkey | Module Public Key | |Supply | uint64 | Total tokens outstanding | |Reserve | uint64 | Reserve amount in Bonding Curve | Hook input to Risk Prediction Module from Outcomes Based Funding Module | Variable Name | Variable Type | Definition| |-----|----------|----| |Outcomes_Funding| address | Module address | |PubKey | pubkey | Module Public Key | |Commitment | uint64 | Commitment to Pay Outcome of Project | |alpha, $\alpha$ | sdk.Dec | Risk factor being attested | |Reserve | uint64 | Reserve amount in Bonding Curve | **Output State** Hook output to Bonding Curve Module Bonding_Curve Update State | Name| Schema | |-----|----------| | Bonding_Curve| Dict | | Variable Name | Variable Type | Definition| |-----|----------|----| |Bonding_Curve| address | Module address | |PubKey | pubkey | Module Public Key | |kappa, $\kappa$ | sdk.Dec | Multiplicative Inverse of Reserve Ratio | |Price | uint64 | Price associated with the Risk Prediction Curve | |alpha, $\alpha$ | sdk.Dec | Risk factor being attested | ## Parameters The nature of the Risk Prediction Module is not reliant centralized updates and parametric control from a governance module. It ideally serves as a dual repository of attested tokens. Thus, the parameter set is exclusively limited to the intialized values of the global state. | Name| Schema | |-----|----------| | Initial_Parameter_Set| Dict_struct | | Variable Name | Variable Type | Definition| |-----|----------|----| |Initial_Supply_0 | uint64 | Starting Tokens in the attest against $\alpha$ pool | |Initial_Supply_1 | uint64 | Starting Tokens in the attest in favor of $\alpha$ pool | |Initial_I_Invariant| Invariant| Starting Risk Prediction Curve Invariant | |Initial_kappa, $\kappa$ | sdk.Dec | Starting Multiplicative Inverse of Reserve Ratio | |Initial_Price | uint64 | Starting Price associated with the Risk Prediction Curve | |Initial_alpha, $\alpha$ | sdk.Dec | Starting Risk factor being attested | From the governing module, in this the Outcome-Based Funding Module, the reserve amount and commitment to pay upon completion are required parameters for this module. | Name| Schema | |-----|----------| | Outcome-Based_Parameter_Set| Dict_struct | | Variable Name | Variable Type | Definition| |-----|----------|----| |Commitment | uint64 | Commitment to pay upon successful completion | ## Initialization Initialization of the Risk Prediction Module contains the Initial Parameter Set to create the first legal state. | Name| Schema | |-----|----------| | Initial_Parameter_Set| Dict_struct | |Risk_Prediction_Module| address | Module address | |PubKey | pubkey | Module Public Key | ## State Transitions Updates to the global state of the Risk Prediction Module occur upon resolution of a block under which there is a positive or a negative attestation. For a positive attestation, the following function will update the global state: ``` def Global_State_Update_Positive_Attestation( Global_State, MsgAttestPositive) alpha = Risk_Prediction['alpha'] R = Risk_Prediction['reserve'] Q = Risk_Prediction['attestations_1'] + Risk_Prediction['attestations_0'] Q1 = Risk_Prediction['attestations_1'] Q0 = Risk_Prediction['attestations_0'] S = Risk_Prediction['supply'] S1 = Risk_Prediction['supply_1'] S0 = Risk_Prediction['supply_0'] I = Risk_Prediction['invariant_I'] q1 = MsgAttestPositive['agent_attestations_1'] q0 = MsgAttestPositive['agent_attestations_0'] s_free = MsgAttestPositive['agent_supply_free'] s1 = MsgAttestPositive['agent_supply_1'] s0 = MsgAttestPositive['agent_supply_0'] def update_Q1(): Q1 = Q1 + MsgAttestPositive['agent_attestations_1'] return 'attestations_1', Q1 def update_S1(): S1 = S1 + MsgAttestPositive['agent_supply_1'] return 'supply_1', S1 def update_alpha(): new_alpha = S1 * R / (S1 * R - S0 * R + S0*C) return new_alpha def update_kappa(): kappa = I / (I - (C*new_alpha)) return 'kappa', kappa #### Hook to BC ########### def update_V(): V = (S**(kappa))/R return 'invariant_V', V #### Hook to BC ########### #### Hook to BC ########### def update_Price(): P = kappa * (R/S) return 'Price', P #### Hook to BC ########### return Risk_Prediction ``` For a negative attestation, the following function will update the global state: ``` def Global_State_Update_Negative_Attestation( Global_State, MsgAttestNegative) alpha = Risk_Prediction['alpha'] R = Risk_Prediction['reserve'] Q = Risk_Prediction['attestations_1'] + Risk_Prediction['attestations_0'] Q1 = Risk_Prediction['attestations_1'] Q0 = Risk_Prediction['attestations_0'] S = Risk_Prediction['supply'] S1 = Risk_Prediction['supply_1'] S0 = Risk_Prediction['supply_0'] I = Risk_Prediction['invariant_I'] q1 = MsgAttestNegative['agent_attestations_1'] q0 = MsgAttestNegative['agent_attestations_0'] s_free = MsgAttestNegative['agent_supply_free'] s1 = MsgAttestNegative['agent_supply_1'] s0 = MsgAttestNegative['agent_supply_0'] def update_Q0(): Q0 = Q0 + MsgAttestNegative['agent_attestations_0'] return 'attestations_0', Q0 def update_S0(): S0 = S0 + MsgAttestNegative['agent_supply_0'] return 'supply_0', S0 def update_alpha(): new_alpha = S1 * R / (S1 * R - S0 * R + S0*C) return new_alpha def update_kappa(): kappa = I / (I - (C*new_alpha)) return 'kappa', kappa #### Hook to BC ########### def update_V(): V = (S**(kappa))/R return 'invariant_V', V #### Hook to BC ########### #### Hook to BC ########### def update_Price(): P = kappa * (R/S) return 'Price', P #### Hook to BC ########### return Risk_Prediction ``` For a positive attestation, the following function will update the agent state: ``` def Agent_State_Update_Positive_Attestation( Agent_State, MsgAttestPositive) q1 = MsgAttestPositive['agent_attestations_1'] q0 = MsgAttestPositive['agent_attestations_0'] s_free = MsgAttestPositive['agent_supply_free'] s1 = MsgAttestPositive['agent_supply_1'] s0 = MsgAttestPositive['agent_supply_0'] def update_q1(): q1 = q1 + MsgAttestPositive['agent_attestations_1'] return 'attestations_1', q1 def update_s1(): s1 = s1 + MsgAttestPositive['agent_supply_1'] return 'supply_1', S1 def update_s_free(): s_free = s_free - MsgAttestPositive['agent_supply_1'] return s_free return Agent_State ``` For a negative attestation, the following function will update the agent state: ``` def Agent_State_Update_Negative_Attestation( Agent_State, MsgAttestNegative) q1 = MsgAttestNegative['agent_attestations_1'] q0 = MsgAttestNegative['agent_attestations_0'] s_free = MsgAttestNegative['agent_supply_free'] s1 = MsgAttestNegative['agent_supply_1'] s0 = MsgAttestNegative['agent_supply_0'] def update_q0(): q0 = q0 + MsgAttestNegative['agent_attestations_0'] return 'attestations_0', q0 def update_s0(): s0 = s0 + MsgAttestNegative['agent_supply_0'] return 'supply_0', S0 def update_s_free(): s_free = s_free - MsgAttestNegative['agent_supply_0'] return s_free return Agent_State ``` ## Messages `Agent Action Space` An agent may attest with their tokens positively or negatively in the Risk Prediction Module. MsgAttestPositive ``` def MsgAttestPositive(PublicKey, Address, Agent_State): get PublicKey get Address q1 = Agent_State['agent_attestations_1'] s1 = Agent_State['agent_supply_1'] return MsgAttestPositive ``` MsgAttestNegative ``` def MsgAttestNegative(PublicKey, Address, Agent_State): get PublicKey get Address q0 = Agent_State['agent_attestations_0'] s0 = Agent_State['agent_supply_0'] return MsgAttestNegative ``` ## Events `Tracing agent action execution` Resolution of an attestation, either negative or postive, will trigger an update to the Global State of the Risk Prediction Module. This update is necessary for the Bonding Curve Module and the instantiating Outcomes Based Funding Module ``` def Global_State_Update(Global_State) return Risk_Prediction ``` An agent or explorer would require execution tracing of messages and thus would need agent state information. ## Handler `Permissible Agent Action Determination Posterior` For either attestation, confirmation of existence of tokens is necessary. ``` def Checksum(PublicKey, Address, Agent_State, Message_Supply): get PublicKey get Address attested_tokens = Message_Supply['supply_tokens'] if attested_tokens > Agent_State['agent_supply_free: FAIL return CheckSum ``` Batching of attestation messages may be necessary for processing transactions. In this case, an aggregation of attestations should be performed. ``` def Batch_attestations(PublicKey, Address, Agent_State, MsgAttestNegative, MsgAttestPositive): get PublicKey get Address for MsgAttestNegative in messages: negative_attested_tokens += Message_Supply['agent_supply_0'] for MsgAttestPositive in messages: positive_attested_tokens += Message_Supply['agent_supply_1'] return negative_attested_tokens, positive_attested_tokens ``` ## Keepers `Permissible Control Action Determination Prior` | Name| Schema | |-----|----------| | Initial_Parameter_Set| Dict_struct | |Risk_Prediction_Module| address | Module address | |PubKey | pubkey | Module Public Key | The Risk Prediction Module in its essence is a place for agents to express their belief about an associated module. Thus, there is little need for centralized control over the specific mechanisms within this module. The controls necessary at this level are to initialize the module, and the authority to pause (with the option to close activity), unpause activity. For initialization: ``` def Initiate_Module(Initial_Parameter_Set, Risk_Prediction_Module, PubKey): return Global_State ``` For pause or close activity: ``` def Pause_Module(Risk_Prediction_Module, PubKey): return Pause_Phase ``` For unpause or close activity: ``` def Unpause_Module(Risk_Prediction_Module, PubKey, Global_State): return Global_State ``` ## Query `Available Prescribed State Computation` The end-user in the Risk Prediction Module would want to get the current published alpha. ``` def Query_Alpha(PublicKey, Address, Global_State): get PublicKey get Address alpha = Global_State['alpha'] return alpha ``` The end-user in the Risk Prediction Module would want to compute the expected in change in alpha, given their prospective attestation of tokens and a direction of attestation, positive or negative. ``` def Query_Realized_Alpha(PublicKey, Address, _input): get PublicKey get Address alpha = Global_State['alpha'] tokens_to_attest = _input realized_alpha = f(alpha, tokens_to_attest, attest_direction) return realized_alpha ``` ## Querier `Call on a Query` Calls on a Query that an end-user could make are referenced here. ``` def get_alpha(PublicKey, Address): get PublicKey get Address alpha = Query_Alpha() return alpha ``` ``` def get_realized_alpha(PublicKey, Address, tokens_to_attest): get PublicKey get Address Query_Realized_Alpha = Query_Realized_Alpha(tokens_to_attest) return Query_Realized_Alpha ``` ## Hooks `Module Interface` An update to the Global State of the Risk Prediction Module should trigger an update to the sibling Bonding Curve Module. Specifically, to retrieve updated values of kappa and alpha. ``` BondingCurveCall ``` ``` def get_Global_State_Update(Global_State) return kappa, alpha ``` The parent Outcomes Based Funding Module will also need to monitor updates to the Global State of the Risk Prediction Module. ``` OutcomesBasedFundingCall ``` ``` def get_Global_State_Update(Global_State) return kappa, alpha ```

    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