Giter Club home page Giter Club logo

huffswap's Introduction

huffswap AMM • ci license solidity

A Huff implementation of UniswapV1.

Security concerns

To make it comparable to uniswap V1 i have to avoid using a Reentrancy guard this is just a POC of a minimal AMM with low gas consumptions build for the ETH Denver hackaton. DO NOT USE IT IN PRODUCTION.

Gas Savings

method Uniswap Huffswap delta percent cheaper
createExchange 227994 106858 121136 53,13%
addLiquidity 99367 91304 8063 8,11%
removeLiquidity 18150 14286 3864 21,29%
swapEthToken 16250 12953 3297 20,29%
swapTokenEth 16999 13595 3404 20,02%
swapTokenToToken 28406 20098 8308 29,25%

Lets make a gas budget, lets imagine 1 create pair, 5 add liquidity, 5 remove liquidity and 30 swaps (per each type of swap);

  • Uniswap: 1432129
  • Huffswap: 1101268

Gas savings, around 30%

Getting Started

Requirements

The following will need to be installed in order to use this template. Please follow the links and instructions.

  • Git
    • You'll know you've done it right if you can run git --version
  • Foundry / Foundryup
    • This will install forge, cast, and anvil
    • You can test you've installed them right by running forge --version and get an output like: forge 0.2.0 (92f8951 2022-08-06T00:09:32.96582Z)
    • To get the latest of each, just run foundryup
  • Huff Compiler
    • You'll know you've done it right if you can run huffc --version and get an output like: huffc 0.3.0

Quickstart

  1. Clone this repo or use template

Click "Use this template" on GitHub to create a new repository with this repo as the initial state.

Or run:

git clone https://github.com/huff-language/huff-project-template
cd huff-project-template
  1. Install dependencies

Once you've cloned and entered into your repository, you need to install the necessary dependencies. In order to do so, simply run:

forge install
  1. Build & Test

To build and test your contracts, you can run:

forge build
forge test

For more information on how to use Foundry, check out the Foundry Github Repository and the foundry-huff library repository.

Blueprint

scripts
├─ Deploy.s.sol — Deployment Script
src
├─ ExchangeLP token implementation
├─ FactoryFactory of LP Tokens

License

The Unlicense

Acknowledgements

Disclaimer

These smart contracts are being provided as is. No guarantee, representation or warranty is being made, express or implied, as to the safety or correctness of the user interface or the smart contracts. They have not been audited and as such there can be no assurance they will work as intended, and users may experience delays, failures, errors, omissions, loss of transmitted information or loss of funds. The creators are not liable for any of the foregoing. Users should proceed with caution and use at their own risk.

huffswap's People

Contributors

eugenioclrc avatar nicobevilacqua avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.