Skip to Content
Symmio Trading-SDK — the SDK surface for builders on Arbitrum
CoreUnified QuotesplanGroupClose

planGroupClose

Allocate an exact close quantity across a grouped position’s children.

Closing “2.8 of a 5-unit merged position” is not one call — it is a set of per-quote closes that must sum to the target exactly, while every partially closed child keeps at least the symbol’s dust floor. This planner produces that allocation or fails without closing anything; there is no partial-success middle ground, because a half-applied close leaves the trader with a position they did not ask for.

Largest child first, so the fewest quotes are touched.

import { toGroupCloseCandidates, planGroupClose } from "@symmio/trading-core"; const plan = planGroupClose( toGroupCloseCandidates(group.quotes, market.minAcceptableQuoteValue), parseUnits("2.8", 18), ); if (!plan.feasible) return plan.reason; // "exceeds-open" | "nothing-to-close" | "dust-locked"

Parameters

candidatesreadonly GroupCloseCandidate[]required
targetQuantitybigintrequired

Exact total to close across the group, wei.

Returns

PlanGroupCloseResult

{ feasible: true, allocations } when the plan sums to the target exactly, otherwise { feasible: false, reason, totalOpen, closeableQuantity } — where closeableQuantity is the largest amount the group could close, for a UI cap.

Failure reasons

exceeds-openPlanGroupCloseFailureReason

The target exceeds the group’s total open quantity.

nothing-to-closePlanGroupCloseFailureReason

No candidate has open size, or the target is not positive.

dust-lockedPlanGroupCloseFailureReason

Every remaining child sits at its dust cap — the exact target is unreachable.

Last updated on