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.
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.
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 [email protected] 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
- Clone this repo
- Populate .env file (local runtime) or specify env. variables on the remote host (server) to be readable from the container
- 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 [email protected] if you have questions about cloud deployment.
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.
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:
- Copy and paste the openAPi.yaml here
- File -> Download resolved yaml
- Upload yaml file to gitbook
- Log in to Premia Docker Hub
- Build new image from root directory and include updated version:
docker build -t premiaresearch/orderbook-api:version . --platform=linux/amd64
Always updatepackage.json
version to be the same as Docker image version. - Push image to Docker Hub:
docker push premiaresearch/orderbook-api:version