Building a MelonBot

Using MelonJS to trade programmatically on behalf of a Melon fund

Erin Koen
Erin Koen
May 6 · 9 min read
Image for post
Image for post
Make sure your bot buys low and sells high.


Everything you need, nothing you don’t.
Image for post
Image for post
A simple directory, so far.

Utility Methods

Wallet, Account, and Environment Setup

Tapping into the Ethereum blockchain.

The Bot Class


The bot begins.

Fund Methods

Querying your Melon fund.

Uniswap Methods

Asking Uniswap for current prices and interpolating the results.
Using the info you got from your fund and from Uniswap to execute a trade.

Pulling it All Together

Do not use this strategy.
The script that runs our bot.
yarn devyarn run v1.21.1$ cross-env NODE_ENV=development ts-node --require dotenv-extended/config --transpile-only srcINSTANTIATING ENVIRONMENT ==>FIRING UP THE BOT ==>CONSULTING THE ORACLE ==>NO TRADING BY ORDER OF THE ORACLEGoing to sleep.INSTANTIATING ENVIRONMENT ==>FIRING UP THE BOT ==>CONSULTING THE ORACLE ==>THE ORACLE SAYS TO TRADEBuying 26270323039658927422.53 MLN by selling 430703553862299497 WETHTransaction successful.blockHash: 0xe0a94b99ec8a3ca8d5ba2d7e71a2f4ca0301cd96764d3d5f0afe9db76f71204ftransactionHash: 0xaa0edecb4c741c58b44daf5742305abb5c055949028b913d18f84cdd260bec33gasUsed: 684251Going to sleep.

Melon Protocol

A Blog Detailing the Endeavours of those within the Melon…

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store