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

# Auto Cancellation

> How auto cancellations work for orders with a referral code.

# Overview

Auto cancellation can be enabled for orders associated with a [referral
code](/dln-details/integration-guidelines/order-creation/creating-order/api-parameters/api-parameters#referral-code). This mechanism improves user
experience by automatically cancelling unfulfilled orders after a timeout period.

<Note>
  This feature is strictly available through an approval from deBridge. To enable this feature, deBridge must be contacted.
</Note>

***

## How it works

* **Timeout duration:** 5 minutes for unprofitable orders, 15 minutes for other causes (e.g. compliance issues)
* **Condition:** If an order is not fulfilled within this period, it is automatically cancelled, along with any external calls (hooks)
* **Benefit:** Users do not need to manually cancel the order on the destination chain, greatly improving the UX
* **Cost:** The cancellation fee is subsidized by deBridge
* **Market orders:** Only market orders can be cancelled, not [limit
  orders](/dln-details/integration-guidelines/order-creation/creating-order/quoting-strategies#limit-order-not-recommended).

***

## Returned funds and asset types

Upon cancellation, returned funds are generally not the same asset originally sent.\
When orders are created, tokens are swapped for [**reserve assets**](/dln-details/dln-specifics/reserve-assets) to simplify solver book balancing.\
Assets with sufficient on-chain liquidity remain tradable.

<Warning>
  In most cases, USDC will be used. If the reserve asset on one chain is USDC, but on another it is ETH, wETH or USDC - USDC will be used on both the
  source and destination chains.
</Warning>

The refund asset and amount can be found in `create-tx` response payload by inspecting the `srcChainTokenOut`
[field](/dln-details/integration-guidelines/order-creation/creating-order/api-parameters/response#srcchaintokenout-optional). The entire input amount
and all of the [fees incurred by creating an order](/dln-details/overview/fee-structure) are returned to the user.

<Note>
  If the `srcChainTokenOut` is not present in the response payload, the refund asset is specified in `srcChainTokenIn`
  [field](/dln-details/integration-guidelines/order-creation/creating-order/api-parameters/response#srcchaintokenin).

  The reason for that is that [pre-order-swap was not performed](/dln-details/dln-specifics/bridging-non-reserve-assets#pre-order-swap) because the
  order input asset was a [reserve asset](/dln-details/dln-specifics/reserve-assets).
</Note>

***

## Required integration parameters

<Danger>
  When auto cancellation is enabled - `dstChainOrderAuthorityAddress`
  [parameter](/dln-details/integration-guidelines/order-creation/creating-order/api-parameters/api-parameters#authorities-and-recipient-address) will be
  overridden to a deBridge-controlled address to [cancel orders on the destination
  chain](/dln-details/integration-guidelines/order-creation/cancelling-order). Cancellation costs will be subsidized by deBridge in this case.

  The `srcAllowedCancelBeneficiary`
  [parameter](/dln-details/integration-guidelines/order-creation/creating-order/api-parameters/api-parameters#cancellation-beneficiary) must be set to
  the user's wallet address. This address acts as the beneficiary of returned funds in the event of a cancellation. **If not set correctly, funds may be
  lost**. It is recommended for partners to set the `srcAllowedCancelBeneficiary` parameter to a user-controlled address explicitly.

  If not set, the `srcChainOrderAuthorityAddress` will be used as a [fallback](/dln-details/affiliates/auto-cancellations#fallbacks).
</Danger>

### Fallbacks

If [`srcChainOrderAuthorityAddress` parameter](/dln-details/integration-guidelines/order-creation/creating-order/api-parameters/api-parameters#authorities-and-recipient-address)
is set in `create-tx` requests, the value of it will be used as `srcAllowedCancelBeneficiary` if `srcAllowedCancelBeneficiary` is not set explicitly.

***

## Feature request steps

* Integrator gives an explicit, unambiguous approval for the feature to be switched on
* Integrator sets the `create-tx` [request parameters correctly](#required-integration-parameters)
* Integrator confirms the parameter settings via an established communication channel
* deBridge reviews several recent orders created by the integrator after the settings confirmation
* deBridge switches the feature on and confirms it to the integrator
