Extensible ERC721 with a Built-in Commitment Scheme.
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
] are permitted to mint; 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.
- 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
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"
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 using their installation guide.
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! 🎉
make
# OR #
make setup
make build
make test
Using foundry.toml, Foundry is easily configurable.
- commit-reveal schemes
- foundry
- solmate
- forge-std
- clones-with-immutable-args.
- foundry-toolchain by onbjerg.
- forge-template by FrankieIsLost.
- Georgios Konstantopoulos for forge-template resource.
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.