Auction

Auction.sol is a module contract that handles auction-related functionalities in the Unlockd Protocol, such as placing bids, redeeming assets, and finalizing auctions.

Key functions:

function getAmountToReedem(
    bytes32 loanId,
    bytes32[] calldata assets
) public view returns (uint256, uint256, uint256)

Calculates the amount required to redeem assets from an auction, including the total amount, total debt amount, and total bidder bonus amount.

Parameters:

loanId: The ID of the loan associated with the auction.

assets: An array of asset IDs to be redeemed.

Returns:

The total amount required to redeem the assets.

The total debt amount.

The total bidder bonus amount.


function getMinBidPriceAuction(
    bytes32 loanId,
    bytes32 assetId,
    uint256 assetPrice,
    uint256 aggLoanPrice,
    uint256 aggLtv
) external view returns (uint256 minBid)

Calculates the minimum bid price for an asset in an auction based on the loan details and asset information.

Parameters:

loanId: The ID of the loan associated with the auction.

assetId: The ID of the asset.

assetPrice: The price of the asset.

aggLoanPrice: The aggregated loan price.

aggLtv: The aggregated loan-to-value ratio.

Returns:

The minimum bid price for the asset.


function getOrderAuction(
    bytes32 orderId
) external view returns (DataTypes.Order memory)

Retrieves the details of an auction order.

Parameters:

orderId: The ID of the auction order.

Returns:

The auction order details.


function bid(
    uint128 amountToPay,
    uint128 amountOfDebt,
    DataTypes.SignAuction calldata signAuction,
    DataTypes.EIP712Signature calldata sig
) external 

Allows users to place a bid in an auction. It validates the signature, updates the loan state, transfers the bid amount, creates a new loan for the bidder if a debt is requested, and updates the auction order with the new bid details.

Parameters:

amountToPay: The amount to pay for the bid.

amountOfDebt: The amount of debt associated with the bid.

signAuction: The signed auction data.

sig: The EIP-712 signature for the bid.

Emits:

AuctionBid event.


function redeem(
    uint256 amount,
    bytes32[] calldata assets,
    DataTypes.SignAuction calldata signAuction,
    DataTypes.EIP712Signature calldata sig
) external

Allows the auction owner to redeem assets from an auction. It validates the signature, transfers the redemption amount, distributes the funds to the bidders, and updates the loan state.

Parameters:

amount: The amount to pay for the redemption.

assets: An array of asset IDs to be redeemed.

signAuction: The signed auction data.

sig: The EIP-712 signature for the redemption.

Emits:

AuctionRedeem event.


function finalize(
    bool claimOnUWallet,
    bytes32 orderId,
    DataTypes.Asset calldata asset,
    DataTypes.SignAuction calldata signAuction,
    DataTypes.EIP712Signature calldata sig
) external

It allows anyone to finalize an expired auction. It validates the signature, retrieves the auction order and loan details, transfers the auctioned asset to the winning bidder, distributes the funds to the auction owner, and updates the loan state.

Parameters:

claimOnUWallet: A flag indicating whether to claim the assets on the user's Unlockd wallet.

orderId: The ID of the auction order.

asset: The asset being auctioned.

signAuction: The signed auction data.

sig: The EIP-712 signature for the finalization.

Emits:

AuctionFinalize event.

Signature

signAuction (type: DataTypes.SignAuction), 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.

assets (type: bytes32[]): An array of asset IDs involved in the auction.

assetPrice (type: uint256): The price of the asset being auctioned.

assetLtv (type: uint256): The loan-to-value ratio of the asset being auctioned.

endTime (type: uint40): The end time of the auction.

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