GithubHelp home page GithubHelp logo

isabella232 / exchange-callees Goto Github PK

View Code? Open in Web Editor NEW

This project forked from makerdao/exchange-callees

0.0 0.0 0.0 331 KB

Exchange Callee contracts for LIQ2.0 Flash Loans

License: GNU Affero General Public License v3.0

Makefile 0.63% Solidity 97.41% Nix 0.51% Shell 1.46%

exchange-callees's Introduction

Exchange Callees

Build Status

This repository contains exchange callee contracts, which wrap around decentralized exchanges and interact with the Maker Protocol. They are used in conjunction with the auction-demo-keeper to demonstrate flash loan functionality within LIQ2.0's collateral auctions.

With built-in flash loans, auction participants can accept a collateral advance from LIQ2.0, send it to an exchange callee contract to be traded for Dai, forward any Dai profit to an external address, and pay back the auction - all in a single transaction. In terms of capital, the participant only needs ETH to pay for gas costs.

NOTE: These contracts are intended as a code example, and have not been audited or tested in a production environment.

Architecture

Each exchange has its own public callee contract, which exposes a function called clipperCall(owe,slice,data). This method is called by the Clipper contract, the collateral auction house of LIQ2.0. After receiving internal gem (i.e. collateral) from Clipper, it conducts the following steps:

  1. Converts internal gem to ERC20 gem
  2. Approves exchange to pull ERC20 gem
  3. Trades ERC20 gem for ERC20 dai
  4. Forwards any ERC20 gem (if present) to external address
  5. Converts ERC20 dai to internal dai and sends to msg.sender
  6. Forwards ERC20 dai profit (if present) to external address
  7. Sends internal dai to Clipper for repayment (occurs in Clipper.take)

NOTE:

  • NEVER DIRECTLY SEND internal/ERC20 gem/dai to an exchange callee contract.
  • Remember to call vat.hope(clipper) from the msg.sender once before calling Clipper.take

Exchanges supported

Public addresses

Improvements

To slow down or defend against generalized frontrunning bots, consider:

  • Deploying an ownable exchange-callee contract and add an auth modifier to clipperCall(), so only the owner (you) can call the function
  • Using a mempool-shielded transaction service, as outlined in this blog post

Testing

Requires Dapptools

$ dapp update
$ dapp --use solc:0.6.12 test

Disclaimer

YOU (MEANING ANY INDIVIDUAL OR ENTITY ACCESSING, USING OR BOTH THE SOFTWARE INCLUDED IN THIS GITHUB REPOSITORY) EXPRESSLY UNDERSTAND AND AGREE THAT YOUR USE OF THE SOFTWARE IS AT YOUR SOLE RISK. THE SOFTWARE IN THIS GITHUB REPOSITORY IS PROVIDED β€œAS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. YOU RELEASE AUTHORS OR COPYRIGHT HOLDERS FROM ALL LIABILITY FOR YOU HAVING ACQUIRED OR NOT ACQUIRED CONTENT IN THIS GITHUB REPOSITORY. THE AUTHORS OR COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS CONCERNING ANY CONTENT CONTAINED IN OR ACCESSED THROUGH THE SERVICE, AND THE AUTHORS OR COPYRIGHT HOLDERS WILL NOT BE RESPONSIBLE OR LIABLE FOR THE ACCURACY, COPYRIGHT COMPLIANCE, LEGALITY OR DECENCY OF MATERIAL CONTAINED IN OR ACCESSED THROUGH THIS GITHUB REPOSITORY.

exchange-callees's People

Contributors

brianmcmichael avatar dizzy avatar e18r avatar godsflaw avatar hexonaut avatar julienmartinlevrai avatar kentonprescott avatar lollike avatar talbaneth 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.