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

  • 4.1.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

Discord

For any queries, join our discord invite link



Installation

npm i @nftperp/sdk

NOTE: Make sure you have ethers@5 installed. ethers v6, which will create errors when initialising the SDK

npm i ethers@5

Usage

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

/**
the general rpc url for arb mainnet is "https://arb1.arbitrum.io/rpc"
recommended using one from infura/alchemy
*/
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.PAPER_TRADING });
Create a market order
import { Amm, Side } from "@nftperp/sdk/types";

const tx = await nftperp.openMarketOrder({
    amm: Amm.BAYC,
    side: Side.BUY,
    margin: 0.1, // in eth
    leverage: 3,
});

note: to get a list of supported amms do:

console.log(nftperp.getSupportedAmms(Instance.PAPER_TRADING));
/**
[ 'BAYC', 'PUNKS', '...' ]
*/
Create a limit order
import { Side } from "@nftperp/sdk/types";

const tx = await nftperp.openLimitOrder({
    amm: AMM.BAYC,
    side: Side.SELL,
    price: 30,
    margin: 0.1,
    leverage: 1,
});
Get postion
const position = await nftperp.getPosition(Amm.BAYC);
Create a trigger order (Stop loss/Take profit)
import { Side, TriggerType } from "@nftperp/sdk/types";

const hash = await nftperp.openTriggerOrder({
    amm: Amm.BAYC,
    price: 20,
    size: 0.1 // in BAYC
    type: TriggerType.TAKE_PROFIT
});
Close position
const hash = await nftperp.closePosition({
    amm: Amm.BAYC,
});
Calculate open summary
const summary = await nftperp.getOpenSummary({
    amm: Amm.BAYC,
    amount: 1,
    leverage: 1,
    side: Side.BUY,
});
Calculate close summary
const summary = await nftperp.getCloseMarketSummary({ amm: Amm.BAYC });
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>" });
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>" });

Keywords

FAQs

Package last updated on 12 Sep 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