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:

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.


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.

Last updated