This repository was archived by the owner on Jan 18, 2023. It is now read-only.
NFT orderbook #1
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Orderbook
Orderbook implementation where bids are fungible tokens and asks are NFTs.
A bid is a request to buy one NFT from a specific collection.
An ask is one NFT with a min price condition.
Askis an object which is associated with a single NFT.When
Askis created, we transfer the ownership of the NFT to thisnew object.
When an
Askis matched with a bid, we transfer the ownership of theaskobject to the bid owner (buyer).The buyer can then claim the NFT via
claim_nftendpoint.One can:
pattern protected)
Witness protected actions
The contract which creates the orderbook can restrict specific actions to be
called only with a witness pattern and not via the entry point function.
This means others can build contracts on top of the orderbook with their own
custom logic based on their requirements or they can just use the entry point
functions that cover other use cases.
If a method is protected, clients will need to call a standard endpoint in the
witness-owning smart contract instead of the relevant endpoint in the orderbook.
Another way to think about this from a marketplace or wallet POV:
if I see that an action is protected, I can decide to either call the downstream
implementation in the collection smart contract, or simply disable that specific
action.
An example of this would be an NFT which has an expiry date like a name service
which requires an additional check before an ask can be placed on the orderbook.
Marketplaces can choose to support this additional logic or simply use the
standard orderbook and enable bids but asks would be disabled until they decide
to support the additional checks.
The setting is stored on the orderbook object:
This means that the additional complexity is (i) opt-in by the collection and
(ii) reserved only to the particular action which warrants that complexity.
To reiterate, a marketplace can list NFTs from collections that have all
actions unprotected, ie. no special logic. Or they can just disable that
particular action that is disabled in the UI.
Additionally, if we created a standard interface for custom implementations of
the disabled actions, then the added opt-in complexity could be abstracted away
from the clients by our SDK.
TBD: Can this be misused by removing the option to cancel an ask/bid?
Changelog
[0.4.0] - 2022-09-29
Changed
the naive implementation with two sorted arrays.
Syrup[0.3.0] - 2022-09-27
Changed
contract has the liberty of deciding when and how a new instance of an
orderbook should be created.
Added
figured out and data model. To collect fees, the downstream collection
contract calls witness protected
collect_feesfunction.[0.2.0] - 2022-09-21
Added
Changed
nft-protocolv0.2.0 and Sui v0.9.0