8.1.0 • Published 2 months ago

@nftperp/sdk v8.1.0

Weekly downloads
-
License
ISC
Repository
github
Last release
2 months ago

nftperp sdk ✨

Typescript

SDK to interact with the nftperp protocol

Discord

For any queries, join our discord invite link



Installation

npm i @nftperp/sdk

Usage

Setup

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

const nftperp = new SDK({ rpcUrl, privateKey }); // ready to make trades ¬‿¬"
const nftperp = new SDK(); // for read-only mode, uses general rpc

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,
});

Create a limit order

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

await nftperp.openLimitOrder({
    amm: AMM.BAYC,
    side: Side.SELL,
    price: 30,
    margin: 0.1,
    leverage: 1,
});

Get postion

await nftperp.getPosition(Amm.BAYC);

Create a trigger order (Stop loss/Take profit)

await nftperp.openTriggerOrder({
    amm: Amm.BAYC,
    price: 20,
    size: 0.1 // in BAYC
    type: TriggerType.TAKE_PROFIT
});

Close position

await nftperp.closePosition({ amm: Amm.BAYC });

Calculate open summary

summary of entry price, price impact, fees etc to be implied on opening a position

await nftperp.getOpenSummary({
    amm: Amm.BAYC,
    amount: 1,
    leverage: 1,
    side: Side.BUY,
});

Calculate close summary

summary of exit price, price impact, fees etc to be implied on closing a position

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 rate

const fundingRate = await nftperp.getFundingRate(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>" });
8.1.0

2 months ago

8.0.0

2 months ago

7.1.2

3 months ago

7.1.1

3 months ago

7.1.0

3 months ago

7.0.0

4 months ago

6.0.1

4 months ago

6.0.0

4 months ago

6.0.2

4 months ago

5.3.0

4 months ago

5.2.0

4 months ago

5.1.0

4 months ago

5.0.0

4 months ago

3.11.0

11 months ago

3.11.1

11 months ago

4.1.0

8 months ago

4.0.0

8 months ago

4.3.0

6 months ago

4.1.2

8 months ago

4.2.0

6 months ago

4.1.1

8 months ago

3.9.3

1 year ago

3.9.2

1 year ago

3.9.1

1 year ago

3.9.0

1 year ago

3.10.0

1 year ago

3.7.2

1 year ago

3.8.0

1 year ago

3.7.1

1 year ago

3.4.0

1 year ago

3.7.0

1 year ago

3.6.0

1 year ago

3.5.1

1 year ago

3.5.0

1 year ago

3.3.0

1 year ago

3.2.0

1 year ago

3.1.1

1 year ago

3.1.0

2 years ago

3.0.1

2 years ago

3.0.0

2 years ago

2.0.5

2 years ago

2.0.6

2 years ago

2.0.4

2 years ago

2.0.3

2 years ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago