Swivel.js

Javascript library for working with the Swivel Finance Protocol

Installation

Installing ethers.js

To use Swivel.js you'll need to install ethers.js (^5.2.0).

npm install --save ethers

If demand for web3.js support is high, we'll consider supporting it in future releases.

Installing swivel-js

npm install --save @swivel-finance/swivel-js

Quickstart

Swivel.js provides implementations for the 3 main contracts of the Swivel protocol:

  • Swivel (sign orders, initiate/exit/cancel orders, split/combine/redeem tokens)

  • MarketPlace (retrieve token/vault information for a market)

  • VaultTracker (retrieve vault information for a market and owner)

In most cases you'll want to use the Swivel contract implementation to work with orders and tokens.

Usage

Swivel

MarketPlace

VaultTracker

Deployed Contract Addresses

To connect a Swivel or MarketPlace instance to the deployed contract on the Ethereum network, you'll need to know the contract address. You can find the currently deployed addresses here: https://github.com/Swivel-Finance/swivel#current-deployments

Other Providers

You can use ethers.js to connect to the Ethereum network in different ways, not only using MetaMask. Please refer to the ethers.js documentation for different ways to connect: https://docs.ethers.io/v5/getting-started/#getting-started--connecting.

Once you have created a provider and a signer, creating a Swivel, MarketPlace or VaultTracker instance is identical to the steps illustrated above.

Last updated