The reference LRB-USDL arbitrage bot implementation, built with neon-js.

Overview

README

Introduction

arby is the reference arbitrage bot for Lyrebird.

arby is able to run at a profit because Lyrebird swaps LRB and USDL based on the target price of USDL (always $1.00), whereas Flamingo maintains the real price of USDL which can deviate from the target price. When these prices differ enough, arby can perform arbitrage by engaging in a swap trade on Flamingo at the real price and rebalancing later on Lyrebird at the target price.

As of May 9, 2022, arby implements arbitrage of USDL between Flamingo and Lyrebird by looping through the following cycle:

  • Fetch the current prevailing price of USDL on Flamingo, defined as USDL/FLM * FLM/fUSDT.
  • If $USDL > 1.0 + PEG_THRESHOLD, sell USDL for LRB through the FlamingoSwapRouter contract.
  • If $USDL < 1.0 / (1.0 + PEG_THRESHOLD), buy USDL using LRB through the FlamingoSwapRouter contract.
  • If the wallet's [USDL_VALUE|LRB_VALUE] / (LRB_VALUE + USDL_VALUE) < BALANCE_THRESHOLD * TOTAL_VALUE, rebalance by swapping appropriately on the LyrebirdAviary contract.

Getting Started

  • Run npm install to install all dependencies.
  • Run export NODE_ENV=test to run on testnet, or export NODE_ENV=prod to run on mainnet.
  • Set up your wallet's private key by calling export PRIVATE_KEY=<PRIVATE_KEY> Do not share your private key with anybody. Ensure that your operating environment is secure.
  • Tune parameters as desired.
  • Run npm run arby-dev to run the bot.
  • Remember to start with DRY_RUN=true and check the output.

Deploying to Production

  • Run npm run build to transpile the source to JavaScript.
  • Run docker build -t lyrebird_arbitrage . to create a container image.
  • Run your image.

Tunable Parameters

Option Description
PEG_THRESHOLD The minimum deviation from the peg at which arby should perform a Flamingo swap. 0.05 indicates that arby maintains the peg at less than 5% away from the target price.
BALANCE_THRESHOLD The threshold at which arby will rebalance on Lyrebird. 0.40 indicates that the market value proportion of USDL and LRB will be maintained above 40% of the combined market value.
SWAP_RATIO The percentage of the perfect swap (that brings the value of USDL exactly to the target price) that will be performed. A value of 0.75 indicates that arby will compute the perfect swap quantity of USDL and swap 75% of this quantity.
MAX_SPREAD The max spread that can be incurred in a Lyrebird swap, expressed in basis points. 100 indicates that a swap on Lyrebird will abort if it loses more than 1% of the fair value (at target price).
SLIPPAGE_TOLERANCE The max slippage that can be incurred in a Flamingo swap, also expressed in basis points. 100 indicates that a swap on Flamingo will abort if it loses more than 1% of the fair value (at real price) due to a preceding trade in the same block.
SLEEP_MILLIS The cycle duration expressed in milliseconds. arby will wait this duration between each cycle. It is meaningless to set this duration to less than 15000, as Flamingo prices can't change between blocks which are generated every 15 seconds.
AVIARY_WAIT_MILLIS The maximum amount of time to wait for an Aviary swap in milliseconds. If the Oracle hasn't responded by this time, arby will continue to the next cycle.
DRY_RUN If set to true, output the computations without actually performing swaps. Useful for testing and tuning parameters.
You might also like...

Stacks Voice is a reference project that builds on the SIP018 signed structured data standard to create an accountless internet forum.

Stacks Voice Stacks Voice is a reference project that builds on the SIP018 signed structured data standard to create an accountless internet forum. Th

Dec 21, 2022

[WIP] WebGL API implementation for Deno, built on GLFW using FFI.

Note I'm no longer working on this project because I have just realized macOS does not support OpenGL ES API, and adding Desktop GL backend to this mo

Jun 11, 2022

The interpretation implementation implemented programming language built for fun. I'm currently boring in full stack web development. So, I crafted this one LoL. 👻

The interpretation implementation implemented programming language built for fun. I'm currently boring in full stack web development. So, I crafted this one LoL.  👻

What's Wuttyi? Everything is expression 👻 I just developed this tiny programming language because of boring in higher level programming construct. Mo

Dec 13, 2022

An example implementation of the slack-gpt starter which ingests confluence pages to create a helpful slack bot

Slack-GPT (HR bot example implementation) Table of Contents Introduction Prerequisites Creating and installing the application Configuration Starting

Jul 31, 2023

Complete Open Source Front End Candy Machine V2 Minter dAPP Built For The Frog Nation NFT Solana Project. Built With React, Candy Machine V2, Typescript

Complete Open Source Front End Candy Machine V2 Minter dAPP Built For The Frog Nation NFT Solana Project. Built With React, Candy Machine V2, Typescript

Complete Open Source Front End Candy Machine V2 Minter dAPP Built For The Frog Nation NFT Solana Project. Built With React, Candy Machine V2, Typescript

Sep 24, 2022

In this project, I built a simple HTML list of To-Do tasks. This simple web page was built using Webpack, creating everything from a JavaScript index file that imported all the modules and assets

In this project, I built a simple HTML list of To-Do tasks. This simple web page was built using Webpack, creating everything from a JavaScript index file that imported all the modules and assets

To Do List In this project, I built a simple HTML list of To-Do tasks. This simple web page was built using Webpack, creating everything from a JavaSc

Mar 31, 2022
Comments
  • feat(logging): multi logging streams, sentry

    feat(logging): multi logging streams, sentry

    The idea is to enable streaming the log output into another log channel, Sentry in this case, so later if the bot owner integrates with Sentry, they can use Sentry to check the warning or error log reports without login into the bot server or sending a message for the owner that the bot does not generate profit in a particular range of time.

    This is just my idea, so feel free to reject it whether it does not match your development plan.

    opened by mcvnh 0
  • Different prices used for computeSwapWithMin

    Different prices used for computeSwapWithMin

    Arby is currently using getGlobalUsdlPrice (/api/prices) as the value for l_asset_price in computeSwapWithMin.

    However https://lyrebird.finance/swap/ uses /api/targetPrices (which is fixed at $1.0 for USDL) for l_asset_price in computeSwapWithMin.

    Which is the correct price used for the actual swap on lyrebird finance?

    opened by Mercurii7 0
Owner
null
Profitable flashloans by arbitraging the ETH Price on Kyber and Uniswap - Bot Arbitrage

profitable_flashloans Arbitrage bot setup to search for arbitrage opportunities using the pair ETH/DAI in the Uniswap & Kyber DEXes This version of th

Stalin Javier Macias Gómez 12 Dec 18, 2022
Integration with https://neon.tech Serverless Postgres

README Welcome to RedwoodJS! Prerequisites Redwood requires Node.js (>=14.19.x <=16.x) and Yarn (>=1.15) Are you on Windows? For best results, follow

RedwoodJS 3 Sep 16, 2022
ParkyDB - block based, linkable and verifiable document database -- javascript reference implementation

Ancon ParkyDB A data mesh database using Web 3.0 technology Note: Requires Node v17.7.2 and up for development More about data mesh architecture Block

Ancon Protocol 6 Aug 16, 2022
The Next.js reference implementation on how to design better APIs

This is the Next.js reference implementation of my blog bost on How to design better APIs. Getting Started Clone the repository git clone https://gith

Ronald Blüthl 7 Nov 22, 2022
An easy-to-read, quick reference for JS best practices, accepted coding standards, and links around the Web

Feel free to contribute! Where? http://www.jstherightway.org Why? Today we have a bunch of websites running JavaScript. I think we need a place to put

BrazilJS 8.5k Jan 1, 2023
Reference for How to Write an Open Source JavaScript Library - https://egghead.io/series/how-to-write-an-open-source-javascript-library

Reference for How to Write an Open Source JavaScript Library The purpose of this document is to serve as a reference for: How to Write an Open Source

Sarbbottam Bandyopadhyay 175 Dec 24, 2022
Modern Spatial Reference System Class. Supports EPSG Codes, PROJ4 String, and Well-Known Text.

spatial-reference-system Modern Spatial Reference System Class. supports EPSG Codes PROJ4 Strings ESRI and OGC Well-Known Text PRJ File install npm in

Daniel J. Dufour 6 Jul 22, 2022
Sanity plugin for viewing resources which reference a particular resource.

@indent-oss/sanityio-referenced-by Plugin to see which documents reference a particular document referenced-by-sanityio.mov Video Alt Text: Demonstrat

Indent 16 Nov 2, 2022
🎹 Memorize piano scales with ease! A music practice program w/ MIDI support. Consider it an interactive reference manual

Piano Trainer Learn to play the piano at your own pace through various modes of practice. Watch the video Features MIDI compatible Home row keyboard i

Zane Helton 1.1k Dec 21, 2022
A Complete Javascript Learning Reference Guide.

Learn Javascript A Javascript Reference Repository, which was initially created for my refernce is now open. Any one can Learn and Add more Content to

Abdul Rehman Kalsekar 18 Oct 26, 2022