🍒Quick Start

A short introduction to use Volare programmatically.

We are in Fuji Testnet. Volare is now in early beta; we have already deployed contracts and services on Avalance's Fuji Testnet. To know more about the testnet, click here.

Structure

The Volare can be split into two different major modules. Option and Exchange. API works like a pipe of information for interaction with the blockchain, while achieving key features that the blockchain finds hard to achieve.

Option

Option carrying the major logic behind options trading. Like short, settle, and redeem are all achieved in Option Module. The minted option itself is a Token, compatible with the ERC20 protocol, its name is VToken.

While interacting with the option module, Vanilla class is needed. And we already have friendly for those actions in our library. The details are documented in Option Page.

Exchange

Exchange modules is the main thing behind our order book mechanism. We are using mtx technology to implement order book on blockchain.

The action Buy/Sell itself is the exchange between a certain kind of currecy and option token (aka VToken). The method to put limit order is simple in our product. Just use wallet to sign a piece of data, then post it to our aggregation service. Then the aggregation engine will do the rest of the work.

Because VToken is only an ordinary ERC20 token, so theoretically, it can be traded on any DEX supports ERC20. But order book is only available in our exchange module. More information about exchange is documented in Exchange Page.

APIs

Theoretically, API is not required for achieving transactions. The informations have already stored in blockchain. But it is really hard to index informations from blockchain. So we provide a series of useful APIs for you to know more about the product, the options, the positions, and more.

Many APIs have used in the examples provided in Option and Exchange Page. You can use APIs through direct HTTP requests or using our library. More details of APIs are documented in APIs Page.

Pre-requisites

You can either call the contract directly or use our library. In this quick start guide, we will demonstrate with our library. Javascript/Typescript is used in the demonstration.

First, create a Node.js program with npm init , then add the packages we need as follows:

npm install @volare.defi/utils.js
npm install @volare.defi/volare.js

adding@ethersproject/providers for type annotation is also recommended.

Initialization

The following code snippets show how to do initialization before using the API module of our library. This part should be either globally declared or imported.

import { ChainId } from "@volare.defi/utils.js"

// The network endpoint of Fuji Testnet
const ETH_ENDPOINT = "https://api.avax-test.network/ext/bc/C/rpc"
// The API endpoint of Volare
const API_ENDPOINT = "https://fuji.api.volare.lol"

// This object contains addresses from specfic chain
const addresses = getContractAddressesForChain(ChainId.Fuji);

// Initialize API configuration for easy data fetch
const apis = new Apis({
  config: { DECIMAL_PLACES: 2 },
  url: API_ENDPOINT,
  chainId: ChainId.Fuji,
  endpoint: ETH_ENDPOINT,
  addresses: addresses
});

// Initialize the Vanilla class
const vanilla = new Vanilla({
  chainId: ChainId.Fuji,
  endpoint: ETH_ENDPOINT,
  addresses,
});

Wallet Configuration

Our SDK use wallet/signer from Ethers.js to interacte with blockchain on your behalf. The wallet setup on Node.js and Browser environment can be different. Here's a minimal example of how to set up wallet from both Node.js and Browser.

import { Wallet } from 'ethers'

const wallet = new Wallet(process.env.PRIVATE_KEY);

// wallet can be passed to methods when needed to call smart contracts

Last updated