Skip to content
forked from refcell/cloaks

Extensible ERC721 with a Built-in Commitment Scheme.

License

Notifications You must be signed in to change notification settings

platocrat/cloaks

 
 

Repository files navigation

cloaks • tests lints GitHub GitHub package.json version

Extensible ERC721 with a Built-in Commitment Scheme.

Overview

Mints suck...

They're difficult to mint, oft impossible. The mint price is fixed - artists and creators don't realize upside.

Is this fixable?

The answer: not without tradeoffs.

To satisfy this, Cloaks sacrifices ordering (first-come first-serve) for price-discovery and gas efficiency.

How does this work?

Cloaks start with a commit phase, that lasts for an arbitrarily long period to prevent gas wars. During the commit phase, anyone can call commit(), providing a sealed bid price (appraisal) and sending depositAmount of a token to the Cloak.

This is possible by using a commitment scheme where the sealed value is hashed and revealed in the next phase. Read more on commitment schemes here.

Once the commit phase ends, everyone who commited values then calls reveal(), providing the bid price. Once this function is called, the sender's sealed bid is becomes public.

NOTE: Commitments can only be made during the commit phase.

Once the reveal phase ends, Cloak enters the third and last phase - the mint phase.

At this time, the mint price is determined by taking the mean of all the revealed bids. The final mint price is the max of either this calculated price or the minPrice set by the Cloak creator.

To incentivize bid accuracy, only bids that are in the range of [resultPrice - flex * stdDev, resultPrice + flex * stdDev], where flex is a scalar value set by the Cloak creator.

Anyone who isn't in this range can call forgo() to withdraw their deposit token.

If a user ends up in the range and forgos, they suffer a loss penalty proportional to how close they are to the resulting price. Additionally, if a bid is an outlier, a loss penalty is incurred proportional to a Z-Score.

NOTE: If a commitooor forgets to reveal their sealed bid, they can call lostReveal() to withdraw their deposit.

Issues

  • Outlier Spoofing
  • Deposit Token Frozen without revealing
  • Loss Penalty is not time weighted to the commitment time
  • Fix token supply and derive price bands dynamically

Blueprint

lib
├─ ds-test — https://github.com/dapphub/ds-test
├─ forge-std — https://github.com/brockelmore/forge-std
├─ solmate — https://github.com/Rari-Capital/solmate
├─ clones-with-immutable-args — https://github.com/wighawag/clones-with-immutable-args
src
├─ tests
│  └─ Cloak.t — "Cloak Tests"
└─ Cloak"The main Cloak contract"

Development

A Cloak is an extensible ERC721 implementation with a commit-reveal scheme built into the ERC721 contract itself. The only contract is located in src/ called Cloak.

Both DappTools and Foundry are supported. Installation instructions for both are included below.

Install DappTools

Install DappTools using their installation guide.

First time with Forge/Foundry?

See the official Foundry installation instructions.

Don't have rust installed? Run

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Then, install the foundry toolchain installer (foundryup) with:

curl -L https://foundry.paradigm.xyz | bash

Now that you've installed the foundryup binary, anytime you need to get the latest forge or cast binaries, you can run foundryup.

So, simply execute:

foundryup

🎉 Foundry is installed! 🎉

Setup

make
# OR #
make setup

Build

make build

Run Tests

make test

Configure Foundry

Using foundry.toml, Foundry is easily configurable.

License

AGPL-3.0-only

Acknowledgements

Disclaimer

These smart contracts are being provided as is. No guarantee, representation or warranty is being made, express or implied, as to the safety or correctness of the user interface or the smart contracts. They have not been audited and as such there can be no assurance they will work as intended, and users may experience delays, failures, errors, omissions, loss of transmitted information or loss of funds. The creators are not liable for any of the foregoing. Users should proceed with caution and use at their own risk.

About

Extensible ERC721 with a Built-in Commitment Scheme.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Solidity 96.2%
  • Makefile 2.9%
  • Shell 0.9%