Previews
Open and close previews
Preview a close
/previews/closeRequest body (required)
PreviewCloseRequest · application/jsonacceptableExitWadstring | nullFormat-checked only; the fill ignores it.
Pattern^-?(0|[1-9][0-9]*)n$Example74250000000000000000nnowMsstring | nullUnix ms the hold checks are judged at (the service defaults to its clock).
Pattern^-?(0|[1-9][0-9]*)n$Example1796677200000npositionIdstringrequiredPattern^-?(0|[1-9][0-9]*)n$Example1042nslippageBpsstring | null0..=10000; with it the preview returns
suggested_bound_wad.Pattern^-?(0|[1-9][0-9]*)n$Example50ntopUpstring | nullOwner top-up added to the free balance (base units).
Pattern^-?(0|[1-9][0-9]*)n$Example100000000n
Responses
Close preview, as public camelCase JSON. fillWad/exitWad are the oracle mid; oneStepWad (n-suffixed decimal or null) is the one-step exit price emergency close and close_retired pay (the mid moved by the one-step spread against the position); oneStepSpreadBps and emergencyAfterMs (a delay; the contract bounds it to 5000..=60000 ms, default 15000, so emergency close is never disabled) are n-suffixed decimal strings like every integer ("5000000n"; fillWindowMs/cancelDelayMs/signedWindowMs included; pnl includes builderFee and builderFeeBps). liquidationPaused (bool or null) is true only under the market's oracle kill switch (liquidate aborts trade::EOracleKilled 20 then; no pause stops liquidation), null for an unindexed market. errors includes price_unavailable when the storage price has not been read.
application/json
dataPreviewCloserequiredWith the market's two-step order params (or the defaults). Without a live price the price fields,
pnl,liquidatableandmax_fee_bpsare null, andspread_source,indicativeandconf_wadare absent (one_step_spread_bpstoo while the market is unindexed).cancelDelayMsstringrequiredMilliseconds.
Pattern^-?(0|[1-9][0-9]*)n$Example30000nconfWadstring | nullScaled by 1e18 (WAD).
Pattern^-?(0|[1-9][0-9]*)n$Example30000000000000000nemergencyAfterMsstringrequiredThe emergency close delay in ms (5000 to 60000 on chain).
Pattern^-?(0|[1-9][0-9]*)n$Example15000nerrorsstring[]requiredReasons the close would fail; empty when it would go through.
execFeestringrequiredCollateral base units escrowed with the request.
Pattern^-?(0|[1-9][0-9]*)n$Example800000nexitWadstring | nullThe two-step exit: the plain mid (WAD).
Pattern^-?(0|[1-9][0-9]*)n$Example74250000000000000000nfeeOwedstring | nullPattern^-?(0|[1-9][0-9]*)n$Example800000nfillWadstring | nullSame as
exit_wad.Pattern^-?(0|[1-9][0-9]*)n$Example74250000000000000000nfillWindowMsstringrequiredMilliseconds.
Pattern^-?(0|[1-9][0-9]*)n$Example60000nindicativeboolean | nullliquidatableboolean | nullliquidationPausedboolean | nullWhether the market's oracle kill switch stops liquidation; null while unindexed.
maxFeeBpsstring | nullThe effective taker fee snapshot; null without a live price.
Pattern^-?(0|[1-9][0-9]*)n$Example8noneStepSpreadBpsstring | nullBasis points (1/10000).
Pattern^-?(0|[1-9][0-9]*)n$Example5noneStepWadstring | nullThe one-step exit price emergency close and close_retired pay: the mid moved by the one-step spread against the position (down for a long, up for a short).
Pattern^-?(0|[1-9][0-9]*)n$Example74250000000000000000npnlnull | ClosePnlpositionIdstringrequiredPattern^-?(0|[1-9][0-9]*)n$Example1042nsignedWindowMsstringrequiredMilliseconds.
Pattern^-?(0|[1-9][0-9]*)n$Example60000nspreadSourcenull | stringsuggestedAcceptablePriceWadstring | nullThe mid 0.5% against the trader; null without a live mid.
Pattern^-?(0|[1-9][0-9]*)n$Example74250000000000000000nsuggestedBoundWadstring | nullexit_wadmovedslippage_bpsagainst the trader; null withoutslippage_bps.Pattern^-?(0|[1-9][0-9]*)n$Example74250000000000000000n
Example request
curl -X POST 'https://api.parchment.trade/previews/close' \
-H 'Content-Type: application/json' \
-d '{
"acceptableExitWad": "74250000000000000000n",
"nowMs": "1796677200000n",
"positionId": "1042n",
"slippageBps": "50n",
"topUp": "100000000n"
}'const res = await fetch("https://api.parchment.trade/previews/close", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"acceptableExitWad": "74250000000000000000n",
"nowMs": "1796677200000n",
"positionId": "1042n",
"slippageBps": "50n",
"topUp": "100000000n"
}),
});
const { data } = await res.json();Example response (200)
{
"data": {
"cancelDelayMs": "30000n",
"confWad": "30000000000000000n",
"emergencyAfterMs": "15000n",
"errors": [],
"execFee": "800000n",
"exitWad": "74250000000000000000n",
"feeOwed": "800000n",
"fillWad": "74250000000000000000n",
"fillWindowMs": "60000n",
"indicative": true,
"liquidatable": true,
"liquidationPaused": true,
"maxFeeBps": "8n",
"oneStepSpreadBps": "5n",
"oneStepWad": "74250000000000000000n",
"pnl": {
"adjusted": "42500000n",
"builderFee": "800000n",
"builderFeeBps": "8n",
"closeToll": "800000n",
"closeTollFromMargin": "100000000n",
"closeTollFromProfit": "100000000n",
"feesCollectedNow": "1850000000000n",
"loss": "100000000n",
"marginReturned": "100000000n",
"net": "100000000n",
"paidNow": true,
"payout": "100000000n",
"payoutBeforeRefund": "100000000n",
"queued": true,
"raw": "42500000n",
"refereeRefund": "800000n",
"trimCPpm": "1000n",
"trimMaxShareBps": "2000n",
"trimmed": "42500000n",
"userProfit": "42500000n",
"winFee": "800000n"
},
"positionId": "1042n",
"signedWindowMs": "60000n",
"spreadSource": "floor",
"suggestedAcceptablePriceWad": "74250000000000000000n",
"suggestedBoundWad": "74250000000000000000n"
}
}Preview an open
/previews/openRequest body (required)
PreviewOpenRequest · application/jsonacceptableEntryWadstring | nullFormat-checked only; the fill ignores it.
Pattern^-?(0|[1-9][0-9]*)n$Example74250000000000000000naccountIdstring | nullWith it, the account's free balance, notional cap and referee discount are checked.
Example0xad23e722f3542ae36c276c1b303e30ae77c840a84db89c7215fa87bf92006691isLongboolean | nullThe service defaults to
true(long).leveragestringrequiredPattern^-?(0|[1-9][0-9]*)n$Example10nmarginstringrequiredCollateral base units, fee included.
Pattern^-?(0|[1-9][0-9]*)n$Example100000000nmarketIdstringrequiredExample0x6e6238eb4f69bfcc3e884a7d20904eb0995ca2e42c95dc8560d5a417486ab645minFactorBpsstring | nullBasis points (1/10000).
Pattern^-?(0|[1-9][0-9]*)n$Example10000nslippageBpsstring | null0..=10000; with it the preview returns
suggested_bound_wad.Pattern^-?(0|[1-9][0-9]*)n$Example50ntopUpstring | nullOwner top-up added to the free balance (base units).
Pattern^-?(0|[1-9][0-9]*)n$Example100000000n
Responses
Open preview, as public camelCase JSON. fillWad/entryWad are the oracle mid (the two-step fill price); oneStepWad (n-suffixed decimal or null) is the one-step reference price (the mid moved by the one-step spread against the trader); every integer (WADs, oneStepSpreadBps, fillWindowMs, cancelDelayMs, signedWindowMs, ...) is an n-suffixed decimal string ("5000000n"). errors includes price_unavailable when the storage price has not been read. spreadSource stays floor.
application/json
dataPreviewOpenrequiredWith the market's two-step order params (or the defaults). A preview stopped at its first invalid input (margin, leverage, sizing) has every sizing and price field and
max_fee_bpsnull, and noindicative,conf_wad,taker_fee_bpsnormin_payout_factor_bps.bustWadstring | nullScaled by 1e18 (WAD).
Pattern^-?(0|[1-9][0-9]*)n$Example67550000000000000000ncancelDelayMsstringrequiredMilliseconds.
Pattern^-?(0|[1-9][0-9]*)n$Example30000nconfWadstring | nullScaled by 1e18 (WAD).
Pattern^-?(0|[1-9][0-9]*)n$Example30000000000000000nentryWadstring | nullSame as
fill_wad.Pattern^-?(0|[1-9][0-9]*)n$Example74250000000000000000nerrorsstring[]requiredReasons the open would fail; empty when it would go through.
execFeestringrequiredCollateral base units escrowed with the request.
Pattern^-?(0|[1-9][0-9]*)n$Example800000nfactorBpsstring | nullBasis points (1/10000).
Pattern^-?(0|[1-9][0-9]*)n$Example10000nfeestring | nullThe charged open fee (after the referee discount).
Pattern^-?(0|[1-9][0-9]*)n$Example800000nfillWadstring | nullThe two-step fill: the plain mid (WAD).
Pattern^-?(0|[1-9][0-9]*)n$Example74250000000000000000nfillWindowMsstringrequiredMilliseconds.
Pattern^-?(0|[1-9][0-9]*)n$Example60000nindicativeboolean | nulltruewhile no fresh signed confidence is indexed (the spread is the floor only).isLongbooleanrequiredlockedstring | nullMargin locked in the position:
marginminus the chargedfee, USDC base units (6 decimals).Pattern^-?(0|[1-9][0-9]*)n$Example100000000nmarginstring | nullPattern^-?(0|[1-9][0-9]*)n$Example100000000nmarketIdstringrequiredPattern^0x[0-9a-f]{64}$Example0x6e6238eb4f69bfcc3e884a7d20904eb0995ca2e42c95dc8560d5a417486ab645maxFeeBpsstring | nullThe effective taker fee snapshot; null on a rejected open.
Pattern^-?(0|[1-9][0-9]*)n$Example8nminPayoutFactorBpsstring | nullBasis points (1/10000).
Pattern^-?(0|[1-9][0-9]*)n$Example10000nnotionalstring | nullPattern^-?(0|[1-9][0-9]*)n$Example1000000000noneStepSpreadBpsstringrequiredBasis points (1/10000).
Pattern^-?(0|[1-9][0-9]*)n$Example5noneStepWadstring | nullThe one-step reference price: the mid moved by the one-step spread against a long open (up) or a short open (down).
Pattern^-?(0|[1-9][0-9]*)n$Example74250000000000000000nsignedWindowMsstringrequiredMilliseconds.
Pattern^-?(0|[1-9][0-9]*)n$Example60000nspreadSourcenull | stringsuggestedAcceptablePriceWadstring | nullThe mid 0.5% against the trader; null without a live mid.
Pattern^-?(0|[1-9][0-9]*)n$Example74250000000000000000nsuggestedBoundWadstring | nullfill_wadmovedslippage_bpsagainst the trader; null withoutslippage_bps.Pattern^-?(0|[1-9][0-9]*)n$Example74250000000000000000ntakerFeeBpsstring | nullThe effective taker fee (market fee or the global override).
Pattern^-?(0|[1-9][0-9]*)n$Example8nwinningExposurestring | nullPattern^-?(0|[1-9][0-9]*)n$Example1850000000000n
Example request
curl -X POST 'https://api.parchment.trade/previews/open' \
-H 'Content-Type: application/json' \
-d '{
"acceptableEntryWad": "74250000000000000000n",
"accountId": "0xad23e722f3542ae36c276c1b303e30ae77c840a84db89c7215fa87bf92006691",
"isLong": true,
"leverage": "10n",
"margin": "100000000n",
"marketId": "0x6e6238eb4f69bfcc3e884a7d20904eb0995ca2e42c95dc8560d5a417486ab645",
"minFactorBps": "10000n",
"slippageBps": "50n",
"topUp": "100000000n"
}'const res = await fetch("https://api.parchment.trade/previews/open", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"acceptableEntryWad": "74250000000000000000n",
"accountId": "0xad23e722f3542ae36c276c1b303e30ae77c840a84db89c7215fa87bf92006691",
"isLong": true,
"leverage": "10n",
"margin": "100000000n",
"marketId": "0x6e6238eb4f69bfcc3e884a7d20904eb0995ca2e42c95dc8560d5a417486ab645",
"minFactorBps": "10000n",
"slippageBps": "50n",
"topUp": "100000000n"
}),
});
const { data } = await res.json();Example response (200)
{
"data": {
"bustWad": "67550000000000000000n",
"cancelDelayMs": "30000n",
"confWad": "30000000000000000n",
"entryWad": "74250000000000000000n",
"errors": [],
"execFee": "800000n",
"factorBps": "10000n",
"fee": "800000n",
"fillWad": "74250000000000000000n",
"fillWindowMs": "60000n",
"indicative": true,
"isLong": true,
"locked": "100000000n",
"margin": "100000000n",
"marketId": "0x6e6238eb4f69bfcc3e884a7d20904eb0995ca2e42c95dc8560d5a417486ab645",
"maxFeeBps": "8n",
"minPayoutFactorBps": "10000n",
"notional": "1000000000n",
"oneStepSpreadBps": "5n",
"oneStepWad": "74250000000000000000n",
"signedWindowMs": "60000n",
"spreadSource": "floor",
"suggestedAcceptablePriceWad": "74250000000000000000n",
"suggestedBoundWad": "74250000000000000000n",
"takerFeeBps": "8n",
"winningExposure": "1850000000000n"
}
}