DEV Community

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

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
(https://twitter.com/Aldrin_Exchange/status/1505272899149598721)

What is dTWAP

dTWAP - distributed TWAP order.
TWAP - means execution over time (read more here: https://en.wikipedia.org/wiki/Time-weighted_average_price)

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 https://github.com/aldrin-exchange/aldrin-sdk/blob/feature/dtwap-executor/examples/dtwap/dtwapSwap.ts
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

NOTICE:
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)

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

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

Collapse
 
rinegade_sol profile image
rinegade.sol

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

Collapse
 
al_guzz profile image
Al-Guzz ‘½⏱’

I will try this step

Collapse
 
rinegade_sol profile image
rinegade.sol

few..