Giter Site home page Giter Site logo

rayeaster / fair-selling Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gallodasballo/fair-selling

0.0 1.0 0.0 279 KB

Work towards a trust-minimized (one day trustless) token swapper. Currently: OnChainPricing & Cowswap Contract Swapper. One day: Automatic Limit Order Swap Protocol

Shell 0.03% Python 22.62% Solidity 77.35%

fair-selling's Introduction

Fair Selling

Release V0.2 - Pricer - BribesProcessor - CowswapSeller

CoswapSeller

OnChain Integration with Cowswap, all the functions you want to:

  • Verify an Order
  • Retrieve the OrderUid from the orderData
  • Validate an order through basic security checks (price is correct, sends to correct recipient)
  • Integrated with an onChain Pricer (see below), to offer stronger execution guarantees

BribesProcessor

Anti-rug technlogy, allows a Multi-sig to rapidly process cowswap orders, without allowing the Multi to rug Allows tokens to be rescued without the need for governance via the ragequit function

MainnetPricing

Given a tokenIn, tokenOut and AmountIn, returns a Quote from the most popular dexes

Dexes Support

  • Curve
  • UniV2
  • UniV3
  • Balancer
  • Sushi

Covering >80% TVL on Mainnet.

Example Usage

NOTE: Because of Balancer and UniV3 (go bug their devs pls), the following functions are not view, you must .call them from offchain to avoid spending gas

isPairSupported

Returns true if the pricer will return a non-zero quote NOTE: This is not proof of optimality

    /// @dev Given tokenIn, out and amountIn, returns true if a quote will be non-zero
    /// @notice Doesn't guarantee optimality, just non-zero
    function isPairSupported(address tokenIn, address tokenOut, uint256 amountIn) external returns (bool)

In Brownie

quote = pricer.isPairSupported.call(t_in, t_out, amt_in) ## Add .call to avoid paying for the tx

findOptimalSwap

Returns the best quote given the various Dexes, used Heuristics to save gas (V0.3 will focus on this) NOTE: While the function says optimal, this is not optimal, just best of the bunch, optimality may never be achieved fully on-chain

    function findOptimalSwap(address tokenIn, address tokenOut, uint256 amountIn) external virtual returns (Quote memory)

In Brownie

quote = pricer.findOptimalSwap.call(t_in, t_out, amt_in) ## Add .call to avoid paying for the tx

Mainnet Pricing Lenient

Variation of Pricer with a slippage tollerance

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.