dexterslabor
    • 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

      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 New
    • Engagement control
    • Make a copy
    • 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 Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
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
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

    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
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Workshop AmsterDOT We build a trade page for a Basilisk XYK pool and display any price movement in a graph. This graphs shows the historical and current spot price. **Conceptual tree** - UI - XYK Pool - High level understanding - AMM - asset pairs - ID of pool - deterministic - getId() exposed in RPC - Read current state of pool - data structure in pallet - balances - tokens - calculate spot price of pool - forumla - implementation in RUST - how it is exposed in JS through WASM - Call extrinsic - Parameters - decide on parameters that will pass trade limits - enough slippage - min/max out - less than 1/3rd of pool in trade - otherwise errors - how to read them (module, index parsing) - substrate errors - pallet errors - common one: min/max - cost structure of extrinsic - weight - protocol fee - Graph/history of prices - extrensic calls move the spot price - current price (discussed above) - historical price/asset balances for pool ID - high level architecture indexer/processor - processor strategy - which events - finality on blocks - implementation of handler - custom starting block for processing - graphql endpoint - show the playground - example queries - explain built in filtering methods (etc.) - takeaway task from the workshop - figure out historical data bucketing in a proper way ## Call Buy on pool (we wanna do sell) Dependencies: * custom React app (create-react-app) * WASM library (first calc manually, then import wasm + typedef) * Basilisk API (no running of a testnet, just a slim processor from subsquid template) * PolkadotJS SDK + PolkadotJS apps * verify chain state vs implmentation in react * monitor events and block production * send extrinsics * show concepts in apps before implementing Call extrensics on Basilisk XYK Pool through an UI. Understand the parameters to avoid errors. * How to calculate spot price * Query storage for balances of pool (Basilisk RPC) * Understanding storage representation. Maybe look at RUST code. * How to get pool id for asset ids (Basilisk RPC) * Maybe RUST code, explaining how pools are deterministic? * How to use WASM library * Definitely showing RUST code to compare. * https://github.com/galacticcouncil/HydraDX-wasm/blob/main/src/lib.rs#L20-L26 Callback function for .signAndSend How to translate errors into proper messages. Different phases of transaction (eg. tx status). "Weights" or transaction ordering. (paymentInfo) Block hash of finalized. What is reordering (briefly). Querying graphql endpoint for historical balances to calculate spotprice in UI. (diff between @client fields and remote/processor fields). Note: we won't have "active account" fetching for the polkadot webwallet, instead hardcode account id. ## Graph Dependencies: * subsquid framework * offer working API/processor/indexer as NPX starter Data of historical balances for given pool id. (someone can transfer to the pool loosing their asset). High level architecture of indexer and processor. Writing the processor (new frameworkstyle without manifest) for this task. Interacting with GRAPHQL endpoint. (show the playground) ### Debriefing #### Learning objectives dWe'll build a web3 app for the Basilisk AMM to execute trades and view historical price movements. Join this comprehensive workshop to acquire hands-on experience interacting with polkadot based chains and leverage this foundation to build future products (such as an arbitrage bot). Among others, we'll learn how to read and navigate RUST code, identify emitted events and build effective strategies to process data, precompute parameters for trading, basics of GraphQL and writing resolvers in React. * writing a resolver * basics of GraphQL * polkadotjs * casting data types * parsing errors * building web3 app for a polkadot based chain in react * read chain data * data structure for assets on basilisk (native/non-native) * read rust code and navigate through pallets * identify (emitted) events in source code * develop a strategy for processing data * AMM pools on basilisk * calculating spot-price in clients with same accuracy as runtime (WASM library) * interacting with the blockchain by executing extrinsics * AMM trading buy/sell assets * precompute parameters for trading * transaction flow * fee calculation for trades * setting up an indexer (high level) * writing a processor for historical balances * creating a graph for historical spot prices of an AMM pool * storage reading * current * historical * processor * custom pallet * navigating through source code * interacting using extrinsics * transaction flow/states => use this for: * arbitrage bot * cross chain swap aggregator # Content delivery Slide deck for workshop. > Do not forget to incorporate insights from workshop before releasing it to the public. High level blogpost with links (substack? medium?).

    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