nftperp sdk ✨
![Typescript](https://img.shields.io/badge/TypeScript-007ACC?style=for-the-badge&logo=typescript&logoColor=white)
SDK to interact with the nftperp protocol (docs).
tldr; nftperp is a derivates platform for nfts. for the first time ever, short nfts with leverage
The protocol is currently in BETA on arbitrum mainnet (dapp). it uses fake eth for paper trading, which can be obtained from faucet on website/sdk
![Discord](https://img.shields.io/badge/Discord-5865F2?style=for-the-badge&logo=discord&logoColor=white)
For any queries, hop in the community discord and ask away invite link
Installation
npm i @nftperp/sdk
Also requires ethers
library
npm i ethers
Terminology
asset
the nft collection to trade. synonymous to market pair, amm.direction
direction of trade. long or short.margin
collateral amount. this is the amount you risk on liquidation.notional
total value of position margin x leverage.mark price
nftperp's price of the asset.index price
actual price of the asset. floor from marketplaces.margin ratio
margin to notional ratio.maintenance margin ratio
minimum margin ratio to be maintained to avoid liquidation.
Usage
Setup
import { ethers } from "ethers";
import { SDK } from "@nftperp/sdk";
const provider = new ethers.providers.JsonRpcProvider("<your-rpc-url>");
const wallet = new ethers.Wallet("<your-private-key>", provider);
const nftperp = new SDK(wallet);
Obtaining paper ETH from faucet
await nftperp.useFaucet();
Open a position
const hash = await nftperp.openPosition({
asset: "bayc",
direction: "long",
margin: 0.1,
leverage: 3,
});
note: currently limited nft collections are supported. to get a list of supported assets do:
console.log(nftperp.getSupportedAssets());
Get postion info
const position = await nftperp.getPosition({
asset: "bayc",
});
console.log(position);
Close a position
const hash = await nftperp.closePosition({
asset: "bayc",
});
Get asset info
const assetInfo = await nftperp.getAssetInfo("bayc");
console.log(assetInfo);