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

  • 3.11.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
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

Discord

For any queries, hop in the community discord and ask away invite link



Installation

npm i @nftperp/sdk

Also requires ethers library
NOTE: ethers v6 introduced a lot of breaking changes and is unsupported yet. please install v5 as below

npm i ethers@5

Usage

Setup
import { ethers } from "ethers";
import { SDK } from "@nftperp/sdk";

/**
the general rpc url for arb mainnet is "https://arb1.arbitrum.io/rpc"
recommended using one from infura/alchemy

sdk is open source, `wallet` is safe to connect :wink:
*/
const provider = new ethers.providers.JsonRpcProvider("<your-rpc-url>");
const wallet = new ethers.Wallet("<your-private-key>", provider);
const nftperp = new SDK({ wallet });
Open a position
import { Amm, Side } from "@nftperp/sdk/types";

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

note: to get a list of supported amms do:

console.log(nftperp.getSupportedAmms(Instance.BETA));
/**
[ 'BAYC', 'PUNKS', '...' ]
*/
Get postion
const position = await nftperp.getPosition(Amm.BAYC);
Close position
const hash = await nftperp.closePosition({
    amm: Amm.BAYC,
});
Pre calculate fee on trade
const feeInfo = await nftperp.calcFee({
    amm: Amm.BAYC,
    amount: 1,
    leverage: 1,
    side: Side.BUY,
    open: true, // true for opening pos, false for closing
});
Pre calculate open position summary (including ee)
const txSummary = await nftperp.getOpenPosTxSummary({
    amm: Amm.BAYC,
    amount: 1,
    leverage: 1,
    side: Side.BUY,
});
Pre calculate close position transaction summary (including fee)
const txSummary = await nftperp.getClosePosTxSummary({
    amm: Amm.BAYC,
    closePercent: 100,
});
Get mark price
const markPrice = await nftperp.getMarkPrice(Amm.BAYC);
Get index price
const indexPrice = await nftperp.getIndexPrice(Amm.BAYC);
Get funding info
const fundingInfo = await nftperp.getFundingInfo(Amm.BAYC);
Get historical trades
await nftperp.getTrades({ amm: Amm.BAYC, trader: "<trader-address>" });
await nftperp.getTrades({ from: 1680307200, to: 1682899200, sort: Sort.ASC });
await nftperp.getTrades({ hash: "<transaction-hash>" });

note: this method is paginated, so use page to loop through!

Get historical fundings
await nftperp.getFundings({ amm: Amm.BAYC });
await nftperp.getFundings({ from: 1680307200, to: 1682899200, sort: Sort.ASC });
await nftperp.getFundings({ hash: "<transaction-hash>" });

note: this method is paginated, so use page to loop through!

Streamer

Stream realtime events! directly consume parsed event data!

import { EVENT } from "@nftperp/sdk/types";

nftperp.on(EVENT.TRADE, (trade) => {});
nftperp.on(EVENT.FUNDING, (funding) => {});

Keywords

FAQs

Package last updated on 02 Jul 2023

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