
Research
/Security News
jscrambler npm Package Compromised in Supply Chain Attack
A compromised jscrambler npm release added a malicious preinstall hook that runs hidden native binaries on Linux, macOS, and Windows.
@pear-protocol/exchanges-sdk
Advanced tools
Unified SDK for connecting to cryptocurrency derivative exchanges. Provides real-time account state tracking including balances, positions, and leverage management through a single, exchange-agnostic interface.
| Exchange | Connector Name | Market Type |
|---|---|---|
| Binance | binanceusdm | USDM Futures |
| Bybit | bybit | Linear Perpetuals |
| Hyperliquid | hyperliquid | Perpetuals |
{
"dependencies": {
"@backend/exchanges-sdk": "workspace:*"
}
}
Requires @pear-protocol/core-sdk and @backend/shared as peer dependencies.
import PearSDK from '@pear-protocol/core-sdk';
import { ExchangesSDK } from '@backend/exchanges-sdk';
const sdk = new PearSDK({ /* ... */ });
const exchanges = new ExchangesSDK({ sdk });
await exchanges.account.connect(tradeAccountId, 'binanceusdm');
const balanceTracker = exchanges.account.trackBalance((balance) => {
console.log(balance.totalEquity);
});
const positionsTracker = exchanges.account.trackPositions((positions) => {
for (const pos of positions) {
console.log(pos.symbol, pos.side, pos.size);
}
});
// Cleanup
balanceTracker.untrack();
positionsTracker.untrack();
exchanges.destroy();
// Production
const exchanges = new ExchangesSDK({ sdk });
// Testnet / demo
const exchanges = new ExchangesSDK({ sdk, demo: true });
Credentials are fetched automatically from the backend when you call connect.
await exchanges.account.connect(tradeAccountId, 'binanceusdm');
await exchanges.account.connect(tradeAccountId, 'bybit');
await exchanges.account.connect(tradeAccountId, 'hyperliquid');
Check connection status:
exchanges.account.isConnected; // WebSocket is active
exchanges.account.isInitialized; // First state snapshot received
Subscribe to real-time balance updates. The callback fires on every balance change.
const tracker = exchanges.account.trackBalance((balance) => {
balance.totalEquity; // total account equity
balance.walletBalance; // wallet balance excluding unrealized PnL
balance.unrealizedPnl; // total unrealized PnL
balance.availableToTrade; // available margin for new trades
balance.marginRatio; // current margin ratio
// Per-asset breakdown
for (const asset of balance.assets) {
asset.asset; // "USDT", "BTC", etc.
asset.free; // available amount
asset.used; // amount in use
asset.total; // total amount
asset.walletBalance; // wallet balance
asset.usdValue; // USD equivalent
}
});
// Read the latest value without waiting for a callback
const current = tracker.get();
// Stop receiving updates
tracker.untrack();
Subscribe to real-time position updates. The callback fires with the full list of open positions on every change.
const tracker = exchanges.account.trackPositions((positions) => {
for (const pos of positions) {
pos.symbol; // "BTCUSDT"
pos.side; // "long" | "short" | "both"
pos.size; // "0.5"
pos.entryPrice; // "65000.00"
pos.unrealizedPnl; // "120.50"
pos.leverage; // "10"
pos.marginType; // "cross" | "isolated"
pos.liquidationPrice; // "58000.00" or null
}
});
const current = tracker.get();
tracker.untrack();
Retrieve leverage, margin type, and trade size constraints for a specific coin. Useful when preparing to place a trade.
const tracker = exchanges.account.trackAsset('ETH', (info) => {
info.coin; // "ETH"
info.leverage; // "20"
info.marginType; // "cross" | "isolated"
});
const current = tracker.get();
tracker.untrack();
await exchanges.account.setLeverage('BTCUSDT', '10');
// Read cached leverage (returns null if not yet fetched)
const leverage = exchanges.account.getLeverage('BTCUSDT');
Access a read-only snapshot of the complete account state at any time.
const state = exchanges.account.getState();
if (state) {
state.balance; // latest balance or null
state.positions; // Map of all open positions
state.leverageSettings; // Map of symbol to leverage
state.trackedAssets; // Map of coin to asset info
state.lastUpdated; // timestamp of last update
state.initialized; // true after first snapshot
}
// Disconnect but keep credentials cached for reconnection
exchanges.account.disconnect();
// Full teardown: disconnect and clear all credentials
exchanges.destroy();
disconnect() or destroy() calls.FAQs
Pear Protocol Exchanges SDK
The npm package @pear-protocol/exchanges-sdk receives a total of 460 weekly downloads. As such, @pear-protocol/exchanges-sdk popularity was classified as not popular.
We found that @pear-protocol/exchanges-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 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
A compromised jscrambler npm release added a malicious preinstall hook that runs hidden native binaries on Linux, macOS, and Windows.

Research
/Security News
A malicious .NET package is typosquatting the Braintree SDK to steal live payment card data, merchant API keys, and host secrets from production apps.

Security News
/Research
Compromised Injective SDK npm version 1.20.21 exfiltrates wallet private keys and mnemonics through fake telemetry functionality.