Skip to content
This repository has been archived by the owner on Feb 20, 2024. It is now read-only.

Levana-Protocol/perps-tutorial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Tutorial code for Levana Perps

NOTE This repository is not actively maintained. While the code present may be helpful for interacting with Levana Perps, it may be out of date in some places. Please see our docs site for our recommendation resources: https://docs.levana.finance/api-tutorial-ts/introduction.

This code is provided as-is with no warranty, implied or otherwise.

Getting started

  1. Copy env.sample to .env and set your seed phrase
  2. In typescript, run npm install
  3. Edit typescript/src/config.ts to have the correct factory address

Examples

In typescript, run any of the available commands (see them in package.json).

  • open-close-position: deposits liquidity, opens a position, closes the position, withdraws liquidity (unless in cooldown).
  • crank-until-finished: runs the crank until there's no more crank work
  • show-price: shows both the live potential spot price and the last spot price pushed into the contract
  • show-collateral: shows the collateral balance and information about the collateral token
  • show-tvl: shows the collateral balance and information about the collateral token

You must supply a networkId of either sei-testnet or osmosis-testnet, and a marketId for all except show-tvl. NPM syntax requires these after a --

So for example, from in the typescript directory, here's how to run the open-close-position script on Sei testnet and the BTC_USD market:

npm run open-close-position -- --networkId="sei-testnet" --marketId="BTC_USD"

And here's how to do the same thing on Osmosis testnet and the ATOM_USD market:

npm run open-close-position -- --networkId="osmosis-testnet" --marketId="ATOM_USD"

And to calculate TVL for Osmosis mainnet

npm run show-tvl -- --networkId="osmosis-mainnet"

Of course, feel free to modify any of this as needed, the purpose of this repo is educational or to bootstrap your own custom project. Go for it!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published