• Stars
    star
    304
  • Rank 137,274 (Top 3 %)
  • Language
    Solidity
  • Created over 3 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A sample application invokes a flashswap in PancakeSwap and a monitoring tool in Node.js.

Pancake & BakerySwap arbitrage

A sample application invokes a flashloan with Flash Swaps and a monitoring tool in Node.js. To know details about Flash Swaps: visit https://uniswap.org/docs/v2/core-concepts/flash-swaps/

Article: visit https://yuyasugano.medium.com/arbitrage-party-between-pancakeswap-and-bakeryswap-apeswap-b055af13e4fc

Disclaimer

This repo is not either an investment advice or a recommendation or solicitation to buy or sell any investment and should not be used in the evaluation of the merits of making any investment decision. It should not be relied upon for accounting, legal or tax advice or investment recommendations. The contents reflected herein are subject to change without being updated.

The codes are written for informational and educational purpose only, https and websocket endpoints might not work well if those endpoint have been depreciated. Please find other available endpoints in that case. Thanks for your understanding.

Links

Infrastructure

Basically arbitrage opportunity dont last long, your transaction must make it into the next block. So you have <3 seconds watching for opportunities, decide and execute transaction. Sometimes there are also a chance to 2-3 have block, see example below. BLOCKNUMBER in the environmental variables can be configured within how many blocks a transaction should be processed.

[7920960] [6/1/2021, 5:50:37 PM]: alive (bsc-ws-node.nariox.org) - took 308.42 ms
[7920991] [6/1/2021, 5:52:09 PM]: [bsc-ws-node.nariox.org] [BAKE/BNB ape>bakery] Arbitrage opportunity found! Expected profit: 0.007 $2.43 - 0.10%
[7920991] [6/1/2021, 5:52:09 PM] [bsc-ws-node.nariox.org]: [BAKE/BNB ape>bakery] and go:  {"profit":"$1.79","profitWithoutGasCost":"$2.43","gasCost":"$0.64","duration":"539.35 ms","provider":"bsc-ws-node.nariox.org"}
[7920992] [6/1/2021, 5:52:13 PM]: [bsc-ws-node.nariox.org] [BAKE/BNB ape>bakery] Arbitrage opportunity found! Expected profit: 0.007 $2.43 - 0.10%
[7920992] [6/1/2021, 5:52:13 PM] [bsc-ws-node.nariox.org]: [BAKE/BNB ape>bakery] and go:  {"profit":"$1.76","profitWithoutGasCost":"$2.43","gasCost":"$0.67","duration":"556.28 ms","provider":"bsc-ws-node.nariox.org"}
[7921000] [6/1/2021, 5:52:37 PM]: alive (bsc-ws-node.nariox.org) - took 280.54 ms

software version

Ensure your node and truffle version is higher than these:

$ node -v
v14.17.6
$ truffle version
Truffle v5.3.7 (core: 5.3.7)
Solidity - >=0.6.6 <0.8.0 (solc-js)
Node v14.17.6
Web3.js v1.3.6

environment variables

TEST_AMOUNT=0.005
BNB_AMOUNT=1000
WALLET_ADDRESS=<your wallet address>
PRIVATE_KEY=<your private key>
PRIVATE_TEST_KEY=<your test private key>
NETWORKID=56
BLOCKNUMBER=3
BSC_WSS=wss://bsc-ws-node.nariox.org:443
BSC_HTTPS=https://bsc-dataseed.binance.org/
BSC_TEST_HTTPS=https://data-seed-prebsc-1-s1.binance.org:8545/
MORALIS_BSC=https://speedy-nodes-nyc.moralis.io/<your account>/bsc/mainnet
WSS_BLOCKS=wss://bsc-ws-node.nariox.org:443

setup steps

  1. Rename .env.template to .env and fill out required information
  2. Configure truffle-config.js with appropriate parameters (if you deploy a contract)
  3. Install node.js packages and compile a smart contract code
npm install
truffle compile
  1. Migrate the contract to the network (confirm if you do this in BSC mainnet)
truffle migrate --network mainnet

License

This library is licensed under the MIT License.

More Repositories

1

finance_python

Elementary Jupyter Notebook Samples for Finance
Jupyter Notebook
72
star
2

sushi-uni-arbitrage

A sample triangular arbitrage application with a dYdX flashloan via Sushi & Uni.
JavaScript
46
star
3

arbitrage-flashloan

A sample application invokes a flashloan in dYdX and a monitoring tool in Node.js.
JavaScript
37
star
4

bsc-arbitrageur

JavaScript
28
star
5

bot

CCXT + Binance python program.
Python
17
star
6

aave_flashloan

sample code to perform aave flashloan https://docs.aave.com/developers/tutorials/performing-a-flash-loan
Solidity
16
star
7

terraform-sagemaker-sample-1

a sample repository for terraform to run Amazon SageMaker notebook part 1
Jupyter Notebook
13
star
8

multiplier-flashloan-arbitrage

Solidity
12
star
9

jpyc-rinkeby

JPYC is a JPY-pegged stablecoin, legally dealt as a prepaid payment instrument in Japan.
Solidity
10
star
10

flashloan

sample code to perform aave flashloan with OrFeed https://docs.aave.com/developers/tutorials/performing-a-flash-loan
Solidity
10
star
11

brownie-test

brownie test for DeFi and Flashloan protocols
Python
10
star
12

backtesting_sample

Jupyter Notebook
5
star
13

blocknative-mev

JavaScript
5
star
14

anaconda3

a sample docker image for crypto currency analytics with anaconda3
Jupyter Notebook
4
star
15

ml-classifier-ohlc

a sample machine learning analysis for bitbank.cc OHLC data
Jupyter Notebook
3
star
16

ohlc

samples pipenv project for ohlc information from bitbank.cc API
Jupyter Notebook
3
star
17

hagoromo

Hagoromo is an open source social project of decentralized crowdfunding written for Ethereum and Polygon network.
JavaScript
3
star
18

dice-test

DiCE Docker container example based on Anaconda3 (ContinuumIO/docker-images)
Jupyter Notebook
3
star
19

ml-classifier-Ta-Lib-ohlc

an advanced machine learning analysis for bitbank.cc OHLC data
Jupyter Notebook
2
star
20

updatable-solidity

JavaScript
2
star
21

defi-test

defipulse data scraper with lambda and dynamodb
Python
2
star
22

donald-trump-twitter-bot

Sentiment analysis Twitter BOT with AWS Lambda and SageMaker
Jupyter Notebook
2
star
23

terraform-sagemaker-sample-2

a sample repository for terraform to run Amazon SageMaker notebook part 2
Jupyter Notebook
2
star
24

information-coefficient-case

Jupyter Notebook
1
star
25

sagemaker-tpot-container

a sample sagemaker scikit-learn container for TPOT AutoML solution
Jupyter Notebook
1
star
26

flashloan_aavev2

Solidity
1
star
27

cardgame-erc721x

A test implementation with erc721x multi-fungible token by Loom
JavaScript
1
star
28

elasticsearch-py

a sample elasticsearch-py script for close/volume/timestamp data a second base
Python
1
star
29

stock-to-flow-model

Jupyter Notebook
1
star
30

defi-analysis

defi-analysis repository
Jupyter Notebook
1
star