NFT Smart contracts docs(draft document)
===
WoomExchange: an exchange NFT smart contracts that manage auctions and direct sell on chain.
# Workflow

---
there are two main flow in WoomEchange contracts:
> Direct sell
> Auctions
## **Direct sell**
In this flow users create an offer using addOffer function and specify an Ether price
Then users can bought direclty the NFT if all conditions are meet.
addOffer parameters
**AddOffer:** this function create an offer for direct sell or auctions, it has 9 main params described below:
| Param | type | description |
| -------- | -------- | -------- |
| seller | address | the NFT owner address |
| collection | address | the ERC721 contrat address |
| assetId | uint256 | the NFT token id |
| token | address | An ERC20 used for payment |
| isEther | bool | true if payment would be in ether else false |
| price | uint256 | the NFT price |
| isForSell | bool | true to activate direct sell |
| isForAuction | bool | false to keep token in direct sell |
| expiresAt | uint256 | the offer expire date |
**BuyOffer:** this function enable to users to buy a NFT in sell once all conditions are meet, it has two main params:
| Param | type | description |
| -------- | -------- | -------- |
| collection | address | the ERC721 contrat address |
| assetId | address | the NFT token id |
And in the `msg.value` users must provide an amount in ether upper or equal to token price.
## **Auctions**
to start an auction for NFT token, user should create and offer like below:
### addOffer ###
| Param | type | description |
| -------- | -------- | -------- |
| seller | address | the NFT owner address |
| collection | address | the ERC721 contrat address |
| assetId | uint256 | the NFT token id |
| token | address | An ERC20 used for payment |
| isEther | bool | false, payment would be processed with ERC20 for auctions |
| price | uint256 | the NFT price |
| isForSell | bool | false to activate auctions |
| isForAuction | bool | true to keep token in direct sell |
| expiresAt | uint256 | the offer expire date |
### setOfferPrice ###
This function set an offer price.
It has 3 mains params
| Param | type | description |
| -------- | -------- | -------- |
| collection | address | the ERC721 contrat address |
| assetId | uint256 | the NFT token id |
| price | uint256 | the offred price |
### setExpiresPrice ###
This function set an offer price.
It has 3 mains params
| Param | type | description |
| -------- | -------- | -------- |
| collection | address | the ERC721 contrat address |
| assetId | uint256 | the NFT token id |
| expiresAt | uint256 | the expire date in second |
### setForAuction ###
This function set an offer price.
It has 3 mains params
| Param | type | description |
| -------- | -------- | -------- |
| collection | address | the ERC721 contrat address |
| assetId | uint256 | the NFT token id |
| isForAuction | bool | enbale/disable for auction |
### setForSell ###
This function set an offer price.
It has 3 mains params
| Param | type | description |
| -------- | -------- | -------- |
| collection | address | the ERC721 contrat address |
| assetId | uint256 | the NFT token id |
| isForSell | bool | enbale/disable for sell |
### placeSafeBid ###
This function create a bid on NFT token in auction whether all conditions have been met.
It has 5 mains params
| Param | type | description |
| -------- | -------- | -------- |
| collection | address | the ERC721 contrat address |
| assetId | uint256 | the NFT token id |
| token | address | An ERC20 used for payment |
| price | uint256 | the offred price |
| expiresAt | uint256 | the bid expire date |
### cancelBid ###
This function cancel a bid on NFT token in auction whether all conditions have been met.
It has 3 main params
| Param | type | description |
| -------- | -------- | -------- |
| bidder | address | address of the bidder |
| collection | address | the ERC721 contrat address |
| assetId | uint256 | the NFT token id |
### acceptBid ###
This function accept a bid on NFT token in auction whether all conditions have been met.
It has 3 main params
| Param | type | description |
| -------- | -------- | -------- |
| bidder | address | address of the bidder |
| collection | address | the ERC721 contrat address |
| assetId | uint256 | the NFT token id |