Rainbow is a dashboard for Decentralized Finance(DeFi) Options trading.

Related tags

Security rainbow
Overview

rainbow

logo Rainbow is a dashboard for Decentralized Finance options trading.

It's developed during Solana's Ignition & Ethereum's EthGlobal Hackathons by members of Teal.Finance.

Motivation

The crypto derivatives markets are expected to grow a lot more in the upcoming years. Specifically, the options markets will see the bigger growth.

In traditional finance, option market is much bigger than the underlying assets market. This is lagging in Crypto, when we look at Deribit's volume, the main (centralized) venue for Crypto Options, compared to Perpetuals future.

Rainbow profits from the following trends:

  • Crypto-assets and DeFi becoming mainstream,

  • DeFi composability & complexity abstraction for easy onboarding of users,

  • Advent of the Internet of Blockchains’ world with more cross-chain applications and communications,

  • Crypto options trading growing (hopefully) bigger than the spot market, like in tradFi.

Target

Rainbow is a first step in that direction: a place where users, traders and market makers can see the options, prices, expiries, liquidities across layers L1/L2.

Current status

The current version is a tool to compare market data across multiple venues, CEX and DEXes.

Deribit is supported since the beginning, because Deribit is the main options trading place.

Opyn is also supported, because we are active users of this protocol. Opyn use the 0x Protocol for the exchange of their options. Rainbow uses both Opyn and 0x APIs to retrieve their trading data. TheGraph is also used to list the available options from Opyn.

Most recently, PsyOptions (from the Solana ecosystem) has also been integrated. PsyOptions is the main DeFi options protocol.

More Ethereum and Solana protocols are planed to also be supported in the near future: Thales, Lyra, Hegic...

Now, using Rainbow, you can compare to arbitrage options across these markets, or simply get the best prices.

Technology

The back-end is developed in Go.

Deribit API is well documented, and the data retrieval was pretty straightforward to implement. Deribit even have an API playground, which all projects should also provide.

To support Opyn, Rainbow retrieves the options list using the TheGraph API. This is our first GraphQL client implementation in Go and we spent days to test and compare the different solutions: we are proud to use the GraphQL state-of-the-art in Go, based on the library https://github.com/Khan/genqlient with type-safe code generation. We got help from the Opyn team for the query examples.

Opyn support also requires to use the 0x protocol. We have battled to correctly get the bid/ask prices from 0x API. We got some help from the 0x team to identify which API call was the most suitable. This help advances our work a lot and enables us to add, in a near future, other protocols like Thales.

To support PsyOptions, we took our first plunge in the Solana ecosystem to understand and use the Serum Go library.

See also the Go documentation: https://pkg.go.dev/github.com/teal-finance/rainbow

Next step is to implement on a proper UI that enables users to trade, based on Typescript/Vue3.

Build

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

CLI

You may just use the pretty nice table printed by the command ./cli.

go build ./cmd/cli && ./cli

CLI screenshot

Back-end

If you prefer the API, use ./server.

go build ./cmd/server && ./server -dev

The flag -dev enables CORS for http://localhost:*.

Front-end

This project also provides a pretty nice Vue3 front-end that uses the API.

cd frontend
yarn
yarn dev

Container

See also the Dockerfile for a light container image: 30 MB.

The image contains the hardened sever executable (with dynamic library) and the front-end.

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 Dockerfile has been successfully tested with Docker-20.10.8 and Podman-3.3.1.

API

Command line flags

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

$ go build ./cmd/server
$ ./server -help
Usage of ./server:
  -burst int
        Max requests during a burst, has precedence over REQ_BURST (default 10)
  -dev
        Run rainbow in dev. mode
  -dns string
        Schema and DNS used for doc URL and CORS, has precedence over MAIN_DNS (default "http://localhost")
  -exp int
        Export port for Prometheus, has precedence over EXP_PORT
  -opa string
        Policy files (comma-separated filenames) for the Open Policy Agent using the Datalog/Rego format
  -port int
        API port, has precedence over MAIN_PORT (default 1234)
  -rate int
        Max requests per minute, has precedence over REQ_PER_MINUTE (default 30)
  -www string
        Folder of the web static files, has precedence over WWW_DIR (default "./dist")

Data structure

The API endpoint /v0/options replies an array of options. Each option is described with the following JSON structure:

{
  "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,
  "ExchangeType": "DEX",      // CEX or DEX
  "Chain": "Solana",          // Ethereum, Solana...
  "Layer": "L1",
  "Provider": "PsyOptions",   // Opyn, Lyra, Thales, Deribit, Psyoptions
  "Bid": [
    {
      "Price": 13.3,
      "Quantity": 5,
      "QuoteCurrency": "USDC" // ETH, BTC...
    },
    {
      "Price": 13.1,
      "Quantity": 10,
      "QuoteCurrency": "USDC"
    }
  ],
  "Ask": [
    {
      "Price": 15.12,
      "Quantity": 5,
      "QuoteCurrency": "USDC"
    },
    {
      "Price": 15.25,
      "Quantity": 9,
      "QuoteCurrency": "USDC"
    }
  ]
}
Issues
  • Add endpoint for contact-form

    Add endpoint for contact-form

    I have an issue with this PR. Explanations:

    :ok: The Garcon example serves the myapp/index.html and processes the contact-form as well: https://github.com/teal-finance/garcon/blob/main/examples/high-level/main.go#L86

    // Static website files
    ws := garcon.NewStaticWebServer("examples/www", g.ErrWriter)
    r.Get("/favicon.ico", ws.ServeFile("favicon.ico", "image/x-icon"))
    r.With(c.Set).Get("/myapp", ws.ServeFile("myapp/index.html", "text/html; charset=utf-8"))
    r.With(c.Set).Get("/myapp/", ws.ServeFile("myapp/index.html", "text/html; charset=utf-8"))
    r.With(c.Chk).Get("/myapp/js/*", ws.ServeDir("text/javascript; charset=utf-8"))
    r.With(c.Chk).Get("/myapp/css/*", ws.ServeDir("text/css; charset=utf-8"))
    r.With(c.Chk).Get("/myapp/images/*", ws.ServeImages())
    
    // Contact-form
    wf := garcon.NewContactForm(addr, "", g.ErrWriter)
    r.With(c.Set).Post("/myapp", wf.NotifyWebForm())
    

    You can test it with:

    cd garcon
    go run ./examples/high-level
    

    😿 But the Rainbow server does not serve the index.html: https://github.com/teal-finance/rainbow/blob/webform/cmd/server/main.go#L82

    // Static website: set the cookie only when visiting index.html
    ws := garcon.NewStaticWebServer(*wwwDir, g.ErrWriter)
    r.Get("/favicon.ico", ws.ServeFile("favicon.ico", "image/x-icon"))
    r.Get("/favicon.png", ws.ServeFile("favicon.png", "image/png"))
    r.Get("/preview.jpg", ws.ServeFile("preview.jpg", "image/jpeg"))
    r.With(c.Chk).Get("/js/*", ws.ServeDir("text/javascript; charset=utf-8"))
    r.With(c.Chk).Get("/assets/*", ws.ServeAssets())
    // NotFound catches index.html and other Vue sub-folders
    r.With(c.Set).NotFound(ws.ServeFile("index.html", "text/html; charset=utf-8"))
    
    // Send contact-form to Mattermost
    cf := garcon.NewContactForm("/", *form, g.ErrWriter)
    r.With(c.Chk).Post("/", cf.NotifyWebForm())
    

    You can test it with:

    cd rainbow
    git switch webform
    git pull
    go run ./cmd/server
    

    The previous snippet works well if you replace NotFound by Get("/",, but we need to add as well all the sub folders/pages managed by index.html (Single-page application).

    Another workaround is to replace Post("/" by Post("//", but not sure it will always work…

    It looks like a bug in https://github.com/go-chi/chi or more probably a mistake on my side, but what?

    opened by 0uep 1
  • Optimize Order struct

    Optimize Order struct

    • [x] Move the QuoteCurrency field from Order type to Option type
    • [x] Shorten Price / Quantity -> Px / Size
    • [x] Reuse Order struct in CPFormat
    • [x] Rename CPFormat to CallPut
    opened by 0uep 1
  • Bump terser from 5.14.1 to 5.14.2 in /frontend

    Bump terser from 5.14.1 to 5.14.2 in /frontend

    Bumps terser from 5.14.1 to 5.14.2.

    Changelog

    Sourced from terser's changelog.

    v5.14.2

    • Security fix for RegExps that should not be evaluated (regexp DDOS)
    • Source maps improvements (#1211)
    • Performance improvements in long property access evaluation (#1213)
    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies javascript 
    opened by dependabot[bot] 0
Owner
Teal.Finance
Cryptocurrencies Data for All to Verify or to Trade
Teal.Finance
🔑 A decentralized key derivation protocol for simple passphrase.

Throttled Identity Protocol (TIP) is a decentralized key derivation protocol, which allows people to obtain a strong secret key through a very simple passphrase, e.g. a six-digit PIN.

Mixin Network 35 Jul 23, 2022
Go-Yahoo-Finance-Daily-Actives - Scrape for the daily actives on yh Finance and save the data to a CSV, and optionally send it to yourself as an email

Go-Yahoo-Finance-Daily-Actives - Scrape for the daily actives on yh Finance and save the data to a CSV, and optionally send it to yourself as an email

Sherief Elsowiny 3 Jan 30, 2022
Renloi: a decentralized finance network for golang

Intro to Renloi A digital decentralized version of cash will allow extremely fas

null 1 Jun 9, 2022
Terraform-grafana-dashboard - Grafana dashboard Terraform module

terraform-grafana-dashboard terraform-grafana-dashboard for project Requirements

hadenlabs 1 May 2, 2022
Github-workflow-dashboard - WEB and CLI dashboard for github action workflows

CLI capable of retrieving github action workflows stats Example usage Dashboard

Marian Zlatev 2 Feb 17, 2022
a Golang sdk for working with DeFi protocols, and ethereum compatible blockchains

A golang sdk for working with DeFi protocols and general utilities for working with ethereum-compatible blockchains. packages bclient bindings cli con

bonedaddy 65 Jul 30, 2022
Rainbow pfetch-like program written in golang.

rfetch Rainbow pfetch-like program written in golang. It has an kind of lolcat function called random, maybe someday I will rewrite lolcat to golang,

null 0 Jan 30, 2022
Kava - Reference implementation of Kava, a blockchain for cross-chain DeFi. Built using the cosmos-sdk

DeFi for Crypto. Telegram | Medium | Discord Reference implementation of Kava, a

null 0 Apr 4, 2022
BTFS - The First Scalable Decentralized Storage System - A Foundational Platform for Decentralized Applications

go-btfs What is BTFS? BitTorrent File System (BTFS) is a protocol forked from IPFS that utilizes the TRON network and the BitTorrent Ecosystem for int

BitTorrent Inc. 83 Jul 26, 2022
:warning: Deprecrated in favor of https://github.com/piquette/finance-go

go-finance go-finance is a Go library for retrieving financial data for quantitative analysis. Deprecation Warning! This library will no longer be mai

null 537 May 3, 2022
Go-finproto - a collection of finance-related protocols implemented in Golang

go-finproto go-finproto is a collection of finance-related protocols implemented

Mark Winter 6 Jul 25, 2022
An in-memory string-interface{} map with various expiration options for golang

TTLCache - an in-memory cache with expiration TTLCache is a simple key/value cache in golang with the following functions: Expiration of items based o

Rene Kroon 466 Jul 28, 2022
A simple, modern and secure encryption tool (and Go library) with small explicit keys, no config options, and UNIX-style composability.

age age is a simple, modern and secure file encryption tool, format, and library. It features small explicit keys, no config options, and UNIX-style c

Filippo Valsorda 11k Aug 1, 2022
An in-memory string-interface{} map with various expiration options for golang

TTLCache - an in-memory cache with expiration TTLCache is a simple key/value cache in golang with the following functions: Expiration of items based o

Rene Kroon 468 Jul 29, 2022
A simple, modern and secure encryption tool (and Go library) with small explicit keys, no config options, and UNIX-style composability.

A simple, modern and secure encryption tool (and Go library) with small explicit keys, no config options, and UNIX-style composability.

Filippo Valsorda 11k Aug 5, 2022
Examples on different options for implementing Flow Based Programming

Flow Based Programming This repository contains fragments and ideas related to Flow Based Programming. It shows different ways of implementing differe

Egon Elbre 9 Nov 19, 2021
CSPFinder is a tool to compare ROI of selling Cash Secure Put options between different tickers for different expiry dates.

CSPFinder is a tool to compare ROI of selling Cash Secure Put options between different tickers for different expiry dates. It is intended to help open new cash secured put positions.

Sreenidhi Sreesha 26 Dec 21, 2021
entcache - An experimental cache driver for ent with variety of storage options

entcache An experimental cache driver for ent with variety of storage options, such as: A context.Context-based cache. Usually, attached to an HTTP re

ariga 95 Jul 30, 2022
🌍 Package tcplisten provides a customizable TCP net.Listener with various performance-related options

Package tcplisten provides customizable TCP net.Listener with various performance-related options: SO_REUSEPORT. This option allows linear scaling ser

Spiral Scout 0 Jan 15, 2022
ip-masq-agent-v2 aims to solve more specific networking cases, allow for more configuration options, and improve observability compared to the original.

ip-masq-agent-v2 Based on the original ip-masq-agent, v2 aims to solve more specific networking cases, allow for more configuration options, and impro

Microsoft Azure 3 Jun 1, 2022
Wrap byte read options with uniform interface for io.Reader and byte slice

nibbler Nibble chunks from Reader streams and slice in a common way Overview This is a golang module that provides an interface for treating a Reader

null 0 Dec 23, 2021
Envopts - Provides a code generator for turning env structs into functional options

envopts Provides a code generator to turn structs annotated for the popular env

null 3 Jan 10, 2022
This repository holds additional AzBlob TransferManager(s) that provide more robust options than the basic managers that are either a sync

Please ⭐ this project Introduction This repository holds additional AzBlob TransferManager(s) that provide more robust options than the basic managers

John Doak 2 May 26, 2022
Anybool - Useful interface for boolean settings and options

anybool Tricky and fun utilities for Go programs. AnyBool is a small utility wit

Michael Treanor 1 Feb 2, 2022
Tiny Go program to set Elgato Key Light options

Elgato Key Light Controller This is a tiny Go program to control the power, brightness, and temperature settings for Elgato Key Lights with known IP a

Julius Volz 2 Feb 8, 2022
Optinator - Idiomatic way to fill structs with options logic

optinator Go packages are generally start with a main struct and the package ini

Erhan Yakut 13 Mar 15, 2022
A golang implementation of a console-based trading bot for cryptocurrency exchanges

Golang Crypto Trading Bot A golang implementation of a console-based trading bot for cryptocurrency exchanges. Usage Download a release or directly bu

Alessandro Sanino 807 Jul 30, 2022
Kelp is a free and open-source trading bot for the Stellar DEX and 100+ centralized exchanges

Kelp Kelp is a free and open-source trading bot for the Stellar universal marketplace and for centralized exchanges such as Binance, Kraken, CoinbaseP

Stellar 911 Aug 4, 2022
The modern cryptocurrency trading bot written in Go.

bbgo A trading bot framework written in Go. The name bbgo comes from the BB8 bot in the Star Wars movie. aka Buy BitCoin Go! Current Status Features E

Yo-An Lin 649 Jul 30, 2022