Skip to content
This repository was archived by the owner on Oct 8, 2024. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 53 additions & 44 deletions contracts/Archetype.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Archetype v0.7.0 - DN404
// Archetype v0.8.0 - BRG404
//
// d8888 888 888
// d88888 888 888
Expand All @@ -16,12 +16,12 @@
pragma solidity ^0.8.4;

import "./ArchetypeLogic.sol";
import "dn404/src/DN404.sol";
import "dn404/src/DN420.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "solady/src/utils/LibString.sol";
import "@openzeppelin/contracts-upgradeable/token/common/ERC2981Upgradeable.sol";

contract Archetype is DN404, Initializable, OwnableUpgradeable, ERC2981Upgradeable {
contract Archetype is DN420, Initializable, OwnableUpgradeable, ERC2981Upgradeable {
//
// EVENTS
//
Expand Down Expand Up @@ -52,13 +52,12 @@ contract Archetype is DN404, Initializable, OwnableUpgradeable, ERC2981Upgradeab
string memory symbol_,
Config calldata config_,
PayoutConfig calldata payoutConfig_,
address mirror,
address _receiver
) external initializer {
_name = name_;
_symbol = symbol_;

_initializeDN404(0, address(0), mirror);
_initializeDN420(0, address(0));

// check max bps not reached and min platform fee.
if (
Expand Down Expand Up @@ -89,12 +88,7 @@ contract Archetype is DN404, Initializable, OwnableUpgradeable, ERC2981Upgradeab
payoutConfig_.partnerBps +
payoutConfig_.superAffiliateBps;

if (
payoutConfig_.platformBps < 250 ||
payoutConfig_.superAffiliate != DEVVAULT ||
payoutConfig_.superAffiliateBps < 250 ||
totalShares != 10000
) {
if (payoutConfig_.platformBps < 250 || totalShares != 10000) {
revert InvalidSplitShares();
}
payoutConfig = payoutConfig_;
Expand Down Expand Up @@ -136,7 +130,8 @@ contract Archetype is DN404, Initializable, OwnableUpgradeable, ERC2981Upgradeab
}
quantity += quantityToAdd;

_mintNext(toList[i], quantityToAdd * _unit());
bytes memory _data;
_mintNext(toList[i], quantityToAdd * _unit(), _data);

unchecked {
++i;
Expand Down Expand Up @@ -224,7 +219,8 @@ contract Archetype is DN404, Initializable, OwnableUpgradeable, ERC2981Upgradeab

ArchetypeLogic.validateMint(i, config, auth, _minted, signature, args, cost);

_mintNext(to, quantity * _unit());
bytes memory _data;
_mintNext(to, quantity * _unit(), _data);

if (i.limit < i.maxSupply) {
_minted[_msgSender()][auth.key] += quantity;
Expand Down Expand Up @@ -256,7 +252,7 @@ contract Archetype is DN404, Initializable, OwnableUpgradeable, ERC2981Upgradeab
return _symbol;
}

function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
function uri(uint256 tokenId) public view override returns (string memory) {
if (!_exists(tokenId)) revert URIQueryForNonexistentToken();

return
Expand Down Expand Up @@ -317,10 +313,6 @@ contract Archetype is DN404, Initializable, OwnableUpgradeable, ERC2981Upgradeab
return PLATFORM;
}

function devVault() external pure returns (address) {
return DEVVAULT;
}

function computePrice(
bytes32 key,
uint256 quantity,
Expand Down Expand Up @@ -389,30 +381,30 @@ contract Archetype is DN404, Initializable, OwnableUpgradeable, ERC2981Upgradeab
options.affiliateFeeLocked = true;
}

function setDiscounts(Discount calldata discounts) external _onlyOwner {
if (options.discountsLocked) {
revert LockedForever();
}
// function setDiscounts(Discount calldata discounts) external _onlyOwner {
// if (options.discountsLocked) {
// revert LockedForever();
// }

if (discounts.affiliateDiscount > MAXBPS) {
revert InvalidConfig();
}
// if (discounts.affiliateDiscount > MAXBPS) {
// revert InvalidConfig();
// }

// ensure mint tiers are correctly ordered from highest to lowest.
for (uint256 i = 1; i < discounts.mintTiers.length; ) {
if (
discounts.mintTiers[i].mintDiscount > MAXBPS ||
discounts.mintTiers[i].numMints > discounts.mintTiers[i - 1].numMints
) {
revert InvalidConfig();
}
unchecked {
++i;
}
}
// // ensure mint tiers are correctly ordered from highest to lowest.
// for (uint256 i = 1; i < discounts.mintTiers.length; ) {
// if (
// discounts.mintTiers[i].mintDiscount > MAXBPS ||
// discounts.mintTiers[i].numMints > discounts.mintTiers[i - 1].numMints
// ) {
// revert InvalidConfig();
// }
// unchecked {
// ++i;
// }
// }

config.discounts = discounts;
}
// config.discounts = discounts;
// }

function lockDiscounts() external _onlyOwner {
options.discountsLocked = true;
Expand Down Expand Up @@ -469,11 +461,6 @@ contract Archetype is DN404, Initializable, OwnableUpgradeable, ERC2981Upgradeab
emit Invited(_key, _cid);
}

function setDefaultRoyalty(address receiver, uint16 feeNumerator) public _onlyOwner {
config.defaultRoyalty = feeNumerator;
_setDefaultRoyalty(receiver, feeNumerator);
}

//
// INTERNAL
//
Expand All @@ -495,4 +482,26 @@ contract Archetype is DN404, Initializable, OwnableUpgradeable, ERC2981Upgradeab
revert TransferFailed();
}
}

//ERC2981 ROYALTY
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(DN420, ERC2981Upgradeable)
returns (bool)
{
// Supports the following `interfaceId`s:
// - IERC165: 0x01ffc9a7
// - ERC1155: 0xd9b67a26
// - ERC1155MetadataURI: 0x0e89341c
// - IERC2981: 0x2a55205a
return
DN420.supportsInterface(interfaceId) || ERC2981Upgradeable.supportsInterface(interfaceId);
}

function setDefaultRoyalty(address receiver, uint16 feeNumerator) public _onlyOwner {
config.defaultRoyalty = feeNumerator;
_setDefaultRoyalty(receiver, feeNumerator);
}
}
3 changes: 1 addition & 2 deletions contracts/ArchetypeLogic.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// ArchetypeLogic v0.7.0 - DN404
// ArchetypeLogic v0.8.0 - BRG404
//
// d8888 888 888
// d88888 888 888
Expand Down Expand Up @@ -125,7 +125,6 @@ struct ValidationArgs {

// UPDATE CONSTANTS BEFORE DEPLOY
address constant PLATFORM = 0x86B82972282Dd22348374bC63fd21620F7ED847B;
address constant DEVVAULT = 0xe9191E06EaA1b32997FFAFB9a2AbBab525518Fa8;
address constant BATCH = 0xEa49e7bE310716dA66725c84a5127d2F6A202eAf;
address constant PAYOUTS = 0xaAfdfA4a935d8511bF285af11A0544ce7e4a1199;
uint16 constant MAXBPS = 5000; // max fee or discount is 50%
Expand Down
8 changes: 3 additions & 5 deletions contracts/Factory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,12 @@ contract Factory is Ownable {
Config calldata config,
PayoutConfig calldata payoutConfig
) external payable returns (address) {
address mirror = address(new DN404Mirror(address(this)));

address clone = ClonesUpgradeable.clone(archetype);
bytes32 salt = keccak256(abi.encodePacked(block.timestamp, msg.sender, block.chainid));
address clone = ClonesUpgradeable.cloneDeterministic(archetype, salt);
Archetype token = Archetype(payable(clone));
token.initialize(name, symbol, config, payoutConfig, mirror, _receiver);
token.initialize(name, symbol, config, payoutConfig, _receiver);

token.transferOwnership(_receiver);
DN404Mirror(payable(mirror)).pullOwner();

if (msg.value > 0) {
(bool sent, ) = payable(_receiver).call{ value: msg.value }("");
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"dependencies": {
"@nomicfoundation/hardhat-verify": "^2.0.4",
"concurrently": "6.4.0",
"dn404": "^0.0.8",
"dn404": "^0.0.19",
"ethereumjs-util": "7.1.4",
"ipfsh": "0.0.6",
"solady": "^0.0.19"
Expand Down
4 changes: 3 additions & 1 deletion test/archetype.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,15 @@ describe("Factory", function () {
factory = await Factory.deploy(archetype.address);
await factory.deployed();

const superAffiliate = (await ethers.getSigners())[4];

DEFAULT_PAYOUT_CONFIG = {
ownerBps: 9000,
platformBps: 500,
partnerBps: 0,
superAffiliateBps: 500,
partner: ZERO,
superAffiliate: await archetype.devVault(),
superAffiliate: superAffiliate.address,
};

console.log({ factoryAddress: factory.address, archetypeAddress: archetype.address });
Expand Down