
Research
/Security News
9 Malicious NuGet Packages Deliver Time-Delayed Destructive Payloads
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.
@perp/v2-sdk
Advanced tools
An SDK for Perpetual Protocol V2
Install the lib
yarn add @perp/v2-sdk
Commit:
Use commitlint and commitizen to regulate commit message.
git ci
Test:
yarn test
Market
indexPrice, markPrice, tradingVolume24h, fundingRatePool
TVL, APRWalletDepositHistoryWithdrawHistoryVault
deposit, withdrawaccountBalance, totalPnlClearingHouse
PositionPositionDraftPositionHistoryFundingPaymentHistory
const perp = new PerpetualProtocol({
chainId: 10,
providerConfigs: [ { rpcUrl: "https://mainnet.optimism.io"}] })
await perp.init()
For example:
Open a Long position using quoteToken.
baseToken: ETH
quoteToken: USD
const perp = new PerpetualProtocol({
chainId: 10,
providerConfigs: [ { rpcUrl: "https://mainnet.optimism.io"}] })
await perp.init()
await perp.connect({ signer })
const tickerSymbol = "ETHUSD"
const slippage = new Big(0.02) // remember to transformed to Big type
const amountInput = new Big(100) // remember to transformed to Big type
const side = PositionSide.LONG
const isAmountInputBase = false // we are not using base token to open a long position here.
const newPositionDraft = perp.clearingHouse.createPositionDraft({
tickerSymbol,
side,
amountInput,
isAmountInputBase,
})
perp.clearingHouse.openPosition(positionDraft, slippage)
const tickerSymbol = "ETHUSD"
const position = await perp.positions.getTakerPositionByTickerSymbol(tickerSymbol)
perp.clearingHouse.closePosition(position, slippage)
For example:
Use quoteToken to add liquidity.
baseToken: ETH
quoteToken: USD
const perpParam = {
chainId: 10,
providerConfigs: [ { rpcUrl: "https://mainnet.optimism.io"}]
}
const perp = new PerpetualProtocol(perpParam)
await perp.init()
await perp.connect({ signer })
const tickerSymbol = "ETHUSD"
const market = perp.markets.getMarket({ tickerSymbol })
const lowerTick = perp.market.getPriceToTick(lowerTickPrice)
const upperTick = perp.market.getPriceToTick(upperTickPrice)
const slippage = new Big(0.02) // remember to transformed to Big type
const rawBaseAmount = undefined
const rawQuoteAmount = new Big(100) // remember to transformed to Big type
const liquidityDraft = perp.clearingHouse.createLiquidityDraft({
tickerSymbol,
rawBaseAmount,
rawQuoteAmount,
upperTick,
lowerTick,
})
perp.clearingHouse.addLiquidity(liquidityDraft, slippage)
ratio means how much ratio you would like to remove. 1 means 100%filterFn to filter out liquidity you would like to remove.
const ratio = new Big(1) // remember to transformed to Big type
const slippage = new Big(0.02) // remember to transformed to Big type
const liquidity = perp.liquidities.getTotalLiquidities().filter(filterFn)
perp.clearingHouse.removeLiquidity(liquidity, ratio, slippage)
FAQs
An SDK for Perpetual Protocol V2
The npm package @perp/v2-sdk receives a total of 1 weekly downloads. As such, @perp/v2-sdk popularity was classified as not popular.
We found that @perp/v2-sdk demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 7 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.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.