# SellNow

`SellNow.sol` is a module contract that provides functionality for selling NFTs within the Unlockd Protocol. It allows users to sell their NFTs either through a direct sale or force-selling them using the protocol's backend in case of liquidation.

### Key functions:

```solidity
function forceSell(
    DataTypes.Asset calldata asset,
    DataTypes.SignSellNow calldata signSellNow,
    DataTypes.EIP712Signature calldata sig
) external onlyAuctionAdmin
```

Allows the auction admin to force-sell an NFT managed by the protocol's bot. It validates the signature, retrieves the loan details, validates the force-sell action, approves the sale, executes the sale using the market adapter, repays the debt, and distributes the funds to the asset owner.

### Parameters:

`asset`: The asset to be force-sold.

`signSellNow`: The signed sell now data.

`sig`: The EIP-712 signature for the force-sell operation.

***

```solidity
function sell(
    DataTypes.Asset calldata asset,
    DataTypes.SignSellNow calldata signSellNow,
    DataTypes.EIP712Signature calldata sig
) external
```

Allows users to sell their NFTs directly. It validates the signature, retrieves the user's Unlockd wallet and protocol owner addresses, validates the sell action, approves the sale, executes the sale using the market adapter, repays the debt (if any), and distributes the funds to the user.

### Parameters:

`asset`: The asset to be sold.

`signSellNow`: The signed sell now data.

`sig`: The EIP-712 signature for the sell operation.

## Signature

#### `signSellNow` (type: `DataTypes.SignSellNow`), it contains the following fields:

`loan` (type: `DataTypes.SignLoanConfig`): The loan configuration data, including the loan ID, aggregated loan price, LTV, liquidation threshold, total assets, nonce, and deadline.

`assetId` (type: `bytes32`): The ID of the asset being sold.

`marketAdapter` (type: `address`): The address of the market adapter used for the sell now action.

`marketApproval` (type: `address`): The address for market approval.

`marketPrice` (type: `uint256`): The market price of the asset.

`underlyingAsset` (type: `address`): The address of the underlying asset.

`from` (type: `address`): The address from which the sell now action is initiated.

`to` (type: `address`): The address to which the asset is being sold.

`data` (type: `bytes`): Additional data for the sell now action.

`value` (type: `uint256`): The value being sent with the sell now action.

`nonce` (type: `uint256`): The nonce value is used to ensure the uniqueness of the signature and prevent replay attacks.

`deadline` (type: `uint256`): The deadline timestamp until which the signature is considered valid.

#### `sig` (type: `DataTypes.EIP712Signature`), it contains the following fields:

`v` (type: `uint8`): The recovery ID of the signature.

`r` (type: `bytes32`): The first 32 bytes of the signature.

`s` (type: `bytes32`): The second 32 bytes of the signature.

`deadline` (type: `uint256`): The deadline timestamp until which the signature is considered valid.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://devs.unlockd.finance/modules/debt-tokens-3.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
