DEV Community

Cover image for How to make a profitable trading bot on Aldrin dTWAP? Or how to generate passive income in web3?

Posted on


How to make a profitable trading bot on Aldrin dTWAP? Or how to generate passive income in web3?

Aldrin Labs recently released dTWAP - distributed TWAP order

What is dTWAP

dTWAP - distributed TWAP order.
TWAP - means execution over time (read more here:

What does it mean "distributed"?

It describes the nature of dTWAP implementation:

  1. You create dTWAP order ( example: buy $10mln SOL over next 2 weeks )
  2. dTWAP program will lock $10mln and start slowly unlock it for execution
  3. dTWAP executor bot will notice arbitrage opportunity against any other source of liquidity and execute the ticket

So distributed means that your order might be executed across many liquidity sources from Serum/AMM to private liquidity pool by some VC

So how to create a bot that will be generating revenue?

Well, it's quite easy actually, first you need to learn node.js basics
Then you need to create a simple node.js web-server in Typescript and figure out how to deploy it to Heroku for example
Then you can just add this file
to your project, import it, setup private key in ENV and you are good to go

Don't forget to tweak priceDiff at Line 13! At this point (27mar 2022) priceDiff must be at least bigger than 0.5 to be profitable with execution against Aldrin AMM

Improvement ideas:

  • integrate with aggregator
  • integrate with CEX
  • integrate with own liquidity

dTWAP right now is in private beta mode, so volume might be not that interesting, but it's good opportunity to learn how to create own bot and prepare for full launch in few weeks!

Image description

Top comments (4)

milan59634410 profile image
M I L A N ‘½⏱’

currently dTWAP is running for a pair of SOL / USDC, are other pairs being considered?

rinegade_sol profile image

good question, sir
yes, Aldrin Labs will add all major liquid pairs and we plan to make it permissionless later in future, so anyone will be able to add own token

al_guzz profile image
Al-Guzz ‘½⏱’

I will try this step

rinegade_sol profile image


50 CLI Tools You Can't Live Without

The top 50 must-have CLI tools, including some scripts to help you automate the installation and updating of these tools on various systems/distros.