Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@nftperp/sdk

Package Overview
Dependencies
Maintainers
2
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nftperp/sdk

SDK for nftperp protocol

  • 2.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
202
decreased by-12.55%
Maintainers
2
Weekly downloads
 
Created
Source

nftperp sdk ✨

Typescript

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

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

  • amm the nft collection to trade. synonymous to market pair, asset.
  • side 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, Instance } from "@nftperp/sdk";

/**
the general rpc url for arb mainnet is "https://arb1.arbitrum.io/rpc"
you can also use a personal one from alchemy (https://www.alchemy.com/)
*/
const provider = new ethers.providers.JsonRpcProvider("<your-rpc-url>");
const wallet = new ethers.Wallet("<your-private-key>", provider);
const nftperp = new SDK({ wallet, instance: Instance.BETA });
Obtaining paper ETH from faucet
await nftperp.useFaucet(); // grants 5 eth
Open a position
import { Amm, Side } from "@nftperp/sdk";

const hash = await nftperp.openPosition({
    amm: Amm.BAYC,
    side: Side.BUY,
    margin: 0.1, // this means 0.1 eth
    leverage: 3,
});

note: currently limited nft collections are supported. to get a list of supported assets do:

console.log(nftperp.getSupportedAssets(Instance.BETA));
/**
[ 'BAYC', 'MOONBIRDS', 'MAYC', 'DOODLES', 'CLONEX' ]
*/
Get postion info
const position = await nftperp.getPosition({
    amm: Amm.BAYC,
});
console.log(position);
/**
{
  size: 0.003,
  margin: 0.1,
  leverage: 3,
  pnl: 0,
  funding: 0,
  entryPrice: 82.981,
  liquidationPrice: 63.224
}
*/
Close a position
const hash = await nftperp.closePosition({
    amm: Amm.BAYC,
});
Get asset info
const ammInfo = await nftperp.getAmmInfo(Amm.BAYC);
console.log(ammInfo);
/**
{
  asset: 'BAYC',
  markPrice: 82.795,
  indexPrice: 84,
  maxLeverage: 5,
  maintenanceMarginPercent: 12.5,
  fullLiquidationPercent: 10,
  previousFundingPercent: -0.662,
  nextFundingTime: 1660194024,
  openInterest: 3583.484,
  openInterestLongs: 2581.935,
  openInterestShorts: 1001.548
}
*/

Keywords

FAQs

Package last updated on 15 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc