Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
@nftperp/sdk
Advanced tools
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
For any queries, hop in the community discord and ask away invite link
npm i @nftperp/sdk
Also requires ethers
library
NOTE: If npm i ethers
is used, it will default to installing ethers v6
, which will create errors when initialising the SDK
npm i ethers@5
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.TRADING_COMP });
If an error of the following occurs: SyntaxError: Cannot use import statement outside a module
, add in the following to your package.json
file
"type": "module"
If an error of the following occurs: Directory import '..\@nftperp\sdk\types' is not supported resolving ES modules
, do the following:
// REPLACE
import { Instance } from "@nftperp/sdk/types";
// WITH
import { Instance } from "@nftperp/sdk/types/index.js";
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', '...' ]
*/
const position = await nftperp.getPosition(Amm.BAYC);
const hash = await nftperp.closePosition({
amm: Amm.BAYC,
});
const feeInfo = await nftperp.calcFee({
amm: Amm.BAYC,
amount: 1,
leverage: 1,
side: Side.BUY,
open: true, // true for opening pos, false for closing
});
const txSummary = await nftperp.getOpenPosTxSummary({
amm: Amm.BAYC,
amount: 1,
leverage: 1,
side: Side.BUY,
});
const txSummary = await nftperp.getClosePosTxSummary({
amm: Amm.BAYC,
closePercent: 100,
});
const markPrice = await nftperp.getMarkPrice(Amm.BAYC);
const indexPrice = await nftperp.getIndexPrice(Amm.BAYC);
const fundingInfo = await nftperp.getFundingInfo(Amm.BAYC);
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>" });
/**
{
"page": 1,
"pageSize": 100,
"totalPages": 838,
"totalCount": 83705,
"result": [
{
"trader": ...,
"amm": ...,
"margin": ...,
"exchangedPositionNotional": ...,
"exchangedPositionSize": ...,
"fee": ...,
...
},
...
]
}
*/
note: this method is paginated, so use page
to loop through!
await nftperp.getFundings({ amm: Amm.BAYC });
await nftperp.getFundings({ from: 1680307200, to: 1682899200, sort: Sort.ASC });
await nftperp.getFundings({ hash: "<transaction-hash>" });
/**
{
"page": 1,
"pageSize": 100,
"totalPages": 838,
"totalCount": 83705,
"result": [
{
"amm": ...,
"markPrice": ...,
"indexPrice": ...,
"fundingRateLong": ...,
"fundingRateShort": ...,
...
},
...
]
}
*/
note: this method is paginated, so use page
to loop through!
Stream realtime events! directly consume parsed event data!
import { EVENT } from "@nftperp/sdk/types";
nftperp.on(EVENT.TRADE, (data) => console.log(data));
/**
{
"trader": ...,
"amm": ...,
"margin": ...,
"exchangedPositionNotional": ...,
"exchangedPositionSize": ...,
"fee": ...,
...
}
*/
nftperp.on(EVENT.FUNDING, (data) => console.log(data));
/**
{
"amm": ...,
"markPrice": ...,
"indexPrice": ...,
"fundingRateLong": ...,
"fundingRateShort": ...,
...
}
*/
FAQs
SDK for nftperp protocol
The npm package @nftperp/sdk receives a total of 177 weekly downloads. As such, @nftperp/sdk popularity was classified as not popular.
We found that @nftperp/sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.