Skip to content

Premian-Labs/orderbook-api

Repository files navigation

logo

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 permissionless use of financial primitives.

Premia Containerized API

This repo contains the source code for a Docker-containerized API to interact with the Premia v3 Orderbook and related protocol functionality for both professionals (market makers) and other advanced/programmatic users. The containerized API allows for development in any language. Web3 functionality is abstracted away from the developer, shortening integration time.

Prerequisites

There are several things that are needed in order to work with the API locally. They include:

  • An EOA (Externally Owned Account) on the Ethereum (funded on Arbitrum) with a wallet provider such as Metamask
  • An API Key from Premia (please email research@premia.finance and use subject line 'API KEY REQUEST')
  • Latest version of Docker
  • 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.

Example of required env. variables to be specified by API user: .env.example

Architecture

architecture

Start Guide

  1. Clone this repo
  2. Populate .env file (local runtime) or specify env. variables on the remote host (server) to be readable from the container
  3. The container will only allow for trading in tokens within the token list inside arbitrum.json and arbitrumGoerli.json. Please add/remove tokens (if necessary) to restrict/provide access to certain markets.

Local runtime

  • We recommend using Docker Compose to run the container on a local host.
  • Open a terminal, and from the repo root directory,run the following command in your terminal docker-compose up to build and run the container.
  • The API should be accessible with the following url http//:localhost:3000.
  • Since docker-compose up requires a dedicated session in the terminal. This will allow you to view container logs during runtime. Open a new terminal session for development work.
  • To stop the container run docker-compose down.

Remote runtime

  • For remote runtime, users can access the docker image directly here
  • Please email research@premia.finance if you have questions about cloud deployment.

OpenAPI Specification

Premia provides the readable OpenAPI specification for the Containerized API on its website here. The source code for the OpenAPI specification can be found in this repository.

Development Team Only

OpenAPI -> Gitbook

Nested reference of schemas do not translate to gitbook correctly, so the openAPI.yaml file must be modified prior to uploading. Steps are as follows:

  1. Copy and paste the openAPi.yamle here
  2. File -> Download resolved yaml
  3. Upload yaml file to gitbook

Docker Image Updates

  1. Log in to Premia Docker Hub
  2. Build new image from root directory and include updated version: docker build -t premiaresearch/orderbook-api:version . --platform=linux/amd64 Always update package.json version to be the same as Docker image version.
  3. Push image to Docker Hub: docker push premiaresearch/orderbook-api:version

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages