SDK Quick Start
Start Here
The full SDK is free to use and open-source, currently available in the following languages:
- Typescript / Javascript
💡 The full SDK can be used trustlessly to execute any action or query any data from the protocol.
The Premia v3 SDK is meant to be an all-in-one solution, just instantiate the Premia object and you will have access to the following:
- analytics, query analytics information from the subgraph
- contracts, find access to the Contract types for each of Premia's main contracts.
- options, an aggregator for different sources of liquidity.
- orders, provide and fill quotes through the orderbook (requires an API key).
- pools, interact with all functionalities related to the option pools.
- pricing, compare prices of different quotes
- tokens, query information about tokens in relation to the pools from the subgraph
- pairs, query information about token pairs in relation to the pools from the subgraph
- transactions, query information about generic/vault transactions made on the protocol via the subgraph
- users, query user information via the subgraph
- vaults, interact with all functionalities related to the vaults.
- vxPremia, interact with all functionalities related to the vxPremia such as vault votes, user stakes, stake histories, and voting histories.
Walkthrough
// Javascript Sample Code
const { WebSocket } = require('ws')
const wsUrl = 'test.quotes.premia.finance'
const MOCK_API_KEY = '3423ee2bfd89491f82b351404ea8c3b7'
const authMessage = {
type: "AUTH",
apiKey: MOCK_API_KEY,
body: null
}
const ws = new WebSocket(`wss://${wsUrl}`)
function connectWebsocket() {
ws.onopen = (event) => {
console.log("Websocket connection open")
ws.send(JSON.stringify(authMessage))
ws.onmessage = (event) => {
console.log(JSON.parse(event.data).message)
ws.close()
}
}
}
connectWebsocket()The end-points
| Chain | Base Url |
|---|---|
| Arbitrum Goerli (421613) | https://test.orderbook.premia.finance |
| Arbitrum One (42161) | https://orderbook.premia.finance |
Extensive API Reference
The documentation at docs-sdk.premia.finance provides detailed information about the Premia V3 SDK, an Alpha software used in the Premia Interface. Here's a summary of the key sections:
Alpha Software Warning: The SDK is considered Alpha software and may contain bugs or significant changes between patch versions.- Development Setup: Instructions for setting up the development environment, including setting NPM auth tokens, API keys, and running necessary commands.
- Anvil Setup: Guidelines for using Anvil as a local blockchain for development purposes, including installation instructions.
- Forking Arbitrum Goerli: Steps to fork Georli for development, including specific terminal commands.
- Contract Deployments: A list of contract deployment dates on Goerli and Arbitrum Goerli networks.
- SDK Documentation: In-depth documentation on the SDK, including details about various factory functions, structures, queries, and more related to ERC20, IERC1155, IPool, IVault, and other blockchain components.
- Utilities and Helpers: Information about various utilities, formatting functions, and helpers used within the SDK.