PearPear
API IntegrationImportant Terms

Synthetic Position

Pear Protocol constructs synthetic positions on top of raw Hyperliquid positions. Each basket trade gets its own position with independent sizing, entry prices, PnL, and TP/SL, even when the underlying Hyperliquid account holds a single aggregated position per asset.

Synthetic Positions vs Hyperliquid Positions

Hyperliquid tracks one position per asset per account. Pear splits that into baskets.

Example: One Underlying, Three Baskets

TradeLongShortBTC Size
Trade 1BTCETH0.5
Trade 2BTCALT0.3
Trade 3BTCSTOCK0.2

Hyperliquid sees: 1.0 BTC long (single position, no basket concept)

Pear sees: 3 independent positions, each with own entry price, PnL, and TP/SL

Users can track performance per basket, set risk per basket, and close baskets independently.

How Fills Become Positions

After execution on Hyperliquid, each fill is processed against existing open positions: first closing exact-match inverse positions, then any partial matches, then merging into same-structure positions or creating new ones. Entry prices use weighted averages on merge.

Execution Flag (pear_execution_flag)

Every position carries a flag indicating where its fills originated:

FlagMeaning
FULLY_PEARAll fills came from Pear orders
FULLY_EXTERNALAll fills came from outside Pear (direct Hyperliquid trades, other frontends)
PARTIALMix of Pear and external fills touched this position

PnL Discrepancy: Pear vs Hyperliquid

Pear calculates PnL at the basket level. Hyperliquid calculates at the asset level. Different entry price tracking → different displayed PnL until all related positions close.

Pear: each basket maintains its own entry price per asset.

pnl = direction × (exit_price − basket_entry_price) × size − fees

Hyperliquid: global weighted average entry across all trades of same asset. Any close uses this global average.

Example

User opens same asset long in four baskets:

PairEntry Price
ASSET / SHORT-A33.500
ASSET / SHORT-B33.700
ASSET / SHORT-C33.879
ASSET / SHORT-D33.880

Hyperliquid global average entry: 33.74

User closes only ASSET / SHORT-C at 34.298:

Entry UsedPnL per Unit
Pear33.879 (basket-specific)+0.419
Hyperliquid33.74 (global average)+0.558

Neither is wrong, total PnL converges once all positions sharing that asset are fully closed.

On this page