> ## Documentation Index
> Fetch the complete documentation index at: https://docs.flew.live/llms.txt
> Use this file to discover all available pages before exploring further.

# Exit a position early

> Close an eligible position before the market closes.

export const DocsFlowEmbed = ({flowId, title, height = 760, mobileHeight, baseUrl}) => {
  const localWebOrigin = "http://localhost:3004";
  const productionWebOrigin = "https://www.flew.live";
  const getTheme = () => {
    if (typeof document === "undefined") return "light";
    const root = document.documentElement;
    const explicitTheme = root.dataset.theme || root.dataset.colorMode;
    if (explicitTheme === "dark" || root.classList.contains("dark")) {
      return "dark";
    }
    if (explicitTheme === "light") return "light";
    return window.matchMedia?.("(prefers-color-scheme: dark)").matches ? "dark" : "light";
  };
  const getDefaultOrigin = () => {
    if (typeof window === "undefined") return productionWebOrigin;
    const isLocalDocs = ["localhost", "127.0.0.1", "::1"].includes(window.location.hostname);
    return isLocalDocs ? localWebOrigin : productionWebOrigin;
  };
  const iframeRef = useRef(null);
  const [theme, setTheme] = useState("light");
  const [isMobile, setIsMobile] = useState(false);
  const [isLoaded, setIsLoaded] = useState(false);
  const [hasTimedOut, setHasTimedOut] = useState(false);
  const [attempt, setAttempt] = useState(0);
  const [detectedOrigin, setDetectedOrigin] = useState(productionWebOrigin);
  const origin = useMemo(() => {
    const value = baseUrl || detectedOrigin;
    try {
      return new URL(value).origin;
    } catch {
      return detectedOrigin;
    }
  }, [baseUrl, detectedOrigin]);
  const source = useMemo(() => {
    const safeFlowId = String(flowId || "").replace(/[^a-z0-9-]/gi, "");
    const params = new URLSearchParams({
      embed: "1",
      theme: "system",
      attempt: String(attempt)
    });
    return `${origin}/docs-flow/${safeFlowId}?${params.toString()}`;
  }, [attempt, flowId, origin]);
  const postTheme = useCallback(nextTheme => {
    iframeRef.current?.contentWindow?.postMessage({
      type: "flew-docs-theme",
      theme: nextTheme
    }, origin);
  }, [origin]);
  useEffect(() => {
    setDetectedOrigin(getDefaultOrigin());
    setTheme(getTheme());
    const media = window.matchMedia?.("(prefers-color-scheme: dark)");
    const mobileMedia = window.matchMedia?.("(max-width: 640px)");
    const updateTheme = () => setTheme(getTheme());
    const updateMobile = () => setIsMobile(Boolean(mobileMedia?.matches));
    const observer = new MutationObserver(updateTheme);
    observer.observe(document.documentElement, {
      attributes: true,
      attributeFilter: ["class", "data-theme", "data-color-mode"]
    });
    updateMobile();
    media?.addEventListener?.("change", updateTheme);
    mobileMedia?.addEventListener?.("change", updateMobile);
    return () => {
      observer.disconnect();
      media?.removeEventListener?.("change", updateTheme);
      mobileMedia?.removeEventListener?.("change", updateMobile);
    };
  }, []);
  useEffect(() => {
    postTheme(theme);
  }, [postTheme, theme]);
  useEffect(() => {
    if (isLoaded) return undefined;
    const timeout = window.setTimeout(() => setHasTimedOut(true), 12000);
    return () => window.clearTimeout(timeout);
  }, [attempt, isLoaded]);
  const retry = () => {
    setIsLoaded(false);
    setHasTimedOut(false);
    setAttempt(value => value + 1);
  };
  const handleLoad = () => {
    setIsLoaded(true);
    setHasTimedOut(false);
    postTheme(theme);
  };
  const accessibleTitle = title || "Flew user flow";
  const effectiveMobileHeight = mobileHeight || height;
  const frameHeight = isMobile ? effectiveMobileHeight : height;
  return <figure className="flew-docs-flow not-prose" style={{
    "--flew-flow-height": `${height}px`,
    "--flew-flow-mobile-height": `${effectiveMobileHeight}px`
  }} aria-label={accessibleTitle}>
      <div className="flew-docs-flow__viewport">
        {!isLoaded && !hasTimedOut && <div className="flew-docs-flow__status" role="status" aria-live="polite">
            <span className="flew-docs-flow__spinner" aria-hidden="true" />
            <span>Loading interactive diagram…</span>
          </div>}

        {hasTimedOut && !isLoaded && <div className="flew-docs-flow__status" role="alert">
            <strong>
              The interactive diagram is taking longer than expected.
            </strong>
            <span>You can try again or open it directly in Flew.</span>
            <div className="flew-docs-flow__actions">
              <button type="button" onClick={retry}>
                Try again
              </button>
              <a href={source} target="_blank" rel="noreferrer">
                Open diagram
              </a>
            </div>
          </div>}

        <iframe ref={iframeRef} key={attempt} className="flew-docs-flow__frame" src={source} title={accessibleTitle} style={{
    height: `${frameHeight}px`,
    minHeight: `${frameHeight}px`
  }} loading="lazy" onLoad={handleLoad} onError={() => setHasTimedOut(true)} allow="fullscreen" />
      </div>

      <figcaption className="flew-docs-flow__caption">
        <span>
          Use the controls to zoom or fit the view.
        </span>
        <a href={source} target="_blank" rel="noreferrer">
          Open full screen
        </a>
      </figcaption>
    </figure>;
};

## What is early exit?

Early exit closes your position before the market resolves. The position becomes final after a successful exit and cannot later claim a payout or refund.

## Eligibility

You can exit only when:

* The market is active and has not reached its closing time
* Your position has not already been claimed or exited
* No claim, refund, or exit is already in progress for your position
* The global minimum holding period has elapsed
* No other Arcium computation is currently updating the market

The minimum holding period is a global on-chain setting and may change between deployments. Flew enables the exit action only after the configured period has elapsed.

## Manual-market exit

For a manually resolved market, click **Exit Early (Capital)**.

This mode performs capital recovery:

* Flew removes your net position amount from its encrypted side of the pool.
* Your gross exit value equals that net position amount.
* The protocol placement fee you paid when entering the position is not returned.
* If an early-exit fee is configured, Flew deducts it from the gross exit value.

This mode does not use the pool ratio to generate an early profit.

## Switchboard-market exit

For a Switchboard market, click **Exit Early (Oracle Price)**.

Flew verifies a fresh Switchboard quote and estimates the probability of your private side using:

* Whether the current feed value satisfies the market threshold
* How far the market has progressed toward closing
* A maximum payout derived from the available market pools

The quote must be no more than 150 Solana slots old. A stale quote causes the transaction to fail.

The oracle exit value can be above or below your net position amount. It cannot exceed the position's maximum proportional payout from the current pools.

## Exit sequence

<DocsFlowEmbed flowId="early-exit" title="Early exit user flow" height={780} mobileHeight={880} />

## Fees

Flew applies the configured early-exit fee to the gross exit value:

```text theme={null}
Net exit payment = Gross exit value - Early-exit fee
```

The placement fee and early-exit fee are separate. See [Fees](/more/fees).

## Finalization

Early exit has two stages: your wallet first submits the Solana transaction, then Arcium finalizes the computation before the market transfers the net exit payment.

Keep the page open until Flew reports completion. A transaction signature alone does not mean the Arcium callback has finalized.

## Privacy boundary

The position side and updated aggregate pools remain encrypted during the computation. The wallet executing the exit, the market, transaction timing, and final exit payment are public on Solana. Your original position amount was already public when you entered the market.

<Warning>
  Early exit is terminal. After it succeeds, you cannot claim the final market
  payout or an unresolved-market refund for that position.
</Warning>
