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

# Output claims and refunds

> Settle current single-hop and multi-hop pending outputs into encrypted token records.

Both swap paths write the same public `SwapOutput`. Both settle through `claim_swap_output`.

## Outcome

Settlement is complete when the claim is accepted, `swap_outputs[swap_id]` is removed, and the wallet has stored the output and optional refund records.

## Pending output shape

```text theme={"languages":{"custom":["/languages/leo.tmLanguage.json"]}}
SwapOutput {
  recipient: address,
  caller: address,
  token_in: field,
  token_out: field,
  amount_out: u128,
  amount_remaining: u128
}
```

All amounts use native token base units. For a multi-hop swap, `token_in` and `amount_remaining` refer to the original route input. The current contract does not expose one refund pair per intermediate hop.

## Claim sequence

<Steps>
  <Step title="Wait for swap acceptance">
    Resolve transaction finality before reading the mapping or retrying the swap.
  </Step>

  <Step title="Read the pending output">
    Load `swap_outputs[swap_id]`. Copy its token IDs and amounts exactly.
  </Step>

  <Step title="Obtain current freezelist proofs">
    Build the two `MerkleProof` values required to prove non-inclusion for the claiming signer.
  </Step>

  <Step title="Submit claim_swap_output">
    Use the original private factor and public confidential address. Pass the mapping values and proofs.
  </Step>

  <Step title="Reconcile records and mapping removal">
    Confirm acceptance, mapping removal, and wallet discovery of both dynamic record outputs.
  </Step>
</Steps>

## Identity and compliance checks

The claim reconstructs the confidential address from the program address, signer, factor, and fixed domain. It also validates signer non-inclusion against the AMM freezelist root. Knowing the public mapping values does not authorize a claim.

The investigator compliance record is not a claim credential. The admin has no redirect or recovery function for lost factor material.

## Router claims

When output or refund must cross a wrapper boundary, use the matching function in `shield_swap_router.aleo`:

* `claim_to_wrapped_refund_arc20`
* `claim_to_arc20_refund_wrapped`
* `claim_to_wrapped_refund_wrapped`

Resolve both asset kinds from the selected environment's contract registry.

## Retry rules

On an ambiguous result:

1. Query the claim transaction.
2. Read `swap_outputs[swap_id]` again.
3. If the mapping remains, verify the prior claim is rejected before resubmitting.
4. If the mapping is absent, scan and decrypt the accepted transaction outputs.

Do not infer success from a client timeout. Do not reconstruct claim amounts from an old quote.
