Giter VIP home page Giter VIP logo

gingerbread's Introduction

GingerBread ๐Ÿช

A bot for executing arbitrage trades using flash swaps on the avalanche C-chain. Has the option to log succesful arbitrage trades on Telegram.

How to Prepare ๐Ÿฅ˜

  • clone this reposity:
git clone https://github.com/Joshua-Oladeji/GingerBread.git
  • run npm install from the root directory to install dependencies

  • fill the .env.example file with the appropriate data and rename the file to .env

    • PRIVATE_KEY: private key of the contract deployer address (metamask)
    • GANACHE_PRIVATE_KEY private key of the deployer address from Ganache
    • GANACHE_ADDR1_PRIVATE_KEY private key of another address from Ganache. This is only needed if you want to run the unit tests.
    • C_CHAIN_NODE: a link that connects you to an avalanche C-chain node. you can get a 'speedy-node' from moralis.io
    • TELEGRAM_BOT_TOKEN: an authorization token from Telegram's Bot father. it's pretty easy to get one
    • SERVER_URL: base url of your server. it's for configuring a webhook for your telegram bot. if you're running on localhost, you will need to expose your server via a public url. check out ngrok
    • FLASH_SWAP_ADDRESS: contract address of the bot you'll deploy
  • compile the contract using the following command:

npx hardhat compile
  • deploy the contract to your preferred network. available networks can be found in hardhat.config.js. default network is Ganache, so make sure to spin up a local blockchain using ganache before running this command.
npx hardhat run scripts/deploy.js --network <network-name>
  • run the server.js file, relax and wait to be served.


Methods โšก

you might want to know the purpose of each method if you want to tweak some things in the recipe.

constructor(token0, token1) ๐Ÿ”ฅ

  • a new GingerBread is initialized with 2 parametes which represents the tokens that constitute a pair.
  • each parameter is an object containing the 'symbol', 'address' and 'volume' keys.... like so:
{ 
  symbol: 'WAVAX', 
  address: '0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7', 
  volume: 1000 
}
  • volume represents the amount of a particular tokens to be borrowed during the arbitrage.

bake() ๐Ÿ‘ฉโ€๐Ÿณ

  • this method runs the bot by listening to every new block and executing arbitrage opportunities if they exist.

taste() ๐Ÿฐ

  • logs the prices of the tokens on the pangolin and traderjoe DEXes.
  • logs the potential profit/loss realized if an arbitrage is attempted based on the current tokens prices. Screenshot (248)

serve() ๐Ÿฝ

  • adds listeners for all events on the FlashSwapper contract. info from every event is then emitted to be logged to telegram.

flourRemaining()

  • returns the balance of AVAX remaining (gas fees) in the FlashSwapper contract.



Written originally as a submission for @cryptofishx bounty.

gingerbread's People

Contributors

jo-oladeji 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.