Market
Market.sol
is a module contract that handles market-related functionalities in the Unlockd Protocol. It allows users to create and manage orders, place bids, claim assets, and perform buy and sell operations.
Key functions:
Returns the details of an order given its ID.
Parameters:
orderId
: The ID of the order to retrieve.
Returns the minimum bid price for an order.
Parameters:
orderId
: The ID of the order.
underlyingAsset
: The address of the underlying asset.
aggLoanPrice
: The aggregated loan price.
aggLtv
: The aggregated loan-to-value ratio.
Returns the buy-now price for an order.
Parameters:
orderId
: The ID of the order.
underlyingAsset
: The address of the underlying asset.
aggLoanPrice
: The aggregated loan price.
aggLtv
: The aggregated loan-to-value ratio.
Allows users to create a new order. It validates the signature, retrieves the loan details, updates the loan state, validates the order creation, and creates a new order with the specified parameters.
Parameters:
underlyingAsset
: The address of the underlying asset.
orderType
: The type of the order.
config
: The configuration parameters for creating the order.
signMarket
: The signed market data.
sig
: The EIP-712 signature for the order creation.
Allows the order owner to cancel an existing order. It retrieves the order and loan details, validates the cancellation action, refunds any existing bid, and deletes the order.
Parameters:
orderId
: The ID of the order to cancel.
Allows users to place a bid on an order. It validates the signature, retrieves the order and loan details, validates the bid action, transfers the bid amount, creates a new loan for the bidder if a debt is requested, refunds any existing bid, and updates the order with the new bid details.
Parameters:
orderId
: The ID of the order to bid on.
amountToPay
: The amount to pay for the bid.
amountOfDebt
: The amount of debt associated with the bid.
signMarket
: The signed market data.
sig
: The EIP-712 signature for the bid.
Allows users to claim assets from a completed order. It validates the signature, retrieves the order and loan details, validates the claim action, transfers the claimed amount, updates the loan state, and transfers the claimed assets to the winning bidder.
Parameters:
claimOnUWallet
: A flag indicating whether to claim the assets on the user's Unlockd wallet.
orderId
: The ID of the order to claim assets from.
signMarket
: The signed market data.
sig
: The EIP-712 signature for the claim.
Allows users to cancel a pending claim on an order. It validates the signature, retrieves the order and loan details, validates the claim cancellation action, and refunds the pending claim amount.
Parameters:
orderId
: The ID of the order associated with the claim to cancel.
signMarket
: The signed market data.
sig
: The EIP-712 signature for the claim cancellation.
It allows users to perform a buy-now operation on an order. It validates the signature, retrieves the order and loan details, validates the buy-now action, transfers the buy-now amount, creates a new loan for the buyer if a debt is requested, refunds any existing bid, and transfers the bought assets to the buyer.
Parameters:
claimOnUWallet
: A flag indicating whether to claim the assets on the user's Unlockd wallet.
orderId
: The ID of the order to buy.
amountToPay
: The amount to pay for the buy now operation.
amountOfDebt
: The amount of debt associated with the buy-now operation.
signMarket
: The signed market data.
sig
: The EIP-712 signature for the buy now operation.
Signature
signMarket
(type: DataTypes.SignMarket
), it contains the following fields:
signMarket
(type: DataTypes.SignMarket
), 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 involved in the market action.
collection
(type: address
): The address of the asset collection.
tokenId
(type: uint256
): The token ID of the asset.
assetPrice
(type: uint256
): The price of the asset.
assetLtv
(type: uint256
): The loan-to-value ratio of the asset.
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:
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