The Polkadot Hackathon Global Series North America edition is the second in a series of hackathons that brings the cutting edge of blockchain to a global community.

Overview

Polkadot Hackathon Project

We are translating Uniswap v2 to Ink.

Dependencies

Install cargo-contract for building Ink contracts:

cargo install dylint-link cargo-dylint
cargo install cargo-contract

cargo-contract requires Binaryen for its wasm-opt tool. It's in most system packagers like apt and homebrew, but versions older than 99 are rejected by the Rust wasm tooling. The best way to get this tool may be to get it directly from their binary releases or build it yourself, in either case adding its bin directory to your PATH environment variable.

For the web frontend:

(cd www && npm install)

Building

At the moment ink crates have to be built individually:

cargo contract build --manifest-path=components/swap_traits/Cargo.toml

For the web frontend:

npm run build

or to serve it with live reloading:

npm run dev

License

GPL3

Comments
  • Factory Contract

    Factory Contract

    I have made some progress with the majority of functions (Thank you @Aimeedeer as I used your work as a stepping stone). I am left with the create_pair function and possibly adding error handling

    opened by kris524 2
  • Add tailwind and some svelte components

    Add tailwind and some svelte components

    There's not much to look at yet, but I've sketched out the main things I think a uniswap UI needs:

    • the menu with items for "swap" and "pools"
    • a system status widget for connecting the wallet, showing the address, etc
    • a swap component
    • a pool list component
    • a status message overlay

    I decided to try tailwindcss for this and so far it's making it fairly easy to get a layout going.

    It can be run with npm run dev once the dependencies are installed (cd www && npm install).

    opened by brson 0
  • Trait cleanup

    Trait cleanup

    Some notable things I did

    • changed Vec<u32> to Vec<u8> to represent bytes types
    • removed all the todos about u256 - there are so many we're just going to have to take another pass over these once we better understand the types in ink.
    • changed the crate type to rlib since this is just a library - it is not compiled to a wasm contract
    • added tuple return types where appropriate. some of these might want to be named types later on

    cc @kris524

    opened by brson 0
  • Figure out bytes32 type

    Figure out bytes32 type

    Uniswap uses bytes32 in a few places. This is an array of bytes up to 32 in length, not strictly 32 bytes. Do we need such a thing? Right now we are just using Vec<u8>.

    opened by brson 0
  • Figure out scalar types

    Figure out scalar types

    The solidity contract uses several types that we are not:

    • uint - a 256-bit integer
    • uint112 - a 112-bit integer?

    Right now we are just using u64 for these, but need to figure out the correct types.

    opened by brson 3
  • Tasks

    Tasks

    This issue is for tracking and assigning major tasks. Feel free to edit.

    We are going to try to translate uniswap v2 to Ink and run it on Astar (or other networks that support the Substrate wasm palett). This will involve

    • Building Rust contracts in ink - Uniswap is well factored in a way we should be able to divide the work up
    • Writing unit tests for those contracts
    • Probably developing a Rust CLI to drive the contracts from the command line, for development, administration, and integration testing
    • Creating a JavaScript module for driving the contracts from the web browser
    • Creating a web app
    • Creating final presentation materials

    It probably won't involve Substrate hacking, though we can try to come with an excuse to make our own Substrate chain..

    Some background links:

    • Hackathon: https://polkadot-na.devpost.com/
    • Hackathon guide: https://angelhack.notion.site/Polkadot-Hackathon-North-America-Edition-Participants-Guide-0f6d16e7db4849a9a4902241f0d4a5cf
    • Ink: https://github.com/paritytech/ink
    • Astar: https://docs.astar.network/
    • Uniswap v2 core contracts: https://github.com/Uniswap/v2-core/tree/master/contracts
    • Uniswap v2 periphery contracts: https://github.com/Uniswap/v2-periphery/tree/master/contracts/interfaces
      • It looks like the router contract may be the only thing relevant to a new implementation
      • We can worry about these later
    • Uniswap tests: https://github.com/Uniswap/v2-core/tree/master/test
    • Substrate RPC libraries for Rust:
      • https://github.com/paritytech/substrate-subxt
      • https://github.com/scs/substrate-api-client
    • Polkadot tokens
      • https://github.com/w3f/PSPs/blob/master/PSPs/psp-22.md
      • https://github.com/paritytech/substrate-open-working-groups/blob/main/SOWG/1-polkadot-token-standard.md

    Tasks:

    • [x] Create skeleton repo. Top level cargo workspace with a 'components' directory to hold further crates. Perhaps start with one crate to hold the traits (uniswap's interfaces) called swap_traits, and we can go from there once we understand more. (@kris524)
    • [x] Outline the uniswap traits in swap_traits, figuring out equivalent ink idioms for solidity idioms.
      • [x] IUniswapV2Callee (@kris524)
      • [x] IUniswapV2ERC20 (@domroselli)
      • [x] IUniswapV2Factory (@kris524)
      • [x] IUniswapV2Pair (@kris524)
    • [x] Figure out what the equivalent of the ERC20 interface is in Ink and how we need to integrate it.
    • [ ] Implement the three uniswap contracts. These probably need to be their own crates but not sure.
      • [x] UniswapV2ERC20 (@Aimeedeer)
      • [ ] UniswapV2Factory (@kris524)
      • [ ] UniswapV2Pair (@kris524)
      • [ ] PSP22 (Fungible Token Standard for Polkadot) (@Aimeedeer)
    • [ ] #20
    • [ ] Create an integration test harness. Uniswap does this in typescript but I think we can do it in Rust. This will involve using a substrate RPC library to drive the contracts.
    • [ ] Implement the existing uniswap tests from https://github.com/Uniswap/v2-core/tree/master/test
      • [ ] UniswapV2ERC20
      • [ ] UniswapV2Factory
      • [ ] UniswapV2Pair
    • [ ] Create a web frontend (brson). https://github.com/kris524/Polkadot-Hackathon-North-America-Edition/issues/8
    opened by brson 1
Owner
Kristiyan Dilov
Software engineer at @AgileAnalog | prev @CQCL
Kristiyan Dilov
Marvin-Blockchain-Rust: A Rust-based blockchain implementation, part of the Marvin blockchain project.

Marvin Blockchain - Rust Implementation Welcome to the Rust implementation of the Marvin Blockchain. This project is part of a comparative study on bu

João Henrique Machado Silva 3 Sep 6, 2024
An Ethereum compatible Substrate blockchain for bounties and governance for the Devcash community.

Substrate Node Template A fresh FRAME-based Substrate node, ready for hacking ?? Getting Started Follow the steps below to get started with the Node T

null 4 Mar 30, 2022
🌍 The Earth Blockchain on Polkadot (archived)

Social Network Blockchain · The Social Network blockchain is a next-generation governance, economic, and social system for humanity built on Polkadot

social.network 18 Jan 2, 2023
Firmware, application and documentation for the hackathon

eclipsecon-2022-hackathon WORK IN PROGRESS This repository contains software, firmware and documentation for the EclipseCon 2022 hackathon. Bluetooth

Eclipse IoT Working Group 6 Oct 27, 2022
Hackathon project, not production ready (yet)

Ledger Nano PIV Application This is a Ledger Hackathon project targeted on building a PIV compatible Ledger Nano X/S+ application. The focus of this a

Ledger 6 Dec 20, 2022
Implementation of Sunny's Mesh Security talk (Hackathon / Prototype status)

mesh-security (Hackathon / Prototype status) An implementation of Sunny's Mesh Security talk from Cosmoverse 2022. This should run on any CosmWasm ena

CosmWasm 83 Apr 17, 2023
The project brings the IC ecosystem to Unity, allowing Unity developers to call the functions of canisters on IC,

Agent of Internet Computer for Unity The Intro The project brings the IC ecosystem to Unity, allowing Unity developers to call the functions of canist

Shiku Labs 9 Nov 18, 2022
Bellman zkSNARK library for community with Ethereum's BN256 support

bellman "Community edition" Originally developed for ZCash, with extensions from us to make it a little more pleasant. Uses our "community edition" pa

Matter Labs 113 Dec 29, 2022
Examples of cw20 usage, extracted from cw-plus, maintained by the community

CosmWasm Tokens This is a collection of cw20-related contracts extracted from cw-plus. These serve as examples of what is possible to build and as sta

CosmWasm 59 Jan 2, 2023
🐰 Rust client library for the Leap Edge socket service

leap_edge_rs Utility library for connecting and receiving events from Leap Edge. Used for Channels and Pipe. Installation Add this to your Cargo.toml:

Hop 9 Sep 7, 2022
Easy setup for Edge host.

Pod's Edge Staking GUI (beta) Features Easily setup your Edge host with a GUI (Graphical User Interface). Uses the device token staking method. Has no

null 3 Apr 29, 2023
Cross-chain hub for Crypto Asset on Polkadot

ChainX ChainX is a community-driven project built on the next-generation blockchain framework substrate, the largest Layer-2 network of Bitcoin using

ChainX 261 Dec 28, 2022
Polkadot Node Implementation

Polkadot Implementation of a https://polkadot.network node in Rust based on the Substrate framework. NOTE: In 2018, we split our implementation of "Po

Parity Technologies 6.5k Jan 6, 2023
A node and runtime configuration for polkadot node.

MANTA NODE This repo is a fresh FRAME-based Substrate node, forked from substrate-developer-hub/substrate-node-templte ?? It links to pallet-manta-dap

Manta Network 14 Apr 25, 2021
Subsocial full node with Substrate/Polkadot pallets for decentralized communities: blogs, posts, comments, likes, reputation.

Subsocial Node by DappForce Subsocial is a set of Substrate pallets with web UI that allows anyone to launch their own decentralized censorship-resist

DappForce 74 Nov 24, 2022
A top-up of fatality based errors, originally developed for polkadot

fatality A generative approach to creating fatal and non-fatal errors. The generated source utilizes thiserror::Error derived attributes heavily, and

Bernhard Schuster 9 Sep 1, 2022
interBTC A trust-minimized bridge from Bitcoin to Polkadot.

interBTC A trust-minimized bridge from Bitcoin to Polkadot. Explore the specification » Report Bug · Request Feature This repository is hosted on GitH

Interlay 192 Dec 27, 2022
A re-write of polkadot staking miner using subxt to avoid hard dependency to each runtime version

Staking Miner v2 WARNING this library is under active development DO NOT USE IN PRODUCTION. The library is a re-write of polkadot staking miner using

Parity Technologies 19 Dec 28, 2022
A holistic, minimal documentation portal for the Polkadot developers.

polkadot-sdk-docs A holistic, minimal documentation portal for the Polkadot developers. Master Tutorial The very, very rough plan that I have so far i

Parity Technologies 9 May 26, 2023