Code Monkey home page Code Monkey logo

range-order-bot's Introduction

What is Premia?

Premia is a peer-to-peer options exchange and settlement engine built for the Ethereum Virtual Machine (EVM). The protocol is designed to provide a set of smart contracts that advance open finance by prioritizing security, self-custody, automatic execution without a trusted intermediary, and permission-less use of financial primitives. Additional information about the protocol can be found here on our website.

Range Order Bot

The range order bot is a market making script that allows users to quote two-sided markets (using concentrated liquidity) for whatever option markets that are preDefined within the settings. IV & Spot oracles are used to automatically update range orders as option prices change, minimizing the need for active management of orders. It is highly recommended that a user is familiar with how range orders work, and the risks associated with owning option positions.

PreRequisites

There are a couple of things that are needed in order to work with the range order bot locally. They include:

  • An EOA (Externally Owned Account) on Ethereum (funded on Arbitrum) with a wallet provider such as Metamask
  • If funds are on Ethereum (Mainnet) funds can be bridged to Arbitrum here
  • The repository is written in Typescript and thus requires Node to be installed
  • Git optionally can be used to clone the repository. It can be installed from here
  • An RPC provider (such as Alchemy or Infura). Due to the higher RPC throughput demand for programmatic trading, a premium RPC API key may be necessary.
  • An understanding of range orders and how concentrated liquidity works on Premia v3. If you have not done so please see our docs on Range Orders

Supported Pairs

The range order bot limited to markets with IV Oracles in order to price markets correctly on chain. All tokens are automatically paired with USDC (ie WETH/USDC). Please make sure to have sufficient capital in both tokens as the base token (ie WETH) is used for call collateral, and the quote token (ie USDC) is used for put collateral.

Token Symbol Arbitrum Goerli (Development) Arbitrum (Production)
WETH ✔️ ✔️
WBTC ✔️ ✔️
ARB ✔️
LINK ✔️ ✔️
WSTETH ✔️
GMX ✔️
MAGIC ✔️
SOL ✔️

Quick Start

  1. Clone the repository on a local computer. Instructions on how to do this can be found here.
  2. Open a terminal and navigate to the root directory, run yarn install (if yarn is installed locally) or npm install to install package dependencies.
  3. Find the .env.example file and rename it to .env. Add necessary information that is required. Note that ENV variable should either be development for Arbitrum Goerli or production to use on Arbitrum Mainnet.
  4. Navigate to src/config/index.example.ts and rename it to index.ts. Review each and every setting. Instructions & descriptions of settings are provided in the example file.
  5. Run yarn start in the command line to run the range order bot.

Watch the tutorial video

Click the Image or Link Here to watch the Tutorial!

One Click Deploy via Railway (Just bring a Wallet and RPC)

Deploy on Railway

Note: To Choose Assets and Strikes creating your own container is recommended, however this Railway template is fully compatible.

Under The Hood

At this point, you should have a general idea of what this bot is supposed to do (hint: it makes markets in options). There are many built-in features that a user should be aware. Some features include:

  • The bot will use IV Oracles & Spot Oracles to intelligently price options.
  • By default, the bot will post a "bid" and "ask" range order around the fair market value of the option
  • The bot utilizes a user defined spread away from the fair value to capture an edge. Additionally, the bot is entitled to trading fees that the taker pays.
  • The bot will automatically withdraw range orders, and deposits updated ranges when the spread is lost due to trading or option price movement.
  • Since Premia options are ERC1155's. There is both a LONG option token and a SHORT option token. The bot will automatically pair off long and short exposures to release collateral.
  • If positions accrue, the bot will begin to use options when depositing into range orders instead of collateral.
  • If an option that the bot is trading expires, the bot will automatically settle the option to release the collateral.
  • The bot will withdraw all liquidity if there is a feed failure in either the IV or Spot Oracle.
  • Parameters such as min/max delta and minDTE (days to expiration) can be used to filter what options are traded and when to stop trading them as time passes.
  • There are parameters that can be utilized to cap max exposure and enter into "close only" mode

LIMITATIONS

While the bot has many automated features, it should not be deemed a "set it and forget it" type of bot. There are many things the bot does NOT do. They include:

  • The bot will NOT manage risk for the user. Options have dynamic properties and their risk evolves over the life of the contract. It is up to the user to make adjustments for this.
  • The bot does NOT delta hedge positions. This is something a user must do on their own.
  • The bot will NOT help determine the appropriate size to trade. This is purely at the users discretion
  • There is NO built-in management of collateral tokens. It is up to the user to maintain proper collateral balances for a given market.
  • The bot is NOT a money printing black-box. It is merely an automation tool for market making.

Improvement List & Changelog

-[ ] Enable trading by side (buy only, sell only, both sides)

-[ ] Create parameter to allow taker orders for mispriced options prior to range deposits

-[ ] Enable the use of other quote tokens besides USDC

-[ ] Dynamic Asset & Strike Selection

range-order-bot's People

Contributors

guceri avatar froggiedev avatar nikkatalnikov avatar syphrpunk avatar

Stargazers

Max Mohammadi avatar Preston Chen  avatar Thales avatar  avatar  avatar Michael Demarais avatar Phil Britton avatar  avatar mav avatar AoverK avatar Tors avatar Mathieu avatar  avatar Rasyidan Akbar F. avatar Nymph avatar John Johnson avatar  avatar cozy avatar  avatar  avatar cryptofelon avatar Puddi avatar c.j.c avatar Jani Anttonen avatar 4n0n avatar Smit Rajput avatar LnsTchTps avatar BlockByBlock avatar wolfy avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

fuchsei johnrjj

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.