All Projects β†’ teal-finance β†’ rainbow

teal-finance / rainbow

Licence: MIT license
DeFi options comparator to detect market opportunities with CLI (Go) and web (Vue3).

Programming Languages

go
31211 projects - #10 most used programming language
Vue
7211 projects
typescript
32286 projects
Dockerfile
14818 projects
Makefile
30231 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to rainbow

uniswap-python
πŸ¦„ The unofficial Python client for the Uniswap exchange.
Stars: ✭ 533 (+1232.5%)
Mutual labels:  dex, decentralized-exchange, defi
botdexdamar
πŸ€– multichain trading bot with sniper, frontrun, backrun, sandwich
Stars: ✭ 124 (+210%)
Mutual labels:  dex, defi
serum-vial
Real-time WebSocket market data API for Serum
Stars: ✭ 154 (+285%)
Mutual labels:  dex, solana
every-eos
Decentralized exchange based on eos.io
Stars: ✭ 20 (-50%)
Mutual labels:  dex, decentralized-exchange
Solnet
Solana's .NET SDK and integration library.
Stars: ✭ 252 (+530%)
Mutual labels:  solana, defi
defi
Tools for use in DeFi. Impermanent Loss calculations, staking and farming strategies, coingecko and pancakeswap API queries, liquidity pools and more
Stars: ✭ 464 (+1060%)
Mutual labels:  dex, defi
uniswap-skim
scripts to scan all of the uniswapV2πŸ¦„ contracts on ethereum and search for skim opportunities
Stars: ✭ 126 (+215%)
Mutual labels:  dex, defi
polkaswap-web
Polkaswap is a non-custodial, cross-chain AMM DEX protocol for swapping tokens based on Polkadot and Kusama relay chains, Polkadot and Kusama parachains, and blockchains directly connected via bridges. Polkaswap removes trusted intermediaries and provides the opportunity for faster trading.
Stars: ✭ 43 (+7.5%)
Mutual labels:  dex, defi
Derbit-Volatility-Visulization
Visualization Tool for Deribit Options
Stars: ✭ 66 (+65%)
Mutual labels:  options, deribit
alcor-ui
Alcor Exchange | First self-listing onchain DEX for eosio tokens;
Stars: ✭ 103 (+157.5%)
Mutual labels:  dex, defi
core
SIREN Core Smart Contracts
Stars: ✭ 39 (-2.5%)
Mutual labels:  options, defi
awesome-defi
Curated list of awesome DeFi protocols, dapps, wallets and other resources
Stars: ✭ 36 (-10%)
Mutual labels:  solana, defi
app-monorepo
Secure, open source and community driven crypto wallet runs on all platforms and trusted by millions.
Stars: ✭ 1,282 (+3105%)
Mutual labels:  solana, defi
atomic-swap-kit-android
Atomic Swap Android library for Bitcoin (BTC) and Bitcoin Cash (BCH) swaps in decentralized manner. Implemented on Kotlin.
Stars: ✭ 17 (-57.5%)
Mutual labels:  dex, decentralized-exchange
airswap-web
AirSwap Web App
Stars: ✭ 94 (+135%)
Mutual labels:  dex, defi
v1-contracts
Primitive protocol solidity contracts.
Stars: ✭ 42 (+5%)
Mutual labels:  options, defi
tomox-sdk-ui
SDK UI to build a Decentralized Exchange on TomoX protocol
Stars: ✭ 24 (-40%)
Mutual labels:  dex, decentralized-exchange
SimpleConfig
No description or website provided.
Stars: ✭ 22 (-45%)
Mutual labels:  options
app-ui
DEUS app front-end
Stars: ✭ 20 (-50%)
Mutual labels:  defi
prettier-config-solidity
Prettier config optimized to reduce AST churn & conform to solidity spec
Stars: ✭ 28 (-30%)
Mutual labels:  defi

🌈 Rainbow

logo Dashboard for DeFi options trading highlighting market opportunities to ease strategies decision. With the Rainbow screener, users can scan CEX/DEX markets to fetch available options data. Empowered by the Teal.Finance team.

Go Report Card

Rainbow is live at teal.finance/rainbow

Please share any feedback:

🎯 Motivations

Rainbow is inspired by the following trends:

  • Crypto-assets and DeFi becoming mainstream,
  • Advent of the Internet of Blockchains’ world with more cross-chain applications and communications,
  • Crypto options trading growing bigger than the spot market, like in traditional Finance.

The crypto derivatives markets are expected to grow a lot more in the upcoming years. Specifically, the options markets will see the biggest growth, because in Finance, Option market is much bigger than the underlying spot market. This is lagging in Crypto, when we look at Deribit's volume (the main centralized venue for Crypto Options), compared to Perpetuals future.

We participated to hackathons and have won super prices: Ethereum's EthGlobal Hackathon, Solana's Ignition Hackathon and Encode Club's Hack DeFi.

More info on our motivations: cryptonuage.com/posts/internet-of-decentralized-options

πŸ›οΈ Supported exchanges

  • Deribit: Centralized exchange. Main venue for crypto Options trading.

  • Delta Exchange: Centralized exchange for futures, options and interest rate swaps on 50 underlying cryptocurrencies.

  • Lyra (Ethereum): DeFi protocol for trading options based on Layer 2, Optimism, using a custom AMM.

  • Thales Optimism and Polygon, DeFi protocol for binary options (exotic options).

  • Zeta (Solana): DeFi options protocol built using Serum order books.

πŸ— Deprecated exchanges

  • PsyOptions (Solana): DeFi options protocol build on Serum order books. But PsyOptions pivoted to DeFi Options Vaults (DOV).

  • Opyn (Ethereum): DeFi options protocol using TheGraph & 0x. But Opyn also pivoted to more vaults like products Squeeth, Crab...

🏎️ Run it from source code

Rainbow can be used as a CLI or with a frontend as our official instance: https://teal.finance/rainbow.

πŸ“‘ Requirements

  • Go v1.18+ (single requirement for the CLI)
  • Node v14+
  • Yarn v1.20+
  • Docker v20 (optional)
  • Podman v3 (optional)

Rainbow can be used in the CLI, without requiring Node, Yarn, Docker…

Snap provides a simple way to install these requirements on many Linux distributions:

snap install go   --classic
snap install node --classic  # installs yarn too

# check
go   version
yarn versions

On Debian/Ubuntu, the command sudo apt install golang may install an older version. Check it with apt list --all-versions golang golang-1.*. To install a more recent Go version, you may try:

sudo apt purge   golang
sudo apt install golang-1.18

The Dockerfile can be used equally with Docker or Podman.

πŸ“₯ Clone the Rainbow Git repo

git clone https://github.com/teal-finance/rainbow
cd rainbow

πŸͺƒ Run the CLI

The Rainbow project provides a Command Line Interface (CLI) to let users play from their terminal. The command ./cli retrieves (few minutes) and prints a pretty nice table of all options.

go run ./cmd/cli

CLI screenshot

βš’οΈ Makefile for server & web

See the make help output.

πŸ”§ Build

make all     # Build both backend and frontend
make server  # Build the backend only
make front   # Build the frontend only
make clean   # Clean all

πŸš€ Run

The run targets do not depend on the above build targets. You do not need to make build before make run.

make run        # Run the backend in dev mode
make run-ui     # Run the frontend in dev mode

To serve the static website using the Rainbow backend only, as in production:

make clean -j && make all -j && make run

πŸ‹ Container

make container-run  # Build and run backend + frontend
make container-rm   # Stop and remove all

The container targets try to use docker, then podman.

The container-run also opens a browser window on http://localhost:1111/ and prints the container logs indefinitely.

Use CTRL+C to stop the log printing. This does not stop, the container. To stop the container simply use make container-rm.

The two other containers targets are not needed to be invoked manually:

make container-build  # Build the container image
make container-stop   # Stop/remove the container

The container parameters can be customized: πŸ™‚

make container-run expose=80 port=80 base=/rainbow/

πŸ–οΈ Manual build & run

Backend

The frontend requires the server API.

go build ./cmd/server && ./server

# or

go run ./cmd/server     # same as "make run"

Frontend

To run the Vue3 frontend in dev mode. Similar to make run-ui:

cd frontend
yarn
yarn dev --open

In prod mode, the backend serves the web static files from frontend/dist. Same as make frontend/dist:

cd frontend
yarn
yarn build

Finally open http://localhost:8090

🐳 Manual build/run of the container

This Git repo provides a Dockerfile for a secured and light all-in-one container image: 30 MB.

The image contains the hardened sever executable and the frontend static files.

The container enables by default the CORS, the export ports and a rate limiter. Some of these features can be customized using environments variables.

The following commands configures the server listening on port 2222 (published to port 1111) and frontend using CORS with http://localhost:1111. See also the comments within the Dockerfile for the details.

podman build --build-arg addr=http://localhost:1111 --build-arg port=2222 -t rainbow .
podman stop rainbow # if already running in background
podman run --rm -p 0.0.0.0:1111:2222 -d --name rainbow rainbow
podman logs --follow rainbow

Open http://localhost:1111.

The above manual commands can be obtained using the Makefile:

make container-run addr=http://localhost:1111 expose=1111 port=2222

🚩 Server command line flags

Rainbow embeds a complete HTTP server, including a rate limiter, an export port (Prometheus monitoring), and more. For more details see the underlying project Teal.Finance/Garcon.

$ go build ./cmd/server
$ ./server -h
Usage of ./server:
  -addr string
      Schema and DNS used for doc URL and CORS, has precedence over MAIN_ADDR (default "http://localhost")
  -aes string
      128-bit AES key (32 hex digits) for the session cookies, has precedence over AES128
  -alert string
      Webhook endpoint to notify anomalies, has precedence over ALERT_URL
  -burst int
      Max requests during a burst, has precedence over REQ_BURST (default 22)
  -cex
      Enable the centralized exchanges: Deribit and Delta Exchange
  -dev
      Enable the developer mode (enabled by default if -addr and -port are not used)
  -dex
      Enable the decentralized exchanges: Lyra, Synquote and Zeta
  -exotic
      Enable the decentralized exchanges with binary options: Thales
  -exp int
      Export port for Prometheus, has precedence over EXP_PORT
  -form string
      Webhook endpoint to notify filled contact form, has precedence over WEBFORM_URL
  -hmac string
      HMAC-SHA256 key (64 hex digits) for the JWT tokens, has precedence over HMAC_SHA256
  -period duration
      Period to fetch market data from providers (default 10m0s)
  -port int
      API port, has precedence over MAIN_PORT (default 8090)
  -providers string
      Coma-separated list of providers, has precedence over PROVIDERS (default "ALL")
  -rate int
      Max requests per minute, has precedence over REQ_PER_MINUTE (default 88)
  -version
      Print version and exit
  -www string
      Folder of the web static files, has precedence over WWW_DIR (default "frontend/dist")

πŸ›£οΈ API

To test the API endpoints, run the backend:

make run

or using the container alternative:

make container-run expose=8090

/v0/options

The /v0/options endpoint accepts optional parameters.

Filtering

Progressive filtering:

The general URL pattern:

/v0/options/{asset}/{expiry}/{provider}/{format}

The API may be tested with cURL:

curl localhost:8090/v0/options

curl localhost:8090/v0/options/BTC

curl localhost:8090/v0/options/BTC/2022-04-29

curl localhost:8090/v0/options/BTC/2022-04-29/Deribit

curl localhost:8090/v0/options/BTC/2022-04-29/Deribit/csv

Query string

Moreover, the parameters can also be passed using the query string:

POST method

The API also supports the POST form:

curl localhost:8090/v0/options -d asset=BTC -d asset=ETH

curl localhost:8090/v0/options -d asset=BTC -d expiry=2022 -d provider=Deribit -d format=csv

The POST form is recommended for privacy reasons since it hides your query within the encrypted request body when using HTTPS.

Awesome expiry filtering

The expiry filtering matches for the beginning of the dates:

Supported formats

The {format} parameter is the last one at any position.

The current supported formats are JSON, CSV and TSV. Depending on user requests, more formats may be supported such as JSON-LD, JSON Lines (or NDJSON, see JSON streaming), Avro, Parquet, DataFrame, Excel, Google Sheets Docs.

HTTP header

The "Accept" HTTP header is also supported:

curl localhost:8090/v0/options -H "Accept: application/json"

curl localhost:8090/v0/options -H "Accept: text/csv"

curl localhost:8090/v0/options -H "Accept: text/tsv"

Example response in JSON format

{
  "name":     "ETH-2021-10-29 23:59:59-3200-PUT",
  "expiry":   "2021-10-29 23:59:59",
  "type":     "PUT",
  "asset":    "ETH",        // ETH, BTC, SOL
  "strike":   3200,
  "exchange": "DEX",        // Type: CEX or DEX
  "chain":    "Solana",     // Ethereum, Solana...
  "layer":    "L1",
  "provider": "PsyOptions", // Opyn, Lyra, Deribit...
  "currency": "USDC"        // Quote currency: BTC...
  "bid": [{
            "px": 13.3,     // Abbreviation for "price"
            "size": 5,      // Variant of "quantity"
          },
          {
            "px": 13.1,
            "size": 10,
          }],
  "ask": [{
            "px": 15.12,
            "size": 5,
          },
          {
            "px": 15.25,
            "size": 9,
          }]
}

Example response in CSV format

The CSV and TSV formats are limited to the two best order-books: Bid #1, Bid #2, Ask #1, Ask #2.

$ curl -s localhost:8090/v0/options/csv
Name,Expiry,Asset,Currency,Strike,Type,Provider,Layer,Chain,Bid Price #1,Bid Size #1,Bid Price #2,Bid Size #2,Ask Price #1,Ask Size #1,Ask Price #2,Ask Size #2
SOL-2022-04-01 08:00:00-120-Call,2022-04-01 08:00:00,SOL,USDC,120,CALL,Zeta,L1,Solana,0.9238,285.24,0.73,300,1.0463,285.24,1.1,300
SOL-2022-04-01 08:00:00-130-Call,2022-04-01 08:00:00,SOL,USDC,130,CALL,Zeta,L1,Solana,0.2187,285.24,0.09,300,0.3486,285.24,0.37,300
BTC-29APR22-40000-P,2022-04-29 08:00:00,BTC,BTC,40000,PUT,Deribit,–,–,736.51598,62.2,712.7574000000001,28.7,807.7917200000002,118.2,831.5503000000001,30.3
BTC-8APR22-44000-P,2022-04-08 08:00:00,BTC,BTC,44000,PUT,Deribit,–,–,617.72308,0.1,593.9645,49.8,641.48166,32.5,665.2402400000001,31.1
BTC-1APR22-42000-P,2022-04-01 08:00:00,BTC,BTC,42000,PUT,Deribit,–,–,71.27574000000001,0.1,47.517160000000004,75.4,95.03432000000001,82.7,118.79290000000002,50.9

/v0/bff/cp

This endpoint has been inspired by the BFF pattern (Backend for Frontend pattern) to simplify the frontend processing. This endpoint should not used by API users because we may drop it in a further release.

[ { "asset": "ETH",
    "expiry": "Dec 31",
    "provider": "Deribit",
    "call": { "bid": {"px": 1805, "size":  24},
              "ask": {"px": 1830, "size": 459}},
    "strike": 4400,
    "put":  { "bid": {"px": 1305, "size":  26},
              "ask": {"px": 1330, "size":  37}}
  },
  { "asset": "ETH",
    "expiry": "Dec 31",
    "provider": "Deribit",
    "call": { "bid": {"px": 1140, "size": 258},
              "ask": {"px": 1160, "size":  33}},
    "strike": 5200,
    "put":  { "bid": {"px": 1235, "size":  80},
              "ask": {"px":    0, "size":   0}}
  },
  // ...
  { "asset": "BTC",
    "expiry": "Nov 26",
    "provider": "Deribit",
    "call": { "bid": {"px": 2045, "size":  7.5},
              "ask": {"px": 2105, "size":  5.3},
    "strike": 50000,
    "put":  { "bid": {"px":  125, "size": 27.2},
              "ask": {"px":  135, "size": 70.2}}
} ]

/v0/graphql

This endpoint is currently designed to meet the requirements of the frontend. This endpoint should not yet used by API users because we may drop it in a further release.

However, other websites can display the Rainbow screener using this GraphQL API. Please contact us. πŸ˜‰

/v0/graphiql (with an "i")

This interactive GraphQL endpoint is used in developer mode to tune the frontend GraphQL queries.

πŸ—£οΈ Need something else?

Please share your thoughts, suggest ideas, request features, contact us and join our efforts to build awesome tools:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].